28
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: cscgsplugin implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <featmgr.h>
|
|
20 |
#include <bautils.h>
|
|
21 |
#include <gscommon.hrh>
|
|
22 |
#include <bldvariant.hrh>
|
|
23 |
#include <StringLoader.h>
|
|
24 |
#include <AknNullService.h>
|
|
25 |
#include <gsparentplugin.h>
|
|
26 |
#include <cscgspluginrsc.rsg>
|
|
27 |
#include <gsprivatepluginproviderids.h>
|
|
28 |
|
|
29 |
#include "cscgsplugin.h"
|
|
30 |
|
|
31 |
const TUid KCscGsPluginImplUid = { 0x1020E568 }; // dll impl uid
|
|
32 |
const TUid KCscAppUid = { 0x10275458 }; // from cscappui.mmp
|
|
33 |
|
|
34 |
_LIT( KCscApp, "z:\\sys\\bin\\csc.exe" );
|
|
35 |
_LIT( KCscGsPluginResourceFileName, "cscgspluginrsc.rsc" );
|
|
36 |
|
|
37 |
// ======== MEMBER FUNCTIONS ========
|
|
38 |
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CCscGsPlugin::CCscGsPlugin()
|
|
43 |
: iResources( *iCoeEnv ), iNullService(NULL)
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
CCscGsPlugin::~CCscGsPlugin()
|
|
51 |
{
|
|
52 |
FeatureManager::UnInitializeLib();
|
|
53 |
iResources.Close();
|
|
54 |
delete iNullService;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void CCscGsPlugin::ConstructL()
|
|
61 |
{
|
|
62 |
FeatureManager::InitializeLibL();
|
|
63 |
OpenLocalizedResourceFileL( KCscGsPluginResourceFileName, iResources );
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CCscGsPlugin* CCscGsPlugin::NewL( TAny* /*aInitParams*/ )
|
|
70 |
{
|
|
71 |
CCscGsPlugin* self = new ( ELeave ) CCscGsPlugin();
|
|
72 |
CleanupStack::PushL(self);
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop(self);
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// From class CAknView.
|
|
80 |
// CCscGsPlugin::Id()
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
TUid CCscGsPlugin::Id() const
|
|
84 |
{
|
|
85 |
return KCscGsPluginImplUid;
|
|
86 |
}
|
|
87 |
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
// From class CAknView.
|
|
90 |
// CCscGsPlugin::DoActivateL()
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CCscGsPlugin::DoActivateL(
|
|
94 |
const TVwsViewId& /*aPrevViewId*/,
|
|
95 |
TUid /*aCustomMessageId*/,
|
|
96 |
const TDesC8& /*aCustomMessage*/ )
|
|
97 |
{
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// From class CAknView.
|
|
102 |
// CCscGsPlugin::DoDeactivate()
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
void CCscGsPlugin::DoDeactivate()
|
|
106 |
{
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// From class CGSPluginInterface.
|
|
111 |
// CCscGsPlugin::GetCaptionL()
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
void CCscGsPlugin::GetCaptionL( TDes& aCaption ) const
|
|
115 |
{
|
|
116 |
HBufC* result = StringLoader::LoadL( R_CSCGSPLUGIN_CAPTION );
|
|
117 |
|
|
118 |
if ( result->Des().Length() < aCaption.MaxLength() )
|
|
119 |
{
|
|
120 |
aCaption.Copy( *result );
|
|
121 |
}
|
|
122 |
else
|
|
123 |
{
|
|
124 |
aCaption = KNullDesC;
|
|
125 |
}
|
|
126 |
|
|
127 |
delete result;
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// From class CGSPluginInterface.
|
|
132 |
// CCscGsPlugin::PluginProviderCategory()
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
TInt CCscGsPlugin::PluginProviderCategory() const
|
|
136 |
{
|
|
137 |
return KGSPluginProviderInternal;
|
|
138 |
}
|
|
139 |
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
// From class CGSPluginInterface.
|
|
142 |
// CCscGsPlugin::ItemType()
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
TGSListboxItemTypes CCscGsPlugin::ItemType()
|
|
146 |
{
|
|
147 |
return EGSItemTypeSettingDialog;
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// From class CGSPluginInterface.
|
|
152 |
// CCscGsPlugin::GetValue()
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CCscGsPlugin::GetValue(
|
|
156 |
const TGSPluginValueKeys /*aKey*/,
|
|
157 |
TDes& /*aValue*/ )
|
|
158 |
{
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
// From class CGSPluginInterface.
|
|
163 |
// CCscGsPlugin::HandleSelection()
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CCscGsPlugin::HandleSelection(
|
|
167 |
const TGSSelectionTypes /*aSelectionType*/ )
|
|
168 |
{
|
|
169 |
TRAP_IGNORE( LaunchCscAppL() );
|
|
170 |
}
|
|
171 |
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
// From class CGSPluginInterface.
|
|
174 |
// CCscGsPlugin::CreateIconL()
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
CGulIcon* CCscGsPlugin::CreateIconL( const TUid /*aIconType*/ )
|
|
178 |
{
|
|
179 |
return NULL;
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
// From class CGSPluginInterface.
|
|
184 |
// CCscGsPlugin::Visible()
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
TBool CCscGsPlugin::Visible() const
|
|
188 |
{
|
|
189 |
TBool visible( ETrue );
|
|
190 |
TBool voipSupported( EFalse );
|
|
191 |
|
|
192 |
// Im should be also checked from feature manager
|
|
193 |
TBool imSupported( EFalse );
|
|
194 |
|
|
195 |
voipSupported = FeatureManager::FeatureSupported(
|
|
196 |
KFeatureIdCommonVoip );
|
|
197 |
|
|
198 |
// If both voip and im are not supported --> set plugin not visible
|
|
199 |
if ( !voipSupported && !imSupported )
|
|
200 |
{
|
|
201 |
visible = EFalse;
|
|
202 |
}
|
|
203 |
|
|
204 |
return visible;
|
|
205 |
}
|
|
206 |
|
|
207 |
// ---------------------------------------------------------------------------
|
|
208 |
// CCscGsPlugin::OpenLocalizedResourceFile()
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
void CCscGsPlugin::OpenLocalizedResourceFileL(
|
|
212 |
const TDesC& aResourceFileName,
|
|
213 |
RConeResourceLoader& aResourceLoader )
|
|
214 |
{
|
|
215 |
RFs fsSession;
|
|
216 |
User::LeaveIfError( fsSession.Connect() );
|
|
217 |
CleanupClosePushL(fsSession);
|
|
218 |
|
|
219 |
// Find the resource file:
|
|
220 |
TParse parse;
|
|
221 |
parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
|
|
222 |
TFileName fileName( parse.FullName() );
|
|
223 |
|
|
224 |
// Get language of resource file:
|
|
225 |
BaflUtils::NearestLanguageFile( fsSession, fileName );
|
|
226 |
|
|
227 |
// Open resource file:
|
|
228 |
aResourceLoader.OpenL( fileName );
|
|
229 |
|
|
230 |
CleanupStack::PopAndDestroy(&fsSession);
|
|
231 |
}
|
|
232 |
|
|
233 |
|
|
234 |
// ---------------------------------------------------------------------------
|
|
235 |
// CCscGsPlugin::LaunchCscAppL()
|
|
236 |
// ---------------------------------------------------------------------------
|
|
237 |
//
|
|
238 |
void CCscGsPlugin::LaunchCscAppL()
|
|
239 |
{
|
|
240 |
// Get the correct application data
|
|
241 |
RWsSession ws;
|
|
242 |
CleanupClosePushL( ws );
|
|
243 |
User::LeaveIfError( ws.Connect() );
|
|
244 |
|
|
245 |
// Find the task with uid
|
|
246 |
TApaTaskList taskList( ws );
|
|
247 |
TApaTask task = taskList.FindApp( KCscAppUid );
|
|
248 |
|
|
249 |
if ( task.Exists() )
|
|
250 |
{
|
|
251 |
//Bring CSC to foreground.
|
|
252 |
task.BringToForeground();
|
|
253 |
}
|
|
254 |
else
|
|
255 |
{
|
|
256 |
//Launch csc application
|
|
257 |
TAppInfo app( KCscAppUid, KCscApp );
|
|
258 |
iEmbedded = NULL;
|
|
259 |
EmbedAppL( app );
|
|
260 |
}
|
|
261 |
CleanupStack::PopAndDestroy( &ws );
|
|
262 |
}
|
|
263 |
|
|
264 |
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
// CCscGsPlugin::EmbedAppL()
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
void CCscGsPlugin::EmbedAppL( const TAppInfo& aApp )
|
|
270 |
{
|
|
271 |
// Launch settings app
|
|
272 |
if ( iNullService )
|
|
273 |
{
|
|
274 |
delete iNullService;
|
|
275 |
iNullService = NULL;
|
|
276 |
}
|
|
277 |
iNullService = CAknNullService::NewL( aApp.iUid, this );
|
|
278 |
}
|
|
279 |
|
|
280 |
|