|
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 * imps group commander. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 |
|
23 #include "ImpsGroupCli.h" |
|
24 #include "ImpsGroupCommand.h" |
|
25 #include "ImpsFields.h" |
|
26 #include "ImpsPacked.h" |
|
27 #include "impsutils.h" |
|
28 #include "ImpsDataAccessor.h" |
|
29 |
|
30 // MACROS |
|
31 #ifndef _DEBUG |
|
32 #define _NO_IMPS_LOGGING_ |
|
33 #endif |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CImpsGroupCommand2::CImpsGroupCommand2 |
|
39 // ---------------------------------------------------------------------------- |
|
40 CImpsGroupCommand2::CImpsGroupCommand2( |
|
41 TInt aPriority, |
|
42 RImpsGroupClient2& aClient ) : |
|
43 CActive( aPriority ), |
|
44 iClient( aClient ) |
|
45 { |
|
46 CActiveScheduler::Add( this ); |
|
47 } |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // CImpsGroupCommand2::NewL |
|
51 // ---------------------------------------------------------------------------- |
|
52 CImpsGroupCommand2* CImpsGroupCommand2::NewL( RImpsGroupClient2& aClient ) |
|
53 { |
|
54 // Perform the construction. |
|
55 CImpsGroupCommand2* self = new (ELeave) |
|
56 CImpsGroupCommand2( EPriorityUserInput, aClient); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CImpsGroupCommand2::~CImpsGroupCommand2 |
|
62 // ---------------------------------------------------------------------------- |
|
63 CImpsGroupCommand2::~CImpsGroupCommand2() |
|
64 { |
|
65 // Cancel any outstanding requests |
|
66 Cancel(); |
|
67 ResetMembers(); |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // CImpsGroupCommand2::StartRunL |
|
72 // ---------------------------------------------------------------------------- |
|
73 void CImpsGroupCommand2::StartRunL( |
|
74 TInt aOpId, |
|
75 TImpsServRequest aType ) |
|
76 { |
|
77 iOpId = aOpId; |
|
78 iType = aType; |
|
79 |
|
80 if ( IsActive() ) |
|
81 { |
|
82 User::Leave( KErrServerBusy ); |
|
83 } |
|
84 |
|
85 // Set this active object active |
|
86 iStatus = KRequestPending; |
|
87 SetActive(); |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // CImpsGroupCommand2::RunL |
|
92 // ---------------------------------------------------------------------------- |
|
93 |
|
94 void CImpsGroupCommand2::RunL() |
|
95 { |
|
96 |
|
97 #ifndef _NO_IMPS_LOGGING_ |
|
98 CImpsClientLogger::Log(_L("CImpsGroupCommand2: RunL %d"), iStatus.Int() ); |
|
99 #endif |
|
100 |
|
101 __ASSERT_DEBUG( iType == EImpsServGroup, |
|
102 User::Panic( KImpsPanicCategory, |
|
103 EImpsCorrupted ) ); |
|
104 |
|
105 // Errors are handled here only. |
|
106 // Successful cases are handled by CImpsImHandler. |
|
107 if ( iStatus == KErrNone ) |
|
108 { |
|
109 return; |
|
110 } |
|
111 |
|
112 MImpsErrorHandler2* ehandler = iClient.ErrorHandler(); |
|
113 |
|
114 // Handler should be registered |
|
115 if ( ehandler ) |
|
116 { |
|
117 TInt err( KErrNone ); |
|
118 TRAP( err, ehandler->HandleErrorL( |
|
119 iStatus.Int(), |
|
120 iOpId, |
|
121 NULL, |
|
122 NULL, |
|
123 *iClient.CspIdentifier() )); |
|
124 } |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CImpsGroupCommand2::DoCancel |
|
129 // Before calling this the unregister should have been called |
|
130 // ---------------------------------------------------------------------------- |
|
131 |
|
132 void CImpsGroupCommand2::DoCancel() |
|
133 { |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CImpsGroupCommand2::ResetMembers |
|
138 // ---------------------------------------------------------------------------- |
|
139 void CImpsGroupCommand2::ResetMembers( ) |
|
140 { |
|
141 delete iImpsFields; |
|
142 iImpsFields = NULL; |
|
143 if( iKey ) |
|
144 iKey->Destroy( ); |
|
145 iKey = NULL; |
|
146 delete iAccessor; |
|
147 iAccessor = NULL; |
|
148 delete iMessage; |
|
149 iMessage = NULL; |
|
150 iMessagePtr.Set( KNullDesC8 ); |
|
151 } |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
|
154 // CImpsGroupCommand2::InitialiseL |
|
155 // ---------------------------------------------------------------------------- |
|
156 void CImpsGroupCommand2::InitialiseL(const TImpsContent* aElementArray, |
|
157 const TUint aArraySize ) |
|
158 { |
|
159 iImpsFields = CImpsFields::NewL(); |
|
160 iAccessor = CImpsDataAccessor::NewL( iImpsFields ); |
|
161 iKey = iAccessor->NewKeyL(); |
|
162 for( TUint i = 0;i < aArraySize;i++ ) |
|
163 iKey->AddL( CREATEKEY( aElementArray[i], 0 ) ); |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CImpsGroupCommand2::InsertElementL |
|
168 // ---------------------------------------------------------------------------- |
|
169 void CImpsGroupCommand2::InsertElementL( const TDesC& aElementValue, |
|
170 const TImpsContent aElementName ) |
|
171 { |
|
172 iKey->AddL( CREATEKEY( aElementName, 0 ) ); |
|
173 iAccessor->StoreDescL( iKey, aElementValue ); |
|
174 iKey->PopL( ); |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 // CImpsGroupCommand2::InsertElementL |
|
179 // ---------------------------------------------------------------------------- |
|
180 void CImpsGroupCommand2::InsertElementL( TBool aBool, |
|
181 const TImpsContent aElementName ) |
|
182 { |
|
183 iKey->AddL( CREATEKEY( aElementName, 0 ) ); |
|
184 iAccessor->StoreBooleanL( iKey, aBool ); |
|
185 iKey->PopL( ); |
|
186 } |
|
187 |
|
188 // ---------------------------------------------------------------------------- |
|
189 // CImpsGroupCommand2::InsertElementIntL |
|
190 // ---------------------------------------------------------------------------- |
|
191 void CImpsGroupCommand2::InsertElementIntL( TInt aInt, |
|
192 const TImpsContent aElementName ) |
|
193 { |
|
194 iKey->AddL( CREATEKEY( aElementName, 0 ) ); |
|
195 iAccessor->StoreIntegerL( iKey, aInt ); |
|
196 iKey->PopL( ); |
|
197 } |
|
198 |
|
199 // ---------------------------------------------------------------------------- |
|
200 // CImpsGroupCommand2::InsertElementL |
|
201 // ---------------------------------------------------------------------------- |
|
202 void CImpsGroupCommand2::InsertElementL( const TDesC& aElementValue, |
|
203 const TImpsContent aElementName, |
|
204 TInt aIndex ) |
|
205 { |
|
206 iKey->AddL( CREATEKEY( aElementName, aIndex ) ); |
|
207 iAccessor->StoreDescL( iKey, aElementValue ); |
|
208 iKey->PopL( ); |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------------------------------- |
|
212 // CImpsGroupCommand2::InsertEmptyL |
|
213 // ---------------------------------------------------------------------------- |
|
214 void CImpsGroupCommand2::InsertEmptyL( const TImpsContent aElementName ) |
|
215 { |
|
216 iKey->AddL( CREATEKEY( aElementName, 0 ) ); |
|
217 iAccessor->StoreEmptyL( iKey ); |
|
218 iKey->PopL( ); |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CImpsGroupCommand2::PackMessageL |
|
223 // ---------------------------------------------------------------------------- |
|
224 void CImpsGroupCommand2::PackMessageL( ) |
|
225 { |
|
226 iImpsFields->SetMessageType( iMessageType ); |
|
227 delete iMessage; |
|
228 iMessage = NULL; |
|
229 iMessagePtr.Set( KNullDesC8 ); |
|
230 iMessage = HBufC8::NewL( iImpsFields->Size() ); |
|
231 TImpsPackedEntity packedMessage( iMessage ); |
|
232 TInt error = packedMessage.PackEntity( *iImpsFields ); |
|
233 User::LeaveIfError( error ); |
|
234 } |
|
235 |
|
236 // ---------------------------------------------------------------------------- |
|
237 // CImpsGroupCommand2::PackAndSendL |
|
238 // ---------------------------------------------------------------------------- |
|
239 void CImpsGroupCommand2::PackAndSendL( TImpsMessageType aMsgType, TInt aOpId ) |
|
240 { |
|
241 SetMessageType( aMsgType ); |
|
242 PackMessageL( ); |
|
243 iMessagePtr.Set( iMessage->Des() ); |
|
244 TImpsServRequest req = EImpsServGroup; |
|
245 StartRunL( aOpId, EImpsServGroup ); |
|
246 iClient.SendReceive( req, TIpcArgs( &iMessagePtr, aOpId ), iStatus ); |
|
247 } |
|
248 |
|
249 // End of File |