Documenting and some clean-up
authorSami Rämö <sami.ramo@ixonos.com>
Tue, 9 Nov 2010 12:18:56 +0000 (14:18 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Tue, 9 Nov 2010 12:18:56 +0000 (14:18 +0200)
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/mainwindow.h

index 40f4309..6863324 100644 (file)
@@ -88,13 +88,6 @@ void FacebookAuthentication::destroyLogin()
     m_browser->deleteLater();
 }
 
-void FacebookAuthentication::loadFinished(bool ok)
-{
-    qWarning() << __PRETTY_FUNCTION__ << ok;
-
-    ///< @todo show browsed window if url != redirect url
-}
-
 void FacebookAuthentication::login()
 {
     qWarning() << __PRETTY_FUNCTION__;
index 3699687..b1c1d11 100644 (file)
@@ -46,12 +46,12 @@ class FacebookAuthentication : public QObject
 
 public:
     /**
-    * @brief FacebookAuthentication constructor
+    * @brief Constructor
     *
-    * -Checks if there is valid credentials stored on the file. If there is emits signal.
+    * Initiates internal data members.
     *
     * @param mainWindow MainWindow instance
-    * @param parent instance of parent
+    * @param parent Instance of the parent
     */
     FacebookAuthentication(MainWindow *mainWindow, QObject *parent = 0);
 
@@ -59,29 +59,59 @@ public:
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public:
+    /**
+      * @brief Initiate login process
+      *
+      * Builds login browser and starts loading login URL.
+      */
     void login();
 
 public slots:
 
     /**
-    * @brief Clears account iformation from settings
+    * @brief Clears account information from settings
     *
     * @param keepUsername keep = true, false otherwise
     */
     void clearAccountInformation(bool keepUsername = false);
 
 private:
+    /**
+      * @brief Destroy login dialog and browser
+      */
     void destroyLogin();
 
+    /**
+      * @brief Parses the session information from the URL
+      *
+      * @param url URL
+      * @returns Parsed session, or empty string if parsing failed.
+      */
     QString parseSession(const QUrl &url);
 
 private slots:
+    /**
+      * @brief Cleanup after browser is destructed
+      *
+      * Clears the pointer to the browser and disables the progress indicator.
+      */
     void browserDestroyed();
 
-    void loadFinished(bool ok);
-
+    /**
+      * @brief Handler for login page loading errors
+      *
+      * @param reply Network reply
+      */
     void networkReplyHandler(QNetworkReply *reply);
 
+    /**
+      * @brief Handler for browser URL changes
+      *
+      * Does check the new URL and based on that invokes the login dialog with visible browser view
+      * or parses the session from the new URL.
+      *
+      * @param url New URL
+      */
     void urlChanged(const QUrl &url);
 
 /*******************************************************************************
@@ -96,14 +126,19 @@ signals:
     */
     void error(const int context, const int error);
 
+    /**
+      * @brief Emitted when logged in successfully
+      *
+      * @param session Session data
+      */
     void loggedIn(const QString session);
 
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QWebView *m_browser;
-    MainWindow *m_mainWindow;
+    QWebView *m_browser;            ///< Login browser
+    MainWindow *m_mainWindow;       ///< MainWindow
 };
 
 #endif // FACEBOOKAUTHENTICATION_H
index 538d432..fd0aea6 100644 (file)
@@ -80,10 +80,7 @@ void SituareService::appendAccessToken(QString &requestUrl)
 {
     qWarning() << __PRETTY_FUNCTION__;
 
-//    requestUrl.append("access_token=");
     requestUrl.append(m_session);
-
-//    qWarning() << __PRETTY_FUNCTION__ << "request url with parameters and access token:" << requestUrl;
 }
 
 void SituareService::buildRequest(const QString &script, const QHash<QString, QString> &parameters)
