00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __TASKMANAGERENGINE_H
00031 #define __TASKMANAGERENGINE_H
00032
00033
00034 #include "TaskManager.hrh"
00035 #include "TaskManagerEngineReader.h"
00036 #include "timeouttimer.h"
00037 #include "request.h"
00038
00039 #include <in_sock.h>
00040 #include <msvapi.h>
00041 #include <cdblen.h>
00042 #include <es_sock.h>
00043
00044
00045 class CSecureSocket;
00046 class CResponse;
00047
00048
00049
00053 class MTransactionObserver
00054 {
00055 public:
00059 virtual void OpeningConnectionL() = 0;
00060
00065 virtual void SuccessL(const CResponse& aResponse) = 0;
00066
00071 virtual void FailedL(const TInt& aError) = 0;
00072
00077 virtual void ConnectingToServerL(const TBool& aLoadingTasks) = 0;
00078
00082 virtual void CancelledL() = 0;
00083
00089 virtual void ErrorL(const TDesC& aErrorMsg) = 0;
00090 };
00091
00092
00093
00097 class TIap
00098 {
00099 public:
00100 TUint32 iId;
00101 TBuf<KCommsDbSvrMaxFieldLength> iName;
00102 };
00103
00104
00105
00106
00112 class CTaskManagerEngine : public CActive,
00113 public MMsvSessionObserver,
00114 public MEngineNotifier,
00115 public MTimeoutNotifier
00116 {
00117 public:
00118
00122 static CTaskManagerEngine* NewL(MTransactionObserver& aObserver);
00123
00127 ~CTaskManagerEngine();
00128
00129 protected:
00130
00134 void DoCancel();
00135
00139 void RunL();
00140
00144 TInt RunError( TInt aError );
00145
00146 public:
00147
00155 void SetConnectionSettings(const TDesC& aServerName,
00156 const TInt& aPort,
00157 const TDesC& aUsername,
00158 const TDesC& aPassword);
00159
00164 void FetchTasksL();
00165
00170 void MarkTaskDoneL(const TInt& aTaskId);
00171
00175 void CheckRefreshL();
00176
00177 public:
00178
00183 TBool PackageReceivedL( const TDesC8& aData );
00184
00185 public:
00186
00190 void TimerExpired();
00191
00192 public:
00193
00198 void SetIap(const TUint32& aId);
00199
00203 void CancelTransaction();
00204
00209 TBool IapSet() const;
00210
00215 RArray<TIap>& Iaps();
00216
00222 void SetAutomaticUpdateL(const TBool& aOn);
00223
00224 private:
00225
00229 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
00230
00231 private:
00232
00236 void LoadIapsL();
00237
00241 void ConnectL();
00242
00247 void ConnectL( TUint32 aAddr );
00248
00254 TBool CheckAndReportErrorsL();
00255
00259 void GPRSConnectL();
00260
00264 void EndConnection();
00265
00266 private:
00267
00271 CTaskManagerEngine(MTransactionObserver& aObserver);
00272 void ConstructL();
00273
00274 enum TEngineState
00275 {
00276
00277 ENotConnected = 1,
00278 EStartingGPRS,
00279 ELookingUp,
00280 EConnecting,
00281 ESSLConnecting,
00282 EConnected,
00283
00284
00285 EWriting,
00286 EReading
00287 };
00288
00289 private:
00290
00291
00292 static const TInt KTimeOut;
00293
00294
00295 RSocketServ iSocketServer;
00296 RSocket iSocket;
00297 RConnection iConnection;
00298 CSecureSocket* iSecureSocket;
00299 TInetAddr iAddress;
00300
00301
00302 TEngineState iState;
00303
00304
00305 CTimeOutTimer* iTimer;
00306
00307
00308 TRequest::TOperationType iOperation;
00309
00310
00311
00312 TBuf<5> iMarkId;
00313
00314
00315 RHostResolver iResolver;
00316
00317
00318 TNameEntry iNameEntry;
00319 TNameRecord iNameRecord;
00320
00321
00322 CMsvSession* iMsvSession;
00323 CMsvEntry* iMsvEntry;
00324
00325
00326 MTransactionObserver& iTransactionObserver;
00327
00328
00329 TBuf<KMaxUsernameLength> iUsername;
00330 TBuf<KMaxPasswordLength> iPassword;
00331 TBuf<KMaxServerNameLength> iServer;
00332 TInt iPort;
00333
00334
00335 TBuf8<KMaxWriteBufferSize> iWriteBuffer;
00336
00337
00338 CTaskManagerEngineReader* iReader;
00339
00340
00341 CResponse* iResponse;
00342
00343
00344 TSockXfrLength iDummyLength;
00345
00346 TBool iRunning;
00347 TBool iDoRefresh;
00348 TBool iOpeningConnection;
00349 RArray<TIap> iIAPs;
00350 TUint32 iIap;
00351 TBool iAutomaticUpdate;
00352 };
00353
00354 #endif
00355
00356
00357
00358
00359