contacts_plat/phonebook_thumbnails_api/inc/CPbkImageManager.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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 image from a image field.
       
    16 *     This class can be used for image and image for call loading.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __CPbkImageManager_H__
       
    22 #define __CPbkImageManager_H__
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <PbkFields.hrh> // TPbkFieldId
       
    27 
       
    28 //  FORWARD DECLARATIONS
       
    29 class CPbkContactEngine;
       
    30 class MPbkImageOperation;
       
    31 class MPbkImageGetObserver;
       
    32 class CPbkContactItem;
       
    33 class MPbkImageGetImageObserver;
       
    34 class MPbkImageSetObserver;
       
    35 class CFbsBitmap;
       
    36 class TPbkImageLoadParameters;
       
    37 class CPbkObserverAdapter;
       
    38 
       
    39 // CLASS DECLARATIONS
       
    40 
       
    41 /**
       
    42  * Phonebook image manager. Contains operations for attaching, removing and
       
    43  * querying images connected to Phonebook contacts.
       
    44  *
       
    45  * For all thumbnail images all the Set* operations convert the image to full 
       
    46  * color (24 bits/pixel) JPEG format and scale it to KPbkPersonalImageSize 
       
    47  * before connecting the image to a contact. Scaling does not change image's 
       
    48  * aspect ratio.
       
    49  * If the original image is in JPEG format and its size is <=KPbkPersonalImageSize
       
    50  * a copy of the original image is stored directly.
       
    51  *
       
    52  * For all call object images all the Set* operations convert the image to full 
       
    53  * color (24 bits/pixel) JPEG format and scale it to the total area of the 
       
    54  * screen available to the application before connecting the image to a contact. 
       
    55  * Scaling does not change image's aspect ratio.
       
    56  * If the original image is in JPEG format and its size is <= 
       
    57  * the application screen area
       
    58  * a copy of the original image is stored directly.
       
    59  * 
       
    60  * @see MPbkImageGetObserver
       
    61  * @see MPbkImageSetObserver
       
    62  */
       
    63 class CPbkImageManager : public CBase
       
    64     {
       
    65     public: // Interface
       
    66         /**
       
    67          * Creates and returns a new image manager.
       
    68          * If given phonebook field id is something else than 
       
    69          * EPbkFieldIdThumbnailImage or EPbkFieldIdCODImageID then
       
    70          * "CPbkImageManager 1" panic will occur.
       
    71          * @param aEngine   Phonebook contact engine
       
    72          * @param aFieldId  Phonebook field type id of fetched image.
       
    73          * If id is something else than EPbkFieldIdThumbnailImage or 
       
    74          * EPbkFieldIdCodImageID then a EPbkInvalidArgument panic will occur.         
       
    75          */
       
    76         IMPORT_C static CPbkImageManager* NewL(CPbkContactEngine& aEngine);
       
    77 
       
    78         /**
       
    79          * Destructor.
       
    80          */
       
    81         ~CPbkImageManager();
       
    82 
       
    83         /**
       
    84          * Gets a image bitmap from a contact asynchronously.
       
    85          *
       
    86          * @param aFieldId  Phonebook field type id of fetched image.
       
    87          * @param aObserver     Observer for this operation.
       
    88          * @param aContactItem  Contact to retrieve the image from.
       
    89          * @return  a image operation object. Caller deletes the object 
       
    90          *          when the operation is done or needs to be canceled.
       
    91          */
       
    92         IMPORT_C MPbkImageOperation* GetImageAsyncL(
       
    93                 TPbkFieldId aFieldId,
       
    94                 MPbkImageGetObserver& aObserver, 
       
    95                 const CPbkContactItem& aContactItem);
       
    96 
       
    97         /**
       
    98          * Gets a parameterized image bitmap
       
    99          * from a contact asynchronously.
       
   100          *
       
   101          * @param aFieldId  Phonebook field type id of fetched image.
       
   102          * @param aObserver     Observer for this operation.
       
   103          * @param aContactItem  Contact to retrieve the image from.
       
   104          * @param aParams       Parameters for bitmap, see TPbkImageLoadParameters.
       
   105          *                      NOTE: iFrameNumber parameter has no meaning.
       
   106          *                      
       
   107          * @return  an image operation object. Caller deletes the object 
       
   108          *          when the operation is done or needs to be canceled.
       
   109          * @see TPbkImageLoadParameters
       
   110          */
       
   111         IMPORT_C MPbkImageOperation* GetImageAsyncL(
       
   112                 TPbkFieldId aFieldId,
       
   113                 MPbkImageGetObserver& aObserver, 
       
   114                 const CPbkContactItem& aContactItem,
       
   115                 TPbkImageLoadParameters& aParams);
       
   116 
       
   117         /**
       
   118          * Gets a image from a contact asynchronously.
       
   119          *
       
   120          * @param aFieldId  Phonebook field type id of fetched image.
       
   121          * @param aObserver     Observer for this operation.
       
   122          * @param aContactItem  Contact to retrieve the image from.
       
   123          * @return  an image operation object. Caller deletes the object 
       
   124          *          when the operation is done or needs to be canceled.
       
   125          */
       
   126         IMPORT_C MPbkImageOperation* GetImageAsyncL(
       
   127                 TPbkFieldId aFieldId,
       
   128                 MPbkImageGetImageObserver& aObserver, 
       
   129                 const CPbkContactItem& aContactItem);
       
   130 
       
   131         /**
       
   132          * Sets a image image for a contact asynchronously.
       
   133          *
       
   134          * @param aFieldId  Phonebook field type id of fetched image.
       
   135          * @param aObserver     Observer for this operation.
       
   136          * @param aContactItem  Contact to set the image to.
       
   137          * @param aBitmap       Bitmap to set as the image for aContact.
       
   138          * @return  an image operation object. Caller deletes the object 
       
   139          *          when the operation is done or needs to be canceled.
       
   140          */
       
   141         IMPORT_C MPbkImageOperation* SetImageAsyncL(
       
   142                 TPbkFieldId aFieldId,
       
   143                 MPbkImageSetObserver& aObserver, 
       
   144                 CPbkContactItem& aContactItem, 
       
   145                 const CFbsBitmap& aBitmap);
       
   146                     
       
   147         /**
       
   148          * Sets a image image for a contact asynchronously.
       
   149          *
       
   150          * @param aFieldId  Phonebook field type id of fetched image.
       
   151          * @param aObserver     Observer for this operation.
       
   152          * @param aContactItem  Contact to set the image to.
       
   153          * @param aImageBuffer  image buffer to set as the image for aContact.
       
   154          * @return  an image operation object. Caller deletes the object 
       
   155          *          when the operation is done or needs to be canceled.
       
   156          */
       
   157         IMPORT_C MPbkImageOperation* SetImageAsyncL(
       
   158                 TPbkFieldId aFieldId,
       
   159                 MPbkImageSetObserver& aObserver, 
       
   160                 CPbkContactItem& aContactItem, 
       
   161                 const TDesC8& aImageBuffer);
       
   162 
       
   163         /**
       
   164          * Sets a image image for a contact asynchronously.
       
   165          *
       
   166          * @param aFieldId  Phonebook field type id of fetched image.
       
   167          * @param aObserver     Observer for this operation.
       
   168          * @param aContactItem  Contact to set the image to.
       
   169          * @param aFileName     File name for a image to set as the image for aContact.
       
   170          * @return  an image operation object. Caller deletes the object 
       
   171          *          when the operation is done or needs to be canceled.
       
   172          */
       
   173         IMPORT_C MPbkImageOperation* SetImageAsyncL(
       
   174                 TPbkFieldId aFieldId,
       
   175                 MPbkImageSetObserver& aObserver, 
       
   176                 CPbkContactItem& aContactItem, 
       
   177                 const TDesC& aFileName);
       
   178 
       
   179         /**
       
   180          * Returns true if aContactItem has a image image attached to it.
       
   181          * @param aFieldId  Phonebook field type id of fetched image.
       
   182          * @param aContactItem Contact that is queried for image.
       
   183          * @return ETrue if given contact has a image, EFalse otherwise.
       
   184          */
       
   185         IMPORT_C TBool HasImage(
       
   186                 TPbkFieldId aFieldId, 
       
   187                 const CPbkContactItem& aContactItem) const;
       
   188 
       
   189         /**
       
   190          * Removes any image from aContactItem.
       
   191          * @param aFieldId  Phonebook field type id of fetched image.
       
   192          * @param aContactItem Contact whose image is removed.
       
   193          */
       
   194         IMPORT_C void RemoveImage(
       
   195                 TPbkFieldId aFieldId,
       
   196                 CPbkContactItem& aContactItem);
       
   197 
       
   198     private: // Implementation
       
   199         CPbkImageManager(CPbkContactEngine& aEngine);
       
   200         void ConstructL();
       
   201     
       
   202     private: // Data members
       
   203         /// Ref: contact engine
       
   204         CPbkContactEngine& iEngine;
       
   205 
       
   206         /// Owns: handles adaptation of different observer APIs
       
   207         CPbkObserverAdapter* iPbkObserverAdapter;
       
   208     };
       
   209 
       
   210 /**
       
   211  * Abstract asynchronous image operation. The operation can be cancelled by
       
   212  * deleting it.
       
   213  *
       
   214  * @see CPbkImageManager
       
   215  */ 
       
   216 class MPbkImageOperation
       
   217     {
       
   218     public:  // Interface
       
   219         /**
       
   220          * Destructor. Cancels this image operation and releases any 
       
   221          * resources held by it.
       
   222          */
       
   223         virtual ~MPbkImageOperation() = 0;
       
   224     };
       
   225 
       
   226 inline  MPbkImageOperation::~MPbkImageOperation()
       
   227     {
       
   228     }
       
   229     
       
   230 #endif // __CPbkImageManager_H__
       
   231 
       
   232 // End of File