svgtviewer/SvgtViewerPlugin/AppSrc/SVGTViewerAppAppUi.cpp
changeset 12 2b69f8f46e4a
parent 1 ec62f27282ac
equal deleted inserted replaced
1:ec62f27282ac 12:2b69f8f46e4a
     1 /*
       
     2 * Copyright (c) 2004,2005 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:  AppUI for SVGT Viewer App.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikapp.h>
       
    20 #include <avkon.hrh>
       
    21 #include <aknnotewrappers.h>
       
    22 #include <w32std.h>                                        // RWsSession 
       
    23 #include <e32std.h> 
       
    24 #include <ctsydomainpskeys.h>                              // For call handling
       
    25 #include <e32property.h>
       
    26 #include <StringLoader.h>
       
    27 #include <coeutils.h>
       
    28 #include <SVGTViewerApp.rsg>
       
    29 #include <SVGTAppObserverUtil.h>
       
    30 #include "SVGTViewerAppDbgFlags.hrh"
       
    31 #include "SVGTViewerAppAppUi.h"
       
    32 #include "SVGTViewerAppDocument.h"
       
    33 #include "SVGTViewerApp.pan"
       
    34 #include "SVGTUIDialog.h"
       
    35 #include "SVGTViewerApp.hrh"
       
    36 
       
    37 
       
    38 #include "SvgtViewerAppView.h"
       
    39 
       
    40 #ifdef RD_MULTIPLE_DRIVE    
       
    41 #include <pathinfo.h>
       
    42 #include <driveinfo.h>
       
    43 #endif
       
    44 // Constants
       
    45 
       
    46 #ifdef SVGTVIEWERAPP_DBG_OPEN_HARDCODE_FILE
       
    47 _LIT(KDummyTstFileName, "c:\\data\\images\\01-guide.svg");
       
    48 #endif
       
    49 
       
    50 // Constant for periodic timer
       
    51 const TInt KOneMicroSec = 1;
       
    52 
       
    53 // ============================ MEMBER FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSVGTViewerAppAppUi::CSVGTViewerAppAppUi
       
    57 // Default Constructor for CSVGTViewerAppAppUi.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CSVGTViewerAppAppUi::CSVGTViewerAppAppUi()             
       
    61     {
       
    62     // No implementation required
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CSVGTViewerAppAppUi::ConstructL
       
    67 // Second Phase constructor for CSVGTViewerAppAppUi.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CSVGTViewerAppAppUi::ConstructL()
       
    71     {
       
    72     BaseConstructL( EAknEnableSkin|EAknEnableMSK );    // Enable skin support and MSK label 
       
    73     												  // for this Application    												
       
    74                                    
       
    75     ResetEmbeddedAppRunning(); //By default, there are no embedded app started.    
       
    76 
       
    77     iContainer = new (ELeave) CSvgtViewerAppView;
       
    78     iContainer->ConstructL(ClientRect());
       
    79 	// add container to stack; enables key event handling.
       
    80 	AddToStackL(iContainer);
       
    81     
       
    82 #ifndef SVGTVIEWERAPP_DBG_OPEN_HARDCODE_FILE    
       
    83     // Launch file only in non-hardcoded option.
       
    84     // Start an idle timer to start the dialog synchronously.
       
    85     iIdleTimer = CPeriodic::NewL(CActive::EPriorityIdle);
       
    86     // Using the periodic timer so that active object for
       
    87     // open file service gets a chance to execute
       
    88     iIdleTimer->Start(KOneMicroSec, KOneMicroSec, 
       
    89         TCallBack(CallBackFuncL,this));
       
    90 #endif    
       
    91     }
       
    92     
       
    93 // -----------------------------------------------------------------------------
       
    94 // Destructor
       
    95 // -----------------------------------------------------------------------------
       
    96 CSVGTViewerAppAppUi::~CSVGTViewerAppAppUi()
       
    97     {
       
    98     iAppDialog = NULL; 
       
    99     iAppObserver = NULL;      
       
   100     if ( iIdleTimer )
       
   101         {
       
   102         delete iIdleTimer;
       
   103         iIdleTimer = NULL;
       
   104         }
       
   105 
       
   106 	RemoveFromStack(iContainer);
       
   107     delete iContainer;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CSVGTViewerAppAppUi::HandleCommandL
       
   112 // Reimplements CAknAppUi::HandleCommandL inorder to handle commands.
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CSVGTViewerAppAppUi::HandleCommandL( TInt aCommand )
       
   116     {
       
   117 #ifdef SVGTVIEWERAPP_DBG_OPEN_HARDCODE_FILE        
       
   118     TFileName fileName;     
       
   119 #endif    
       
   120     switch ( aCommand )
       
   121         {
       
   122         case EEikCmdExit:
       
   123         case EAknSoftkeyExit:
       
   124             Exit();
       
   125             break;
       
   126         case ESVGTViewerAppCommand1:
       
   127 #ifdef _DEBUG
       
   128             iEikonEnv->InfoMsg( _L( "not implemented" ) );
       
   129 #endif
       
   130 #ifdef SVGTVIEWERAPP_DBG_OPEN_HARDCODE_FILE            
       
   131             fileName.Append( KDummyTstFileName );
       
   132             OpenFileL( fileName );
       
   133 #endif        
       
   134             break;
       
   135 
       
   136         default:           
       
   137             break;
       
   138         }
       
   139     }
       
   140 
       
   141 
       
   142 
       
   143 
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CSVGTViewerAppAppUi::OpenFileL
       
   147 // Reimplements CAknAppUi::OpenFileL inorder to provide for opening SVG 
       
   148 // content through doc handler.
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CSVGTViewerAppAppUi::OpenFileL( 
       
   152     RFile& aFileHandle ) // File Handle to 
       
   153                          // SVGT content
       
   154     {
       
   155     // Display an info note if a video call is in progress.
       
   156     // SVG content cannot be displayed in this case.    
       
   157     if ( IsVideoCall() )
       
   158         {
       
   159         HBufC* text = StringLoader::LoadLC( 
       
   160                 R_SVGT_VIEWER_INFO_VIDEO_CALL_ONGOING );
       
   161         CAknInformationNote* dlg = new (ELeave) CAknInformationNote( ETrue );
       
   162         dlg->ExecuteLD( text->Des() );
       
   163         CleanupStack::PopAndDestroy( text );  // text
       
   164         Exit();
       
   165         }
       
   166     
       
   167     TRAPD( err, iAppDialog = CSVGTUIDialog::NewL() );
       
   168     
       
   169     if ( err != KErrNone )
       
   170         {
       
   171         // Reset the pointer to dialog
       
   172         iAppDialog = NULL;
       
   173         iEikonEnv->HandleError( err );
       
   174         Exit();
       
   175         }
       
   176 
       
   177     // Get the File's fullpath, Handle and pass it to App Observer Util. 
       
   178     TFileName filename;
       
   179     CSVGTViewerAppDocument *appDocument = 
       
   180             static_cast< CSVGTViewerAppDocument* >(iDocument);
       
   181 
       
   182     if ( appDocument->IsFileFullPathAvailable() )
       
   183         {
       
   184         appDocument->GetFileFullPath(filename);
       
   185         }
       
   186 
       
   187     TRAP( err, iAppObserver = CSVGTAppObserverUtil::NewL( iAppDialog,
       
   188                                      &aFileHandle, 
       
   189                                      filename,
       
   190                                      appDocument->IsFileFullPathAvailable(),
       
   191                                      CanShowSave(),
       
   192                                      ShouldMoveContent()) );
       
   193     if ( err != KErrNone )
       
   194         {
       
   195         // Delete the dialog
       
   196         delete iAppDialog;
       
   197         // Reset the dialog pointer
       
   198         iAppDialog = NULL;
       
   199         // Reset the App Observer Pointer
       
   200         iAppObserver = NULL;
       
   201         iEikonEnv->HandleError( err );
       
   202         Exit();
       
   203         }
       
   204     
       
   205     if( iAppDialog )
       
   206         {
       
   207         TRAP( err, iAppDialog->ExecuteLD( aFileHandle, iAppObserver ) );
       
   208         if ( err != KErrNone )
       
   209             {
       
   210             if( err == KLeaveExit )
       
   211                 {
       
   212             	delete iAppDialog;
       
   213             	delete iAppObserver;
       
   214             	
       
   215             	iAppObserver = NULL;
       
   216             	iAppDialog   = NULL;
       
   217             	
       
   218             	Exit();
       
   219                 }
       
   220             // Reset the dialog pointer
       
   221             iAppDialog = NULL;
       
   222             // Delete the app observer 
       
   223             delete iAppObserver;
       
   224             iEikonEnv->HandleError( err );
       
   225             Exit();
       
   226             }
       
   227         }
       
   228     // Delete the app observer
       
   229     delete iAppObserver;
       
   230     
       
   231     // Reset the App Observer Pointer
       
   232     iAppObserver = NULL;
       
   233     
       
   234     // Dialog has destroyed itself, Reset the pointer
       
   235     iAppDialog = NULL;
       
   236     
       
   237     Exit();
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // CSVGTViewerAppAppUi::OpenFileL
       
   242 // Reimplements CAknAppUi::OpenFileL inorder to provide for opening SVG 
       
   243 // content through doc handler.
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 void CSVGTViewerAppAppUi::OpenFileL( 
       
   247     const TDesC& aFileName) // File Name of SVGT content
       
   248     {
       
   249     // Display an info note if a video call is in progress.
       
   250     // SVG content cannot be displayed in this case.
       
   251     if ( IsVideoCall() )
       
   252         {
       
   253         HBufC* text = StringLoader::LoadLC( 
       
   254                 R_SVGT_VIEWER_INFO_VIDEO_CALL_ONGOING );
       
   255         CAknInformationNote* dlg = new (ELeave) CAknInformationNote( ETrue );
       
   256         dlg->ExecuteLD( text->Des() );
       
   257         CleanupStack::PopAndDestroy( text );  // text
       
   258         Exit();
       
   259         }
       
   260     
       
   261     // Open File Handle for the file
       
   262 
       
   263     RFile fileHandle;
       
   264     TInt err = fileHandle.Open( iEikonEnv->FsSession(), 
       
   265                                 aFileName, EFileShareAny );
       
   266     if ( err != KErrNone )
       
   267         {       
       
   268         iEikonEnv->HandleError( err );
       
   269         Exit();
       
   270         }
       
   271 
       
   272 
       
   273     TRAP( err, iAppDialog = CSVGTUIDialog::NewL() );
       
   274     if ( err != KErrNone )
       
   275         {
       
   276         // Reset the Dialog pointer
       
   277         iAppDialog = NULL;
       
   278         // Close the file handle
       
   279         fileHandle.Close();
       
   280 
       
   281         iEikonEnv->HandleError( err );
       
   282         Exit();
       
   283         }
       
   284     
       
   285     TRAP( err, 
       
   286         iAppObserver = CSVGTAppObserverUtil::NewL( iAppDialog, 
       
   287                                      &fileHandle, 
       
   288                                      aFileName,
       
   289                                      ETrue,
       
   290                                      CanShowSave(),
       
   291                                      ShouldMoveContent() ) );
       
   292     if ( err != KErrNone )
       
   293         {
       
   294         // Reset the AppObserver Pointer
       
   295         iAppObserver = NULL;
       
   296         // Reset the Dialog pointer
       
   297         iAppDialog = NULL;
       
   298         // Close the file handle
       
   299         fileHandle.Close();
       
   300         
       
   301         iEikonEnv->HandleError( err );
       
   302         Exit();
       
   303         }
       
   304         
       
   305     if( iAppDialog )
       
   306         {
       
   307         TRAP( err, iAppDialog->ExecuteLD( fileHandle, iAppObserver ) );
       
   308 
       
   309         if ( err != KErrNone )
       
   310             {
       
   311             if( err == KLeaveExit )
       
   312                 {
       
   313                 delete iAppDialog;
       
   314                 delete iAppObserver;
       
   315             	
       
   316                 iAppObserver = NULL;
       
   317                 iAppDialog   = NULL;
       
   318             	
       
   319                 Exit();
       
   320                 }
       
   321             // Delete the AppObserver Pointer
       
   322             delete iAppObserver;
       
   323             // Reset the AppObserver Pointer
       
   324             iAppObserver = NULL;
       
   325             // Reset the Dialog pointer
       
   326             iAppDialog = NULL;
       
   327             // Close the file handle
       
   328             fileHandle.Close();
       
   329         
       
   330             iEikonEnv->HandleError( err );
       
   331             Exit();
       
   332             }
       
   333         }
       
   334     
       
   335     // Delete the App Observer
       
   336     delete iAppObserver;
       
   337    
       
   338     // Reset the App Observer pointer
       
   339     iAppObserver = NULL;
       
   340 
       
   341     // Dialog has destroyed itself, Reset the pointer
       
   342     iAppDialog = NULL;
       
   343     
       
   344     // Close the file handle and session
       
   345     fileHandle.Close();
       
   346     
       
   347     Exit();
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CSVGTViewerAppAppUi::SetAllowMove
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 void CSVGTViewerAppAppUi::SetAllowMove(TInt32 aMoveAllowed)
       
   355     {
       
   356     iMoveAllowed = aMoveAllowed;
       
   357     }
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // CSVGTViewerAppAppUi::ProcessCommandParametersL
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 TBool CSVGTViewerAppAppUi::ProcessCommandParametersL(
       
   364     TApaCommand /* aCommand */ ,
       
   365     TFileName& aDocumentName, 
       
   366     const TDesC8& /* aTail */ )
       
   367     {
       
   368     return ConeUtils::FileExists(aDocumentName);
       
   369     }    
       
   370 
       
   371 // -----------------------------------------------------------------------------
       
   372 // CSVGTViewerAppAppUi::HandleScreenDeviceChangedL
       
   373 // Handle the screen size being changed
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 void CSVGTViewerAppAppUi::HandleScreenDeviceChangedL()
       
   377     {
       
   378     CAknAppUiBase::HandleScreenDeviceChangedL();  
       
   379     }
       
   380 // -----------------------------------------------------------------------------
       
   381 // CSVGTViewerAppAppUi::HandleResourceChangeL
       
   382 // Handle the screen size being changed
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 void CSVGTViewerAppAppUi::HandleResourceChangeL( TInt aType )
       
   386     {
       
   387     CAknAppUi::HandleResourceChangeL( aType );
       
   388     }
       
   389 // -----------------------------------------------------------------------------
       
   390 // CSVGTViewerAppAppUi::HandleForegroundEventL
       
   391 // App Framework calls this api to give background/foreground events to the
       
   392 // application. Param: aForeground : ETrue: Foreground. EFalse: Background.
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 
       
   396 void CSVGTViewerAppAppUi::HandleForegroundEventL( TBool aForeground )
       
   397     {   
       
   398     // Pass the application foreground or goes to background,
       
   399     // give the events to the underlying dialog and the custom
       
   400     // control so that the animation is paused when app goes
       
   401     // to background and so on. But the app might have
       
   402     // opened another application embedded (Browser or another
       
   403     // viewer). So need to qualify these events with these
       
   404     // conditions. Whenever opening/closing another app 
       
   405     // embedded, need to pass background/foreground events to
       
   406     // dialog, and call Set/ResetEmbeddedAppRunning.
       
   407 
       
   408     // Passing the event to the base class
       
   409     CAknAppUi::HandleForegroundEventL( aForeground );
       
   410     
       
   411     if ( !IsEmbeddedAppRunning() )
       
   412         {
       
   413         if ( iAppDialog )
       
   414             {
       
   415             iAppDialog->HandleApplicationForegroundEvent(
       
   416                             aForeground );
       
   417             }
       
   418 
       
   419         }
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CSVGTViewerAppAppUi::IsVideoCall()
       
   424 // Used to find out if the videocall is going on. The
       
   425 // viewer is not allowed to open if viedo call is 
       
   426 // going on.
       
   427 // -----------------------------------------------------------------------------
       
   428 //
       
   429 TBool CSVGTViewerAppAppUi::IsVideoCall() const
       
   430     {
       
   431     TBool lVideoCallConnected = EFalse;
       
   432     TInt lType = 0;  
       
   433     TInt error = RProperty::Get( KPSUidCtsyCallInformation, 
       
   434                                  KCTsyCallType, lType );
       
   435     
       
   436     // EPSTelephonyCallTypeH324Multimedia is used for 3G video calls
       
   437     if ( !error && lType == EPSCTsyCallTypeH324Multimedia )
       
   438         {
       
   439         // Call is of video call, check whether call is connected
       
   440         TInt lState = 0;         
       
   441         error = RProperty::Get( KPSUidCtsyCallInformation, 
       
   442                                 KCTsyCallState, lState );
       
   443         if ( !error &&
       
   444          ( lState != EPSCTsyCallStateUninitialized &&
       
   445            lState != EPSCTsyCallStateNone &&
       
   446            lState != EPSCTsyCallStateDisconnecting ) )
       
   447             {
       
   448             lVideoCallConnected = ETrue;    
       
   449             }
       
   450         }
       
   451     return lVideoCallConnected;
       
   452     }
       
   453 
       
   454 // -----------------------------------------------------------------------------
       
   455 // CSVGTViewerAppAppUi::IsEmbeddedAppRunning()
       
   456 // Used to find out if viewer application has in turn 
       
   457 // started an embedded application.
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 TBool CSVGTViewerAppAppUi::IsEmbeddedAppRunning() const
       
   461     {
       
   462     return iEmbeddedAppRunning;
       
   463     }
       
   464 
       
   465 // -----------------------------------------------------------------------------
       
   466 // CSVGTViewerAppAppUi::SetEmbeddedAppRunning()
       
   467 // Used to set state in Viewer application if it has in turn 
       
   468 // started an embedded application.
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 void CSVGTViewerAppAppUi::SetEmbeddedAppRunning()
       
   472     {
       
   473     iEmbeddedAppRunning = ETrue;
       
   474     }
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // CSVGTViewerAppAppUi::ResetEmbeddedAppRunning()
       
   478 // Used to set state in viewer application if embedded
       
   479 // application started by it is closed now.
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 void CSVGTViewerAppAppUi::ResetEmbeddedAppRunning()
       
   483     {
       
   484     iEmbeddedAppRunning = EFalse;
       
   485     }
       
   486 
       
   487 // -----------------------------------------------------------------------------
       
   488 // CSVGTViewerAppAppUi::CallBackFuncL()
       
   489 // Used to callback by the idle timer in order to launch 
       
   490 // the dialog
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 TInt CSVGTViewerAppAppUi::CallBackFuncL(TAny *aPtr)
       
   494     {
       
   495     CSVGTViewerAppAppUi* appUi = 
       
   496         static_cast< CSVGTViewerAppAppUi* >( aPtr );
       
   497     if ( appUi )    
       
   498         {
       
   499         return ( appUi->LaunchDialogL() );    
       
   500         }
       
   501         else
       
   502             {
       
   503             // To indicate that the timer is not
       
   504             // called again, return false to the timer
       
   505             // RunL
       
   506             return ( EFalse );
       
   507             }
       
   508     }
       
   509     
       
   510 // -----------------------------------------------------------------------------
       
   511 // CSVGTViewerAppAppUi::LaunchDialogL()
       
   512 // This function accesses the document and launches the 
       
   513 // content.
       
   514 // -----------------------------------------------------------------------------
       
   515 //
       
   516 TBool CSVGTViewerAppAppUi::LaunchDialogL()
       
   517     {
       
   518     // Check if file-handle in document is valid
       
   519     if ( static_cast< CSVGTViewerAppDocument* >
       
   520         (iDocument)->IsFileHandleValid() )
       
   521         {
       
   522         // Obtain the file-handle
       
   523         RFile& fileHandle = 
       
   524         (static_cast< CSVGTViewerAppDocument* >
       
   525         (iDocument)->GetSvgtContentFileHandle());
       
   526         
       
   527         // Cancel the periodic timer
       
   528         if ( iIdleTimer->IsActive() )
       
   529             {
       
   530             iIdleTimer->Cancel();
       
   531             }
       
   532             
       
   533         // Launch the content
       
   534         OpenFileL( fileHandle );
       
   535  
       
   536         // Delete and reset the idle-timer
       
   537         delete iIdleTimer;
       
   538         iIdleTimer = NULL;  
       
   539  
       
   540         // Return False to indicate that 
       
   541         // timer need not callback further.
       
   542         return EFalse; 
       
   543         
       
   544         }
       
   545         else
       
   546             {
       
   547             // Return True to indicate that the 
       
   548             // timer needs to callback this function 
       
   549             // again, as the file-handle is not valid 
       
   550             // yet.
       
   551             return ETrue;           
       
   552             }
       
   553     }
       
   554 
       
   555 // -----------------------------------------------------------------------------
       
   556 // CSVGTViewerAppAppUi::WeAreEmbedded
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 TBool CSVGTViewerAppAppUi::WeAreEmbedded() const
       
   560 {
       
   561    // SVGT-Viewer will be opened in embedded mode always
       
   562    return ETrue;       
       
   563 }
       
   564 
       
   565 // -----------------------------------------------------------------------------
       
   566 // CSVGTViewerAppAppUi::CanShowSave
       
   567 // -----------------------------------------------------------------------------
       
   568 //
       
   569 TBool CSVGTViewerAppAppUi::CanShowSave() const 
       
   570     {
       
   571     // By default dont show the save option
       
   572     TBool ret = EFalse;
       
   573     
       
   574     // Check if we are launched embedded
       
   575     if (WeAreEmbedded())
       
   576         {
       
   577         // If the file is not a local file then 
       
   578         // display the save option
       
   579         if ( !IsLocalFile() )
       
   580             {
       
   581             ret = ETrue;
       
   582             }
       
   583         }
       
   584     return ret;
       
   585     }
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // CSVGTViewerAppAppUi::ShouldMoveContent
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 TBool CSVGTViewerAppAppUi::ShouldMoveContent() const
       
   592     {
       
   593     return iMoveAllowed;
       
   594     }
       
   595 
       
   596 // -----------------------------------------------------------------------------
       
   597 // CSVGTViewerAppAppUi::IsLocalFile
       
   598 //  This function returns ETrue if file is local, EFalse otherwise
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 TBool CSVGTViewerAppAppUi::IsLocalFile() const 
       
   602     {
       
   603     // By default file is not local
       
   604     TBool isLocal = EFalse;
       
   605    
       
   606     // Obtain the file-handle
       
   607     RFile& fileHandle = (static_cast<CSVGTViewerAppDocument*>
       
   608                         (iDocument)->GetSvgtContentFileHandle());
       
   609     // Check whether local/remote  
       
   610     TRAP_IGNORE( isLocal = IsLocalFileL( fileHandle ) );
       
   611     
       
   612     return isLocal;
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------------------------
       
   616 // CSVGTViewerAppAppUi::IsLocalFileL
       
   617 //  This function checks whether the filepath of the content opened is 
       
   618 //  in the PHONE_MEMORY_IMAGES_PATH or MEMORYCARD_IMAGES_PATH
       
   619 // -----------------------------------------------------------------------------
       
   620 //
       
   621 TBool CSVGTViewerAppAppUi::IsLocalFileL( RFile& aFileHandle ) const 
       
   622     {
       
   623     // By default file is not local
       
   624     TBool retVal = EFalse;
       
   625 
       
   626 #ifdef RD_MULTIPLE_DRIVE    
       
   627 
       
   628     HBufC* fileNameBuf = HBufC::NewLC( KMaxFileName );
       
   629     TPtr fileNamePtr = fileNameBuf->Des();
       
   630     aFileHandle.FullName( fileNamePtr );
       
   631 
       
   632     RFs fsSession = iEikonEnv->FsSession();
       
   633     TName driveRootPath;
       
   634      
       
   635     TInt intDrive;
       
   636     DriveInfo::TDriveArray driveArray;
       
   637     User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fsSession, driveArray ) );
       
   638     for(TInt i=0; i < driveArray.Count(); i++)
       
   639         {
       
   640         TChar driveLetter = driveArray.LetterAt(i);
       
   641         User::LeaveIfError( RFs::CharToDrive(driveLetter, intDrive) );
       
   642         User::LeaveIfError( PathInfo::GetRootPath(driveRootPath, intDrive) );
       
   643 
       
   644         // Check whether filepath consists of phone mem path or mmc path
       
   645         if ( driveRootPath.FindF( fileNamePtr.Left(driveRootPath.Length() ) ) != KErrNotFound )
       
   646             {
       
   647             // Path Found means file is local
       
   648             retVal = ETrue;
       
   649             break;
       
   650             }
       
   651         }
       
   652 
       
   653     CleanupStack::PopAndDestroy( fileNameBuf );    
       
   654 #else
       
   655     // Get the phone memory path
       
   656     HBufC* phoneMemImgPath = iEikonEnv->AllocReadResourceLC( 
       
   657             R_SVGT_VIEWER_PHONE_MEMORY_IMAGES_PATH );
       
   658 
       
   659     // Get the Memory Card path
       
   660     HBufC* memCardImgPath = iEikonEnv->AllocReadResourceLC(
       
   661             R_SVGT_VIEWER_MEMORYCARD_IMAGES_PATH );
       
   662     
       
   663     // Get the content filename
       
   664     HBufC* fileNameBuf = HBufC::NewLC( KMaxFileName );
       
   665     TPtr fileNamePtr = fileNameBuf->Des();
       
   666     aFileHandle.FullName( fileNamePtr );
       
   667 
       
   668     // Check whether filepath consists of phone mem path or mmc path
       
   669     if ( phoneMemImgPath->FindF( fileNamePtr.Left( 
       
   670             phoneMemImgPath->Length() ) ) != KErrNotFound
       
   671          || memCardImgPath->FindF( fileNamePtr.Left( 
       
   672             memCardImgPath->Length() ) ) != KErrNotFound )
       
   673         {
       
   674         // Path Found means file is local
       
   675         retVal = ETrue;
       
   676         }
       
   677 
       
   678     // Perform Cleanup         
       
   679     CleanupStack::PopAndDestroy( fileNameBuf );
       
   680     CleanupStack::PopAndDestroy( memCardImgPath );
       
   681     CleanupStack::PopAndDestroy( phoneMemImgPath );
       
   682 #endif    
       
   683 
       
   684     return retVal;
       
   685     }
       
   686 //End of File