author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:53:46 +0300 | |
branch | RCL_3 |
changeset 130 | 67f2ed48ad91 |
parent 122 | 6cadd6867c17 |
permissions | -rw-r--r-- |
114 | 1 |
/* |
2 |
* Copyright (c) 2009-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: The engine class of MCS plugin. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// System includes |
|
19 |
#include <gulicon.h> |
|
20 |
#include <gslauncher.h> |
|
21 |
#include <mcsmenufilter.h> |
|
22 |
#include <mcsmenuoperation.h> |
|
23 |
#include <mcsmenuiconutility.h> |
|
24 |
#include <bautils.h> |
|
25 |
#include <StringLoader.h> |
|
26 |
#include <aknnotedialog.h> |
|
27 |
#include <mcspluginres.rsg> |
|
28 |
#include <apgcli.h> |
|
29 |
#include <apacmdln.h> |
|
30 |
#include <gfxtranseffect/gfxtranseffect.h> |
|
31 |
#include <akntranseffect.h> |
|
32 |
#include <schemehandler.h> |
|
33 |
#include <viewcli.h> // For CVwsSessionWrapper |
|
34 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 |
#include <viewclipartner.h> |
|
36 |
#endif |
|
37 |
#include <aisystemuids.hrh> |
|
38 |
||
39 |
// User includes |
|
40 |
#include "mcspluginengine.h" |
|
41 |
#include "mcsplugin.h" |
|
42 |
#include "mcsplugindata.h" |
|
43 |
#include "mcspluginuids.hrh" |
|
44 |
||
45 |
// Constants |
|
46 |
_LIT( KMyMenuData, "matrixmenudata" ); |
|
47 |
_LIT( KSkin, "skin" ); |
|
48 |
_LIT( KMif, "mif" ); |
|
49 |
_LIT( KResourceDrive, "Z:" ); |
|
50 |
_LIT( KResourceFile, "mcspluginres.rsc" ); |
|
51 |
_LIT( KResPath, "\\resource\\" ); |
|
52 |
_LIT( KMMApplication, "mm://" ); |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
53 |
_LIT( KHideExit2, "&exit=hide" ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
54 |
_LIT( KSetFocusString, "!setfocus?applicationgroup_name=" ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
55 |
_LIT( KApplicationGroupName, "applicationgroup_name" ); |
114 | 56 |
_LIT( KIcon, "icon" ); |
57 |
_LIT( KMenuAttrUndefUid, "0x99999991" ); |
|
58 |
_LIT( KMenuIconFile, "aimcsplugin.mif" ); |
|
59 |
_LIT( KMenuBookmarkIconId, "16386" ); |
|
60 |
_LIT( KMenuBookmarkMaskId, "16387" ); |
|
61 |
_LIT( KMenuMailboxIconId, "16388" ); |
|
62 |
_LIT( KMenuMailboxMaskId, "16389" ); |
|
63 |
_LIT( KMenuTypeMailbox, "menu:mailbox" ); |
|
64 |
_LIT( KPrefix, "0x" ); |
|
65 |
||
66 |
const TUid KHomescreenUid = { AI_UID3_AIFW_COMMON }; |
|
67 |
const TUid KMMUid = { 0x101F4CD2 }; |
|
68 |
const TUid KMCSCmailUidValue = { 0x2001E277 }; |
|
69 |
const TUid KMCSCmailMailboxViewIdValue = { 0x2 }; |
|
70 |
const TUid KBrowserUid = { 0x10008D39 }; |
|
71 |
||
72 |
// ======== LOCAL FUNCTIONS ======== |
|
73 |
// ---------------------------------------------------------------------------- |
|
74 |
// NextIdToken |
|
75 |
// ---------------------------------------------------------------------------- |
|
76 |
// |
|
77 |
static TPtrC NextIdToken( TLex& aLexer ) |
|
78 |
{ |
|
79 |
aLexer.SkipSpace(); |
|
80 |
aLexer.Mark(); |
|
81 |
||
82 |
while( !aLexer.Eos() && !aLexer.Peek().IsSpace() && aLexer.Peek() != ')' ) |
|
83 |
{ |
|
84 |
aLexer.Inc(); |
|
85 |
} |
|
86 |
||
87 |
return aLexer.MarkedToken(); |
|
88 |
} |
|
89 |
||
90 |
// ---------------------------------------------------------------------------- |
|
91 |
// Shows note dailog, with the given resource. |
|
92 |
// ---------------------------------------------------------------------------- |
|
93 |
// |
|
94 |
static void ShowNoteDlgL( TInt aResource ) |
|
95 |
{ |
|
96 |
HBufC* temp = StringLoader::LoadLC( aResource ); |
|
97 |
||
98 |
CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
99 |
CAknNoteDialog::EConfirmationTone, |
|
100 |
CAknNoteDialog::ENoTimeout ); |
|
101 |
CleanupStack::PushL( dialog ); |
|
102 |
dialog->SetTextL( temp->Des() ); |
|
103 |
dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
104 |
CleanupStack::Pop( dialog ); |
|
105 |
CleanupStack::PopAndDestroy( temp ); |
|
106 |
} |
|
107 |
||
108 |
// ---------------------------------------------------------------------------- |
|
109 |
// Parses uid in Hexadecimal format from the given string. |
|
110 |
// ---------------------------------------------------------------------------- |
|
111 |
// |
|
112 |
TUid ParseHexUidFromString(const TDesC& aUidString ) |
|
113 |
{ |
|
114 |
TUid uid( KNullUid ); |
|
115 |
const TInt pos( aUidString.FindF( KPrefix ) ); |
|
116 |
||
117 |
if ( pos != KErrNotFound ) |
|
118 |
{ |
|
119 |
TLex lex( aUidString.Mid( pos + KPrefix().Length() ) ); |
|
120 |
||
121 |
// Hex parsing needs unsigned int |
|
122 |
TUint32 value( 0 ); |
|
123 |
const TInt parseResult( lex.Val( value, EHex ) ); |
|
124 |
||
125 |
if ( parseResult == KErrNone ) |
|
126 |
{ |
|
127 |
TInt32 value32( value ); |
|
128 |
uid.iUid = value32; |
|
129 |
} |
|
130 |
} |
|
131 |
return uid; |
|
132 |
} |
|
133 |
||
134 |
// ---------------------------------------------------------------------------- |
|
135 |
// Start transition effect. User has launched the application with the given uid. |
|
136 |
// ---------------------------------------------------------------------------- |
|
137 |
// |
|
138 |
void StartEffect( TUid aUid ) |
|
139 |
{ |
|
140 |
//start a full screen effect |
|
141 |
GfxTransEffect::BeginFullScreen( |
|
142 |
AknTransEffect::EApplicationStart, |
|
143 |
TRect(), |
|
144 |
AknTransEffect::EParameterType, |
|
145 |
AknTransEffect::GfxTransParam( aUid, |
|
146 |
AknTransEffect::TParameter::EActivateExplicitContinue )); |
|
147 |
} |
|
148 |
||
149 |
// ============================ MEMBER FUNCTIONS =============================== |
|
150 |
// ---------------------------------------------------------------------------- |
|
151 |
// CMCSPluginEngine::CMCSPluginEngine |
|
152 |
// |
|
153 |
// ---------------------------------------------------------------------------- |
|
154 |
// |
|
155 |
CMCSPluginEngine::CMCSPluginEngine( CMCSPlugin& aPlugin, |
|
156 |
const TDesC8& aInstanceUid ) |
|
157 |
: iPlugin( aPlugin ), iInstanceUid( aInstanceUid ) |
|
158 |
{ |
|
159 |
} |
|
160 |
||
161 |
// ---------------------------------------------------------------------------- |
|
162 |
// CMCSPluginEngine::NewL |
|
163 |
// |
|
164 |
// ---------------------------------------------------------------------------- |
|
165 |
// |
|
166 |
CMCSPluginEngine* CMCSPluginEngine::NewL( CMCSPlugin& aPlugin, |
|
167 |
const TDesC8& aInstanceUid ) |
|
168 |
{ |
|
169 |
CMCSPluginEngine* self = |
|
170 |
new( ELeave ) CMCSPluginEngine( aPlugin, aInstanceUid ); |
|
171 |
||
172 |
CleanupStack::PushL( self ); |
|
173 |
self->ConstructL(); |
|
174 |
CleanupStack::Pop( self ); |
|
175 |
||
176 |
return self; |
|
177 |
} |
|
178 |
||
179 |
// ---------------------------------------------------------------------------- |
|
180 |
// CMCSPluginEngine::ConstructL |
|
181 |
// |
|
182 |
// ---------------------------------------------------------------------------- |
|
183 |
// |
|
184 |
void CMCSPluginEngine::ConstructL() |
|
185 |
{ |
|
186 |
TFullName resourceFile( KResourceDrive ); |
|
187 |
resourceFile.Append( KResPath ); |
|
188 |
resourceFile.Append( KResourceFile ); |
|
189 |
BaflUtils::NearestLanguageFile( |
|
190 |
CCoeEnv::Static()->FsSession(), |
|
191 |
resourceFile ); |
|
192 |
iResourceOffset = |
|
193 |
CCoeEnv::Static()->AddResourceFileL( resourceFile ); |
|
194 |
InitL(); |
|
195 |
StartObservingL(); |
|
196 |
||
197 |
// Get "Undefined" item |
|
198 |
CMenuFilter* filter = CMenuFilter::NewL(); |
|
199 |
CleanupStack::PushL( filter ); |
|
200 |
filter->HaveAttributeL( KMenuAttrUid, KMenuAttrUndefUid ); |
|
201 |
iUndefinedItemHeader = FindMenuItemL( *filter ); |
|
202 |
CleanupStack::PopAndDestroy( filter ); |
|
203 |
iUndefinedItem = CMenuItem::OpenL( iMenu, iUndefinedItemHeader ); |
|
204 |
} |
|
205 |
||
206 |
// ---------------------------------------------------------------------------- |
|
207 |
// CMCSPluginEngine::~CMCSPluginEngine |
|
208 |
// |
|
209 |
// ---------------------------------------------------------------------------- |
|
210 |
// |
|
211 |
CMCSPluginEngine::~CMCSPluginEngine() |
|
212 |
{ |
|
213 |
StopObserving(); |
|
214 |
||
215 |
delete iPluginData; |
|
216 |
||
217 |
// Notifier close has to be before iMenu close |
|
218 |
iNotifier.Close(); |
|
219 |
iMenu.Close(); |
|
220 |
delete iWatcher; |
|
221 |
delete iNotifyWatcher; |
|
222 |
||
223 |
CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ); |
|
224 |
||
225 |
delete iUndefinedItem; |
|
226 |
} |
|
227 |
||
228 |
// --------------------------------------------------------------------------- |
|
229 |
// CMCSPluginEngine::InitL |
|
230 |
// |
|
231 |
// --------------------------------------------------------------------------- |
|
232 |
// |
|
233 |
void CMCSPluginEngine::InitL() |
|
234 |
{ |
|
235 |
iMenu.OpenL( KMyMenuData ); |
|
236 |
iPluginData = CMCSPluginData::NewL( *this, iInstanceUid ); |
|
237 |
iWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation ); |
|
238 |
||
239 |
TInt err( iNotifier.Open( iMenu ) ); |
|
240 |
||
241 |
if ( err == KErrNone ) |
|
242 |
{ |
|
243 |
iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify ); |
|
244 |
||
245 |
iNotifier.Notify( 0, |
|
246 |
RMenuNotifier::EItemsAddedRemoved, |
|
247 |
iNotifyWatcher->iStatus ); |
|
248 |
iNotifyWatcher->WatchNotify( this ); |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
// --------------------------------------------------------------------------- |
|
253 |
// CMCSPluginEngine::StartObservingL |
|
254 |
// |
|
255 |
// --------------------------------------------------------------------------- |
|
256 |
// |
|
257 |
void CMCSPluginEngine::StartObservingL() |
|
258 |
{ |
|
259 |
// registering to mailbox db. changes observing |
|
260 |
iMsvSession = CMsvSession::OpenAsObserverL( *this ); |
|
261 |
} |
|
262 |
||
263 |
// --------------------------------------------------------------------------- |
|
264 |
// CMCSPluginEngine::StopObserving |
|
265 |
// |
|
266 |
// --------------------------------------------------------------------------- |
|
267 |
// |
|
268 |
void CMCSPluginEngine::StopObserving() |
|
269 |
{ |
|
270 |
delete iMsvSession; |
|
271 |
iMsvSession = NULL; |
|
272 |
} |
|
273 |
||
274 |
// --------------------------------------------------------------------------- |
|
275 |
// CMCSPluginEngine::MenuDataL |
|
276 |
// |
|
277 |
// --------------------------------------------------------------------------- |
|
278 |
// |
|
279 |
CMCSData& CMCSPluginEngine::MenuDataL( const TInt& aIndex ) |
|
280 |
{ |
|
281 |
return iPluginData->DataItemL( aIndex ); |
|
282 |
} |
|
283 |
||
284 |
// --------------------------------------------------------------------------- |
|
285 |
// CMCSPluginEngine::MenuItemCount |
|
286 |
// |
|
287 |
// --------------------------------------------------------------------------- |
|
288 |
// |
|
289 |
TInt CMCSPluginEngine::MenuItemCount() |
|
290 |
{ |
|
291 |
return iPluginData->DataCount(); |
|
292 |
} |
|
293 |
||
294 |
// --------------------------------------------------------------------------- |
|
295 |
// CMCSPluginEngine::FindMenuItemL |
|
296 |
// Returns the menu item header, which matches the given filter. |
|
297 |
// --------------------------------------------------------------------------- |
|
298 |
// |
|
299 |
TMenuItem CMCSPluginEngine::FindMenuItemL( CMenuFilter& aFilter ) |
|
300 |
{ |
|
301 |
TMenuItem item; |
|
302 |
const TInt root( iMenu.RootFolderL() ); |
|
303 |
||
304 |
RArray<TMenuItem> items; |
|
305 |
CleanupClosePushL( items ); |
|
306 |
||
307 |
iMenu.GetItemsL( items, root, &aFilter, ETrue ); |
|
308 |
||
309 |
if ( items.Count() > 0 ) |
|
310 |
{ |
|
311 |
item = items[0]; |
|
312 |
} |
|
313 |
||
314 |
CleanupStack::PopAndDestroy( &items ); |
|
315 |
||
316 |
return item; |
|
317 |
} |
|
318 |
||
319 |
// --------------------------------------------------------------------------- |
|
320 |
// CMCSPluginEngine::FetchMenuItemL |
|
321 |
// Returns the actual menu item for the given header. |
|
322 |
// --------------------------------------------------------------------------- |
|
323 |
// |
|
324 |
CMenuItem* CMCSPluginEngine::FetchMenuItemL( CMCSData& aData ) |
|
325 |
{ |
|
326 |
CMenuItem* item = NULL; |
|
327 |
||
328 |
TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, aData.MenuItem().Id() ) ); |
|
329 |
||
330 |
if( item ) |
|
331 |
{ |
|
332 |
return item; |
|
333 |
} |
|
334 |
||
335 |
if( aData.MenuItem().Type() == KMenuTypeUrl ) |
|
336 |
{ |
|
337 |
item = CreateBkmItemL( aData ); |
|
338 |
} |
|
339 |
else if( aData.MenuItem().Type() == KMenuTypeMailbox ) |
|
340 |
{ |
|
341 |
item = CreateMailboxItemL( aData); |
|
342 |
} |
|
343 |
||
344 |
return item; |
|
345 |
} |
|
346 |
||
347 |
// --------------------------------------------------------------------------- |
|
348 |
// |
|
349 |
// --------------------------------------------------------------------------- |
|
350 |
// |
|
351 |
CMenuItem* CMCSPluginEngine::CreateBkmItemL( CMCSData& aData ) |
|
352 |
{ |
|
353 |
CMenuItem* item( NULL ); |
|
354 |
if( aData.MenuItem().Id() != KErrNotFound ) |
|
355 |
{ |
|
356 |
item = CMenuItem::CreateL( iMenu, KMenuTypeUrl, 0, 0 ); |
|
357 |
CleanupStack::PushL( item ); |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
358 |
item->SetAttributeL( KMenuAttrLongName, aData.Name() ); |
114 | 359 |
item->SetAttributeL( KMenuAttrIconFile, KMenuIconFile ); |
360 |
item->SetAttributeL( KMenuAttrIconId, KMenuBookmarkIconId ); |
|
361 |
item->SetAttributeL( KMenuAttrMaskId, KMenuBookmarkMaskId ); |
|
362 |
CleanupStack::Pop( item ); |
|
363 |
} |
|
364 |
return item; |
|
365 |
} |
|
366 |
||
367 |
// --------------------------------------------------------------------------- |
|
368 |
// |
|
369 |
// --------------------------------------------------------------------------- |
|
370 |
// |
|
371 |
CMenuItem* CMCSPluginEngine::CreateMailboxItemL( CMCSData& aData ) |
|
372 |
{ |
|
373 |
CMenuItem* item( NULL ); |
|
374 |
if( aData.MenuItem().Id() != KErrNotFound ) |
|
375 |
{ |
|
376 |
item = CMenuItem::CreateL( iMenu, KMenuTypeMailbox, 0, 0 ); |
|
377 |
CleanupStack::PushL( item ); |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
378 |
item->SetAttributeL( KMenuAttrLongName, aData.Name() ); |
114 | 379 |
item->SetAttributeL( KMenuAttrIconFile, KMenuIconFile ); |
380 |
item->SetAttributeL( KMenuAttrIconId, KMenuMailboxIconId ); |
|
381 |
item->SetAttributeL( KMenuAttrMaskId, KMenuMailboxMaskId ); |
|
382 |
CleanupStack::Pop( item ); |
|
383 |
} |
|
384 |
return item; |
|
385 |
} |
|
386 |
||
387 |
// --------------------------------------------------------------------------- |
|
388 |
// CMCSPluginEngine::ItemIconL |
|
389 |
// Returns MCS default icon if attribute is 'icon' else parses the |
|
390 |
// skin definition from attribute and sets attributes to aMenuItem. |
|
391 |
// --------------------------------------------------------------------------- |
|
392 |
// |
|
393 |
CGulIcon* CMCSPluginEngine::ItemIconL( CMenuItem* aMenuItem, |
|
394 |
const TDesC& aAttr ) |
|
395 |
{ |
|
396 |
||
397 |
CMenuItem* menuItem; |
|
398 |
||
399 |
// check if item exists in MCS |
|
400 |
if ( aMenuItem ) |
|
401 |
{ |
|
402 |
TUint32 flags = aMenuItem->Flags(); |
|
403 |
TUint32 isHidden = flags & TMenuItem::EHidden; |
|
404 |
TUint32 isMissing = flags & TMenuItem::EMissing; |
|
405 |
||
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
406 |
if ( iUndefinedItem && ( isHidden || isMissing ) ) |
114 | 407 |
{ |
408 |
menuItem = iUndefinedItem; |
|
409 |
} |
|
410 |
else |
|
411 |
{ |
|
412 |
menuItem = aMenuItem; |
|
413 |
} |
|
414 |
} |
|
415 |
else |
|
416 |
{ |
|
417 |
// item not found in MCS. Use Undefined Icon |
|
418 |
menuItem = iUndefinedItem; |
|
419 |
} |
|
420 |
||
421 |
CAknIcon* icon( NULL ); |
|
422 |
CGulIcon* gIcon( NULL ); |
|
423 |
TBool exists( ETrue ); |
|
424 |
||
425 |
if ( aAttr != KIcon ) |
|
426 |
{ |
|
427 |
// Resolve secondary icon definition from attribute |
|
428 |
TPtrC iconDef( menuItem->GetAttributeL( aAttr, exists ) ); |
|
429 |
||
430 |
if ( exists ) |
|
431 |
{ |
|
432 |
exists = ConstructMenuItemForIconL( iconDef, *menuItem ); |
|
433 |
} |
|
434 |
} |
|
435 |
||
436 |
if ( exists ) |
|
437 |
{ |
|
438 |
icon = MenuIconUtility::GetItemIconL( *menuItem ); |
|
439 |
||
440 |
if ( icon ) |
|
441 |
{ |
|
442 |
CleanupStack::PushL( icon ); |
|
443 |
||
444 |
gIcon = CGulIcon::NewL( icon->Bitmap(), icon->Mask() ); |
|
445 |
||
446 |
// Detach and delete |
|
447 |
icon->SetBitmap( NULL ); |
|
448 |
icon->SetMask( NULL ); |
|
449 |
||
450 |
CleanupStack::PopAndDestroy( icon ); |
|
451 |
} |
|
452 |
} |
|
453 |
||
454 |
return gIcon; |
|
455 |
} |
|
456 |
||
457 |
// --------------------------------------------------------------------------- |
|
458 |
// CMCSPluginEngine::ItemTextL |
|
459 |
// Returns text string for the given attribute |
|
460 |
// --------------------------------------------------------------------------- |
|
461 |
// |
|
462 |
TPtrC CMCSPluginEngine::ItemTextL( CMenuItem* aMenuItem, const TDesC& aAttr ) |
|
463 |
{ |
|
464 |
||
465 |
CMenuItem* menuItem; |
|
466 |
||
467 |
// check if item exists in MCS |
|
468 |
if ( aMenuItem ) |
|
469 |
{ |
|
470 |
TUint32 flags = aMenuItem->Flags(); |
|
471 |
TUint32 isHidden = flags & TMenuItem::EHidden; |
|
472 |
TUint32 isMissing = flags & TMenuItem::EMissing; |
|
473 |
||
474 |
// if item is hidden or missing (mmc card removed) |
|
475 |
// use "Undefined" text instead |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
476 |
if ( iUndefinedItem && ( isHidden || isMissing ) ) |
114 | 477 |
{ |
478 |
menuItem = iUndefinedItem; |
|
479 |
} |
|
480 |
else |
|
481 |
{ |
|
482 |
menuItem = aMenuItem; |
|
483 |
} |
|
484 |
} |
|
485 |
else |
|
486 |
{ |
|
487 |
// item not found in MCS. Use "Undefined" text |
|
488 |
menuItem = iUndefinedItem; |
|
489 |
} |
|
490 |
||
491 |
TBool exists( KErrNotFound ); |
|
492 |
||
493 |
TPtrC name( menuItem->GetAttributeL( aAttr, exists ) ); |
|
494 |
||
495 |
if ( exists ) |
|
496 |
{ |
|
497 |
return name; |
|
498 |
} |
|
499 |
||
500 |
return KNullDesC(); |
|
501 |
} |
|
502 |
||
503 |
// --------------------------------------------------------------------------- |
|
504 |
// CMCSPluginEngine::LaunchItemL |
|
505 |
// Calls the open command for the given menu item header |
|
506 |
// --------------------------------------------------------------------------- |
|
507 |
// |
|
508 |
void CMCSPluginEngine::LaunchItemL( const TInt& aIndex ) |
|
509 |
{ |
|
510 |
if ( iBackupRestore ) |
|
511 |
{ |
|
512 |
ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM ); |
|
513 |
return; |
|
514 |
} |
|
515 |
||
516 |
CMCSData& dataItem( iPluginData->DataItemL( aIndex ) ); |
|
517 |
// run item based on its type |
|
518 |
TPtrC type( dataItem.MenuItem().Type()); |
|
519 |
||
520 |
// run folder |
|
521 |
if ( type == KMenuTypeFolder ) |
|
522 |
{ |
|
523 |
LaunchFolderItemL( dataItem ); |
|
524 |
} |
|
525 |
else if( type == KMenuTypeUrl ) |
|
526 |
{ |
|
527 |
LaunchBookmarkItemL( dataItem ); |
|
528 |
} |
|
529 |
else if( type == KMenuTypeMailbox ) |
|
530 |
{ |
|
531 |
LaunchMailboxItemL( dataItem ); |
|
532 |
} |
|
533 |
else |
|
534 |
{ |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
535 |
LaunchMCSItemL( dataItem ); |
114 | 536 |
} |
537 |
} |
|
538 |
||
539 |
// --------------------------------------------------------------------------- |
|
540 |
// |
|
541 |
// --------------------------------------------------------------------------- |
|
542 |
// |
|
543 |
void CMCSPluginEngine::LaunchFolderItemL( CMCSData& aData ) |
|
544 |
{ |
|
545 |
CMenuItem* item = NULL; |
|
546 |
TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, aData.MenuItem().Id() ) ); |
|
547 |
||
548 |
// item does not exist at all in MCS |
|
549 |
if ( item == NULL ) |
|
550 |
{ |
|
551 |
ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
552 |
return; |
|
553 |
} |
|
554 |
||
555 |
CleanupStack::PushL( item ); |
|
556 |
||
557 |
StartEffect( KMMUid ); |
|
558 |
||
559 |
// message for MM application |
|
560 |
HBufC8* message; |
|
561 |
||
562 |
// prepare message for launching folder |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
563 |
TBool hasApplicationGroupName( EFalse ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
564 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
565 |
TPtrC applicationGroupName( item->GetAttributeL( |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
566 |
KApplicationGroupName, hasApplicationGroupName ) ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
567 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
568 |
if ( !hasApplicationGroupName ) |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
569 |
{ |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
570 |
return; |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
571 |
} |
114 | 572 |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
573 |
message = HBufC8::NewLC( KMMApplication().Length() + |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
574 |
KSetFocusString().Length() + |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
575 |
applicationGroupName.Length() + |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
576 |
KHideExit2().Length() ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
577 |
|
114 | 578 |
message->Des().Copy( KMMApplication ); |
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
579 |
message->Des().Append( KSetFocusString ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
580 |
message->Des().Append( applicationGroupName ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
581 |
message->Des().Append( KHideExit2 ); |
114 | 582 |
|
583 |
// find MM application |
|
584 |
TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
585 |
TApaTask task( taskList.FindApp( KMMUid ) ); |
|
586 |
||
587 |
if ( task.Exists() ) |
|
588 |
{ |
|
589 |
// MM is already running in background - send APA Message |
|
590 |
task.SendMessage( |
|
591 |
TUid::Uid( KUidApaMessageSwitchOpenFileValue ), *message ); |
|
592 |
} |
|
593 |
else |
|
594 |
{ |
|
595 |
// MM not running yet - use Command Line Tail |
|
596 |
RApaLsSession appArcSession; |
|
597 |
CleanupClosePushL( appArcSession ); |
|
598 |
||
599 |
User::LeaveIfError( appArcSession.Connect() ); |
|
600 |
||
601 |
TApaAppInfo appInfo; |
|
602 |
TInt err( appArcSession.GetAppInfo( appInfo, KMMUid ) ); |
|
603 |
||
604 |
if ( err == KErrNone ) |
|
605 |
{ |
|
606 |
CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
607 |
cmdLine->SetExecutableNameL( appInfo.iFullName ); |
|
608 |
cmdLine->SetCommandL( EApaCommandRun ); |
|
609 |
cmdLine->SetTailEndL( *message ); |
|
610 |
appArcSession.StartApp( *cmdLine ); |
|
611 |
CleanupStack::PopAndDestroy( cmdLine ); |
|
612 |
} |
|
613 |
CleanupStack::PopAndDestroy( &appArcSession ); |
|
614 |
} |
|
615 |
CleanupStack::PopAndDestroy( message ); |
|
616 |
CleanupStack::PopAndDestroy( item ); |
|
617 |
} |
|
618 |
||
619 |
// --------------------------------------------------------------------------- |
|
620 |
// |
|
621 |
// --------------------------------------------------------------------------- |
|
622 |
// |
|
623 |
void CMCSPluginEngine::LaunchBookmarkItemL( CMCSData& aData ) |
|
624 |
{ |
|
625 |
StartEffect( KBrowserUid ); |
|
626 |
||
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
627 |
CSchemeHandler* urlHandler = CSchemeHandler::NewL( aData.Value()); |
114 | 628 |
CleanupStack::PushL( urlHandler ); |
629 |
urlHandler->HandleUrlStandaloneL(); |
|
630 |
CleanupStack::PopAndDestroy( urlHandler ); |
|
631 |
} |
|
632 |
||
633 |
// --------------------------------------------------------------------------- |
|
634 |
// |
|
635 |
// --------------------------------------------------------------------------- |
|
636 |
// |
|
637 |
void CMCSPluginEngine::LaunchMailboxItemL( CMCSData& aData ) |
|
638 |
{ |
|
639 |
TInt id( aData.MenuItem().Id()); |
|
640 |
if ( id == KErrNotFound ) |
|
641 |
{ |
|
642 |
ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
643 |
return; |
|
644 |
} |
|
645 |
||
646 |
StartEffect( KMCSCmailUidValue ); |
|
647 |
||
648 |
TUid uId = TUid::Uid( id ); |
|
649 |
const TVwsViewId viewId( KMCSCmailUidValue, KMCSCmailMailboxViewIdValue ); |
|
650 |
CVwsSessionWrapper* vwsSession = CVwsSessionWrapper::NewL(); |
|
651 |
vwsSession->CreateActivateViewEvent( viewId, uId, KNullDesC8() ); |
|
652 |
delete vwsSession; |
|
653 |
} |
|
654 |
||
655 |
// --------------------------------------------------------------------------- |
|
656 |
// |
|
657 |
// --------------------------------------------------------------------------- |
|
658 |
// |
|
659 |
void CMCSPluginEngine::LaunchMCSItemL( CMCSData& aData ) |
|
660 |
{ |
|
661 |
if( iWatcher->IsActive()) |
|
662 |
{ |
|
663 |
return; |
|
664 |
} |
|
665 |
CMenuItem* item = NULL; |
|
666 |
TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, aData.MenuItem().Id() ) ); |
|
667 |
||
668 |
// item does not exist at all in MCS |
|
669 |
if ( item == NULL ) |
|
670 |
{ |
|
671 |
ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
672 |
return; |
|
673 |
} |
|
674 |
||
675 |
CleanupStack::PushL( item ); |
|
676 |
||
677 |
TBool attrExists = ETrue; |
|
678 |
TPtrC uid = item->GetAttributeL( KMenuAttrUid, attrExists ); |
|
679 |
||
680 |
// trying to run hidden or missing application (e.g. unistalled app |
|
681 |
// or app on MMC which was removed ) |
|
682 |
// -> We display a note for a user that this is not possible¨ |
|
683 |
TUint32 isHidden = item->Flags() & TMenuItem::EHidden; |
|
684 |
TUint32 isMissing = item->Flags() & TMenuItem::EMissing; |
|
685 |
||
686 |
if ( ( attrExists && uid == KMenuAttrUndefUid ) || isHidden || isMissing ) |
|
687 |
{ |
|
688 |
CleanupStack::PopAndDestroy( item ); |
|
689 |
ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
690 |
return; |
|
691 |
} |
|
692 |
||
693 |
if ( attrExists ) |
|
694 |
{ |
|
695 |
StartEffect( ParseHexUidFromString( uid )); |
|
696 |
} |
|
697 |
||
698 |
// run application/shortcut |
|
699 |
CMenuOperation* operation( item->HandleCommandL( |
|
700 |
KMenuCmdOpen, KNullDesC8, iWatcher->iStatus ) ); |
|
701 |
iWatcher->Watch( operation ); |
|
702 |
CleanupStack::PopAndDestroy( item ); |
|
703 |
} |
|
704 |
||
705 |
// --------------------------------------------------------------------------- |
|
706 |
// CMCSPluginEngine::HandleNotifyL |
|
707 |
// Handle the change in Menu Content |
|
708 |
// --------------------------------------------------------------------------- |
|
709 |
// |
|
710 |
void CMCSPluginEngine::HandleNotifyL() |
|
711 |
{ |
|
712 |
TInt count( iPluginData->DataCount() ); |
|
713 |
||
714 |
for ( TInt i = 0; i < count; i++ ) |
|
715 |
{ |
|
716 |
CMCSData& data( iPluginData->DataItemL( i ) ); |
|
717 |
data.SetDirty( ETrue ); |
|
718 |
} |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
719 |
iPluginData->UpdateDataL(); |
114 | 720 |
|
721 |
iPlugin.PublishL(); |
|
722 |
||
723 |
// Notification must be activated again |
|
724 |
iNotifyWatcher->Cancel(); |
|
725 |
iNotifier.Notify( 0, |
|
726 |
RMenuNotifier::EItemsAddedRemoved, |
|
727 |
iNotifyWatcher->iStatus ); |
|
728 |
||
729 |
iNotifyWatcher->WatchNotify( this ); |
|
730 |
} |
|
731 |
||
732 |
// --------------------------------------------------------------------------- |
|
733 |
// CMCSPluginEngine::HandleSessionEventL |
|
734 |
// Handles an event from the message server. |
|
735 |
// --------------------------------------------------------------------------- |
|
736 |
// |
|
737 |
void CMCSPluginEngine::HandleSessionEventL( TMsvSessionEvent aEvent, |
|
738 |
TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
739 |
{ |
|
740 |
switch ( aEvent ) |
|
741 |
{ |
|
742 |
case EMsvEntriesDeleted: |
|
743 |
{ |
|
744 |
CMsvEntrySelection* sel = static_cast<CMsvEntrySelection*>( aArg1 ); |
|
745 |
TInt count( sel->Count()); |
|
746 |
for( TInt i = 0; i < count; i++ ) |
|
747 |
{ |
|
748 |
iPluginData->RemoveDataL( sel->At( i ) ); |
|
749 |
} |
|
750 |
} |
|
751 |
break; |
|
752 |
default: |
|
753 |
break; |
|
754 |
} |
|
755 |
} |
|
756 |
||
757 |
// --------------------------------------------------------------------------- |
|
758 |
// CMCSPluginEngine::SetBackupRestore |
|
759 |
// |
|
760 |
// --------------------------------------------------------------------------- |
|
761 |
// |
|
762 |
void CMCSPluginEngine::SetBackupRestore( TBool aBackupRestore ) |
|
763 |
{ |
|
764 |
iBackupRestore = aBackupRestore; |
|
765 |
} |
|
766 |
||
767 |
// --------------------------------------------------------------------------- |
|
768 |
// CMCSPluginEngine::ShowSettingsL |
|
769 |
// Launch General Settings plugin |
|
770 |
// --------------------------------------------------------------------------- |
|
771 |
// |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
772 |
void CMCSPluginEngine::ShowSettingsL() |
114 | 773 |
{ |
774 |
TUid uid = {AI_UID_ECOM_IMPLEMENTATION_SETTINGS_MCSPLUGIN}; |
|
775 |
||
776 |
CGSLauncher* launcher = CGSLauncher::NewLC(); |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
777 |
launcher->LaunchGSViewL ( uid, KHomescreenUid, iInstanceUid ); |
114 | 778 |
CleanupStack::PopAndDestroy( launcher ); |
779 |
} |
|
780 |
||
781 |
// --------------------------------------------------------------------------- |
|
782 |
// CMCSPluginEngine::ConstructMenuItemForIconL |
|
783 |
// Syntax: skin(major minor):mif(filename bimapId maskId) |
|
784 |
// --------------------------------------------------------------------------- |
|
785 |
// |
|
786 |
TBool CMCSPluginEngine::ConstructMenuItemForIconL( const TDesC& aPath, |
|
787 |
CMenuItem& aMenuItem ) |
|
788 |
{ |
|
789 |
TInt pos( aPath.Locate( ':' ) ); |
|
790 |
if ( pos == KErrNotFound ) |
|
791 |
{ |
|
792 |
pos = aPath.Length(); |
|
793 |
} |
|
794 |
TPtrC skin( aPath.Left( pos ) ); |
|
795 |
TInt sf( skin.FindF( KSkin ) ); |
|
796 |
||
797 |
if ( sf == KErrNotFound ) |
|
798 |
{ |
|
799 |
return EFalse; |
|
800 |
} |
|
801 |
||
802 |
TPtrC temp( skin.Mid( sf + KSkin().Length() ) ); |
|
803 |
TLex input( temp ); |
|
804 |
input.SkipSpace(); |
|
805 |
||
806 |
if ( !input.Eos() && input.Peek() == '(' ) |
|
807 |
{ |
|
808 |
input.Inc(); |
|
809 |
} |
|
810 |
TPtrC majorId( NextIdToken( input ) ); |
|
811 |
TPtrC minorId( NextIdToken( input ) ); |
|
812 |
||
813 |
aMenuItem.SetAttributeL( KMenuAttrIconSkinMajorId, majorId ); |
|
814 |
aMenuItem.SetAttributeL( KMenuAttrIconSkinMinorId, minorId ); |
|
815 |
||
816 |
if ( aPath.Length() > pos && |
|
817 |
( aPath.Mid( pos + 1 ).FindF( KMif ) != KErrNotFound ) ) |
|
818 |
{ |
|
819 |
TPtrC mif( aPath.Mid( pos + 1 ) ); |
|
820 |
TInt mf( mif.FindF( KMif ) ); |
|
821 |
||
822 |
TLex input1( mif.Mid( mf + KMif().Length() ) ); |
|
823 |
input1.SkipSpace(); |
|
824 |
||
825 |
if ( !input1.Eos() && input1.Peek() == '(' ) |
|
826 |
{ |
|
827 |
input1.Inc(); |
|
828 |
} |
|
829 |
||
830 |
TPtrC file( NextIdToken( input1 ) ); |
|
831 |
TPtrC bitmapId( NextIdToken( input1 ) ); |
|
832 |
TPtrC maskId( NextIdToken( input1 ) ); |
|
833 |
||
834 |
aMenuItem.SetAttributeL( KMenuAttrIconFile, file ); |
|
835 |
aMenuItem.SetAttributeL( KMenuAttrIconId, bitmapId ); |
|
836 |
aMenuItem.SetAttributeL( KMenuAttrMaskId, maskId ); |
|
837 |
} |
|
838 |
||
839 |
return ETrue; |
|
840 |
} |
|
841 |
||
842 |
// End of file |