Changed Doxyfile to ignore moc_* 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 #include "../facebookservice/facebookauthentication.h"
33 #include "../facebookservice/facebookcredentials.h"
34
35 /**
36 * @brief SituareService class for communicating with Situare server
37 *
38 * @author Henri Lampela
39 * @class SituareService situareservice.h "situareservice/situareservice.h"
40 */
41 class SituareService : public QObject
42 {
43     Q_OBJECT
44
45 public:
46
47     /**
48     * @brief Default constructor
49     *
50     * @param parent instance of parent
51     * @param manager instance of QNetworkAccessManager
52     */
53     SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
54
55     /**
56     * @brief Destructor
57     *
58     */
59     ~SituareService();
60
61     /**
62     * @brief Updates location to the Situare server
63     *
64     * @param coordinates current cordinates
65     * @param status message
66     * @param publish publish location on Facebook wall (true/false)
67     */
68     void updateLocation(const QPointF &coordinates, const QString &status, const bool &publish);
69
70     /**
71     * @brief Translates coordinates to street address via Situare server
72     *
73     * @param coordinates coordinates to be translated
74     */
75     void reverseGeo(const QPointF &coordinates);
76
77 public slots:
78
79     /**
80     * @brief Public slot, which indicates when http request has been completed
81     *
82     * @param reply storage for http reply
83     */
84     void requestFinished(QNetworkReply *reply);
85
86
87     /**
88     * @brief Public slot, which indicates when facebook credentials are ready
89     *
90     */
91     void credentialsReady();
92
93 private:
94
95     /**
96     * @brief Forms a http url
97     *
98     * @param baseUrl Server url
99     * @param phpScript Server script
100     * @param urlParameters optional parameters for url
101     * @return QUrl formed url
102     */
103     QUrl formUrl(const QString &baseUrl, const QString &phpScript, QString urlParameters = 0);
104
105     /**
106     * @brief Forms url parameters
107     *
108     * @param coordinates current coordinates
109     * @param status optional status message
110     * @param publish optional publish location on Facebook wall (true/false)
111     * @return QString
112     */
113     QString formUrlParameters(const QPointF &coordinates, QString status = 0, QString publish = 0);
114
115     /**
116     * @brief Sends http request
117     *
118     * @param url destination
119     * @param cookieType type of the cookie
120     * @param cookie http cookie
121     */
122     void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
123
124 signals:
125
126     /**
127     * @brief Signals error
128     *
129     * @param error error message
130     */
131     void error(const QString &error);
132
133 private:
134
135     FacebookCredentials m_credentials; ///< handle for FacebookCredentials
136     QList<QNetworkReply *> m_currentRequests; ///< List of current http requests
137     FacebookAuthentication m_facebookAuthentication; ///< Pointer to FacebookAuthentication
138     QNetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager
139 };
140
141 #endif // SITUARESERVICE_H