|
1 /* |
|
2 * Copyright (c) 2007-2009 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: ESMR Contact Handler for fetching contacts for attendee field |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CESMRCONTACTHANDLER_H |
|
19 #define CESMRCONTACTHANDLER_H |
|
20 |
|
21 // Includes |
|
22 #include <e32base.h> |
|
23 #include <MVPbkSingleContactOperationObserver.h> |
|
24 #include <AiwCommon.h> |
|
25 //<cmail> |
|
26 #include "cpbkxremotecontactlookupserviceuicontext.h" |
|
27 //</cmail> |
|
28 #include "resmrstatic.h" |
|
29 #include "mesmrclslistsobserver.h" |
|
30 #include "cesmrcontactmanagerhandler.h" |
|
31 #include "resmrpluginextensionstatic.h" |
|
32 |
|
33 // Forward declarations |
|
34 class CFSMailBox; |
|
35 class CESMRClsListsHandler; |
|
36 class CVPbkContactManager; |
|
37 class CESMRClsItem; |
|
38 class MVPbkContactOperationBase; |
|
39 class MVPbkStoreContact; |
|
40 class MESMRContactHandlerObserver; |
|
41 class MVPbkContactOperationBase; |
|
42 class MVPbkContactLinkArray; |
|
43 class CAiwServiceHandler; |
|
44 class CESMRClsItem; |
|
45 class CContactItem; |
|
46 |
|
47 /** |
|
48 * Command to execute by contact handler |
|
49 */ |
|
50 enum TContactHandlerCmd |
|
51 { |
|
52 EGetAddressesFromPhonebook = 1, |
|
53 ESearchContacts |
|
54 }; |
|
55 |
|
56 /** |
|
57 * Implements remote look up and contact search related functionality. |
|
58 * It will launch AIW service (virtual phonebook provided) to create those views |
|
59 */ |
|
60 class CESMRContactHandler: |
|
61 public CBase, |
|
62 public MESMRClsListsObserver, |
|
63 public MVPbkSingleContactOperationObserver, |
|
64 public MAiwNotifyCallback, |
|
65 public MESMRContactManagerObserver |
|
66 { |
|
67 public: // Construction & Deconstruction |
|
68 /** |
|
69 * Two-phased constructor. Creates and initializes |
|
70 * CESMRContactHandler object. |
|
71 * @return Pointer to object. |
|
72 */ |
|
73 static CESMRContactHandler* NewL(); |
|
74 |
|
75 /** |
|
76 * Two-phased constructor. Creates and initializes |
|
77 * CESMRContactHandler object, which is left on |
|
78 * the cleanupstack |
|
79 * @return Pointer to object. |
|
80 */ |
|
81 static CESMRContactHandler* NewLC(); |
|
82 |
|
83 /** |
|
84 * Shows the popup on the screen. |
|
85 */ |
|
86 ~CESMRContactHandler(); |
|
87 |
|
88 public: // Interface |
|
89 /** |
|
90 * Search for contacts by PCS engine. This is asynchronous call, and results are in |
|
91 * ArrayUpdated( resultsArray ) |
|
92 * |
|
93 * @param aText = new search text. |
|
94 * @param aClsListObserver = observer to collect results |
|
95 */ |
|
96 void SearchMatchesL( const TDesC& aText, |
|
97 MESMRContactHandlerObserver* aObserver ); |
|
98 |
|
99 /** |
|
100 * Launches remote lookup query window (remote lookup UI) |
|
101 * @param aQueryString search string for search engines |
|
102 * @param aDisplayname displayed name of contact |
|
103 * @param aEmailAddress email address of contact |
|
104 * @return not used |
|
105 */ |
|
106 TBool LaunchRemoteLookupL( const TDesC& aQueryString, |
|
107 TDes& aDisplayname, |
|
108 TDes& aEmailAddress ); |
|
109 |
|
110 /** |
|
111 * get last name found with search |
|
112 * aEmailAddress email address of contact |
|
113 * @return display name of contact |
|
114 */ |
|
115 HBufC* GetLastSearchNameLC( const TDesC& aEmailAddress ); |
|
116 |
|
117 /** |
|
118 * Get pointer to contact manager (handles phone book stores) |
|
119 * @return pointer to contact manager |
|
120 */ |
|
121 CVPbkContactManager* GetContactManager(); |
|
122 |
|
123 /** |
|
124 * Lauches multiple item fetch dialog through AIW launcher framework. |
|
125 * Results are returned to observer |
|
126 * @param aObserver = observer to collect results |
|
127 */ |
|
128 void GetAddressesFromPhonebookL( MESMRContactHandlerObserver* aObserver ); |
|
129 |
|
130 TBool RemoteLookupSupportedL(); |
|
131 |
|
132 public: // from MESMRClsListsObserver |
|
133 void ArrayUpdatedL( RPointerArray<CESMRClsItem>& aMatchingItems ); |
|
134 void OperationErrorL( TInt aErrorCode ); |
|
135 |
|
136 public: // from MVPbkSingleContactOperationObserver |
|
137 void VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation, |
|
138 MVPbkStoreContact* aContact ); |
|
139 |
|
140 void VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation, |
|
141 TInt aError ); |
|
142 |
|
143 public: // from MAiwNotifyCallback |
|
144 TInt HandleNotifyL( TInt aCmdId, |
|
145 TInt aEventId, |
|
146 CAiwGenericParamList& aEventParamList, |
|
147 const CAiwGenericParamList& aInParamList); |
|
148 |
|
149 public: // from MESMRContactManagerObserver |
|
150 void ContactManagerReady(); |
|
151 |
|
152 private: // Implementation |
|
153 CESMRContactHandler(); |
|
154 void ConstructL(); |
|
155 TBool IsRemoteLookupSupported(); |
|
156 void GetNameAndEmail( TDes& aName, TDes& aEmail, CContactItem& aItem ); |
|
157 void VPbkSingleContactOperationFailedL( MVPbkContactOperationBase& aOperation, TInt aError ); |
|
158 void VPbkSingleContactOperationCompleteL( MVPbkContactOperationBase& aOperation, |
|
159 MVPbkStoreContact* aContact ); |
|
160 void GetContactFieldsL( RArray<TInt>& aFieldIds, |
|
161 RPointerArray<HBufC>& aNumbers, |
|
162 MVPbkStoreContact* aContact ); |
|
163 void DoRemoteLookupL( const TDesC& aQueryString, |
|
164 CPbkxRemoteContactLookupServiceUiContext::TResult& aResult, |
|
165 CPbkxRemoteContactLookupServiceUiContext::TMode aContext = |
|
166 CPbkxRemoteContactLookupServiceUiContext::EModeContactSelector ); |
|
167 CFSMailBox& DelayedMailBoxL(); |
|
168 |
|
169 private: // data |
|
170 RESMRStatic iESMRStatic;//not own, reference counted |
|
171 CESMRClsListsHandler* iClsListHandler;//own |
|
172 CESMRClsItem* iSearchMatch;//own |
|
173 MESMRContactHandlerObserver* iHandlerObserver;//not own |
|
174 CFSMailBox* iMailBox;//not own |
|
175 CVPbkContactManager* iContactManager; //not own |
|
176 MVPbkContactOperationBase* iLinkOperationFetch;//own |
|
177 const MVPbkContactLink* iCurrentLink;//own |
|
178 MVPbkContactLinkArray* iLinksSet;//own |
|
179 CAiwServiceHandler* iServiceHandler;//own |
|
180 /** |
|
181 * Static TLS stored pointer to fsmailbox. |
|
182 */ |
|
183 RESMRPluginExtensionStatic iESMRMailBoxStatic; |
|
184 TBool iESMRMailBoxStaticCalled; |
|
185 TBool iRemoteLookupSupported; |
|
186 |
|
187 /** |
|
188 * State of contact handlers asynchronous processing |
|
189 */ |
|
190 enum TContactHandlerState |
|
191 { |
|
192 EContactHandlerIdle = 1, |
|
193 EContactHandlerSearchMatches, |
|
194 EContactHandlerGetAddressesFromPhonebook |
|
195 }; |
|
196 TContactHandlerState iState; |
|
197 |
|
198 //internal arrays on the stack |
|
199 RPointerArray<CESMRClsItem> iContactObjects; |
|
200 RArray<TInt> iLastnameFields; |
|
201 RArray<TInt> iFirstnameFields; |
|
202 RArray<TInt> iEmailFields; |
|
203 }; |
|
204 |
|
205 #endif |