Added fuction for checking username registration on the server.
authorTiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
Wed, 17 Mar 2010 09:32:56 +0000 (11:32 +0200)
committerToni Jussila <toni.jussila@fudeco.com>
Wed, 17 Mar 2010 09:54:48 +0000 (11:54 +0200)
Client/UI.pro
Client/UI.pro.user
Client/carmainwindow.cpp
Client/carmainwindow.h
Client/httpclient.cpp
Client/httpclient.h
Client/ui_carmainwindow.h
Client/ui_resultdialog.h

index e630312..134e417 100644 (file)
@@ -28,6 +28,7 @@ SOURCES += main.cpp \
     maemo5locationprivate.cpp \
     maemo5location.cpp \
     routedialog.cpp
+
 HEADERS += carmainwindow.h \
     resultdialog.h \
     stringlistmodel.h \
@@ -46,12 +47,12 @@ HEADERS += carmainwindow.h \
     maemo5locationprivate.h \
     maemo5location.h \
     routedialog.h
+
 FORMS += carmainwindow.ui \
     resultdialog.ui \
     measuredialog.ui \
     loginwindow.ui \
     registration.ui \
-    welcomedialog.ui
     welcomedialog.ui \
     routedialog.ui
 
index c86a445..f4af51a 100644 (file)
   <variable>buildconfiguration-Debug-buildstep0</variable>
   <valuemap type="QVariantMap">
    <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+   <valuelist key="abstractProcess.Environment" type="QVariantList">
+    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-51tDZ2Xnqs,guid=d9736a446700e43c64f1e7f04ba083b3</value>
+    <value type="QString">DESKTOP_SESSION=gnome</value>
+    <value type="QString">DISPLAY=:0.0</value>
+    <value type="QString">GDMSESSION=gnome</value>
+    <value type="QString">GDM_KEYBOARD_LAYOUT=fi       classic</value>
+    <value type="QString">GDM_LANG=en_US.UTF-8</value>
+    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
+    <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-GEEl2F/socket</value>
+    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
+    <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/tkk/.gtkrc-1.2-gnome2</value>
+    <value type="QString">HOME=/home/tkk</value>
+    <value type="QString">LANG=en_US.UTF-8</value>
+    <value type="QString">LD_LIBRARY_PATH=/home/tkk/qtsdk-2010.01/lib/qtcreator:</value>
+    <value type="QString">LOGNAME=tkk</value>
+    <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-tkk</value>
+    <value type="QString">PATH=/home/tkk/qtsdk-2010.01/qt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
+    <value type="QString">PWD=/home/tkk/qtsdk-2010.01/bin</value>
+    <value type="QString">QTDIR=/home/tkk/qtsdk-2010.01/qt</value>
+    <value type="QString">SESSION_MANAGER=local/tkk-laptop:@/tmp/.ICE-unix/1211,unix/tkk-laptop:/tmp/.ICE-unix/1211</value>
+    <value type="QString">SHELL=/bin/bash</value>
+    <value type="QString">SPEECHD_PORT=7560</value>
+    <value type="QString">SSH_AGENT_PID=1380</value>
+    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-GEEl2F/socket.ssh</value>
+    <value type="QString">USER=tkk</value>
+    <value type="QString">USERNAME=tkk</value>
+    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-tkk-r3DlIx/database</value>
+    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
+    <value type="QString">XDG_SESSION_COOKIE=cac5a30ec2a4b235840876964b6a848d-1268810656.39871-1736995145</value>
+   </valuelist>
+   <valuelist key="abstractProcess.arguments" type="QVariantList">
+    <value type="QString">/home/tkk/speedfreak/Client/UI.pro</value>
+    <value type="QString">-spec</value>
+    <value type="QString">linux-g++</value>
+    <value type="QString">-r</value>
+    <value type="QString">CONFIG+=debug</value>
+   </valuelist>
+   <value key="abstractProcess.command" type="QString">/home/tkk/qtsdk-2010.01/qt/bin/qmake</value>
+   <value key="abstractProcess.enabled" type="bool">true</value>
+   <value key="abstractProcess.workingDirectory" type="QString">/home/tkk/speedfreak/Client</value>
   </valuemap>
  </data>
  <data>
   <variable>buildconfiguration-Debug-buildstep1</variable>
   <valuemap type="QVariantMap">
    <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+   <valuelist key="abstractProcess.Environment" type="QVariantList">
