imagehandling_plat/thumbnailmanager_api/tsrc/src/thumbnailcenrep.cpp
changeset 0 2014ca87e772
child 30 b67379558a75
child 38 2b4b06654caa
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Class for handling central repositoty data
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <centralrepository.h>
       
    20 #include <thumbnailmanager.h>
       
    21 
       
    22 #include "thumbnailcenrep.h"
       
    23 
       
    24 
       
    25 #define THUMBNAIL_CENREP_UID 0x102830B0
       
    26 
       
    27 const TUint32 KSizeImageGridWidth = 0x0;
       
    28 const TUint32 KSizeImageGridHeight = 0x1;
       
    29 const TUint32 KSizeImageListWidth = 0x2;
       
    30 const TUint32 KSizeImageListHeight = 0x3;
       
    31 const TUint32 KSizeImageFullscreenWidth = 0x4;
       
    32 const TUint32 KSizeImageFullscreenHeight = 0x5;
       
    33 const TUint32 KSizeVideoGridWidth = 0x6;
       
    34 const TUint32 KSizeVideoGridHeight = 0x7;
       
    35 const TUint32 KSizeVideoListWidth = 0x8;
       
    36 const TUint32 KSizeVideoListHeight = 0x9;
       
    37 const TUint32 KSizeVideoFullscreenWidth = 0x10;
       
    38 const TUint32 KSizeVideoFullscreenHeight = 0x11;
       
    39 const TUint32 KSizeAudioGridWidth = 0x12;
       
    40 const TUint32 KSizeAudioGridHeight = 0x13;
       
    41 const TUint32 KSizeAudioListWidth = 0x14;
       
    42 const TUint32 KSizeAudioListHeight = 0x15;
       
    43 const TUint32 KSizeAudioFullscreenWidth = 0x16;
       
    44 const TUint32 KSizeAudioFullscreenHeight = 0x17;
       
    45 
       
    46 const TUint32 KAutoCreateImageGrid = 0x100;
       
    47 const TUint32 KAutoCreateImageList = 0x101;
       
    48 const TUint32 KAutoCreateImageFullscreen = 0x102;
       
    49 const TUint32 KAutoCreateVideoGrid = 0x103;
       
    50 const TUint32 KAutoCreateVideoList = 0x104;
       
    51 const TUint32 KAutoCreateVideoFullscreen = 0x105;
       
    52 const TUint32 KAutoCreateAudioGrid = 0x106;
       
    53 const TUint32 KAutoCreateAudioList = 0x107;
       
    54 const TUint32 KAutoCreateAudioFullscreen = 0x108;
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // TThumbnailPersistentSize::TThumbnailPersistentSize
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 TThumbnailPersistentSize::TThumbnailPersistentSize( const TSize& aSize, TBool
       
    62     aCrop, TDisplayMode aMode, TInt aFormat ): iSize( aSize ), iCrop( aCrop ),
       
    63     iMode( aMode ), iFormat( aFormat )
       
    64     {
       
    65     iType = EUnknownThumbnailSize;
       
    66     iSourceType = EUnknownSourceType;
       
    67     iAutoCreate = ETrue;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // TThumbnailPersistentSize::TThumbnailPersistentSize
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 TThumbnailPersistentSize::TThumbnailPersistentSize( TThumbnailSize aType,
       
    75     const TSize& aSize, TBool aCrop, TDisplayMode aMode, TInt aFormat,
       
    76     TBool aAutoCreate )
       
    77     : iType( aType ), iSize( aSize ), iCrop( aCrop ), iMode( aMode ),
       
    78       iFormat( aFormat ), iAutoCreate( aAutoCreate )
       
    79     {
       
    80     switch ( aType )
       
    81         {        
       
    82         case EImageGridThumbnailSize:
       
    83         case EImageListThumbnailSize:
       
    84         case EImageFullScreenThumbnailSize:
       
    85             iSourceType = EImage;
       
    86             break;
       
    87         case EVideoGridThumbnailSize:
       
    88         case EVideoListThumbnailSize:
       
    89         case EVideoFullScreenThumbnailSize:  
       
    90             iSourceType = EVideo;
       
    91             break;
       
    92         case EAudioGridThumbnailSize:
       
    93         case EAudioListThumbnailSize:
       
    94         case EAudioFullScreenThumbnailSize:
       
    95             iSourceType = EAudio;
       
    96             break;
       
    97         default:
       
    98             iSourceType = EUnknownSourceType;        
       
    99         }
       
   100 
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // TThumbnailAutoCreate::TThumbnailAutoCreate
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 TThumbnailAutoCreate::TThumbnailAutoCreate()
       
   108     : iImageGrid(EFalse), iImageList(EFalse), iImageFullscreen(EFalse),
       
   109       iVideoGrid(EFalse), iVideoList(EFalse), iVideoFullscreen(EFalse),
       
   110       iAudioGrid(EFalse), iAudioList(EFalse), iAudioFullscreen(EFalse)
       
   111     {
       
   112     // No implementation required
       
   113     }
       
   114 
       
   115 // ======== MEMBER FUNCTIONS ========
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CThumbnailCenRep::CThumbnailCenRep()
       
   119 // C++ default constructor can NOT contain any code, that might leave.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CThumbnailCenRep::CThumbnailCenRep()
       
   123     {
       
   124     // No implementation required
       
   125     }
       
   126 
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CThumbnailCenRep::~CThumbnailCenRep()
       
   130 // Destructor.
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 CThumbnailCenRep::~CThumbnailCenRep()
       
   134     {
       
   135     iPersistentSizes.Close();
       
   136     delete iAutoCreate;
       
   137     delete iRepository;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CThumbnailCenRep::NewL()
       
   142 // Two-phased constructor.
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 CThumbnailCenRep* CThumbnailCenRep::NewL()
       
   146     {
       
   147     CThumbnailCenRep* self = new( ELeave )CThumbnailCenRep();
       
   148     CleanupStack::PushL( self );
       
   149     self->ConstructL();
       
   150     CleanupStack::Pop( self );
       
   151     return self;
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // CThumbnailCenRep::ConstructL()
       
   156 // Returns id of specific task.
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 void CThumbnailCenRep::ConstructL()
       
   160     {
       
   161     iRepository = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID ));
       
   162 
       
   163     TInt xSize( 0 );
       
   164     TInt ySize( 0 );
       
   165     TBool flags( EFalse );
       
   166     const TBool KGridAndListThumbnailCropped = ETrue; 
       
   167     TInt raw_mode( EColor16M ); // always 16-bit
       
   168     TInt format( 0 );
       
   169     TBool autoCreate( EFalse );
       
   170     
       
   171     User::LeaveIfError( iRepository->Get( KSizeImageGridWidth, xSize ));
       
   172     User::LeaveIfError( iRepository->Get( KSizeImageGridHeight, ySize ));
       
   173     User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, autoCreate ));
       
   174 
       
   175     iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageGridThumbnailSize, TSize( xSize, ySize ),
       
   176             KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   177 
       
   178     User::LeaveIfError( iRepository->Get( KSizeImageListWidth, xSize ));
       
   179     User::LeaveIfError( iRepository->Get( KSizeImageListHeight, ySize ));
       
   180     User::LeaveIfError( iRepository->Get( KAutoCreateImageList, autoCreate ));
       
   181 
       
   182     iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageListThumbnailSize, TSize( xSize, ySize ),
       
   183             KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   184     
       
   185     User::LeaveIfError( iRepository->Get( KSizeImageFullscreenWidth, xSize ));
       
   186     User::LeaveIfError( iRepository->Get( KSizeImageFullscreenHeight, ySize ));
       
   187     User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, autoCreate ));
       
   188     
       
   189     iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageFullScreenThumbnailSize, TSize( xSize, ySize ),
       
   190                               flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   191     
       
   192     User::LeaveIfError( iRepository->Get( KSizeVideoGridWidth, xSize ));
       
   193     User::LeaveIfError( iRepository->Get( KSizeVideoGridHeight, ySize ));
       
   194     User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, autoCreate ));
       
   195 
       
   196     iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoGridThumbnailSize, TSize( xSize, ySize ),
       
   197             KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   198 
       
   199     User::LeaveIfError( iRepository->Get( KSizeVideoListWidth, xSize ));
       
   200     User::LeaveIfError( iRepository->Get( KSizeVideoListHeight, ySize ));
       
   201     User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, autoCreate ));
       
   202 
       
   203     iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoListThumbnailSize, TSize( xSize, ySize ),
       
   204             KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   205     
       
   206     User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenWidth, xSize ));
       
   207     User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenHeight, ySize ));
       
   208     User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, autoCreate ));
       
   209     
       
   210     iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoFullScreenThumbnailSize, TSize( xSize, ySize ),
       
   211                               flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));  
       
   212     
       
   213     User::LeaveIfError( iRepository->Get( KSizeAudioGridWidth, xSize ));
       
   214     User::LeaveIfError( iRepository->Get( KSizeAudioGridHeight, ySize ));
       
   215     User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, autoCreate ));
       
   216 
       
   217     iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioGridThumbnailSize, TSize( xSize, ySize ),
       
   218             KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   219 
       
   220     User::LeaveIfError( iRepository->Get( KSizeAudioListWidth, xSize ));
       
   221     User::LeaveIfError( iRepository->Get( KSizeAudioListHeight, ySize ));
       
   222     User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, autoCreate ));
       
   223 
       
   224     iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioListThumbnailSize, TSize( xSize, ySize ),
       
   225             KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));
       
   226     
       
   227     User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenWidth, xSize ));
       
   228     User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenHeight, ySize ));
       
   229     User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, autoCreate ));
       
   230     
       
   231     iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioFullScreenThumbnailSize, TSize( xSize, ySize ),
       
   232                               flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate ));     
       
   233     
       
   234     iAutoCreate = new (ELeave) TThumbnailAutoCreate();
       
   235     
       
   236     User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, iAutoCreate->iImageGrid ));
       
   237     User::LeaveIfError( iRepository->Get( KAutoCreateImageList, iAutoCreate->iImageList ));
       
   238     User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, iAutoCreate->iImageFullscreen ));
       
   239     User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, iAutoCreate->iVideoGrid ));
       
   240     User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, iAutoCreate->iVideoList ));
       
   241     User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, iAutoCreate->iVideoFullscreen ));
       
   242     User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, iAutoCreate->iAudioGrid ));
       
   243     User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, iAutoCreate->iAudioList ));
       
   244     User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, iAutoCreate->iAudioFullscreen ));    
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 // CThumbnailCenRep::GetPersistentSizes()
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 RArray < TThumbnailPersistentSize > & CThumbnailCenRep::GetPersistentSizes()
       
   252     {
       
   253     return iPersistentSizes;
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // CThumbnailCenRep::GetAutoCreateParams()
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 TThumbnailAutoCreate & CThumbnailCenRep::GetAutoCreateParams()
       
   261     {
       
   262     return *iAutoCreate;
       
   263     }
       
   264 
       
   265 TThumbnailPersistentSize & CThumbnailCenRep::PersistentSizeL( TThumbnailSize
       
   266         aThumbnailSize )
       
   267     {
       
   268     TThumbnailPersistentSize* persistentSize = NULL;
       
   269     TInt i = iPersistentSizes.Count();
       
   270     for ( ; --i >= 0; )
       
   271         {
       
   272         persistentSize = &iPersistentSizes[i];
       
   273         if ( persistentSize->iType == aThumbnailSize )
       
   274             {
       
   275             break;
       
   276             }
       
   277         }
       
   278     if ( i < 0 )
       
   279         { // size not found
       
   280         User::Leave( KErrNotFound );
       
   281         }
       
   282     
       
   283     return *persistentSize;
       
   284     }
       
   285 
       
   286 // End of file