|
1 /* |
|
2 * Copyright (c) 2007-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: AppMngr2 GS Installation Files plugin implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2gsinstfilesplugin.h" // CAppMngr2GsInstFilesPlugin |
|
20 #include "appmngr2internalpskeys.h" // KAppManagerApplicationMode |
|
21 #include "appmngr2.hrh" // KAppMngr2AppUidValue |
|
22 #include <AknNullService.h> // CAknNullService |
|
23 #include <e32property.h> // RProperty |
|
24 #include <StringLoader.h> // StringLoader |
|
25 #include <bautils.h> // BaflUtils |
|
26 #include <gsprivatepluginproviderids.h> // KGSPluginProviderInternal |
|
27 #include <appmngr2debugutils.h> // FLOG macros |
|
28 #include <appmngr2gsinstfilespluginrsc.rsg> // Resource IDs |
|
29 #include <appmngr2.mbg> // Bitmap IDs |
|
30 |
|
31 _LIT( KAppMngr2InstFilesResourceFileName, "z:appmngr2gsinstfilespluginrsc.rsc" ); |
|
32 _LIT( KAppMngrIconFileNameMif, "appmngr2.mif" ); |
|
33 _LIT( KDriveZ, "z:" ); |
|
34 const TUid KAppMngr2AppUid = { KAppMngr2AppUidValue }; |
|
35 |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CAppMngr2GsInstFilesPlugin::NewL() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CAppMngr2GsInstFilesPlugin* CAppMngr2GsInstFilesPlugin::NewL( TAny* /*aInitParams*/ ) |
|
44 { |
|
45 CAppMngr2GsInstFilesPlugin* self = new( ELeave ) CAppMngr2GsInstFilesPlugin(); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop(self); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CAppMngr2GsInstFilesPlugin::~CAppMngr2GsInstFilesPlugin() |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CAppMngr2GsInstFilesPlugin::~CAppMngr2GsInstFilesPlugin() |
|
57 { |
|
58 FLOG( "CAppMngr2GsInstFilesPlugin::~CAppMngr2GsInstFilesPlugin" ); |
|
59 iResources.Close(); |
|
60 delete iNullService; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CAppMngr2GsInstFilesPlugin::GetCaptionL() |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CAppMngr2GsInstFilesPlugin::GetCaptionL( TDes& aCaption ) const |
|
68 { |
|
69 HBufC* result = StringLoader::LoadL( R_CP_FOLDER_NOT_INSTALLED ); |
|
70 aCaption.Copy( *result ); |
|
71 delete result; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CAppMngr2GsInstFilesPlugin::HandleSelection() |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CAppMngr2GsInstFilesPlugin::HandleSelection( const TGSSelectionTypes /*aSelectionType*/ ) |
|
79 { |
|
80 TRAP_IGNORE( LaunchAppManagerL() ); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CAppMngr2GsInstFilesPlugin::ItemType() |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 TGSListboxItemTypes CAppMngr2GsInstFilesPlugin::ItemType() |
|
88 { |
|
89 return EGSItemTypeSettingDialog; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CAppMngr2GsInstFilesPlugin::CreateIconL() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CGulIcon* CAppMngr2GsInstFilesPlugin::CreateIconL( const TUid aIconType ) |
|
97 { |
|
98 HBufC* iconFilePath = HBufC::NewLC( KDriveZ().Length() + |
|
99 KDC_APP_BITMAP_DIR().Length() + KAppMngrIconFileNameMif().Length() ); |
|
100 TPtr ptr = iconFilePath->Des(); |
|
101 ptr.Append( KDriveZ ); |
|
102 ptr.Append( KDC_APP_BITMAP_DIR ); |
|
103 ptr.Append( KAppMngrIconFileNameMif ); |
|
104 |
|
105 CGulIcon* icon; |
|
106 if( aIconType == KGSIconTypeLbxItem ) |
|
107 { |
|
108 icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
|
109 KAknsIIDQgnPropCpInstFiles, *iconFilePath, |
|
110 EMbmAppmngr2Qgn_prop_cp_inst_files, |
|
111 EMbmAppmngr2Qgn_prop_cp_inst_files_mask ); |
|
112 } |
|
113 else |
|
114 { |
|
115 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
116 } |
|
117 |
|
118 CleanupStack::PopAndDestroy( iconFilePath ); |
|
119 return icon; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CAppMngr2GsInstFilesPlugin::PluginProviderCategory() |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 TInt CAppMngr2GsInstFilesPlugin::PluginProviderCategory() const |
|
127 { |
|
128 return KGSPluginProviderInternal; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CAppMngr2GsInstFilesPlugin::Id() |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 TUid CAppMngr2GsInstFilesPlugin::Id() const |
|
136 { |
|
137 return KAppMngr2InstFilesPluginUid; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CAppMngr2GsInstFilesPlugin::DoActivateL() |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CAppMngr2GsInstFilesPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
145 TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/ ) |
|
146 { |
|
147 FLOG( "CAppMngr2GsInstFilesPlugin::DoActivateL" ); // not called |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CAppMngr2GsInstFilesPlugin::DoDeactivate() |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void CAppMngr2GsInstFilesPlugin::DoDeactivate() |
|
155 { |
|
156 FLOG( "CAppMngr2GsInstFilesPlugin::DoDeactivate" ); // not called |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CAppMngr2GsInstFilesPlugin::CAppMngr2GsInstFilesPlugin() |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CAppMngr2GsInstFilesPlugin::CAppMngr2GsInstFilesPlugin() : iResources( *iCoeEnv ) |
|
164 { |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CAppMngr2GsInstFilesPlugin::ConstructL() |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CAppMngr2GsInstFilesPlugin::ConstructL() |
|
172 { |
|
173 FLOG( "CAppMngr2GsInstFilesPlugin::ConstructL" ); |
|
174 OpenLocalizedResourceFileL( KAppMngr2InstFilesResourceFileName, iResources ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CAppMngr2GsInstFilesPlugin::OpenLocalizedResourceFileL() |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CAppMngr2GsInstFilesPlugin::OpenLocalizedResourceFileL( |
|
182 const TDesC& aResourceFileName, RConeResourceLoader& aResourceLoader ) |
|
183 { |
|
184 TParse parse; |
|
185 parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
186 TFileName fileName( parse.FullName() ); |
|
187 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
188 aResourceLoader.OpenL( fileName ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // CAppMngr2GsInstFilesPlugin::LaunchAppManagerL() |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CAppMngr2GsInstFilesPlugin::LaunchAppManagerL() |
|
196 { |
|
197 FLOG( "CAppMngr2GsInstFilesPlugin::LaunchAppManagerL" ); |
|
198 |
|
199 _LIT_SECURITY_POLICY_PASS( KPropReadPolicy ); |
|
200 _LIT_SECURITY_POLICY_C1( KPropWritePolicy, ECapabilityWriteDeviceData ); |
|
201 TInt err = RProperty::Define( KPSUidAppManagerNotification, |
|
202 KAppManagerApplicationMode, RProperty::EInt, |
|
203 KPropReadPolicy, KPropWritePolicy ); |
|
204 if( err != KErrNone && err != KErrAlreadyExists ) |
|
205 { |
|
206 User::Leave( err ); |
|
207 } |
|
208 User::LeaveIfError( RProperty::Set( KPSUidAppManagerNotification, |
|
209 KAppManagerApplicationMode, EAppMngr2InstallationFilesView ) ); |
|
210 |
|
211 RWsSession ws; |
|
212 User::LeaveIfError( ws.Connect() ); |
|
213 CleanupClosePushL( ws ); |
|
214 TApaTaskList taskList( ws ); |
|
215 TApaTask task = taskList.FindApp( KAppMngr2AppUid ); |
|
216 |
|
217 if( task.Exists() ) |
|
218 { |
|
219 task.BringToForeground(); |
|
220 } |
|
221 else |
|
222 { |
|
223 EmbedAppL( KAppMngr2AppUid ); |
|
224 } |
|
225 |
|
226 CleanupStack::PopAndDestroy( &ws ); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CAppMngr2GsInstFilesPlugin::EmbedAppL() |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CAppMngr2GsInstFilesPlugin::EmbedAppL( const TUid& aAppUid ) |
|
234 { |
|
235 if( iNullService ) |
|
236 { |
|
237 delete iNullService; |
|
238 iNullService = NULL; |
|
239 } |
|
240 iNullService = CAknNullService::NewL( aAppUid, this ); |
|
241 } |
|
242 |