00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __TASKMANAGERENGINE_H
00012 #define __TASKMANAGERENGINE_H
00013
00014
00015 #include "TaskManager.hrh"
00016 #include "TaskManagerEngineReader.h"
00017 #include "timeouttimer.h"
00018 #include "request.h"
00019
00020 #include <in_sock.h>
00021 #include <msvapi.h>
00022 #include <cdblen.h>
00023 #include <es_sock.h>
00024
00025
00026 class CSecureSocket;
00027 class CResponse;
00028
00029
00030
00034 class MTransactionObserver
00035 {
00036 public:
00040 virtual void OpeningConnectionL() = 0;
00041
00046 virtual void SuccessL(const CResponse& aResponse) = 0;
00047
00052 virtual void FailedL(const TInt& aError) = 0;
00053
00058 virtual void ConnectingToServerL(const TBool& aLoadingTasks) = 0;
00059
00063 virtual void CancelledL() = 0;
00064
00070 virtual void ErrorL(const TDesC& aErrorMsg) = 0;
00071 };
00072
00073
00074
00078 class TIap
00079 {
00080 public:
00081 TUint32 iId;
00082 TBuf<KCommsDbSvrMaxFieldLength> iName;
00083 };
00084
00085
00086
00087
00093 class CTaskManagerEngine : public CActive,
00094 public MMsvSessionObserver,
00095 public MEngineNotifier,
00096 public MTimeoutNotifier
00097 {
00098 public:
00099
00103 static CTaskManagerEngine* NewL(MTransactionObserver& aObserver);
00104
00108 ~CTaskManagerEngine();
00109
00110 protected:
00111
00115 void DoCancel();
00116
00120 void RunL();
00121
00125 TInt RunError( TInt aError );
00126
00127 public:
00128
00136 void SetConnectionSettings(const TDesC& aServerName,
00137 const TInt& aPort,
00138 const TDesC& aUsername,
00139 const TDesC& aPassword);
00140
00145 void FetchTasksL();
00146
00151 void MarkTaskDoneL(const TInt& aTaskId);
00152
00156 void CheckRefreshL();
00157
00158 public:
00159
00164 TBool PackageReceivedL( const TDesC8& aData );
00165
00166 public:
00167
00171 void TimerExpired();
00172
00173 public:
00174
00179 void SetIap(const TUint32& aId);
00180
00184 void CancelTransaction();
00185
00190 TBool IapSet() const;
00191
00196 RArray<TIap>& Iaps();
00197
00203 void SetAutomaticUpdateL(const TBool& aOn);
00204
00205 private:
00206
00210 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
00211
00212 private:
00213
00217 void LoadIapsL();
00218
00222 void ConnectL();
00223
00228 void ConnectL( TUint32 aAddr );
00229
00235 TBool CheckAndReportErrorsL();
00236
00240 void GPRSConnectL();
00241
00245 void EndConnection();
00246
00247 private:
00248
00252 CTaskManagerEngine(MTransactionObserver& aObserver);
00253 void ConstructL();
00254
00255 enum TEngineState
00256 {
00257
00258 ENotConnected = 1,
00259 EStartingGPRS,
00260 ELookingUp,
00261 EConnecting,
00262 ESSLConnecting,
00263 EConnected,
00264
00265
00266 EWriting,
00267 EReading
00268 };
00269
00270 private:
00271
00272
00273 static const TInt KTimeOut;
00274
00275
00276 RSocketServ iSocketServer;
00277 RSocket iSocket;
00278 RConnection iConnection;
00279 CSecureSocket* iSecureSocket;
00280 TInetAddr iAddress;
00281
00282
00283 TEngineState iState;
00284
00285
00286 CTimeOutTimer* iTimer;
00287
00288
00289 TRequest::TOperationType iOperation;
00290
00291
00292
00293 TBuf<5> iMarkId;
00294
00295
00296 RHostResolver iResolver;
00297
00298
00299 TNameEntry iNameEntry;
00300 TNameRecord iNameRecord;
00301
00302
00303 CMsvSession* iMsvSession;
00304 CMsvEntry* iMsvEntry;
00305
00306
00307 MTransactionObserver& iTransactionObserver;
00308
00309
00310 TBuf<KMaxUsernameLength> iUsername;
00311 TBuf<KMaxPasswordLength> iPassword;
00312 TBuf<KMaxServerNameLength> iServer;
00313 TInt iPort;
00314
00315
00316 TBuf8<KMaxWriteBufferSize> iWriteBuffer;
00317
00318
00319 CTaskManagerEngineReader* iReader;
00320
00321
00322 CResponse* iResponse;
00323
00324
00325 TSockXfrLength iDummyLength;
00326
00327 TBool iRunning;
00328 TBool iDoRefresh;
00329 TBool iOpeningConnection;
00330 RArray<TIap> iIAPs;
00331 TUint32 iIap;
00332 TBool iAutomaticUpdate;
00333 };
00334
00335 #endif
00336
00337
00338
00339
00340