|
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: Container class to hold Runtime plugin and related data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2pluginholder.h" // CAppMngr2PluginHolder |
|
20 #include <appmngr2runtime.h> // CAppMngr2Runtime |
|
21 #include <appmngr2debugutils.h> // FLOG macros |
|
22 #include <AknIconArray.h> // CAknIconArray |
|
23 |
|
24 const TInt KIconGranularity = 8; |
|
25 const TInt KDataTypeGranularity = 8; |
|
26 |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CAppMngr2PluginHolder::CAppMngr2PluginHolder() |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CAppMngr2PluginHolder::CAppMngr2PluginHolder( CAppMngr2Runtime* aRuntime ) |
|
35 { |
|
36 iRuntime = aRuntime; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CAppMngr2PluginHolder::~CAppMngr2PluginHolder() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CAppMngr2PluginHolder::~CAppMngr2PluginHolder() |
|
44 { |
|
45 delete iRuntime; |
|
46 delete iDataTypes; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CAppMngr2PluginHolder:: |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CAppMngr2Runtime& CAppMngr2PluginHolder::Runtime() |
|
54 { |
|
55 return *iRuntime; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CAppMngr2PluginHolder:: |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CDataTypeArray& CAppMngr2PluginHolder::DataTypes() |
|
63 { |
|
64 return *iDataTypes; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CAppMngr2PluginHolder:: |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CAppMngr2PluginHolder::LoadIconsL( CAknIconArray& aIconArray ) |
|
72 { |
|
73 CAknIconArray* iconArray = new ( ELeave ) CAknIconArray( KIconGranularity ); |
|
74 CleanupStack::PushL( iconArray ); |
|
75 |
|
76 // Use temporary array to load icons from plugin. This prevents |
|
77 // plugin from messing icons that other plugins have loaded. |
|
78 TRAP_IGNORE( iRuntime->LoadIconsL( *iconArray ) ); |
|
79 iIconIndexBase = aIconArray.Count(); |
|
80 iIconCount = iconArray->Count(); |
|
81 |
|
82 // Insert icons in reverse order so that they can be removed |
|
83 // from the iconArray while inserting in aIconArray. Icons must |
|
84 // be inserted in the right position to maintain icon indexes |
|
85 // (the same icon order as in iconArray). |
|
86 TInt insertPosition = iIconIndexBase; |
|
87 for( TInt index = iIconCount - 1; index >= 0; index-- ) |
|
88 { |
|
89 // copies CGulIcon from iconArray to aIconArray |
|
90 aIconArray.InsertL( insertPosition, iconArray->At( index ) ); |
|
91 iconArray->Delete( index ); |
|
92 } |
|
93 CleanupStack::PopAndDestroy( iconArray ); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CAppMngr2PluginHolder:: |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void CAppMngr2PluginHolder::FetchDataTypesL() |
|
101 { |
|
102 if( iDataTypes ) |
|
103 { |
|
104 delete iDataTypes; |
|
105 iDataTypes = NULL; |
|
106 } |
|
107 iDataTypes = new (ELeave) CDataTypeArray( KDataTypeGranularity ); |
|
108 iRuntime->GetSupportedDataTypesL( *iDataTypes ); |
|
109 FLOG( "CAppMngr2PluginHolder::FetchDataTypesL: iDataTypes->Count() = %d", |
|
110 iDataTypes->Count() ); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CAppMngr2PluginHolder:: |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CAppMngr2PluginHolder::IconIndexBase() |
|
118 { |
|
119 return iIconIndexBase; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CAppMngr2PluginHolder:: |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 TInt CAppMngr2PluginHolder::IconIndexMax() |
|
127 { |
|
128 return iIconIndexBase + iIconCount; |
|
129 } |