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__;
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);
* 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);
/*******************************************************************************
*/
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
{
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> ¶meters)
{
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);
*/
void requestFinished(QNetworkReply *reply);
+ /**
+ * @brief Update session data
+ *
+ * @param session New session data
+ */
void updateSession(const QString &session);
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);
/**
*/
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> ¶meters);
+ /**
+ * @brief Send request
+ *
+ * @param requestUrl Request URL containing also all parameters
+ */
void sendRequest(const QString &requestUrl);
private slots:
-
/**
* @brief Slot for received images
*
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
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
public:
+ /**
+ * @brief Build and show login dialog with login browser
+ *
+ * @param browser Login browser instance
+ */
void buildLoginDialog(QWebView *browser);
/**
*/
void buildInformationBox(const QString &message, bool modal=false);
+ /**
+ * @brief Hides and deletes login dialog
+ */
void destroyLoginDialog();
/**