|
1 /* |
|
2 * Copyright (c) 2010 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 copy "new SIM" contacts to phone memory. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPSU2COPYALLTOPBKCMD_H |
|
20 #define CPSU2COPYALLTOPBKCMD_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MPbk2Command.h> |
|
25 #include <MVPbkContactStoreObserver.h> |
|
26 #include <MVPbkContactViewObserver.h> |
|
27 #include <MVPbkBatchOperationObserver.h> |
|
28 #include <MPbk2ProcessDecorator.h> |
|
29 #include <RPbk2LocalizedResourceFile.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class MVPbkContactStore; |
|
33 class CVPbkContactStoreUriArray; |
|
34 class MVPbkContactView; |
|
35 class CVPbkContactLinkArray; |
|
36 class CVPbkContactCopier; |
|
37 class CVPbkContactLinkArray; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Phonebook 2 copy "new SIM" contacts to phone memory. |
|
43 */ |
|
44 class CPsu2CopyAllToPbkCmd : public CActive, |
|
45 public MPbk2Command, |
|
46 private MVPbkContactStoreObserver, |
|
47 private MVPbkContactViewObserver, |
|
48 private MVPbkBatchOperationObserver, |
|
49 private MPbk2ProcessDecoratorObserver |
|
50 { |
|
51 public: // Constructors and destructor |
|
52 |
|
53 /** |
|
54 * Creates a new instance of this class. |
|
55 * @return A new instance of this class. |
|
56 */ |
|
57 static CPsu2CopyAllToPbkCmd* NewL( ); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CPsu2CopyAllToPbkCmd(); |
|
63 |
|
64 private: // From CActive |
|
65 void RunL(); |
|
66 void DoCancel(); |
|
67 TInt RunError( |
|
68 TInt aError ); |
|
69 |
|
70 public: // From MPbk2Command |
|
71 void ExecuteLD(); |
|
72 void AddObserver( |
|
73 MPbk2CommandObserver& aObserver ); |
|
74 void ResetUiControl( |
|
75 MPbk2ContactUiControl& aUiControl ); |
|
76 |
|
77 private: // From MVPbkContactStoreObserver |
|
78 void StoreReady( |
|
79 MVPbkContactStore& aContactStore ); |
|
80 void StoreUnavailable( |
|
81 MVPbkContactStore& aContactStore, |
|
82 TInt aReason ); |
|
83 void HandleStoreEventL( |
|
84 MVPbkContactStore& aContactStore, |
|
85 TVPbkContactStoreEvent aStoreEvent ); |
|
86 |
|
87 private: // From MVPbkContactViewObserver |
|
88 void ContactViewReady( |
|
89 MVPbkContactViewBase& aView ); |
|
90 void ContactViewUnavailable( |
|
91 MVPbkContactViewBase& aView ); |
|
92 void ContactAddedToView( |
|
93 MVPbkContactViewBase& aView, |
|
94 TInt aIndex, |
|
95 const MVPbkContactLink& aContactLink ); |
|
96 void ContactRemovedFromView( |
|
97 MVPbkContactViewBase& aView, |
|
98 TInt aIndex, |
|
99 const MVPbkContactLink& aContactLink ); |
|
100 void ContactViewError( |
|
101 MVPbkContactViewBase& aView, |
|
102 TInt aError, |
|
103 TBool aErrorNotified ); |
|
104 |
|
105 private: // From MVPbkBatchOperationObserver |
|
106 void StepComplete( |
|
107 MVPbkContactOperationBase& aOperation, |
|
108 TInt aStepSize ); |
|
109 TBool StepFailed( |
|
110 MVPbkContactOperationBase& aOperation, |
|
111 TInt aStepSize, |
|
112 TInt aError ); |
|
113 void OperationComplete( |
|
114 MVPbkContactOperationBase& aOperation ); |
|
115 |
|
116 private: // From MPbk2ProcessDecoratorObserver |
|
117 void ProcessDismissed( |
|
118 TInt aCancelCode ); |
|
119 |
|
120 private: // Implementation |
|
121 /// Tasks |
|
122 enum TNextTask |
|
123 { |
|
124 EOpenStores, |
|
125 ECheckSimStorePrerequisites, |
|
126 ELaunchCopyAllSIMContactsQueryL, |
|
127 ECreateSimViews, |
|
128 ECopyContacts, |
|
129 EComplete |
|
130 }; |
|
131 |
|
132 CPsu2CopyAllToPbkCmd( ); |
|
133 void ConstructL(); |
|
134 void OpenStoresL(); |
|
135 void CheckSimStorePrerequisitesL(); |
|
136 void LaunchCopyAllSIMContactsQueryL(); |
|
137 void CreateSimViewsL(); |
|
138 void CopyContactsL(); |
|
139 void ShowResultsL(); |
|
140 void Complete(); |
|
141 void CompleteWithError( |
|
142 TInt aError ); |
|
143 void CloseStores(); |
|
144 |
|
145 void Finish( TInt aReason ); |
|
146 |
|
147 void StartNext( TNextTask aNextTask ); |
|
148 |
|
149 |
|
150 private: // Data |
|
151 /// Ref: Command observer |
|
152 MPbk2CommandObserver* iCommandObserver; |
|
153 /// Own: Decorator for the process |
|
154 MPbk2ProcessDecorator* iDecorator; |
|
155 TBool iDecoratorShown; |
|
156 /// Own: Indicates next task |
|
157 TInt iNextTask; |
|
158 /// Own: URI array that contains the SIM source stores |
|
159 CVPbkContactStoreUriArray* iValidSourceStoreUris; |
|
160 /// Ref: Array of source store references |
|
161 RPointerArray<MVPbkContactStore> iSourceStores; |
|
162 /// Target store reference |
|
163 MVPbkContactStore* iTargetStore; |
|
164 /// Own: Counter for opened SIM stores and views |
|
165 TInt iCounter; |
|
166 /// Own: Array of SIM contact views |
|
167 RPointerArray<MVPbkContactView> iSourceViews; |
|
168 /// Own: Source contact links |
|
169 CVPbkContactLinkArray* iSourceContactLinks; |
|
170 /// Own: Copy operation |
|
171 MVPbkContactOperationBase* iCopyOperation; |
|
172 /// Own: Number of successfully copied contacts |
|
173 TInt iCopiedSuccessfully; |
|
174 /// Own: The virtual phonebook contact copier |
|
175 CVPbkContactCopier* iCopier; |
|
176 /// Own: An array for copy results |
|
177 CVPbkContactLinkArray* iCopiedContacts; |
|
178 /// Own: If there is just one contact being copied, store the title |
|
179 /// for copy results note |
|
180 HBufC* iTheOnlyContactTitle; |
|
181 }; |
|
182 |
|
183 #endif // CPSU2COPYALLTOPBKCMD_H |
|
184 |
|
185 // End of File |