00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Jussi Laitinen - jussi.laitinen@ixonos.com 00006 00007 Situare is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 version 2 as published by the Free Software Foundation. 00010 00011 Situare is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Situare; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 #ifndef NETWORKACCESSMANAGER_H 00023 #define NETWORKACCESSMANAGER_H 00024 00025 #include <QList> 00026 #include <QHash> 00027 #include <QNetworkReply> 00028 #include <QNetworkRequest> 00029 #include <QAbstractNetworkCache> 00030 00031 class NetworkHandler; 00032 class QNetworkAccessManager; 00033 00041 class NetworkAccessManager : public QObject 00042 { 00043 Q_OBJECT 00044 00045 /******************************************************************************* 00046 * MEMBER FUNCTIONS AND SLOTS 00047 ******************************************************************************/ 00048 public: 00054 static NetworkAccessManager *instance(); 00055 00062 QNetworkReply *get(const QNetworkRequest &request); 00063 00069 void setCache(QAbstractNetworkCache *cache); 00070 00076 QAbstractNetworkCache *cache() const; 00077 00078 protected: 00084 NetworkAccessManager(); 00085 00086 private slots: 00090 void connected(); 00091 00097 void downloadFinished(QNetworkReply *reply); 00098 00099 /******************************************************************************* 00100 * SIGNALS 00101 ******************************************************************************/ 00102 signals: 00108 void finished(QNetworkReply *reply); 00109 00110 /******************************************************************************* 00111 * DATA MEMBERS 00112 ******************************************************************************/ 00113 private: 00114 static NetworkAccessManager *m_instance; 00115 NetworkHandler *m_networkHandler; 00116 QNetworkAccessManager *m_networkAccessManagerPrivate; 00117 QList<QNetworkRequest> m_requestQueue; 00118 QHash<QString, QNetworkReply*> m_offlineReplyQueue; 00119 QHash<QString, QNetworkReply*> m_temporaryReplyQueue; 00120 }; 00121 00122 #endif // NETWORKACCESSMANAGER_H