@@ -238,20 +235,15 @@ QString SituareService::formUrlParameters(const GeoCoordinate &coordinates, QStr
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    // one scene pixel is about 5.4e-6 degrees, the integer part is max three digits and one
-    // additional digit is added for maximum precision
-    const int COORDINATE_PRECISION = 10;
-
     QString parameters;
-
     parameters.append(QUESTION_MARK);
     parameters.append(LATITUDE);
     parameters.append(EQUAL_MARK);
-    parameters.append(QString::number(coordinates.latitude(), 'f', COORDINATE_PRECISION));
+    parameters.append(degreesToString(coordinates.latitude()));
     parameters.append(AMBERSAND_MARK);
     parameters.append(LONGTITUDE);
     parameters.append(EQUAL_MARK);
-    parameters.append(QString::number(coordinates.longitude(), 'f', COORDINATE_PRECISION));
+    parameters.append(degreesToString(coordinates.longitude()));
 
     parameters.append(AMBERSAND_MARK);
     parameters.append(PUBLISH);
index a860340..a85127c 100644 (file)
@@ -100,6 +100,11 @@ public slots:
     */
     void requestFinished(QNetworkReply *reply);
 
+    /**
+      * @brief Update session data
+      *
+      * @param session New session data
+      */
     void updateSession(const QString &session);
 
 private:
@@ -112,8 +117,19 @@ private:
     */
     void addProfileImages(const QList<QUrl> &imageUrlList);
 
+    /**
+      * @brief Append access_token and other session data to the reques url
+      *
+      * @param[in,out] requestUrl Request URL with other request parameters and ending to &
+      */
     void appendAccessToken(QString &requestUrl);
 
+    /**
+      * @brief Convert coordinate value in degrees (double) to string with enough precision
+      *
+      * @param degrees Coordinate value in degrees
+      * @returns Coordinate value as string
+      */
     QString degreesToString(double degrees);
 
     /**
@@ -170,13 +186,25 @@ private:
     */
     void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
 
-
+    /**
+      * @brief Build and send request
+      *
+      * Appends script pathname and parameters to the server base URL. Access token is appended and
+      * the request sent if the access token is available, otherwise the request is queued.
+      *
+      * @param script Requested script pathname
+      * @param parameters Hash containing parameter key/value pairs.
+      */
     void buildRequest(const QString &script, const QHash<QString,QString> &parameters);
 
+    /**
+      * @brief Send request
+      *
+      * @param requestUrl Request URL containing also all parameters
+      */
     void sendRequest(const QString &requestUrl);
 
 private slots:
-
     /**
     * @brief Slot for received images
     *
@@ -242,13 +270,13 @@ private:
 
     bool m_defaultImage;    ///< Indicates if some of the friends/user doesn't have a image
 
-    QList<QNetworkReply *> m_currentRequests;   ///< List of current http requests
-    QList<QString> m_requestsWaitingAccessToken;
-    QList<User *> m_friendsList;                ///< List of friends(User)
+    QList<QNetworkReply *> m_currentRequests;       ///< List of current http requests
+    QList<QString> m_requestsWaitingAccessToken;    ///< Requests waiting for access_token
+    QList<User *> m_friendsList;                    ///< List of friends(User)
 
-    QString m_session;
+    QString m_session;                          ///< Session data
 
-    NetworkAccessManager *m_networkManager;    ///< Pointer to QNetworkAccessManager
+    NetworkAccessManager *m_networkManager;     ///< Pointer to QNetworkAccessManager
 
     ImageFetcher *m_imageFetcher;               ///< Instance of the image fetcher
     User *m_user;                               ///< Pointer to User
index 14f5402..f9a1a13 100644 (file)
@@ -93,6 +93,11 @@ private:
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public:
+    /**
+      * @brief Build and show login dialog with login browser
+      *
+      * @param browser Login browser instance
+      */
     void buildLoginDialog(QWebView *browser);
 
     /**
@@ -160,6 +165,9 @@ public slots:
      */
     void buildInformationBox(const QString &message, bool modal=false);
 
+    /**
+      * @brief Hides and deletes login dialog
+      */
     void destroyLoginDialog();
 
     /**