|
1 /* |
|
2 * Copyright (c) 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: Basic functionality of MediaFileList. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "mediafiledialogutils.h" |
|
23 |
|
24 |
|
25 #include <bautils.h> // bafl.lib |
|
26 #include <StringLoader.h> |
|
27 #include <driveinfo.h> |
|
28 #include <pathinfo.h> |
|
29 |
|
30 #include <aknnavide.h> // CAknNavigationDecorator |
|
31 #include <aknnavilabel.h> // CAknNaviLabel |
|
32 #include <akntitle.h> // CAknTitlePane |
|
33 #include <AknQueryDialog.h> |
|
34 #include <aknnotewrappers.h> |
|
35 #include <AknsUtils.h> // AknsUtils |
|
36 |
|
37 // for CWebBrowserLauncher |
|
38 #include <browserlauncher.h> |
|
39 #include <DocumentHandler.h> |
|
40 #include <AiwCommon.h> |
|
41 |
|
42 |
|
43 #include <mediafilelist.rsg> |
|
44 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 /****************************************************************************** |
|
50 * class TMFDialogUtil |
|
51 ******************************************************************************/ |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // TMFDialogUtil::StrCopy |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void TMFDialogUtil::StrCopy( TDes& aTarget, const TDesC& aSource ) |
|
60 { |
|
61 TInt len = aTarget.MaxLength(); |
|
62 if( len < aSource.Length() ) |
|
63 { |
|
64 aTarget.Copy( aSource.Left(len) ); |
|
65 return; |
|
66 } |
|
67 aTarget.Copy( aSource ); |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // TMFDialogUtil::Panic |
|
73 // |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void TMFDialogUtil::Panic( TInt aReason ) |
|
77 { |
|
78 _LIT( KPanicCategory, "TMFDialogUtil" ); |
|
79 |
|
80 User::Panic( KPanicCategory, aReason ); |
|
81 } |
|
82 |
|
83 |
|
84 //------------------------------------------------------------------------------ |
|
85 // TMFDialogUtil::ShowInformationNoteL |
|
86 // |
|
87 //------------------------------------------------------------------------------ |
|
88 // |
|
89 void TMFDialogUtil::ShowInformationNoteL( TInt aResource ) |
|
90 { |
|
91 HBufC* hBuf = StringLoader::LoadLC( aResource ); |
|
92 ShowInformationNoteL( hBuf->Des() ); |
|
93 CleanupStack::PopAndDestroy( hBuf ); |
|
94 } |
|
95 |
|
96 |
|
97 //------------------------------------------------------------------------------ |
|
98 // TMFDialogUtil::ShowInformationNoteL |
|
99 // |
|
100 //------------------------------------------------------------------------------ |
|
101 // |
|
102 void TMFDialogUtil::ShowInformationNoteL( const TDesC& aText ) |
|
103 { |
|
104 CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote( ETrue ); |
|
105 queryDialog->ExecuteLD( aText ); |
|
106 } |
|
107 |
|
108 |
|
109 //------------------------------------------------------------------------------ |
|
110 // TMFDialogUtil::ShowInformationQueryL |
|
111 // |
|
112 //------------------------------------------------------------------------------ |
|
113 // |
|
114 void TMFDialogUtil::ShowInformationQueryL( const TDesC& aText ) |
|
115 { |
|
116 CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog; |
|
117 queryDialog->ExecuteLD( R_INFORMATION_QUERY, aText ); |
|
118 } |
|
119 |
|
120 |
|
121 //------------------------------------------------------------------------------ |
|
122 // TMFDialogUtil::ShowInformationQueryL |
|
123 // |
|
124 //------------------------------------------------------------------------------ |
|
125 // |
|
126 void TMFDialogUtil::ShowInformationQueryL( TInt aResource ) |
|
127 { |
|
128 HBufC* hBuf = StringLoader::LoadLC( aResource ); |
|
129 ShowInformationQueryL( hBuf->Des() ); |
|
130 CleanupStack::PopAndDestroy( hBuf ); |
|
131 } |
|
132 |
|
133 //------------------------------------------------------------------------------ |
|
134 // TMFDialogUtil::ShowErrorNoteL |
|
135 // |
|
136 //------------------------------------------------------------------------------ |
|
137 // |
|
138 void TMFDialogUtil::ShowErrorNoteL( TInt aResource ) |
|
139 { |
|
140 HBufC* hBuf = StringLoader::LoadLC( aResource ); |
|
141 ShowErrorNoteL( hBuf->Des() ); |
|
142 CleanupStack::PopAndDestroy( hBuf ); |
|
143 } |
|
144 |
|
145 |
|
146 //------------------------------------------------------------------------------ |
|
147 // TMFDialogUtil::ShowErrorNoteL |
|
148 // |
|
149 //------------------------------------------------------------------------------ |
|
150 // |
|
151 void TMFDialogUtil::ShowErrorNoteL( const TDesC& aText ) |
|
152 { |
|
153 CAknErrorNote* errorNote = new (ELeave) CAknErrorNote(ETrue); |
|
154 errorNote->ExecuteLD( aText ); |
|
155 } |
|
156 |
|
157 |
|
158 //------------------------------------------------------------------------------ |
|
159 // TMFDialogUtil::ShowErrorNoteL |
|
160 // |
|
161 //------------------------------------------------------------------------------ |
|
162 // |
|
163 void TMFDialogUtil::ShowErrorNoteL( const TDesC& aText, TInt aError ) |
|
164 { |
|
165 _LIT( KFormat, "%S (%d)" ); |
|
166 |
|
167 TInt len = aText.Length(); |
|
168 HBufC* hBuf = HBufC::NewLC( len + KBufSize64 ); |
|
169 |
|
170 TPtr ptr = hBuf->Des(); |
|
171 ptr.Format( KFormat, &aText, aError); |
|
172 |
|
173 ShowErrorNoteL( ptr ); |
|
174 |
|
175 CleanupStack::PopAndDestroy( hBuf ); |
|
176 } |
|
177 |
|
178 //------------------------------------------------------------------------------ |
|
179 // ShowNumberQueryL |
|
180 // |
|
181 //------------------------------------------------------------------------------ |
|
182 // |
|
183 TBool TMFDialogUtil::ShowNumberQueryL( TInt& aNumber, const TDesC& aTitle ) |
|
184 { |
|
185 CAknNumberQueryDialog* queryDialog = CAknNumberQueryDialog::NewL(aNumber); |
|
186 |
|
187 if ( aTitle.Length() > 1 ) |
|
188 { |
|
189 CleanupStack::PushL( queryDialog ); |
|
190 queryDialog->SetPromptL( aTitle ); |
|
191 CleanupStack::Pop( queryDialog ); |
|
192 } |
|
193 |
|
194 return queryDialog->ExecuteLD( R_NUMBER_QUERY ); |
|
195 } |
|
196 |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // TMFDialogUtil::ShowListQueryL |
|
200 // |
|
201 // ----------------------------------------------------------------------------- |
|
202 TBool TMFDialogUtil::ShowListQueryL( const TDesC& aTitle, CDesCArray* aList, |
|
203 TInt* aSelectedIndex ) |
|
204 { |
|
205 CAknListQueryDialog* query = new (ELeave) CAknListQueryDialog( aSelectedIndex ); |
|
206 CleanupStack::PushL( query ); |
|
207 |
|
208 query->PrepareLC( R_LIST_QUERY ); |
|
209 query->SetItemTextArray( aList ); |
|
210 query->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
211 CAknPopupHeadingPane* headingPane = query->QueryHeading(); |
|
212 headingPane->SetTextL( aTitle ); |
|
213 |
|
214 CleanupStack::Pop( query ); |
|
215 |
|
216 return query->RunLD(); |
|
217 } |
|
218 |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // TMFDialogUtil::AddResFileL |
|
222 // |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 TInt TMFDialogUtil::AddResFileL() |
|
226 { |
|
227 _LIT( KDriveZ, "z:" ); |
|
228 _LIT( KResFileName, "mediafilelist.rsc" ); |
|
229 |
|
230 TFileName fileName; |
|
231 fileName.Append( KDriveZ ); |
|
232 fileName.Append( KDC_RESOURCE_FILES_DIR ); |
|
233 fileName.Append( KResFileName ); |
|
234 |
|
235 CEikonEnv* env = CEikonEnv::Static(); |
|
236 BaflUtils::NearestLanguageFile( env->FsSession(), fileName ); |
|
237 |
|
238 return env->AddResourceFileL( fileName ); |
|
239 } |
|
240 |
|
241 |
|
242 // ---------------------------------------------------------------------------- |
|
243 // TMFDialogUtil::SetIconFileNameL |
|
244 // |
|
245 // ---------------------------------------------------------------------------- |
|
246 // |
|
247 void TMFDialogUtil::SetIconFileNameL( const TDesC& aName, TDes& aFullName ) |
|
248 { |
|
249 _LIT( KDriveZ, "z:" ); |
|
250 |
|
251 aFullName = KNullDesC; |
|
252 |
|
253 aFullName.Append( KDriveZ ); |
|
254 aFullName.Append( KDC_APP_RESOURCE_DIR ); |
|
255 aFullName.Append( aName ); |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // TMFDialogUtil::CreateImageL |
|
261 // |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 CEikImage* TMFDialogUtil::CreateImageLC( TAknsItemID aId, const TDesC& aFileName, |
|
265 TInt aFileBitmapId, TInt aFileMaskId ) |
|
266 { |
|
267 CFbsBitmap* bitmap1 = NULL; |
|
268 CFbsBitmap* bitmap2 = NULL; |
|
269 |
|
270 CEikImage* image = new (ELeave) CEikImage; |
|
271 CleanupStack::PushL( image ); |
|
272 |
|
273 AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), aId, bitmap1, bitmap2, |
|
274 aFileName, aFileBitmapId, aFileMaskId ); |
|
275 image->SetPicture( bitmap1, bitmap2 ); |
|
276 CleanupStack::Pop(2); // bitmap1 bitmap2 |
|
277 |
|
278 return image; |
|
279 } |
|
280 |
|
281 // ------------------------------------------------------------------------------- |
|
282 // TMFDialogUtil::IsEmpty |
|
283 // |
|
284 // Function returns ETrue if string only contains white space or has |
|
285 // no characters. |
|
286 // ------------------------------------------------------------------------------- |
|
287 // |
|
288 TBool TMFDialogUtil::IsEmpty( const TDesC& aText ) |
|
289 { |
|
290 TInt len = aText.Length(); |
|
291 |
|
292 for ( TInt i=0; i<len; i++ ) |
|
293 { |
|
294 TChar c = aText[i]; |
|
295 if ( !c.IsSpace() ) |
|
296 { |
|
297 return EFalse; |
|
298 } |
|
299 } |
|
300 return ETrue; |
|
301 } |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 /****************************************************************************** |
|
307 * class CMFActiveCaller |
|
308 ******************************************************************************/ |
|
309 |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CMFActiveCaller::NewL |
|
313 // |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 CMFActiveCaller* CMFActiveCaller::NewL( MMFActiveCallerObserver* aObserver ) |
|
317 { |
|
318 CMFActiveCaller* self = new (ELeave) CMFActiveCaller( aObserver ); |
|
319 CleanupStack::PushL( self ); |
|
320 self->ConstructL(); |
|
321 CleanupStack::Pop( self ); |
|
322 |
|
323 return self; |
|
324 } |
|
325 |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // Destructor |
|
329 // |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 CMFActiveCaller::~CMFActiveCaller() |
|
333 { |
|
334 Cancel(); |
|
335 iTimer.Close(); |
|
336 } |
|
337 |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CMFActiveCaller::CMFActiveCaller |
|
341 // |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 CMFActiveCaller::CMFActiveCaller(MMFActiveCallerObserver* aObserver) : CActive(CActive::EPriorityStandard) |
|
345 { |
|
346 iObserver = aObserver; |
|
347 } |
|
348 |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CMFActiveCaller::ConstructL |
|
352 // |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void CMFActiveCaller::ConstructL() |
|
356 { |
|
357 User::LeaveIfError( iTimer.CreateLocal() ); |
|
358 CActiveScheduler::Add( this ); |
|
359 } |
|
360 |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CMFActiveCaller::DoCancel |
|
364 // |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 void CMFActiveCaller::DoCancel() |
|
368 { |
|
369 iTimer.Cancel(); |
|
370 } |
|
371 |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CMFActiveCaller::RunL |
|
375 // |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 void CMFActiveCaller::RunL() |
|
379 { |
|
380 TRAP_IGNORE( iObserver->HandleActiveCallL( iCallId ) ); |
|
381 } |
|
382 |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CMFActiveCaller::Request |
|
386 // |
|
387 // This function calls this class RunL. |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void CMFActiveCaller::Request() |
|
391 { |
|
392 Cancel(); |
|
393 SetActive(); |
|
394 TRequestStatus* status = &iStatus; |
|
395 User::RequestComplete( status, KErrNone ); |
|
396 } |
|
397 |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // CMFActiveCaller::Start |
|
401 // |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 void CMFActiveCaller::Start( TInt aCallId, TInt aMilliseconds ) |
|
405 { |
|
406 const TInt KThousand = 1000; |
|
407 Cancel(); |
|
408 |
|
409 iCallId = aCallId; |
|
410 |
|
411 if ( aMilliseconds <= 0 ) |
|
412 { |
|
413 Request(); // no delay - complete asap |
|
414 } |
|
415 else |
|
416 { |
|
417 iTimer.After( iStatus, aMilliseconds*KThousand ); |
|
418 SetActive(); |
|
419 } |
|
420 } |
|
421 |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CMFActiveCaller::Stop |
|
425 // |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 void CMFActiveCaller::Stop() |
|
429 { |
|
430 Cancel(); |
|
431 } |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 /******************************************************************************* |
|
437 * class CNaviPaneHandler |
|
438 *******************************************************************************/ |
|
439 |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // Destructor |
|
443 // |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 CNaviPaneHandler::~CNaviPaneHandler() |
|
447 { |
|
448 if ( iNaviDecorator ) |
|
449 { |
|
450 if ( iNaviPane && iNavidecoratorPushed ) |
|
451 { |
|
452 iNaviPane->Pop( iNaviDecorator ); |
|
453 } |
|
454 |
|
455 delete iNaviDecorator; |
|
456 } |
|
457 |
|
458 if ( iNaviPane && iNavipanePushed ) |
|
459 { |
|
460 iNaviPane->Pop(); // restore previous navi pane |
|
461 } |
|
462 } |
|
463 |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // CNaviPaneHandler::CNaviPaneHandler |
|
467 // |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 CNaviPaneHandler::CNaviPaneHandler( CEikStatusPane* aStatusPane ) : iStatusPane( aStatusPane ) |
|
471 { |
|
472 iNavidecoratorPushed = EFalse; |
|
473 iNavipanePushed = EFalse; |
|
474 |
|
475 if ( iStatusPane ) |
|
476 { |
|
477 TRAP_IGNORE( iNaviPane = (CAknNavigationControlContainer*)iStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidNavi)) ); |
|
478 } |
|
479 } |
|
480 |
|
481 |
|
482 // ---------------------------------------------------------------------------- |
|
483 // CNaviPaneHandler::SetNaviPaneTitleL |
|
484 // |
|
485 // ---------------------------------------------------------------------------- |
|
486 // |
|
487 void CNaviPaneHandler::SetNaviPaneTitleL(const TDesC& aTitle) |
|
488 { |
|
489 if ( !iStatusPane || !iNaviPane ) |
|
490 { |
|
491 return; |
|
492 } |
|
493 |
|
494 if ( iNaviDecorator ) |
|
495 { |
|
496 CAknNaviLabel* naviLabel = static_cast<CAknNaviLabel*>(iNaviDecorator->DecoratedControl()); |
|
497 if ( naviLabel ) |
|
498 { |
|
499 naviLabel->SetTextL( aTitle ); |
|
500 iNaviDecorator->DrawDeferred(); |
|
501 } |
|
502 } |
|
503 else |
|
504 { |
|
505 iNaviDecorator = iNaviPane->CreateNavigationLabelL( aTitle ) ; |
|
506 iNaviPane->PushL( *iNaviDecorator ); // activate navi label in navi pane |
|
507 iNavidecoratorPushed = ETrue; |
|
508 } |
|
509 } |
|
510 |
|
511 |
|
512 // ---------------------------------------------------------------------------- |
|
513 // CNaviPaneHandler::StoreNavipaneL |
|
514 // |
|
515 // ---------------------------------------------------------------------------- |
|
516 // |
|
517 void CNaviPaneHandler::StoreNavipaneL() |
|
518 { |
|
519 if ( !iNaviPane || !iStatusPane || iNavipanePushed ) |
|
520 { |
|
521 return; |
|
522 } |
|
523 |
|
524 if ( iStatusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidTitle)).IsPresent() ) |
|
525 { |
|
526 iNaviPane->PushDefaultL(); |
|
527 iNavipanePushed = ETrue; |
|
528 } |
|
529 } |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 /******************************************************************************* |
|
535 * class CStatusPaneHandler |
|
536 *******************************************************************************/ |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // CStatusPaneHandler::NewL |
|
540 // |
|
541 // Two-phased constructor. |
|
542 // ----------------------------------------------------------------------------- |
|
543 // |
|
544 CStatusPaneHandler* CStatusPaneHandler::NewL( CAknAppUi* aAppUi ) |
|
545 { |
|
546 CStatusPaneHandler* self = new (ELeave) CStatusPaneHandler( aAppUi ); |
|
547 CleanupStack::PushL( self ); |
|
548 self->ConstructL(); |
|
549 CleanupStack::Pop( self ); |
|
550 return self; |
|
551 } |
|
552 |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // Destructor |
|
556 // |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 CStatusPaneHandler::~CStatusPaneHandler() |
|
560 { |
|
561 TRAP_IGNORE( RestoreOriginalTitleL() ); |
|
562 |
|
563 delete iNaviPaneHandler; |
|
564 } |
|
565 |
|
566 |
|
567 // ----------------------------------------------------------------------------- |
|
568 // CStatusPaneHandler::ConstructL |
|
569 // |
|
570 // Symbian 2nd phase constructor can leave. |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 void CStatusPaneHandler::ConstructL() |
|
574 { |
|
575 iNaviPaneHandler = new (ELeave) CNaviPaneHandler( iAppUi->StatusPane() ); |
|
576 } |
|
577 |
|
578 |
|
579 // ----------------------------------------------------------------------------- |
|
580 // CStatusPaneHandler::CStatusPaneHandler |
|
581 // |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 CStatusPaneHandler::CStatusPaneHandler( CAknAppUi* aAppUi ) : iAppUi(aAppUi ) |
|
585 { |
|
586 __ASSERT_ALWAYS( iAppUi, TMFDialogUtil::Panic( KErrGeneral ) ); |
|
587 |
|
588 iOriginalTitleStored = EFalse; |
|
589 iOriginalTitle = KNullDesC; |
|
590 } |
|
591 |
|
592 |
|
593 // ---------------------------------------------------------------------------- |
|
594 // CStatusPaneHandler::GetTitleL |
|
595 // |
|
596 // ---------------------------------------------------------------------------- |
|
597 // |
|
598 TBool CStatusPaneHandler::GetTitleL( CAknAppUi* aAppUi, TDes& aTitle ) |
|
599 { |
|
600 aTitle = KNullDesC; |
|
601 |
|
602 CEikStatusPane* statusPane = aAppUi->StatusPane(); |
|
603 if (statusPane && statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
604 { |
|
605 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
606 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
607 if ( titlePane->Text() ) |
|
608 { |
|
609 TMFDialogUtil::StrCopy( aTitle, *titlePane->Text() ); |
|
610 return ETrue; |
|
611 } |
|
612 } |
|
613 |
|
614 return EFalse; |
|
615 } |
|
616 |
|
617 |
|
618 // ---------------------------------------------------------------------------- |
|
619 // CStatusPaneHandler::SetTitleL |
|
620 // |
|
621 // ---------------------------------------------------------------------------- |
|
622 // |
|
623 TBool CStatusPaneHandler::SetTitleL( CAknAppUi* aAppUi, const TDesC& aTitle ) |
|
624 { |
|
625 CEikStatusPane* statusPane = aAppUi->StatusPane(); |
|
626 if ( statusPane && statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
627 { |
|
628 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
629 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
630 if ( titlePane->Text() ) |
|
631 { |
|
632 titlePane->SetTextL( aTitle ); |
|
633 return ETrue; |
|
634 } |
|
635 } |
|
636 return EFalse; |
|
637 } |
|
638 |
|
639 |
|
640 // ---------------------------------------------------------------------------- |
|
641 // CStatusPaneHandler::SetNaviPaneTitleL |
|
642 // |
|
643 // ---------------------------------------------------------------------------- |
|
644 // |
|
645 void CStatusPaneHandler::SetNaviPaneTitleL( const TDesC& aTitle ) |
|
646 { |
|
647 iNaviPaneHandler->SetNaviPaneTitleL( aTitle ); |
|
648 } |
|
649 |
|
650 |
|
651 // ---------------------------------------------------------------------------- |
|
652 // CStatusPaneHandler::SetNaviPaneTitle |
|
653 // |
|
654 // ---------------------------------------------------------------------------- |
|
655 // |
|
656 void CStatusPaneHandler::SetNaviPaneTitle( const TDesC& aTitle ) |
|
657 { |
|
658 TRAP_IGNORE( iNaviPaneHandler->SetNaviPaneTitleL( aTitle ) ); |
|
659 } |
|
660 |
|
661 |
|
662 // ---------------------------------------------------------------------------- |
|
663 // CStatusPaneHandler::SetNaviPaneTitleL |
|
664 // |
|
665 // ---------------------------------------------------------------------------- |
|
666 // |
|
667 void CStatusPaneHandler::SetNaviPaneTitleL( TInt aResource ) |
|
668 { |
|
669 HBufC* hBuf = StringLoader::LoadLC( aResource) ; |
|
670 SetNaviPaneTitleL( hBuf->Des() ); |
|
671 CleanupStack::PopAndDestroy( hBuf ); |
|
672 } |
|
673 |
|
674 |
|
675 // ---------------------------------------------------------------------------- |
|
676 // CStatusPaneHandler::StoreNavipaneL |
|
677 // |
|
678 // ---------------------------------------------------------------------------- |
|
679 // |
|
680 void CStatusPaneHandler::StoreNavipaneL() |
|
681 { |
|
682 iNaviPaneHandler->StoreNavipaneL(); |
|
683 } |
|
684 |
|
685 |
|
686 // ---------------------------------------------------------------------------- |
|
687 // CStatusPaneHandler::StoreOriginalTitleL |
|
688 // |
|
689 // ---------------------------------------------------------------------------- |
|
690 // |
|
691 void CStatusPaneHandler::StoreOriginalTitleL() |
|
692 { |
|
693 TBool ret = GetTitleL( iAppUi, iOriginalTitle ); |
|
694 |
|
695 if ( ret ) |
|
696 { |
|
697 iOriginalTitleStored = ETrue; |
|
698 } |
|
699 } |
|
700 |
|
701 |
|
702 // ---------------------------------------------------------------------------- |
|
703 // CStatusPaneHandler::RestoreOriginalTitleL |
|
704 // |
|
705 // ---------------------------------------------------------------------------- |
|
706 // |
|
707 void CStatusPaneHandler::RestoreOriginalTitleL() |
|
708 { |
|
709 if ( iOriginalTitleStored ) |
|
710 { |
|
711 SetTitleL( iAppUi, iOriginalTitle ); |
|
712 } |
|
713 } |
|
714 |
|
715 |
|
716 // ---------------------------------------------------------------------------- |
|
717 // CStatusPaneHandler::SetTitleL |
|
718 // |
|
719 // ---------------------------------------------------------------------------- |
|
720 // |
|
721 void CStatusPaneHandler::SetTitleL( const TDesC& aText ) |
|
722 { |
|
723 if ( iOriginalTitleStored ) |
|
724 { |
|
725 SetTitleL( iAppUi, aText ); |
|
726 } |
|
727 } |
|
728 |
|
729 |
|
730 // ---------------------------------------------------------------------------- |
|
731 // CStatusPaneHandler::SetTitleL |
|
732 // |
|
733 // ---------------------------------------------------------------------------- |
|
734 // |
|
735 void CStatusPaneHandler::SetTitleL( TInt aResourceId ) |
|
736 { |
|
737 HBufC* hBuf = StringLoader::LoadLC( aResourceId ); |
|
738 SetTitleL( hBuf->Des() ); |
|
739 CleanupStack::PopAndDestroy( hBuf ); |
|
740 } |
|
741 |
|
742 |
|
743 |
|
744 /****************************************************************************** |
|
745 * class CDriveUtil |
|
746 ******************************************************************************/ |
|
747 |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // CDriveUtil::NewL |
|
751 // |
|
752 // ----------------------------------------------------------------------------- |
|
753 // |
|
754 CDriveUtil* CDriveUtil::NewL() |
|
755 { |
|
756 CDriveUtil* self = new (ELeave) CDriveUtil(); |
|
757 CleanupStack::PushL( self ); |
|
758 self->ConstructL(); |
|
759 CleanupStack::Pop( self ); |
|
760 |
|
761 return self; |
|
762 } |
|
763 |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // Destructor |
|
767 // |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 CDriveUtil::~CDriveUtil() |
|
771 { |
|
772 iFsSession.Close(); |
|
773 } |
|
774 |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CDriveUtil::CDriveUtil |
|
778 // |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 CDriveUtil::CDriveUtil() |
|
782 { |
|
783 } |
|
784 |
|
785 |
|
786 // ----------------------------------------------------------------------------- |
|
787 // CDriveUtil::ConstructL |
|
788 // |
|
789 // ----------------------------------------------------------------------------- |
|
790 // |
|
791 void CDriveUtil::ConstructL() |
|
792 { |
|
793 User::LeaveIfError( iFsSession.Connect() ); |
|
794 } |
|
795 |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CDriveUtil::IsRom |
|
799 // |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 TBool CDriveUtil::IsRom( const TDesC& aFullPath ) |
|
803 { |
|
804 const TUint KMassStorageBits = DriveInfo::EDriveRom; |
|
805 |
|
806 TDriveUnit drive( aFullPath ); |
|
807 TUint driveStatus( 0 ); |
|
808 |
|
809 TInt err = DriveInfo::GetDriveStatus( iFsSession, drive, driveStatus ); |
|
810 if ( err != KErrNone ) |
|
811 { |
|
812 return EFalse; |
|
813 } |
|
814 |
|
815 if ( (driveStatus & KMassStorageBits) == KMassStorageBits ) |
|
816 { |
|
817 return ETrue; |
|
818 } |
|
819 |
|
820 return EFalse; |
|
821 } |
|
822 |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CDriveUtil::IsMassStorage |
|
826 // |
|
827 // ----------------------------------------------------------------------------- |
|
828 // |
|
829 TBool CDriveUtil::IsMassStorage( const TDesC& aFullPath ) |
|
830 { |
|
831 const TUint KMassStorageBits = DriveInfo::EDriveInternal | |
|
832 DriveInfo::EDriveExternallyMountable; |
|
833 |
|
834 TDriveUnit drive( aFullPath ); |
|
835 TUint driveStatus( 0 ); |
|
836 |
|
837 TInt err = DriveInfo::GetDriveStatus( iFsSession, drive, driveStatus ); |
|
838 if ( err != KErrNone ) |
|
839 { |
|
840 return EFalse; |
|
841 } |
|
842 |
|
843 if ( (driveStatus & KMassStorageBits) == KMassStorageBits ) |
|
844 { |
|
845 return ETrue; |
|
846 } |
|
847 |
|
848 return EFalse; |
|
849 } |
|
850 |
|
851 |
|
852 // ----------------------------------------------------------------------------- |
|
853 // CDriveUtil::IsMemoryCard |
|
854 // |
|
855 // ----------------------------------------------------------------------------- |
|
856 // |
|
857 TBool CDriveUtil::IsMemoryCard( const TDesC& aFullPath ) |
|
858 { |
|
859 const TUint KMemoryCardBits = DriveInfo::EDriveRemovable | |
|
860 DriveInfo::EDriveExternallyMountable; |
|
861 |
|
862 TDriveUnit drive( aFullPath ); |
|
863 TUint driveStatus( 0 ); |
|
864 |
|
865 TInt err = DriveInfo::GetDriveStatus( iFsSession, drive, driveStatus ); |
|
866 if ( err != KErrNone ) |
|
867 { |
|
868 return EFalse; |
|
869 } |
|
870 |
|
871 if ( (driveStatus & KMemoryCardBits) == KMemoryCardBits ) |
|
872 { |
|
873 return ETrue; |
|
874 } |
|
875 |
|
876 return EFalse; |
|
877 } |
|
878 |
|
879 |
|
880 |
|
881 /****************************************************************************** |
|
882 * class CMimeTypeList |
|
883 ******************************************************************************/ |
|
884 |
|
885 |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // CMimeTypeList::NewL |
|
889 // |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 CMimeTypeList* CMimeTypeList::NewL() |
|
893 { |
|
894 CMimeTypeList* object = new (ELeave) CMimeTypeList; |
|
895 return object; |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CMimeTypeList::CMimeTypeList |
|
900 // |
|
901 // ----------------------------------------------------------------------------- |
|
902 // |
|
903 CMimeTypeList::CMimeTypeList() |
|
904 { |
|
905 } |
|
906 |
|
907 // ----------------------------------------------------------------------------- |
|
908 // CMimeTypeList::~CMimeTypeList |
|
909 // |
|
910 // ----------------------------------------------------------------------------- |
|
911 // |
|
912 CMimeTypeList::~CMimeTypeList() |
|
913 { |
|
914 iList.Close(); |
|
915 } |
|
916 |
|
917 |
|
918 // ----------------------------------------------------------------------------- |
|
919 // CMimeTypeList::ConstructL |
|
920 // |
|
921 // ----------------------------------------------------------------------------- |
|
922 // |
|
923 void CMimeTypeList::ConstructL() |
|
924 { |
|
925 } |
|
926 |
|
927 |
|
928 |
|
929 // ----------------------------------------------------------------------------- |
|
930 // CMimeTypeList::ResetL |
|
931 // |
|
932 // ----------------------------------------------------------------------------- |
|
933 // |
|
934 void CMimeTypeList::ResetL() |
|
935 { |
|
936 iList.Reset(); |
|
937 } |
|
938 |
|
939 |
|
940 // ----------------------------------------------------------------------------- |
|
941 // CMimeTypeList::Count |
|
942 // |
|
943 // ----------------------------------------------------------------------------- |
|
944 // |
|
945 TInt CMimeTypeList::Count() |
|
946 { |
|
947 return iList.Count(); |
|
948 } |
|
949 |
|
950 |
|
951 // ----------------------------------------------------------------------------- |
|
952 // CMimeTypeList::Compare |
|
953 // |
|
954 // ----------------------------------------------------------------------------- |
|
955 // |
|
956 TInt CMimeTypeList::Compare(const TFileName& aFirst, const TFileName& aSecond) |
|
957 { |
|
958 return aFirst.Compare( aSecond ); |
|
959 } |
|
960 |
|
961 |
|
962 // ----------------------------------------------------------------------------- |
|
963 // CMimeTypeList::AddMimeTypeL |
|
964 // |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 void CMimeTypeList::AddMimeTypeL( const TDesC& aText ) |
|
968 { |
|
969 if ( aText.Length() > KMaxFileName || aText.Length() == 0 ) |
|
970 { |
|
971 User::Leave( KErrArgument ); |
|
972 } |
|
973 |
|
974 TLinearOrder<TFileName> sortFunction( Compare ); |
|
975 |
|
976 TInt err = iList.InsertInOrder( aText, sortFunction ); |
|
977 |
|
978 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
979 { |
|
980 User::Leave( err ); |
|
981 } |
|
982 } |
|
983 |
|
984 |
|
985 // ----------------------------------------------------------------------------- |
|
986 // CMimeTypeList::FindMimeTypeL |
|
987 // |
|
988 // ----------------------------------------------------------------------------- |
|
989 // |
|
990 TBool CMimeTypeList::FindMimeTypeL( const TDesC& aText ) |
|
991 { |
|
992 TInt count = Count(); |
|
993 |
|
994 for ( TInt i=0; i<count; i++ ) |
|
995 { |
|
996 TPtrC ptr = MimeType( i ); |
|
997 if ( ptr.Compare( aText ) == 0 ) |
|
998 { |
|
999 return ETrue; |
|
1000 } |
|
1001 } |
|
1002 |
|
1003 return EFalse; |
|
1004 } |
|
1005 |
|
1006 |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // CMimeTypeList::MimeType |
|
1009 // |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // |
|
1012 const TDesC& CMimeTypeList::MimeType( TInt aIndex ) |
|
1013 { |
|
1014 TInt count = iList.Count(); |
|
1015 __ASSERT_ALWAYS( aIndex >= 0 && aIndex < count, TMFDialogUtil::Panic( KErrGeneral ) ); |
|
1016 |
|
1017 return iList[aIndex]; |
|
1018 } |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 /****************************************************************************** |
|
1024 * class CWebBrowserLauncher |
|
1025 ******************************************************************************/ |
|
1026 |
|
1027 |
|
1028 // ----------------------------------------------------------------------------- |
|
1029 // CWebBrowserLauncher::CWebBrowserLauncher |
|
1030 // |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 CWebBrowserLauncher::CWebBrowserLauncher() |
|
1034 { |
|
1035 } |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // CWebBrowserLauncher::ConstructL |
|
1039 // |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // |
|
1042 void CWebBrowserLauncher::ConstructL() |
|
1043 { |
|
1044 iBrowserLauncher = CBrowserLauncher::NewL(); |
|
1045 iDocumentHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() ); |
|
1046 } |
|
1047 |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 // CWebBrowserLauncher::NewLC |
|
1050 // |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // |
|
1053 CWebBrowserLauncher* CWebBrowserLauncher::NewLC() |
|
1054 { |
|
1055 CWebBrowserLauncher* self = new( ELeave ) CWebBrowserLauncher(); |
|
1056 CleanupStack::PushL( self ); |
|
1057 self->ConstructL(); |
|
1058 return self; |
|
1059 } |
|
1060 |
|
1061 |
|
1062 // ----------------------------------------------------------------------------- |
|
1063 // CWebBrowserLauncher::~CWebBrowserLauncher |
|
1064 // |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // |
|
1067 CWebBrowserLauncher::~CWebBrowserLauncher() |
|
1068 { |
|
1069 delete iDocumentHandler; |
|
1070 delete iBrowserLauncher; |
|
1071 } |
|
1072 |
|
1073 |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // CWebBrowserLauncher::HandleContentL |
|
1076 // |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // |
|
1079 TBool CWebBrowserLauncher::HandleContentL( const TDesC& aFileName, |
|
1080 const CAiwGenericParamList& aParamList, |
|
1081 TBool& aContinue ) |
|
1082 { |
|
1083 TBool isSaved = EFalse; |
|
1084 |
|
1085 if ( aParamList.Count() > 0 ) |
|
1086 { |
|
1087 TInt index = 0; |
|
1088 aParamList.FindFirst( index, EGenericParamFileSaved ); |
|
1089 |
|
1090 if( index != KErrNotFound ) |
|
1091 { |
|
1092 isSaved = ( aParamList[ index ].Value().AsTInt32() ); |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 // Tone is NOT yet saved by a browser, save it by using DocHandler |
|
1097 if( !isSaved ) |
|
1098 { |
|
1099 //Let documenthandler to find out the datatype |
|
1100 TDataType nullType; |
|
1101 iDocumentHandler->CopyL( aFileName, KNullDesC, nullType, NULL ); |
|
1102 } |
|
1103 |
|
1104 aContinue = ETrue; |
|
1105 |
|
1106 return ETrue; |
|
1107 } |
|
1108 |
|
1109 |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // CWebBrowserLauncher::HandleContentL |
|
1112 // |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // |
|
1115 TAny* CWebBrowserLauncher::DownloadedContentHandlerReserved1( TAny* /*aAnyParam*/ ) |
|
1116 { |
|
1117 return NULL; |
|
1118 } |
|
1119 |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // CWebBrowserLauncher::LaunchBrowserL |
|
1122 // |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // |
|
1125 void CWebBrowserLauncher::LaunchBrowserL() |
|
1126 { |
|
1127 iBrowserLauncher->LaunchBrowserSyncEmbeddedL( KFavouritesAudioContextId ); |
|
1128 } |
|
1129 |
|
1130 |
|
1131 |
|
1132 // End of File |