Integrated updateLocation, it currently uses hardcoded coordinates.
authorlampehe-local <henri.lampela@ixonos.com>
Tue, 27 Apr 2010 06:20:48 +0000 (09:20 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Tue, 27 Apr 2010 06:20:48 +0000 (09:20 +0300)
Fixed facebookcredentials when expire value is 0 (infinite).

src/engine/engine.cpp
src/engine/engine.h
src/facebookservice/facebookauthentication.cpp
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/listviewscreen.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/updatelocation/updatelocationdialog.cpp
src/ui/updatelocation/updatelocationdialog.h

index f50d98a..dddbc58 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Kaj Wallin - kaj.wallin@ixonos.com
+        Henri Lampela - henri.lampela@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -32,8 +33,14 @@ SituareEngine::SituareEngine(QMainWindow *parent)
 
     m_loggedIn = false;
     m_facebookAuthenticator = new FacebookAuthentication();
+
     connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOk()));
     connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
+
+    connect(m_ui, SIGNAL(requestReverseGeo()), this, SLOT(requestAddress()));
+    connect(m_situareService, SIGNAL(reverseGeoReady(QString)), m_ui, SIGNAL(reverseGeoReady(QString)));
+    connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool)));
+
     start();
 }
 
@@ -69,6 +76,20 @@ void SituareEngine::loginScreenClosed()
     }
 }
 
+void SituareEngine::requestAddress()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    QPointF coordinates(65, 25.5); // this will be get from somewhere, map etc...
+    m_situareService->reverseGeo(coordinates);
+}
+
+void SituareEngine::requestUpdateLocation(const QString &status, const bool &publish)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    QPointF coordinates(65, 25.5); // this will be get from somewhere, map etc...
+    m_situareService->updateLocation(coordinates, status, publish);
+}
+
 void SituareEngine::updateFriendsList()
 {
     qDebug() << __PRETTY_FUNCTION__;
index cc98c1a..70bcf40 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Kaj Wallin - kaj.wallin@ixonos.com
+        Henri Lampela - henri.lampela@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -69,11 +70,26 @@ public slots:
     */
     void loginScreenClosed();
 
-    /**#include "engine/engine.h"
+    /**
     * @brief Slot to intercept signal from successful login
     */
     void loginOk();
 
+    /**
+    * @brief Calls reverseGeo from SituareService to translate coordinates to street address
+    *
+    */
+    void requestAddress();
+
+    /**
+    * @brief Calls updateLocation from SituareService to send the location update to
+    *        Situare server.
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook
+    */
+    void requestUpdateLocation(const QString &status, const bool &publish);
+
     void updateFriendsList();
 
 /*******************************************************************************
index e00d23f..d04a2cf 100644 (file)
@@ -232,18 +232,25 @@ void FacebookAuthentication::readCredentials(FacebookCredentials &credentialsFro
  bool FacebookAuthentication::verifyCredentials(const FacebookCredentials &credentials) const
  {
      qDebug() << __PRETTY_FUNCTION__;
-     QString expires = credentials.expires();
-     QDateTime expireTime;
-     expireTime.setTime_t(expires.toInt());
-     QString expiresString = expireTime.toString("dd.MM.yyyy  hh:mm:ss");
-     qDebug() << expiresString.toAscii();
-
-     QDateTime currentTime;
-     currentTime = QDateTime::currentDateTime();
-     QString currentTimeString = currentTime.toString("dd.MM.yyyy  hh:mm:ss");
-     qDebug() << currentTimeString.toAscii();
-
-     return currentTime < expireTime;
+
+     // if expires value is 0, then credentials are valid forever
+     if(credentials.expires() == "0") {
+         return true;
+     }
+     else {
+         QString expires = credentials.expires();
+         QDateTime expireTime;
+         expireTime.setTime_t(expires.toInt());
+         QString expiresString = expireTime.toString("dd.MM.yyyy  hh:mm:ss");
+         qDebug() << expiresString.toAscii();
+
+         QDateTime currentTime;
+         currentTime = QDateTime::currentDateTime();
+         QString currentTimeString = currentTime.toString("dd.MM.yyyy  hh:mm:ss");
+         qDebug() << currentTimeString.toAscii();
+
+         return currentTime < expireTime;
+     }
  }
 
  void FacebookAuthentication::closeEvent(QCloseEvent *event)
index 1f98fc3..f801cd2 100644 (file)
@@ -206,13 +206,15 @@ void SituareService::requestFinished(QNetworkReply *reply)
             qDebug() << "JSON string";
             parseUserData(replyArray);
         }
+        else if(replyArray == "") {
+            qDebug() << "No error, update was successful";
+        }
         else {
-            // no error -> update was successful
-            // ToDo: signal UI?
-            qDebug() << reply->read(max);
+            // Street address ready
+            QString address(replyArray);
+            emit reverseGeoReady(address);
         }
     }
-
     m_currentRequests.removeAll(reply);
     reply->deleteLater();
 }
index 35998ca..e574b71 100644 (file)
@@ -60,9 +60,9 @@ public:
     */
     ~SituareService();
 
-    /*******************************************************************************
-     * MEMBER FUNCTIONS AND SLOTS
-     ******************************************************************************/
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
 
     /**
     * @brief Retrieves location user and friends information from Situare server
@@ -139,9 +139,9 @@ private:
     */
     void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
 
-    /*******************************************************************************
-     * SIGNALS
-     ******************************************************************************/
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
 
 signals:
 
@@ -152,6 +152,12 @@ signals:
     */
     void error(const QString &error);
 
+    /**
+    * @brief Signals when address data is retrieved
+    *
+    * @param address Street address
+    */
+    void reverseGeoReady(const QString &address);
 
     /**
     * @brief Signals when user data is retrieved
@@ -161,9 +167,9 @@ signals:
     */
     void userDataChanged(User &user, QList<User *> &friendList);
 
-    /*******************************************************************************
-     * DATA MEMBERS
-     ******************************************************************************/
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
 
 private:
 
index 5080439..6e4d8dc 100644 (file)
@@ -95,7 +95,7 @@ ListViewScreen::ListViewScreen(QWidget *parent)
     m_vbox->addWidget(view);
     m_vbox->setMargin(0);
 
-    connect(m_personalInfo,SIGNAL(launchMessageUpdate()),this,SLOT(updateMessage()));
+    //connect(m_personalInfo,SIGNAL(launchMessageUpdate()),this,SLOT(updateMessage()));
 }
 
 ListViewScreen::~ListViewScreen()
