|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] - do not remove |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <StifTestInterface.h> |
|
24 #include "imcache_test.h" |
|
25 |
|
26 #include "cimcachefactory.h" |
|
27 #include "mimcacheupdater.h" |
|
28 #include "mimcacheaccessor.h" |
|
29 #include "mimcacheeventhandler.h" |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // Cimcache_test::Delete |
|
36 // Delete here all resources allocated and opened from test methods. |
|
37 // Called from destructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 void Cimcache_test::Delete() |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // Cimcache_test::RunMethodL |
|
47 // Run specified method. Contains also table of test mothods and their names. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 TInt Cimcache_test::RunMethodL( |
|
51 CStifItemParser& aItem ) |
|
52 { |
|
53 |
|
54 static TStifFunctionInfo const KFunctions[] = |
|
55 { |
|
56 // Copy this line for every implemented function. |
|
57 // First string is the function name used in TestScripter script file. |
|
58 // Second is the actual implementation member function. |
|
59 ENTRY( "CreateSameUpdaterL", Cimcache_test::CreateSameUpdaterL ), |
|
60 ENTRY( "CreateDifferentUpdaterL", Cimcache_test::CreateDifferentUpdaterL ), |
|
61 ENTRY( "CreateSameAccessorL", Cimcache_test::CreateSameAccessorL ), |
|
62 ENTRY( "CreateDifferentAccessorL", Cimcache_test::CreateDifferentAccessorL ), |
|
63 ENTRY( "StartNewConversationL", Cimcache_test::StartNewConversationL ), |
|
64 ENTRY( "AppendSendMessageL", Cimcache_test::AppendSendMessageL ), |
|
65 ENTRY( "AppendRecieveMessageL", Cimcache_test::AppendRecieveMessageL ), |
|
66 ENTRY( "FetchExistingMessageL", Cimcache_test::FetchExistingMessageL), |
|
67 ENTRY( "DeactivateConversationL", Cimcache_test::DeactivateConversationL), |
|
68 ENTRY( "CloseConversationL", Cimcache_test::CloseConversationL ), |
|
69 ENTRY( "GetUnreadMsgCountL", Cimcache_test::GetUnreadMsgCountL ), |
|
70 ENTRY( "GetNewMsgNotificationtL", Cimcache_test::GetNewMsgNotificationtL ), |
|
71 |
|
72 ENTRY( "ConversationUnExistTestL", Cimcache_test::ConversationUnExistTestL ), |
|
73 ENTRY( "ConversationExistTestL", Cimcache_test::ConversationExistTestL ), |
|
74 |
|
75 ENTRY( "AppendMessageL", Cimcache_test::AppendMessageL ), |
|
76 ENTRY( "GetAllUnreadMsgCountL", Cimcache_test::GetAllUnreadMsgCountL ), |
|
77 |
|
78 |
|
79 ENTRY( "GetChatListTestL", Cimcache_test::GetChatListTestL ), |
|
80 ENTRY( "AccessorCloseConversationTestL", Cimcache_test::AccessorCloseConversationTestL ) |
|
81 |
|
82 //ADD NEW ENTRY HERE |
|
83 // [test cases entries] - Do not remove |
|
84 |
|
85 }; |
|
86 |
|
87 const TInt count = sizeof( KFunctions ) / |
|
88 sizeof( TStifFunctionInfo ); |
|
89 |
|
90 return RunInternalL( KFunctions, count, aItem ); |
|
91 |
|
92 } |
|
93 |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // Cimcache_test::CreateSameUpdaterL |
|
97 // Example test method function. |
|
98 // (other items were commented in a header). |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TInt Cimcache_test::CreateSameUpdaterL( CStifItemParser& /*aItem*/ ) |
|
102 { |
|
103 |
|
104 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
105 |
|
106 MIMCacheUpdater* updater1 = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue ); |
|
107 |
|
108 MIMCacheUpdater* updater2 = instance->CreateUpdaterL(1, _L("testlm123@gmail.com") ,ETrue); |
|
109 |
|
110 TInt error = KErrGeneral; |
|
111 |
|
112 if(updater1 == updater2 ) |
|
113 { |
|
114 error = KErrNone; |
|
115 } |
|
116 |
|
117 CIMCacheFactory::Release(); |
|
118 |
|
119 return error; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // Cimcache_test::CreateDifferentUpdaterL |
|
124 // Example test method function. |
|
125 // (other items were commented in a header). |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TInt Cimcache_test::CreateDifferentUpdaterL( CStifItemParser& /*aItem*/ ) |
|
129 { |
|
130 |
|
131 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
132 |
|
133 MIMCacheUpdater* updater1 = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue ); |
|
134 |
|
135 MIMCacheUpdater* updater2 = instance->CreateUpdaterL(2, _L("abc123@gmail.com") ,ETrue); |
|
136 |
|
137 TInt error = KErrGeneral; |
|
138 |
|
139 if(updater1 != updater2 ) |
|
140 { |
|
141 error = KErrNone; |
|
142 } |
|
143 |
|
144 CIMCacheFactory::Release(); |
|
145 |
|
146 return error; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // Cimcache_test::CreateSameAccessorL |
|
151 // Example test method function. |
|
152 // (other items were commented in a header). |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 TInt Cimcache_test::CreateSameAccessorL( CStifItemParser& /*aItem*/ ) |
|
156 { |
|
157 |
|
158 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
159 |
|
160 MIMCacheAccessor* accessor1 = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
161 |
|
162 MIMCacheAccessor* accessor2 = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
163 |
|
164 TInt error = KErrGeneral; |
|
165 |
|
166 if(accessor1 == accessor2 ) |
|
167 { |
|
168 error = KErrNone; |
|
169 } |
|
170 |
|
171 CIMCacheFactory::Release(); |
|
172 |
|
173 return error; |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // Cimcache_test::CreateDifferentAccessorL |
|
178 // Example test method function. |
|
179 // (other items were commented in a header). |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TInt Cimcache_test::CreateDifferentAccessorL( CStifItemParser& /*aItem*/ ) |
|
183 { |
|
184 |
|
185 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
186 |
|
187 MIMCacheAccessor* accessor1 = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
188 |
|
189 MIMCacheAccessor* accessor2 = instance->CreateAccessorL(2, _L("abc123@gmail.com") ); |
|
190 |
|
191 TInt error = KErrGeneral; |
|
192 |
|
193 if(accessor1 != accessor2 ) |
|
194 { |
|
195 error = KErrNone; |
|
196 } |
|
197 |
|
198 CIMCacheFactory::Release(); |
|
199 |
|
200 return error; |
|
201 } |
|
202 // ----------------------------------------------------------------------------- |
|
203 // Cimcache_test::StartNewConversationL |
|
204 // Example test method function. |
|
205 // (other items were commented in a header). |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 TInt Cimcache_test::StartNewConversationL( CStifItemParser& /*aItem*/ ) |
|
209 { |
|
210 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
211 |
|
212 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue ); |
|
213 updater->RegisterObserverL(*this); |
|
214 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
215 |
|
216 if( !iWait.IsStarted() ) |
|
217 { |
|
218 iWait.Start(); |
|
219 } |
|
220 updater->UnRegisterObserver(*this); |
|
221 CIMCacheFactory::Release(); |
|
222 return KErrNone; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // Cimcache_test::AppendSendMessageL |
|
227 // Example test method function. |
|
228 // (other items were commented in a header). |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 TInt Cimcache_test::AppendSendMessageL( CStifItemParser& /*aItem*/ ) |
|
232 { |
|
233 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
234 |
|
235 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com") ,ETrue); |
|
236 updater->RegisterObserverL(*this); |
|
237 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
238 |
|
239 if( !iWait.IsStarted() ) |
|
240 { |
|
241 iWait.Start(); |
|
242 } |
|
243 updater->AppendSendMessageL( _L("hello this is test message appended") ) ; |
|
244 updater->UnRegisterObserver(*this); |
|
245 CIMCacheFactory::Release(); |
|
246 return KErrNone; |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // Cimcache_test::AppendRecieveMessageL |
|
251 // Example test method function. |
|
252 // (other items were commented in a header). |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 TInt Cimcache_test::AppendRecieveMessageL( CStifItemParser& /*aItem*/ ) |
|
256 { |
|
257 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
258 |
|
259 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue ); |
|
260 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is test message appended") ) ; |
|
261 |
|
262 CIMCacheFactory::Release(); |
|
263 return KErrNone; |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // Cimcache_test::StartNewConversationL |
|
268 // Example test method function. |
|
269 // (other items were commented in a header). |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TInt Cimcache_test::FetchExistingMessageL( CStifItemParser& /*aItem*/ ) |
|
273 { |
|
274 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
275 TInt error = KErrNotFound; |
|
276 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com") ,ETrue); |
|
277 // tow message appended hence counter will be two. |
|
278 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is test first message appended") ) ; |
|
279 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is test second message appended") ) ; |
|
280 |
|
281 updater->RegisterObserverL(*this); |
|
282 |
|
283 if( !iWait.IsStarted() ) |
|
284 { |
|
285 iWait.Start(); |
|
286 } |
|
287 |
|
288 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
289 |
|
290 if( !iWait.IsStarted() ) |
|
291 { |
|
292 iWait.Start(); |
|
293 } |
|
294 updater->UnRegisterObserver(*this); |
|
295 CIMCacheFactory::Release(); |
|
296 if( iMessageFetch == 2) // two message should be fetched |
|
297 { |
|
298 error = KErrNone; |
|
299 } |
|
300 return error; |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // Cimcache_test::DeactivateConversationL |
|
305 // Example test method function. |
|
306 // (other items were commented in a header). |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 TInt Cimcache_test::DeactivateConversationL( CStifItemParser& /*aItem*/ ) |
|
310 { |
|
311 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
312 |
|
313 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue ); |
|
314 updater->RegisterObserverL(*this); |
|
315 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
316 |
|
317 if( !iWait.IsStarted() ) |
|
318 { |
|
319 iWait.Start(); |
|
320 } |
|
321 // close the active conversation |
|
322 updater->DeactivateConversationL(); |
|
323 |
|
324 updater->UnRegisterObserver(*this); |
|
325 CIMCacheFactory::Release(); |
|
326 return KErrNone; |
|
327 } |
|
328 // ----------------------------------------------------------------------------- |
|
329 // Cimcache_test::CloseConversationL |
|
330 // Example test method function. |
|
331 // (other items were commented in a header). |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 TInt Cimcache_test::CloseConversationL( CStifItemParser& /*aItem*/ ) |
|
335 { |
|
336 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
337 |
|
338 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue ); |
|
339 updater->RegisterObserverL(*this); |
|
340 |
|
341 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
342 |
|
343 if( !iWait.IsStarted() ) |
|
344 { |
|
345 iWait.Start(); |
|
346 } |
|
347 // close the active conversation |
|
348 updater->CloseConversationL( _L("testui123@gmail.com") ); |
|
349 |
|
350 if( !iWait.IsStarted() ) |
|
351 { |
|
352 iWait.Start(); |
|
353 } |
|
354 |
|
355 updater->UnRegisterObserver(*this); |
|
356 CIMCacheFactory::Release(); |
|
357 return KErrNone; |
|
358 } |
|
359 |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // Cimcache_test::GetUnreadMsgCountL |
|
363 // Example test method function. |
|
364 // (other items were commented in a header). |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 TInt Cimcache_test::GetUnreadMsgCountL(CStifItemParser& /*aItem*/) |
|
368 { |
|
369 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
370 |
|
371 MIMCacheAccessor* accessor = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
372 |
|
373 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"), ETrue ); |
|
374 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is test message appended") ) ; |
|
375 TInt count = accessor->GetUnreadMessageCountL( _L("testui123@gmail.com") ); |
|
376 CIMCacheFactory::Release(); |
|
377 if(count == 1) |
|
378 { |
|
379 return KErrNone; |
|
380 } |
|
381 return KErrArgument; |
|
382 } |
|
383 |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // Cimcache_test::GetUnreadMsgCountChangeL |
|
387 // Example test method function. |
|
388 // (other items were commented in a header). |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 TInt Cimcache_test::GetAllUnreadMsgCountL(CStifItemParser& /*aItem*/) |
|
392 { |
|
393 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
394 |
|
395 MIMCacheAccessor* accessor = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
396 |
|
397 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"), ETrue ); |
|
398 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is test message appended") ) ; |
|
399 updater->AppendReceiveMessageL( _L("meco1111@gmail.com"),_L("i am fine here") ) ; |
|
400 |
|
401 TInt count = accessor->GetAllUnreadMessageCountL( ); |
|
402 CIMCacheFactory::Release(); |
|
403 if(count == 2) |
|
404 { |
|
405 return KErrNone; |
|
406 } |
|
407 return KErrArgument; |
|
408 } |
|
409 // ----------------------------------------------------------------------------- |
|
410 // Cimcache_test::ConversationUnExistTestL |
|
411 // Example test method function. |
|
412 // (other items were commented in a header). |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 TInt Cimcache_test::ConversationUnExistTestL(CStifItemParser& /*aItem*/) |
|
416 { |
|
417 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
418 |
|
419 MIMCacheAccessor* accessor = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
420 // not yest conversation open so must be EFalse here |
|
421 TBool ret = accessor->IsConversationExistL(_L("testui123@gmail.com") ); |
|
422 |
|
423 CIMCacheFactory::Release(); |
|
424 |
|
425 if(!ret) |
|
426 { |
|
427 return KErrNone; |
|
428 } |
|
429 return KErrArgument; |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // Cimcache_test::ConversationExistTestL |
|
434 // Example test method function. |
|
435 // (other items were commented in a header). |
|
436 // ----------------------------------------------------------------------------- |
|
437 // |
|
438 TInt Cimcache_test::ConversationExistTestL(CStifItemParser& /*aItem*/) |
|
439 { |
|
440 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
441 |
|
442 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"), ETrue ); |
|
443 updater->RegisterObserverL(*this); |
|
444 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
445 |
|
446 if( !iWait.IsStarted() ) |
|
447 { |
|
448 iWait.Start(); |
|
449 } |
|
450 |
|
451 MIMCacheAccessor* accessor = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
452 // conversation already open so must be ETrue here |
|
453 TBool ret = accessor->IsConversationExistL( _L("testui123@gmail.com") ); |
|
454 |
|
455 updater->UnRegisterObserver(*this); |
|
456 |
|
457 CIMCacheFactory::Release(); |
|
458 |
|
459 if(ret) |
|
460 { |
|
461 return KErrNone; |
|
462 } |
|
463 return KErrArgument; |
|
464 } |
|
465 |
|
466 // ----------------------------------------------------------------------------- |
|
467 // Cimcache_test::AppendMessageL |
|
468 // Example test method function. |
|
469 // (other items were commented in a header). |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 TInt Cimcache_test::AppendMessageL( CStifItemParser& /*aItem*/ ) |
|
473 { |
|
474 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
475 |
|
476 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com") ,ETrue); |
|
477 updater->RegisterObserverL(*this); |
|
478 updater->StartNewConversationL( _L("testui123@gmail.com") ) ; |
|
479 |
|
480 if( !iWait.IsStarted() ) |
|
481 { |
|
482 iWait.Start(); |
|
483 } |
|
484 updater->AppendMessageL(_L("testui123@gmail.com"), _L("this is system or information message message") ) ; |
|
485 updater->UnRegisterObserver(*this); |
|
486 CIMCacheFactory::Release(); |
|
487 return KErrNone; |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // Cimcache_test::GetUnreadMsgCountL |
|
492 // Example test method function. |
|
493 // (other items were commented in a header). |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 TInt Cimcache_test::GetNewMsgNotificationtL(CStifItemParser& /*aItem*/) |
|
497 { |
|
498 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
499 MIMCacheAccessor* accessor = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
500 accessor->RegisterObserverL(*this); |
|
501 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),ETrue); |
|
502 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is new message notification") ) ; |
|
503 |
|
504 if( !iWait.IsStarted() ) |
|
505 { |
|
506 iWait.Start(); |
|
507 } |
|
508 accessor->UnRegisterObserver(*this); |
|
509 |
|
510 CIMCacheFactory::Release(); |
|
511 |
|
512 return KErrNone; |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // Cimcache_test::GetChatListTestL |
|
517 // Example test method function. |
|
518 // (other items were commented in a header). |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 TInt Cimcache_test::GetChatListTestL( CStifItemParser& /*aItem*/) |
|
522 { |
|
523 TInt error = KErrGeneral; |
|
524 |
|
525 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
526 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"), EFalse ); |
|
527 |
|
528 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is new message notification 1 ") ) ; |
|
529 updater->AppendReceiveMessageL( _L("abc123@gmail.com"),_L("hello this is new message notification 2 ") ) ; |
|
530 updater->AppendReceiveMessageL( _L("testgizmo123@gmail.com"),_L("hello this is new message notification 3 ") ) ; |
|
531 |
|
532 |
|
533 RArray<SIMCacheChatItem> listArray = updater->GetChatListL( 1 ); |
|
534 |
|
535 if( listArray.Count() == 3 ) // total 3 chat created in server |
|
536 { |
|
537 error = KErrNone; |
|
538 } |
|
539 |
|
540 CIMCacheFactory::Release(); |
|
541 |
|
542 return error; |
|
543 } |
|
544 // ----------------------------------------------------------------------------- |
|
545 // Cimcache_test::AccessorCloseConversationTestL |
|
546 // Example test method function. |
|
547 // (other items were commented in a header). |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 TInt Cimcache_test::AccessorCloseConversationTestL( CStifItemParser& /*aItem*/) |
|
551 { |
|
552 TInt error = KErrGeneral; |
|
553 |
|
554 CIMCacheFactory* instance = CIMCacheFactory::InstanceL(); |
|
555 |
|
556 MIMCacheUpdater* updater = instance->CreateUpdaterL(1, _L("testlm123@gmail.com"),EFalse ); |
|
557 updater->AppendReceiveMessageL( _L("testui123@gmail.com"),_L("hello this is new message notification 1 ") ) ; |
|
558 |
|
559 MIMCacheAccessor* accessor = instance->CreateAccessorL(1, _L("testlm123@gmail.com") ); |
|
560 accessor->RegisterObserverL(*this); |
|
561 |
|
562 if( accessor->IsConversationExistL(_L("testui123@gmail.com") ) ) |
|
563 { |
|
564 // close the active conversation |
|
565 accessor->CloseConversationL( _L("testui123@gmail.com") ); |
|
566 |
|
567 if( !iWait.IsStarted() ) |
|
568 { |
|
569 iWait.Start(); |
|
570 } |
|
571 error = KErrNone; |
|
572 } |
|
573 |
|
574 accessor->UnRegisterObserver(*this); |
|
575 |
|
576 CIMCacheFactory::Release(); |
|
577 |
|
578 return error; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // Cimcache_test::HandleIMCacheNewMessageEventL |
|
583 // Example test method function. |
|
584 // (other items were commented in a header). |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 |
|
588 void Cimcache_test::HandleIMCacheEventL( TIMCacheEventType aEventType, TAny* /*aChatMessage*/ ) |
|
589 { |
|
590 switch( aEventType ) |
|
591 { |
|
592 case EIMCacheUnreadMessage : |
|
593 { |
|
594 if( iWait.IsStarted() ) |
|
595 { |
|
596 iWait.AsyncStop(); |
|
597 } |
|
598 break; |
|
599 } |
|
600 case EIMCacheUnreadChange : |
|
601 { |
|
602 if( iWait.IsStarted() ) |
|
603 { |
|
604 iWait.AsyncStop(); |
|
605 } |
|
606 break; |
|
607 } |
|
608 |
|
609 case EIMCacheRequestCompleted : |
|
610 { |
|
611 if( iWait.IsStarted() ) |
|
612 { |
|
613 iWait.AsyncStop(); |
|
614 } |
|
615 break; |
|
616 } |
|
617 case EIMCacheNewMessage : |
|
618 { |
|
619 iMessageFetch++; |
|
620 if( iWait.IsStarted() && iMessageFetch == 2 ) |
|
621 { |
|
622 iWait.AsyncStop(); |
|
623 } |
|
624 break; |
|
625 } |
|
626 case EIMCacheNewChat: |
|
627 { |
|
628 if( iWait.IsStarted() ) |
|
629 { |
|
630 iWait.AsyncStop(); |
|
631 } |
|
632 break; |
|
633 } |
|
634 case EIMCacheChatClosed: |
|
635 { |
|
636 if( iWait.IsStarted() ) |
|
637 { |
|
638 iWait.AsyncStop(); |
|
639 } |
|
640 break; |
|
641 } |
|
642 |
|
643 } |
|
644 } |
|
645 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
646 // None |
|
647 |
|
648 // end of file |