mediator/inc/Client/MediatorServerClient.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:  A client interface for Mediator Server.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MEDIATORSERVERSESSION_H
       
    19 #define MEDIATORSERVERSESSION_H
       
    20 
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "MediatorCommon.h"
       
    25 #include "MediatorServiceDefs.h"
       
    26 
       
    27 // NAMESPACE
       
    28 using namespace MediatorService;
       
    29 
       
    30 
       
    31 /**
       
    32 *  Client API for Mediator Server.
       
    33 *
       
    34 *  The Mediator Server is used to pass information between clients. The 
       
    35 *  services of Mediator Server include passing events and passing commands with
       
    36 *  respective responses. For events there can be multiple event providers and 
       
    37 *  consumers. For commands there can be only one initiator and one responder.
       
    38 *
       
    39 *  The operations of Mediator server have the following hierarchy.
       
    40 *  Domain -> Category -> Event/Command -> Data
       
    41 *
       
    42 *  The domain means the application domain, the purpose, for which the services 
       
    43 *  of Mediator Server are used.
       
    44 *
       
    45 *  The category means the functionality area within the domain to which an event
       
    46 *  or a command belongs to.
       
    47 *
       
    48 *  An event or a command is a message passed to Mediator server. Each message
       
    49 *  may have data assosiated with it. For each command exactly one response shall 
       
    50 *  be sent.
       
    51 *
       
    52 *  Before any messages can be sent to Mediator Server, the messages need to be
       
    53 *  registered. When registering messages, the capabilities required to consume 
       
    54 *  that message are defined. In case of commands timeout values for responses
       
    55 *  are also defined.
       
    56 *
       
    57 *  @lib MediatorClient.lib
       
    58 *  @since S60 3.1
       
    59 */
       
    60 
       
    61 ////////////////////////////////////////
       
    62 //	class RMediatorServerSession
       
    63 ////////////////////////////////////////
       
    64 
       
    65 
       
    66 NONSHARABLE_CLASS(RMediatorServer) : public RSessionBase
       
    67 	{
       
    68     public:
       
    69     
       
    70         /**
       
    71         * Session constructor.
       
    72         */
       
    73 	    RMediatorServer();
       
    74 	
       
    75     public:
       
    76         
       
    77         /**
       
    78         * Creates a connection to server. If server is not started,
       
    79         * method will start the server first and then create a new session.
       
    80         * 
       
    81         * @since S60 3.1
       
    82         * @param none
       
    83         * @return TInt indicating the success of the call.
       
    84         */
       
    85         TInt Connect();
       
    86         
       
    87         /**
       
    88         * Closes the session to server
       
    89         * 
       
    90         * @since S60 3.1
       
    91         * @param none
       
    92         * @return None.
       
    93         */
       
    94         void Close();
       
    95     
       
    96         /**
       
    97         * Cancels all ongoing async operations
       
    98         * 
       
    99         * @since S60 3.1
       
   100         * @return None
       
   101         */                  
       
   102         void Cancel();
       
   103         
       
   104 
       
   105     public: // Mediator Service Registration API        
       
   106 
       
   107         /**
       
   108         * Registers an event list. After registering the list 
       
   109         * clients can provide and consume the events.
       
   110         * 
       
   111         * @since S60 3.1
       
   112         * @param aDomain    The identifier of the domain.
       
   113         * @param aCategory  The identifier of the category.
       
   114         * @param aEvents    List of events to be registered
       
   115         * @return TInt      an error value.
       
   116         */
       
   117         TInt RegisterEventList( TUid aDomain,  
       
   118                                 TUid aCategory, 
       
   119                                 const REventList& aEvents );
       
   120 
       
   121         /**
       
   122         * Register a command list. After registering the list 
       
   123         * clients can initiate and respond the commands.
       
   124         * 
       
   125         * @since S60 3.1
       
   126         * @param aDomain    The identifier of the domain.
       
   127         * @param aCategory  The identifier of the category.
       
   128         * @param aCommands  List of commands to be registered
       
   129         * @return TInt      an error value.
       
   130         */
       
   131         TInt RegisterCommandList( TUid aDomain, 
       
   132                                   TUid aCategory, 
       
   133                                   const RCommandList& aCommands );
       
   134 
       
   135         /**
       
   136         * Unregister an event list. After unregistering no clients can consume
       
   137         * or provide these events.
       
   138         * 
       
   139         * @since S60 3.1
       
   140         * @param aDomain    The identifier of the domain.
       
   141         * @param aCategory  The identifier of the category.
       
   142         * @param aEvents    List of events to be unregistered.
       
   143         * @return TInt      an error value.
       
   144         */
       
   145         TInt UnregisterEventList( TUid aDomain,  
       
   146                                   TUid aCategory,
       
   147                                   const REventList& aEvents );
       
   148 
       
   149 
       
   150         /**
       
   151         * Unregister a command list. After unregistering no clients can initiate
       
   152         * or respond to these events.
       
   153         * 
       
   154         * @since S60 3.1
       
   155         * @param aDomain    The identifier of the domain.
       
   156         * @param aCategory  The identifier of the category.
       
   157         * @param aCommands  List of commands to be unregistered.
       
   158         * @return TInt      an error value.
       
   159         */
       
   160         TInt UnregisterCommandList( TUid aDomain, 
       
   161                                     TUid aCategory,
       
   162                                     const RCommandList& aCommands );
       
   163         
       
   164 
       
   165     public: // Mediator Service Notification API - Event Provider   
       
   166 
       
   167         /**
       
   168         * Raise an event.
       
   169         * 
       
   170         * @since S60 3.1
       
   171         * @param aDomain    The identifier of the domain.
       
   172         * @param aCategory  The identifier of the category.
       
   173         * @param aEventId   The identifier of the event.
       
   174         * @param aVersion   The version of the event.
       
   175         * @param aData      The parameters of the event.
       
   176         * @return TInt      an error value.
       
   177         */
       
   178         TInt RaiseEvent( TUid aDomain, 
       
   179                          TUid aCategory, 
       
   180                          TInt aEventId,
       
   181                          TVersion aVersion, 
       
   182                          const TDesC8& aData );
       
   183 
       
   184     public: // Mediator Service Notification API - Event Consumer
       
   185 
       
   186         /**
       
   187         * Subscribes a list of events. Raised events will be
       
   188         * delivered via the observer interface.
       
   189         * 
       
   190         * @since S60 3.1
       
   191         * @param aDomain    The identifier of the domain.
       
   192         * @param aCategory  The identifier of the category.
       
   193         * @param aEvents    List of the events to be subscribed.
       
   194         * @return TInt      an error value.
       
   195         */
       
   196         TInt SubscribeEventList( TUid aDomain, 
       
   197                                  TUid aCategory, 
       
   198                                  const REventList& aEvents );
       
   199 
       
   200         /**
       
   201         * Unsubscribe an event list.
       
   202         * 
       
   203         * @since S60 3.1
       
   204         * @param aDomain    The identifier of the domain.
       
   205         * @param aCategory  The identifier of the category.
       
   206         * @param aEvents    The list of events.
       
   207         * @return TInt      an error value.
       
   208         */
       
   209         TInt UnsubscribeEventList( TUid aDomain, 
       
   210                                    TUid aCategory, 
       
   211                                    const REventList& aEvents );
       
   212 
       
   213         /**
       
   214         * Unsubscribe an event.
       
   215         * 
       
   216         * @since S60 3.1
       
   217         * @param aDomain    The identifier of the domain.
       
   218         * @param aCategory  The identifier of the category.
       
   219         * @param aEventId   The identifier of the event.
       
   220         * @return TInt      an error value.
       
   221         */
       
   222         TInt UnsubscribeEvent( TUid aDomain, TUid aCategory, TInt aEventId );
       
   223         
       
   224         /**
       
   225         * Start to receive events from Mediator Server
       
   226         * 
       
   227         * @since S60 3.1
       
   228         * @param aStatus            TRequestStatus of the AO to be completed when event occurs.
       
   229         * @param aCategoryBuffer    Category buffer.
       
   230         * @param aEventData         Pointer descriptor to buffer where event data is written.
       
   231         * @return TInt indicating the status of the operation
       
   232         */
       
   233         void ReceiveEvents( TRequestStatus& aStatus, 
       
   234                             TMediatorCategoryRetBuffer& aCategoryBuffer,
       
   235                             TEventRetBuffer& aEventBuffer,
       
   236                             TPtr8& aEventData );
       
   237 
       
   238 
       
   239     public: // Mediator Service Command API - Command Initiatior
       
   240 
       
   241         /**
       
   242         * Issue a command.
       
   243         * 
       
   244         * @since S60 3.1
       
   245         * @param aDomain    The identifier of the domain.
       
   246         * @param aCategory  The identifier of the category.
       
   247         * @param aCommandId The identifier of the command.
       
   248         * @param aVersion   The version of the command.
       
   249         * @param aData      The parameters of the command.        
       
   250         * @return TInt indicating the success of the call.
       
   251         */
       
   252         TInt IssueCommand( TUid aDomain,
       
   253                            TUid aCategory, 
       
   254                            TInt aCommandId,
       
   255                            TVersion aVersion, 
       
   256                            const TDesC8& aData );
       
   257         
       
   258         /**
       
   259         * Wait for command response.
       
   260         * 
       
   261         * @since S60 3.1
       
   262         * @param aStatus            TRequestStatus of the AO to be completed when command response is received.
       
   263         * @param aCategoryBuffer    Category buffer.
       
   264         * @param aCommandBuffer     Command buffer
       
   265         * @param aCommandData       Pointer descriptor to buffer where command data is written.
       
   266         * @param aStatusBuffer      Status buffer.
       
   267         * @return None.
       
   268         */                  
       
   269         void WaitForCommandResponse( TRequestStatus& aStatus,
       
   270                                      TMediatorCategoryRetBuffer& aCategoryBuffer,
       
   271                                      TCommandRetBuffer& aCommandBuffer,
       
   272                                      TPtr8& aCommandData,
       
   273                                      TPckg<TInt>& aStatusBuffer );
       
   274         
       
   275         /**
       
   276         * Cancel a command.
       
   277         * 
       
   278         * @since S60 3.1
       
   279         * @param aDomain    The identifier of the domain.
       
   280         * @param aCategory  The identifier of the category.
       
   281         * @param aCommandId The identifier of the command.        
       
   282         * @return TInt indicating the status of the call.
       
   283         */
       
   284         TInt CancelCommand( TUid aDomain, TUid aCategory, TInt aCommandId );
       
   285 
       
   286     public: // Mediator Service Command API - Command Responder
       
   287 
       
   288 
       
   289         /**
       
   290         * Issue a response to a command.
       
   291         * 
       
   292         * @since S60 3.1
       
   293         * @param aDomain    The identifier of the domain.
       
   294         * @param aCategory  The identifier of the category.
       
   295         * @param aCommandId The identifier of the command.
       
   296         * @param aStatus    Processing status of the command
       
   297         * @param aData      The parameters of the response.        
       
   298         * @return TInt indicating the status of the operation.
       
   299         */
       
   300         TInt IssueResponse( TUid aDomain, 
       
   301                             TUid aCategory, 
       
   302                             TInt aCommandId,
       
   303                             TInt aStatus,
       
   304                             const TDesC8& aData );
       
   305         
       
   306         /**
       
   307         * Get command requests.
       
   308         * 
       
   309         * @since S60 3.1
       
   310         * @param aCategoryBuffer    Category buffer.
       
   311         * @param aCommandBuffer     Command buffer
       
   312         * @param aCommandData       Pointer descriptor to buffer where command data is written.
       
   313         * @return TInt indicating the status of the operation.
       
   314         */                  
       
   315         void ReceiveCommands( TRequestStatus& aStatus,
       
   316                               TMediatorCategoryRetBuffer& aCategoryBuffer,
       
   317                               TCommandRetBuffer& aCommandBuffer,
       
   318                               TPtr8& aCommandData );
       
   319         
       
   320     public: // Mediator Service  - Notifications
       
   321     
       
   322         /**
       
   323         * Get registered domains
       
   324         * 
       
   325         * @since S60 3.1
       
   326         * @param aDomains   The list of registered domains.
       
   327         * @return TInt indicating the success of the call.
       
   328         */
       
   329         TInt GetDomains( RDomainList& aDomains );
       
   330         
       
   331         /**
       
   332         * Get registered categories for the domain
       
   333         * 
       
   334         * @since S60 3.1
       
   335         * @param aDomain        UID for the domain.
       
   336         * @param aCategories    List of registered categories within the domain.
       
   337         * @return TInt indicating the success of the call.
       
   338         */
       
   339         TInt GetCategories( TUid aDomain, RCategoryList& aCategories );
       
   340         
       
   341         /**
       
   342         * Get a list of registered events.
       
   343         * 
       
   344         * @since S60 3.1
       
   345         * @param aDomain    The identifier of the domain.
       
   346         * @param aCategory  The identifier of the category.
       
   347         * @param aEvents    The list of registered events for the category.
       
   348         * @return TInt indicating the status of the operation.
       
   349         */
       
   350         TInt GetEvents( TUid aDomain, 
       
   351                         TUid aCategory,
       
   352                         REventList& aEvents );
       
   353 
       
   354         /**
       
   355         * Get a list of registered commands.
       
   356         * 
       
   357         * @since S60 3.1
       
   358         * @param aDomain    The identifier of the domain.
       
   359         * @param aCategory  The identifier of the category.
       
   360         * @param aCommands  The list of registered commands for the category.
       
   361         * @return TInt indicating the status of the operation.
       
   362         */
       
   363         TInt GetCommands( TUid aDomain, 
       
   364                           TUid aCategory,
       
   365                           RCommandList& aCommands );
       
   366         
       
   367         /**
       
   368         * Get a list of registered commands.
       
   369         * 
       
   370         * @since S60 3.1
       
   371         * @param aStatus            TRequestStatus of the operation to be completed when notification is received.
       
   372         * @param aCategoryBuffer    Category buffer.
       
   373         * @param aTypeBuffer        Type buffer
       
   374         * @param aEventArrayPtr     Pointer descriptor to buffer where event data is written.
       
   375         * @param aCommandArrayPtr   Pointer descriptor to buffer where command data is written.
       
   376         * @return None.
       
   377         */                  
       
   378         void ReceiveNotifications( TRequestStatus& aStatus,
       
   379                                    TMediatorCategoryRetBuffer& aCategoryBuffer,
       
   380                                    TNotificationTypeRetBuffer& aTypeBuffer,
       
   381                                    TPtr8& aEventArrayPtr, 
       
   382                                    TPtr8& aCommandArrayPtr );
       
   383         
       
   384         /**
       
   385         * Get a list of registered commands.
       
   386         * 
       
   387         * @since S60 3.1
       
   388         * @return TInt indicating the status of the operation.
       
   389         */                  
       
   390         TInt CancelNotifications();
       
   391     
       
   392     public: // Mediator Service  - Common
       
   393     
       
   394         /**
       
   395         * Fetch parameter data, if data size was larger than default boundary.
       
   396         * 
       
   397         * @since S60 3.1
       
   398         * @param aParameterData pointer to data buffer where Mediator writes data
       
   399         * @return TInt indicating the status of the operation.
       
   400         */                  
       
   401         TInt FetchParameterData( TPtr8& aParameterData );
       
   402         
       
   403         /**
       
   404         * Fetch event list, if list size was larger than default boundary.
       
   405         * 
       
   406         * @since S60 3.1
       
   407         * @param aEventArrayPtr pointer to data buffer where Mediator writes data
       
   408         * @return TInt indicating the status of the operation.
       
   409         */  
       
   410         TInt FetchNotificationEventList( TPtr8& aEventArrayPtr );
       
   411         
       
   412         /**
       
   413         * Fetch command list, if list size was larger than default boundary.
       
   414         * 
       
   415         * @since S60 3.1
       
   416         * @param aCommandArrayPtr pointer to data buffer where Mediator writes data
       
   417         * @return TInt indicating the status of the operation.
       
   418         */  
       
   419         TInt FetchNotificationCommandList( TPtr8& aCommandArrayPtr );
       
   420                 
       
   421     private:
       
   422     
       
   423         /**
       
   424         * Gets server version information.
       
   425         * @since S60 3.1
       
   426         * @param None
       
   427         * @return Version structure
       
   428         */
       
   429 	    TVersion Version() const;
       
   430 	    
       
   431         /**
       
   432         * Server start function
       
   433         *
       
   434         * @since S60 3.1
       
   435         * @param None
       
   436         * @return KErrNone          server process was succesfully started
       
   437         *         KErrAlreadyExists server process was already running
       
   438         *         TInt              other system wide error code
       
   439         */
       
   440         TInt StartServer();
       
   441 	    
       
   442     private: // Data        
       
   443          
       
   444 	};
       
   445 
       
   446 
       
   447 #endif  // MEDIATORSERVERSESSION_H
       
   448 
       
   449 // End of file