|
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 * fundemental feature client interface. |
|
16 * Issues WV requests belonging to the Fundamental API |
|
17 * |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "impsfundhandler.h" |
|
24 #include "impsfundcommand.h" |
|
25 #include "impsfundcli.h" |
|
26 #include "impscdatautils.h" |
|
27 #include "impsutils.h" |
|
28 |
|
29 // MACROS |
|
30 #ifndef _DEBUG |
|
31 #define _NO_IMPS_LOGGING_ |
|
32 #endif |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // RImpsFundClient2::RImpsFundClient2 |
|
38 // --------------------------------------------------------- |
|
39 EXPORT_C RImpsFundClient2::RImpsFundClient2() : |
|
40 RImpsClient2(), |
|
41 iCommand( NULL ), |
|
42 iSearchCallBack( NULL ), |
|
43 iInviteCallBack( NULL ) |
|
44 { |
|
45 SetOpIdRange( ); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // RImpsFundClient2::RegisterL |
|
50 // --------------------------------------------------------- |
|
51 EXPORT_C void RImpsFundClient2::RegisterL( |
|
52 RImpsEng& aEngine, |
|
53 MImpsSearchHandler2* aSearchObs, |
|
54 MImpsInviteHandler2* aInviteObs, |
|
55 const TDesC& aClientId, |
|
56 TBool aReceiveNew, |
|
57 TInt aPriority ) |
|
58 { |
|
59 iSearchCallBack = aSearchObs; |
|
60 iInviteCallBack = aInviteObs; |
|
61 iHandler = CImpsFundHandler2::NewL( *this, aPriority ); |
|
62 iCommand = CImpsFundCommand2::NewL( *this ); |
|
63 iActiveCommand = iCommand; |
|
64 |
|
65 // Start the handler |
|
66 iHandler->StartRun(); |
|
67 iHandleNew = aReceiveNew; |
|
68 iAnyContent = EFalse; |
|
69 |
|
70 // Send registeration to the server thread |
|
71 TInt err = DoRegister( aEngine, iHandler ); |
|
72 User::LeaveIfError( err ); |
|
73 |
|
74 DoAssign( aClientId ); |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // RImpsFundClient2::Unregister() |
|
79 // ---------------------------------------------------------------------------- |
|
80 EXPORT_C void RImpsFundClient2::Unregister() |
|
81 { |
|
82 DoUnregister(); |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // RImpsFundClient2::DoRegister() |
|
87 // ---------------------------------------------------------------------------- |
|
88 TInt RImpsFundClient2::DoRegister( |
|
89 RImpsEng& aEngine, |
|
90 CImpsHandler2* aHandler ) |
|
91 { |
|
92 return DoRegister2( aEngine, aHandler, EImpsFundRegister ); |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // RImpsFundClient2::SearchFirstL |
|
97 // ---------------------------------------------------------------------------- |
|
98 EXPORT_C TInt RImpsFundClient2::SearchFirstL( const CSearchPairs& aPairs, |
|
99 TInt aSearchLimit ) |
|
100 { |
|
101 IncreaseOpId( ); |
|
102 iCommand->InitialiseL( KSearchRequestElements, |
|
103 sizeof( KSearchRequestElements ) / |
|
104 sizeof( KSearchRequestElements[0] ) ); |
|
105 TInt count = aPairs.Count(); |
|
106 if( count > 0 ) |
|
107 { |
|
108 iCommand->MakeSearchPairListL( aPairs ); |
|
109 iCommand->InsertIntegerElementL( aSearchLimit, EImpsKeySearchLimit, 0 ); |
|
110 } |
|
111 else |
|
112 User::Leave( KErrCorrupt); |
|
113 iCommand->PackAndSendL( EImpsSearchReq, iOpId ); |
|
114 #ifndef _NO_IMPS_LOGGING_ |
|
115 CImpsClientLogger::Log(_L("RImpsFundClient2: SearchFirstL opid=%d cli=%d"), |
|
116 iOpId, (TInt)this ); |
|
117 #endif |
|
118 return iOpId; |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // RImpsFundClient2::SearchNextL |
|
123 // ---------------------------------------------------------------------------- |
|
124 EXPORT_C TInt RImpsFundClient2::SearchNextL( TInt aSearchID, TInt aIndex ) |
|
125 { |
|
126 IncreaseOpId( ); |
|
127 iCommand->InitialiseL( KSearchRequestElements, |
|
128 sizeof( KSearchRequestElements ) / |
|
129 sizeof( KSearchRequestElements[0] ) ); |
|
130 iCommand->InsertIntegerElementL( aSearchID, EImpsKeySearchID, 0 ); |
|
131 iCommand->InsertIntegerElementL( aIndex, EImpsKeySearchIndex, 0 ); |
|
132 iCommand->PackAndSendL( EImpsSearchReq, iOpId ); |
|
133 |
|
134 #ifndef _NO_IMPS_LOGGING_ |
|
135 CImpsClientLogger::Log(_L("RImpsFundClient2: SearchNextL opid=%d cli=%d"), |
|
136 iOpId, (TInt)this ); |
|
137 #endif |
|
138 |
|
139 return iOpId; |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // RImpsFundClient2::StopSearchL |
|
144 // |
|
145 // ---------------------------------------------------------------------------- |
|
146 EXPORT_C TInt RImpsFundClient2::StopSearchL( TInt aSearchID ) |
|
147 { |
|
148 IncreaseOpId( ); |
|
149 iCommand->InitialiseL( KSearchStopRequestElements, |
|
150 sizeof( KSearchStopRequestElements ) / |
|
151 sizeof( KSearchStopRequestElements[0] ) ); |
|
152 iCommand->InsertIntegerElementL( aSearchID, EImpsKeySearchID, 0 ); |
|
153 iCommand->PackAndSendL( EImpsStopSearchReq, iOpId ); |
|
154 |
|
155 #ifndef _NO_IMPS_LOGGING_ |
|
156 CImpsClientLogger::Log(_L("RImpsFundClient2: StopSearchL opid=%d cli=%d"), |
|
157 iOpId, (TInt)this ); |
|
158 #endif |
|
159 |
|
160 return iOpId; |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // RImpsFundClient2::GroupInviteL |
|
165 // ---------------------------------------------------------------------------- |
|
166 EXPORT_C TInt RImpsFundClient2::GroupInviteL( const TDesC& aInviteID, |
|
167 const MDesCArray* aUserID, |
|
168 const MDesCArray* aScreenName, |
|
169 const MDesCArray* aGroupName, |
|
170 const TDesC& aInviteGroup, |
|
171 const TDesC& aOwnScreenName, |
|
172 const TDesC& aOwnGroupName, |
|
173 const TDesC& aInviteReason, |
|
174 const TInt aValidityPeriod ) |
|
175 { |
|
176 IncreaseOpId( ); |
|
177 TBool recipients = EFalse; |
|
178 iCommand->InitialiseL( KInviteRequestElements, |
|
179 sizeof( KInviteRequestElements ) / |
|
180 sizeof( KInviteRequestElements[0] ) ); |
|
181 iCommand->InsertDescriptorElementL( aInviteID, EImpsKeyInviteID, 0 ); |
|
182 iCommand->InsertIntegerElementL( EImpsGR, EImpsKeyInviteType, 0 ); |
|
183 iCommand->InsertEmptyElementL( EImpsKeyRecipient, 0 ); |
|
184 if( aUserID != NULL && aUserID->MdcaCount() > 0 ) |
|
185 { |
|
186 iCommand->SetUserIDsL( aUserID ); |
|
187 recipients = ETrue; |
|
188 } |
|
189 if( aScreenName != NULL && aScreenName->MdcaCount() > 0 ) |
|
190 { |
|
191 iCommand->InsertEmptyElementL( EImpsKeyGroup, 0 ); |
|
192 iCommand->SetScreenNamesL( aScreenName, aGroupName ); |
|
193 recipients = ETrue; |
|
194 } |
|
195 iCommand->PopElementL(); //recipient |
|
196 //No recipients defined, please try again... |
|
197 if( !recipients ) |
|
198 User::Leave( KErrCorrupt ); |
|
199 //This is mandatory |
|
200 iCommand->InsertDescriptorElementL( aInviteGroup, EImpsKeyGroupID, 0 ); |
|
201 //This is not |
|
202 if( aInviteReason.Length() > 0 ) |
|
203 iCommand->InsertDescriptorElementL( aInviteReason, |
|
204 EImpsKeyInviteNote, 0 ); |
|
205 //Nor are these |
|
206 if( aOwnScreenName.Length() > 0 ) |
|
207 { |
|
208 iCommand->InsertEmptyElementL( EImpsKeyScreenName, 0 ); |
|
209 iCommand->InsertDescriptorElementL( aOwnScreenName, EImpsKeySName, 0 ); |
|
210 iCommand->InsertDescriptorElementL( aOwnGroupName, EImpsKeyGroupID, 0 ); |
|
211 iCommand->PopElementL(); // screen name |
|
212 } |
|
213 iCommand->InsertIntegerElementL( aValidityPeriod, EImpsKeyValidity, 0 ); |
|
214 iCommand->PackAndSendL( EImpsInviteReq, iOpId ); |
|
215 |
|
216 #ifndef _NO_IMPS_LOGGING_ |
|
217 CImpsClientLogger::Log(_L("RImpsFundClient2: GroupInviteL opid=%d cli=%d"), |
|
218 iOpId, (TInt)this ); |
|
219 #endif |
|
220 |
|
221 return iOpId; |
|
222 } |
|
223 |
|
224 // ---------------------------------------------------------------------------- |
|
225 // RImpsFundClient2::ImInviteL |
|
226 // ---------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C TInt RImpsFundClient2::ImInviteL( const TDesC& aInviteID, |
|
229 const TDesC& aUserID, |
|
230 const TDesC& aInviteReason, |
|
231 const TInt aValidityPeriod ) |
|
232 { |
|
233 IncreaseOpId( ); |
|
234 |
|
235 iCommand->InitialiseL( KInviteRequestElements, |
|
236 sizeof( KInviteRequestElements ) / |
|
237 sizeof( KInviteRequestElements[0] ) ); |
|
238 iCommand->InsertDescriptorElementL( aInviteID, EImpsKeyInviteID, 0 ); |
|
239 iCommand->InsertIntegerElementL( EImpsIM, EImpsKeyInviteType, 0 ); |
|
240 iCommand->InsertEmptyElementL( EImpsKeyRecipient, 0 ); |
|
241 iCommand->InsertDescriptorElementL( aUserID, EImpsKeyUserID, 0 ); |
|
242 iCommand->PopElementL(); // recipient |
|
243 if( aInviteReason.Length() > 0 ) |
|
244 { |
|
245 iCommand->InsertDescriptorElementL( aInviteReason, |
|
246 EImpsKeyInviteNote, 0 ); |
|
247 } |
|
248 iCommand->InsertIntegerElementL( aValidityPeriod, EImpsKeyValidity, 0 ); |
|
249 iCommand->PackAndSendL( EImpsInviteReq, iOpId ); |
|
250 |
|
251 #ifndef _NO_IMPS_LOGGING_ |
|
252 CImpsClientLogger::Log(_L("RImpsFundClient2: GroupInviteL opid=%d cli=%d"), |
|
253 iOpId, (TInt)this ); |
|
254 #endif |
|
255 |
|
256 return iOpId; |
|
257 |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // RImpsFundClient2::CancelInviteL |
|
262 // ---------------------------------------------------------------------------- |
|
263 EXPORT_C TInt RImpsFundClient2::CancelInviteL( const TDesC& aInviteId, |
|
264 const MDesCArray* aUserID, |
|
265 const MDesCArray* aScreenName, |
|
266 const MDesCArray* aGroupName, |
|
267 const TDesC& aCancelReason, |
|
268 const TDesC& aOwnScreenName, |
|
269 const TDesC& aOwnGroupName ) |
|
270 { |
|
271 IncreaseOpId( ); |
|
272 TBool recipients = EFalse; |
|
273 iCommand->InitialiseL( KInviteCancelRequestElements, |
|
274 sizeof( KInviteCancelRequestElements ) / |
|
275 sizeof( KInviteCancelRequestElements[0] ) ); |
|
276 iCommand->InsertDescriptorElementL( aInviteId, EImpsKeyInviteID, 0 ); |
|
277 iCommand->InsertEmptyElementL( EImpsKeyRecipient, 0 ); |
|
278 if( aUserID != NULL && aUserID->MdcaCount() > 0 ) |
|
279 { |
|
280 iCommand->SetUserIDsL( aUserID ); |
|
281 recipients = ETrue; |
|
282 } |
|
283 if( aScreenName != NULL && aScreenName->MdcaCount() > 0 ) |
|
284 { |
|
285 iCommand->InsertEmptyElementL( EImpsKeyGroup, 0 ); |
|
286 iCommand->SetScreenNamesL( aScreenName, aGroupName ); |
|
287 recipients = ETrue; |
|
288 } |
|
289 iCommand->PopElementL( 2 ); //group, recipient |
|
290 //No recipients defined, please try again... |
|
291 if( !recipients ) |
|
292 User::Leave( KErrCorrupt ); |
|
293 if( aCancelReason.Length() != 0 ) |
|
294 iCommand->InsertDescriptorElementL( aCancelReason, EImpsKeyInviteNote, 0 ); |
|
295 if( aOwnScreenName.Length() > 0 ) |
|
296 { |
|
297 iCommand->InsertEmptyElementL( EImpsKeyScreenName, 0 ); |
|
298 iCommand->InsertDescriptorElementL( aOwnScreenName, EImpsKeySName, 0 ); |
|
299 iCommand->InsertDescriptorElementL( aOwnGroupName, EImpsKeyGroupID, 0 ); |
|
300 } |
|
301 iCommand->PackAndSendL( EImpsCancelInviteReq, iOpId ); |
|
302 |
|
303 #ifndef _NO_IMPS_LOGGING_ |
|
304 CImpsClientLogger::Log(_L("RImpsFundClient2: CancelInviteL opid=%d cli=%d"), |
|
305 iOpId, (TInt)this ); |
|
306 #endif |
|
307 |
|
308 return iOpId; |
|
309 } |
|
310 |
|
311 // ---------------------------------------------------------------------------- |
|
312 // RImpsFundClient2::InviteResponseL |
|
313 // ---------------------------------------------------------------------------- |
|
314 EXPORT_C TInt RImpsFundClient2::InviteResponseL( const TDesC& aInviteId, |
|
315 TBool aAcceptance, |
|
316 const TDesC& aInviteResponse, |
|
317 const TDesC& aOwnScreenName, |
|
318 const TDesC& aOwnGroupName ) |
|
319 |
|
320 { |
|
321 IncreaseOpId( ); |
|
322 iCommand->InitialiseL( KInviteUserResponseElements, |
|
323 sizeof( KInviteUserResponseElements ) / |
|
324 sizeof( KInviteUserResponseElements[0] ) ); |
|
325 iCommand->InsertDescriptorElementL( aInviteId, EImpsKeyInviteID, 0 ); |
|
326 iCommand->InsertBooleanElementL( aAcceptance, EImpsKeyAcceptance, 0 ); |
|
327 if( aInviteResponse.Length() != 0 ) |
|
328 { |
|
329 iCommand->InsertDescriptorElementL( aInviteResponse, EImpsKeyResponseNote, 0 ); |
|
330 } |
|
331 if( aOwnScreenName.Length() != 0 ) |
|
332 { |
|
333 iCommand->InsertEmptyElementL( EImpsKeyScreenName, 0 ); |
|
334 iCommand->InsertDescriptorElementL( aOwnScreenName, EImpsKeySName, 0 ); |
|
335 iCommand->InsertDescriptorElementL( aOwnGroupName, EImpsKeyGroupID, 0 ); |
|
336 } |
|
337 iCommand->PackAndSendL( EImpsInviteUserRes, iOpId ); |
|
338 #ifndef _NO_IMPS_LOGGING_ |
|
339 CImpsClientLogger::Log(_L("RImpsFundClient2: InviteResponseL opid=%d cli=%d"), |
|
340 iOpId, (TInt)this ); |
|
341 #endif |
|
342 return iOpId; |
|
343 } |
|
344 |
|
345 |
|
346 |
|
347 // End of File |
|
348 |
|
349 |