1 /* |
|
2 * Copyright (c) 2002-2005 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: AIW provider for pbkinfoview. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "pbkinfoviewapi.h" |
|
20 #include "rubydebug.h" |
|
21 |
|
22 #include <AiwMenu.h> |
|
23 #include <CVPbkContactManager.h> |
|
24 #include <CVPbkContactLinkArray.h> |
|
25 #include <MVPbkContactLink.h> |
|
26 #include <CVPbkContactStoreUriArray.h> |
|
27 #include <CVPbkContactIdConverter.h> |
|
28 #include <MVPbkContactStoreListObserver.h> |
|
29 #include <VPbkContactStoreUris.h> |
|
30 #include <VPbkContactStoreUris.h> |
|
31 #include <TVPbkContactStoreUriPtr.h> |
|
32 #include <MVPbkContactStoreList.h> |
|
33 #include <MVPbkContactStore.h> |
|
34 #include <MVPbkContactStoreProperties.h> |
|
35 |
|
36 #include <implementationproxy.h> |
|
37 |
|
38 #include <data_caging_path_literals.hrh> // for resource and bitmap directories |
|
39 |
|
40 #include <aiwpbkinfoviewprovider.rsg> |
|
41 #include "aiwpbkinfoviewprovider.h" |
|
42 #include "aiwpbkinfoviewprovideruids.hrh" |
|
43 #include "aiwpbkinfoviewprovider.rh" |
|
44 |
|
45 _LIT( KResFileName, "z:aiwpbkinfoviewprovider.rsc" ); |
|
46 const TInt32 KVoiceTaglessContactId = -2; |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CAiwPbkInfoViewProvider::NewL |
|
50 // |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CAiwPbkInfoViewProvider* CAiwPbkInfoViewProvider::NewL() |
|
54 { |
|
55 CAiwPbkInfoViewProvider* self = new (ELeave) CAiwPbkInfoViewProvider(); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(self); |
|
59 |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CAiwPbkInfoViewProvider::Constructor |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CAiwPbkInfoViewProvider::CAiwPbkInfoViewProvider() |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CAiwPbkInfoViewProvider::Destructor |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CAiwPbkInfoViewProvider::~CAiwPbkInfoViewProvider() |
|
78 { |
|
79 delete iInfoViewApi; |
|
80 iInfoViewApi = NULL; |
|
81 delete iWait; |
|
82 iWait = NULL; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CAiwPbkInfoViewProvider::ConstructL |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CAiwPbkInfoViewProvider::ConstructL() |
|
91 { |
|
92 iInfoViewApi = CPbkInfoViewApi::NewL(); |
|
93 iWait = new (ELeave) CActiveSchedulerWait(); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CAiwPbkInfoViewProvider::InitialiseL (from CAiwServiceIfBase) |
|
98 // |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CAiwPbkInfoViewProvider::InitialiseL( |
|
102 MAiwNotifyCallback& /*aFrameworkCallback*/, |
|
103 const RCriteriaArray& /*aInterest*/ ) |
|
104 { |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CAiwPbkInfoViewProvider::HandleServiceCmdL (from CAiwServiceIfBase) |
|
109 // |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CAiwPbkInfoViewProvider::HandleServiceCmdL( |
|
113 const TInt& /*aCmdId*/, |
|
114 const CAiwGenericParamList& /*aInParamList*/, |
|
115 CAiwGenericParamList& /*aOutParamList*/, |
|
116 TUint /*aCmdOptions*/, |
|
117 const MAiwNotifyCallback* /*aCallback*/ ) |
|
118 { |
|
119 User::Leave( KErrNotSupported ); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CAiwPbkInfoViewProvider::InitializeMenuPaneL (from CAiwServiceIfMenu) |
|
124 // Initialises menu pane by adding provider specific menu items. The AIW |
|
125 // framework gives the parameters to be used in addition. |
|
126 // @param aMenuPane Menu pane handle |
|
127 // @param aIndex position of item where to add menu items. |
|
128 // @param aCascadeId ID of cascade menu item. |
|
129 // @param aInParamList input parameter list for provider's parameters checking |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CAiwPbkInfoViewProvider::InitializeMenuPaneL( |
|
133 CAiwMenuPane& aMenuPane, |
|
134 TInt aIndex, |
|
135 TInt /*aCascadeId*/, |
|
136 const CAiwGenericParamList& aInParamList ) |
|
137 { |
|
138 TFileName resFile; |
|
139 GetResFileName( resFile ); |
|
140 |
|
141 TInt serviceCommand = GetServiceCommandId( aInParamList ); |
|
142 |
|
143 if ( serviceCommand == KErrNotFound ) |
|
144 { |
|
145 User::Leave( KErrArgument ); |
|
146 } |
|
147 |
|
148 if ( serviceCommand == KAiwCmdSindInfoView ) |
|
149 { |
|
150 aMenuPane.AddMenuItemsL( resFile, R_PBKINFOVIEWPROVIDER_SUBMENU, |
|
151 KAiwCmdSindInfoView, aIndex ); |
|
152 } |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CAiwPbkInfoViewProvider::HandleMenuCmdL (from CAiwServiceIfMenu) |
|
157 // Handles a menu command invoked by the Handler. |
|
158 // @param aMenuCmdId Command ID for the menu command, |
|
159 // defined by the provider when adding the menu commands. |
|
160 // @param aInParamList Input parameters, could be empty list |
|
161 // @param aOutParamList Output parameters, could be empty list |
|
162 // @param aCmdOptions Options for the command, see KAiwCmdOpt* constants. |
|
163 // @param aCallback callback if asynchronous command handling is wanted by consumer. |
|
164 // The provider may or may not support this, leaves with KErrNotSupported |
|
165 // if not. |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CAiwPbkInfoViewProvider::HandleMenuCmdL( |
|
169 TInt aMenuCmdId, |
|
170 const CAiwGenericParamList& aInParamList, |
|
171 CAiwGenericParamList& /*aOutParamList*/, |
|
172 TUint /*aCmdOptions*/, |
|
173 const MAiwNotifyCallback* /*aCallback*/ ) |
|
174 { |
|
175 RUBY_DEBUG_BLOCK( "CAiwPbkInfoViewProvider::HandleMenuCmdL" ); |
|
176 |
|
177 if( aMenuCmdId == EPbkInfoViewProviderCmd ) |
|
178 { |
|
179 TInt contactId = GetContactIdL( aInParamList ); |
|
180 |
|
181 iInfoViewApi->ShowInfoViewL( contactId ); |
|
182 } |
|
183 } |
|
184 |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreObserver) |
|
188 // |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CAiwPbkInfoViewProvider::StoreReady( MVPbkContactStore& /*aContactStore*/ ) |
|
192 { |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreObserver) |
|
197 // |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CAiwPbkInfoViewProvider::StoreUnavailable( MVPbkContactStore& /*aContactStore*/, |
|
201 TInt /*aReason*/ ) |
|
202 { |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreObserver) |
|
207 // |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 void CAiwPbkInfoViewProvider::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/, |
|
211 TVPbkContactStoreEvent /*aStoreEvent*/ ) |
|
212 { |
|
213 } |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreListObserver) |
|
216 // |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void CAiwPbkInfoViewProvider::OpenComplete() |
|
220 { |
|
221 // Continue with GetContactIdL-method |
|
222 if ( iWait && iWait->IsStarted() ) |
|
223 { |
|
224 iWait->AsyncStop(); |
|
225 } |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CAiwPbkInfoViewProvider::GetContactIdL |
|
230 // Gets the contact id from AIW parameter list. |
|
231 // @param aInParamList AIW parameter list. |
|
232 // @return Contact id. |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TInt CAiwPbkInfoViewProvider::GetContactIdL( |
|
236 const CAiwGenericParamList& aInParamList ) |
|
237 { |
|
238 RUBY_DEBUG_BLOCK( "CAiwPbkInfoViewProvider::GetContactIdL" ); |
|
239 |
|
240 TInt index( 0 ); |
|
241 TInt32 contactId( KVoiceTaglessContactId ); |
|
242 |
|
243 const TAiwGenericParam* param |
|
244 = aInParamList.FindFirst( index, EGenericParamContactLinkArray ); |
|
245 |
|
246 if( param ) |
|
247 { |
|
248 // Get the externalized contact link array |
|
249 TPtrC8 packedLinkArray = param->Value().AsData(); |
|
250 |
|
251 CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC(); |
|
252 |
|
253 uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
|
254 |
|
255 CVPbkContactManager* contactManager = CVPbkContactManager::NewL( *uriArray ); |
|
256 CleanupStack::PushL( contactManager ); |
|
257 |
|
258 // Open contact stores |
|
259 MVPbkContactStoreList& storeList = contactManager->ContactStoresL(); |
|
260 storeList.OpenAllL( *this ); |
|
261 |
|
262 // Let's synchronize the OpenAllL call |
|
263 if ( iWait && !iWait->IsStarted() ) |
|
264 { |
|
265 iWait->Start(); |
|
266 } |
|
267 |
|
268 // Internalize contact link array |
|
269 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC( |
|
270 packedLinkArray, contactManager->ContactStoresL() ); |
|
271 |
|
272 if( links->Count() > 0 ) |
|
273 { |
|
274 // There should only be one link in the array |
|
275 const MVPbkContactLink& link = links->At( 0 ); |
|
276 |
|
277 MVPbkContactStore& store = link.ContactStore(); |
|
278 |
|
279 // Get the contact id |
|
280 CVPbkContactIdConverter* idConverter |
|
281 = CVPbkContactIdConverter::NewL( store ); |
|
282 CleanupStack::PushL( idConverter ); |
|
283 |
|
284 contactId = idConverter->LinkToIdentifier( link ); |
|
285 |
|
286 CleanupStack::PopAndDestroy( idConverter ); |
|
287 } |
|
288 |
|
289 CleanupStack::PopAndDestroy( links ); |
|
290 CleanupStack::PopAndDestroy( contactManager ); |
|
291 CleanupStack::PopAndDestroy( uriArray ); |
|
292 } |
|
293 |
|
294 RUBY_DEBUG1( "Contact id: %d", contactId ); |
|
295 return contactId; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CAiwPbkInfoViewProvider::GetServiceCommandId |
|
300 // Gets service command id from AIW parameter list. |
|
301 // @param aInParamList AIW parameter list. |
|
302 // @return TInt Service command id. |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 TInt CAiwPbkInfoViewProvider::GetServiceCommandId( |
|
306 const CAiwGenericParamList& aInParamList) |
|
307 { |
|
308 TInt index( 0 ); |
|
309 TInt32 num( 0 ); |
|
310 |
|
311 const TAiwGenericParam* param |
|
312 = aInParamList.FindFirst( index, EGenericParamServiceCommand ); |
|
313 |
|
314 const TAiwVariant& val = param->Value(); |
|
315 if ( !val.Get( num ) ) |
|
316 { |
|
317 num = KErrNotFound; |
|
318 } |
|
319 return num; |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CAiwPbkInfoViewProvider::GetResFileName |
|
324 // Gets this plugin resource file name. |
|
325 // @param aText Resource file name. |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 void CAiwPbkInfoViewProvider::GetResFileName( TDes& aText ) |
|
329 { |
|
330 TParse parse; |
|
331 parse.Set( KResFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
332 StrCopy( aText, parse.FullName() ); |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CAiwPbkInfoViewProvider::StrCopy |
|
337 // |
|
338 // String copy with lenght check. |
|
339 // @param TDes& aTarget Copied text will be put to this variable. |
|
340 // @param TDesC8& aSource Includes the text to be copied. |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 void CAiwPbkInfoViewProvider::StrCopy( TDes& aTarget, const TDesC& aSource ) |
|
344 { |
|
345 TInt len = aTarget.MaxLength(); |
|
346 if( len < aSource.Length() ) |
|
347 { |
|
348 aTarget.Copy( aSource.Left( len ) ); |
|
349 return; |
|
350 } |
|
351 aTarget.Copy( aSource ); |
|
352 } |
|
353 |
|
354 // |
|
355 // Rest of the file is for ECom initialization. |
|
356 // |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // Map the interface UIDs to implementation factory functions |
|
360 // |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 const TImplementationProxy ImplementationTable[] = |
|
364 { |
|
365 IMPLEMENTATION_PROXY_ENTRY( KAspInfoViewProviderImplUid, |
|
366 CAiwPbkInfoViewProvider::NewL ) |
|
367 }; |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // Exported proxy for instantiation method resolution |
|
371 // |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
375 { |
|
376 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
377 |
|
378 return ImplementationTable; |
|
379 } |
|
380 |
|
381 // |
|
382 // DLL entry point |
|
383 // |
|
384 #ifndef EKA2 |
|
385 GLDEF_C TInt E32Dll(TDllReason /*aReason*/) |
|
386 { |
|
387 return KErrNone; |
|
388 } |
|
389 #endif |
|
390 |
|
391 // End of file |
|