photosgallery/viewframework/dataprovider/src/glxmuliconprovider.cpp
changeset 0 4e91876724a2
child 18 bcb43dc84c44
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Provide Icon File Considering Requirement
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxmuliconprovider.h"               // Icon details
       
    22 #include <avkon.mbg>
       
    23 #include <e32math.h>                          // A collection of mathematical functions
       
    24 #include <glxicons.mbg>
       
    25 #include "glxdrmutility.h"                   // DRM utility class to provide DRM-related functionality 
       
    26 #include "glxmedia.h"                        // Reference to a media item in the item pool
       
    27 #include <glxlog.h>                          // Logging
       
    28 #include <lbsposition.h> // TCoordinate
       
    29 #include <pathinfo.h> 
       
    30 #include <driveinfo.h> // Added for DriveInfo class
       
    31 #include <data_caging_path_literals.hrh>
       
    32 #include <glxtracer.h>
       
    33 #include <glxerrormanager.h>
       
    34 #include <glxthumbnailattributeinfo.h>
       
    35 
       
    36 _LIT(KGlxIconsFilename, "glxicons.mif");
       
    37 
       
    38 // ----------------------------------------------------------------------------
       
    39 // ConstructL
       
    40 // ----------------------------------------------------------------------------
       
    41 //
       
    42 void CGlxMulIconProvider::ConstructL()
       
    43     {
       
    44     TRACER("CGlxMulIconProvider::ConstructL");
       
    45     iResFileName.Copy(KDC_APP_BITMAP_DIR);
       
    46     iResFileName.Append(KGlxIconsFilename);
       
    47     //iResFileName.Copy(resFile);
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // ResourceFileName
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 const TDesC& CGlxMulIconProvider::ResourceFileName() const
       
    55     {
       
    56     TRACER("CGlxMulIconProvider::ResourceFileName");
       
    57     return iResFileName;
       
    58     }
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // NewL
       
    62 // ----------------------------------------------------------------------------
       
    63 //   
       
    64 EXPORT_C CGlxMulLocationIconProvider* CGlxMulLocationIconProvider::NewL( ) 
       
    65     {
       
    66     TRACER("CGlxMulLocationIconProvider::NewL");
       
    67     CGlxMulLocationIconProvider* self = new (ELeave) CGlxMulLocationIconProvider();
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL(  );
       
    70     CleanupStack::Pop( self );
       
    71     return self;
       
    72     }
       
    73  
       
    74 // ----------------------------------------------------------------------------
       
    75 // Destructor
       
    76 // ----------------------------------------------------------------------------
       
    77 //   
       
    78 CGlxMulLocationIconProvider::~CGlxMulLocationIconProvider()
       
    79 	{
       
    80 	
       
    81 	}
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // NewL
       
    85 // ----------------------------------------------------------------------------
       
    86 //   
       
    87 EXPORT_C CGlxMulDriveIconProvider* CGlxMulDriveIconProvider::NewL( )
       
    88     {
       
    89     TRACER("CGlxMulDriveIconProvider::NewL");
       
    90     CGlxMulDriveIconProvider* self = new (ELeave) CGlxMulDriveIconProvider();
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL( );
       
    93     CleanupStack::Pop( self );
       
    94     return self;
       
    95     }
       
    96 // ----------------------------------------------------------------------------
       
    97 // Destructor
       
    98 // ----------------------------------------------------------------------------
       
    99 //   
       
   100 CGlxMulDriveIconProvider::~CGlxMulDriveIconProvider()
       
   101 	{
       
   102 	
       
   103 	}
       
   104 
       
   105 // ----------------------------------------------------------------------------
       
   106 // IconIdL
       
   107 // ----------------------------------------------------------------------------
       
   108 //   
       
   109 TInt CGlxMulLocationIconProvider::IconIdL( const TGlxMedia& aMedia ) const
       
   110     {
       
   111     TRACER("CGlxMulLocationIconProvider::IconIdL");
       
   112     const CGlxMedia* media = aMedia.Properties();
       
   113     if( media->IsSupported( KGlxMediaGeneralLocation ) )
       
   114         {
       
   115         TCoordinate cordinate = media->ValueTObject<TCoordinate>(KGlxMediaGeneralLocation);	 
       
   116         //Check for valid co-ordinates
       
   117         if( (!Math::IsNaN(cordinate.Latitude())) && (!Math::IsNaN(cordinate.Longitude())) ) 
       
   118             {
       
   119             return EMbmGlxiconsQgn_indi_cam4_geotag_on;
       
   120             }
       
   121       }
       
   122      return EMbmAvkonQgn_note_empty;
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // IconIdL
       
   127 // ----------------------------------------------------------------------------
       
   128 //   
       
   129 TInt CGlxMulDriveIconProvider::IconIdL( const TGlxMedia& aMedia ) const
       
   130     {
       
   131 
       
   132     TRACER("CGlxMulDriveIconProvider::IconIdL");
       
   133     // by default set icon for internal mass storage
       
   134     const CGlxMedia* media = aMedia.Properties();
       
   135     TInt iconId= EMbmGlxiconsQgn_indi_fmgr_ms_add;
       
   136     if( media->IsSupported( KMPXMediaGeneralDrive ) )
       
   137         {
       
   138     const TDesC& drive =  media->ValueText(KMPXMediaGeneralDrive);
       
   139     if(0 == drive.CompareF(
       
   140     PathInfo::PhoneMemoryRootPath().Left( KMaxDriveName )))
       
   141         {
       
   142         // in phone memory
       
   143         iconId = EMbmGlxiconsQgn_indi_phone_add;
       
   144         }
       
   145     else 
       
   146         {
       
   147         RFs fsSession;
       
   148         User::LeaveIfError(fsSession.Connect());
       
   149         TUint drvStatus( 0 );
       
   150         TDriveUnit driveNumber(drive);
       
   151         User::LeaveIfError(DriveInfo::GetDriveStatus
       
   152         ( fsSession, driveNumber, drvStatus ) );
       
   153         // To get the entire status of the Drive as "drvStatus"
       
   154         fsSession.Close();
       
   155         if(drvStatus & DriveInfo::EDriveRemovable)
       
   156         // Do a AND operation to check that the status of the drive is "Removable" or not
       
   157             {
       
   158             // in mmc memory
       
   159             iconId = EMbmGlxiconsQgn_indi_mmc_add;
       
   160                 }
       
   161             }
       
   162         }
       
   163     return iconId;    
       
   164     }
       
   165 
       
   166 // ----------------------------------------------------------------------------
       
   167 // Constructor
       
   168 // ----------------------------------------------------------------------------
       
   169 //   
       
   170 CGlxMulStaticIconProvider::CGlxMulStaticIconProvider(TInt aResourceIconId)
       
   171     {
       
   172     TRACER("CGlxMulStaticIconProvider::CGlxMulStaticIconProvider");
       
   173     iIconId = aResourceIconId;
       
   174     
       
   175     }
       
   176 
       
   177 // ----------------------------------------------------------------------------
       
   178 // NewL
       
   179 // ----------------------------------------------------------------------------
       
   180 //   
       
   181 EXPORT_C CGlxMulStaticIconProvider* CGlxMulStaticIconProvider::NewL(TInt aResourceIconId )
       
   182     {
       
   183     TRACER("CGlxMulStaticIconProvider::NewL");
       
   184     CGlxMulStaticIconProvider* self = new (ELeave) CGlxMulStaticIconProvider(aResourceIconId);
       
   185     CleanupStack::PushL( self );
       
   186     self->ConstructL();
       
   187     CleanupStack::Pop( self );
       
   188     return self;
       
   189     }
       
   190 
       
   191 // ----------------------------------------------------------------------------
       
   192 // IconIdL
       
   193 // ----------------------------------------------------------------------------
       
   194 //   
       
   195 TInt CGlxMulStaticIconProvider::IconIdL(const TGlxMedia& /*aMedia*/ ) const
       
   196     {
       
   197     TRACER("CGlxMulStaticIconProvider::IconIdL");
       
   198     return iIconId;
       
   199     }
       
   200 
       
   201 //-----------------------------------------------------------------------------
       
   202 
       
   203 // ----------------------------------------------------------------------------
       
   204 // Constructor
       
   205 // ----------------------------------------------------------------------------
       
   206 //  
       
   207 CGlxMulDRMIconProvider::CGlxMulDRMIconProvider()
       
   208     {
       
   209     
       
   210     }
       
   211     
       
   212 // ----------------------------------------------------------------------------
       
   213 // Destructor
       
   214 // ----------------------------------------------------------------------------
       
   215 //   
       
   216 CGlxMulDRMIconProvider::~CGlxMulDRMIconProvider()
       
   217     {
       
   218     TRACER("CGlxMulDRMIconProvider::~CGlxMulDRMIconProvider");
       
   219     if(iDRMUtility)
       
   220         {
       
   221     iDRMUtility->Close();    // Memory Leak Fix
       
   222     }
       
   223     }
       
   224 
       
   225 
       
   226     
       
   227 // ----------------------------------------------------------------------------
       
   228 // NewL
       
   229 // ----------------------------------------------------------------------------
       
   230 //   
       
   231 EXPORT_C CGlxMulDRMIconProvider* CGlxMulDRMIconProvider::NewL( )
       
   232     {
       
   233     TRACER("CGlxMulDRMIconProvider::NewL");
       
   234     CGlxMulDRMIconProvider* self = new (ELeave) CGlxMulDRMIconProvider;
       
   235     CleanupStack::PushL( self );
       
   236     self->ConstructL();
       
   237     CleanupStack::Pop( self );
       
   238     return self;
       
   239     }
       
   240 
       
   241 // ----------------------------------------------------------------------------
       
   242 // ConstructL
       
   243 // ----------------------------------------------------------------------------
       
   244 // 
       
   245 void CGlxMulDRMIconProvider::ConstructL()
       
   246     {
       
   247     TRACER("CGlxMulDRMIconProvider::ConstructL");
       
   248     iDRMUtility = CGlxDRMUtility::InstanceL();
       
   249     iIconId = EMbmAvkonQgn_note_empty;
       
   250     iMifFileName.Copy( KDC_APP_BITMAP_DIR );
       
   251     iMifFileName.Append( KGlxIconsFilename );
       
   252     }
       
   253     
       
   254 // ----------------------------------------------------------------------------
       
   255 // IconIdL
       
   256 // ----------------------------------------------------------------------------
       
   257 //   
       
   258 TInt CGlxMulDRMIconProvider::IconIdL(const TGlxMedia& aMedia/**/ ) const
       
   259     {
       
   260     TRACER("CGlxMulDRMIconProvider::IconIdL");
       
   261     if( aMedia.IsDrmProtected() )
       
   262         {
       
   263         const TDesC& uri = aMedia.Uri();
       
   264         if( uri.Length() > 0)
       
   265             {
       
   266             if(iDRMUtility->IsForwardLockedL(uri))
       
   267                 {
       
   268                 return EMbmGlxiconsQgn_prop_drm_rights_valid_super;
       
   269                 }
       
   270             else 
       
   271                 {
       
   272                 TMPXGeneralCategory  cat = aMedia.Category();                  
       
   273                 TBool checkViewRights = (cat==EMPXImage);
       
   274                 
       
   275                 if(iDRMUtility->CheckOpenRightsL(uri, checkViewRights))
       
   276                         {
       
   277                         return EMbmGlxiconsQgn_prop_drm_rights_valid_super;        
       
   278                         }
       
   279                      else
       
   280                         {
       
   281                         return EMbmGlxiconsQgn_prop_drm_rights_exp_super;
       
   282                         }
       
   283                 }
       
   284             }
       
   285         }
       
   286     
       
   287     return iIconId;
       
   288     }
       
   289 
       
   290 // ----------------------------------------------------------------------------
       
   291 // ResourceFileName
       
   292 // ----------------------------------------------------------------------------
       
   293 //   
       
   294 const TDesC& CGlxMulDRMIconProvider::ResourceFileName() const
       
   295     {
       
   296     TRACER("CGlxMulDRMIconProvider::ResourceFileName");
       
   297     return iMifFileName;
       
   298     }
       
   299 
       
   300     
       
   301 // ----------------------------------------------------------------------------
       
   302 // Constructor
       
   303 // ----------------------------------------------------------------------------
       
   304 //  
       
   305 CGlxMulVideoIconProvider::CGlxMulVideoIconProvider(TBool aIsFullscreen)
       
   306 	: iIsFullscreen(aIsFullscreen)
       
   307     {
       
   308     
       
   309     }
       
   310     
       
   311 // ----------------------------------------------------------------------------
       
   312 // Destructor
       
   313 // ----------------------------------------------------------------------------
       
   314 //   
       
   315 CGlxMulVideoIconProvider::~CGlxMulVideoIconProvider()
       
   316     {
       
   317     TRACER("CGlxMulVideoIconProvider::~CGlxMulVideoIconProviderr");
       
   318     }
       
   319 
       
   320 
       
   321     
       
   322 // ----------------------------------------------------------------------------
       
   323 // NewL
       
   324 // ----------------------------------------------------------------------------
       
   325 //   
       
   326 EXPORT_C CGlxMulVideoIconProvider* CGlxMulVideoIconProvider::NewL(TBool aIsFullscreen)
       
   327     {
       
   328     TRACER("CGlxMulVideoIconProvider::NewL");
       
   329     CGlxMulVideoIconProvider* self = new (ELeave) CGlxMulVideoIconProvider(aIsFullscreen);
       
   330     CleanupStack::PushL( self );
       
   331     self->ConstructL();
       
   332     CleanupStack::Pop( self );
       
   333     return self;
       
   334     }
       
   335 
       
   336 // ----------------------------------------------------------------------------
       
   337 // ConstructL
       
   338 // ----------------------------------------------------------------------------
       
   339 // 
       
   340 void CGlxMulVideoIconProvider::ConstructL()
       
   341     {
       
   342     TRACER("CGlxMulVideoIconProvider::ConstructL");
       
   343     iIconId = EMbmAvkonQgn_note_empty;
       
   344     iMifFileName.Copy( KDC_APP_BITMAP_DIR );
       
   345     iMifFileName.Append( KGlxIconsFilename );
       
   346     }
       
   347     
       
   348 // ----------------------------------------------------------------------------
       
   349 // IconIdL
       
   350 // ----------------------------------------------------------------------------
       
   351 //   
       
   352 TInt CGlxMulVideoIconProvider::IconIdL(const TGlxMedia& aMedia) const
       
   353     {
       
   354     TRACER("CGlxMulVideoIconProvider::IconIdL");
       
   355         
       
   356     if((aMedia.Category() == EMPXVideo) && (GlxErrorManager::HasAttributeErrorL(aMedia.Properties(), KGlxMediaIdThumbnail ) == KErrNone))
       
   357         {
       
   358 		if (iIsFullscreen)
       
   359             {                       	        	
       
   360 		    return EMbmGlxiconsQgn_indi_media_fullscreen_play;			                
       
   361             }        
       
   362     	return EMbmGlxiconsQgn_indi_media_thumbnail;      
       
   363         }   
       
   364     return iIconId;
       
   365     }
       
   366 
       
   367 // ----------------------------------------------------------------------------
       
   368 // ResourceFileName
       
   369 // ----------------------------------------------------------------------------
       
   370 //   
       
   371 const TDesC& CGlxMulVideoIconProvider::ResourceFileName() const
       
   372     {
       
   373     TRACER("CGlxMulVideoIconProvider::ResourceFileName");
       
   374     return iMifFileName;
       
   375     }
       
   376 
       
   377