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