Changed Notification class to Message.
[situare] / src / situareservice / situareservice.h
index 1e62f8e..92f5a90 100644 (file)
@@ -3,6 +3,7 @@
    Copyright (C) 2010  Ixonos Plc. Authors:
 
       Henri Lampela - henri.lampela@ixonos.com
+      Jussi Laitinen - jussi.laitinen@ixonos.com
 
    Situare is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -49,11 +50,17 @@ class SituareService : public QObject
 public:
 
     /**
+    * Unit test class
+    */
+    friend class TestSituareService;
+
+    /**
     * @brief Default constructor
     *
     * @param parent instance of parent
     */
-    SituareService(QObject *parent = 0);
+    SituareService(NetworkAccessManager *networkManager, ImageFetcher *imageFetcher,
+                   QObject *parent = 0);
 
     /**
     * @brief Destructor
@@ -64,7 +71,6 @@ public:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-
     /**
     * @brief Retrieves people with similart interest (same tags).
     *
@@ -82,11 +88,6 @@ public:
     void fetchLocations();
 
     /**
-    * @brief Retrieves messages sent to user.
-    */
-    void fetchMessages();
-
-    /**
     * @brief Translates coordinates to street address via Situare server
     *
     * @param coordinates coordinates to be translated
@@ -112,6 +113,10 @@ public:
     void updateTags(const QString &userId, const QStringList &tags);
 
 public slots:
+    /**
+    * @brief Retrieves messages sent to user.
+    */
+    void fetchMessages();
 
     /**
     * @brief Public slot, to clear user data
@@ -133,15 +138,22 @@ public slots:
     */
     void requestFinished(QNetworkReply *reply);
 
-private:
+    /**
+    * @brief Sends a message to a person.
+    *
+    * @param receiverId Facebook user ID
+    * @param message message text
+    */
+    void sendMessage(const QString &receiverId, const QString &message);
 
+private:
     /**
     * @brief Requests ImageFetcher if user/friend has a profile image
     *        uses members: m_user and m_friendsList
     *
     * @param imageUrlList list of image urls
     */
-    void addProfileImages(const QList<QUrl> &imageUrlList);
+    void addProfileImages(const QHash<QString, QUrl> &imageUrlList);
 
     /**
     * @brief Forms a http cookie
@@ -191,6 +203,21 @@ private:
     QStringList getTags(const QString &userId);
 
     /**
+    * @brief Parses interesting people data from JSON string
+    *
+    * @param jsonReply JSON string
+    */
+    void parseInterestingPeopleData(const QByteArray &jsonReply);
+
+    /**
+    * @brief Parses messages data from JSON string
+    *
+    * @param jsonReply JSON string
+    */
+    void parseMessagesData(const QByteArray &jsonReply);
+
+
+    /**
     * @brief Parses user and friend data from JSON string
     *
     * @param jsonReply JSON string
@@ -210,10 +237,10 @@ private slots:
     /**
     * @brief Slot for received images
     *
-    * @param url Image url
-    * @param image Received image
+    * @param id image ID
+    * @param image image pixmap
     */
-    void imageReceived(const QUrl &url, const QPixmap &image);
+    void imageReceived(const QString &id, const QPixmap &image);
 
 /*******************************************************************************
  * SIGNALS
@@ -230,9 +257,10 @@ signals:
     /**
     * @brief Signal for image fetching
     *
+    * @param id Image id
     * @param url Image url
     */
-    void fetchImage(const QUrl &url);
+    void fetchImage(const QString &id, const QUrl &url);
 
     /**
     * @brief Signals when user's/friend's image is downloaded
@@ -242,11 +270,19 @@ signals:
     void imageReady(User *user);
 
     /**
+    * @brief Signals when image is downloaded
+    *
+    * @param id image ID
+    * @param image image pixmap
+    */
+    void imageReady(const QString &id, const QPixmap &image);
+
+    /**
     * @brief Signal when fetchPeopleWithSimilarInterest request is finished
     *
     * @param interestingPeople list of interesting people
     */
-    void interestingPeopleReceived(QList<User *> &interestingPeople);
+    void interestingPeopleReceived(QList<User> &interestingPeople);
 
     /**
     * @brief Signal when fetchMessages request is finished
@@ -279,9 +315,7 @@ signals:
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
-
 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