|
1 /** |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Declaration of CABSession class. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 #ifndef __ABSESSION_H__ |
|
26 #define __ABSESSION_H__ |
|
27 |
|
28 #include <e32std.h> |
|
29 #include "abserver.h" |
|
30 #include <connect/sbtypes.h> |
|
31 #include <connect/abclientserver.h> |
|
32 |
|
33 namespace conn |
|
34 { |
|
35 class CDataOwner; |
|
36 |
|
37 /** Constant definition for the watchdog timer */ |
|
38 const TTimeIntervalMicroSeconds32 KABCallbackWatchdogTimeout(200000000); |
|
39 |
|
40 class CABSession : public CSession2 |
|
41 /** |
|
42 @internalComponent |
|
43 @ingroup Server |
|
44 |
|
45 A AB client Session. |
|
46 */ |
|
47 { |
|
48 public: |
|
49 virtual void CreateL(); |
|
50 static CABSession* NewL(TSecureId aSecureId); |
|
51 |
|
52 // Methods |
|
53 void RestoreCompleteL(TDriveNumber aDriveNumber); |
|
54 void AllSnapshotsSuppliedL(); |
|
55 void GetExpectedDataSizeL(TDriveNumber aDriveNumber, TUint& aSize); |
|
56 void SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer, |
|
57 TBool aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID); |
|
58 void RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer, |
|
59 TBool& aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID); |
|
60 void TerminateMultiStageOperationL(); |
|
61 TUint GetDataChecksumL(TDriveNumber aDrive); |
|
62 static TInt ABSessionStaticWatchdogCaller(TAny* aWatchdoggingObject); |
|
63 TInt WatchdogExpired(); |
|
64 TBool ConfirmedReadyForBUR() const; |
|
65 TBool CallbackInterfaceAvailable() const; |
|
66 void RestoreCompleteL(); |
|
67 void SetInvalid(); |
|
68 TBool Invalidated(); |
|
69 |
|
70 private: |
|
71 CABSession(TSecureId aSecureId); |
|
72 ~CABSession(); |
|
73 void ConstructL(); |
|
74 inline CABServer& Server() const; |
|
75 CDataOwner& DataOwnerL() const; |
|
76 void ServiceL(const RMessage2& aMessage); |
|
77 void TakeOwnershipOfIPCMessage(const RMessage2& aMessage); |
|
78 void CleanupClientSendState(); |
|
79 |
|
80 // Handle IPC messages |
|
81 void HandleIPCBURModeInfoL(const RMessage2& aMessage); |
|
82 void HandleIPCDoesPartialBURAffectMeL(const RMessage2& aMessage); |
|
83 void HandleIPCConfirmReadyForBURL(const RMessage2& aMessage); |
|
84 void HandleIPCPropagateLeaveL(const RMessage2& aMessage); |
|
85 TInt HandleIPCGetDataSyncL(const RMessage2& aMessage); |
|
86 TInt HandleIPCSendDataLengthL(const RMessage2& aMessage); |
|
87 TInt HandleIPCClosingDownCallback(); |
|
88 |
|
89 // Callback methods |
|
90 void MadeCallback(); |
|
91 void ReturnFromCallback(); |
|
92 void CheckCallbackAvailableL(); |
|
93 void MakeCallbackAllSnapshotsSuppliedL(); |
|
94 void MakeCallbackReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection); |
|
95 TUint MakeCallbackGetExpectedDataSizeL(TDriveNumber aDrive); |
|
96 void MakeCallbackGetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished); |
|
97 void MakeCallbackInitialiseGetBackupDataL(TDriveNumber aDrive); |
|
98 void MakeCallbackGetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished); |
|
99 void MakeCallbackInitialiseRestoreBaseDataL(TDriveNumber aDrive); |
|
100 void MakeCallbackRestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
101 void MakeCallbackInitialiseRestoreIncrementDataL(TDriveNumber aDrive); |
|
102 void MakeCallbackRestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
103 void MakeCallbackRestoreCompleteL(TDriveNumber aDrive); |
|
104 void MakeCallbackInitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive); |
|
105 void MakeCallbackInitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive); |
|
106 void MakeCallbackTerminateMultiStageOperationL(); |
|
107 TUint MakeCallbackGetDataChecksumL(TDriveNumber aDrive); |
|
108 |
|
109 private: |
|
110 /** Last message received from client. Stored and used when |
|
111 the connection status changes. */ |
|
112 RMessage2 iMessage; |
|
113 |
|
114 /** The SecureId of the client that should be connecting to this session */ |
|
115 TSecureId iClientSID; |
|
116 |
|
117 /** Callback Timer used to determine whether a rogue client is attempting a denial of service */ |
|
118 CPeriodic* iCallbackWatchdog; |
|
119 |
|
120 CActiveSchedulerWait* iActiveSchedulerWait; /*!< Inner scheduler for blocking on active callback */ |
|
121 |
|
122 /** The leave code that must persist so that leaves can be propagated from the abclient */ |
|
123 TInt iABClientLeaveCode; |
|
124 |
|
125 /** Identifies the callback that is in progress. Used for validating multiple calls for a callback */ |
|
126 TABCallbackCommands iCallbackInProgress; |
|
127 |
|
128 /** This flag records whether or not the client has finished sending data */ |
|
129 TBool iReceiveFromClientFinished; |
|
130 |
|
131 /** Assign data to this TPtr so that it may be sent to the client */ |
|
132 TPtrC8 iSendToClientBuffer; |
|
133 |
|
134 /** Function pointer to the handler function that */ |
|
135 TCallBack iWatchdogHandler; |
|
136 |
|
137 /** Client has not responded - potentially allow some operations */ |
|
138 TBool iMisbehavingClient; |
|
139 |
|
140 /** The drive that snapshot data has been supplied for */ |
|
141 TDriveNumber iSuppliedSnapshotDriveNum; |
|
142 |
|
143 /** Flag to store whether or not client has called ConfirmReadyForBURL */ |
|
144 TBool iConfirmedReadyForBUR; |
|
145 |
|
146 /** Flag to indicate whether this session is valid or not,invalid |
|
147 * session means this session is for a backup/restore event which is |
|
148 * already over, but not disconnect from the client |
|
149 */ |
|
150 TBool iInvalid; |
|
151 }; |
|
152 |
|
153 } |
|
154 #endif //__ABSESSION_H__ |