00001 /* 00002 !concept {:name => "Multipart HTTP posting (Qt)", 00003 :desc => "Multipart HTTP(S) POSTing using the QtNetwork API."} 00004 */ 00005 00006 #ifndef __up_uploader_qt_private_hpp__ 00007 #define __up_uploader_qt_private_hpp__ 00008 00009 #include "up_private.h" 00010 00011 #include "ac_app_context.h" 00012 #include "iodeviceseq_qt.hpp" 00013 #include "ut_abs_timer_qt.hpp" 00014 00015 #include <glib.h> 00016 00017 #include <QBuffer> 00018 #include <QFile> 00019 #include <QIODevice> 00020 #include <QNetworkAccessManager> 00021 #include <QNetworkReply> 00022 #include <QNetworkRequest> 00023 #include <QSslConfiguration> 00024 #include <QTimer> 00025 00026 class PostSession : 00027 public QObject 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 QNetworkReply* iNetworkReply; 00033 QFile* iFileToPost; // not owned 00034 QBuffer* iPrologue; 00035 QBuffer* iEpilogue; 00036 QList<QIODevice*> iPostElems; 00037 QIODeviceSeq* iPostData; 00038 00039 public: 00040 PostSession(); 00041 ~PostSession(); 00042 }; 00043 00044 class CUploader : 00045 public QObject 00046 { 00047 Q_OBJECT 00048 00049 public: 00050 CUploader(ac_AppContext* aAppContext); 00051 ~CUploader(); 00052 00053 void RefreshIap(bool aNotInitial); 00054 void RefreshSnapshotTimeExpr(bool aNotInitial); 00055 00056 void RequestSnapshot(); 00057 00058 private slots: 00059 void handlePosterTimerEvent(); 00060 void handleSnapshotTimerEvent(); 00061 00062 private: // MPosterObserver 00063 void PosterEvent(int anError); 00064 00065 private: // methods 00066 void Inactivate(); 00067 void StateChanged(); 00068 void StateChangedL(); 00069 void NextOldFileL(); 00070 void CreatePosterAoL(); 00071 void DestroyPosterAo(); 00072 bool PosterAoIsActive(); 00073 void HandleCommsError(int errCode); 00074 void PostNowL(); 00075 void SetPostTimer(); 00076 void SetSnapshotTimerL(); 00077 void TakeSnapshotNowL(); 00078 void FatalError(const std::exception &ex); 00079 00080 private: // property 00081 00082 ac_AppContext* iAppContext; // not owned 00083 00084 bool iNoConfig; // no upload URL 00085 #if defined(__SYMBIAN32__) 00086 TUint32 iIapId; 00087 #endif /* __SYMBIAN32__ */ 00088 00089 //// posting state 00090 QNetworkAccessManager iNetworkAccessManager; 00091 QSslConfiguration iSslConfiguration; 00092 QNetworkRequest iNetworkRequest; 00093 QTimer iPostTimerAo; // interval timer 00094 bool iNoOldFiles; // getNextOldLogFile found nothing 00095 int iNumPostFailures; // affects retry timing 00096 00097 PostSession* iPostSession; 00098 QFile* iFileToPost; // pathname of file to upload 00099 00100 //// snapshot taking state 00101 QAbsTimer iSnapshotTimerAo; 00102 bool iSnapshotTimePassed; 00103 gchar* iSnapshotTimeExpr; 00104 time_t iSnapshotTimeCtx; 00105 bool iNoNextSnapshotTime; 00106 00107 private slots: 00108 //void postingError ( QNetworkReply::NetworkError code ); 00109 void postingSslErrors(const QList<QSslError> & errors); 00110 void postingFinished(); 00111 00112 private: 00113 LogDb* GetLogDb() const { return ac_LogDb(iAppContext); } 00114 QUrl GetUrl() const { return iNetworkRequest.url(); } 00115 00116 //// blackboard 00117 public: 00118 void Set_uploads_allowed(bool val); 00119 private: 00120 bool i_uploads_allowed; // from blackboard 00121 bb_Closure iClosure; 00122 void BbRegisterL(); 00123 void BbUnregister(); 00124 }; 00125 00126 #endif /* __up_uploader_qt_private_hpp__ */ 00127 00128 /** 00129 00130 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00131 and the authors. All rights reserved. 00132 00133 Authors: Tero Hasu <tero.hasu@hut.fi> 00134 00135 Permission is hereby granted, free of charge, to any person 00136 obtaining a copy of this software and associated documentation files 00137 (the "Software"), to deal in the Software without restriction, 00138 including without limitation the rights to use, copy, modify, merge, 00139 publish, distribute, sublicense, and/or sell copies of the Software, 00140 and to permit persons to whom the Software is furnished to do so, 00141 subject to the following conditions: 00142 00143 The above copyright notice and this permission notice shall be 00144 included in all copies or substantial portions of the Software. 00145 00146 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00147 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00148 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00149 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00150 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00151 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00152 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00153 SOFTWARE. 00154 00155 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:57 2011 by Doxygen 1.6.1