svgtviewer/SvgtViewerPlugin/ScreenSaverPluginSrc/SvgScreenSaver.cpp
branchRCL_3
changeset 20 5fd161fa28b6
parent 0 632761c941a7
equal deleted inserted replaced
17:e52958d06c29 20:5fd161fa28b6
       
     1 /*
       
     2 * Copyright (c) 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:  This file implements the SVGT Screen Saver Plugin which
       
    15 *                is used by Screen Saver application to display SVGT content
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <eikenv.h>
       
    21 #include <bautils.h>
       
    22 
       
    23 #include <aknnotewrappers.h> 
       
    24 #include <SVGTCustControl.h>
       
    25 #include <coecntrl.h>
       
    26 #include <SVGTUIDialog.hrh>
       
    27 #include <SVGTAppObserverUtil.h>
       
    28 #include "SvgScreenSaver.h"
       
    29 #include "SvgRenderFrameControl.h"
       
    30 
       
    31 _LIT( KSccSmilFitValue,"meet" );
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CSvgScreenSaver::CSvgScreenSaver
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CSvgScreenSaver::CSvgScreenSaver():iIsRenderFrameControl(ETrue),
       
    40                                    iLastError(KErrNone)
       
    41     {        
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSvgScreenSaver::~CSvgScreenSaver
       
    46 // -----------------------------------------------------------------------------
       
    47 //   
       
    48 CSvgScreenSaver::~CSvgScreenSaver()
       
    49     {
       
    50     iFileHandle.Close();
       
    51     delete iSvgControl;    
       
    52     }
       
    53     
       
    54 // -----------------------------------------------------------------------------
       
    55 // CSvgScreenSaver::SetRect
       
    56 // -----------------------------------------------------------------------------
       
    57 //    
       
    58 void CSvgScreenSaver::SetRect(const TRect& aRect)
       
    59     {
       
    60     iRect = aRect;
       
    61 
       
    62     if ( iIsRenderFrameControl )
       
    63         {
       
    64         if ( iSvgControl )
       
    65             {
       
    66             TInt index = STATIC_CAST(CSvgRenderFrameControl*, iSvgControl)->
       
    67                 GetCurrentIndex(); 
       
    68             delete iSvgControl;      
       
    69             iSvgControl = NULL;
       
    70             AsFile( iFileName );
       
    71             if ( iIsRenderFrameControl && iSvgControl )
       
    72                 {
       
    73                 STATIC_CAST(CSvgRenderFrameControl*, iSvgControl)->
       
    74                    SetCurrentIndex( index );                    
       
    75                 }
       
    76             }        
       
    77         }
       
    78     else
       
    79         {
       
    80         if ( iSvgControl )
       
    81             {
       
    82             iSvgControl->SetExtentToWholeScreen();
       
    83             }
       
    84         }        
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CSvgScreenSaver::SendCommandL
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CSvgScreenSaver::SendCommandL( TInt aCommand )
       
    92     {
       
    93     if ( !iSvgControl )
       
    94         {
       
    95         User::Leave( KErrGeneral );
       
    96         }
       
    97     if ( iIsRenderFrameControl )
       
    98         {
       
    99         STATIC_CAST(CSvgRenderFrameControl*, iSvgControl)->
       
   100                 ProcessViewerCommandL( aCommand );
       
   101         }
       
   102     else
       
   103         {
       
   104         STATIC_CAST(CSVGTCustControl*, iSvgControl)->
       
   105                 ProcessViewerCommandL( aCommand );
       
   106         }    
       
   107     }
       
   108     
       
   109 // -----------------------------------------------------------------------------
       
   110 // CSvgScreenSaver::MakeVisible
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CSvgScreenSaver::MakeVisible( TBool aVisible )
       
   114     {
       
   115     if ( iSvgControl )
       
   116         {
       
   117         iSvgControl->MakeVisible( aVisible );        
       
   118         }    
       
   119     }
       
   120  
       
   121 // -----------------------------------------------------------------------------
       
   122 // CSvgScreenSaver::GetLastError
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 TInt CSvgScreenSaver::GetLastError() const
       
   126     {
       
   127     return iLastError;
       
   128     }
       
   129 
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CSvgScreenSaver::FetchImage
       
   133 // -----------------------------------------------------------------------------
       
   134 //    
       
   135 TInt CSvgScreenSaver::FetchImage( const TDesC& aUri, RFs& aSession, 
       
   136                  RFile& aFileHandle )
       
   137     {
       
   138     CSVGTAppObserverUtil::TDownloadNeeded dnloadNeeded = 
       
   139                                      CSVGTAppObserverUtil::ELocalImageFile ;
       
   140     TRAPD( err, 
       
   141        dnloadNeeded = CSVGTAppObserverUtil::IsDownloadNeededL( aUri ));
       
   142     if ( err != KErrNone )
       
   143         {        
       
   144         return err;   
       
   145         }
       
   146     
       
   147            
       
   148     if ( CSVGTAppObserverUtil::ELocalImageFile == dnloadNeeded )
       
   149         {
       
   150                            
       
   151         TFileName fileName;    
       
   152         if ( CSVGTAppObserverUtil::GetLocalFile( aUri, fileName, iFileName ) )
       
   153             {
       
   154             return aFileHandle.Open( aSession, fileName, EFileShareAny );
       
   155             }
       
   156         else
       
   157             {
       
   158             return KErrNotFound;
       
   159             }
       
   160         }
       
   161     return KErrNotFound;
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CSvgScreenSaver::GetSmilFitValue
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CSvgScreenSaver::GetSmilFitValue(TDes& aSmilValue)
       
   169     {
       
   170     aSmilValue.Copy( KSccSmilFitValue );
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CSvgScreenSaver::NotifyL
       
   175 // -----------------------------------------------------------------------------
       
   176 //    
       
   177 TInt CSvgScreenSaver::NotifyL(TNotificationType /*aCallType*/, 
       
   178                                     void* /*aParam*/)
       
   179     {
       
   180     return KErrNone;
       
   181     }
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CSvgScreenSaver::ConstructL
       
   185 // -----------------------------------------------------------------------------
       
   186 //    
       
   187 void CSvgScreenSaver::ConstructL( const CCoeControl* aParent )
       
   188     { 
       
   189     iParent = aParent; 
       
   190     iEikEnv = CEikonEnv::Static();
       
   191     }
       
   192     
       
   193 // -----------------------------------------------------------------------------
       
   194 // CSvgScreenSaver::AsFile
       
   195 // -----------------------------------------------------------------------------
       
   196 //     
       
   197 TInt CSvgScreenSaver::AsFile(const TDesC& aFileName)
       
   198     {
       
   199     iFileName = aFileName;
       
   200     iLastError = iFileHandle.Open( iEikEnv->FsSession(), 
       
   201                                  aFileName, 
       
   202                                  EFileShareReadersOnly );
       
   203                                  
       
   204     if ( iLastError != KErrNone )
       
   205         {
       
   206         return iLastError;
       
   207         }
       
   208     TInt aSize = 0;
       
   209     iFileHandle.Size(aSize);
       
   210         
       
   211     if ( aSize > KMaxFileSize )
       
   212        {
       
   213             iLastError = KErrGeneral;
       
   214         }
       
   215                                      
       
   216     else
       
   217         {
       
   218             TRAP( iLastError,
       
   219             iSvgControl = CSvgRenderFrameControl::NewL( iParent, iFileHandle, this ) );    
       
   220         }                                   
       
   221             
       
   222     if ( iLastError != KErrNone )
       
   223         {
       
   224         iIsRenderFrameControl = EFalse;
       
   225         delete iSvgControl;
       
   226         iSvgControl = NULL;
       
   227      
       
   228         // reset iLastError
       
   229         iLastError = KErrNone;
       
   230 
       
   231         // Render Frames returned error
       
   232         TRAP( iLastError, 
       
   233           iSvgControl = CSVGTCustControl::NewL( iFileHandle,
       
   234                                               this,   // App Observer
       
   235                                               NULL,   // Progress Bar Draw Impl
       
   236                                               NULL,	  // MSK label Impl
       
   237                                               NULL,   // Exit Observer
       
   238                                               EFalse, // No Progressive Render
       
   239                                               iParent,
       
   240                                               ESvgWindowOwning ));
       
   241                                                
       
   242         if ( iSvgControl )
       
   243             {
       
   244             STATIC_CAST(CSVGTCustControl*, iSvgControl)->
       
   245                     SetCurrentFullScreenStatus( ETrue );
       
   246             // trigger a size changed event
       
   247             iSvgControl->SetExtentToWholeScreen();                    
       
   248             TRAP_IGNORE(STATIC_CAST(CSVGTCustControl*, iSvgControl)->
       
   249                     ProcessViewerCommandL(ESvgtDlgStopCommand));
       
   250             }          
       
   251         else
       
   252             {
       
   253             // Control is not created.
       
   254             iLastError = KErrGeneral;
       
   255             }
       
   256         } 
       
   257       
       
   258     iFileHandle.Close();
       
   259    
       
   260     return iLastError;
       
   261     
       
   262     }
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CSvgScreenSaver::LinkActivated
       
   266 // -----------------------------------------------------------------------------
       
   267 //  
       
   268 TBool CSvgScreenSaver::LinkActivated( const TDesC& /*aUri*/ )
       
   269     {
       
   270     return EFalse;
       
   271     }
       
   272 
       
   273         
       
   274 // -----------------------------------------------------------------------------
       
   275 // CSvgScreenSaver::LinkActivatedWithShow
       
   276 // -----------------------------------------------------------------------------
       
   277 // 
       
   278 TBool CSvgScreenSaver::LinkActivatedWithShow( const TDesC& /*aUri*/, 
       
   279                                               const TDesC& /*aShow*/ )
       
   280     {
       
   281     return EFalse;
       
   282     }
       
   283                
       
   284 // -----------------------------------------------------------------------------
       
   285 // CSvgScreenSaver::SetDownloadMenu
       
   286 // -----------------------------------------------------------------------------
       
   287 // 
       
   288 void CSvgScreenSaver::SetDownloadMenu( TBool /*aAddDownloadMenu*/ )
       
   289     {
       
   290     }
       
   291         
       
   292 // -----------------------------------------------------------------------------
       
   293 // CSvgScreenSaver::CanShowDownload
       
   294 // -----------------------------------------------------------------------------
       
   295 //   
       
   296 TBool CSvgScreenSaver::CanShowDownload() const
       
   297     {
       
   298     return EFalse;
       
   299     }       
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CSvgScreenSaver::DisplayDownloadMenuL
       
   303 // -----------------------------------------------------------------------------
       
   304 //  
       
   305 void CSvgScreenSaver::DisplayDownloadMenuL()
       
   306     {
       
   307     }
       
   308 // -----------------------------------------------------------------------------
       
   309 // CSvgScreenSaver::CanShowSave
       
   310 // -----------------------------------------------------------------------------
       
   311 // 
       
   312 TBool CSvgScreenSaver::CanShowSave()
       
   313     {
       
   314     return EFalse;
       
   315     }
       
   316         
       
   317 // -----------------------------------------------------------------------------
       
   318 // CSvgScreenSaver::IsSavingDone
       
   319 // -----------------------------------------------------------------------------
       
   320 // 
       
   321 TBool CSvgScreenSaver::IsSavingDone()
       
   322     {
       
   323     return EFalse;
       
   324     }
       
   325 
       
   326 // -----------------------------------------------------------------------------
       
   327 // CSvgScreenSaver::DoSaveL
       
   328 // -----------------------------------------------------------------------------
       
   329 //  
       
   330 void CSvgScreenSaver::DoSaveL( TInt /*aCommandId*/ )
       
   331     {
       
   332     }
       
   333 
       
   334 // -----------------------------------------------------------------------------
       
   335 // CSvgScreenSaver::NewFetchImageData
       
   336 // -----------------------------------------------------------------------------
       
   337 //  
       
   338 TInt CSvgScreenSaver::NewFetchImageData( const TDesC& /* aUri */ )
       
   339     {
       
   340     return KErrNone;
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CSvgScreenSaver::AssignEmbededDataL
       
   345 // -----------------------------------------------------------------------------
       
   346 //  
       
   347 void CSvgScreenSaver::AssignEmbededDataL( const TDesC& /*aUri*/ )
       
   348     {
       
   349     }
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CSvgScreenSaver::ExitWhenOrientationChange
       
   353 // -----------------------------------------------------------------------------
       
   354 //  
       
   355 TBool CSvgScreenSaver::ExitWhenOrientationChange()
       
   356     {
       
   357         return EFalse;
       
   358     }
       
   359 
       
   360 // End Of file.
       
   361