|
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 add to group command object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPGUADDMEMBERSCMD_H |
|
20 #define CPGUADDMEMBERSCMD_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MPbk2FetchDlgObserver.h> |
|
25 #include <MPbk2ContactRelocatorObserver.h> |
|
26 #include <MVPbkContactObserver.h> |
|
27 #include <MVPbkSingleContactOperationObserver.h> |
|
28 #include <MVPbkContactViewObserver.h> |
|
29 #include <MPbk2Command.h> |
|
30 #include <MVPbkContactSelector.h> |
|
31 #include <MPbk2ProcessDecorator.h> |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class MPbk2ContactUiControl; |
|
35 class MVPbkContactGroup; |
|
36 class MVPbkContactLink; |
|
37 class MVPbkContactLinkArray; |
|
38 class CVPbkContactLinkArray; |
|
39 class MVPbkContactOperationBase; |
|
40 class MVPbkContactViewBase; |
|
41 class CPbk2ContactRelocator; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * Phonebook 2 add to group command object. |
|
47 */ |
|
48 class CPguAddMembersCmd : public CActive, |
|
49 public MPbk2Command, |
|
50 private MVPbkSingleContactOperationObserver, |
|
51 private MVPbkContactObserver, |
|
52 private MPbk2FetchDlgObserver, |
|
53 private MVPbkContactViewObserver, |
|
54 private MVPbkContactSelector, |
|
55 private MPbk2ContactRelocatorObserver, |
|
56 private MPbk2ProcessDecoratorObserver |
|
57 { |
|
58 public: // Construction and destruction |
|
59 |
|
60 /** |
|
61 * Creates a new instance of this class. |
|
62 * |
|
63 * @param aGroup Group link. |
|
64 * @param aUiControl UI control. |
|
65 * @return A new instance of this class. |
|
66 */ |
|
67 static CPguAddMembersCmd* NewLC( |
|
68 MVPbkContactLink& aGroup, |
|
69 MPbk2ContactUiControl& aUiControl ); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 ~CPguAddMembersCmd(); |
|
75 |
|
76 public: // From MPbk2Command |
|
77 void ExecuteLD(); |
|
78 void AddObserver( |
|
79 MPbk2CommandObserver& aObserver ); |
|
80 void ResetUiControl( |
|
81 MPbk2ContactUiControl& aUiControl ); |
|
82 |
|
83 private: // From CActive |
|
84 void RunL(); |
|
85 void DoCancel(); |
|
86 TInt RunError( |
|
87 TInt aError ); |
|
88 |
|
89 private: // From MVPbkSingleContactOperationObserver |
|
90 void VPbkSingleContactOperationComplete( |
|
91 MVPbkContactOperationBase& aOperation, |
|
92 MVPbkStoreContact* aContact ); |
|
93 void VPbkSingleContactOperationFailed( |
|
94 MVPbkContactOperationBase& aOperation, |
|
95 TInt aError ); |
|
96 |
|
97 private: // From MVPbkContactObserver |
|
98 void ContactOperationCompleted( |
|
99 TContactOpResult aResult ); |
|
100 void ContactOperationFailed( |
|
101 TContactOp aOpCode, |
|
102 TInt aErrorCode, |
|
103 TBool aErrorNotified ); |
|
104 |
|
105 private: // From MVPbkContactViewObserver |
|
106 void ContactViewReady( |
|
107 MVPbkContactViewBase& aView ); |
|
108 void ContactViewUnavailable( |
|
109 MVPbkContactViewBase& aView ); |
|
110 void ContactAddedToView( |
|
111 MVPbkContactViewBase& aView, |
|
112 TInt aIndex, |
|
113 const MVPbkContactLink& aContactLink ); |
|
114 void ContactRemovedFromView( |
|
115 MVPbkContactViewBase& aView, |
|
116 TInt aIndex, |
|
117 const MVPbkContactLink& aContactLink ); |
|
118 void ContactViewError( |
|
119 MVPbkContactViewBase& aView, |
|
120 TInt aError, |
|
121 TBool aErrorNotified ); |
|
122 |
|
123 private: // From MVPbkContactSelector |
|
124 TBool IsContactIncluded( |
|
125 const MVPbkBaseContact& aContact ); |
|
126 |
|
127 private: // From MPbk2FetchDlgObserver |
|
128 TPbk2FetchAcceptSelection AcceptFetchSelectionL( |
|
129 TInt aNumMarkedEntries, |
|
130 MVPbkContactLink& aLastSelection ); |
|
131 void FetchCompletedL( |
|
132 MVPbkContactLinkArray* aMarkedEntries ); |
|
133 void FetchCanceled(); |
|
134 void FetchAborted(); |
|
135 TBool FetchOkToExit(); |
|
136 |
|
137 private: // From MPbk2ContactRelocatorObserver |
|
138 void ContactRelocatedL( |
|
139 MVPbkStoreContact* aRelocatedContact ); |
|
140 void ContactRelocationFailed( |
|
141 TInt aReason, |
|
142 MVPbkStoreContact* aContact ); |
|
143 void ContactsRelocationFailed( |
|
144 TInt aReason, |
|
145 CVPbkContactLinkArray* aContacts ); |
|
146 void RelocationProcessComplete(); |
|
147 |
|
148 public: // From MPbk2ProcessDecoratorObserver |
|
149 void ProcessDismissed( |
|
150 TInt aCancelCode ); |
|
151 |
|
152 private: // Implementation |
|
153 CPguAddMembersCmd( |
|
154 MVPbkContactLink& aContactGroup, |
|
155 MPbk2ContactUiControl& aUiControl ); |
|
156 void ConstructL(); |
|
157 void HandleContactLockedEventL(); |
|
158 void DoLaunchFetchDialogL(); |
|
159 void PrepareFetchResultsL( |
|
160 MVPbkContactLinkArray* aMarkedEntries ); |
|
161 void RelocateContactsL(); |
|
162 void RelocateContactL( |
|
163 MVPbkStoreContact* aStoreContact ); |
|
164 void AddContactsToGroupL(); |
|
165 void CommitTransactionL(); |
|
166 void FinishCommand( |
|
167 TInt aResult ); |
|
168 void ShowRelocationNoteL( |
|
169 TInt aCount ); |
|
170 void ShowProgressNoteL(); |
|
171 void IssueRequest(); |
|
172 void IssueStopRequest(); |
|
173 void SetFocusToLastAddedL(); |
|
174 |
|
175 private: // Data structures |
|
176 /// Process states |
|
177 enum TState |
|
178 { |
|
179 ERetrievingContact, |
|
180 EHandleContactLockedEvent, |
|
181 EShowingProgressNote, |
|
182 EAddingContactsToGroup, |
|
183 ECommitingTransaction, |
|
184 EStopping |
|
185 }; |
|
186 |
|
187 private: // Data |
|
188 /// Ref: UI control |
|
189 MPbk2ContactUiControl* iUiControl; |
|
190 /// Ref: Command observer |
|
191 MPbk2CommandObserver* iCommandObserver; |
|
192 /// Own: Retrieve group operation |
|
193 MVPbkContactOperationBase* iRetrieveGroupOperation; |
|
194 /// Own: Retrieve contact operation |
|
195 MVPbkContactOperationBase* iRetrieveContactOperation; |
|
196 /// Ref: A group where to add members |
|
197 MVPbkContactLink& iGroupLink; |
|
198 /// Own: Contact group |
|
199 MVPbkContactGroup* iContactGroup; |
|
200 /// Own: A filtered view for dialog |
|
201 MVPbkContactViewBase* iFilteredView; |
|
202 /// Own: Entries to add to group |
|
203 CVPbkContactLinkArray* iEntriesToAdd; |
|
204 /// Own: Entries to relocate |
|
205 CVPbkContactLinkArray* iEntriesToRelocate; |
|
206 /// Own: Contact relocator |
|
207 CPbk2ContactRelocator* iContactRelocator; |
|
208 /// Own: Decorator for the wait note process |
|
209 MPbk2ProcessDecorator* iDecorator; |
|
210 /// Own: Contacts that already belongs to the group |
|
211 MVPbkContactLinkArray* iContactsInGroup; |
|
212 /// Own: State of the command |
|
213 TState iState; |
|
214 }; |
|
215 |
|
216 #endif // CPGUADDMEMBERSCMD_H |
|
217 |
|
218 // End of File |