|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of detailsview plugin menu handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cvimpstdetailsviewmenuhandler.h" |
|
20 |
|
21 #include "cvimpstdetailsviewlistboxmodel.h" |
|
22 #include "cvimpstdetailsviewcontainer.h" |
|
23 #include "cvimpstdetailsviewplugin.h" |
|
24 #include "cvimpstdetailscontacthandler.h" |
|
25 #include "vimpstdetailsview.hrh" |
|
26 #include <vimpstdetailsviewpluginrsc.rsg> |
|
27 #include <ccappdetailsviewpluginrsc.rsg> |
|
28 #include <aknnotewrappers.h> |
|
29 #include <AiwContactAssignDataTypes.h> |
|
30 #include <CVPbkContactLinkArray.h> |
|
31 |
|
32 using namespace AiwContactAssign; |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CVIMPSTDetailsViewMenuHandler::NewL |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CVIMPSTDetailsViewMenuHandler* CVIMPSTDetailsViewMenuHandler::NewL( |
|
40 CVIMPSTDetailsViewPlugin& aPlugin, |
|
41 TStoreType aStoreType ) |
|
42 { |
|
43 CVIMPSTDetailsViewMenuHandler* self = new(ELeave) CVIMPSTDetailsViewMenuHandler( aPlugin,aStoreType ); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop(self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CVIMPSTDetailsViewMenuHandler::~CVIMPSTDetailsViewMenuHandler |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CVIMPSTDetailsViewMenuHandler::~CVIMPSTDetailsViewMenuHandler() |
|
55 { |
|
56 delete iAiwServiceHandler; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CVIMPSTDetailsViewMenuHandler::CVIMPSTDetailsViewMenuHandler() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CVIMPSTDetailsViewMenuHandler::CVIMPSTDetailsViewMenuHandler( |
|
64 CVIMPSTDetailsViewPlugin& aPlugin, |
|
65 TStoreType aStoreType) : |
|
66 iPlugin(aPlugin), |
|
67 iStoreType( aStoreType ) |
|
68 { |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CVIMPSTDetailsViewMenuHandler::ConstructL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CVIMPSTDetailsViewMenuHandler::ConstructL() |
|
76 { |
|
77 PrepareAiwMenusL(); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CVIMPSTDetailsViewMenuHandler::DynInitMenuPaneL |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CVIMPSTDetailsViewMenuHandler::DynInitMenuPaneL(TInt aResourceId, |
|
85 CEikMenuPane* aMenuPane ) |
|
86 { |
|
87 if (iAiwServiceHandler) |
|
88 { |
|
89 if ( iAiwServiceHandler->HandleSubmenuL(*aMenuPane)) |
|
90 { |
|
91 return; |
|
92 } |
|
93 } |
|
94 switch (aResourceId) |
|
95 { |
|
96 case R_VIMPSTDETAILSVIEW_MENUPANE: |
|
97 { |
|
98 TInt pos = 0; |
|
99 if ( iAiwServiceHandler ) |
|
100 { |
|
101 if ( iAiwServiceHandler->IsAiwMenu(aResourceId)) |
|
102 { |
|
103 iAiwServiceHandler->InitializeMenuPaneL( *aMenuPane, |
|
104 aResourceId, ECCAppDetailsViewAiwBaseCmd, |
|
105 iAiwServiceHandler->InParamListL() ); |
|
106 } |
|
107 } |
|
108 if ( aMenuPane->MenuItemExists(ECCAppDetailsViewSetTopContactCmd, pos) ) |
|
109 { |
|
110 aMenuPane->SetItemDimmed(ECCAppDetailsViewSetTopContactCmd, ETrue ); |
|
111 } |
|
112 if( aMenuPane->MenuItemExists(ECCAppDetailsViewRemoveTopContactCmd, pos) ) |
|
113 { |
|
114 aMenuPane->SetItemDimmed(ECCAppDetailsViewRemoveTopContactCmd, ETrue ); |
|
115 } |
|
116 if (aMenuPane->MenuItemExists(ECCAppDetailsViewNumberCmd, pos) ) |
|
117 { |
|
118 aMenuPane->SetItemDimmed(ECCAppDetailsViewNumberCmd,ETrue ); |
|
119 } |
|
120 if (aMenuPane->MenuItemExists(ECCAppDetailsViewAddressCmd, pos) ) |
|
121 { |
|
122 aMenuPane->SetItemDimmed(ECCAppDetailsViewAddressCmd,ETrue ); |
|
123 } |
|
124 if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyNumberCmd, pos) ) |
|
125 { |
|
126 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyNumberCmd, ETrue ); |
|
127 } |
|
128 if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyAddressCmd, pos) ) |
|
129 { |
|
130 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyAddressCmd, ETrue ); |
|
131 } |
|
132 if (aMenuPane->MenuItemExists(ECCAppDetailsViewImageCmd, pos) ) |
|
133 { |
|
134 aMenuPane->SetItemDimmed(ECCAppDetailsViewImageCmd, ETrue ); |
|
135 } |
|
136 if (aMenuPane->MenuItemExists(ECCAppDetailsViewSendBusinessCardCmd, pos) ) |
|
137 { |
|
138 aMenuPane->SetItemDimmed(ECCAppDetailsViewSendBusinessCardCmd, ETrue ); |
|
139 } |
|
140 if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyCmd, pos) ) |
|
141 { |
|
142 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyCmd, ETrue ); |
|
143 } |
|
144 // Dims the edit option in service details view. |
|
145 if(aMenuPane->MenuItemExists(KAiwCmdAssign, pos)) |
|
146 { |
|
147 aMenuPane->SetItemDimmed(KAiwCmdAssign,ETrue ); |
|
148 } |
|
149 |
|
150 if (aMenuPane->MenuItemExists(EVIMPSTDetailsCopyCmd, pos)) |
|
151 { |
|
152 aMenuPane->SetItemDimmed(EVIMPSTDetailsCopyCmd, ETrue ); |
|
153 } |
|
154 if (aMenuPane->MenuItemExists(EVIMPSTDetailsDeleteCmd, pos)) |
|
155 { |
|
156 aMenuPane->SetItemDimmed(EVIMPSTDetailsDeleteCmd, ETrue ); |
|
157 } |
|
158 |
|
159 |
|
160 const CVIMPSTDetailsViewContainer& container = |
|
161 static_cast<const CVIMPSTDetailsViewContainer&>( iPlugin.GetContainer() ); |
|
162 |
|
163 TInt count = container.ListBoxModel().MdcaCount(); |
|
164 if( !count ) |
|
165 { |
|
166 // no items hide options |
|
167 if (aMenuPane->MenuItemExists(EVIMPSTDetailsEditCmd, pos)) |
|
168 { |
|
169 aMenuPane->SetItemDimmed(EVIMPSTDetailsEditCmd, ETrue ); |
|
170 } |
|
171 if (aMenuPane->MenuItemExists(ECCAppDetailsViewDeleteCmd, pos) ) |
|
172 { |
|
173 aMenuPane->SetItemDimmed(ECCAppDetailsViewDeleteCmd, ETrue ); |
|
174 } |
|
175 if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyDetailCmd, pos) ) |
|
176 { |
|
177 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyDetailCmd,ETrue ); |
|
178 } |
|
179 if (aMenuPane->MenuItemExists(ECCAppDetailsViewEditItemCmd, pos) ) |
|
180 { |
|
181 aMenuPane->SetItemDimmed(ECCAppDetailsViewEditItemCmd,ETrue ); |
|
182 } |
|
183 } |
|
184 break; |
|
185 } |
|
186 default: |
|
187 break; |
|
188 } |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // CVIMPSTDetailsViewMenuHandler::HandleNotifyL |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CVIMPSTDetailsViewMenuHandler::HandleNotifyL( |
|
196 TInt aCmdId, |
|
197 TInt aEventId, |
|
198 CAiwGenericParamList& aEventParamList, |
|
199 const CAiwGenericParamList& /*aInParamList*/) |
|
200 { |
|
201 TInt result = KErrNone; |
|
202 |
|
203 if (aCmdId == KAiwCmdAssign) |
|
204 { |
|
205 if (aEventId == KAiwEventCompleted) |
|
206 { |
|
207 TInt index = 0; |
|
208 const TAiwGenericParam* param = aEventParamList.FindFirst(index, |
|
209 EGenericParamContactLinkArray); |
|
210 if (param) |
|
211 { |
|
212 TPtrC8 contactLinks = param->Value().AsData(); |
|
213 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC( |
|
214 contactLinks, iPlugin.GetContactHandler()->ContactStoresL()); |
|
215 if(links) |
|
216 { |
|
217 iPlugin.GetContactHandler()->SetLinks(links, EFalse); |
|
218 } |
|
219 CleanupStack::Pop(links); |
|
220 } |
|
221 |
|
222 const TAiwGenericParam* indexparam = aEventParamList.FindFirst(index, |
|
223 EGenericParamContactItem); |
|
224 if (indexparam) |
|
225 { |
|
226 const CVIMPSTDetailsViewContainer& container = |
|
227 static_cast<const CVIMPSTDetailsViewContainer&>(iPlugin.GetContainer()); |
|
228 TInt index = indexparam->Value().AsTInt32(); |
|
229 container.ListBoxModel().SetFocusedListIndex(index); |
|
230 } |
|
231 result = ETrue; |
|
232 } |
|
233 else if (aEventId == KAiwEventCanceled) |
|
234 { |
|
235 //if cancelled |
|
236 result = ETrue; |
|
237 } |
|
238 else if (aEventId == KAiwEventQueryExit) |
|
239 { |
|
240 //issue command to cancel the previous request. |
|
241 iAiwServiceHandler->ExecuteServiceCmdL( |
|
242 KAiwCmdAssign, |
|
243 iAiwServiceHandler->InParamListL(), |
|
244 iAiwServiceHandler->OutParamListL(), |
|
245 KAiwOptCancel, |
|
246 this); |
|
247 result = ETrue; |
|
248 } |
|
249 } |
|
250 |
|
251 return result; |
|
252 } |
|
253 // --------------------------------------------------------------------------- |
|
254 // CVIMPSTDetailsViewMenuHandler::HandleCommandL |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CVIMPSTDetailsViewMenuHandler::HandleCommandL(TInt aCommand) |
|
258 { |
|
259 // TODO : dependency on cca , they are not deleting the menu items Then check if command is normal application command |
|
260 switch (aCommand) |
|
261 { |
|
262 case KAiwCmdAssign:// AIW service cmd for Editing |
|
263 { |
|
264 if(iAiwServiceHandler && (iStoreType == EStoreLocal)) |
|
265 { |
|
266 DoEditCmdL(); |
|
267 } |
|
268 break; |
|
269 } |
|
270 case EVIMPSTDetailsEditCmd: |
|
271 case ECCAppDetailsViewEditItemCmd: |
|
272 { |
|
273 //TODO: in case of server store nick names has to be supported |
|
274 break; |
|
275 } |
|
276 case EVIMPSTDetailsDeleteCmd: |
|
277 case ECCAppDetailsViewDeleteCmd: |
|
278 { |
|
279 DoDeleteCmdL(); |
|
280 break; |
|
281 } |
|
282 case EVIMPSTDetailsCopyCmd: |
|
283 case ECCAppDetailsViewCopyDetailCmd: |
|
284 { |
|
285 DoCopyCmdL(); |
|
286 break; |
|
287 } |
|
288 default: |
|
289 break; |
|
290 } |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CVIMPSTDetailsViewMenuHandler::DoEditCmdL |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 void CVIMPSTDetailsViewMenuHandler::DoEditCmdL() |
|
298 { |
|
299 const CVIMPSTDetailsViewContainer& container = |
|
300 static_cast<const CVIMPSTDetailsViewContainer&>(iPlugin.GetContainer()); |
|
301 |
|
302 |
|
303 CAiwGenericParamList& inParamList = iAiwServiceHandler->InParamListL(); |
|
304 |
|
305 inParamList.AppendL(TAiwGenericParam( |
|
306 EGenericParamContactAssignData, |
|
307 TAiwVariant(TAiwSingleContactAssignDataV1Pckg( |
|
308 TAiwSingleContactAssignDataV1().SetFlags(EskipInfoNotes))))); |
|
309 |
|
310 HBufC8* packedLinks = iPlugin.GetContactHandler()->Links()->PackLC(); |
|
311 |
|
312 inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray, |
|
313 TAiwVariant( *packedLinks))); |
|
314 |
|
315 TInt focusIndex = container.ListBoxModel().FocusedFieldIndex(); |
|
316 |
|
317 // TODO: use int instead of buf. |
|
318 TBuf<8> focusIndexBuf; |
|
319 focusIndexBuf.Num(focusIndex); |
|
320 const TAiwVariant focusIndexVariant(focusIndexBuf); |
|
321 |
|
322 inParamList.AppendL(TAiwGenericParam(EGenericParamContactItem, focusIndexVariant)); |
|
323 |
|
324 iAiwServiceHandler->ExecuteServiceCmdL( |
|
325 KAiwCmdAssign, |
|
326 inParamList, |
|
327 iAiwServiceHandler->OutParamListL(), |
|
328 NULL, |
|
329 this); |
|
330 |
|
331 CleanupStack::PopAndDestroy(packedLinks); |
|
332 |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // CVIMPSTDetailsViewMenuHandler::DoDeleteCmdL |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 void CVIMPSTDetailsViewMenuHandler::DoDeleteCmdL() |
|
340 { |
|
341 CAknInformationNote* informationNote = new(ELeave) CAknInformationNote; |
|
342 informationNote->ExecuteLD(_L("Delete not supported yet")); |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // CVIMPSTDetailsViewMenuHandler::DoCopyCmdL |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 void CVIMPSTDetailsViewMenuHandler::DoCopyCmdL() |
|
350 { |
|
351 CAknInformationNote* informationNote = new(ELeave) CAknInformationNote; |
|
352 informationNote->ExecuteLD(_L("Copy not supported yet")); |
|
353 } |
|
354 // --------------------------------------------------------------------------- |
|
355 // CVIMPSTDetailsViewMenuHandler::PrepareAiwMenusL |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CVIMPSTDetailsViewMenuHandler::PrepareAiwMenusL() |
|
359 { |
|
360 // Initialisation of AIW Servicehandler cannot be in |
|
361 // ConstructL, since the menus of plugin are given |
|
362 // later via ProvideApplicationResourcesL(..) |
|
363 iAiwServiceHandler = CAiwServiceHandler::NewL(); |
|
364 iAiwServiceHandler->AttachL( |
|
365 R_VIMPSTDETAILSVIEW_AIW_SERVICE_INTERESTS); |
|
366 |
|
367 } |
|
368 // End of File |