logsui/logsserviceextension/inc/clogsuicontrolextension.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 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:  Provides additional functionality to the Logs UI application
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CLOGSUICONTROLEXTENSION_H
       
    21 #define C_CLOGSUICONTROLEXTENSION_H
       
    22 
       
    23 
       
    24 #include "MLogsUiControlExtension.h"
       
    25 #include "mlogsextbrandfetcherobserver.h"
       
    26 #include "mlogsextpresentityidfetcherobserver.h"
       
    27 #include "mlogsextservicehandlerobserver.h"
       
    28 
       
    29 #include "MLogsModel.h"
       
    30 #include "MLogsEventGetter.h"
       
    31 #include "MLogsExtObserver.h"
       
    32 #include "LogsConsts.h"
       
    33 #include "logsextconsts.h"
       
    34 #include "MLogsEventGetter.h"
       
    35 
       
    36 class CAknIconArray;
       
    37 class CAknDoubleGraphicStyleListBox;
       
    38 class CLogsPresenceTableManager;
       
    39 class CLogsExtBrandFetcher;
       
    40 class CLogsExtPresentityIdFetcher;
       
    41 class CLogsEventInfoManager;
       
    42 class TLogsEventInfo;
       
    43 class CLogsExtServiceHandler;
       
    44 class RFile;
       
    45 
       
    46 /**
       
    47  *  Logs Ui Extension
       
    48  *
       
    49  *  Implements the MLogsUiControlExtension interface which is used by the
       
    50  *  Logs application to provide the support for the branding icon / 
       
    51  *  presence status icon appearance.
       
    52  *
       
    53  *  @since S60 v3.2 
       
    54  */
       
    55 NONSHARABLE_CLASS(CLogsUiControlExtension) : 
       
    56         public CBase,
       
    57         public MLogsUiControlExtension,
       
    58         public MLogsExtBrandFetcherObserver,        
       
    59         public MLogsExtPresentityIdFetcherObserver,
       
    60         public MLogsExtServiceHandlerObserver
       
    61     {
       
    62     
       
    63 public: 
       
    64 
       
    65     /**
       
    66      * Two-phased constructor.
       
    67      *
       
    68      * @since S60 v3.2
       
    69      */
       
    70     static CLogsUiControlExtension* NewL();
       
    71     
       
    72     /**
       
    73      * Two-phased constructor.
       
    74      *
       
    75      * @since S60 v3.2
       
    76      */
       
    77     static CLogsUiControlExtension* NewLC();        
       
    78         
       
    79     /**
       
    80      * Destructor.
       
    81      *
       
    82      * @since S60 v3.2
       
    83      */
       
    84     ~CLogsUiControlExtension();
       
    85 
       
    86 public:
       
    87 
       
    88 // from MLogsUiControlExtension        
       
    89        
       
    90     /**
       
    91      * From MLogsUiControlExtension
       
    92      * Method does nothing.
       
    93      *
       
    94      * @since S60 v3.2
       
    95      * @param aArray array of icons
       
    96      */
       
    97     void AppendIconsL( CAknIconArray* aArray );
       
    98 
       
    99     /**
       
   100      * From MLogsUiControlExtension
       
   101      * Method does nothing.
       
   102      *
       
   103      * @since S60 v3.2
       
   104      * @param aContactId contact id
       
   105      * @param aIndex icon index
       
   106      * @return ETrue if found, otherwise EFalse
       
   107      */
       
   108     TBool GetIconIndexL( TContactItemId aContactId, TInt& aIndex );
       
   109         
       
   110     /**
       
   111      * From MLogsUiControlExtension
       
   112      * Creates and starts all the icon fetching processes
       
   113      *
       
   114      * @since S60 v3.2
       
   115      * @param aModel the data model that contains the
       
   116      * information about the log event entries in the current view.
       
   117      * @param aListBox fetched icons will be added to the icon array
       
   118      * of the specified listbox
       
   119      */
       
   120     void HandleAdditionalData( 
       
   121             MLogsModel& aModel, 
       
   122             CAknDoubleGraphicStyleListBox& aListBox );
       
   123         
       
   124     /**
       
   125      * From MLogsUiControlExtension
       
   126      * Modifies the given icon string.
       
   127      *
       
   128      * @since S60 v3.2
       
   129      * @param aDes the icon string to be modified
       
   130      * @param aServiceId the service id of the log event
       
   131      * this icon string is modified for
       
   132      */ 
       
   133     void ModifyIconString( 
       
   134             TDes& aDes, 
       
   135             const MLogsEventGetter& aLogsEventGetter );
       
   136         
       
   137     /**
       
   138      * From MLogsUiControlExtension
       
   139      * Sets the observer of the extension
       
   140      *
       
   141      * @since S60 v3.2
       
   142      * @param aObserver the observer that handles the callback
       
   143      * of this extension.
       
   144      */ 
       
   145     void SetObserver(MLogsExtObserver& aObserver);
       
   146         
       
   147         
       
   148 // from MLogsExtBrandFetcherObserver
       
   149 
       
   150     /**
       
   151      * From MLogsExtBrandFetcherObserver
       
   152      * Callback for the brand fetcher objects.
       
   153      *
       
   154      * @since S60 v3.2
       
   155      * @param aServiceId service id
       
   156      * @param aBitmapFile file handle to bitmap file
       
   157      * @param aBitmapId id of the the presence icon's bitmap in the file
       
   158      * @param aBitmapMaskId id of the the presence icon's mask in the file
       
   159      */
       
   160     void BrandIconFetchDoneL( const TUint32 aServiceId,
       
   161                               RFile& aBitmapFile,
       
   162                               const TInt aBitmapId,   
       
   163                               const TInt aBitmapMaskId );                              
       
   164                               
       
   165 
       
   166 // from MLogsExtPresentityIdFetcherObserver                              
       
   167 
       
   168     /**
       
   169      * From MLogsExtPresentityIdFetcherObserver
       
   170      * Callback for presentity id fetcher objects.     
       
   171      *
       
   172      * @since S60 v3.2
       
   173      * @param aServiceId a service id
       
   174      * @param aPresentityId the presentity id that was retrieved 
       
   175      *        by the fetcher
       
   176      * @param aLogId a unique event id associated with a log event
       
   177      */                                             
       
   178     void PresentityIdFetchDoneL( const TUint32 aServiceId, 
       
   179                                  const TDesC& aPresentityId,
       
   180                                  const TLogId aLogId );
       
   181 
       
   182 // from MLogsExtServiceHandlerObserver
       
   183     
       
   184     /**
       
   185      * From MLogsExtServiceHandlerObserver
       
   186      * Handles the service handler's callback.
       
   187      *
       
   188      * @since S60 v3.2
       
   189      * @param aServiceId service id
       
   190      * @param aPresentityId presentity id
       
   191      * @param aPresenceStatus a presence status
       
   192      * @param aShowStatus presentity presense status display flag
       
   193      */
       
   194     void HandlePresentityPresenceStatusL( 
       
   195                 const TUint32 aServiceId, 
       
   196                 const TDesC& aPresentityId,
       
   197                 const TDesC& aPresenceStatus,
       
   198                 TBool aShowStatus );
       
   199     
       
   200     /**
       
   201      * From MLogsExtServiceHandlerObserver
       
   202      * This function is used to notify the observer of a service handler
       
   203      * if the presence status of a certain presentity should be displayed
       
   204      * or not.
       
   205      *
       
   206      * @since S60 v3.2
       
   207      * @param aServiceId service id
       
   208      * @param aPresentityId presentity id
       
   209      * @param aShowStatus presentity presense status display flag
       
   210      */
       
   211     void SetDisplayStatusFlag( const TUint32 aServiceId, 
       
   212                                const TDesC& aPresentityId,
       
   213                                TBool aShowStatus );
       
   214     
       
   215 private: 
       
   216 
       
   217     /**
       
   218      * Constructor.
       
   219      */
       
   220     CLogsUiControlExtension();
       
   221 
       
   222     /**
       
   223      * Symbian second-phase constructor
       
   224      */ 
       
   225     void ConstructL();
       
   226        
       
   227 
       
   228 // from MLogsUiExtensionBase
       
   229         
       
   230     /**
       
   231      * From MLogsUiExtensionBase
       
   232      * Releases this object and any resources it owns.
       
   233      *
       
   234      * @since S60 v3.2
       
   235      */
       
   236     void DoRelease();
       
   237 
       
   238 
       
   239 private:
       
   240 
       
   241     /**
       
   242      * Creates and starts all the icon fetching processes
       
   243      *
       
   244      * @since S60 v3.2
       
   245      * @param aModel the data model that contains the information about 
       
   246      *        the log event entries in the current view.
       
   247      */ 
       
   248     void DoAdditionalDataHandlingL( MLogsModel& aModel );
       
   249         
       
   250     /**
       
   251      * Notifies the update function of the observer of this extension.
       
   252      * 
       
   253      * @since S60 v3.2
       
   254      */ 
       
   255     void NotifyObserverL();        
       
   256  
       
   257     /**
       
   258      * Checks whether servicehandler with the specified service id already 
       
   259      * exists
       
   260      *
       
   261      * @since S60 v3.2
       
   262      * @param aServiceId a service id
       
   263      * @return ETrue, if there is already a service handler for the specified 
       
   264      *         service id; EFalse otherwise
       
   265      */ 
       
   266     TBool ServiceHandlerExists( const TUint32 aServiceId );
       
   267 
       
   268     
       
   269     /**
       
   270      * Checks whether brandfetcher with the specified service id already 
       
   271      * exists
       
   272      *
       
   273      * @since S60 v3.2
       
   274      * @param aServiceId a service id
       
   275      * @return ETrue, if there is already a fetcher for the specified 
       
   276      *         service id; EFalse otherwise
       
   277      */ 
       
   278     TBool BrandFetcherExists( const TUint32 aServiceId );
       
   279 
       
   280 
       
   281     /**
       
   282      * Checks whether a presence fetcher for the specified service id 
       
   283      * and presentity id already exists
       
   284      *
       
   285      * @since S60 v3.2
       
   286      * @param aServiceId a service id
       
   287      * @param aPresentityId a presentity id
       
   288      * @return ETrue, if there is already a fetcher for the specified 
       
   289      *         service id and presentity id; EFalse otherwise
       
   290      */ 
       
   291     TBool PresenceFetcherExists( const TUint32 aServiceId, 
       
   292                                  const TDesC& aPresentityId );
       
   293 
       
   294  
       
   295     /**
       
   296      * Stores the brand icon's index in the listbox's icon array
       
   297      * to a manager, that keeps track of this information.
       
   298      *
       
   299      * @since S60 v3.2
       
   300      * @param aServiceId a service id
       
   301      * @param aIndex the index
       
   302      * @return KErrNone, if setting the index succeeded or one errorcode
       
   303      *         if setting failed(e.g. KErrNotFound)
       
   304      */ 
       
   305     TInt SetBrandIndex( const TUint32 aServiceId, 
       
   306                         const TInt aIndex );
       
   307 
       
   308 
       
   309 
       
   310     /**
       
   311      * Stores the presence icon's index in the listbox's icon array
       
   312      * to a manager, that keeps track of this information.
       
   313      *
       
   314      * @since S60 v3.2
       
   315      * @param aServiceId a service id
       
   316      * @param aPresenceStatus a presence status
       
   317      * @param aIndex the index
       
   318      * @return KErrNone, if setting the index succeeded; system-wide
       
   319      *         errorcode otherwise
       
   320      */
       
   321     TInt SetPresenceIndex( const TUint32 aServiceId, 
       
   322                            const TDesC& aPresenceStatus,
       
   323                            const TInt aIndex );
       
   324 
       
   325 
       
   326     /**
       
   327      * Creates a proper icon and adds it to the listbox' icon array.
       
   328      *
       
   329      * @since S60 v3.2
       
   330      * @param aBitmap the bitmap of the fetched icon
       
   331      * @param aBitmask the bitmask of the fetched icon
       
   332      * @param aIndex the index of the appended icon in the icon array
       
   333      * @return The index of the added icon in the icon array 
       
   334      */ 
       
   335     void AddIconL( CFbsBitmap* aBitmap, CFbsBitmap* aBitmask, TInt& aIndex );
       
   336     
       
   337     /**
       
   338      * Performs the icon string modification.
       
   339      *
       
   340      * @since S60 v3.2
       
   341      * @param aDes reference of the icon string the descriptor 
       
   342      * @param aDataField a unparsed data field of a log event
       
   343      */ 
       
   344     void DoIconStringModificationL( 
       
   345             TDes& aDes, 
       
   346             const MLogsEventGetter& aLogsEventGetter );
       
   347             
       
   348     
       
   349     /**
       
   350      * Adds the Branding icon index to a local copy of the icon string
       
   351      * that we want to modify.
       
   352      *
       
   353      * @since S60 v3.2
       
   354      * @param aTempDes the icon string where we append the branding
       
   355      *        icon
       
   356      * @param aServiceId service id
       
   357      * @return True, if appending successful, false otherwise
       
   358      */ 
       
   359     TBool AddBrandIconIndex( TDes& aTempDes, const TUint32 aServiceId );
       
   360     
       
   361     /**
       
   362      * Copies that part of the global icon string to the local copy 
       
   363      * which contains the non-icon index related data.
       
   364      *
       
   365      * @since S60 v3.2
       
   366      * @param aDes the original icon string
       
   367      * @param aTempDes the icon string where we append the data
       
   368      * @return True, if appending successful, false otherwise
       
   369      */ 
       
   370     TBool AddNonIndexData( const TDesC& aDes, TDes& aTempDes );
       
   371     
       
   372     /**
       
   373      * Appends the trailing delimiters (if they do not already exist)
       
   374      * and the presence icon index.
       
   375      *
       
   376      * @since S60 v3.2
       
   377      * @param aTempDes the icon string where we append the data
       
   378      * @param aServiceId service id
       
   379      * @param aPresentityId presentity id  
       
   380      * @return True, if appending successful, false otherwise
       
   381      */ 
       
   382     TBool AddPresenceIconIndex( TDes& aTempDes, 
       
   383                                 const TUint32 aServiceId, 
       
   384                                 const TDesC& aPresentityId );
       
   385     
       
   386     /**
       
   387      * Appends 'aNumber' trailing delimiters to the specified icon string.
       
   388      *
       
   389      * @since S60 v3.2
       
   390      * @param aTempDes the icon string where we append the data
       
   391      * @param aNumber the number of trailing delimiters that should
       
   392      *        be appended to aTempDes
       
   393      * @return KErrNone, if appending was successful, KErrNoMemory otherwise
       
   394      */ 
       
   395     TInt AppendTrailingDelimiters( TDes& aTempDes, TInt aNumber );
       
   396 
       
   397     /**
       
   398      * Determines the number of delimiters in the specified string.
       
   399      *
       
   400      * @since S60 v3.2
       
   401      * @param aTempDes a string
       
   402      * @return the number of delimiters 'aTempDes' contains
       
   403      */ 
       
   404     TInt DetermineNumberDelimiters( const TDesC& aTempDes );
       
   405 
       
   406     /**
       
   407      * Deletes the bitmaps.
       
   408      *
       
   409      * @since S60 v3.2
       
   410      */
       
   411     void DeleteBitmaps();
       
   412     
       
   413     /**
       
   414      * Creates a certain service handler.
       
   415      *
       
   416      * @since S60 v3.2
       
   417      * @param aServiceId a service id
       
   418      */        
       
   419     void CreateAndBindServiceHandlerL( TUint32 aServiceId );
       
   420     
       
   421     /**
       
   422      * Creates and starts the brand fetchers.
       
   423      *
       
   424      * @since S60 v3.2
       
   425      * @param aModel the data model that contains the
       
   426      * information about the log event entries in the current view.
       
   427      */    
       
   428     void CreateAndStartBrandFetchersL( MLogsModel& aModel );
       
   429     
       
   430     /**
       
   431      * Initiates the presence / presentity id  fetcher creation.
       
   432      *
       
   433      * @since S60 v3.2
       
   434      * @param aModel the data model that contains the
       
   435      * information about the log event entries in the current view.
       
   436      */    
       
   437     void CreateAndStartPresentityIdFetchersL( MLogsModel& aModel );
       
   438     
       
   439     
       
   440     /**
       
   441      * Adds a single presentity to a service handler.
       
   442      *
       
   443      * @since S60 v3.2
       
   444      * @param aServiceId service id
       
   445      * @param aPresentityId presentity id
       
   446      */    
       
   447     void AddPresentityToServiceHandlerL( const TUint32 aServiceId, 
       
   448                                          const TDesC& aPresentityId );
       
   449 
       
   450 
       
   451     /**
       
   452      * Creates and starts one presentity id fetcher.
       
   453      *
       
   454      * @since S60 v3.2
       
   455      * @param aServiceId service id
       
   456      * @param aCntLink a contact link
       
   457      * @param aLogId a log id
       
   458      */    
       
   459     void DoPresentityIdFetcherCreationL( const TUint32 aServiceId, 
       
   460                                          const TDesC8& aCntLink,
       
   461                                          const TLogId aLogId  );
       
   462                                      
       
   463     /**
       
   464      * Retrieves a presentity id using the specified log id.
       
   465      *
       
   466      * @since S60 v3.2
       
   467      * @param aLogId a log id
       
   468      * @return the retrieved presentity id or NULL if no mapping was found 
       
   469      *         for the specified lod id.
       
   470      */
       
   471     const TDesC* LookupPresentityId( const TLogId aLogId );
       
   472     
       
   473     /**
       
   474      * Adds another mapping to the collection of mappings.
       
   475      *
       
   476      * @since S60 v3.2
       
   477      * @param aLogId a log id
       
   478      * @param aPresentityId presentity id     
       
   479      */    
       
   480     void AddLogIdToPresentityIdMappingL( const TLogId aLogId, 
       
   481                                          const TDesC& aPresentityId );
       
   482    
       
   483     /**
       
   484      * Resets the presentity id fetcher array and also deletes the objects
       
   485      * whose pointers are stored in the array.
       
   486      *
       
   487      * @since S60 v3.2     
       
   488      */    
       
   489     void ResetPresentityIdFetcherArray();    
       
   490     
       
   491     /**
       
   492      * Resets the presence status of all entries in the status table.
       
   493      */
       
   494     void ResetPresenceStatuses();    
       
   495     
       
   496     /**
       
   497      * Gets the service handler of the specified service.
       
   498      *
       
   499      * @since S60 v3.2
       
   500      * @param aServiceId a service id
       
   501      * @param aServiceHandler service handler object pointer. 
       
   502      * @return KErrNone in case data has been retrieved successfully,
       
   503      *         system-wide errorcode otherwise 
       
   504      */
       
   505     TInt GetServiceHandler( TUint32 aServiceId, 
       
   506                             CLogsExtServiceHandler*& aServiceHandler );
       
   507 
       
   508     /**
       
   509      * Retrieves the icon bitmaps from the branding server
       
   510      *
       
   511      * @since S60 v3.2
       
   512      * @param aServiceId service id. 
       
   513      * @param aPresenceStatus the current presence status.
       
   514      * @param aBitmapFile file handle to bitmap file
       
   515      * @param aBitmapId id of the presence image bitmap in the file
       
   516      * @param aBitmapMaskId id of the presence image mask in the file
       
   517      */
       
   518     void FetchBitmapsFromBrandingServerL( 
       
   519             const TUint aServiceId,
       
   520             const TDesC& aPresenceStatus,
       
   521             RFile& aBitmapFile,
       
   522             TInt& aBitmapId,
       
   523             TInt& aBitmapMaskId );
       
   524     
       
   525 private: // data
       
   526 
       
   527     /**
       
   528      * A reference to a listbox. The fetched icons will be added 
       
   529      * to this listbox.
       
   530      * Not own.
       
   531      */        
       
   532     CAknDoubleGraphicStyleListBox* iListBox;
       
   533 
       
   534     /**
       
   535      * The observer of this extension.
       
   536      * Not own. 
       
   537      */
       
   538     MLogsExtObserver* iLogsExtObserver;
       
   539 
       
   540     /**
       
   541      * Stores the information about the service ids and the brand
       
   542      * icon indices that correspond to the service ids of each
       
   543      * log event.
       
   544      * Own.
       
   545      */
       
   546     CLogsEventInfoManager* iLogEntryInfoManager;    
       
   547 
       
   548     
       
   549     /**
       
   550      * Stores presence related information. Uses 
       
   551      * CLogsPresenceStatusTableInformation and 
       
   552      * CLogsPresenceIndexTableInformation objects in order to achieve that.
       
   553      * Own.
       
   554      */
       
   555     CLogsPresenceTableManager* iPresenceTableManager;
       
   556     
       
   557     /**
       
   558      * The array that contains the different fetchers 
       
   559      * Own. 
       
   560      */  
       
   561     RPointerArray<CLogsExtBrandFetcher> iBrandFetcherArray;
       
   562         
       
   563     /**
       
   564      * The array that contains the presence fetchers. 
       
   565      * Own. 
       
   566      */  
       
   567     RPointerArray<CLogsExtPresentityIdFetcher> iPresentityIdFetcherArray;
       
   568 
       
   569     /**
       
   570      * The array that contains the presence fetchers. 
       
   571      * Own. 
       
   572      */  
       
   573     RPointerArray<CLogsExtServiceHandler> iServiceHandlerArray;
       
   574     
       
   575     /**
       
   576      * The icon's bitmap.
       
   577      * Own.
       
   578      */
       
   579     CFbsBitmap* iBitmap;
       
   580     
       
   581     /**
       
   582      * The icon's bitmap mask.
       
   583      * Own.
       
   584      */
       
   585     CFbsBitmap* iBitmask;
       
   586     
       
   587     };
       
   588 
       
   589 #endif // C_CLOGSUICONTROLEXTENSION_H