From: Sami Rämö Date: Tue, 9 Nov 2010 12:18:56 +0000 (+0200) Subject: Documenting and some clean-up X-Git-Url: https://vcs.maemo.org/git/?p=situare;a=commitdiff_plain;h=5c278b1afcacc9371e8424b6af64b1cdfd233e61 Documenting and some clean-up --- diff --git a/src/facebookservice/facebookauthentication.cpp b/src/facebookservice/facebookauthentication.cpp index 40f4309..6863324 100644 --- a/src/facebookservice/facebookauthentication.cpp +++ b/src/facebookservice/facebookauthentication.cpp @@ -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__; diff --git a/src/facebookservice/facebookauthentication.h b/src/facebookservice/facebookauthentication.h index 3699687..b1c1d11 100644 --- a/src/facebookservice/facebookauthentication.h +++ b/src/facebookservice/facebookauthentication.h @@ -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 diff --git a/src/situareservice/situareservice.cpp b/src/situareservice/situareservice.cpp index 538d432..fd0aea6 100644 --- a/src/situareservice/situareservice.cpp +++ b/src/situareservice/situareservice.cpp @@ -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 ¶meters) @@ -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); diff --git a/src/situareservice/situareservice.h b/src/situareservice/situareservice.h index a860340..a85127c 100644 --- a/src/situareservice/situareservice.h +++ b/src/situareservice/situareservice.h @@ -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 &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 ¶meters); + /** + * @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 m_currentRequests; ///< List of current http requests - QList m_requestsWaitingAccessToken; - QList m_friendsList; ///< List of friends(User) + QList m_currentRequests; ///< List of current http requests + QList m_requestsWaitingAccessToken; ///< Requests waiting for access_token + QList 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 diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 14f5402..f9a1a13 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -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(); /**