phonebookui/Phonebook2/spbcontentprovider/inc/spbcontent.h
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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: Content info container
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef SPBCONTENT_H
       
    19 #define SPBCONTENT_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <TPbk2IconId.h>
       
    24 #include <MVPbkContactLink.h>
       
    25 #include "spbcontentprovider.h"
       
    26 
       
    27 class CVPbkContactManager;
       
    28 class CSpbServiceIconProvider;
       
    29 class CSpbStatusProvider;
       
    30 class MSpbContentProviderObserver;
       
    31 class CSpbPhoneNumberParser;
       
    32 
       
    33 NONSHARABLE_CLASS( CSpbContent ) : public CBase
       
    34     {
       
    35 public:
       
    36 struct TParameters
       
    37     {
       
    38     CVPbkContactManager* iContactManager;
       
    39     TInt32 iFeatures;
       
    40     RPointerArray<MSpbContentProviderObserver>* iObservers;
       
    41     CSpbServiceIconProvider* iIconProvider; // can be NULL
       
    42     CSpbStatusProvider* iStatusProvider;  // can be NULL
       
    43     };
       
    44     
       
    45     static CSpbContent* NewLC(
       
    46             const CSpbContent::TParameters& aParameters,
       
    47             const MVPbkContactLink& aLink);
       
    48     
       
    49     ~CSpbContent();
       
    50 
       
    51 public:
       
    52     inline TBool IsReady() const;
       
    53     inline TPtrC Text() const;
       
    54     inline const TPbk2IconId& IconId() const;
       
    55     inline TBool Match(const MVPbkContactLink& aLink) const;
       
    56     inline TBool Match(const TDesC& aBuddyId) const;
       
    57     inline MVPbkContactLink& Link() const;
       
    58     inline void SetBuddyId( HBufC* aId );
       
    59     inline CSpbContentProvider::TSpbContentType Type() const;
       
    60 
       
    61     void StatusDataUpdatedL(
       
    62             const TDesC& aStatusMessage, 
       
    63             const TDesC8& aBrandId,
       
    64             const TDesC8& aIconEntry );
       
    65     void PhoneNumberUpdatedL(
       
    66             const TDesC& aPhoneNumber );
       
    67     /*
       
    68 	 * Function reloads the phonenumber, if there is no status text provided
       
    69 	 */
       
    70     void RefreshNumber();
       
    71     
       
    72 private:
       
    73     inline CSpbContent(
       
    74             const CSpbContent::TParameters& aParameters);
       
    75     inline void ConstructL(
       
    76             const MVPbkContactLink& aLink);
       
    77 private:
       
    78     static TInt StartFetchContent( 
       
    79             TAny* aPtr );
       
    80     void DoStartFetchContent();
       
    81     void NotifyObservers(
       
    82             MSpbContentProviderObserver::TSpbContentEvent aEvent);
       
    83     
       
    84 private:
       
    85         
       
    86     TParameters iParameters;
       
    87     /// Own
       
    88     MVPbkContactLink* iLink;
       
    89     // Own
       
    90     CSpbPhoneNumberParser* iPhoneNumberParser;
       
    91     /// 
       
    92     CAsyncCallBack iAsyncCallBack;
       
    93     /// Own
       
    94     HBufC* iText;
       
    95     /// Own
       
    96     HBufC* iBuddyId;
       
    97     TPbk2IconId iIconId;
       
    98     TBool iReady;
       
    99     /// Content type
       
   100     CSpbContentProvider::TSpbContentType iType;
       
   101     };
       
   102 
       
   103 inline void CSpbContent::SetBuddyId( HBufC* aId )
       
   104     {
       
   105     delete iBuddyId;
       
   106     iBuddyId = aId;
       
   107     }
       
   108 
       
   109 inline MVPbkContactLink& CSpbContent::Link() const
       
   110     {
       
   111     return *iLink;
       
   112     }
       
   113 
       
   114 inline TBool CSpbContent::Match(const MVPbkContactLink& aLink) const
       
   115     {
       
   116     return iLink->IsSame( aLink );
       
   117     }
       
   118 
       
   119 inline TBool CSpbContent::Match(const TDesC& aBuddyId) const
       
   120     {
       
   121     if(iBuddyId && iBuddyId->Compare(aBuddyId) == 0)
       
   122         {
       
   123         return ETrue;
       
   124         }
       
   125     return EFalse;
       
   126     }
       
   127 
       
   128 inline TBool CSpbContent::IsReady() const
       
   129     {
       
   130     return iReady;
       
   131     }
       
   132 
       
   133 inline TPtrC CSpbContent::Text() const
       
   134     {
       
   135     return iText ? *iText : KNullDesC();
       
   136     }
       
   137 
       
   138 inline const TPbk2IconId& CSpbContent::IconId() const
       
   139     {
       
   140     return iIconId;
       
   141     }
       
   142 
       
   143 inline CSpbContentProvider::TSpbContentType CSpbContent::Type() const
       
   144     {
       
   145     return iType;
       
   146     }
       
   147 
       
   148 #endif // SPBCONTENT_H