|
1 /* |
|
2 * Copyright (c) 2002 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 * Check if a Contact Link is valid |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CLogsCntLinkChecker.h" |
|
21 #include "MLogsObserver.h" |
|
22 #include "MLogsReaderConfig.h" |
|
23 |
|
24 // EXTERNAL DATA STRUCTURES |
|
25 |
|
26 // EXTERNAL FUNCTION PROTOTYPES |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // LOCAL CONSTANTS AND MACROS |
|
33 |
|
34 // MODULE DATA STRUCTURES |
|
35 |
|
36 // LOCAL FUNCTION PROTOTYPES |
|
37 |
|
38 // ==================== LOCAL FUNCTIONS ==================== |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CLogsCntLinkChecker::CLogsCntLinkChecker |
|
45 // ---------------------------------------------------------------------------- |
|
46 // |
|
47 CLogsCntLinkChecker::CLogsCntLinkChecker( |
|
48 RFs& aFsSession, |
|
49 MLogsObserver* aObserver ) : |
|
50 CLogsBaseUpdater( aFsSession, aObserver), |
|
51 iContactLinkValid( EFalse ) |
|
52 { |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CLogsCntLinkChecker::NewL |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 CLogsCntLinkChecker* CLogsCntLinkChecker::NewL( |
|
60 RFs& aFsSession, |
|
61 MLogsObserver* aObserver ) |
|
62 { |
|
63 CLogsCntLinkChecker* self = new ( ELeave ) CLogsCntLinkChecker( aFsSession, aObserver ); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // CLogsCntLinkChecker::ConstructL |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 void CLogsCntLinkChecker::ConstructL() |
|
75 { |
|
76 BaseConstructL(CVPbkPhoneNumberMatchStrategy::EVPbkExactMatchFlag); |
|
77 iWait = new( ELeave )CActiveSchedulerWait(); |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CLogsCntLinkChecker::~CLogsEventUpdater |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CLogsCntLinkChecker::~CLogsCntLinkChecker() |
|
85 { |
|
86 delete iContactLink; |
|
87 |
|
88 if ( iWait ) |
|
89 { |
|
90 if( iWait->IsStarted() ) |
|
91 { |
|
92 iWait->AsyncStop(); |
|
93 } |
|
94 delete iWait; |
|
95 iWait = NULL; |
|
96 } |
|
97 } |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CLogsCntLinkChecker::StartRunningL |
|
101 // |
|
102 // Called from base class |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 void CLogsCntLinkChecker::StartRunningL() |
|
106 { |
|
107 //Important that ConfigureL is called before we start here |
|
108 if( iContactLink ) |
|
109 { |
|
110 //We first try to search corresponding contact for this phonenumber from Phonebook |
|
111 SearchContactLinkL( *iContactLink ); |
|
112 } |
|
113 } |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CLogsCntLinkChecker::ContinueRunningL |
|
117 // ---------------------------------------------------------------------------- |
|
118 // |
|
119 void CLogsCntLinkChecker::ContinueRunningL( TInt aFieldId ) |
|
120 { |
|
121 iContactLinkValid = EFalse; |
|
122 |
|
123 if( aFieldId != KErrNotFound ) |
|
124 { |
|
125 iContactLinkValid = ETrue; |
|
126 } |
|
127 |
|
128 iState = EStateCheckContactLinkFinished; |
|
129 iPhase = EDone; |
|
130 |
|
131 if( iWait->IsStarted() ) |
|
132 { |
|
133 iWait->AsyncStop(); |
|
134 } |
|
135 |
|
136 if ( iObserver ) |
|
137 { |
|
138 iObserver->StateChangedL( this ); |
|
139 } |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // CLogsCntLinkChecker::CntLinkDeletedL |
|
144 // ---------------------------------------------------------------------------- |
|
145 // |
|
146 void CLogsCntLinkChecker::CntLinkDeletedL() |
|
147 { |
|
148 if( iContactLink ) |
|
149 { |
|
150 delete iContactLink; |
|
151 iContactLink = NULL; |
|
152 } |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CLogsCntLinkChecker::ConfigureL |
|
157 // |
|
158 // Sets the contact link which is used to retrieve the contact. |
|
159 // ---------------------------------------------------------------------------- |
|
160 // |
|
161 void CLogsCntLinkChecker::ConfigureL( const MLogsReaderConfig* aConfig ) //Implemented from MLogsReader |
|
162 { |
|
163 if( iContactLink ) |
|
164 { |
|
165 delete iContactLink; |
|
166 iContactLink = NULL; |
|
167 } |
|
168 iState = EStateUndefined; |
|
169 iContactLink = aConfig->ContactLink().AllocL(); |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------- |
|
173 // CLogsCntLinkChecker::IsSameContactLink |
|
174 // |
|
175 // Check if contact link is the same one, if same, no need to reconfig it. |
|
176 // ---------------------------------------------------------------------------- |
|
177 // |
|
178 EXPORT_C TBool CLogsCntLinkChecker::IsSameContactLink( const TDesC8& aContactLink ) const |
|
179 { |
|
180 TBool flag = EFalse; |
|
181 |
|
182 if ( iContactLink |
|
183 && 0 == iContactLink->Compare( aContactLink ) |
|
184 && ( iState == EStateCheckContactLinkFinished |
|
185 || iState == EStateInitializing ) ) |
|
186 { |
|
187 flag = ETrue; |
|
188 } |
|
189 return flag; |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CLogsCntLinkChecker::IsCntLinkValidSync |
|
194 // |
|
195 // Check if contact link is valid. |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C TBool CLogsCntLinkChecker::IsCntLinkValidSync ( const TDesC8& aContactLink ) |
|
199 { |
|
200 TBool flag = EFalse; |
|
201 |
|
202 if ( !iContactLink || 0 != iContactLink->Compare(aContactLink) ) |
|
203 { |
|
204 return flag; |
|
205 } |
|
206 |
|
207 if ( iState == EStateInitializing ) |
|
208 { |
|
209 if( !(iWait->IsStarted()) ) |
|
210 { |
|
211 iWait->Start(); |
|
212 } |
|
213 } |
|
214 if ( iState == EStateCheckContactLinkFinished ) |
|
215 { |
|
216 if( iContactLinkValid ) |
|
217 { |
|
218 flag = ETrue; |
|
219 } |
|
220 else |
|
221 { |
|
222 flag = EFalse; |
|
223 } |
|
224 } |
|
225 |
|
226 return flag; |
|
227 } |
|
228 |
|
229 // ---------------------------------------------------------------------------- |
|
230 // CLogsCntLinkChecker::RunL |
|
231 // ---------------------------------------------------------------------------- |
|
232 // |
|
233 void CLogsCntLinkChecker::RunL() |
|
234 { |
|
235 |
|
236 } |
|
237 |
|
238 // ---------------------------------------------------------------------------- |
|
239 // CLogsCntLinkChecker::Stop |
|
240 // ---------------------------------------------------------------------------- |
|
241 // |
|
242 void CLogsCntLinkChecker::Stop() |
|
243 { |
|
244 if ( iOperation ) |
|
245 { |
|
246 delete iOperation; |
|
247 iOperation = NULL; |
|
248 iPbkOperationsOngoing = EFalse; |
|
249 iState = EStateInterrupted; |
|
250 } |
|
251 |
|
252 if ( iWait->IsStarted() ) |
|
253 { |
|
254 iWait->AsyncStop(); |
|
255 } |
|
256 return; |
|
257 } |
|
258 |
|
259 // ---------------------------------------------------------------------------- |
|
260 // CLogsCntLinkChecker::ProcessVPbkSingleContactOperationCompleteImplL |
|
261 // ---------------------------------------------------------------------------- |
|
262 // |
|
263 void CLogsCntLinkChecker::ProcessVPbkSingleContactOperationCompleteImplL( |
|
264 MVPbkContactOperationBase& /* aOperation */, |
|
265 MVPbkStoreContact* /*aContact)*/ ) |
|
266 { |
|
267 |
|
268 } |
|
269 |
|
270 // ---------------------------------------------------------------------------- |
|
271 // CLogsCntLinkChecker::HandleStoreEventL |
|
272 // ---------------------------------------------------------------------------- |
|
273 // |
|
274 void CLogsCntLinkChecker::HandleStoreEventL( MVPbkContactStore& /*aContactStore */, |
|
275 TVPbkContactStoreEvent aStoreEvent ) |
|
276 { |
|
277 if(aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactDeleted) |
|
278 { |
|
279 CntLinkDeletedL(); |
|
280 } |
|
281 } |
|
282 // End of File |
|
283 |
|
284 |