+    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-51tDZ2Xnqs,guid=d9736a446700e43c64f1e7f04ba083b3</value>
+    <value type="QString">DESKTOP_SESSION=gnome</value>
+    <value type="QString">DISPLAY=:0.0</value>
+    <value type="QString">GDMSESSION=gnome</value>
+    <value type="QString">GDM_KEYBOARD_LAYOUT=fi       classic</value>
+    <value type="QString">GDM_LANG=en_US.UTF-8</value>
+    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
+    <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-GEEl2F/socket</value>
+    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
+    <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/tkk/.gtkrc-1.2-gnome2</value>
+    <value type="QString">HOME=/home/tkk</value>
+    <value type="QString">LANG=en_US.UTF-8</value>
+    <value type="QString">LD_LIBRARY_PATH=/home/tkk/qtsdk-2010.01/lib/qtcreator:</value>
+    <value type="QString">LOGNAME=tkk</value>
+    <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-tkk</value>
+    <value type="QString">PATH=/home/tkk/qtsdk-2010.01/qt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
+    <value type="QString">PWD=/home/tkk/qtsdk-2010.01/bin</value>
+    <value type="QString">QTDIR=/home/tkk/qtsdk-2010.01/qt</value>
+    <value type="QString">SESSION_MANAGER=local/tkk-laptop:@/tmp/.ICE-unix/1211,unix/tkk-laptop:/tmp/.ICE-unix/1211</value>
+    <value type="QString">SHELL=/bin/bash</value>
+    <value type="QString">SPEECHD_PORT=7560</value>
+    <value type="QString">SSH_AGENT_PID=1380</value>
+    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-GEEl2F/socket.ssh</value>
+    <value type="QString">USER=tkk</value>
+    <value type="QString">USERNAME=tkk</value>
+    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-tkk-r3DlIx/database</value>
+    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
+    <value type="QString">XDG_SESSION_COOKIE=cac5a30ec2a4b235840876964b6a848d-1268810656.39871-1736995145</value>
+   </valuelist>
+   <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
+   <valuelist key="abstractProcess.arguments" type="QVariantList">
+    <value type="QString">-w</value>
+   </valuelist>
+   <value key="abstractProcess.command" type="QString">/usr/bin/make</value>
+   <value key="abstractProcess.enabled" type="bool">true</value>
+   <value key="abstractProcess.workingDirectory" type="QString">/home/tkk/speedfreak/Client</value>
   </valuemap>
  </data>
  <data>
index e5f35f8..5b1e1f4 100644 (file)
@@ -33,7 +33,7 @@ CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::Ca
     myHttpClient = new HttpClient(this);
     myRegistration = new Registration(this);
     connect(myRegistration,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
-
+    connect(myLogin,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
     myRoute = new RouteDialog( this);
 
     time = 0;
@@ -424,7 +424,15 @@ void CarMainWindow::regUserToServer()
     myHttpClient->requestRegistration();
 }
 
+<<<<<<< HEAD:Client/carmainwindow.cpp
 void CarMainWindow::on_drawRoutePushButton_clicked()
 {
     myRoute->show();
 }
+
+=======
+>>>>>>> Added fuction for checking username registration on the server.:Client/carmainwindow.cpp
+void CarMainWindow::userLogin()
+{
+    myHttpClient->checkLogin();
+}
index 6e6582b..a65818f 100644 (file)
@@ -107,6 +107,7 @@ private slots:
     void after_timeout();
     void updateUserName();
     void regUserToServer();
+    void userLogin();
 };
 
 #endif // CARMAINWINDOW_H
