stif/TestEngine/src/SettingServerClient.cpp
changeset 0 a03f92240627
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     1 /*
       
     2 * Copyright (c) 2009 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 module contain implementation of RSettingServer 
       
    15 * class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32svr.h>
       
    21 #include "SettingServerClient.h"
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 
       
    25 // EXTERNAL FUNCTION PROTOTYPES
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // MACROS
       
    30 
       
    31 // LOCAL CONSTANTS AND MACROS
       
    32 
       
    33 // MODULE DATA STRUCTURES
       
    34 
       
    35 // LOCAL FUNCTION PROTOTYPES
       
    36 
       
    37 // Function for starting the Setting server
       
    38 IMPORT_C TInt StartNewServer( TName& aServerName );
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 
       
    42 // ==================== LOCAL FUNCTIONS =======================================
       
    43 
       
    44 // None
       
    45 
       
    46 // ================= MEMBER FUNCTIONS =========================================
       
    47 
       
    48 /*
       
    49 -------------------------------------------------------------------------------
       
    50 
       
    51     Class: RSettingServer
       
    52 
       
    53     Method: RSettingServer
       
    54 
       
    55     Description: Default constructor
       
    56 
       
    57     C++ default constructor can NOT contain any code, that
       
    58     might leave.
       
    59 
       
    60     Parameters: None
       
    61 
       
    62     Return Values: None
       
    63 
       
    64     Errors/Exceptions: None
       
    65 
       
    66     Status: Proposal
       
    67 
       
    68 -------------------------------------------------------------------------------
       
    69 */
       
    70 EXPORT_C RSettingServer::RSettingServer()
       
    71     {
       
    72 
       
    73     }
       
    74 
       
    75 /*
       
    76 -------------------------------------------------------------------------------
       
    77 
       
    78     Class: RSettingServer
       
    79 
       
    80     Method: Connect
       
    81 
       
    82     Description: Connect method creates new RSettingServer session.
       
    83     First the server is tried to start. If start is successfull or server is
       
    84     already started, then a new session is created.  
       
    85 
       
    86     Parameters: None
       
    87 
       
    88     Return Values: TInt: Error code
       
    89 
       
    90     Errors/Exceptions: None
       
    91 
       
    92     Status: Proposal
       
    93 
       
    94 -------------------------------------------------------------------------------
       
    95 */
       
    96 EXPORT_C TInt RSettingServer::Connect()
       
    97     {
       
    98     TName serverName;
       
    99     TInt ret = StartNewServer( serverName );
       
   100 
       
   101     if( ret == KErrNone || ret == KErrAlreadyExists )
       
   102         {
       
   103         ret = CreateSession( serverName, Version() );
       
   104         }
       
   105 
       
   106     return ret;
       
   107 
       
   108     }
       
   109 
       
   110 /*
       
   111 -------------------------------------------------------------------------------
       
   112 
       
   113     Class: RSettingServer
       
   114 
       
   115     Method: Version
       
   116 
       
   117     Description: Return client side version.
       
   118 
       
   119     Parameters: None
       
   120 
       
   121     Return Values: TVersion: Version number
       
   122 
       
   123     Errors/Exceptions: None
       
   124 
       
   125     Status: Proposal
       
   126 
       
   127 -------------------------------------------------------------------------------
       
   128 */
       
   129 EXPORT_C TVersion RSettingServer::Version() const
       
   130     {
       
   131     return( TVersion( KSettingServerMajorVersionNumber,
       
   132                       KSettingServerMinorVersionNumber, 
       
   133                       KSettingServerVersionNumber 
       
   134                      ) );
       
   135 
       
   136     }
       
   137 
       
   138 /*
       
   139 -------------------------------------------------------------------------------
       
   140 
       
   141     Class: RSettingServer
       
   142 
       
   143     Method: Close
       
   144 
       
   145     Description: Closes the RSettingServer session.
       
   146 
       
   147     Parameters: None
       
   148 
       
   149     Return Values: None
       
   150 
       
   151     Errors/Exceptions: None
       
   152 
       
   153     Status: Proposal
       
   154 
       
   155 -------------------------------------------------------------------------------
       
   156 */
       
   157 EXPORT_C void RSettingServer::Close()
       
   158     {
       
   159     // Check that server is connected and send close message to it if possible.
       
   160     if( Handle() != 0 )
       
   161         {
       
   162         TIpcArgs args( TIpcArgs::ENothing, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   163         // Goes to CSettingServer's DispatchMessageL() method
       
   164         SendReceive( ESettingServerCloseSession, args );
       
   165         }
       
   166 
       
   167     RSessionBase::Close();
       
   168 
       
   169     }
       
   170 
       
   171 /*
       
   172 -------------------------------------------------------------------------------
       
   173 
       
   174     Class: RSettingServer
       
   175 
       
   176     Method: SetIniFileInformation
       
   177 
       
   178     Description: Set initialization filename and path settings to Setting
       
   179                  server.
       
   180 
       
   181     Parameters: const TFileName& aIniFile: in: Filename and path information.
       
   182 
       
   183     Return Values: TInt: Symbian error code
       
   184 
       
   185     Errors/Exceptions: None
       
   186 
       
   187     Status: Proposal
       
   188     
       
   189 -------------------------------------------------------------------------------
       
   190 */
       
   191 EXPORT_C TInt RSettingServer::SetIniFileInformation( const TFileName& aIniFile )
       
   192     {
       
   193     TIpcArgs args( &aIniFile, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   194     // Goes to CSettingServer's DispatchMessageL() method
       
   195     SendReceive( ESetIniFileInformation, args );
       
   196 
       
   197     return KErrNone;
       
   198 
       
   199     }
       
   200 
       
   201 /*
       
   202 -------------------------------------------------------------------------------
       
   203 
       
   204     Class: RSettingServer
       
   205 
       
   206     Method: ReadLoggerSettingsFromIniFile
       
   207 
       
   208     Description: Read Logger setting from initialization file. Mainly use from
       
   209                  TestEngine side.
       
   210 
       
   211     Parameters: TLoggerSettings& aLoggerSettings: inout: Logger's overwrite
       
   212                 struct
       
   213 
       
   214     Return Values: TInt: Symbian error code
       
   215 
       
   216     Errors/Exceptions: None
       
   217 
       
   218     Status: Proposal
       
   219 
       
   220 -------------------------------------------------------------------------------
       
   221 */
       
   222 EXPORT_C TInt RSettingServer::ReadLoggerSettingsFromIniFile( 
       
   223                                             TLoggerSettings& aLoggerSettings )
       
   224     {
       
   225     // Package
       
   226     TPckg<TLoggerSettings> loggerSettingsPckg( aLoggerSettings );
       
   227 
       
   228 	TIpcArgs args( &loggerSettingsPckg, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   229     // Goes to CSettingServer's DispatchMessageL() method
       
   230     SendReceive( EReadLoggerSettingsFromIniFile, args );
       
   231    
       
   232     return KErrNone;
       
   233 
       
   234     }
       
   235 
       
   236 /*
       
   237 -------------------------------------------------------------------------------
       
   238 
       
   239     Class: RSettingServer
       
   240 
       
   241     Method: GetLoggerSettings
       
   242 
       
   243     Description: Get Logger settings. Mainly use from Logger side.
       
   244 
       
   245     Parameters: TLoggerSettings& aLoggerSettings: in: Logger's overwrite struct
       
   246 
       
   247     Return Values: TInt: Symbian error code
       
   248 
       
   249     Errors/Exceptions: None
       
   250 
       
   251     Status: Proposal
       
   252 
       
   253 -------------------------------------------------------------------------------
       
   254 */
       
   255 EXPORT_C TInt RSettingServer::GetLoggerSettings( 
       
   256                                             TLoggerSettings& aLoggerSettings )
       
   257     {
       
   258     // Package
       
   259     TPckg<TLoggerSettings> loggerSettingsPckg( aLoggerSettings );
       
   260 
       
   261 	TIpcArgs args( &loggerSettingsPckg, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   262     // Goes to CSettingServer's DispatchMessageL() method
       
   263     SendReceive( EGetLoggerSettings, args );
       
   264 
       
   265     return KErrNone;
       
   266 
       
   267     }
       
   268 
       
   269 /*
       
   270 -------------------------------------------------------------------------------
       
   271 
       
   272     Class: RSettingServer
       
   273 
       
   274     Method: SetIniFileSetting
       
   275 
       
   276     Description: Set new initialization file setting(e.g. SetAttribute).
       
   277 
       
   278     Parameters: TName& aNewIniFileSetting: in: New setting
       
   279 
       
   280     Return Values: TInt: Symbian error code
       
   281 
       
   282     Errors/Exceptions: None
       
   283 
       
   284     Status: Proposal
       
   285 
       
   286 -------------------------------------------------------------------------------
       
   287 */
       
   288 EXPORT_C TInt RSettingServer::SetNewIniFileSetting( TName& aNewIniFileSetting )
       
   289     {
       
   290 	TIpcArgs args( &aNewIniFileSetting, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   291     // Goes to CSettingServer's DispatchMessageL() method
       
   292     SendReceive( ESetNewIniFileSetting, args );
       
   293 
       
   294     return KErrNone;
       
   295 
       
   296     }
       
   297 
       
   298 /*
       
   299 -------------------------------------------------------------------------------
       
   300 
       
   301     Class: RSettingServer
       
   302 
       
   303     Method: GetEngineSettings
       
   304 
       
   305     Description: Get Engine settings.
       
   306 
       
   307     Parameters: TEngineSettings& aEngineSettings: in: Engine settings struct
       
   308 
       
   309     Return Values: TInt: Symbian error code
       
   310 
       
   311     Errors/Exceptions: None
       
   312 
       
   313     Status: Proposal
       
   314 
       
   315 -------------------------------------------------------------------------------
       
   316 */
       
   317 EXPORT_C TInt RSettingServer::GetEngineSettings(TEngineSettings& aEngineSettings)
       
   318     {
       
   319     // Package
       
   320     TPckg<TEngineSettings> engineSettingsPckg(aEngineSettings);
       
   321 
       
   322     TIpcArgs args(&engineSettingsPckg, TIpcArgs::ENothing, TIpcArgs::ENothing);
       
   323     // Goes to CSettingServer's DispatchMessageL() method
       
   324     SendReceive(EGetEngineSettings, args);
       
   325 
       
   326     return KErrNone;
       
   327     }
       
   328 
       
   329 /*
       
   330 -------------------------------------------------------------------------------
       
   331 
       
   332     Class: RSettingServer
       
   333 
       
   334     Method: StoreEngineSettings
       
   335 
       
   336     Description: Store Engine settings.
       
   337 
       
   338     Parameters: TEngineSettings& aEngineSettings: in: Engine settings struct
       
   339 
       
   340     Return Values: TInt: Symbian error code
       
   341 
       
   342     Errors/Exceptions: None
       
   343 
       
   344     Status: Proposal
       
   345 
       
   346 -------------------------------------------------------------------------------
       
   347 */
       
   348 EXPORT_C TInt RSettingServer::StoreEngineSettings(TEngineSettings& aEngineSettings)
       
   349     {
       
   350     // Package
       
   351     TPckg<TEngineSettings> engineSettingsPckg(aEngineSettings);
       
   352 
       
   353     TIpcArgs args(&engineSettingsPckg, TIpcArgs::ENothing, TIpcArgs::ENothing);
       
   354     // Goes to CSettingServer's DispatchMessageL() method
       
   355     SendReceive(EStoreEngineSettings, args);
       
   356 
       
   357     return KErrNone;
       
   358     }
       
   359 
       
   360 // End of File