38 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
39 // |
38 // |
40 CVIMPSTUIMenuExtension::CVIMPSTUIMenuExtension( ) |
39 CVIMPSTUIMenuExtension::CVIMPSTUIMenuExtension( ) |
41 : iNewCommands( EServiceTabMenuExtensionFirstFreeCommand ) |
40 : iNewCommands( EServiceTabMenuExtensionFirstFreeCommand ) |
42 { |
41 { |
43 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::CVIMPSTUIMenuExtension"); |
42 TRACER_AUTO; |
44 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::CVIMPSTUIMenuExtension"); |
|
45 } |
43 } |
46 |
44 |
47 // --------------------------------------------------------------------------- |
45 // --------------------------------------------------------------------------- |
48 // CVIMPSTUIMenuExtension::ConstructL |
46 // CVIMPSTUIMenuExtension::ConstructL |
49 // --------------------------------------------------------------------------- |
47 // --------------------------------------------------------------------------- |
50 // |
48 // |
51 void CVIMPSTUIMenuExtension::ConstructL() |
49 void CVIMPSTUIMenuExtension::ConstructL() |
52 { |
50 { |
53 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::ConstructL"); |
51 TRACER_AUTO; |
54 LoadPluginL( ); |
52 LoadPluginL( ); |
55 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::ConstructL"); |
53 |
56 |
54 |
57 } |
55 } |
58 |
56 |
59 // --------------------------------------------------------------------------- |
57 // --------------------------------------------------------------------------- |
60 // CVIMPSTUIMenuExtension::NewL |
58 // CVIMPSTUIMenuExtension::NewL |
61 // --------------------------------------------------------------------------- |
59 // --------------------------------------------------------------------------- |
62 // |
60 // |
63 CVIMPSTUIMenuExtension* CVIMPSTUIMenuExtension::NewL( ) |
61 CVIMPSTUIMenuExtension* CVIMPSTUIMenuExtension::NewL( ) |
64 { |
62 { |
65 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::NewL"); |
63 TRACER_AUTO; |
66 CVIMPSTUIMenuExtension* self = NewLC( ); |
64 CVIMPSTUIMenuExtension* self = NewLC( ); |
67 CleanupStack::Pop(self); |
65 CleanupStack::Pop(self); |
68 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::NewL"); |
66 |
69 return self; |
67 return self; |
70 } |
68 } |
71 |
69 |
72 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
73 // CVIMPSTUIMenuExtension::NewLC |
71 // CVIMPSTUIMenuExtension::NewLC |
74 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
75 // |
73 // |
76 CVIMPSTUIMenuExtension* CVIMPSTUIMenuExtension::NewLC() |
74 CVIMPSTUIMenuExtension* CVIMPSTUIMenuExtension::NewLC() |
77 { |
75 { |
78 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::NewL"); |
76 TRACER_AUTO; |
79 CVIMPSTUIMenuExtension* self = |
77 CVIMPSTUIMenuExtension* self = |
80 new (ELeave) CVIMPSTUIMenuExtension( ); |
78 new (ELeave) CVIMPSTUIMenuExtension( ); |
81 CleanupStack::PushL( self ); |
79 CleanupStack::PushL( self ); |
82 self->ConstructL(); |
80 self->ConstructL(); |
83 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::NewL"); |
81 |
84 return self; |
82 return self; |
85 } |
83 } |
86 |
84 |
87 // --------------------------------------------------------------------------- |
85 // --------------------------------------------------------------------------- |
88 // CVIMPSTUIMenuExtension::~CVIMPSTUIMenuExtension |
86 // CVIMPSTUIMenuExtension::~CVIMPSTUIMenuExtension |
89 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
90 // |
88 // |
91 CVIMPSTUIMenuExtension::~CVIMPSTUIMenuExtension() |
89 CVIMPSTUIMenuExtension::~CVIMPSTUIMenuExtension() |
92 { |
90 { |
93 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::~CVIMPSTUIMenuExtension"); |
91 TRACER_AUTO; |
94 iCommandIdMap.ResetAndDestroy(); |
92 iCommandIdMap.ResetAndDestroy(); |
95 //iCommandIdMap.Close(); |
93 //iCommandIdMap.Close(); |
96 // Reset and destroy the contents of the owned arrays, |
94 // Reset and destroy the contents of the owned arrays, |
97 // this will delete the plugins. |
95 // this will delete the plugins. |
98 iPlugins.ResetAndDestroy(); |
96 iPlugins.ResetAndDestroy(); |
100 |
98 |
101 iAIWCommandMap.ResetAndDestroy(); |
99 iAIWCommandMap.ResetAndDestroy(); |
102 |
100 |
103 // Close the ECOM interface |
101 // Close the ECOM interface |
104 REComSession::FinalClose(); |
102 REComSession::FinalClose(); |
105 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::~CVIMPSTUIMenuExtension"); |
103 |
106 } |
104 } |
107 |
105 |
108 // ---------------------------------------------------------------------------- |
106 // ---------------------------------------------------------------------------- |
109 // CVIMPSTUIMenuExtension::LoadPluginL |
107 // CVIMPSTUIMenuExtension::LoadPluginL |
110 // Loads all plugins |
108 // Loads all plugins |
111 // (other items were commented in a header). |
109 // (other items were commented in a header). |
112 // ---------------------------------------------------------------------------- |
110 // ---------------------------------------------------------------------------- |
113 // |
111 // |
114 void CVIMPSTUIMenuExtension::LoadPluginL( ) |
112 void CVIMPSTUIMenuExtension::LoadPluginL( ) |
115 { |
113 { |
116 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::LoadPluginL"); |
114 TRACER_AUTO; |
117 // plugininfo array, Owned |
115 // plugininfo array, Owned |
118 RImplInfoPtrArray pluginInfo; |
116 RImplInfoPtrArray pluginInfo; |
119 iPlugins.ResetAndDestroy(); |
117 iPlugins.ResetAndDestroy(); |
120 REComSession::ListImplementationsL( KMenuCustomisationInterfaceUid,pluginInfo ); |
118 REComSession::ListImplementationsL( KMenuCustomisationInterfaceUid,pluginInfo ); |
121 TInt pluginCount = pluginInfo.Count(); |
119 TInt pluginCount = pluginInfo.Count(); |
122 CHAT_DP( D_CHAT_LIT("CVIMPSTUIMenuExtension::LoadPluginL -->plugincount: %d" ),pluginCount ); |
120 TRACE("plugincount: %d" ,pluginCount ); |
123 |
121 |
124 for ( TInt pluginIndex(0); pluginIndex < pluginCount; ++pluginIndex ) |
122 for ( TInt pluginIndex(0); pluginIndex < pluginCount; ++pluginIndex ) |
125 { |
123 { |
126 CHAT_DP( D_CHAT_LIT("Inside for loop" ) ); |
124 TRACE("Inside for loop" ); |
127 TUid pluginUid = pluginInfo[pluginIndex]->ImplementationUid(); |
125 TUid pluginUid = pluginInfo[pluginIndex]->ImplementationUid(); |
128 CHAT_DP( D_CHAT_LIT("CVIMPSTUIMenuExtension::LoadPluginL -->ImplementationUid: %u" ),pluginUid.iUid ); |
126 TRACE("ImplementationUid: %u" ,pluginUid.iUid ); |
129 // Creates the plugin and transfers ownership of the services |
127 // Creates the plugin and transfers ownership of the services |
130 // object to the plugin. |
128 // object to the plugin. |
131 CMenuExtension* plugin = NULL; |
129 CMenuExtension* plugin = NULL; |
132 TRAPD(error, plugin = CMenuExtension::CreateImplementationL( pluginUid )); |
130 TRAPD(error, plugin = CMenuExtension::CreateImplementationL( pluginUid )); |
133 |
131 |
134 if(KErrNone != error) |
132 if(KErrNone != error) |
135 { |
133 { |
136 // handle the error here. |
134 // handle the error here. |
137 CHAT_DP( D_CHAT_LIT("error loading the plugin error: %d" ),error ); |
135 TRACE("error loading the plugin error: %d" ,error ); |
138 } |
136 } |
139 else |
137 else |
140 { |
138 { |
141 CHAT_DP( D_CHAT_LIT("plugin loaded sucessfully" ) ); |
139 TRACE("plugin loaded sucessfully" ); |
142 //if its here its sure that plugin is not null; |
140 //if its here its sure that plugin is not null; |
143 CleanupStack::PushL( plugin); |
141 CleanupStack::PushL( plugin); |
144 |
142 |
145 CHAT_DP( D_CHAT_LIT("before mapcommandl" ) ); |
143 TRACE("before mapcommandl" ); |
146 //map the plugin commands to servicetab commands, |
144 //map the plugin commands to servicetab commands, |
147 //assings the command maintained in the commandpool, |
145 //assings the command maintained in the commandpool, |
148 //for more details see |
146 //for more details see |
149 MapCommandL(*plugin,pluginUid.iUid); |
147 MapCommandL(*plugin,pluginUid.iUid); |
150 CHAT_DP( D_CHAT_LIT("after mapcommandl" ) ); |
148 TRACE("after mapcommandl" ); |
151 |
149 |
152 //add the plugin to the array |
150 //add the plugin to the array |
153 CPluginInfo* newPlugin = new ( ELeave ) CVIMPSTUIMenuExtension::CPluginInfo( plugin, pluginUid); |
151 CPluginInfo* newPlugin = new ( ELeave ) CVIMPSTUIMenuExtension::CPluginInfo( plugin, pluginUid); |
154 CleanupStack::PushL( newPlugin ); |
152 CleanupStack::PushL( newPlugin ); |
155 iPlugins.AppendL( newPlugin ); |
153 iPlugins.AppendL( newPlugin ); |
171 // Generates the list of active plugins |
169 // Generates the list of active plugins |
172 // ---------------------------------------------------------------------------- |
170 // ---------------------------------------------------------------------------- |
173 // |
171 // |
174 void CVIMPSTUIMenuExtension::OfferMenuPaneToPlugins(TInt aPreviousId, CEikMenuPane& aMenuPane,TUint aServiceId) |
172 void CVIMPSTUIMenuExtension::OfferMenuPaneToPlugins(TInt aPreviousId, CEikMenuPane& aMenuPane,TUint aServiceId) |
175 { |
173 { |
176 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::OfferMenuPaneToPlugins"); |
174 TRACER_AUTO; |
177 CHAT_DP( D_CHAT_LIT("CVIMPSTUIMenuExtension::OfferMenuPaneToPlugins --> aServiceId : %u" ), aServiceId ); |
175 TRACE(" aServiceId : %u" , aServiceId ); |
178 |
176 |
179 iMenuPane = &aMenuPane; |
177 iMenuPane = &aMenuPane; |
180 // Get the number of plugins |
178 // Get the number of plugins |
181 const TInt count = iPlugins.Count(); |
179 const TInt count = iPlugins.Count(); |
182 CHAT_DP( D_CHAT_LIT("CVIMPSTUIMenuExtension::OfferMenuPaneToPlugins --> count : %d" ), count ); |
180 TRACE(" count : %d" , count ); |
183 // Loop though all the command handlers, If DynInitMenuPaneL leaves for one plugin, a plugin |
181 // Loop though all the command handlers, If DynInitMenuPaneL leaves for one plugin, a plugin |
184 // error message will be displayed and the loop will continue with |
182 // error message will be displayed and the loop will continue with |
185 // the next command handler. If none of the plugins leave, there will |
183 // the next command handler. If none of the plugins leave, there will |
186 // be only one TRAP used. |
184 // be only one TRAP used. |
187 for ( TInt index = 0; index < count; ++index ) |
185 for ( TInt index = 0; index < count; ++index ) |
188 { |
186 { |
189 CHAT_DP( D_CHAT_LIT("inside for loop" ) ); |
187 TRACE("inside for loop" ); |
190 //trap is required if one plugin leaves then it should continue with other plugins. |
188 //trap is required if one plugin leaves then it should continue with other plugins. |
191 TRAPD(error,iPlugins[index]->Plugin().DynInitMenuPaneL( aPreviousId, |
189 TRAPD(error,iPlugins[index]->Plugin().DynInitMenuPaneL( aPreviousId, |
192 aMenuPane,aServiceId,*this )); |
190 aMenuPane,aServiceId,*this )); |
193 if(KErrNone != error) |
191 if(KErrNone != error) |
194 { |
192 { |
195 //display the appropriate error note for leaving; |
193 //display the appropriate error note for leaving; |
196 CHAT_DP( D_CHAT_LIT("error by one of plugind dyninitmenupanel" ) ); |
194 TRACE("error by one of plugind dyninitmenupanel" ); |
197 } |
195 } |
198 |
196 |
199 } |
197 } |
200 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::OfferMenuPaneToPlugins"); |
|
201 |
198 |
202 } |
199 } |
203 // ---------------------------------------------------------------------------- |
200 // ---------------------------------------------------------------------------- |
204 // CVIMPSTUIMenuExtension::OfferHandleCommandToPluginsL |
201 // CVIMPSTUIMenuExtension::OfferHandleCommandToPluginsL |
205 // Generates the list of active plugins |
202 // Generates the list of active plugins |
206 // ---------------------------------------------------------------------------- |
203 // ---------------------------------------------------------------------------- |
207 // |
204 // |
208 TBool CVIMPSTUIMenuExtension::OfferHandleCommandToPlugins(TInt aCommandId) |
205 TBool CVIMPSTUIMenuExtension::OfferHandleCommandToPlugins(TInt aCommandId) |
209 { |
206 { |
210 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::OfferHandleCommandToPlugins"); |
207 TRACER_AUTO; |
211 |
208 |
212 //Get the number of plugins loaded |
209 //Get the number of plugins loaded |
213 const TInt count = iPlugins.Count(); |
210 const TInt count = iPlugins.Count(); |
214 CHAT_DP( D_CHAT_LIT("CVIMPSTUIMenuExtension::OfferHandleCommandToPlugins -->count : %d" ),count ); |
211 TRACE("count : %d" ,count ); |
215 |
212 |
216 TBool retval = EFalse; |
213 TBool retval = EFalse; |
217 // Loop though all the command handlers, |
214 // Loop though all the command handlers, |
218 // If HandleCommandL leaves for one plugin, a plugin |
215 // If HandleCommandL leaves for one plugin, a plugin |
219 // error message will be displayed and the loop will continue with |
216 // error message will be displayed and the loop will continue with |
243 CMenuExtension* aPlugin, |
240 CMenuExtension* aPlugin, |
244 TUid aPluginUid ) |
241 TUid aPluginUid ) |
245 : iPlugin( aPlugin ), |
242 : iPlugin( aPlugin ), |
246 iPluginUid( aPluginUid ) |
243 iPluginUid( aPluginUid ) |
247 { |
244 { |
248 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::CPluginInfo::CPluginInfo"); |
245 TRACER_AUTO; |
249 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::CPluginInfo::CPluginInfo"); |
|
250 |
246 |
251 } |
247 } |
252 // ---------------------------------------------------------------------------- |
248 // ---------------------------------------------------------------------------- |
253 // CVIMPSTUIMenuExtension::CPluginInfo::~CPluginInfo( |
249 // CVIMPSTUIMenuExtension::CPluginInfo::~CPluginInfo( |
254 // C++ destructor |
250 // C++ destructor |
255 // (other items were commented in a header). |
251 // (other items were commented in a header). |
256 // ---------------------------------------------------------------------------- |
252 // ---------------------------------------------------------------------------- |
257 // |
253 // |
258 CVIMPSTUIMenuExtension::CPluginInfo::~CPluginInfo() |
254 CVIMPSTUIMenuExtension::CPluginInfo::~CPluginInfo() |
259 { |
255 { |
260 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::LoadPluginL"); |
256 TRACER_AUTO; |
261 delete iPlugin; |
257 delete iPlugin; |
262 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::LoadPluginL"); |
258 |
263 } |
259 } |
264 |
260 |
265 // ---------------------------------------------------------------------------- |
261 // ---------------------------------------------------------------------------- |
266 // CVIMPSTUIMenuExtension::CPluginInfo::Plugin |
262 // CVIMPSTUIMenuExtension::CPluginInfo::Plugin |
267 // returns a reference to the plugin |
263 // returns a reference to the plugin |
268 // (other items were commented in a header). |
264 // (other items were commented in a header). |
269 // ---------------------------------------------------------------------------- |
265 // ---------------------------------------------------------------------------- |
270 // |
266 // |
271 CMenuExtension& CVIMPSTUIMenuExtension::CPluginInfo::Plugin() |
267 CMenuExtension& CVIMPSTUIMenuExtension::CPluginInfo::Plugin() |
272 { |
268 { |
273 CHAT_DP_FUNC_ENTER("CVIMPSTUIMenuExtension::CPluginInfo::Plugin"); |
269 TRACER_AUTO; |
274 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::CPluginInfo::Plugin"); |
|
275 return *iPlugin; |
270 return *iPlugin; |
276 } |
271 } |
277 |
272 |
278 |
273 |
279 // ---------------------------------------------------------------------------- |
274 // ---------------------------------------------------------------------------- |
357 aNewCommand = info->NewCommandId(); |
352 aNewCommand = info->NewCommandId(); |
358 err = KErrNone; |
353 err = KErrNone; |
359 break; |
354 break; |
360 } |
355 } |
361 } |
356 } |
362 CHAT_DP_FUNC_DONE("CVIMPSTUIMenuExtension::GetNewCommand"); |
357 |
363 |
358 |
364 return err; |
359 return err; |
365 } |
360 } |
366 // ---------------------------------------------------------------------------- |
361 // ---------------------------------------------------------------------------- |
367 // CVIMPSTUIMenuExtension::AddToAIWCommandMap |
362 // CVIMPSTUIMenuExtension::AddToAIWCommandMap |
368 // ---------------------------------------------------------------------------- |
363 // ---------------------------------------------------------------------------- |
369 // |
364 // |
370 void CVIMPSTUIMenuExtension::AddToAIWCommandMap(TInt aOriginalCommand, TInt aNewCommand) |
365 void CVIMPSTUIMenuExtension::AddToAIWCommandMap(TInt aOriginalCommand, TInt aNewCommand) |
371 { |
366 { |
|
367 TRACER_AUTO; |
372 TAIWCommandMapTableItem *item = new TAIWCommandMapTableItem(); |
368 TAIWCommandMapTableItem *item = new TAIWCommandMapTableItem(); |
373 item->iOriginalCmd = aOriginalCommand; |
369 item->iOriginalCmd = aOriginalCommand; |
374 item->iNewCmd = aNewCommand; |
370 item->iNewCmd = aNewCommand; |
375 iAIWCommandMap.Append(item); |
371 iAIWCommandMap.Append(item); |
376 } |
372 } |