index ea44e7a..5a25562 100644 (file)
@@ -135,6 +135,29 @@ void HttpClient::requestCategories()
 
 
 /**
+  *@brief Check that username and password exist on the server.
+  *Send authentication information in the header.
+  */
+void HttpClient::checkLogin()
+{
+    qDebug() << "_checkLogin";
+
+    QUrl qurl("http://api.speedfreak-app.com/api/login/");
+    qDebug() << qurl.toString();
+    QNetworkRequest request(qurl);
+    QNetworkReply *currentDownload;
+
+    QString credentials = myMainw->myRegistration->getUserName() + ":" + myMainw->myRegistration->getPassword();
+    credentials = "Basic " + credentials.toAscii().toBase64();
+    request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
+
+    currentDownload = netManager->post(request, ("data=" ));
+    connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfLogin()));
+    //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+}
+
+
+/**
   *@brief React to servers responce after result has been sent.
   *@todo Implement consequencies of reply.
   */
@@ -205,6 +228,31 @@ void HttpClient::ackOfCategories()
 
 }
 
+
+/**
+  *@brief React to servers responce after request of TopList in certain category has been sent.
+  *@todo Implement routing reply`s contents to UI.
+  */
+void HttpClient::ackOfLogin()
+{
+    qDebug() << "_ackOffLogin";
+
+    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
+    myXmlreader->xmlReadTop10Results(reply);
+
+    QNetworkReply::NetworkError errorcode;
+    errorcode = reply->error();
+    if(errorcode != 0) {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        QMessageBox::about(myMainw, "Server does not recognize your username. Please registrate.",reply->errorString());
+    }
+    else {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        QMessageBox::about(myMainw, "Server reply to login", "User login " + reply->readAll());
+    }
+}
+
+
 /**
   *@brief Reports errors, when server has sent error signal.
   */
index f01f23b..decff1b 100644 (file)
@@ -24,15 +24,18 @@ class HttpClient : public QObject
 public:
     HttpClient(CarMainWindow *myCarw);
     ~HttpClient();
+    XmlWriter *myXmlwriter;
+    XmlReader *myXmlreader;
 
 private:
     CarMainWindow *myMainw;
     QNetworkAccessManager *netManager;
-    XmlWriter *myXmlwriter;
-    XmlReader *myXmlreader;
+    //XmlWriter *myXmlwriter;
+    //XmlReader *myXmlreader;
 
 public slots:
     void requestRegistration();
+    void checkLogin();
     void sendResultXml();
     void requestTopList(QString category, QString limit);
     void requestCategories();
@@ -40,6 +43,7 @@ public slots:
     void ackOfRegistration();
     void ackOfCategories();
     void ackOfToplist();
+    void ackOfLogin();
     void errorFromServer(QNetworkReply::NetworkError);
 
 };
