|
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: cvimpstuimenuextension.h |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CVIMPSUIMENUEXTENSION_H |
|
19 #define CVIMPSUIMENUEXTENSION_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <e32const.h> |
|
24 #include "mcommandmapper.h" |
|
25 #include "cmenuextension.h" |
|
26 #include <mimpstuiaiwitemcontrol.h> |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CEikMenuPane; |
|
32 class CCommandInfo; |
|
33 |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * |
|
39 * This class provides extensions to options menu. |
|
40 * |
|
41 * @lib vimpstui.lib |
|
42 * @since S60 5.0 |
|
43 */ |
|
44 NONSHARABLE_CLASS( CVIMPSTUIMenuExtension ) : public CBase, |
|
45 public MCommandMapper, |
|
46 public MVIMPSTUiAIWControl |
|
47 { |
|
48 public: // Constructor and destructor |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * |
|
53 * @param aServiceName, service name. |
|
54 * @param aExtensionFactory, extension factory |
|
55 */ |
|
56 static CVIMPSTUIMenuExtension* NewL( ); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * |
|
61 * @param aServiceName, service name. |
|
62 * @param aExtensionFactory, extension factory |
|
63 */ |
|
64 static CVIMPSTUIMenuExtension* NewLC(); |
|
65 |
|
66 /** |
|
67 * Standard C++ destructor |
|
68 */ |
|
69 ~CVIMPSTUIMenuExtension(); |
|
70 public: // fomr MCommandMapper |
|
71 /** |
|
72 * Gets old original "Service Tab" command ID which corresponds |
|
73 * to the given new one |
|
74 * |
|
75 * @param aPluginId implementation ID for identification |
|
76 * @param aNewCommand New mapped command ID |
|
77 * @param aOldCommand On return old/original command ID |
|
78 * @return KErrNone if mapping exist, otherwise KErrNotFound |
|
79 */ |
|
80 TInt GetOldCommand( TInt32 aPluginId, TInt aNewCommand, |
|
81 TInt& aOldCommand ) const; |
|
82 |
|
83 /** |
|
84 * Gets new mapped "ServiceTab" command ID which corresponds |
|
85 * to the given old one |
|
86 * |
|
87 * @param aPluginId implementation ID for identification |
|
88 * @param aOldCommand Old/original command ID |
|
89 * @param aNewCommand On return new mapped command ID |
|
90 * @return KErrNone if mapping exist, otherwise KErrNotFound |
|
91 */ |
|
92 TInt GetNewCommand( TInt32 aPluginId,TInt aOldCommand, |
|
93 TInt& aNewCommand ) const; |
|
94 public: |
|
95 /** |
|
96 * offers the menu pane of the servicetab view connected to this |
|
97 * extension. |
|
98 * |
|
99 * @param aPreviousId Menu command id after which the plugins menu |
|
100 * should come. |
|
101 * @param aMenuPane Menu pane which will be filtered. |
|
102 * @param aServiceid service id |
|
103 */ |
|
104 void OfferMenuPaneToPlugins |
|
105 (TInt aPreviousId, CEikMenuPane& aMenuPane,TUint aServiceId); |
|
106 |
|
107 /** |
|
108 * Handles servicetab extension commands. |
|
109 * |
|
110 * @param aCommandId Command ID. |
|
111 * |
|
112 * @return ETrue if command was handled, otherwise EFalse. |
|
113 */ |
|
114 TBool OfferHandleCommandToPlugins(TInt aCommandId); |
|
115 |
|
116 /** |
|
117 * Loads all the plugins |
|
118 */ |
|
119 void LoadPluginL( ); |
|
120 |
|
121 /** |
|
122 * Map the plugin command to servicetab command |
|
123 */ |
|
124 void MapCommandL(CMenuExtension& aMenuExtension, TInt32 aPluginId); |
|
125 |
|
126 /** |
|
127 * Add the entry to the map table |
|
128 */ |
|
129 void AddToAIWCommandMap(TInt aOriginalCommand, TInt aNewCommand); |
|
130 |
|
131 /** |
|
132 * Finds the entry from the map table |
|
133 */ |
|
134 TInt GetNewAIWCommand(TInt aOriginalCommand); |
|
135 |
|
136 /** |
|
137 * Resets the AIW Command Map |
|
138 */ |
|
139 void ResetAIWCommandMap(); |
|
140 |
|
141 public: //from interface - MVIMPSTUiAIWControl |
|
142 |
|
143 /** |
|
144 * called by plugins to hide/unhide the AIW menu item |
|
145 */ |
|
146 void SetAIWItemDimmed(TInt aCommand, TBool aHide); |
|
147 |
|
148 private: // Implementation |
|
149 |
|
150 /** |
|
151 * Standard C++ constructor |
|
152 * @param aServiceName, service name. |
|
153 * @param aExtensionFactory, extension factory |
|
154 */ |
|
155 CVIMPSTUIMenuExtension( ); |
|
156 |
|
157 /** |
|
158 * Performs the 2nd phase of construction. |
|
159 */ |
|
160 void ConstructL(); |
|
161 private: |
|
162 /** |
|
163 * Internal class used as a wrapper around a plugin |
|
164 * and its uid. |
|
165 */ |
|
166 class CPluginInfo : public CBase |
|
167 { |
|
168 public: // Constructor & Destructor |
|
169 CPluginInfo( CMenuExtension* aPlugin, TUid aUid ); |
|
170 ~CPluginInfo(); |
|
171 |
|
172 public: // New functions |
|
173 CMenuExtension& Plugin(); |
|
174 private: // Data |
|
175 CMenuExtension* iPlugin; |
|
176 TUid iPluginUid; |
|
177 }; |
|
178 |
|
179 private: |
|
180 /** |
|
181 *Internal structure used as a item in the AIW command map table |
|
182 */ |
|
183 struct TAIWCommandMapTableItem |
|
184 { |
|
185 TInt iOriginalCmd; //is used as the primary key in the table |
|
186 TInt iNewCmd; //Mapped Command |
|
187 }; |
|
188 |
|
189 private: // Data |
|
190 |
|
191 // New commands pool |
|
192 TInt iNewCommands; |
|
193 |
|
194 // takes ownership of the plugins |
|
195 RPointerArray<CPluginInfo> iPlugins; |
|
196 |
|
197 // Array of command id mappings,Owned |
|
198 RPointerArray<CCommandInfo> iCommandIdMap; |
|
199 |
|
200 // AIW map table - keeps the ownership of the items |
|
201 RPointerArray<TAIWCommandMapTableItem> iAIWCommandMap; |
|
202 |
|
203 //doesnt owns |
|
204 CEikMenuPane* iMenuPane; |
|
205 |
|
206 }; |
|
207 |
|
208 #endif // C_CVIMPSTUIVIEWMANAGER_H |
|
209 |
|
210 // End of file |