contacts_plat/phonebook_thumbnails_api/inc/CPbkThumbnailManager.h
changeset 0 e686773b3f54
child 3 04ab22b956c2
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 *     Class which loads a thumbnail from a contact field.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CPbkThumbnailManager_H__
       
    21 #define __CPbkThumbnailManager_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 // CONSTANTS
       
    27 /// Size of thumbnail images stored to Phonebook contacts
       
    28 #define KPbkPersonalImageSize TSize(80,96)
       
    29 
       
    30 //  FORWARD DECLARATIONS
       
    31 class CPbkContactEngine;
       
    32 class MPbkThumbnailOperation;
       
    33 class MPbkThumbnailGetObserver;
       
    34 class CPbkContactItem;
       
    35 class MPbkThumbnailGetImageObserver;
       
    36 class MPbkThumbnailSetObserver;
       
    37 class CFbsBitmap;
       
    38 class CPAlbImageData;
       
    39 class TPbkImageLoadParameters;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44  * Phonebook thumbnail manager. Contains operations for attaching, removing and
       
    45  * querying thumbnail images connected to Phonebook contacts.
       
    46  *
       
    47  * All the Set* operations convert the image to full color (24 bits/pixel) 
       
    48  * JPEG format and scale it to KPbkPersonalImageSize before connecting the 
       
    49  * image to a contact. Scaling does not change image's aspect ratio.
       
    50  * If the original image is in JPEG format and its size is <=KPbkPersonalImageSize
       
    51  * a copy of the original image is stored directly.
       
    52  *
       
    53  * @see MPbkThumbnailOperation
       
    54  * @see MPbkThumbnailGetObserver
       
    55  * @see MPbkThumbnailSetObserver
       
    56  */
       
    57 class CPbkThumbnailManager : public CBase
       
    58     {
       
    59     public: // Interface
       
    60         /**
       
    61          * Creates and returns a new thumbnail manager.
       
    62          * @param aEngine   Phonebook contact engine
       
    63          */
       
    64         IMPORT_C static CPbkThumbnailManager* NewL(CPbkContactEngine& aEngine);
       
    65 
       
    66         /**
       
    67          * Destructor.
       
    68          */
       
    69         ~CPbkThumbnailManager();
       
    70 
       
    71         /**
       
    72          * Gets a thumbnail bitmap from a contact asynchronously.
       
    73          *
       
    74          * @param aObserver     Observer for this operation.
       
    75          * @param aContactItem  Contact to retrieve the thumbnail from.
       
    76          * @return  a thumbnail operation object. Caller deletes the object 
       
    77          *          when the operation is done or needs to be canceled.
       
    78          */
       
    79         IMPORT_C MPbkThumbnailOperation* GetThumbnailAsyncL(
       
    80             MPbkThumbnailGetObserver& aObserver, 
       
    81             const CPbkContactItem& aContactItem);
       
    82 
       
    83         /**
       
    84          * Gets a parameterized thumbnail bitmap
       
    85          * from a contact asynchronously.
       
    86          *
       
    87          * @param aObserver     Observer for this operation.
       
    88          * @param aContactItem  Contact to retrieve the thumbnail from.
       
    89          * @param aParams       Parameters for bitmap, see TPbkImageLoadParameters.
       
    90          *                      NOTE: iFrameNumber parameter has no meaning.
       
    91          *                      
       
    92          * @return  a thumbnail operation object. Caller deletes the object 
       
    93          *          when the operation is done or needs to be canceled.
       
    94          * @see TPbkImageLoadParameters
       
    95          */
       
    96         IMPORT_C MPbkThumbnailOperation* GetThumbnailAsyncL(
       
    97             MPbkThumbnailGetObserver& aObserver, 
       
    98             const CPbkContactItem& aContactItem,
       
    99             TPbkImageLoadParameters& aParams);
       
   100 
       
   101         /**
       
   102          * Gets a thumbnail image from a contact asynchronously.
       
   103          *
       
   104          * @param aObserver     Observer for this operation.
       
   105          * @param aContactItem  Contact to retrieve the thumbnail from.
       
   106          * @return  a thumbnail operation object. Caller deletes the object 
       
   107          *          when the operation is done or needs to be canceled.
       
   108          */
       
   109         IMPORT_C MPbkThumbnailOperation* GetThumbnailImageAsyncL(
       
   110             MPbkThumbnailGetImageObserver& aObserver, 
       
   111             const CPbkContactItem& aContactItem);
       
   112 
       
   113         /**
       
   114          * Sets a thumbnail image for a contact asynchronously.
       
   115          *
       
   116          * @param aObserver     Observer for this operation.
       
   117          * @param aContactItem  Contact to set the thumbnail to.
       
   118          * @param aBitmap       Bitmap to set as the thumbnail for aContact.
       
   119          * @return  a thumbnail operation object. Caller deletes the object 
       
   120          *          when the operation is done or needs to be canceled.
       
   121          */
       
   122         IMPORT_C MPbkThumbnailOperation* SetThumbnailAsyncL(
       
   123             MPbkThumbnailSetObserver& aObserver, 
       
   124             CPbkContactItem& aContactItem, 
       
   125             const CFbsBitmap& aBitmap);
       
   126 
       
   127         /**
       
   128          * Sets a thumbnail image for a contact asynchronously.
       
   129          *
       
   130          * @param aObserver     Observer for this operation.
       
   131          * @param aContactItem  Contact to set the thumbnail to.
       
   132          * @param aImageBuffer  Image buffer to set as the thumbnail for aContact.
       
   133          * @return  a thumbnail operation object. Caller deletes the object 
       
   134          *          when the operation is done or needs to be canceled.
       
   135          */
       
   136         IMPORT_C MPbkThumbnailOperation* SetThumbnailAsyncL(
       
   137             MPbkThumbnailSetObserver& aObserver, 
       
   138             CPbkContactItem& aContactItem, 
       
   139             const TDesC8& aImageBuffer);
       
   140 
       
   141         /**
       
   142          * Sets a thumbnail image for a contact asynchronously.
       
   143          *
       
   144          * @param aObserver     Observer for this operation.
       
   145          * @param aContactItem  Contact to set the thumbnail to.
       
   146          * @param aFileName     File name for a image to set as the thumbnail for aContact.
       
   147          * @return  a thumbnail operation object. Caller deletes the object 
       
   148          *          when the operation is done or needs to be canceled.
       
   149          */
       
   150         IMPORT_C MPbkThumbnailOperation* SetThumbnailAsyncL(
       
   151             MPbkThumbnailSetObserver& aObserver, 
       
   152             CPbkContactItem& aContactItem, 
       
   153             const TDesC& aFileName);
       
   154 
       
   155         /**
       
   156          * Returns true if aContactItem has a thumbnail image attached to it.
       
   157          * @param aContactItem Contact that is queried for thumbnail.
       
   158          * @return ETrue if given contact has a thumbnail, EFalse otherwise.
       
   159          */
       
   160         IMPORT_C TBool HasThumbnail(const CPbkContactItem& aContactItem) const;
       
   161 
       
   162         /**
       
   163          * Removes any thumbnail image from aContactItem.
       
   164          * @param aContactItem Contact whose thumbnail is removed.
       
   165          */
       
   166         IMPORT_C void RemoveThumbnail(CPbkContactItem& aContactItem);
       
   167 
       
   168     private: // Implementation
       
   169         CPbkThumbnailManager(CPbkContactEngine& aEngine);
       
   170         void ConstructL();
       
   171 
       
   172     private: // Data members
       
   173         /// Ref: contact engine
       
   174         CPbkContactEngine& iEngine;
       
   175     };
       
   176 
       
   177 
       
   178 /**
       
   179  * Abstract asynchronous thumbnail operation. The operation can be cancelled by
       
   180  * deleting it.
       
   181  *
       
   182  * @see CPbkThumbnailManager
       
   183  */ 
       
   184 class MPbkThumbnailOperation
       
   185     {
       
   186     public:  // Interface
       
   187         /**
       
   188          * Destructor. Cancels this thumbnail operation and releases any 
       
   189          * resources held by it.
       
   190          */
       
   191         virtual ~MPbkThumbnailOperation() =0;
       
   192     };
       
   193 
       
   194 inline MPbkThumbnailOperation::~MPbkThumbnailOperation()
       
   195     {
       
   196     }
       
   197 
       
   198 #endif // __CPbkThumbnailManager_H__
       
   199 
       
   200 // End of File