|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <mcsmenuutils.h> |
|
20 #include "menulinkhandler.h" |
|
21 #include "menuuninstalloperation.h" |
|
22 #include "mcsdef.h" |
|
23 #include "mcsmenuitem.h" |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // --------------------------------------------------------- |
|
28 // CMenuLinkHandler::~CMenuLinkHandler |
|
29 // --------------------------------------------------------- |
|
30 // |
|
31 CMenuLinkHandler::~CMenuLinkHandler() |
|
32 { |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // CMenuLinkHandler::NewL |
|
37 // --------------------------------------------------------- |
|
38 // |
|
39 CMenuLinkHandler* CMenuLinkHandler::NewL( RMenu &aMenu ) |
|
40 { |
|
41 CMenuLinkHandler* handler = new (ELeave) CMenuLinkHandler( aMenu ); |
|
42 CleanupStack::PushL( handler ); |
|
43 handler->ConstructL(); |
|
44 CleanupStack::Pop( handler ); |
|
45 return handler; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // CMenuLinkHandler::CMenuLinkHandler |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CMenuLinkHandler::CMenuLinkHandler( RMenu &aMenu ) |
|
53 : CMenuHandlerPlugin( aMenu ) |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------- |
|
58 // CMenuLinkHandler::ConstructL |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 void CMenuLinkHandler::ConstructL() |
|
62 { |
|
63 BaseConstructL(); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CMenuLinkHandler::SupportsType |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 TBool CMenuLinkHandler::SupportsType( const TDesC& aType ) |
|
71 { |
|
72 if ( !aType.Compare( KMenuTypeLink ) ) |
|
73 { |
|
74 return ETrue; |
|
75 } |
|
76 return EFalse; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CMenuLinkHandler::HandleCommandL |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CMenuOperation* CMenuLinkHandler::HandleCommandL( |
|
84 CMenuItem& aItem, |
|
85 const TDesC8& aCommand, |
|
86 const TDesC8& aParams, |
|
87 TRequestStatus& aStatus ) |
|
88 { |
|
89 if ( aCommand == KMenuCmdOpen && aItem.Type() == KMenuTypeLink ) |
|
90 { |
|
91 TBool attrExists = EFalse; |
|
92 TPtrC val = aItem.GetAttributeL( KMenuAttrRefId, attrExists ); |
|
93 if ( attrExists ) |
|
94 { |
|
95 // "ref_id" defined, get item and forward command. |
|
96 TUint refId = 0; |
|
97 MenuUtils::GetTUint( val, refId ); |
|
98 CMenuItem* item = CMenuItem::OpenL( iMenu, refId ); |
|
99 CleanupStack::PushL( item ); |
|
100 CMenuOperation* op = item->HandleCommandL |
|
101 ( aCommand, aParams, aStatus ); // Not pushed, no leaving. |
|
102 CleanupStack::PopAndDestroy( item ); |
|
103 return op; |
|
104 } |
|
105 else |
|
106 { |
|
107 // "ref_id" missing from aItem. |
|
108 User::Leave( KErrCorrupt ); |
|
109 return NULL; |
|
110 } |
|
111 } |
|
112 else if ( aCommand == KMenuCmdRemove && aItem.Type() == KMenuTypeLink ) |
|
113 { |
|
114 return CMenuUninstallOperation::NewL |
|
115 ( iMenu, CActive::EPriorityStandard, aStatus, aItem ); |
|
116 } |
|
117 |
|
118 User::Leave ( KErrNotSupported ); |
|
119 return NULL; |
|
120 } |
|
121 |
|
122 // End of file |