|
1 /* |
|
2 * Copyright (c) 2005 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: Common Agent SyncML command handling |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __NSMLCMDSBASE_H |
|
20 #define __NSMLCMDSBASE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <s32mem.h> |
|
25 |
|
26 #include "smlmetinfdtd.h" |
|
27 #include "nsmlerror.h" |
|
28 #include "nsmlagenttestdefines.h" |
|
29 #include "smlsyncmltags.h" |
|
30 #include "NSmlPrivateAPI.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CNSmlAgentBase; |
|
34 class CNSmlURI; |
|
35 class CNSmlStatusContainer; |
|
36 class CNSmlResponseController; |
|
37 class CNSmlResultsContainer; |
|
38 class CWBXMLSyncMLGenerator; |
|
39 class CWBXMLParser; |
|
40 class CWBXMLSyncMLDocHandler; |
|
41 class CNSmlPhoneInfo; |
|
42 class CNSmlAuth; |
|
43 class CNSmlFutureReservation; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 |
|
47 /** |
|
48 * CNSmlCmdsBase implements common parts (for DS and DM) of SyncML commands handling |
|
49 * |
|
50 */ |
|
51 class CNSmlCmdsBase:public CBase |
|
52 { |
|
53 public: // Constructors and destructor |
|
54 |
|
55 IMPORT_C CNSmlCmdsBase(); |
|
56 IMPORT_C virtual ~CNSmlCmdsBase(); |
|
57 |
|
58 public: //enumerations |
|
59 enum TReturnValue |
|
60 { |
|
61 EReturnOK = 0, |
|
62 EReturnNotFound, |
|
63 EReturnSkipped, |
|
64 EReturnEndData, |
|
65 EReturnBufferFull |
|
66 }; |
|
67 |
|
68 public: // new functions |
|
69 virtual void DoAlertL( const TDesC8& aAlertCode, TTime* aLastSyncAnchor = NULL, TTime* aNextSyncAnchor = NULL ) = 0; |
|
70 virtual void DoPutL() = 0; |
|
71 virtual TReturnValue DoResultsL() = 0; |
|
72 virtual void DoGetL() = 0; |
|
73 virtual TReturnValue DoStartSyncL() = 0; |
|
74 virtual void DoEndSyncL() = 0; |
|
75 virtual TReturnValue DoAddOrReplaceOrDeleteL() = 0; |
|
76 virtual TReturnValue DoMapL() = 0; |
|
77 virtual void DoEndMessageL( TBool aFinal = ETrue ) = 0; |
|
78 virtual void ProcessResultsCmdL( SmlResults_t* aResults ) = 0; |
|
79 virtual void ProcessPutCmdL( SmlPut_t* aPut ) = 0; |
|
80 virtual void ProcessGetCmdL( SmlGet_t* aGet ) = 0; |
|
81 virtual void ProcessAlertCmdL( SmlAlert_t* aAlert, TBool aNextAlert = EFalse, TBool aServerAlert = EFalse, TBool aDisplayAlert = EFalse ) = 0; |
|
82 virtual void ProcessSyncL( SmlSync_t* aSync ) = 0; |
|
83 virtual void ProcessEndSyncL() = 0; |
|
84 virtual void ProcessUpdatesL( const TDesC8& aCmd, SmlGenericCmd_t* aContent ) = 0; |
|
85 virtual void ProcessAtomicL( SmlAtomic_t* aAtomic ) = 0; |
|
86 virtual void ProcessEndAtomicL() = 0; |
|
87 virtual void ProcessSequenceL( SmlSequence_t* aSequence) = 0; |
|
88 virtual void ProcessEndSequence() = 0; |
|
89 IMPORT_C virtual void ProcessCopyCmdL(SmlCopy_t* aCopy); |
|
90 IMPORT_C virtual void ProcessExecCmdL(SmlExec_t* aExec); |
|
91 IMPORT_C virtual void ProcessMapCmdL(SmlMap_t* aContent); |
|
92 IMPORT_C virtual void ProcessSearchCmdL(SmlSearch_t* aSearch); |
|
93 IMPORT_C virtual void FetchIDMappingTableL(const TInt aType); |
|
94 IMPORT_C virtual void CloseIDMappingTableL(); |
|
95 IMPORT_C virtual TBool DeleteIDMappingTableL(const TDesC& aId, const TDesC& aDatabase); |
|
96 |
|
97 IMPORT_C virtual void EndOfServerMessageL() const; |
|
98 IMPORT_C virtual TInt WriteMappingInfoToDbL() const; |
|
99 |
|
100 IMPORT_C virtual void DoSyncHdrL(); |
|
101 IMPORT_C TReturnValue DoStatusL( SmlStatus_t* aStatus ); |
|
102 // FOTA |
|
103 IMPORT_C virtual void DoGenericAlertL ( const TDesC8& aFwMgmtUri, const TDesC8& aMetaType, const TDesC8& aMetaFormat, TInt aFinalResult, const TDesC8& aFwCorrelator ); |
|
104 IMPORT_C virtual TBool DoGenericUserAlertL ( TInt aProfileId ); |
|
105 IMPORT_C virtual void ResetGenericUserAlertL(); |
|
106 IMPORT_C virtual void MarkGenAlertsSentL(); |
|
107 IMPORT_C virtual void MarkGenAlertsSentL(const TDesC8& aURI); |
|
108 IMPORT_C virtual void DisconnectFromOtherServers(); |
|
109 // FOTA end |
|
110 IMPORT_C TBool ProcessReceivedDataL(); |
|
111 IMPORT_C virtual void ProcessSyncHdrL ( SmlSyncHdr_t* aSyncHdr ); |
|
112 IMPORT_C virtual void ProcessStatusCmdL( SmlStatus_t* aStatus ); |
|
113 IMPORT_C TPtr8 AlertCode( SmlAlert_t* aAlert ) const; |
|
114 IMPORT_C void StatusToUnsupportedCommandL( TBool aIllegal, const TDesC8& aCmd, const SmlPcdata_t* aCmdRef, Flag_t aFlags = 0 ); |
|
115 TPtrC8 GeneratedDocument() const; |
|
116 IMPORT_C TPtr8 BufferAreaForParsingL(); |
|
117 IMPORT_C TBool BusyStatus() const; |
|
118 IMPORT_C CNSmlStatusContainer* StatusContainer() const; |
|
119 IMPORT_C CNSmlResponseController* ResponseController() const; |
|
120 IMPORT_C CNSmlResultsContainer* ResultsContainer() const; |
|
121 IMPORT_C CNSmlAuth* ServerAuth() const; |
|
122 IMPORT_C CNSmlURI* RespURI() const; |
|
123 IMPORT_C void DoMetaL( SmlPcdata_t*& aMeta, const SmlMetInfMetInf_t* aMetaData ) const; |
|
124 IMPORT_C void DoMetInfLC( SmlMetInfMetInf_t*& aMeta ) const; |
|
125 IMPORT_C void PcdataNewL( SmlPcdata_t*& aPcdata, const TDesC8& aContent ) const; |
|
126 IMPORT_C void DoSourceL( sml_source_s*& aSource, const TDesC& aLocURIData ) const; |
|
127 IMPORT_C void DoSourceL( sml_source_s*& aSource, const TDesC8& aLocURIData ) const; |
|
128 IMPORT_C void DoSourceL( sml_source_s*& aSource, const TDesC& aLocURIData, const TDesC& aLocNameData ) const; |
|
129 IMPORT_C void DoTargetL( sml_target_s*& aTarget, const TDesC& aLocURIData ) const; |
|
130 IMPORT_C void DoTargetL( sml_target_s*& aTarget, const TDesC8& aLocURIData ) const; |
|
131 IMPORT_C void DoTargetL( sml_target_s*& aTarget, const TDesC& aLocURIData, const TDesC& aLocNameData ) const; |
|
132 IMPORT_C void PCDATAToUnicodeLC( const SmlPcdata_t& aPcdata, HBufC*& aUnicodeData ) const; |
|
133 IMPORT_C void ResetLargeObjectBuffer(); |
|
134 IMPORT_C TBool WaitingLargeObjectChunk() const; |
|
135 IMPORT_C void SetMaximumWorkspaceSize( const TInt aMaxSize ); |
|
136 IMPORT_C virtual void DoGenericAlertL ( const TDesC8& aCorrelator, const RArray<CNSmlDMAlertItem>& aData ); |
|
137 |
|
138 protected: //new functions |
|
139 IMPORT_C void ConstructL( CNSmlAgentBase* aAgentBase, const TDesC8& aSessionID, const TDesC8& aVerProto, const TInt aPublicId, const HBufC& aSyncMLUserName, CNSmlURI* aSyncServer, TBool aVersionCheck = ETrue ); |
|
140 IMPORT_C void ConstructL( CNSmlAgentBase* aAgentBase, const TDesC8& aSessionID, const TDesC8& aVerProto, const HBufC& aSyncMLUserName, CNSmlURI* aSyncServer, TBool aVersionCheck = ETrue ); |
|
141 |
|
142 IMPORT_C void DoCmdIdL( SmlPcdata_t*& aCmdID); |
|
143 IMPORT_C void DoAnchorsL( SmlMetInfMetInf_t& aMetInf, const TDesC8* aLast, const TDesC8* aNext ) const; |
|
144 IMPORT_C void DoMaxObjSizeL( SmlMetInfMetInf_t& aMetInf, TInt aMaxObjSize ) const; |
|
145 |
|
146 IMPORT_C void SubtractConsumedFromPcData( SmlItem_t*& aItem, TInt aConsumed ); |
|
147 IMPORT_C TInt StatusDataToGenericCommandL( const TDesC8& aCmd, const SmlGenericCmd_t* aContent, const SmlItem_t* aItem, TNSmlError::TNSmlSyncMLStatusCode aStatusCode, const TDesC8* aStatusItem = NULL ); |
|
148 IMPORT_C TInt StatusDataToGetCommandL( const SmlGet_t* aContent, const SmlItem_t* aItem, TNSmlError::TNSmlSyncMLStatusCode aStatusCode, const TDesC8* aStatusItem = NULL ); |
|
149 IMPORT_C TInt StatusDataToCommandL( const TDesC8& aCmd, const SmlPcdata_t* aCmdID, TUint aFlags, const SmlItem_t* aItem, TNSmlError::TNSmlSyncMLStatusCode aStatusCode, const TDesC8* aStatusItem = NULL ); |
|
150 IMPORT_C TInt CreateAndInitResponseItemL( const TDesC8& aCommand ); |
|
151 IMPORT_C TBool TargetIsUnderItem( const SmlItemList_t* aItemList ) const; |
|
152 IMPORT_C TBool SourceIsUnderItem( const SmlItemList_t* aItemList ) const; |
|
153 IMPORT_C HBufC8* MetaTypeInUtf8LC( const SmlPcdata_t* aMeta ) const; |
|
154 IMPORT_C HBufC* MetaTypeLC( const SmlPcdata_t* aMeta ) const; |
|
155 IMPORT_C HBufC8* MetaFormatInUtf8LC( const SmlPcdata_t* aMeta ) const; |
|
156 IMPORT_C TBool IsFlagSet( const TUint& aValue, const TUint& aBit ) const; |
|
157 IMPORT_C void TrimRightSpaceAndNull (TDes8& aDes ) const; |
|
158 IMPORT_C TNSmlError::TNSmlSyncMLStatusCode MoreDataL( const HBufC8* aUID, const SmlItem_t* aCurrentItem, const SmlPcdata_t* aMetaInCommand, CBufBase*& aTotalItem ); |
|
159 IMPORT_C TInt ServerMaxObjSize( const SmlPcdata_t* aMeta ) const; |
|
160 IMPORT_C TInt ServerObjectSize( const SmlPcdata_t* aMeta ) const; |
|
161 |
|
162 private: //functions |
|
163 |
|
164 CNSmlCmdsBase( const CNSmlCmdsBase& aOther ); |
|
165 CNSmlCmdsBase& operator=( const CNSmlCmdsBase& aOther ); |
|
166 |
|
167 // |
|
168 public: // Data |
|
169 #ifdef __NOTRANSPORT |
|
170 TPtr8 BufferAreaForDebugDumpL(); |
|
171 #endif |
|
172 |
|
173 protected: // Data |
|
174 HBufC8* iVerDTD; |
|
175 TInt iVersionPublicId; |
|
176 |
|
177 // protocol version |
|
178 HBufC8* iVerProto; |
|
179 // Current SyncML SessionID |
|
180 HBufC8* iSessionID; |
|
181 // Current SyncML MsgID of a client |
|
182 TInt iCurrMsgID; |
|
183 // Current SyncML CmdID of a client |
|
184 TInt iCurrCmdID; |
|
185 // Current SyncML MsgID of a server |
|
186 HBufC8* iCurrServerMsgID; |
|
187 // No Response Status to the message sent by Server |
|
188 TBool iStatusToServerNoResponse; |
|
189 // Target/LocURI element which client has sent to server |
|
190 CNSmlURI* iSentSyncHdrTarget; |
|
191 // Source/LocURI element which client has sent to server |
|
192 CNSmlURI* iSentSyncHdrSource; |
|
193 // URI for response from a server |
|
194 CNSmlURI* iRespURI; |
|
195 // switches for checking SyncML version |
|
196 TBool iVersionCheck; |
|
197 TBool iVersionIsChecked; |
|
198 // workspace size |
|
199 TInt iWorkspaceSize; |
|
200 // maximum workspace size |
|
201 TInt iMaxWorkspaceSize; |
|
202 // bufferArea |
|
203 HBufC8* iBufferArea; |
|
204 // read stream; |
|
205 RDesReadStream iReadStream; |
|
206 // switch for authentication (client) |
|
207 TBool iAlreadyAuthenticated; |
|
208 // switch for Busy Status |
|
209 TBool iBusyStatusReceived; |
|
210 // switch for Result Alert |
|
211 TBool iResultAlertIssued; |
|
212 // switch for Data Update Status package; |
|
213 TBool iStatusPackage; |
|
214 // Indicates invalid device |
|
215 TBool iUnknownDevice; |
|
216 // User Name |
|
217 HBufC* iSyncMLUserName; |
|
218 // SyncML server |
|
219 CNSmlURI* iSyncServer; |
|
220 // partially sent large object item |
|
221 SmlItem_t* iLargeObjectItem; |
|
222 // buffer for received data; |
|
223 CBufFlat* iRecBuf; |
|
224 // size of the large object of a server |
|
225 TInt iServerLargeObjectSize; |
|
226 // identifier in first chunk in server's large object |
|
227 HBufC8* iLargeObjectUID; |
|
228 // max. object size in SyncHdr level |
|
229 TInt iSynchHdrMaxObjSize; |
|
230 // max object size of a server |
|
231 TInt iServerMaxObjectSize; |
|
232 // |
|
233 // Used classes |
|
234 // |
|
235 CNSmlAgentBase* iAgent; |
|
236 // |
|
237 // Owned classes |
|
238 // |
|
239 CNSmlStatusContainer* iStatusToServer; |
|
240 CNSmlResponseController* iResponseController; |
|
241 CNSmlResultsContainer* iResultsToServer; |
|
242 CWBXMLSyncMLGenerator* iGenerator; |
|
243 CWBXMLParser* iParser; |
|
244 CWBXMLSyncMLDocHandler* iDocHandler; |
|
245 CNSmlPhoneInfo* iPhoneInfo; |
|
246 CNSmlAuth* iServerAuth; |
|
247 // Reserved to maintain binary compability |
|
248 CNSmlFutureReservation* iReserved; |
|
249 |
|
250 TInt iAmountReceived; |
|
251 TBool iMoreData; |
|
252 TInt iItemSizeInStream; |
|
253 }; |
|
254 |
|
255 #endif // __NSMLCMDSBASE_H |
|
256 |
|
257 // End of File |