|
1 /* |
|
2 * Copyright (c) 2007-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: General Settings plug-in that launches an embedded |
|
15 * application. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "gsdevdiagplugin.h" |
|
22 #include "gsdevdiagplugin.hrh" |
|
23 |
|
24 #include <GSDevDiagPlugin.mbg> // Icons |
|
25 #include <gsdevdiagpluginrsc.rsg> |
|
26 #include <gsprivatepluginproviderids.h> |
|
27 |
|
28 #include <StringLoader.h> |
|
29 #include <bautils.h> |
|
30 #include <AknNullService.h> |
|
31 |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 |
|
34 // EXTERNAL FUNCTION PROTOTYPES |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 // MACROS |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 //const TInt KGSAutodTimeIndex = 0; |
|
42 |
|
43 _LIT( KGSDDPluginResourceFileName, "z:GSDevDiagPluginRsc.rsc" ); |
|
44 |
|
45 // MODULE DATA STRUCTURES |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 |
|
51 // ============================= LOCAL FUNCTIONS ============================== |
|
52 |
|
53 // ========================= MEMBER FUNCTIONS ================================ |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CGSDevDiagPlugin::CGSDevDiagPlugin() |
|
57 // |
|
58 // Constructor |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 CGSDevDiagPlugin::CGSDevDiagPlugin(): iResourceLoader( *iCoeEnv ), |
|
62 iNullService(NULL) |
|
63 { |
|
64 } |
|
65 |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CGSDevDiagPlugin::NewL() |
|
69 // |
|
70 // Symbian OS default constructor |
|
71 // --------------------------------------------------------------------------- |
|
72 CGSDevDiagPlugin* CGSDevDiagPlugin::NewL( TAny* /*aInitParams*/ ) |
|
73 { |
|
74 CGSDevDiagPlugin* self = new( ELeave ) CGSDevDiagPlugin (); |
|
75 |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop(); |
|
79 |
|
80 return self; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CGSDevDiagPlugin::ConstructL() |
|
85 // |
|
86 // Symbian OS two-phased constructor |
|
87 // --------------------------------------------------------------------------- |
|
88 void CGSDevDiagPlugin::ConstructL() |
|
89 { |
|
90 OpenLocalizedResourceFileL( KGSDDPluginResourceFileName, iResourceLoader); |
|
91 } |
|
92 |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CGSDevDiagPlugin::~CGSDevDiagPlugin |
|
96 // |
|
97 // Destructor |
|
98 // ---------------------------------------------------------------------------- |
|
99 CGSDevDiagPlugin::~CGSDevDiagPlugin() |
|
100 { |
|
101 iResourceLoader.Close(); |
|
102 |
|
103 if ( iNullService ) |
|
104 { |
|
105 delete iNullService; |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // TUid CGSDevDiagPlugin::Id() |
|
112 // |
|
113 // Returns view's ID. |
|
114 // --------------------------------------------------------------------------- |
|
115 TUid CGSDevDiagPlugin::Id() const |
|
116 { |
|
117 return KGSDDPluginUid; |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // CGSDevDiagPlugin::GetCaption |
|
122 // |
|
123 // Return application/view caption. |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 void CGSDevDiagPlugin::GetCaptionL( TDes& aCaption ) const |
|
127 { |
|
128 // the resource file is already opened. |
|
129 HBufC* result = StringLoader::LoadL( R_GS_DIAGNOSTICS_VIEW_CAPTION ); |
|
130 |
|
131 aCaption.Copy( *result ); |
|
132 delete result; |
|
133 } |
|
134 |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CGSDevDiagPlugin::PluginProviderCategory |
|
138 // |
|
139 // A means to identify the location of this plug-in in the framework. |
|
140 // ---------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CGSDevDiagPlugin::PluginProviderCategory() const |
|
143 { |
|
144 //To identify internal plug-ins. |
|
145 return KGSPluginProviderInternal; |
|
146 } |
|
147 |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CGSDevDiagPlugin::ItemType (from CGSPluginInterface) |
|
151 // |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 TGSListboxItemTypes CGSDevDiagPlugin::ItemType() |
|
155 { |
|
156 return EGSItemTypeSettingDialog; |
|
157 } |
|
158 |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CGSDevDiagPlugin::GetValue (from CGSPluginInterface) |
|
162 // |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CGSDevDiagPlugin::GetValue( const TGSPluginValueKeys /*aKey*/, |
|
166 TDes& /*aValue*/ ) |
|
167 { |
|
168 } |
|
169 // --------------------------------------------------------------------------- |
|
170 // CAuthtypePlugin::CreateIconL |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 CGulIcon* CGSDevDiagPlugin::CreateIconL( const TUid aIconType ) |
|
174 { |
|
175 |
|
176 //EMbm<Mbm_file_name><Bitmap_name> |
|
177 CGulIcon* icon; |
|
178 TParse* fp = new( ELeave ) TParse(); |
|
179 CleanupStack::PushL( fp ); |
|
180 fp->Set( KGSDDPluginIconDirAndName, &KDC_BITMAP_DIR, NULL ); |
|
181 |
|
182 if ( aIconType == KGSIconTypeLbxItem ) |
|
183 { |
|
184 icon = AknsUtils::CreateGulIconL( |
|
185 AknsUtils::SkinInstance(), |
|
186 KAknsIIDDefault, |
|
187 fp->FullName(), |
|
188 EMbmGsdevdiagpluginQgn_prop_set_conn_data, |
|
189 EMbmGsdevdiagpluginQgn_prop_set_conn_data_mask ); |
|
190 } |
|
191 else |
|
192 { |
|
193 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
194 } |
|
195 |
|
196 CleanupStack::PopAndDestroy( fp ); |
|
197 return icon; |
|
198 |
|
199 } |
|
200 |
|
201 // ---------------------------------------------------------------------------- |
|
202 // CGSDevDiagPlugin::DoActivateL |
|
203 // |
|
204 // Do nothing. See HandleSelection. |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 void CGSDevDiagPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
208 TUid /*aCustomMessageId*/, |
|
209 const TDesC8& /*aCustomMessage*/ ) |
|
210 { |
|
211 } |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // CGSDevDiagPlugin::DoDeactivate |
|
215 // |
|
216 // Do nothing. See HandleSelection. |
|
217 // ---------------------------------------------------------------------------- |
|
218 // |
|
219 void CGSDevDiagPlugin::DoDeactivate() |
|
220 { |
|
221 } |
|
222 |
|
223 |
|
224 // ---------------------------------------------------------------------------- |
|
225 // Opens the resource file, because it is not loaded automatically by the |
|
226 // GS framework. |
|
227 // ---------------------------------------------------------------------------- |
|
228 // |
|
229 void CGSDevDiagPlugin::OpenLocalizedResourceFileL( |
|
230 const TDesC& aResourceFileName, |
|
231 RConeResourceLoader& aResourceLoader ) |
|
232 { |
|
233 RFs fsSession; |
|
234 User::LeaveIfError( fsSession.Connect() ); |
|
235 |
|
236 // Find the resource file: |
|
237 TParse parse; |
|
238 parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
239 TFileName fileName( parse.FullName() ); |
|
240 |
|
241 // Get language of resource file: |
|
242 BaflUtils::NearestLanguageFile( fsSession, fileName ); |
|
243 |
|
244 // Open resource file: |
|
245 aResourceLoader.OpenL( fileName ); |
|
246 |
|
247 // If leave occurs before this, close is called automatically when the |
|
248 // thread exits. |
|
249 fsSession.Close(); |
|
250 } |
|
251 |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // GS calls this function when plug-in is opened. |
|
255 // |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CGSDevDiagPlugin::HandleSelection( |
|
259 const TGSSelectionTypes /*aSelectionType*/ ) |
|
260 { |
|
261 TRAP_IGNORE( LaunchDiagnosticsAppL() ); |
|
262 } |
|
263 |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CGSDevDiagPlugin::LaunchDiagnosticsAppL |
|
267 // |
|
268 // Checks first is the application already running. |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CGSDevDiagPlugin::LaunchDiagnosticsAppL() |
|
272 { |
|
273 // Get the correct application data |
|
274 RWsSession ws; |
|
275 User::LeaveIfError(ws.Connect()); |
|
276 CleanupClosePushL(ws); |
|
277 |
|
278 // Find the task with uid |
|
279 TApaTaskList taskList(ws); |
|
280 TApaTask task = taskList.FindApp( KGsDiagnosticsAppUid ); |
|
281 |
|
282 if ( task.Exists() ) |
|
283 { |
|
284 task.BringToForeground(); |
|
285 } |
|
286 else |
|
287 { |
|
288 //Launch Diagnostics application as embedded |
|
289 TAppInfo app( KGsDiagnosticsAppUid, KGSDiagnosticsApp ); |
|
290 EmbedAppL( app ); |
|
291 } |
|
292 CleanupStack::PopAndDestroy(&ws); |
|
293 } |
|
294 |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // Handle Diagnostics application exit. GS should be closed down also. |
|
298 // |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 void CGSDevDiagPlugin::HandleServerAppExit(TInt aReason ) |
|
302 { |
|
303 if ( aReason != EAknSoftkeyBack ) |
|
304 { |
|
305 TRAP_IGNORE(AppUi()->HandleCommandL( EAknSoftkeyExit )); |
|
306 } |
|
307 } |
|
308 |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // Use null service to launch the embedded application |
|
312 // |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CGSDevDiagPlugin::EmbedAppL( const TAppInfo& aApp ) |
|
316 { |
|
317 if ( iNullService ) |
|
318 { |
|
319 delete iNullService; |
|
320 iNullService = NULL; |
|
321 } |
|
322 |
|
323 iNullService = CAknNullService::NewL( aApp.iUid, this ); |
|
324 } |
|
325 |
|
326 |
|
327 // End of File |