1 /* |
|
2 * Copyright (c) 2005-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: PslnGSPlugin implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // GS Framework and this plugin. |
|
20 #include "PslnGSPlugin.h" |
|
21 #ifdef RD_CONTROL_PANEL |
|
22 #include <pslngsplugin.mbg> |
|
23 #endif // RD_CONTROL_PANEL |
|
24 #include <gsparentplugin.h> |
|
25 #include <gscommon.hrh> |
|
26 #include <pslngspluginrsc.rsg> |
|
27 #include <gsprivatepluginproviderids.h> |
|
28 #include <gsfwviewuids.h> |
|
29 |
|
30 // General services. |
|
31 #include <AknNullService.h> |
|
32 #include <bautils.h> |
|
33 #include <StringLoader.h> |
|
34 #include <AknsUtils.h> |
|
35 |
|
36 // Themes application UID. |
|
37 const TUid KPslnThemesAppUid = { 0x10005A32 }; |
|
38 |
|
39 // This application's resource file. |
|
40 _LIT( KPslnGSPluginResourceFileName, "z:pslngspluginrsc.rsc" ); |
|
41 |
|
42 #ifdef RD_CONTROL_PANEL |
|
43 #ifdef __SCALABLE_ICONS |
|
44 // bitmap |
|
45 _LIT( KPslnGSPluginIconFileName, "\\resource\\apps\\pslngsplugin.mif"); |
|
46 #else //__SCALABLE_ICONS |
|
47 // svg file |
|
48 _LIT( KPslnGSPluginIconFileName, "\\resource\\apps\\pslngsplugin.mbm"); |
|
49 #endif //__SCALABLE_ICONS |
|
50 #endif // RD_CONTROL_PANEL |
|
51 |
|
52 |
|
53 // ========================= MEMBER FUNCTIONS ================================ |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Constructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CPslnGSPlugin::CPslnGSPlugin() : iResources( *iCoeEnv ), iNullService( NULL ) |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Destructor |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CPslnGSPlugin::~CPslnGSPlugin() |
|
68 { |
|
69 iResources.Close(); |
|
70 |
|
71 if ( iNullService ) |
|
72 { |
|
73 delete iNullService; |
|
74 } |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Symbian OS two-phased constructor |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CPslnGSPlugin::ConstructL() |
|
82 { |
|
83 BaseConstructL(); |
|
84 |
|
85 OpenLocalizedResourceFileL( KPslnGSPluginResourceFileName, iResources ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // Static constructor |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 CPslnGSPlugin* CPslnGSPlugin::NewL( TAny* /*aInitParams*/ ) |
|
93 { |
|
94 CPslnGSPlugin* self = new( ELeave ) CPslnGSPlugin(); |
|
95 CleanupStack::PushL( self ); |
|
96 self->ConstructL(); |
|
97 CleanupStack::Pop( self ); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CPslnGSPlugin::Id |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TUid CPslnGSPlugin::Id() const |
|
106 { |
|
107 return KPslnGSPluginUID; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CPslnGSPlugin::DoActivateL |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CPslnGSPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
115 TUid /*aCustomMessageId*/, |
|
116 const TDesC8& /*aCustomMessage*/ ) |
|
117 { |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CPslnGSPlugin::DoDeactivate |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CPslnGSPlugin::DoDeactivate() |
|
125 { |
|
126 } |
|
127 |
|
128 // ========================= From CGSPluginInterface ================== |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CPslnGSPlugin::GetCaptionL |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CPslnGSPlugin::GetCaptionL( TDes& aCaption ) const |
|
134 { |
|
135 HBufC* result = StringLoader::LoadL( R_PSLN_GS_PLUGIN_CAPTION ); |
|
136 aCaption.Copy( *result ); |
|
137 delete result; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CPslnGSPlugin::PluginProviderCategory |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 TInt CPslnGSPlugin::PluginProviderCategory() const |
|
145 { |
|
146 return KGSPluginProviderInternal; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CPslnGSPlugin::ItemType() |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 TGSListboxItemTypes CPslnGSPlugin::ItemType() |
|
154 { |
|
155 return EGSItemTypeSettingDialog; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CPslnGSPlugin::GetValue() |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CPslnGSPlugin::GetValue( const TGSPluginValueKeys /*aKey*/, |
|
163 TDes& /*aValue*/ ) |
|
164 { |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CPslnGSPlugin::HandleSelection() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CPslnGSPlugin::HandleSelection( |
|
172 const TGSSelectionTypes /*aSelectionType*/ ) |
|
173 { |
|
174 TRAP_IGNORE( LaunchThemesAppL() ); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CPslnGSPlugin::CreateIconL() |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 CGulIcon* CPslnGSPlugin::CreateIconL( const TUid aIconType ) |
|
182 { |
|
183 CGulIcon* icon; |
|
184 #ifdef RD_CONTROL_PANEL |
|
185 if( aIconType == KGSIconTypeLbxItem ) |
|
186 { |
|
187 icon = AknsUtils::CreateGulIconL( |
|
188 AknsUtils::SkinInstance(), |
|
189 KAknsIIDQgnPropCpPersoTheme, |
|
190 KPslnGSPluginIconFileName, |
|
191 EMbmPslngspluginQgn_prop_cp_perso_theme, |
|
192 EMbmPslngspluginQgn_prop_cp_perso_theme_mask ); |
|
193 } |
|
194 else |
|
195 { |
|
196 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
197 } |
|
198 #else |
|
199 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
200 #endif // RD_CONTROL_PANEL |
|
201 return icon; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CPslnGSPlugin::OpenLocalizedResourceFileL() |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CPslnGSPlugin::OpenLocalizedResourceFileL( |
|
209 const TDesC& aResourceFileName, |
|
210 RConeResourceLoader& aResourceLoader ) |
|
211 { |
|
212 // Find the resource file: |
|
213 TParse* parse = new (ELeave) TParse; |
|
214 CleanupStack::PushL( parse ); |
|
215 parse->Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
216 TFileName* fileName = new (ELeave) TFileName( parse->FullName() ); |
|
217 CleanupStack::PushL( fileName ); |
|
218 |
|
219 // Open resource file: |
|
220 aResourceLoader.OpenL( *fileName ); |
|
221 CleanupStack::PopAndDestroy( 2, parse ); // fileName, parse |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CPslnGSPlugin::LaunchThemesAppL() |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CPslnGSPlugin::LaunchThemesAppL() |
|
229 { |
|
230 // Get the correct application data |
|
231 RWsSession ws; |
|
232 User::LeaveIfError( ws.Connect() ); |
|
233 CleanupClosePushL( ws ); |
|
234 |
|
235 // Find the task with uid |
|
236 TApaTaskList taskList(ws); |
|
237 TApaTask task = taskList.FindApp( KPslnThemesAppUid ); |
|
238 |
|
239 if ( task.Exists() ) |
|
240 { |
|
241 task.BringToForeground(); |
|
242 } |
|
243 else |
|
244 { |
|
245 // Launch themes application as embedded. |
|
246 if ( iNullService ) |
|
247 { |
|
248 delete iNullService; |
|
249 iNullService = NULL; |
|
250 } |
|
251 iNullService = CAknNullService::NewL( KPslnThemesAppUid, this ); |
|
252 } |
|
253 CleanupStack::PopAndDestroy(); // ws |
|
254 } |
|
255 |
|
256 // End of file |
|