mediator/inc/Server/MediatorServerObjectHandler.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Handler Mediator objects (domains, categories and 
       
    15 *                commands/events)
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef MEDIATORSERVEROBJECTHANDLER_H
       
    20 #define MEDIATORSERVEROBJECTHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "MediatorCommon.h"
       
    25 #include "MediatorServerObjects.h"
       
    26 #include "MediatorServiceDefs.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CDomain;
       
    30 class CCategory;
       
    31 class MMediatorCommandObserver;
       
    32 class MMediatorServerEventObserver;
       
    33 
       
    34 // NAMESPACE
       
    35 using namespace MediatorService;
       
    36 
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  An observer interface for receiving Mediator Service notifications.
       
    42 *
       
    43 *  @since S60 3.1
       
    44 */
       
    45 class MMediatorServerNotificationObserver
       
    46     {
       
    47     public: 
       
    48 
       
    49         /**
       
    50         * Events have been registered. The events can now be subscribed.
       
    51         * The list can contain 1-n new events into the category.
       
    52         *
       
    53         * @since S60 3.1
       
    54         * @param aDomain    The identifier of the domain.
       
    55         * @param aCategory  The identifier of the category.
       
    56         * @param aEvents    The list of events that have been registered.
       
    57         * @return None.
       
    58         */
       
    59         virtual void MediatorEventsAddedL( TUid aDomain, 
       
    60                                            TUid aCategory, 
       
    61                                            const REventList& aEvents ) = 0;
       
    62 
       
    63         /**
       
    64         * New commands have been registered. The commands can now be subscribed.
       
    65         * The list can contain 1-n new commands into the category.
       
    66         *
       
    67         * @since S60 3.1
       
    68         * @param aDomain    The identifier of the domain.
       
    69         * @param aCategory  The identifier of the category.
       
    70         * @param aCommands  List of commands that have been registered.
       
    71         * @return None.
       
    72         */
       
    73         virtual void MediatorCommandsAddedL( TUid aDomain, 
       
    74                                              TUid aCategory,
       
    75                                              const RCommandList& aCommands ) = 0;
       
    76          
       
    77         /**
       
    78         * A category has been removed. All subscriptions are cancelled.
       
    79         *
       
    80         * @since S60 3.1
       
    81         * @param aDomain    The identifier of the domain.
       
    82         * @param aCategory  The identifier of the category.        
       
    83         * @return None.
       
    84         */
       
    85         virtual void MediatorCategoryRemovedL( TUid aDomain, TUid aCategory ) = 0;
       
    86 
       
    87         /**
       
    88         * List of events has been removed. All subscriptions are cancelled.
       
    89         * List can contain 1-n events from the specified category.
       
    90         *
       
    91         * @since S60 3.1
       
    92         * @param aDomain    The identifier of the domain.
       
    93         * @param aCategory  The identifier of the category.
       
    94         * @param aEvents    The list of events removed.
       
    95         * @return None.
       
    96         */
       
    97         virtual void MediatorEventsRemovedL( TUid aDomain, 
       
    98                                              TUid aCategory,
       
    99                                              const REventList& aEvents ) = 0;
       
   100                                              
       
   101         /**
       
   102         * List of commands have been removed. All subscriptions are cancelled.
       
   103         * List can contain 1-n commands from the specified category.
       
   104         *
       
   105         * @since S60 3.1
       
   106         * @param aDomain    The identifier of the domain.
       
   107         * @param aCategory  The identifier of the category.
       
   108         * @param aCommands  The list of commands removed
       
   109         * @return None.
       
   110         */
       
   111         virtual void MediatorCommandsRemovedL( TUid aDomain, 
       
   112                                                TUid aCategory,
       
   113                                                const RCommandList& aCommands ) = 0;
       
   114     };
       
   115 
       
   116 
       
   117 /**
       
   118 *  Object handler class for Mediator Server.
       
   119 *
       
   120 *  @lib MediatorServer
       
   121 *  @since S60 3.1
       
   122 */
       
   123 class CMediatorServerObjectHandler : public CBase
       
   124     {
       
   125     public:  // Constructors and destructor
       
   126         
       
   127         /**
       
   128         * Two-phased constructor.
       
   129         */
       
   130         static CMediatorServerObjectHandler* NewL();
       
   131         
       
   132         /**
       
   133         * Destructor.
       
   134         */
       
   135         virtual ~CMediatorServerObjectHandler();
       
   136 
       
   137     public: // New functions
       
   138         
       
   139         /**
       
   140         * Adds new observer to get events about registration changes
       
   141         *
       
   142         * @since S60 3.1
       
   143         * @param aObserver pointer to observer instance
       
   144         * @return None.
       
   145         */
       
   146         void AddObserverL( MMediatorServerNotificationObserver* aObserver );
       
   147         
       
   148         /**
       
   149         * Removes observer.
       
   150         *
       
   151         * @since S60 3.1
       
   152         * @param aObserver pointer to observer instance
       
   153         * @return None.
       
   154         */
       
   155         void RemoveObserverL( MMediatorServerNotificationObserver* aObserver );
       
   156         
       
   157         /**
       
   158         * Finds domain from the domain list
       
   159         * @since S60 3.1
       
   160         * @param aDomain identifying the domain
       
   161         * @return CDomain pointer to found domain. Null if not found
       
   162         */      
       
   163         CDomain* FindDomain( const TUid aDomain );
       
   164         
       
   165         /**
       
   166         * Adds new domain to domain list
       
   167         * @since S60 3.1
       
   168         * @param aDomain identifying the domain
       
   169         * @return CDomain pointer to new domain.
       
   170         */      
       
   171         CDomain* AddDomainL( const TUid aDomain );
       
   172         
       
   173         /**
       
   174         * Returns pointer to category specified
       
   175         * @since S60 3.1
       
   176         * @param aCategory structure defining domain and category
       
   177         * @return CCategory pointer to category
       
   178         */      
       
   179         CCategory* CategoryL( TMediatorCategory aCategory );
       
   180         
       
   181         
       
   182         /**
       
   183         * Gets all domains
       
   184         * @since S60 3.1
       
   185         * @param aDomains   Array where list of registered domains is written
       
   186         * @return none.
       
   187         */
       
   188         void GetDomainsL( RDomainList& aDomains );  
       
   189         
       
   190         /**
       
   191         * Gets all categories from the domains
       
   192         * @since S60 3.1
       
   193         * @param aCategory      Information for the domain
       
   194         * @param aCategories    Array for the registered categories
       
   195         * @return none.
       
   196         */
       
   197         void GetCategoriesL( TMediatorCategory aCategory, 
       
   198                              RCategoryList& aCategories );     
       
   199         
       
   200         /**
       
   201         * Gets registered commands from the category
       
   202         * @since S60 3.1
       
   203         * @param aCategory  Information for the domain & category
       
   204         * @param aCommands  Array where list of registered commands is written
       
   205         * @return none.
       
   206         */
       
   207 
       
   208         void GetCommandsL( TMediatorCategory aCategory, 
       
   209                            RCommandList& aCommands );    
       
   210         
       
   211         /**
       
   212         * Gets registered events from the category
       
   213         * @since S60 3.1
       
   214         * @param aCategory  Information for the domain & category
       
   215         * @param aEvents    Array where list of registered events is written
       
   216         * @return none.
       
   217         */
       
   218 
       
   219         void GetEventsL( TMediatorCategory aCategory, 
       
   220                          REventList& aEvents );     
       
   221                          
       
   222                          
       
   223         /**
       
   224         * Events have been registered. The events can now be subscribed.
       
   225         * The list can contain 1-n new events into the category.
       
   226         *
       
   227         * @since S60 3.1
       
   228         * @param aDomain    The identifier of the domain.
       
   229         * @param aCategory  The identifier of the category.
       
   230         * @param aEvents    The list of events that have been registered.
       
   231         * @return None.
       
   232         */
       
   233         void EventsAdded( TUid aDomain, 
       
   234                           TUid aCategory, 
       
   235                           const REventList& aEvents );
       
   236 
       
   237         /**
       
   238         * New commands have been registered. The commands can now be subscribed.
       
   239         * The list can contain 1-n new commands into the category.
       
   240         *
       
   241         * @since S60 3.1
       
   242         * @param aDomain    The identifier of the domain.
       
   243         * @param aCategory  The identifier of the category.
       
   244         * @param aCommands  List of commands that have been registered.
       
   245         * @return None.
       
   246         */
       
   247         void CommandsAdded( TUid aDomain, 
       
   248                             TUid aCategory,
       
   249                             const RCommandList& aCommands );
       
   250 
       
   251         /**
       
   252         * List of events has been removed. All subscriptions are cancelled.
       
   253         * List can contain 1-n events from the specified category.
       
   254         *
       
   255         * @since S60 3.1
       
   256         * @param aDomain    The identifier of the domain.
       
   257         * @param aCategory  The identifier of the category.
       
   258         * @param aEvents    The list of events removed.
       
   259         * @return None.
       
   260         */
       
   261         void EventsRemoved( TUid aDomain, 
       
   262                             TUid aCategory,
       
   263                             const REventList& aEvents );
       
   264                                              
       
   265         /**
       
   266         * List of commands have been removed. All subscriptions are cancelled.
       
   267         * List can contain 1-n commands from the specified category.
       
   268         *
       
   269         * @since S60 3.1
       
   270         * @param aDomain    The identifier of the domain.
       
   271         * @param aCategory  The identifier of the category.
       
   272         * @param aCommands  The list of commands removed
       
   273         * @return None.
       
   274         */
       
   275         void CommandsRemoved( TUid aDomain, 
       
   276                               TUid aCategory,
       
   277                               const RCommandList& aCommands );
       
   278                               
       
   279         /**
       
   280         * Clears all registrations made by this observer
       
   281         *
       
   282         * @since S60 3.1
       
   283         * @param aEventObserver     Pointer to event observer.
       
   284         * @param aCommandObserver   Pointer to command observer.
       
   285         * @param aNotifObserver     Pointer to notifications observer.
       
   286         * @return None.
       
   287         */
       
   288         void ClearRegistrations( MMediatorServerEventObserver* aEventObserver, 
       
   289                                  MMediatorCommandObserver* aCommandObserver,
       
   290                                  MMediatorServerNotificationObserver* aNotifObserver );                              
       
   291         
       
   292         
       
   293         /**
       
   294         * Gets statistical information about owned objects..
       
   295         *
       
   296         * @since S60 3.1
       
   297         * @param aDomainCount     domain count (OUT)
       
   298         * @param aCategoryCount   category count (OUT)
       
   299         * @param aEventCount      count of events in all categories (OUT)
       
   300         * @param aCommandCount    count of commands in all categories (OUT)
       
   301         * @param aObserverCount   observer count (OUT)
       
   302         * @return None.
       
   303         */
       
   304         void GetStatistics(TInt& aDomainCount, 
       
   305                            TInt& aCategoryCount,
       
   306                            TInt& aEventCount,
       
   307                            TInt& aCommandCount,
       
   308                            TInt& aObserverCount);
       
   309                               
       
   310     private:
       
   311         
       
   312          /**
       
   313         * Compares two domains according to their UIDs. User in array finds.
       
   314         * @since S60 3.1
       
   315         * @param aLeftDomain reference to left domain
       
   316         * @param aRightdomain reference to right domain
       
   317         * @return TBool indicating if items are same or not.
       
   318         */      
       
   319         static TBool CompareDomains( const CDomain& aLeftDomain, 
       
   320                                      const CDomain& aRightDomain );
       
   321                                
       
   322         /**
       
   323         * Checks whether category has any events and commands
       
   324         * @since S60 3.1
       
   325         * @param aDomain UID for the domain
       
   326         * @param aCategory UID for the category
       
   327         * @return TBool ETrue if empty, EFalse if not
       
   328         */      
       
   329         TBool IsCategoryEmptyL( TUid aDomain, TUid aCategory);
       
   330         
       
   331         /**
       
   332         * Removes category if it was empty
       
   333         * @since S60 3.1
       
   334         * @param aDomain UID for the domain
       
   335         * @param aCategory UID for the category
       
   336         * @return TBool ETrue if removed, EFalse if not
       
   337         */      
       
   338         TBool RemoveCategoryIfEmptyL( TUid aDomain, TUid aCategory);
       
   339         
       
   340     private:
       
   341 
       
   342         /**
       
   343         * C++ default constructor.
       
   344         */
       
   345         CMediatorServerObjectHandler();
       
   346 
       
   347         /**
       
   348         * By default Symbian 2nd phase constructor is private.
       
   349         */
       
   350         void ConstructL();
       
   351 
       
   352     private:    // Data
       
   353         
       
   354         /**
       
   355         * List of domains (includes categories and then commands and events  
       
   356         */
       
   357 
       
   358         RPointerArray<CDomain>  iDomainList;
       
   359         
       
   360         /**
       
   361         * List of registration change observers
       
   362         */
       
   363         RPointerArray<MMediatorServerNotificationObserver> iObserverList;
       
   364         
       
   365         /**
       
   366         * A helper object for searches. Does not manage any other data than UID.
       
   367         * Own.
       
   368         */
       
   369         CDomain* iSearchDomain;
       
   370          
       
   371     };
       
   372 
       
   373 #endif      // MEDIATORSERVEROBJECTHANDLER_H  
       
   374             
       
   375 // End of File