ccservices/cmsservices/bpas/inc/bpas.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007, 2008 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:  This class handles presence related tasks for
       
    15 *                branding
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_BPAS_H
       
    22 #define C_BPAS_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <badesca.h>
       
    26 #include <presencecachereadhandler2.h>
       
    27 #include <spdefinitions.h>
       
    28 #include <mpresencebuddyinfo2.h>
       
    29 
       
    30 class MBPASObserver;
       
    31 class CBPASInfo;
       
    32 class CBPASPresenceInfo;
       
    33 class CBPASServiceInfo;
       
    34 class CBPASIconInfo;
       
    35 class CSPSettings;
       
    36 class MPresenceCacheReader2;
       
    37 class MPresenceBuddyInfo2;
       
    38 
       
    39 
       
    40     /** 
       
    41      * BPAS presence data type
       
    42      */
       
    43     enum EBPASPresenceType
       
    44         {
       
    45         EBPASPresenceTypeNotDefined,
       
    46         EBPASPersonPresence,
       
    47         EBPASDevicePresence,
       
    48         EBPASServicePresence,
       
    49         };
       
    50         
       
    51     /** 
       
    52      * BPAS element type
       
    53      */
       
    54     enum EBPASElementType
       
    55         {
       
    56         EBPASElementTypeNotDefined,
       
    57         EBPASElementImage,
       
    58         EBPASElementText,
       
    59         };
       
    60 
       
    61 /**
       
    62  *  This is a middleware dll which is used to get branded presence.
       
    63  *  It uses presence cache and spsettings to do the job
       
    64  *  ?more_complete_description
       
    65  *
       
    66  *  @lib bpas.lib
       
    67  *  @since S60 v3.2
       
    68  */
       
    69 class CBPAS : public CActive,
       
    70               public MPresenceCacheReadHandler2
       
    71     {
       
    72 
       
    73 public:
       
    74 
       
    75     /**
       
    76      * Public constructor. 
       
    77      */
       
    78     IMPORT_C static CBPAS* NewL();
       
    79     
       
    80     /**
       
    81      * Public constructor. 
       
    82      *
       
    83      *@param aObserver      [in] Reference to the MBPASObserver
       
    84      *                      interface implementation class.
       
    85      */
       
    86     IMPORT_C static CBPAS* NewL( MBPASObserver* aObserver );
       
    87     
       
    88     
       
    89     /**
       
    90      * Public destructor. 
       
    91      */
       
    92     virtual ~CBPAS();
       
    93     
       
    94     
       
    95     /**
       
    96      * Set observer. 
       
    97      *
       
    98      *@param aObserver      [in] Reference to the MBPASObserver
       
    99      *                      interface implementation class.
       
   100      */
       
   101     IMPORT_C void SetObserver( MBPASObserver* aObserver );
       
   102                 
       
   103     /**
       
   104      * Synchronous
       
   105      *
       
   106      * @since S60 ?S60_version
       
   107      * @param aContacts             [in] contact string array
       
   108      * @param aInfos                [out] result array
       
   109      *                              Ownership is not transferred.
       
   110      * @return ?description
       
   111      */
       
   112     IMPORT_C void GiveInfosL( MDesCArray& aContacts, 
       
   113                               RPointerArray<CBPASInfo>& aInfos );
       
   114                                     
       
   115 
       
   116      
       
   117     /**
       
   118      * Asynchronous, user of this method needs to implement
       
   119      * MBPASObserver interface and give reference to it
       
   120      *
       
   121      * Leaves with KErrNotSupported if the observer doesn't exist
       
   122      * Leaves with KErrInUse if prosessing of the previous request 
       
   123      * is not ready.
       
   124      * @since S60 ?S60_version
       
   125      * @param aContacts            [in] contact string array
       
   126      * @return ?description
       
   127      */
       
   128     IMPORT_C void GiveInfosL( MDesCArray& aContacts );
       
   129     
       
   130     
       
   131     /**
       
   132      * Subscribe given contacts for presence changes. User of this method needs
       
   133      * to implement MBPASObserver interface and give reference to it using
       
   134      * SetObserver method. All notifications are delivered to the observer's 
       
   135      * HandleSubscribedInfoL method. If observer is changed later, all presence
       
   136      * changes previously subscribed or subscribed in future, will be delivered
       
   137      * to the new observer. The contacts should be in xsp id format.
       
   138      *
       
   139      * This method varifies either that given xsp id's service is found from the
       
   140      * device's sp table. Otherwise
       
   141      * ids are ignored.
       
   142      * 
       
   143      * @param aContacts contact string array, ids in xsp id format
       
   144      */                                   
       
   145      IMPORT_C void SubscribePresenceInfosL( MDesCArray& aContacts);
       
   146      
       
   147     
       
   148     /**
       
   149      * UnSubscribe given contact for presence changes. The Presence Change
       
   150      * notification for these contacts will no longer be delivered. Contacts
       
   151      * which are not subscribed are ignored. The contacts should be in xsp id 
       
   152      * format. The contacts should be in xsp id format.
       
   153      *
       
   154      * This method varifies either that given xsp id's service is found from the
       
   155      * device's sp table. Otherwise
       
   156      * ids are ignored.
       
   157      * 
       
   158      * @param aContacts contact string array, ids in xsp id format
       
   159      */                                   
       
   160      IMPORT_C void UnSubscribePresenceInfosL( MDesCArray& aContacts);
       
   161              
       
   162     
       
   163     /**
       
   164      * Synchronous
       
   165      *
       
   166      * @since S60 ?S60_version
       
   167      * @param aContacts             [in] 
       
   168      * @param aInfos                [out] 
       
   169      *                              Owner
       
   170      * @return ?description
       
   171      */
       
   172     void CreateInfosL( RPointerArray<CBPASInfo>& aInfos );
       
   173     
       
   174     
       
   175     /**
       
   176      * Synchronous
       
   177      *
       
   178      * @since S60 ?S60_version
       
   179      * @param aContacts             [in] contact string array
       
   180      * @param aInfos                [out] result array
       
   181      *                              Ownership is not transferred.
       
   182      * @return ?description
       
   183      */
       
   184     void GivePresenceInfosL( MDesCArray& aContacts, 
       
   185                              RPointerArray<CBPASPresenceInfo>& aInfos );
       
   186                                     
       
   187 
       
   188      /**
       
   189      * Synchronous
       
   190      *
       
   191      * @param aBrandId                [in] brand id
       
   192      * @param aServiceId              [in] element id
       
   193      * @param aIconHandle             [out] icon info
       
   194      * @return 
       
   195      */
       
   196     CBPASIconInfo* GiveIconInfoL( const TDesC8& aImageId, 
       
   197                                   const TDesC8& aTextId );                                        
       
   198 
       
   199     /**
       
   200      * Synchronous
       
   201      *
       
   202      * @since S60 ?S60_version
       
   203      * @param aPresenceType             [in] presence type
       
   204      * @param aElementType              [in] element type
       
   205      * @param aAttribute                [in] presence attribute
       
   206      * @param aAttributeValue           [in] presence attribute value
       
   207      * @return ?description
       
   208      */                                   
       
   209      HBufC8* CreateElementIdLC( EBPASPresenceType aPresenceType, 
       
   210                                 EBPASElementType aElementType, 
       
   211                                 const TDesC& aAttributeValue );
       
   212      
       
   213      //NULL if not found and in that case not pushed to cleanup
       
   214      CBPASServiceInfo* ReadServiceDataLC(TInt aServiceId);
       
   215                                 
       
   216     
       
   217 public:     // From CActive
       
   218 
       
   219     /**
       
   220      * Handles an active object’s request completion event.
       
   221      * Gets data and notifies observers.
       
   222      */
       
   223     void RunL();
       
   224     
       
   225 
       
   226     /**
       
   227      * Handles a leave occurring in the RunL().
       
   228      *
       
   229      * @param aError The leave code from RunL().
       
   230      * @return aError
       
   231      */
       
   232     TInt RunError( TInt aError );
       
   233 
       
   234 
       
   235     /**
       
   236      * Implements cancellation of an outstanding request.
       
   237      * This function is called as part of the active object’s Cancel().
       
   238      */
       
   239     void DoCancel();
       
   240     
       
   241     
       
   242 public:     // From MPresCacheReadHandler2
       
   243         
       
   244     void HandlePresenceReadL(TInt aErrorCode,
       
   245          RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList);
       
   246                            
       
   247     void HandlePresenceNotificationL(TInt aErrorCode,
       
   248         MPresenceBuddyInfo2* aPresenceBuddyInfo);    
       
   249 
       
   250     
       
   251 private:
       
   252 
       
   253     CBPAS( MBPASObserver* aObserver );
       
   254 
       
   255     void ConstructL( );
       
   256     
       
   257     
       
   258     void ReadPresenceInfosL( MDesCArray& aContacts, 
       
   259                              RPointerArray<CBPASPresenceInfo>& aInfos );
       
   260                              
       
   261     void SetPresenceInfosL( RPointerArray<CBPASInfo>& aInfos );
       
   262                                                               
       
   263     void SetServiceInfosL( RPointerArray<CBPASInfo>& aInfos );
       
   264     
       
   265     void SetIconInfosL( RPointerArray<CBPASInfo>& aInfos );
       
   266      
       
   267     void ReadAndCreatePresenceInfoL( const TDesC& aContact,
       
   268                                      RPointerArray<CBPASPresenceInfo>& aInfos );
       
   269             
       
   270     
       
   271     /**
       
   272      * Get service id from the given Uri. the Uri has possibly xsp id prefix
       
   273      * using which it tries to find service id. If service id is found then
       
   274      * ETrue is returned
       
   275      *
       
   276      * @param aServiceId, found service id returned here or KErrNotFound [out]
       
   277      * @param aUri, complete uri as read from contact database [in]
       
   278      * @return ETrue if service id is found.
       
   279      */
       
   280     TBool GetServiceId(TInt& aServiceId, TPtrC aUri);
       
   281     
       
   282     /**
       
   283      * Get serviceId from xsp id. e.g. (msn)
       
   284      *
       
   285      * @param aXsp XSP id
       
   286      * @return service id or KErrNotFound.
       
   287      */
       
   288     TInt XspToServiceId(TPtrC aXsp);
       
   289     
       
   290     /**
       
   291      * Read service table data and store locally to iSPIds and iSPNames
       
   292      *
       
   293      * @param none
       
   294      */
       
   295     void ReadSPSettingsToLocalStoresL();
       
   296     
       
   297     /**
       
   298      * Verify whether given service id is available in sptable or not, return its index
       
   299      * @param aServiceId
       
   300      * @return index of service id in iSPIds, or KErrNotFound
       
   301      */
       
   302     TInt VerifyServiceIdL(TInt aServiceId);                
       
   303    
       
   304 private:
       
   305 
       
   306 
       
   307     /** 
       
   308      * BPAS States
       
   309      */
       
   310     enum EBPASState
       
   311         {
       
   312         EBPASIdle,
       
   313         EBPASProcessing
       
   314         };
       
   315         
       
   316 
       
   317     MBPASObserver*          iObserver;
       
   318     TInt                    iState;
       
   319     CPtrCArray*             iContacts;
       
   320     CActiveSchedulerWait*   iSchedulerWait;
       
   321     CSPSettings*            iSettings;    
       
   322     MPresenceCacheReader2*   iCacheReader;
       
   323     
       
   324     RIdArray iSPIds;
       
   325     CDesCArray* iSPNames;
       
   326     };
       
   327 
       
   328 
       
   329 
       
   330 
       
   331 #endif // C_BPAS_H