|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * commander for data accessor. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 |
|
23 #include "ImpsAccessCli.h" |
|
24 #include "ImpsAccessCommand.h" |
|
25 #include "impsutils.h" |
|
26 #include "impspacked.h" |
|
27 #include "impsliterals.h" |
|
28 |
|
29 // MACROS |
|
30 #ifndef _DEBUG |
|
31 #define _NO_IMPS_LOGGING_ |
|
32 #endif |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // ---------------------------------------------------------------------------- |
|
37 // CImpsAccessCommand2::CImpsAccessCommand2 |
|
38 // ---------------------------------------------------------------------------- |
|
39 CImpsAccessCommand2::CImpsAccessCommand2( |
|
40 TInt aPriority, |
|
41 RImpsAccessClient2& aClient ) : |
|
42 CActive( aPriority ), iClient( aClient ) |
|
43 { |
|
44 CActiveScheduler::Add( this ); |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // CImpsAccessCommand2::NewL |
|
49 // ---------------------------------------------------------------------------- |
|
50 CImpsAccessCommand2* CImpsAccessCommand2::NewL( RImpsAccessClient2& aClient ) |
|
51 { |
|
52 |
|
53 // Perform the construction. |
|
54 CImpsAccessCommand2* self = new (ELeave) |
|
55 CImpsAccessCommand2( EPriorityUserInput, aClient); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CImpsAccessCommand2::~CImpsAccessCommand2() |
|
62 // ---------------------------------------------------------------------------- |
|
63 CImpsAccessCommand2::~CImpsAccessCommand2() |
|
64 { |
|
65 // Cancel any outstanding requests |
|
66 Cancel(); |
|
67 |
|
68 delete iCookie; |
|
69 delete iMessageStream; |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // CImpsAccessCommand2::StartRunL() |
|
74 // ---------------------------------------------------------------------------- |
|
75 void CImpsAccessCommand2::StartRunL( |
|
76 TInt aOpId, |
|
77 TImpsServRequest aType ) |
|
78 { |
|
79 iOpId = aOpId; |
|
80 iType = aType; |
|
81 iState = 0; |
|
82 |
|
83 if ( IsActive() ) |
|
84 { |
|
85 User::Leave( KErrServerBusy ); |
|
86 } |
|
87 |
|
88 |
|
89 // Set this active object active |
|
90 iStatus = KRequestPending; |
|
91 SetActive(); |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CImpsAccessCommand2::SetParametersL() |
|
96 // ---------------------------------------------------------------------------- |
|
97 void CImpsAccessCommand2::SetParametersL( |
|
98 const TDesC& aServer, |
|
99 const TDesC& aUser, |
|
100 const TDesC& aPsw, |
|
101 const TDesC& aClientId, |
|
102 TUint32 aAP, |
|
103 const TDesC* aKey1, |
|
104 const TDesC* aKey2 ) |
|
105 { |
|
106 |
|
107 if ( IsActive() ) |
|
108 { |
|
109 User::Leave( KErrServerBusy ); |
|
110 } |
|
111 |
|
112 delete iCookie; |
|
113 iCookie = NULL; |
|
114 |
|
115 delete iMessageStream; |
|
116 iMessageStream = NULL; |
|
117 TInt myLen = aUser.Size() + aClientId.Size() + aPsw.Size() + |
|
118 aServer.Size(); |
|
119 |
|
120 TPtrC key1 (KNullDesC); |
|
121 TPtrC key2 (KNullDesC); |
|
122 |
|
123 if ( aKey1 ) |
|
124 { |
|
125 key1.Set( *aKey1 ); |
|
126 } |
|
127 |
|
128 if ( aKey2 ) |
|
129 { |
|
130 key2.Set( *aKey2 ); |
|
131 } |
|
132 |
|
133 myLen += key1.Size() + key2.Size(); |
|
134 |
|
135 // some extra space for elements needed |
|
136 iMessageStream = HBufC8::NewL( myLen + 50 ); |
|
137 *iMessageStream = KNullDesC8; |
|
138 |
|
139 CDesCArrayFlat* myTempArr = new ( ELeave )CDesCArrayFlat( 7 ); |
|
140 CleanupStack::PushL( myTempArr ); // << |
|
141 |
|
142 TImpsPackedEntity packedMessage( iMessageStream ); |
|
143 |
|
144 myTempArr->AppendL( aUser ); |
|
145 myTempArr->AppendL( aPsw ); |
|
146 myTempArr->AppendL( aClientId ); |
|
147 myTempArr->AppendL( aServer ); |
|
148 myTempArr->AppendL( key1 ); |
|
149 myTempArr->AppendL( key2 ); |
|
150 |
|
151 // add aAp |
|
152 TBuf<4> temp; |
|
153 temp.Num( (TInt)aAP ); |
|
154 myTempArr->AppendL( temp ); |
|
155 |
|
156 const TUint8* pS = iMessageStream->Ptr(); |
|
157 |
|
158 packedMessage.DoPackArray( pS, myTempArr ); |
|
159 // update the length of the buffer |
|
160 iMessageStream->Des().SetLength( pS-iMessageStream->Ptr() ); |
|
161 iMessagePtr.Set( iMessageStream->Des() ); |
|
162 |
|
163 |
|
164 myTempArr->Reset(); |
|
165 |
|
166 CleanupStack::PopAndDestroy( 1 ); // >> myTempArr |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CImpsAccessCommand2::RunL() |
|
171 // ---------------------------------------------------------------------------- |
|
172 |
|
173 void CImpsAccessCommand2::RunL() |
|
174 { |
|
175 |
|
176 #ifndef _NO_IMPS_LOGGING_ |
|
177 CImpsClientLogger::Log(_L("CImpsAccessCommand2: RunL %d"), iStatus.Int() ); |
|
178 #endif |
|
179 |
|
180 MImpsAccessHandler2* handler = ( MImpsAccessHandler2* )iClient.iHandlerCallBack; |
|
181 MImpsErrorHandler2* ehandler = iClient.ErrorHandler(); |
|
182 |
|
183 |
|
184 // Error handler should be registered |
|
185 if ( iStatus < KErrNone ) |
|
186 { |
|
187 if ( ehandler ) |
|
188 { |
|
189 TInt err( KErrNone ); |
|
190 TRAP( err, ehandler->HandleErrorL( |
|
191 iStatus.Int(), |
|
192 iOpId, |
|
193 NULL, |
|
194 NULL, |
|
195 *iClient.CspIdentifier() )); |
|
196 } |
|
197 return; |
|
198 } |
|
199 |
|
200 // Errors are handled here only except couple of nice cases |
|
201 if ( iType == EImpsServIsLogged ) |
|
202 { |
|
203 return; |
|
204 } |
|
205 if ( iType == EImpsServNbrSessions ) |
|
206 { |
|
207 // Status includes the required data! |
|
208 // No "push" later |
|
209 TInt err( KErrNone ); |
|
210 TRAP( err, handler->HandleNbrSessionsL( |
|
211 iOpId, |
|
212 iStatus.Int(), |
|
213 *iClient.CspIdentifier() )); |
|
214 return; |
|
215 } |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------------------------- |
|
219 // CImpsAccessCommand2::DoCancel() |
|
220 // Before calling this the Cancel should have sent to the engine! |
|
221 // ---------------------------------------------------------------------------- |
|
222 |
|
223 void CImpsAccessCommand2::DoCancel() |
|
224 { |
|
225 } |
|
226 |
|
227 // End of File |
|
228 |