|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 delete contacts command. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2DELETECONTACTSCMD_H |
|
20 #define CPBK2DELETECONTACTSCMD_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MPbk2Command.h> |
|
25 #include <MVPbkSingleContactOperationObserver.h> |
|
26 #include <MVPbkBatchOperationObserver.h> |
|
27 #include <MVPbkContactFindObserver.h> |
|
28 #include "MPbk2ProcessDecorator.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CVPbkContactManager; |
|
32 class CAknProgressDialog; |
|
33 class CEikProgressInfo; |
|
34 class MPbk2ContactUiControl; |
|
35 class MVPbkContactLink; |
|
36 class MVPbkContactLinkArray; |
|
37 class MVPbkStoreContact; |
|
38 class MPbk2ContactNameFormatter; |
|
39 class CVPbkContactLinkArray; |
|
40 class MPbk2ContactLinkIterator; |
|
41 class CPbk2ApplicationServices; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * Phonebook 2 delete contacts command. |
|
47 */ |
|
48 NONSHARABLE_CLASS(CPbk2DeleteContactsCmd) : |
|
49 public CActive, |
|
50 public MPbk2Command, |
|
51 public MVPbkSingleContactOperationObserver, |
|
52 public MVPbkBatchOperationObserver, |
|
53 public MPbk2ProcessDecoratorObserver |
|
54 { |
|
55 public: // Construction and destruction |
|
56 /** |
|
57 * Creates a new instance of this class. |
|
58 * |
|
59 * @param aUiControl UI control. |
|
60 * @return A new instance of this class. |
|
61 */ |
|
62 static CPbk2DeleteContactsCmd* NewL( |
|
63 MPbk2ContactUiControl& aUiControl ); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 ~CPbk2DeleteContactsCmd(); |
|
69 |
|
70 public: // From MPbk2Command |
|
71 void ExecuteLD(); |
|
72 void AddObserver( MPbk2CommandObserver& aObserver ); |
|
73 void ResetUiControl(MPbk2ContactUiControl& aUiControl); |
|
74 |
|
75 private: // From CActive |
|
76 void DoCancel(); |
|
77 void RunL(); |
|
78 TInt RunError( TInt aError ); |
|
79 |
|
80 private: // From MVPbkSingleContactOperationObserver |
|
81 void VPbkSingleContactOperationComplete( |
|
82 MVPbkContactOperationBase& aOperation, |
|
83 MVPbkStoreContact* aContact ); |
|
84 void VPbkSingleContactOperationFailed( |
|
85 MVPbkContactOperationBase& aOperation, TInt aError ); |
|
86 |
|
87 private: // From MVPbkBatchOperationObserver |
|
88 void StepComplete( MVPbkContactOperationBase& aOperation, |
|
89 TInt aStepSize ); |
|
90 TBool StepFailed( MVPbkContactOperationBase& aOperation, |
|
91 TInt aStepSize, TInt aError ); |
|
92 void OperationComplete( MVPbkContactOperationBase& aOperation ); |
|
93 |
|
94 private: // From MPbk2ProcessDecoratorObserver |
|
95 void ProcessDismissed( TInt aCancelCode ); |
|
96 |
|
97 private: // Data structures |
|
98 /// Process states |
|
99 enum TProcessState |
|
100 { |
|
101 ERetrieving, |
|
102 EConfirming, |
|
103 EStarting, |
|
104 EDeleting, |
|
105 EStopping, |
|
106 ECanceling |
|
107 }; |
|
108 |
|
109 private: // Implementation |
|
110 CPbk2DeleteContactsCmd( MPbk2ContactUiControl& aUiControl ); |
|
111 void ConstructL(); |
|
112 void RetrieveContactL( const MVPbkContactLink& aContactLink ); |
|
113 void DoDeleteContactsL(); |
|
114 TInt FilterErrors( TInt aErrorCode ); |
|
115 void IssueRequest(); |
|
116 void IssueStopRequest( TProcessState aState ); |
|
117 void ConfirmDeletionL(); |
|
118 TInt GetContactCountL(); |
|
119 TBool IsFromReadOnlyStore( |
|
120 const MVPbkContactLink& aContactLink ) const; |
|
121 |
|
122 private: // Data |
|
123 /// Ref: UI control |
|
124 MPbk2ContactUiControl* iUiControl; |
|
125 /// Own: Decorator for the process |
|
126 MPbk2ProcessDecorator* iDecorator; |
|
127 /// Own: Contacts to delete |
|
128 MVPbkContactLinkArray* iContactLinkArray; |
|
129 /// Own: Retrieve operation |
|
130 MVPbkContactOperationBase* iRetrieveOperation; |
|
131 /// Own: Delete operation |
|
132 MVPbkContactOperationBase* iDeleteOperation; |
|
133 /// Own: List contacts operation |
|
134 MVPbkContactOperationBase* iListContactsOperation; |
|
135 /// Own: The store contact to delete |
|
136 MVPbkStoreContact* iStoreContact; |
|
137 /// Ref: Command observer |
|
138 MPbk2CommandObserver* iCommandObserver; |
|
139 /// Own: Current state of process |
|
140 TProcessState iState; |
|
141 /// Own: Contact to be deleted in next cycle |
|
142 CVPbkContactLinkArray* iContactsToDelete; |
|
143 /// Own: Count of contacts to be deleted |
|
144 TInt iContactCount; |
|
145 /// Own: Contact link iterator |
|
146 MPbk2ContactLinkIterator* iContactIterator; |
|
147 /// Own: Application Services pointer |
|
148 CPbk2ApplicationServices* iAppServices; |
|
149 }; |
|
150 |
|
151 #endif // CPBK2DELETECONTACTSCMD_H |
|
152 |
|
153 // End of File |