phonebookui/Phonebook2/inc/spbcontentprovider.h
branchRCL_3
changeset 20 f4a778e096c2
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SPBCONTENTPROVIDER_H_
       
    20 #define SPBCONTENTPROVIDER_H_
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 class CSpbContentProviderPrivate;
       
    26 class MVPbkContactLink;
       
    27 class CVPbkContactManager;
       
    28 class CPbk2StoreManager;
       
    29 class TPbk2IconId;
       
    30 class CGulIcon;
       
    31 class MVPbkContactStore;
       
    32 
       
    33 /**
       
    34  * Interface to observe content changes
       
    35  */
       
    36 class MSpbContentProviderObserver
       
    37     {
       
    38 public:
       
    39     
       
    40     /**
       
    41      * Event types
       
    42      */
       
    43     enum TSpbContentEvent
       
    44         {
       
    45         EContentChanged = 0x0,
       
    46         EContentNotAvailable
       
    47         };
       
    48     
       
    49     /**
       
    50      * Provider send this event when there is updated content 
       
    51      * information available for the contact.
       
    52      * 
       
    53      * @param aLink Contact which the event is about
       
    54      * @param aEvent Type of the event
       
    55      */
       
    56     virtual void ContentUpdated(
       
    57         MVPbkContactLink& aLink, 
       
    58         MSpbContentProviderObserver::TSpbContentEvent aEvent ) = 0;
       
    59 
       
    60 protected:
       
    61     MSpbContentProviderObserver(){};
       
    62     virtual ~MSpbContentProviderObserver() {};
       
    63     };
       
    64 
       
    65 
       
    66 /**
       
    67  * CSpbContentProvider provides methods to access 
       
    68  * to extra content of the contact for Social phonebook features.
       
    69  * 
       
    70  * @since TB9.2
       
    71  * @lib pbk2spbcontentprovider.lib
       
    72  */
       
    73 NONSHARABLE_CLASS( CSpbContentProvider ) : public CBase
       
    74     {
       
    75 public: // Data types
       
    76 
       
    77     /// Content flags (binary)
       
    78     enum TSpbContentFlags
       
    79         {
       
    80         ENone           = 0x0,
       
    81         /**
       
    82          * If Feature Manager FF_CONTACTS_SOCIAL flag is not defined  
       
    83          * status message is not fetched
       
    84          */ 
       
    85         EStatusMessage  = 0x1,
       
    86         /**
       
    87          * If Feature Manager FF_CONTACTS_SOCIAL flag is not defined  
       
    88          * service icon is not fetched
       
    89          */ 
       
    90         EServiceIcon    = 0x2,
       
    91         /**
       
    92          * If status message is not available or Feature Manager 
       
    93          * FF_CONTACTS_SOCIAL is not defined phone number is returned
       
    94          */ 
       
    95         EPhoneNumber    = 0x4
       
    96         };
       
    97 
       
    98     /// Type of the retrieved content
       
    99     enum TSpbContentType
       
   100         {
       
   101         /// No content available
       
   102         ETypeNone       = 0x0,
       
   103                 
       
   104         /// Content is contact's social status (text & icon)  
       
   105         ETypeSocialStatus,
       
   106         
       
   107         /// Content is contact's phone number (text)
       
   108         ETypePhoneNumber,
       
   109         
       
   110         /// Content is contact's phone number count (text [only number])
       
   111         /// This type is used when contact has multiple numbers and no default number
       
   112         ETypePhoneNumberMultiple
       
   113         };
       
   114     
       
   115 public: // Construction & destruction
       
   116 
       
   117     /**
       
   118      * Constructor
       
   119      * 
       
   120      * @param aContactManager Contact Manager instance
       
   121      * @param aFeatures Required content (see TSpbContentFlags)
       
   122      */
       
   123     IMPORT_C static CSpbContentProvider* NewL(
       
   124         CVPbkContactManager& aContactManager,
       
   125         CPbk2StoreManager& aStoreManager,
       
   126         TInt32 aFeatures );
       
   127     
       
   128     /// Destructor
       
   129     ~CSpbContentProvider();
       
   130 
       
   131 public:
       
   132     /**
       
   133      * Add observer
       
   134      */
       
   135     IMPORT_C void AddObserverL(
       
   136         MSpbContentProviderObserver& aObserver );
       
   137 
       
   138     /**
       
   139      * Removes observer
       
   140      */
       
   141     IMPORT_C void RemoveObserver(
       
   142         MSpbContentProviderObserver& aObserver );
       
   143             
       
   144     /**
       
   145      * Provides Spb content information for the contact. 
       
   146      * If current extra content is not know by provider then provider 
       
   147      * starts fetch extra information and send observer event when content 
       
   148      * information is available.
       
   149      */
       
   150     IMPORT_C void GetContentL(
       
   151         MVPbkContactLink& aLink,
       
   152         HBufC*& aText,
       
   153         TPbk2IconId& aIconId, 
       
   154         TSpbContentType& aType );
       
   155 
       
   156     /**
       
   157      * Create service icon. Ownership transferred to caller
       
   158      * Note! Function returns a NULL pointer if Feature Manager Flag 
       
   159      * FF_CONTACTS_SOCIAL is not supported or CSpbContentProvider::EServiceIcon
       
   160      * flag is not defined
       
   161      * 
       
   162      * @param aIconId icon id for created icon
       
   163      * @return Created icon object 
       
   164      */
       
   165     IMPORT_C CGulIcon* CreateServiceIconLC( 
       
   166         const TPbk2IconId& aIconId );
       
   167     
       
   168     /**
       
   169      * Clean the content in the cache if it belongs to the specified store
       
   170      */
       
   171     IMPORT_C void CleanContentL( MVPbkContactStore& aStore );
       
   172     
       
   173 private: // Constructors
       
   174     
       
   175     /// Constructor
       
   176     inline CSpbContentProvider();
       
   177     
       
   178     /// Constructor
       
   179     inline void ConstructL(
       
   180         CVPbkContactManager& aContactManager,
       
   181         CPbk2StoreManager& aStoreManager,
       
   182         TInt32 aFeatures);
       
   183 
       
   184 private: // data
       
   185     
       
   186     // Own. Private implementation
       
   187     CSpbContentProviderPrivate* iImpl;
       
   188     };
       
   189 
       
   190 #endif /*SPBCONTENTPROVIDER_H_*/