phonebookui/Phonebook2/UIControls/src/CPbk2ThumbnailLoader.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Phonebook 2 thumbnail loader.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2ThumbnailLoader.h"
       
    20 
       
    21 // Phonebook 2
       
    22 
       
    23 /// Virtual Phonebook
       
    24 #include <CVPbkContactManager.h>
       
    25 #include <MVPbkStoreContact.h>
       
    26 #include <MVPbkContactOperationBase.h>
       
    27 
       
    28 // Debugging headers
       
    29 #include <Pbk2Debug.h>
       
    30 
       
    31 
       
    32 /// Unnamed namespace for local definitions
       
    33 namespace {
       
    34 
       
    35 #ifdef _DEBUG
       
    36 enum TPanic
       
    37     {
       
    38     EPanicLogic_VPbkSingleContactOperationComplete,
       
    39     EPanicLogic_VPbkSingleContactOperationFailed
       
    40     };
       
    41 
       
    42 void Panic(TPanic aPanic)
       
    43     {
       
    44     _LIT(KPanicCat, "CPbk2ThumbnailLoader");
       
    45     User::Panic(KPanicCat, aPanic);
       
    46     }
       
    47 
       
    48 #endif // _DEBUG
       
    49 
       
    50 } /// namespace
       
    51 
       
    52 
       
    53 // --------------------------------------------------------------------------
       
    54 // CPbk2ThumbnailLoader::CPbk2ThumbnailLoader
       
    55 // --------------------------------------------------------------------------
       
    56 //
       
    57 CPbk2ThumbnailLoader::CPbk2ThumbnailLoader
       
    58         ( CVPbkContactManager& aContactManager ) :
       
    59             iContactManager( aContactManager )
       
    60     {
       
    61     }
       
    62 
       
    63 // --------------------------------------------------------------------------
       
    64 // CPbk2ThumbnailLoader::~CPbk2ThumbnailLoader
       
    65 // --------------------------------------------------------------------------
       
    66 //
       
    67 CPbk2ThumbnailLoader::~CPbk2ThumbnailLoader()
       
    68     {
       
    69     delete iThumbnailPopup;
       
    70     delete iStoreContact;
       
    71     delete iRetrieveOperation;
       
    72     }
       
    73 
       
    74 // --------------------------------------------------------------------------
       
    75 // CPbk2ThumbnailLoader::ConstructL
       
    76 // --------------------------------------------------------------------------
       
    77 //
       
    78 inline void CPbk2ThumbnailLoader::ConstructL()
       
    79     {
       
    80     iThumbnailPopup = CPbk2ThumbnailPopup::NewL( iContactManager );
       
    81     }
       
    82 
       
    83 // --------------------------------------------------------------------------
       
    84 // CPbk2ThumbnailLoader::NewL
       
    85 // --------------------------------------------------------------------------
       
    86 //
       
    87 EXPORT_C CPbk2ThumbnailLoader* CPbk2ThumbnailLoader::NewL
       
    88         ( CVPbkContactManager& aContactManager )
       
    89     {
       
    90     CPbk2ThumbnailLoader* self =
       
    91         new ( ELeave ) CPbk2ThumbnailLoader( aContactManager );
       
    92     CleanupStack::PushL( self );
       
    93     self->ConstructL();
       
    94     CleanupStack::Pop( self );
       
    95     return self;
       
    96     }
       
    97 
       
    98 // --------------------------------------------------------------------------
       
    99 // CPbk2ThumbnailLoader::LoadThumbnailL
       
   100 // --------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C void CPbk2ThumbnailLoader::LoadThumbnailL
       
   103         ( MVPbkContactLink* aContactLink, const CEikListBox* aListBox,
       
   104           TPbk2ThumbnailLocation aThumbnailLocation )
       
   105     {
       
   106     iListBox = aListBox;
       
   107     
       
   108     delete iRetrieveOperation;
       
   109     iRetrieveOperation = NULL;
       
   110     
       
   111     delete iThumbnailPopup;
       
   112     iThumbnailPopup = NULL;
       
   113     iThumbnailPopup = CPbk2ThumbnailPopup::NewL( iContactManager );
       
   114     
       
   115     if ( aContactLink )
       
   116         {
       
   117         iThumbnailPopup->SetThumbnailLocation( aThumbnailLocation );
       
   118         iRetrieveOperation = iContactManager.RetrieveContactL
       
   119             ( *aContactLink, *this );
       
   120         }
       
   121     }
       
   122 
       
   123 // --------------------------------------------------------------------------
       
   124 // CPbk2ThumbnailLoader::LoadThumbnail
       
   125 // --------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C void CPbk2ThumbnailLoader::LoadThumbnail
       
   128         ( MVPbkStoreContact* aStoreContact, const CEikListBox* aListBox,
       
   129           TPbk2ThumbnailLocation aThumbnailLocation )
       
   130     {
       
   131     iListBox = aListBox;
       
   132     
       
   133     delete iRetrieveOperation;
       
   134     iRetrieveOperation = NULL;
       
   135     
       
   136     delete iThumbnailPopup;
       
   137     iThumbnailPopup = NULL;
       
   138     TRAPD(err, iThumbnailPopup = CPbk2ThumbnailPopup::NewL( iContactManager ));
       
   139     
       
   140     if ( !err && aStoreContact )
       
   141         {
       
   142         iThumbnailPopup->SetThumbnailLocation( aThumbnailLocation );
       
   143         iThumbnailPopup->Load( *aStoreContact, *this, iListBox );
       
   144         }
       
   145     }
       
   146 
       
   147 // --------------------------------------------------------------------------
       
   148 // CPbk2ThumbnailLoader::HideThumbnail
       
   149 // --------------------------------------------------------------------------
       
   150 //
       
   151 EXPORT_C void CPbk2ThumbnailLoader::HideThumbnail()
       
   152     {
       
   153     iThumbnailPopup->HideAndCancel();
       
   154     delete iRetrieveOperation;
       
   155     iRetrieveOperation = NULL;
       
   156     }
       
   157 
       
   158 // --------------------------------------------------------------------------
       
   159 // CPbk2ThumbnailLoader::Refresh
       
   160 // --------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C void CPbk2ThumbnailLoader::Refresh()
       
   163     {
       
   164     iThumbnailPopup->Refresh();
       
   165     }
       
   166 
       
   167 // --------------------------------------------------------------------------
       
   168 // CPbk2ThumbnailLoader::Reset
       
   169 // --------------------------------------------------------------------------
       
   170 //
       
   171 EXPORT_C void CPbk2ThumbnailLoader::Reset()
       
   172     {
       
   173     // Cancel loading...
       
   174     HideThumbnail();
       
   175     // ...and destroy the contact
       
   176     delete iStoreContact;
       
   177     iStoreContact = NULL;
       
   178     }
       
   179 
       
   180 // --------------------------------------------------------------------------
       
   181 // CPbk2ThumbnailLoader::VPbkSingleContactOperationComplete
       
   182 // --------------------------------------------------------------------------
       
   183 //
       
   184 void CPbk2ThumbnailLoader::VPbkSingleContactOperationComplete
       
   185         ( MVPbkContactOperationBase& PBK2_DEBUG_ONLY ( aOperation ),
       
   186           MVPbkStoreContact* aContact )
       
   187     {
       
   188     __ASSERT_DEBUG( &aOperation == iRetrieveOperation,
       
   189         Panic( EPanicLogic_VPbkSingleContactOperationComplete ) );
       
   190 
       
   191     delete iRetrieveOperation;
       
   192     iRetrieveOperation = NULL;
       
   193 
       
   194     delete iStoreContact;
       
   195     iStoreContact = aContact;
       
   196 
       
   197     iThumbnailPopup->Load( *iStoreContact, *this, iListBox );
       
   198     }
       
   199 
       
   200 // --------------------------------------------------------------------------
       
   201 // CPbk2ThumbnailLoader::VPbkSingleContactOperationFailed
       
   202 // --------------------------------------------------------------------------
       
   203 //
       
   204 void CPbk2ThumbnailLoader::VPbkSingleContactOperationFailed
       
   205         ( MVPbkContactOperationBase& PBK2_DEBUG_ONLY( aOperation ),
       
   206           TInt /*aError*/ )
       
   207     {
       
   208     __ASSERT_DEBUG( &aOperation == iRetrieveOperation,
       
   209         Panic( EPanicLogic_VPbkSingleContactOperationFailed)  );
       
   210     }
       
   211 
       
   212 // --------------------------------------------------------------------------
       
   213 // CPbk2ThumbnailLoader::PopupLoadComplete
       
   214 // --------------------------------------------------------------------------
       
   215 //
       
   216 void CPbk2ThumbnailLoader::PopupLoadComplete()
       
   217     {
       
   218     // Do nothing
       
   219     }
       
   220 
       
   221 // --------------------------------------------------------------------------
       
   222 // CPbk2ThumbnailLoader::PopupLoadFailed
       
   223 // --------------------------------------------------------------------------
       
   224 //
       
   225 void CPbk2ThumbnailLoader::PopupLoadFailed( TInt /*aError*/ )
       
   226     {
       
   227     // Do nothing
       
   228     }
       
   229 
       
   230 // End of File