index 094cc08..ec4b824 100644 (file)
@@ -1,7 +1,7 @@
 /********************************************************************************
 ** Form generated from reading UI file 'carmainwindow.ui'
 **
-** Created: Mon Mar 15 13:03:04 2010
+** Created: Wed Mar 17 10:18:14 2010
 **      by: Qt User Interface Compiler version 4.6.1
 **
 ** WARNING! All changes made in this file will be lost when recompiling UI file!
@@ -14,6 +14,7 @@
 #include <QtGui/QAction>
 #include <QtGui/QApplication>
 #include <QtGui/QButtonGroup>
+#include <QtGui/QCheckBox>
 #include <QtGui/QComboBox>
 #include <QtGui/QHeaderView>
 #include <QtGui/QLabel>
@@ -69,6 +70,11 @@ public:
     QLabel *labelMeasureTabSpeed;
     QLabel *labelMeasureTabResultHeader_2;
     QLabel *labelMeasureTabResult;
+    QWidget *tab;
+    QCheckBox *gpsOnCheckBox;
+    QPushButton *startRecPushButton;
+    QPushButton *stopRecPushButton;
+    QPushButton *drawRoutePushButton;
     QPushButton *registratePushButton;
     QMenuBar *menuBar;
     QToolBar *mainToolBar;
@@ -249,6 +255,21 @@ public:
         labelMeasureTabResult->setGeometry(QRect(570, 60, 61, 61));
         labelMeasureTabResult->setFont(font6);
         tabWidget->addTab(tabMeasureResult, QString());
+        tab = new QWidget();
+        tab->setObjectName(QString::fromUtf8("tab"));
+        gpsOnCheckBox = new QCheckBox(tab);
+        gpsOnCheckBox->setObjectName(QString::fromUtf8("gpsOnCheckBox"));
+        gpsOnCheckBox->setGeometry(QRect(20, 20, 94, 22));
+        startRecPushButton = new QPushButton(tab);
+        startRecPushButton->setObjectName(QString::fromUtf8("startRecPushButton"));
+        startRecPushButton->setGeometry(QRect(30, 76, 151, 51));
+        stopRecPushButton = new QPushButton(tab);
+        stopRecPushButton->setObjectName(QString::fromUtf8("stopRecPushButton"));
+        stopRecPushButton->setGeometry(QRect(30, 150, 151, 51));
+        drawRoutePushButton = new QPushButton(tab);
+        drawRoutePushButton->setObjectName(QString::fromUtf8("drawRoutePushButton"));
+        drawRoutePushButton->setGeometry(QRect(30, 220, 151, 51));
+        tabWidget->addTab(tab, QString());
         registratePushButton = new QPushButton(centralWidget);
         registratePushButton->setObjectName(QString::fromUtf8("registratePushButton"));
         registratePushButton->setGeometry(QRect(520, 370, 231, 41));
@@ -266,7 +287,7 @@ public:
 
         retranslateUi(CarMainWindow);
 
-        tabWidget->setCurrentIndex(3);
+        tabWidget->setCurrentIndex(4);
 
 
         QMetaObject::connectSlotsByName(CarMainWindow);
@@ -299,6 +320,11 @@ public:
         labelMeasureTabResultHeader_2->setText(QApplication::translate("CarMainWindow", "Time:", 0, QApplication::UnicodeUTF8));
         labelMeasureTabResult->setText(QApplication::translate("CarMainWindow", "0", 0, QApplication::UnicodeUTF8));
         tabWidget->setTabText(tabWidget->indexOf(tabMeasureResult), QApplication::translate("CarMainWindow", "Measure", 0, QApplication::UnicodeUTF8));
+        gpsOnCheckBox->setText(QApplication::translate("CarMainWindow", "GPS on", 0, QApplication::UnicodeUTF8));
+        startRecPushButton->setText(QApplication::translate("CarMainWindow", "Start recording", 0, QApplication::UnicodeUTF8));
+        stopRecPushButton->setText(QApplication::translate("CarMainWindow", "Stop recording", 0, QApplication::UnicodeUTF8));
+        drawRoutePushButton->setText(QApplication::translate("CarMainWindow", "Draw route", 0, QApplication::UnicodeUTF8));
+        tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("CarMainWindow", "Route", 0, QApplication::UnicodeUTF8));
         registratePushButton->setText(QApplication::translate("CarMainWindow", "Registrate", 0, QApplication::UnicodeUTF8));
     } // retranslateUi
 
index 1a1f856..3e029b2 100644 (file)
@@ -1,7 +1,7 @@
 /********************************************************************************
 ** Form generated from reading UI file 'resultdialog.ui'
 **
-** Created: Mon Mar 15 13:03:04 2010
+** Created: Wed Mar 17 10:18:14 2010
 **      by: Qt User Interface Compiler version 4.6.1
 **
 ** WARNING! All changes made in this file will be lost when recompiling UI file!