|
1 /* |
|
2 * Copyright (c) 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: CUPnPGSPluginView class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #include <upnpgspluginrsc.rsg> |
|
25 #include <hlplch.h> |
|
26 #include <avkon.mbg> |
|
27 #include <bautils.h> |
|
28 #include <gsfwviewuids.h> |
|
29 #include <aknnavide.h> |
|
30 #include <StringLoader.h> |
|
31 #include <featmgr.h> |
|
32 #include <akntitle.h> |
|
33 #include <pathinfo.h> |
|
34 #include <upnpgspluginrsc.mbg> |
|
35 |
|
36 #include "upnpappsettingslist.h" |
|
37 #include "upnpfilesharingengine.h" |
|
38 #include "upnpgsplugin.hrh" |
|
39 #include "upnpgspluginview.h" |
|
40 #include "upnpsettingsengine.h" |
|
41 |
|
42 _LIT( KComponentLogfile, "upnpgsplugin.txt"); |
|
43 #include "upnplog.h" |
|
44 |
|
45 // CONSTANTS |
|
46 const TUid KUPnPGSPluginImpUid = { KUPnPGSPluginImplementationUid }; |
|
47 |
|
48 _LIT( KUPnPGSPluginRscFile, "\\resource\\upnpgspluginrsc.rsc" ); |
|
49 _LIT( KAknHomeConnectMbmFileName, "\\resource\\apps\\upnpgspluginrsc.mif" ); |
|
50 |
|
51 // ======== MEMBER FUNCTIONS ======== |
|
52 |
|
53 // -------------------------------------------------------------------------- |
|
54 // Two phased constructor. |
|
55 // -------------------------------------------------------------------------- |
|
56 // |
|
57 CUPnPGSPluginView* CUPnPGSPluginView::NewL() |
|
58 { |
|
59 CUPnPGSPluginView* self = new ( ELeave ) CUPnPGSPluginView(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CUPnPGSPluginView::CUPnPGSPluginView() |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 CUPnPGSPluginView::CUPnPGSPluginView() |
|
71 { |
|
72 __LOG("CUPnPGSPluginView::CUPnPGSPluginView"); |
|
73 } |
|
74 |
|
75 // -------------------------------------------------------------------------- |
|
76 // CUPnPGSPluginView::ConstructL() |
|
77 // -------------------------------------------------------------------------- |
|
78 // |
|
79 void CUPnPGSPluginView::ConstructL() |
|
80 { |
|
81 __LOG( "CUPnPGSPlugin::ConstructL" ); |
|
82 // Get the pointer to coe env (owned by Eikon env) |
|
83 iCoeEnv = CEikonEnv::Static(); |
|
84 |
|
85 if( !iCoeEnv ) |
|
86 { |
|
87 User::Leave( KErrNotSupported ); |
|
88 } |
|
89 |
|
90 // Get the filesession reference from coe env |
|
91 RFs& fileSession = iCoeEnv->FsSession(); |
|
92 |
|
93 // Load resource file |
|
94 TFileName rscFileName( KUPnPGSPluginRscFile ); |
|
95 TFileName dllName; |
|
96 Dll::FileName( dllName ); |
|
97 TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' |
|
98 rscFileName.Insert( 0, drive ); |
|
99 |
|
100 // Get the exact filename of the resource file |
|
101 BaflUtils::NearestLanguageFile( fileSession, rscFileName ); |
|
102 |
|
103 // Check if the resource file exists or not |
|
104 if ( !BaflUtils::FileExists( fileSession, rscFileName ) ) |
|
105 { |
|
106 __LOG( "[UpnpCommand]\t Resource file does not exist!" ); |
|
107 User::Leave( KErrNotFound ); |
|
108 } |
|
109 |
|
110 // Read the resource file offset |
|
111 iResFileOffset = iCoeEnv->AddResourceFileL( rscFileName ); |
|
112 |
|
113 BaseConstructL( R_GS_UPNP_VIEW ); |
|
114 } |
|
115 |
|
116 // -------------------------------------------------------------------------- |
|
117 // CUPnPGSPluginView::~CUPnPGSPluginView() |
|
118 // -------------------------------------------------------------------------- |
|
119 // |
|
120 CUPnPGSPluginView::~CUPnPGSPluginView() |
|
121 { |
|
122 __LOG("CMSMainView::~CUPnPGSPluginView"); |
|
123 |
|
124 if ( iResFileOffset ) |
|
125 { |
|
126 iCoeEnv->DeleteResourceFile( iResFileOffset ); |
|
127 } |
|
128 |
|
129 DoDeactivate(); |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // TUid CUPnPGSPluginView::Id() |
|
134 // -------------------------------------------------------------------------- |
|
135 // |
|
136 TUid CUPnPGSPluginView::Id() const |
|
137 { |
|
138 __LOG("CUPnPGSPluginView::Id"); |
|
139 |
|
140 return KUPnPGSPluginImpUid; |
|
141 } |
|
142 |
|
143 // -------------------------------------------------------------------------- |
|
144 // CUPnPGSPluginView::HandleCommandL(TInt aCommand) |
|
145 // -------------------------------------------------------------------------- |
|
146 // |
|
147 void CUPnPGSPluginView::HandleCommandL( TInt aCommand ) |
|
148 { |
|
149 switch ( aCommand ) |
|
150 { |
|
151 |
|
152 case EAknSoftkeyChange: |
|
153 { |
|
154 TInt selectedItem = |
|
155 iSettingItemList->ListBox()->CurrentItemIndex(); |
|
156 iSettingItemList->EditItemL(selectedItem, ETrue); |
|
157 |
|
158 // fix ESLX-7LYLR7 |
|
159 iSettingItemList->DrawNow(); |
|
160 break; |
|
161 } |
|
162 case EAknSoftkeyBack: |
|
163 { |
|
164 AppUi()->ActivateLocalViewL( iViewToClose.iViewUid ); |
|
165 break; |
|
166 } |
|
167 case EAknCmdHelp : |
|
168 { |
|
169 TRAP_IGNORE( HlpLauncher::LaunchHelpApplicationL( |
|
170 iEikonEnv->WsSession(), |
|
171 iEikonEnv->EikAppUi()->AppHelpContextL() )); |
|
172 break; |
|
173 } |
|
174 default: |
|
175 { |
|
176 AppUi()->HandleCommandL( aCommand ); |
|
177 break; |
|
178 } |
|
179 } |
|
180 } |
|
181 |
|
182 // -------------------------------------------------------------------------- |
|
183 // CUPnPGSPluginView::DoActivateL(...) |
|
184 // -------------------------------------------------------------------------- |
|
185 // |
|
186 void CUPnPGSPluginView::DoActivateL( |
|
187 const TVwsViewId& aPrevViewId, TUid /*aCustomMessageId*/, |
|
188 const TDesC8& /*aCustomMessage*/ ) |
|
189 { |
|
190 __LOG("CUPnPGSPluginView::DoActivateL"); |
|
191 |
|
192 iViewToClose = aPrevViewId; |
|
193 |
|
194 // Set title pane text to default |
|
195 SetTitlePaneTextL( R_UPNP_GS_SETTINGS_VIEW_TITLE ); |
|
196 |
|
197 if( !iFileSharing ) |
|
198 { |
|
199 iFileSharing = CUPnPFileSharingEngine::NewL(); |
|
200 iFileSharing->SetObserver( this ); |
|
201 } |
|
202 |
|
203 if ( !iSettingItemList ) |
|
204 { |
|
205 iSharingState = static_cast<TInt>( iFileSharing->SharingStateL() ); |
|
206 // create settings screen |
|
207 iSettingItemList = |
|
208 CUPnPAppSettingsList::NewL( iSharingState, |
|
209 R_UPNP_GS_SETTINGS_LIST ); |
|
210 iSettingItemList->SetMopParent( this ); |
|
211 iSettingItemList->LoadDataFromEngineL(); |
|
212 // now control receives keyboard events |
|
213 AppUi()->AddToStackL( *this, iSettingItemList ); |
|
214 iSettingItemList->ActivateL(); |
|
215 } |
|
216 |
|
217 } |
|
218 |
|
219 // -------------------------------------------------------------------------- |
|
220 // CUPnPGSPluginView::DoDeactivate() |
|
221 // -------------------------------------------------------------------------- |
|
222 // |
|
223 void CUPnPGSPluginView::DoDeactivate() |
|
224 { |
|
225 __LOG("CUPnPGSPluginView::DoDeactivate"); |
|
226 |
|
227 if( iFileSharing ) |
|
228 { |
|
229 iFileSharing->SetObserver( NULL ); |
|
230 } |
|
231 delete iFileSharing; |
|
232 iFileSharing = NULL; |
|
233 |
|
234 if ( iSettingItemList ) |
|
235 { |
|
236 AppUi()->RemoveFromStack( iSettingItemList ); |
|
237 } |
|
238 |
|
239 delete iSettingItemList; // Deletes the container class object. |
|
240 iSettingItemList = NULL; |
|
241 } |
|
242 |
|
243 // -------------------------------------------------------------------------- |
|
244 // Method for getting caption of this plugin. |
|
245 // -------------------------------------------------------------------------- |
|
246 // |
|
247 void CUPnPGSPluginView::GetCaptionL( TDes& aCaption ) const |
|
248 { |
|
249 HBufC* pluginText = StringLoader::LoadLC( |
|
250 R_UPNP_GS_SETTINGS_VIEW_CAPTION ); |
|
251 aCaption.Copy( *pluginText ); |
|
252 CleanupStack::PopAndDestroy( pluginText ); |
|
253 } |
|
254 |
|
255 // -------------------------------------------------------------------------- |
|
256 // Creates a new icon of desired type. |
|
257 // -------------------------------------------------------------------------- |
|
258 // |
|
259 CGulIcon* CUPnPGSPluginView::CreateIconL( const TUid /*aIconType*/ ) |
|
260 { |
|
261 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
262 TFileName iconsPath( AknIconUtils::AvkonIconFileName() ); |
|
263 |
|
264 CFbsBitmap* bitmap = NULL; |
|
265 CFbsBitmap* mask = NULL; |
|
266 |
|
267 AknsUtils::CreateIconLC( |
|
268 skin, |
|
269 KAknsIIDDefault, |
|
270 bitmap, |
|
271 mask, |
|
272 KAknHomeConnectMbmFileName, |
|
273 EMbmUpnpgspluginrscQgn_menu_upnp_homemedia, |
|
274 EMbmUpnpgspluginrscQgn_menu_upnp_homemedia_mask ); |
|
275 |
|
276 CGulIcon* icon = CGulIcon::NewL(bitmap, mask); |
|
277 CleanupStack::Pop(mask); |
|
278 CleanupStack::Pop(bitmap); |
|
279 bitmap = NULL; |
|
280 mask = NULL; |
|
281 |
|
282 return icon; |
|
283 } |
|
284 |
|
285 // -------------------------------------------------------------------------- |
|
286 // CUPnPGSPluginView::SetTitlePaneTextL() |
|
287 // Sets text to title pane. |
|
288 // -------------------------------------------------------------------------- |
|
289 void CUPnPGSPluginView::SetTitlePaneTextL( TInt aResourceId ) |
|
290 { |
|
291 // Fetches pointer to the default title pane control. |
|
292 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( |
|
293 StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
294 |
|
295 TBuf<KMaxFileName> titleText( 0 ); |
|
296 iCoeEnv->ReadResourceL( titleText, aResourceId ); |
|
297 titlePane->SetTextL( titleText ); |
|
298 } |
|
299 |
|
300 // -------------------------------------------------------------------------- |
|
301 // CUPnPGSPlugin::DynInitMenuPaneL() |
|
302 // |
|
303 // dynamically handle help item if not supported |
|
304 // -------------------------------------------------------------------------- |
|
305 // |
|
306 void CUPnPGSPluginView::DynInitMenuPaneL( TInt aResourceId, |
|
307 CEikMenuPane* aMenuPane ) |
|
308 { |
|
309 if( aResourceId == R_HOMECONNECT_SETTINGS_MENU ) |
|
310 { |
|
311 User::LeaveIfNull( aMenuPane ); |
|
312 |
|
313 if ( FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
314 { |
|
315 aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse ); |
|
316 } |
|
317 else |
|
318 { |
|
319 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
320 } |
|
321 } |
|
322 } |
|
323 |
|
324 // -------------------------------------------------------------------------- |
|
325 // CUPnPGSPlugin::OnSharingStatusChanged |
|
326 // From MUPnPFileSharingEngineObserver |
|
327 // Function informs when file sharing was enabled or disabled |
|
328 // -------------------------------------------------------------------------- |
|
329 // |
|
330 void CUPnPGSPluginView::OnSharingStatusChanged( |
|
331 TInt aError, TBool aEnabled ) |
|
332 { |
|
333 __LOG("CUPnPGSPlugin::OnSharingStatusChanged"); |
|
334 if ( !aError ) |
|
335 { |
|
336 iSharingState = aEnabled; |
|
337 } |
|
338 } |
|
339 |
|
340 // -------------------------------------------------------------------------- |
|
341 // CUPnPGSPluginView::OnSharingConnectionLost |
|
342 // From MUPnPFileSharingEngineObserver |
|
343 // Callback to inform if connection has been lost |
|
344 // -------------------------------------------------------------------------- |
|
345 // |
|
346 void CUPnPGSPluginView::OnSharingConnectionLost() |
|
347 { |
|
348 iSharingState = EFalse; |
|
349 } |
|
350 |
|
351 // End of File |
|
352 |