2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
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.
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.
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,
22 #ifndef NETWORKACCESSMANAGER_H
23 #define NETWORKACCESSMANAGER_H
27 #include <QNetworkReply>
28 #include <QNetworkRequest>
29 #include <QAbstractNetworkCache>
32 class QNetworkAccessManager;
35 * @brief NetworkAccessManager class.
37 * This class handles network requests and receives network replies.
38 * NetworkAccessManager queues requests when disconnected from network
39 * and makes requests when connected to network.
41 class NetworkAccessManager : public QObject
45 /*******************************************************************************
46 * MEMBER FUNCTIONS AND SLOTS
47 ******************************************************************************/
50 * @brief Returns instance of NetworkAccessManager.
52 * Creates instance if not created.
54 static NetworkAccessManager *instance();
57 * @brief Makes request and return reply.
59 * @param request QNetworkRequest
60 * @return QNetworkReply
62 QNetworkReply *get(const QNetworkRequest &request);
67 * @param cache QAbstractNetworkCache instance
69 void setCache(QAbstractNetworkCache *cache);
72 * @brief Returns cache.
74 * @return QAbstractNetworkCache
76 QAbstractNetworkCache *cache() const;
82 * Instance of this class can only be created by using instance method.
84 NetworkAccessManager();
88 * @brief Slot for network connected state.
93 * @brief Slot for finished download.
95 * @param reply reply from network
97 void downloadFinished(QNetworkReply *reply);
99 /*******************************************************************************
101 ******************************************************************************/
104 * Signal for finished download.
106 * @param reply reply from network
108 void finished(QNetworkReply *reply);
110 /*******************************************************************************
112 ******************************************************************************/
114 static NetworkAccessManager *m_instance; ///< Instance of NetworkAccessManager
115 NetworkHandler *m_networkHandler; ///< Instance of NetworkHandler
116 QNetworkAccessManager *m_networkAccessManagerPrivate; ///< Instance of QNetworkAccessManager
117 QList<QNetworkRequest> m_requestQueue; ///< Queue for requests
118 QHash<QString, QNetworkReply*> m_offlineReplyQueue; ///< Queue for offline replies
119 QHash<QString, QNetworkReply*> m_temporaryReplyQueue; ///< Queue for temporary replies
122 #endif // NETWORKACCESSMANAGER_H