phonebookui/Phonebook2/NamesListExtension/inc/CPbk2EcePresenceEngine.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Phonebook 2 Nameslist UI control UI extension.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPbk2EcePresenceEngine_H
       
    20 #define CPbk2EcePresenceEngine_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MPbk2ContactUiControlExtension.h>
       
    25 
       
    26 #include "CPbk2IconArray.h"
       
    27 #include "TPbk2IconId.h"
       
    28 #include "CPbk2NlxPresenceIconInfo.h"
       
    29 #include "CPbk2NlxPresenceSubscriptionInfo.h"
       
    30 #include "MPbk2EcePresenceEngineObserver.h"
       
    31 
       
    32 #include <mcontactpresenceobs.h>
       
    33 #include <mcontactpresenceinfo.h>
       
    34 // FORWARD DECLARATIONS
       
    35 class CVPbkContactManager;
       
    36 class MVPbkContactLink;
       
    37 class MContactPresence;
       
    38 class CFbsBitmap;
       
    39 class CBSFactory;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44  * Phonebook 2 ECE Presence Engine.
       
    45  *
       
    46  */
       
    47 NONSHARABLE_CLASS(CPbk2EcePresenceEngine) : 
       
    48         public CBase,
       
    49         public MContactPresenceObs
       
    50     {
       
    51     public:  // Constructors and destructor
       
    52         
       
    53         /**
       
    54          * Creates a new instance of this class.
       
    55          *
       
    56          * @param aContactManager       Virtual Phonebook contact manager.
       
    57          * @param aObserver Observer to this engine.
       
    58          * @param aIconSize Required icon size
       
    59          * @return  A new instance of this class.
       
    60          */
       
    61         static CPbk2EcePresenceEngine* NewL(
       
    62             CVPbkContactManager& aContactManager,
       
    63             MPbk2EcePresenceEngineObserver& aObserver,
       
    64             TSize aIconSize );
       
    65         
       
    66         /**
       
    67          * Destructor.
       
    68          */
       
    69         ~CPbk2EcePresenceEngine();
       
    70 
       
    71     private: // Construction & destruction
       
    72         CPbk2EcePresenceEngine(
       
    73             CVPbkContactManager& aContactManager,
       
    74             MPbk2EcePresenceEngineObserver& aObserver,
       
    75             TSize aIconSize );
       
    76         void ConstructL();
       
    77         
       
    78     public: // new methods
       
    79 
       
    80         /**
       
    81          * Subscribe for presence information of a certain contact.
       
    82          *
       
    83          * @param aLink A contact link.
       
    84          */
       
    85         void SubscribeContactPresenceL( const MVPbkContactLink& aLink );
       
    86 
       
    87         /**
       
    88          * Gets the ID of the current presence icon of a contact.
       
    89          * The TBool return value tells whether the icon ID and icon is available.
       
    90          * If the ID is successfully obtained, then CreateIconCopyLC() can be called.
       
    91          *
       
    92          * @param aLink A contact link.
       
    93          *
       
    94          * @return ETrue if the icon ID was available, and vice versa.
       
    95          */
       
    96         TBool GetIconIdForContact( const MVPbkContactLink& aLink, TPbk2IconId& aIconId );
       
    97 
       
    98         /**
       
    99          * Creates an icon instance. Call only after a succesfull call to GetIconIdForContactL().
       
   100          *
       
   101          * @exception Panics if called when icon is not available. See GetIconIdForContactL().
       
   102          */
       
   103         CGulIcon* CreateIconCopyLC( const TPbk2IconId& aIconId );
       
   104         
       
   105         /**
       
   106          * Gets the bitmap and mask for the element from the Branding Server
       
   107          * @param aLanguageId - Language for which Brand is requested        
       
   108          * @param aBrandedBitmap - Ptr to the Bitmap Ownership is transferred to the caller
       
   109          * @param aBrandedMask - Ptr to the BitmapMask Ownership is transferred to the caller
       
   110          * @param aBSFactory - interface for  access brandingserver 
       
   111          * @param aBrandId - brandingId,
       
   112          * @param aElementId - elementId
       
   113          */
       
   114          void GetBitmapFromBrandingServerL(
       
   115                              TLanguage aLanguageId, 
       
   116                              CFbsBitmap*& aBrandedBitmap, 
       
   117                              CFbsBitmap*& aBrandedMask,
       
   118                              CBSFactory& aBSFactory,
       
   119                              const TDesC8& aBrandId, 
       
   120                              const TDesC8& aElementId) ;
       
   121          
       
   122          /**
       
   123          * Loops thro the ServiceTable/SpSettings and finds the
       
   124          * BrandLanguage associated to the BrandId (aBrandId)
       
   125          * @param aBrandId - BrandId mentioned in the ServiceTable
       
   126          * @return TLanguage - Returns the matched Language Id, else 47(ELangInternationalEnglish)
       
   127          */
       
   128          TLanguage CPbk2EcePresenceEngine::FindBrandLanguageIdL( const TDesC8& aBrandId );
       
   129 
       
   130 
       
   131     private: // from MContactPresenceObs
       
   132         void ReceiveIconInfoL( 
       
   133             const TDesC8& aPackedLink, 
       
   134             const TDesC8& aBrandId, 
       
   135             const TDesC8& aElementId );
       
   136         void ReceiveIconFileL( 
       
   137             const TDesC8& aBrandId, 
       
   138             const TDesC8& aElementId, 
       
   139             CFbsBitmap* aBrandedBitmap, 
       
   140             CFbsBitmap* aMask );
       
   141         void ReceiveIconInfosL(
       
   142             const TDesC8& aPackedLink,
       
   143             RPointerArray <MContactPresenceInfo>& aInfoArray,
       
   144             TInt aOpId );
       
   145         void PresenceSubscribeError( 
       
   146             const TDesC8& aContactLink,
       
   147             TInt aStatus );        
       
   148         void ErrorOccured( 
       
   149             TInt aOpId, 
       
   150             TInt aStatus );   
       
   151         
       
   152 
       
   153     private: // New methods
       
   154 
       
   155         void InformObserverOfContactChanges(
       
   156             const TDesC8& aBrandId,
       
   157             const TDesC8& aElementId );
       
   158 
       
   159         CPbk2NlxPresenceSubscriptionInfo* FindSubscription( const MVPbkContactLink& aContactLink );
       
   160         CPbk2NlxPresenceIconInfo* FindIconInfo( const TDesC8& aBrandId, const TDesC8& aElementId );
       
   161         CPbk2NlxPresenceIconInfo* FindIconInfo( const TPbk2IconId& aIconId );
       
   162         void CleanUpOldSubscriptionsL();
       
   163         void CleanUpExtraIcons();
       
   164 
       
   165         static CFbsBitmap* CloneBitmapL( const CFbsBitmap& aOriginalBitmap );
       
   166 
       
   167         static TInt SubscriptionMonitorL(TAny* aPtr);
       
   168         TInt SubscriptionMonitorL();
       
   169         static TSize CalculateListIconSize();
       
   170     private: // Data
       
   171         /// Ref: Virtual Phonebook contact manager
       
   172         CVPbkContactManager& iContactManager;
       
   173 
       
   174         MContactPresence* iPresenceClient;
       
   175         RPointerArray<CPbk2NlxPresenceSubscriptionInfo> iSubscriptions; // owns the objects
       
   176         RPointerArray<CPbk2NlxPresenceIconInfo> iIconInfoArray; // owns the objects
       
   177         TInt iNextIconId;
       
   178         MPbk2EcePresenceEngineObserver& iObserver;
       
   179         CIdle* iSubscriptionMonitor;
       
   180         TSize iIconSize;
       
   181     };
       
   182 
       
   183 #endif // CPbk2EcePresenceEngine_H
       
   184            
       
   185 // End of File