Added missing files
[situare] / src / situareservice / situareservice.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22
23 #ifndef SITUARESERVICE_H
24 #define SITUARESERVICE_H
25
26 #include <QObject>
27 #include <QPointF>
28 #include <QNetworkAccessManager>
29 #include <QNetworkRequest>
30 #include <QNetworkReply>
31 #include <QUrl>
32
33 /**
34 * @brief SituareService class for communicating with Situare server
35 *
36 * @class SituareService situareservice.h "situareservice/situareservice.h"
37 */
38 class SituareService : public QObject
39 {
40     Q_OBJECT
41
42 public:
43
44     /**
45     * @brief Default constructor
46     *
47     * @fn SituareService
48     * @param parent instance of parent
49     * @param manager instance of QNetworkAccessManager
50     */
51     SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
52     ~SituareService();
53
54     /**
55     * @brief Updates location to the Situare server
56     *
57     * @fn updateLocation
58     * @param coordinates current cordinates
59     * @param status message
60     * @param publish publish location on Facebook wall (true/false)
61     */
62     void updateLocation(QPointF coordinates, QString status, bool publish);
63
64     /**
65     * @brief Forms a http url
66     *
67     * @fn formUrl
68     * @param baseUrl Server url
69     * @param phpScript Server script
70     * @param urlParameters optional parameters for url
71     * @return QUrl formed url
72     */
73     QUrl formUrl(QString baseUrl, QString phpScript, QString urlParameters = 0);
74
75     /**
76     * @brief Forms url parameters
77     *
78     * @fn formUrlParameters
79     * @param coordinates current coordinates
80     * @param status status message
81     * @param publish publish location on Facebook wall (true/false)
82     * @return QString
83     */
84     QString formUrlParameters(QPointF coordinates, QString status, QString publish);
85
86     /**
87     * @brief Forms a http cookie
88     *
89     * @fn formCookie
90     * @param apiKeyValue application key
91     * @param expiresValue session expire date&time from Facebook
92     * @param userValue user id from Facebook
93     * @param sessionKeyValue session key from Facebook
94     * @param sessionSecretValue session secret from Facebook
95     * @param signatureValue md5 generated signature
96     * @param localeValue used locale
97     * @return QString formed cookie
98     */
99     //QString formCookie(QString apiKeyValue, QString expiresValue, QString userValue, QString sessionKeyValue, QString sessionSecretValue, QString signatureValue, QString localeValue);
100
101     /**
102     * @brief Sends http request
103     *
104     * @fn sendRequest
105     * @param url destination
106     * @param cookie http cookie
107     */
108     void sendRequest(QUrl url, QString cookie);
109
110 public slots:
111
112     /**
113     * @brief Public slot, which indicates when http request has been completed
114     *
115     * @fn requestFinished
116     * @param reply storage for http reply
117     */
118     void requestFinished(QNetworkReply *reply);
119
120 private:
121     QNetworkAccessManager *m_manager;
122     QList<QNetworkReply *> currentRequests;
123 };
124
125 #endif // SITUARESERVICE_H