|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Implementation of class CESMRContactManagerHandler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "cesmrcontactmanagerhandler.h" |
|
21 |
|
22 #include <cvpbkcontactmanager.h> |
|
23 #include <cvpbkcontactstoreuriarray.h> |
|
24 #include <mvpbkcontactstorelist.h> |
|
25 #include <vpbkcontactstoreuris.h> |
|
26 #include <tvpbkcontactstoreuriptr.h> |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CESMRContactManagerHandler::CESMRContactManagerHandler |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CESMRContactManagerHandler::CESMRContactManagerHandler() |
|
35 { |
|
36 FUNC_LOG; |
|
37 // Do nothing |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CESMRContactManagerHandler::NewL |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CESMRContactManagerHandler* CESMRContactManagerHandler::NewL() |
|
45 { |
|
46 FUNC_LOG; |
|
47 CESMRContactManagerHandler* self = new (ELeave) CESMRContactManagerHandler(); |
|
48 CleanupStack::PushL (self ); |
|
49 self->ConstructL ( ); |
|
50 CleanupStack::Pop (self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CESMRContactManagerHandler::ConstructL |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void CESMRContactManagerHandler::ConstructL ( ) |
|
59 { |
|
60 FUNC_LOG; |
|
61 CVPbkContactStoreUriArray* uriList = CVPbkContactStoreUriArray::NewLC(); |
|
62 uriList->AppendL(VPbkContactStoreUris::DefaultCntDbUri() ); |
|
63 iContactManager = CVPbkContactManager::NewL( *uriList ); |
|
64 CleanupStack::PopAndDestroy(uriList); |
|
65 |
|
66 MVPbkContactStoreList& stores = iContactManager->ContactStoresL( ); |
|
67 stores.OpenAllL( *this ); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CESMRContactManagerHandler::~CESMRContactManagerHandler |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CESMRContactManagerHandler::~CESMRContactManagerHandler() |
|
75 { |
|
76 FUNC_LOG; |
|
77 delete iContactManager; |
|
78 iObservers.Reset(); |
|
79 iObservers.Close(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CESMRContactManagerHandler::IsReady |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C TBool CESMRContactManagerHandler::IsReady() |
|
87 { |
|
88 FUNC_LOG; |
|
89 return iContactManagerReady; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CESMRContactManagerHandler::AddObserverL |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C void CESMRContactManagerHandler::AddObserverL( |
|
97 MESMRContactManagerObserver* aObserver ) |
|
98 { |
|
99 FUNC_LOG; |
|
100 if ( iObservers.Find(aObserver) == KErrNotFound ) |
|
101 { |
|
102 iObservers.AppendL(aObserver); |
|
103 } |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CESMRContactManagerHandler::RemoveObserver |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C void CESMRContactManagerHandler::RemoveObserver( |
|
111 MESMRContactManagerObserver* aObserver ) |
|
112 { |
|
113 FUNC_LOG; |
|
114 TInt index = iObservers.Find(aObserver ); |
|
115 if ( index != KErrNotFound ) |
|
116 { |
|
117 iObservers.Remove(index ); |
|
118 } |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CESMRContactManagerHandler::GetContactManager |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C CVPbkContactManager& CESMRContactManagerHandler::GetContactManager() |
|
126 { |
|
127 FUNC_LOG; |
|
128 return *iContactManager; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CESMRContactManagerHandler::OpenComplete |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CESMRContactManagerHandler::OpenComplete ( ) |
|
136 { |
|
137 FUNC_LOG; |
|
138 iContactManagerReady = ETrue; |
|
139 const TInt count(iObservers.Count()); |
|
140 for (TInt i=count-1; i>=0; --i ) |
|
141 { |
|
142 iObservers[i]->ContactManagerReady( ); |
|
143 } |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CESMRContactManagerHandler::StoreReady |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CESMRContactManagerHandler::StoreReady( |
|
151 MVPbkContactStore& /*aContactStore*/ ) |
|
152 { |
|
153 FUNC_LOG; |
|
154 // Do nothing |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CESMRContactManagerHandler::StoreUnavailable |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CESMRContactManagerHandler::StoreUnavailable ( |
|
162 MVPbkContactStore& /*aContactStore*/, TInt /*aReason*/) |
|
163 { |
|
164 FUNC_LOG; |
|
165 // Do nothing |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CESMRContactManagerHandler::HandleStoreEventL |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void CESMRContactManagerHandler::HandleStoreEventL ( |
|
173 MVPbkContactStore& /*aContactStore*/, |
|
174 TVPbkContactStoreEvent /*aStoreEvent*/) |
|
175 { |
|
176 FUNC_LOG; |
|
177 // Do nothing |
|
178 } |
|
179 |
|
180 // End of file |
|
181 |