1 /* |
|
2 * Copyright (c) 2007 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: Active Palette Items* |
|
15 */ |
|
16 |
|
17 |
|
18 /** |
|
19 * @file ActivePalette2Item.cpp |
|
20 * Active Palette Items |
|
21 */ |
|
22 |
|
23 // DEFINITIONS |
|
24 #define ACTIVEPALETTE_SUPPORT_PLUGIN_CAM |
|
25 |
|
26 // INCLUDE FILES |
|
27 #include <activepalette2genericpluginint.h> |
|
28 |
|
29 #include "ActivePalette2Item.h" |
|
30 #include "ActivePalette2Model.h" |
|
31 #include "ActivePalette2Logger.h" |
|
32 #include "ActivePalette2Cfg.h" |
|
33 #include "ActivePalette2GenericPlugin.h" |
|
34 #include "CActivePalettePluginBase.h" |
|
35 |
|
36 #include <gulicon.h> |
|
37 #include <fbs.h> |
|
38 #include <bitstd.h> |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CActivePalette2IDHolder::CActivePalette2IDHolder() |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CActivePalette2IDHolder::CActivePalette2IDHolder() |
|
48 { |
|
49 // no implementation required |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CActivePalette2IDHolder::CActivePalette2IDHolder() |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CActivePalette2IDHolder::CActivePalette2IDHolder(TInt aItemId) |
|
57 : iItemId(aItemId) |
|
58 { |
|
59 // no implementation required |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CActivePalette2IDHolder::SetItemId() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CActivePalette2IDHolder::SetItemId(TInt aItemId) |
|
67 { |
|
68 iItemId = aItemId; |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CActivePalette2Item::NewLC() |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CActivePalette2Item * CActivePalette2Item::NewLC(TInt aItemId, |
|
77 const TUid& aPluginUid, |
|
78 CActivePalette2Model& aModel) |
|
79 { |
|
80 CActivePalette2Item * self = new (ELeave) CActivePalette2Item( |
|
81 aItemId, aPluginUid, aModel |
|
82 ); |
|
83 CleanupStack::PushL(self); |
|
84 self->ConstructL(); |
|
85 return self; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CActivePalette2Item::CActivePalette2Item() |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CActivePalette2Item::CActivePalette2Item( |
|
93 TInt aItemId, |
|
94 const TUid& aPluginUid, |
|
95 CActivePalette2Model& aModel |
|
96 ) |
|
97 : CActivePalette2IDHolder(aItemId), |
|
98 iPluginUid(aPluginUid), |
|
99 iModel(aModel) |
|
100 { |
|
101 LOGTEXT( _L( "CActivePalette2Item::CActivePalette2Item" )); |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CActivePalette2Item::ConstructL() |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CActivePalette2Item::ConstructL(void) |
|
110 { |
|
111 NActivePalettePluginFactory::TInstantiatePluginLFunc |
|
112 instantiatePluginL = FindPluginFactoryL(iPluginUid); |
|
113 |
|
114 // instantiate plugin |
|
115 CActivePalettePluginBase* pluginObj = instantiatePluginL(iPluginUid, GetPluginCreationParams()); |
|
116 if (NULL == iPlugin || pluginObj != iPlugin) |
|
117 { |
|
118 // illegal plugin, plugin was supposed to callback via NotifyPluginCreated() |
|
119 User::Leave(KErrGeneral); |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CActivePalette2Item::~CActivePalette2Item() |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 CActivePalette2Item::~CActivePalette2Item() |
|
128 { |
|
129 LOGTEXT1( _L( "CActivePalette2Item::~CActivePalette2Item entered, item ID : %d" ), ItemId()); |
|
130 |
|
131 if (iPlugin) |
|
132 { |
|
133 LOGTEXT( _L( "... calling plugin's shutdown" ) ); |
|
134 iPlugin->Shutdown(); |
|
135 LOGTEXT( _L( "... plugin's shutdown returned" ) ); |
|
136 } |
|
137 LOGTEXT( _L( "... deleting plugin's object" ) ); |
|
138 CBase::Delete(iPlugin); |
|
139 LOGTEXT( _L( "... plugin's object deleted" ) ); |
|
140 iPlugin = NULL; |
|
141 |
|
142 if (iOwnsIcon) |
|
143 { |
|
144 delete iIcon; |
|
145 } |
|
146 iIcon = NULL; |
|
147 |
|
148 delete iTooltip; |
|
149 iTooltip = NULL; |
|
150 |
|
151 iDLL.Close(); |
|
152 |
|
153 LOGTEXT( _L( "CActivePalette2Item::~CActivePalette2Item left" ) ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CActivePalette2Item::FindPluginFactoryL() |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 NActivePalettePluginFactory::TInstantiatePluginLFunc CActivePalette2Item::FindPluginFactoryL(const TUid aUid) |
|
161 { |
|
162 LOGTEXT1( _L( "CActivePalette2Item::FindPluginFactoryL entered, Uid : %d" ), |
|
163 aUid.iUid); |
|
164 |
|
165 NActivePalettePluginFactory::TInstantiatePluginLFunc factory = NULL; |
|
166 |
|
167 if (aUid == TUid::Uid(KActivePalette2GenericPluginUID)) |
|
168 { |
|
169 factory = &InstantiateGenericPluginL; |
|
170 } |
|
171 else |
|
172 { |
|
173 // lookup DLL file name |
|
174 TFileName dllFileName; |
|
175 TBool dllNameAssigned = EFalse; |
|
176 // todo: implement lookup in plugin table |
|
177 |
|
178 if (TUid::Uid(KPrintPluginUid) == aUid) |
|
179 { |
|
180 dllFileName = KPrintPluginDLLName; |
|
181 dllNameAssigned = ETrue; |
|
182 } |
|
183 else if (TUid::Uid(KPrintIntentPluginUid) == aUid) |
|
184 { |
|
185 dllFileName = KPrintIntentPluginDLLName; |
|
186 dllNameAssigned = ETrue; |
|
187 } |
|
188 else if( TUid::Uid( KOnlineSharingPluginUid ) == aUid ) |
|
189 { |
|
190 dllFileName = KOnlineSharingPluginDLLName; |
|
191 dllNameAssigned = ETrue; |
|
192 } |
|
193 #ifdef ACTIVEPALETTE_SUPPORT_PLUGIN_CAM |
|
194 else if (TUid::Uid( KCamAPPluginUid ) == aUid) |
|
195 { |
|
196 dllFileName = KCamAPluginDLLName; |
|
197 dllNameAssigned = ETrue; |
|
198 } |
|
199 else |
|
200 { |
|
201 // lint |
|
202 } |
|
203 #endif // ACTIVEPALETTE_SUPPORT_PLUGIN_CAM |
|
204 |
|
205 LOGTEXT1( _L( "... DLL file name found?: %d" ), dllNameAssigned); |
|
206 if (EFalse == dllNameAssigned) |
|
207 { |
|
208 User::Leave(KErrNotSupported); |
|
209 } |
|
210 |
|
211 // load plug-in DLL |
|
212 LOGTEXT( _L( "... loading DLL" )); |
|
213 User::LeaveIfError(iDLL.Load(dllFileName)); |
|
214 |
|
215 // get factory function |
|
216 LOGTEXT( _L( "... factory entry point lookup" )); |
|
217 factory = (NActivePalettePluginFactory::TInstantiatePluginLFunc) |
|
218 iDLL.Lookup(NActivePalettePluginFactory::KFactoryEntryOrdinal); |
|
219 |
|
220 if(!factory) |
|
221 { |
|
222 User::Leave(KErrGeneral); |
|
223 } |
|
224 } |
|
225 |
|
226 LOGTEXT1( _L( "CActivePalette2Item::FindPluginFactoryL left, factory : %p" ), |
|
227 factory); |
|
228 |
|
229 return factory; |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CActivePalette2Item::GetPluginCreationParams() |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 NActivePalettePluginFactory::TPluginCreationParams CActivePalette2Item::GetPluginCreationParams(void) |
|
237 { |
|
238 return NActivePalettePluginFactory::TPluginCreationParams( |
|
239 *this, |
|
240 iModel.ItemSize()); |
|
241 } |
|
242 |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CActivePalette2Item::NotifyPluginCreated() |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CActivePalette2Item::NotifyPluginCreated(CActivePalettePluginBase* aPlugin) |
|
249 { |
|
250 iPlugin = aPlugin; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CActivePalette2Item::NotifyPluginDestroyed() |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void CActivePalette2Item::NotifyPluginDestroyed(CActivePalettePluginBase* aPlugin) |
|
258 { |
|
259 if (iPlugin == aPlugin) |
|
260 { |
|
261 iPlugin = NULL; |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CActivePalette2Item::PluginUid() |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 TUid CActivePalette2Item::PluginUid(void) const |
|
270 { |
|
271 return iPluginUid; |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CActivePalette2Item::DoSetItemIcon() |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CActivePalette2Item::DoSetItemIcon(CGulIcon* aIcon, TBool aOnwershipTransfer) |
|
279 { |
|
280 if (iOwnsIcon) |
|
281 { |
|
282 delete iIcon; |
|
283 iIcon = NULL; |
|
284 } |
|
285 |
|
286 iIcon = aIcon; |
|
287 iOwnsIcon = aOnwershipTransfer; |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CActivePalette2Item::SetItemIcon() |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 void CActivePalette2Item::SetItemIcon(CGulIcon* aIcon, TBool aOnwershipTransfer) |
|
295 { |
|
296 DoSetItemIcon(aIcon,aOnwershipTransfer); |
|
297 // notify UI |
|
298 iModel.NotifyGraphicsChanged(*this,ETrue,EFalse); |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CActivePalette2Item::SetItemTooltipL() |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 void CActivePalette2Item::SetItemTooltipL(const TDesC& aTooltipText) |
|
306 { |
|
307 // delete old |
|
308 delete iTooltip; |
|
309 iTooltip = NULL; |
|
310 |
|
311 // copy text |
|
312 iTooltip = aTooltipText.AllocL(); |
|
313 // notify UI |
|
314 iModel.NotifyGraphicsChanged(*this,EFalse,ETrue); |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CActivePalette2Item::SetItemIconAndTooltipL() |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CActivePalette2Item::SetItemIconAndTooltipL( |
|
322 CGulIcon* aIcon, |
|
323 TBool aOnwershipTransfer, |
|
324 const TDesC & aTooltipText |
|
325 ) |
|
326 { |
|
327 // delete old |
|
328 delete iTooltip; |
|
329 iTooltip = NULL; |
|
330 |
|
331 // copy icon and tooltip |
|
332 DoSetItemIcon(aIcon, aOnwershipTransfer); |
|
333 iTooltip = aTooltipText.AllocL(); |
|
334 |
|
335 |
|
336 // notify UI |
|
337 iModel.NotifyGraphicsChanged(*this,ETrue,ETrue); |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CActivePalette2Item::NotifyItemComplete() |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 void CActivePalette2Item::NotifyItemComplete(const TDesC8& aDataDes) |
|
345 { |
|
346 // notify model' user |
|
347 iModel.NotifyItemComplete(*this, KErrNone, aDataDes, KActivePaletteNoDataInt); |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CActivePalette2Item::NotifyItemComplete() |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 void CActivePalette2Item::NotifyItemComplete(TInt aDataInt) |
|
355 { |
|
356 // notify model' user |
|
357 iModel.NotifyItemComplete(*this, KErrNone, KNullDesC8, aDataInt); |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CActivePalette2Item::SendMessage() |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CActivePalette2Item::SendMessage(TInt aMessageID, const TDesC8& aDataDes) |
|
365 { |
|
366 // notify model' user |
|
367 iModel.NotifyMessage(*this, KErrNone, aMessageID, aDataDes, KActivePaletteNoDataInt); |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CActivePalette2Item::SendMessage() |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 void CActivePalette2Item::SendMessage(TInt aMessageID, TInt aDataInt) |
|
375 { |
|
376 // notify model' user |
|
377 iModel.NotifyMessage(*this, KErrNone, aMessageID, KNullDesC8, aDataInt); |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CActivePalette2Item::Icon() |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 CFbsBitmap & CActivePalette2Item::Icon(void) const |
|
385 { // icon is always valid |
|
386 return *iIcon->Bitmap(); |
|
387 } |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // CActivePalette2Item::Mask() |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 CFbsBitmap * CActivePalette2Item::Mask(void) const |
|
394 { |
|
395 return (NULL == iIcon) ? NULL : iIcon->Mask(); |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CActivePalette2Item::Tooltip() |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 HBufC* CActivePalette2Item::Tooltip(void) const |
|
403 { |
|
404 return iTooltip; |
|
405 } |
|
406 |
|
407 |
|
408 // ----------------------------------------------------------------------------- |
|
409 // CActivePalette2Item::InitPluginL() |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 void CActivePalette2Item::InitPluginL(const TDesC8& aCustomDataDes, TInt aCustomDataInt) |
|
413 { |
|
414 // do construct |
|
415 iPlugin->ConstructL(GetPluginCreationParams(),aCustomDataDes,aCustomDataInt); |
|
416 // validate icon |
|
417 if (NULL == iIcon || NULL == iIcon->Bitmap()) |
|
418 { |
|
419 User::Leave(KErrGeneral); // plugin MUST produce an icon during its ConstructL() |
|
420 } |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CActivePalette2Item::Plugin() |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 CActivePalettePluginBase& CActivePalette2Item::Plugin(void) const |
|
428 { |
|
429 return *iPlugin; |
|
430 } |
|
431 |
|
432 |
|
433 // End of File |
|