index 959ec89..035ba02 100644 (file)
@@ -42,6 +42,9 @@ MainWindow::MainWindow(QWidget *parent)
     connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
             this,SLOT(openLocationUpdateDialog()));
 
+    connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
+    connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
+            SIGNAL(statusUpdate(QString,bool)));
 }
 
 MainWindow::~MainWindow()
@@ -113,5 +116,7 @@ void MainWindow::switchView(int nextIndex)
 void MainWindow::openLocationUpdateDialog()
 {
     qDebug() << __PRETTY_FUNCTION__;
+
+    emit requestReverseGeo();
     m_locationDialog->exec();
 }
index fe61dde..b0f28e7 100644 (file)
@@ -31,7 +31,6 @@
 #include "facebookservice/facebookauthentication.h"
 #include "situareservice/situareservice.h"
 #include <QNetworkAccessManager>
-//#include "engine/engine.h"
 #include "listviewscreen.h"
 #include "mapviewscreen.h"
 #include "updatelocation/updatelocationdialog.h"
@@ -95,22 +94,53 @@ private:
     void switchView(int);
 
 private slots:
+
+    /**
+    * @brief Private slot, which starts UpdateLocationDialog
+    *
+    */
     void openLocationUpdateDialog();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+
+signals:
+
+    /**
+    * @brief Signal for requesting reverseGeo from SituareEngine
+    *
+    */
+    void requestReverseGeo();
+
+    /**
+    * @brief Signals, when address data is ready
+    *
+    * @param address Street address
+    */
+    void reverseGeoReady(const QString &address);
+
+    /**
+    * @brief Signal for requestLocationUpdate from SituareEngine
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook
+    */
+    void statusUpdate(const QString &status, const bool &publish);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 
 private:
-//    SituareEngine *m_situareEngine;
 
     ListViewScreen *m_listViewScreen;
+    UpdateLocationDialog *m_locationDialog; ///< Message dialog
     MapViewScreen *m_mapViewScreen;
     QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
     QAction *m_toListViewAct; ///< Action to trigger switch to list view
     QAction *m_toMapViewAct; ///< Action to trigger switch to map view
     QMenu *m_viewMenu; ///< Object that hold the view menu items
