107 { |
107 { |
108 iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) ); |
108 iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) ); |
109 } |
109 } |
110 else |
110 else |
111 { |
111 { |
112 iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
112 iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
113 } |
113 } |
114 |
114 |
115 iStore->OpenL( *this ); |
115 iStore->OpenL( *this ); |
116 |
116 |
117 // Wait until the stores are open |
117 // Wait until the stores are open |
143 if(iContactLinksToAddToGroup) |
141 if(iContactLinksToAddToGroup) |
144 { |
142 { |
145 iContactLinksToAddToGroup->ResetAndDestroy(); |
143 iContactLinksToAddToGroup->ResetAndDestroy(); |
146 delete iContactLinksToAddToGroup; |
144 delete iContactLinksToAddToGroup; |
147 } |
145 } |
148 //plese note you shouldn't close stores before cleaning links arrays |
146 //plese note you shouldn't close stores before cleaning links arrays |
149 if ( iContactManager ) |
147 if ( iContactManager ) |
150 { |
148 { |
151 TRAP_IGNORE(iContactManager->ContactStoresL().CloseAll( *this )); |
149 TRAP_IGNORE(iContactManager->ContactStoresL().CloseAll( *this )); |
152 delete iContactManager; |
150 delete iContactManager; |
153 iContactManager = NULL; |
151 iContactManager = NULL; |
154 } |
152 } |
155 |
153 |
156 if(iOp) |
154 if(iOp) |
157 { |
155 { |
158 delete iOp ; |
156 delete iOp ; |
159 iOp = NULL; |
157 iOp = NULL; |
160 } |
158 } |
161 |
|
162 } |
159 } |
163 |
160 |
164 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
165 // From class MVPbkContactStoreListObserver. |
162 // From class MVPbkContactStoreListObserver. |
166 // --------------------------------------------------------------------------- |
163 // --------------------------------------------------------------------------- |
167 void CPcsTestContactsHandler::OpenComplete() |
164 void CPcsTestContactsHandler::OpenComplete() |
168 { |
165 { |
169 iOpenComplete = ETrue; |
166 iOpenComplete = ETrue; |
170 if( iWait->IsStarted() ) |
167 if( iWait->IsStarted() ) |
171 { |
168 { |
172 iWait->AsyncStop(); |
169 iWait->AsyncStop(); |
173 } |
170 } |
174 } |
171 } |
175 |
172 |
176 // --------------------------------------------------------------------------- |
173 // --------------------------------------------------------------------------- |
177 // // Call back method. Called if the store is available |
174 // // Call back method. Called if the store is available |
178 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
196 // Handles the events received from the contact store. |
193 // Handles the events received from the contact store. |
197 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
198 void CPcsTestContactsHandler::HandleStoreEventL(MVPbkContactStore& /*aContactStore*/, |
195 void CPcsTestContactsHandler::HandleStoreEventL(MVPbkContactStore& /*aContactStore*/, |
199 TVPbkContactStoreEvent aStoreEvent) |
196 TVPbkContactStoreEvent aStoreEvent) |
200 { |
197 { |
201 |
|
202 if ( aStoreEvent.iEventType == iStoreEventToWaitFor ) |
198 if ( aStoreEvent.iEventType == iStoreEventToWaitFor ) |
203 { |
199 { |
204 iExpectedStoreEventReceived = ETrue; |
200 iExpectedStoreEventReceived = ETrue; |
205 } |
201 } |
206 |
202 |
207 switch (aStoreEvent.iEventType) |
203 switch (aStoreEvent.iEventType) |
208 { |
204 { |
209 case TVPbkContactStoreEvent::EContactAdded: |
205 case TVPbkContactStoreEvent::EContactAdded: |
210 { |
206 { |
293 } |
289 } |
294 |
290 |
295 // --------------------------------------------------------------------------------- |
291 // --------------------------------------------------------------------------------- |
296 // This fucntion deletes all the created contacts |
292 // This fucntion deletes all the created contacts |
297 // --------------------------------------------------------------------------------- |
293 // --------------------------------------------------------------------------------- |
298 |
|
299 void CPcsTestContactsHandler::DeleteAllCreatedContactsL() |
294 void CPcsTestContactsHandler::DeleteAllCreatedContactsL() |
300 { |
295 { |
301 if(iContactsCreatedLinks->Count()) |
296 if(iContactsCreatedLinks->Count()) |
302 { |
297 { |
303 iOperationComplete = EFalse; |
298 iOperationComplete = EFalse; |
312 } |
307 } |
313 |
308 |
314 // --------------------------------------------------------------------------------- |
309 // --------------------------------------------------------------------------------- |
315 // This fucntion adds a group |
310 // This fucntion adds a group |
316 // --------------------------------------------------------------------------------- |
311 // --------------------------------------------------------------------------------- |
317 |
|
318 void CPcsTestContactsHandler::AddGroupL(const TDesC& aGroupName) |
312 void CPcsTestContactsHandler::AddGroupL(const TDesC& aGroupName) |
319 { |
313 { |
320 iGroupAdded = iStore->CreateNewContactGroupLC(); |
314 iGroupAdded = iStore->CreateNewContactGroupLC(); |
321 iGroupAdded->SetGroupLabelL( aGroupName ); |
315 iGroupAdded->SetGroupLabelL( aGroupName ); |
322 iGroupAdded->CommitL(*this); |
316 iGroupAdded->CommitL(*this); |
361 |
355 |
362 // --------------------------------------------------------------------------------- |
356 // --------------------------------------------------------------------------------- |
363 // Stops main active scheduler loop if stop conditions are fullfiled |
357 // Stops main active scheduler loop if stop conditions are fullfiled |
364 // --------------------------------------------------------------------------------- |
358 // --------------------------------------------------------------------------------- |
365 void CPcsTestContactsHandler::StopSchedulerIfNothingToWaitFor() |
359 void CPcsTestContactsHandler::StopSchedulerIfNothingToWaitFor() |
366 { |
360 { |
367 if( iOperationComplete && iExpectedStoreEventReceived ) |
361 if( iOperationComplete && iExpectedStoreEventReceived ) |
368 { |
362 { |
369 CActiveScheduler::Stop(); |
363 CActiveScheduler::Stop(); |
370 } |
364 } |
371 } |
365 } |
372 |
366 |
373 // --------------------------------------------------------------------------------- |
367 // --------------------------------------------------------------------------------- |
374 // Called when a contact operation has succesfully completed. |
368 // Called when a contact operation has succesfully completed. |
375 // Callback for CommitL |
369 // Callback for CommitL |
376 // --------------------------------------------------------------------------------- |
370 // --------------------------------------------------------------------------------- |