equal
deleted
inserted
replaced
|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include "CntClient.h" |
|
18 |
|
19 CCntClient::CCntClient(RTest &aTest, const TDesC &aDatabaseName) |
|
20 { |
|
21 iDatabaseName.Copy(aDatabaseName); |
|
22 iTest=&aTest; |
|
23 iTest->Start(_L("New client")); |
|
24 } |
|
25 |
|
26 CCntClient::~CCntClient() |
|
27 { |
|
28 CloseDatabase(); |
|
29 iTest->End(); |
|
30 } |
|
31 |
|
32 CContactDatabase* CCntClient::CreateDatabaseL() |
|
33 { |
|
34 CloseDatabase(); |
|
35 iDb=CContactDatabase::ReplaceL(iDatabaseName); |
|
36 iNotifier = CContactChangeNotifier::NewL(*iDb,this); |
|
37 iObservers++; // |
|
38 return(iDb); |
|
39 } |
|
40 |
|
41 CContactDatabase* CCntClient::OpenDatabaseL() |
|
42 { |
|
43 if(!iDb) |
|
44 iDb=CContactDatabase::OpenL(iDatabaseName); |
|
45 if(!iNotifier) |
|
46 { |
|
47 iNotifier = CContactChangeNotifier::NewL(*iDb,this); |
|
48 iObservers++;// |
|
49 } |
|
50 return(iDb); |
|
51 } |
|
52 |
|
53 void CCntClient::CloseDatabase() |
|
54 { |
|
55 if (iNotifier) |
|
56 { |
|
57 iObservers--; |
|
58 } |
|
59 delete iNotifier; |
|
60 iNotifier = NULL; |
|
61 delete iDb; |
|
62 iDb=NULL; |
|
63 } |
|
64 |
|
65 void CCntClient::HandleDatabaseEventL(TContactDbObserverEvent aEvent) |
|
66 { |
|
67 static TInt i=0; |
|
68 if(aEvent.iType == EContactDbObserverEventGroupAdded) |
|
69 { |
|
70 i++; |
|
71 } |
|
72 |
|
73 if (i==iObservers) |
|
74 { |
|
75 // Stop the scheduler when all the clients have handled the event |
|
76 CActiveScheduler::Stop(); |
|
77 i=0; |
|
78 } |
|
79 } |