-
-    UpdateLocationDialog *m_locationDialog; ///< Message dialog
 };
 
 #endif // MAINWINDOW_H
index 930b754..e4613d9 100755 (executable)
@@ -3,6 +3,7 @@
    Copyright (C) 2010  Ixonos Plc. Authors:
 
       Katri Kaikkonen - katri.kaikkonen@ixonos.com
+      Henri Lampela - henri.lampela@ixonos.com
 
    Situare is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -19,7 +20,6 @@
    USA.
 */
 
-#include <QtGui>
 #include <QDebug>
 #include "updatelocationdialog.h"
 
@@ -32,16 +32,16 @@ UpdateLocationDialog::UpdateLocationDialog(QWidget *parent)
     QGridLayout *gridLayout = new QGridLayout(this);
     QGroupBox *groupBox = new QGroupBox(scrollArea);
 
-    QTextEdit *m_textEdit = new QTextEdit;
-    QLineEdit *m_lineEdit = new QLineEdit;
-    QCheckBox *m_checkBox = new QCheckBox(tr("Publish in Fabebook"));
+    m_textEdit = new QTextEdit;
+    m_locationLabel = new QLabel;
+    m_checkBox = new QCheckBox(tr("Publish in Facebook"));
 
-    QPushButton *m_okButton = new QPushButton(tr("Send"));
-    QDialogButtonBox *m_buttonBox = new QDialogButtonBox(Qt::Vertical);
+    m_okButton = new QPushButton(tr("Send"));
+    m_buttonBox = new QDialogButtonBox(Qt::Vertical);
     m_buttonBox->addButton(m_okButton, QDialogButtonBox::ActionRole);
 
     QFormLayout *form = new QFormLayout();
-    form->addRow(new QLabel(tr("Location:")), m_lineEdit);
+    form->addRow(new QLabel(tr("Location:")), m_locationLabel);
     form->addRow(new QLabel(tr("Message:")), m_textEdit);
     form->addWidget(m_checkBox);
 
@@ -54,5 +54,23 @@ UpdateLocationDialog::UpdateLocationDialog(QWidget *parent)
     gridLayout->addWidget(m_buttonBox, 0, 1, 1, 1);
     setLayout(gridLayout);
 
+    connect(m_okButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
+
     scrollArea->show();
 }
+
+void UpdateLocationDialog::setAddress(const QString &address)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    m_locationLabel->setText(address);
+}
+
+void UpdateLocationDialog::sendUpdate()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    // coordinates for this call will be get from somewhere, map etc...
+    emit statusUpdate(m_textEdit->toPlainText(), m_checkBox->isChecked());
+
+    this->close();
+}
index 998b86f..7196f3e 100755 (executable)
@@ -3,6 +3,7 @@
    Copyright (C) 2010  Ixonos Plc. Authors:
 
       Katri Kaikkonen - katri.kaikkonen@ixonos.com
+      Henri Lampela - henri.lampela@ixonos.com
 
    Situare is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -23,7 +24,6 @@
 #define UPDATELOCATIONDIALOG_H
 
 #include <QDialog>
-#include <QtGui>
 #ifdef Q_WS_MAEMO_5
 #include <QAbstractKineticScroller>
 #endif // Q_WS_MAEMO_5
@@ -55,12 +55,50 @@ public:
     */
     UpdateLocationDialog(QWidget *parent = 0);
 
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+
+public slots:
+
+    /**
+    * @brief Public slot, which is used to set the street address to location label
+    *
+    * @param address Street address, result from SituareService's reverseGeo
+    */
+    void setAddress(const QString &address);
+
 private slots:
 
+    /**
+    * @brief Private slot, which is used to connect send button
+    *
+    */
+    void sendUpdate();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+
+signals:
+
+    /**
+    * @brief Signal Signal for requestLocationUpdate from SituareEngine via MainWindow class
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook
+    */
+    void statusUpdate(const QString &status, const bool &publish);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+
 private:
+
     QDialogButtonBox *m_buttonBox; ///< Pointer to DialogButtonBox
     QCheckBox *m_checkBox; ///< Pointer to CheckBox
-    QLineEdit *m_lineEdit; ///< Pointer to LineEdit
+    QLabel *m_locationLabel; ///< Pointer to locationLabel
     QPushButton *m_okButton; ///< Pointer to PushButton
     QTextEdit *m_textEdit; ///< Pointer to TextEdit
 };