videocollection/hgmyvideos/src/vcxhgmyvideosthumbnailmanager.cpp
branchRCL_3
changeset 8 ce5ada96ab30
equal deleted inserted replaced
6:7d91903f795f 8:ce5ada96ab30
       
     1 /*
       
     2 * Copyright (c) 2008 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 the License "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 sharing thumbnailmanager session
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <thumbnailmanager.h>
       
    20 #include <thumbnailmanagerobserver.h>
       
    21 #include "vcxhgmyvideosthumbnailmanager.h"
       
    22 
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CVcxHgMyVideosThumbnailManager::NewL()
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CVcxHgMyVideosThumbnailManager* CVcxHgMyVideosThumbnailManager::NewL()
       
    31     {
       
    32     CVcxHgMyVideosThumbnailManager* self = 
       
    33         CVcxHgMyVideosThumbnailManager::NewLC();
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CVcxHgMyVideosThumbnailManager::NewLC()
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CVcxHgMyVideosThumbnailManager* CVcxHgMyVideosThumbnailManager::NewLC()
       
    43     {
       
    44     CVcxHgMyVideosThumbnailManager* self = 
       
    45         new (ELeave) CVcxHgMyVideosThumbnailManager();
       
    46     CleanupStack::PushL( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CVcxHgMyVideosThumbnailManager::~CVcxHgMyVideosThumbnailManager()
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CVcxHgMyVideosThumbnailManager::~CVcxHgMyVideosThumbnailManager()
       
    55     {
       
    56     iTnObservers.Reset(); // The pointers are not own
       
    57     delete iTnManager;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CVcxHgMyVideosThumbnailManager::PeekL()
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 TThumbnailRequestId CVcxHgMyVideosThumbnailManager::PeekL(
       
    65     CThumbnailObjectSource& aSource )
       
    66     {
       
    67     CThumbnailManager& tnm = SessionL();
       
    68 
       
    69     // Set 'do not create' if needed
       
    70     if ( !( iCurrentFlags & CThumbnailManager::EDoNotCreate ) )
       
    71         {
       
    72         CThumbnailManager::TThumbnailFlags flags =
       
    73             static_cast< CThumbnailManager::TThumbnailFlags >(
       
    74                 iCurrentFlags | CThumbnailManager::EDoNotCreate );
       
    75         tnm.SetFlagsL( flags );
       
    76         iCurrentFlags = flags;
       
    77         }
       
    78 
       
    79     return tnm.GetThumbnailL( aSource );
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CVcxHgMyVideosThumbnailManager::GetL()
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 TThumbnailRequestId CVcxHgMyVideosThumbnailManager::GetL(
       
    87     CThumbnailObjectSource& aSource )
       
    88     {
       
    89     CThumbnailManager& tnm = SessionL();
       
    90 
       
    91     // Remove 'do not create' if needed
       
    92     if ( iCurrentFlags & CThumbnailManager::EDoNotCreate )
       
    93         {
       
    94         CThumbnailManager::TThumbnailFlags flags =
       
    95             static_cast< CThumbnailManager::TThumbnailFlags >(
       
    96                 iCurrentFlags & (~CThumbnailManager::EDoNotCreate) );
       
    97         tnm.SetFlagsL( flags );
       
    98         iCurrentFlags = flags;
       
    99         }
       
   100 
       
   101     return tnm.GetThumbnailL( aSource );
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CVcxHgMyVideosThumbnailManager::Cancel()
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CVcxHgMyVideosThumbnailManager::Cancel( TThumbnailRequestId aRequestId )
       
   109     {
       
   110     if ( iTnManager )
       
   111         {
       
   112         iTnManager->CancelRequest( aRequestId );
       
   113         }
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CVcxHgMyVideosThumbnailManager::AddObserverL()
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CVcxHgMyVideosThumbnailManager::AddObserverL(
       
   121         MThumbnailManagerObserver& aObserver )
       
   122     {
       
   123     iTnObservers.InsertInAddressOrderL( &aObserver );
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CVcxHgMyVideosThumbnailManager::RemoveObserver()
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CVcxHgMyVideosThumbnailManager::RemoveObserver(
       
   131         MThumbnailManagerObserver& aObserver )
       
   132     {
       
   133     TInt i = iTnObservers.FindInAddressOrder( &aObserver );
       
   134     if ( i >= 0 && i < iTnObservers.Count() )
       
   135         {
       
   136         iTnObservers.Remove( i ); // Pointer is not own
       
   137         }
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CVcxHgMyVideosThumbnailManager::ThumbnailPreviewReady()
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CVcxHgMyVideosThumbnailManager::ThumbnailPreviewReady(
       
   145         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
       
   146     {
       
   147     // No implementation required.
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CVcxHgMyVideosThumbnailManager::ThumbnailReady()
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CVcxHgMyVideosThumbnailManager::ThumbnailReady( TInt aError,
       
   155         MThumbnailData& aThumbnail, TThumbnailRequestId aId )
       
   156     {
       
   157     TInt count = iTnObservers.Count();
       
   158     for( TInt i = 0; i < count; ++i )
       
   159         {
       
   160         iTnObservers[i]->ThumbnailReady( aError, aThumbnail, aId );
       
   161         }
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CVcxHgMyVideosThumbnailManager::CVcxHgMyVideosThumbnailManager()
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 CVcxHgMyVideosThumbnailManager::CVcxHgMyVideosThumbnailManager()
       
   169     {
       
   170     // No implementation required.
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CVcxHgMyVideosThumbnailManager::SessionL()
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 CThumbnailManager& CVcxHgMyVideosThumbnailManager::SessionL()
       
   178     {
       
   179     if ( !iTnManager )
       
   180         {
       
   181         CThumbnailManager* tnm = CThumbnailManager::NewLC( *this );
       
   182         tnm->SetThumbnailSizeL( EVideoListThumbnailSize );
       
   183         tnm->SetDisplayModeL( EColor16M );
       
   184         iCurrentFlags = tnm->Flags();
       
   185         CleanupStack::Pop( tnm );
       
   186         iTnManager = tnm;
       
   187         }
       
   188     return *iTnManager;
       
   189     }