accessoryservices/accessoryserver/inc/Server/AccServer.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Server's side server class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CACCSERVER_H
       
    20 #define CACCSERVER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "AccClientServerMessages.h"
       
    24 #include "AsyProxyAPI.h"
       
    25 #include <e32base.h>
       
    26 
       
    27 // CONSTANTS
       
    28 // ----------------------------------------------------------------------------------------
       
    29 // Accessory Server's policy
       
    30 // ----------------------------------------------------------------------------------------
       
    31 
       
    32 //Total number of ranges
       
    33 const TUint KAccessoryServerRangeCount = 7;
       
    34 
       
    35 //Definition of the ranges of IPC numbers
       
    36 const TInt accessoryServerRanges[KAccessoryServerRangeCount] =
       
    37     {
       
    38     EAccSrvCreateSubSessionAccessoryMode,        //0th range. Accessory API;               EAccSrvCreateSubSessionAccessoryMode -> EAccSrvGetValueTDes8
       
    39     EAccSrvCreateSubSessionAccessoryConnection,  //1st range. Accessory & Accessory Monitoring API; EAccSrvCreateSubSessionAccessoryConnection -> EAccSrvGetValueTInt
       
    40     EAccSrvCreateSubSessionAccessoryControl,     //2nd range, Accessory Control API;       EAccSrvCreateSubSessionAccessoryControl -> EAccSrvSetAccessoryModeSettings
       
    41     EAccSrvCreateSubSessionAccessoryBTControl,   //3rd range, Accessory BT Control API ;   EAccSrvCreateSubSessionAccessoryBTControl -> EAccSrvCancelNotifyBluetoothAudioLinkCloseReq
       
    42     EAccSrvCreateSubSessionAccessoryAudioControl,//4th range, Accessory Audio Control API; EAccSrvCreateSubSessionAccessoryAudioControl->EAccSrvCancelNotifyAccessoryAudioLinkClosed
       
    43     EAccSrvCreateSubSessionAccessoryAsyComms,    //5th range, Accessory Asy Comms API;     EAccSrvCreateSubSessionAccessoryAsyComms->EAccSrvProcessResponseTDes    
       
    44     EAccSrvUnknown                               //6th range,                              non implemented function end of range check ; ENotSupported
       
    45     };
       
    46 
       
    47 //Policy to implement for each of the above ranges
       
    48 const TUint8 accessoryServerElementsIndex[KAccessoryServerRangeCount] =
       
    49     {
       
    50     0,                           //applies to 0th range
       
    51     CPolicyServer::EAlwaysPass,  //applies to 1st range
       
    52     1,                           //applies to 2nd range
       
    53     2,                           //applies to 3rd range
       
    54     2,                           //applies to 4th range
       
    55     3,                           //applies to 5th range    
       
    56     CPolicyServer::ENotSupported //applies to 6th range (out of range IPC)
       
    57     //ECustomCheck
       
    58     //EAlwaysPass
       
    59     };
       
    60 
       
    61 //Specific capability checks
       
    62 const CPolicyServer::TPolicyElement accessoryServerElements[] =
       
    63     {
       
    64     { _INIT_SECURITY_POLICY_C1( ECapabilityReadUserData ), CPolicyServer::EFailClient },     //policy "0"
       
    65     { _INIT_SECURITY_POLICY_C3( ECapabilityReadUserData,
       
    66                                 ECapabilityReadDeviceData,
       
    67                                 ECapabilityWriteDeviceData
       
    68                              /* ECapabilityDRM */
       
    69                              /* ECapabilityLocalServices */), CPolicyServer::EFailClient },//policy "1"
       
    70     { _INIT_SECURITY_POLICY_C4( ECapabilityReadUserData,
       
    71                                 ECapabilityReadDeviceData,
       
    72                                 ECapabilityWriteDeviceData,
       
    73                              /* ECapabilityDRM */
       
    74                              /* ECapabilityLocalServices */
       
    75                                 ECapabilitySurroundingsDD ), CPolicyServer::EFailClient },   //policy "2"
       
    76     { _INIT_SECURITY_POLICY_S0( 0x10205030 ), CPolicyServer::EPanicClient },                 //policy "3", i.e. access is allowed only for AccServer.exe
       
    77     };
       
    78 
       
    79 //Package all the above together into a policy
       
    80 const CPolicyServer::TPolicy accessoryServerPolicy =
       
    81     {
       
    82     CPolicyServer::EAlwaysPass,  //all connect attempts to Accessory Server pass
       
    83     KAccessoryServerRangeCount,  //number of ranges
       
    84     accessoryServerRanges,       //ranges array
       
    85     accessoryServerElementsIndex,//elements<->ranges index
       
    86     accessoryServerElements,     //array of elements
       
    87     };
       
    88 
       
    89 // MACROS
       
    90 _LIT( KASYProxyNotFound, "ASYproxy not found" );
       
    91 
       
    92 // DATA TYPES
       
    93 
       
    94 // FUNCTION PROTOTYPES
       
    95 
       
    96 // FORWARD DECLARATIONS
       
    97 class CASYProxyStarter;
       
    98 class CAccSrvConnectionController;
       
    99 class CAccSrvServerModel;
       
   100 
       
   101 // CLASS DECLARATION
       
   102 /**
       
   103 *  Server's side server class
       
   104 *
       
   105 *  @lib AccServer.exe
       
   106 *  @since S60 3.1
       
   107 */
       
   108 
       
   109 NONSHARABLE_CLASS( CAccServer ) : public CPolicyServer
       
   110     {
       
   111     public: // Constructors and destructor
       
   112 
       
   113         /**
       
   114         * Two-phased constructor.
       
   115         */
       
   116         static CAccServer* NewLC();
       
   117 
       
   118         /**
       
   119         * Destructor.
       
   120         */
       
   121         ~CAccServer();
       
   122 
       
   123     public: // New functions
       
   124 
       
   125         /**
       
   126         * Main function for the server thread.
       
   127         * @since S60 3.1
       
   128         * @param void
       
   129         * @return Error code
       
   130         */
       
   131         static TInt ThreadFunction();
       
   132 
       
   133         /**
       
   134         * Creates one CObjectCon object for every session.
       
   135         * @since S60 3.1
       
   136         * @param void
       
   137         * @return a pointer to a CObjectCon
       
   138         */
       
   139         CObjectCon* NewContainerL();
       
   140 
       
   141         /**
       
   142         * Removes CObjectCon object from the container index and deletes the CObjectCon object.
       
   143         * @since S60 3.2
       
   144         * @param aObjectCon Object container to delete
       
   145         */
       
   146         void RemoveContainer( CObjectCon* aObjectCon );
       
   147 
       
   148     public:    // Functions from base classes
       
   149 
       
   150     protected: // New functions
       
   151 
       
   152     protected: // Functions from base classes
       
   153 
       
   154         /**
       
   155         * From CActive Process any errors
       
   156         */
       
   157         TInt RunError( TInt aError );
       
   158 
       
   159     private:
       
   160 
       
   161         /**
       
   162         * C++ default constructor.
       
   163         */
       
   164         CAccServer(TInt aPriority, TServerType aType);
       
   165 
       
   166         /**
       
   167         * By default Symbian 2nd phase constructor is private.
       
   168         */
       
   169         void ConstructL();
       
   170 
       
   171         /**
       
   172         * Creates instance of ASYProxy
       
   173         */
       
   174         void CreateASYProxyL();
       
   175 
       
   176         /**
       
   177         * Raises panic for this server
       
   178         */
       
   179         static void PanicServer( TAccServerError aReason );
       
   180 
       
   181         /**
       
   182         * Constructs the server.
       
   183         * Creates, initializes and starts the ActiveScheduler.
       
   184         */
       
   185         static void ThreadFunctionL();
       
   186 
       
   187         /**
       
   188         * Creates main session for server
       
   189         */
       
   190         CSession2* NewSessionL( const TVersion &aVersion,
       
   191                                 const RMessage2& aMessage ) const;
       
   192 
       
   193     public:     // Data
       
   194 
       
   195         // pointer to a CObjectConIx
       
   196         CObjectConIx* iObjectConIx; // Owned
       
   197 
       
   198     protected:  // Data
       
   199 
       
   200     private:    // Data
       
   201 
       
   202         CASYProxyAPI*                iProxy; // Owned
       
   203         CASYProxyStarter*            iProxyStarter; // Owned
       
   204 
       
   205         // Connection Controller is treated as singleton in Accessory Server.
       
   206         // This ensures that only one Connection Controller object exist and
       
   207         // its destructed properly.
       
   208         CAccSrvConnectionController* iConnectionController; // Owned
       
   209 
       
   210         // Server Model is treated as singleton in Accessory Server.
       
   211         // This ensures that only one Server Model object exist and
       
   212         // its destructed properly.
       
   213         CAccSrvServerModel*          iServerModel; // Owned
       
   214 
       
   215     public:     // Friend classes
       
   216 
       
   217     protected:  // Friend classes
       
   218 
       
   219     private:    // Friend classes
       
   220 
       
   221     };
       
   222 
       
   223 #endif // CACCSERVER_H
       
   224 
       
   225 // End of File