phonebookui/Phonebook/View/src/CPbkThumbnailManager.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *       Provides Phonebook thumbnail manager methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkThumbnailManager.h"  // This class
       
    22 #include "MPbkThumbnailOperationObservers.h"
       
    23 #include "CPbkThumbnailManagerImpl.h"
       
    24 #include "TPbkImageLoadParameters.h"
       
    25 
       
    26 #include <CPbkContactEngine.h>
       
    27 #include <CPbkContactItem.h>
       
    28 #include <TPbkContactItemField.h>
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 inline CPbkThumbnailManager::CPbkThumbnailManager
       
    33         (CPbkContactEngine& aEngine) :
       
    34     iEngine(aEngine)
       
    35     {
       
    36     }
       
    37 
       
    38 inline void CPbkThumbnailManager::ConstructL()
       
    39     {
       
    40     }
       
    41 
       
    42 EXPORT_C CPbkThumbnailManager* CPbkThumbnailManager::NewL(CPbkContactEngine& aEngine)
       
    43     {
       
    44     CPbkThumbnailManager* self = new(ELeave) CPbkThumbnailManager(aEngine);
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop(self); 
       
    48     return self;
       
    49     }
       
    50 
       
    51 CPbkThumbnailManager::~CPbkThumbnailManager()
       
    52     {
       
    53     }
       
    54 
       
    55 EXPORT_C MPbkThumbnailOperation* CPbkThumbnailManager::GetThumbnailAsyncL
       
    56         (MPbkThumbnailGetObserver& aObserver, 
       
    57         const CPbkContactItem& aContactItem)
       
    58     {
       
    59     MPbkThumbnailReader* reader = PbkThumbnailOperationFactory::CreateReaderLC
       
    60         (aContactItem, aObserver);
       
    61     if (reader)
       
    62         {
       
    63         reader->StartReadL();
       
    64         CleanupStack::Pop();  // reader
       
    65         }
       
    66     return reader;
       
    67     }
       
    68 
       
    69 EXPORT_C MPbkThumbnailOperation* CPbkThumbnailManager::GetThumbnailAsyncL
       
    70         (MPbkThumbnailGetObserver& aObserver, 
       
    71         const CPbkContactItem& aContactItem,
       
    72         TPbkImageLoadParameters& aParams)
       
    73     {
       
    74     MPbkThumbnailReader* reader = PbkThumbnailOperationFactory::CreateReaderLC
       
    75         (aContactItem, aObserver);
       
    76     if (reader)
       
    77         {
       
    78         TSize KNullSize(0,0);
       
    79         if (aParams.iSize == KNullSize)
       
    80             {
       
    81             // Parameters are at defaults, don't pass them
       
    82             reader->StartReadL();
       
    83             }
       
    84         else
       
    85             {
       
    86             // Frame number parameter has no meaning here.
       
    87             aParams.iFrameNumber = 0; 
       
    88             reader->StartReadL(&aParams);
       
    89             }
       
    90         CleanupStack::Pop();  // reader
       
    91         }
       
    92     return reader;
       
    93     }
       
    94 
       
    95 
       
    96 EXPORT_C MPbkThumbnailOperation* CPbkThumbnailManager::GetThumbnailImageAsyncL
       
    97         (MPbkThumbnailGetImageObserver& aObserver, 
       
    98         const CPbkContactItem& aContactItem)
       
    99     {
       
   100     MPbkThumbnailReader* reader = PbkThumbnailOperationFactory::
       
   101         CreateImageReaderLC(aContactItem, aObserver);
       
   102     if (reader)
       
   103         {
       
   104         reader->StartReadL();
       
   105         CleanupStack::Pop();  // reader
       
   106         }
       
   107     return reader;
       
   108     }
       
   109 
       
   110 EXPORT_C MPbkThumbnailOperation* CPbkThumbnailManager::SetThumbnailAsyncL
       
   111         (MPbkThumbnailSetObserver& aObserver, 
       
   112         CPbkContactItem& aContactItem, 
       
   113         const CFbsBitmap& aBitmap)
       
   114     {
       
   115     MPbkThumbnailWriter* writer = PbkThumbnailOperationFactory::CreateWriterLC
       
   116         (aContactItem, iEngine.FieldsInfo(), aObserver);
       
   117     writer->StartWriteL(aBitmap);
       
   118     CleanupStack::Pop();  // writer
       
   119     return writer;
       
   120     }
       
   121 
       
   122 EXPORT_C MPbkThumbnailOperation* CPbkThumbnailManager::SetThumbnailAsyncL(
       
   123         MPbkThumbnailSetObserver& aObserver, 
       
   124         CPbkContactItem& aContactItem, 
       
   125         const TDesC8& aImageBuffer)
       
   126     {
       
   127     MPbkThumbnailWriter* writer = PbkThumbnailOperationFactory::CreateWriterLC
       
   128         (aContactItem, iEngine.FieldsInfo(), aObserver);
       
   129     writer->StartWriteL(aImageBuffer);
       
   130     CleanupStack::Pop();  // writer
       
   131     return writer;
       
   132     }
       
   133 
       
   134 EXPORT_C MPbkThumbnailOperation* CPbkThumbnailManager::SetThumbnailAsyncL(
       
   135         MPbkThumbnailSetObserver& aObserver, 
       
   136         CPbkContactItem& aContactItem, 
       
   137         const TDesC& aFileName)
       
   138     {
       
   139     MPbkThumbnailWriter* writer = PbkThumbnailOperationFactory::CreateWriterLC
       
   140         (aContactItem, iEngine.FieldsInfo(), aObserver);
       
   141     writer->StartWriteL(aFileName);
       
   142     CleanupStack::Pop();  // writer
       
   143     return writer;
       
   144     }
       
   145 
       
   146 EXPORT_C TBool CPbkThumbnailManager::HasThumbnail
       
   147         (const CPbkContactItem& aContactItem) const
       
   148     {
       
   149     const TPbkContactItemField* field = aContactItem.FindField(EPbkFieldIdThumbnailImage);
       
   150     return (field && !field->IsEmptyOrAllSpaces());
       
   151     }
       
   152 
       
   153 EXPORT_C void CPbkThumbnailManager::RemoveThumbnail
       
   154         (CPbkContactItem& aContactItem)
       
   155     {
       
   156     TPbkContactItemField* field = aContactItem.FindField(EPbkFieldIdThumbnailImage);
       
   157     if (field)
       
   158         {
       
   159         aContactItem.RemoveField(aContactItem.FindFieldIndex(*field));
       
   160         }
       
   161     }
       
   162 
       
   163 //  End of File