homescreenpluginsrv/hspsmanager/client/hspsclientsession.cpp
changeset 0 79c6a41cd166
child 4 1a2a00e78665
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 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:  Implementaion of ChspsClientSession class.
       
    15 *                For details, see hspsClientSession.h.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <e32svr.h>
       
    22 #include "hsps_builds_cfg.hrh"
       
    23 #include "hspsthememanagement.h"
       
    24 #include "hspsthemeserver.h"
       
    25 #include "hspsclientsession.h"
       
    26 
       
    27 // Standard server startup code
       
    28 static TInt StartServer()
       
    29     {
       
    30     const TUidType serverUid(KNullUid,KNullUid,KhspsThemeServerUid3);
       
    31     // ------------------------------------------------------------------------ 
       
    32     // EPOC and EKA2 just create a new server process. Simultaneous
       
    33     // launching of two such processes should be detected when the second one
       
    34     // attempts to create the server object, failing with KErrAlreadyExists.
       
    35     // ------------------------------------------------------------------------
       
    36     RProcess server;
       
    37     TInt r=server.Create(KhspsThemeServerName,KNullDesC);
       
    38     if (r!=KErrNone)
       
    39         {
       
    40 #ifdef _hsps_DEBUG_          
       
    41         RDebug::Print(_L("hspsClientSession: server start failed %d"),r);
       
    42 #endif        
       
    43         return r;
       
    44         }
       
    45     TRequestStatus stat;
       
    46     server.Rendezvous(stat);
       
    47     if (stat!=KRequestPending)
       
    48         {
       
    49         server.Kill(0);   // abort startup
       
    50         }
       
    51     else
       
    52         {
       
    53         server.Resume();  // logon OK - start the server
       
    54         }
       
    55 
       
    56     User::WaitForRequest(stat);   // wait for start or death
       
    57     // ------------------------------------------------------------------------ 
       
    58     // we can't use the 'exit reason' if the server panicked as this
       
    59     // is the panic 'reason' and may be '0' which cannot be distinguished
       
    60     // from KErrNone
       
    61     ///
       
    62     r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
       
    63     server.Close();
       
    64     return r;
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // RhspsClientSession::Connect
       
    70 // This is the standard retry pattern for server connection
       
    71 // (other items were commented in a header).
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C TInt RhspsClientSession::Connect()
       
    75     {
       
    76     TVersion ver = TVersion(KhspsThemeServerMajorVersionNumber,KhspsThemeServerMinorVersionNumber,
       
    77                                                              KhspsThemeServerBuildVersionNumber);    
       
    78     TInt retry=2;
       
    79     for (;;)
       
    80         {
       
    81         TInt r=CreateSession(KhspsThemeServerName, ver, KDefaultMessageSlots);
       
    82   
       
    83         if (r!=KErrNotFound && r!=KErrServerTerminated)
       
    84             {
       
    85             return r;
       
    86             }
       
    87         
       
    88         if (--retry==0)
       
    89             {
       
    90             return r;
       
    91             }
       
    92         
       
    93         r=StartServer();
       
    94         if (r!=KErrNone && r!=KErrAlreadyExists)
       
    95             {
       
    96             return r;
       
    97             }
       
    98         }
       
    99     }
       
   100   
       
   101 // -----------------------------------------------------------------------------
       
   102 // RhspsClientSession::Close()
       
   103 // Closes the session
       
   104 // (other items were commented in a header).
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C void RhspsClientSession::Close()
       
   108     {
       
   109     RSessionBase::Close();
       
   110     }
       
   111 
       
   112 
       
   113 // ----------------------------------------------------------------------------------------
       
   114 // Client Server functions follow
       
   115 // ----------------------------------------------------------------------------------------
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // RhspsClientSession::InstallTheme
       
   119 // Installation service
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 EXPORT_C TInt RhspsClientSession::InstallTheme(TDes8& aResultData, const TDesC& aManifestFileName,
       
   124                        TDes8& aHeaderData)
       
   125     {
       
   126     aHeaderData.Zero();
       
   127     aResultData.Zero();
       
   128     return SendReceive(EhspsInstallTheme,TIpcArgs(&aResultData, &aManifestFileName, &aHeaderData)); 
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // RhspsClientSession::InstallNextPhase
       
   133 // Calls for the next phase of the installation
       
   134 // (other items were commented in a header).
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void RhspsClientSession::InstallNextPhase(TDes8& aResultData, TDes8& aHeaderData,
       
   138                          TRequestStatus& aStatus)
       
   139     {
       
   140     aHeaderData.Zero();
       
   141     aResultData.Zero();
       
   142     TIpcArgs args;
       
   143     args.Set(0, &aResultData );
       
   144     args.Set(1, &KNullDesC8);
       
   145     args.Set(2, &aHeaderData);
       
   146     SendReceive(EhspsInstallNextPhase, args, aStatus);  
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // RhspsClientSession::GetListHeaders
       
   151 // Maintenance service, header listing
       
   152 // (other items were commented in a header).
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 EXPORT_C TInt RhspsClientSession::GetListHeaders(TDes8& aResultData, const TDesC8& aSearchMaskData,
       
   156                          TDes8& aHeaderData)
       
   157     {
       
   158     aHeaderData.Zero();
       
   159     aResultData.Zero();
       
   160     return SendReceive(EhspsGetListHeaders, TIpcArgs(&aResultData, &aSearchMaskData, &aHeaderData));  
       
   161     } 
       
   162   
       
   163 // -----------------------------------------------------------------------------
       
   164 // RhspsClientSession::GetNextHeader
       
   165 // (other items were commented in a header).
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 EXPORT_C void RhspsClientSession::GetNextHeader(TDes8& aResultData, TDes8& aHeaderData, 
       
   169                         TRequestStatus& aStatus)
       
   170     {
       
   171     aHeaderData.Zero();
       
   172     aResultData.Zero();
       
   173     TIpcArgs args;
       
   174     args.Set(0, &aResultData );
       
   175     args.Set(1, &KNullDesC8);
       
   176     args.Set(2, &aHeaderData);
       
   177     SendReceive(EhspsGetNextHeader, args, aStatus); 
       
   178     }
       
   179   
       
   180 // -----------------------------------------------------------------------------
       
   181 // RhspsClientSession::SetActiveTheme
       
   182 // Theme activation
       
   183 // (other items were commented in a header).
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 EXPORT_C TInt RhspsClientSession::SetActiveTheme(TDes8& aResultData, const TDesC8& aSetMaskData,
       
   187                          TDes8& aHeaderData)
       
   188     {
       
   189     aHeaderData.Zero();
       
   190     aResultData.Zero(); 
       
   191     return SendReceive(EhspsSetActiveTheme, TIpcArgs(&aResultData, &aSetMaskData, &aHeaderData)); 
       
   192     }
       
   193   
       
   194 // -----------------------------------------------------------------------------
       
   195 // RhspsClientSession::RestoreDefault
       
   196 // Restore defaults
       
   197 // (other items were commented in a header).
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 EXPORT_C TInt RhspsClientSession::RestoreDefault(TDes8& aResultData, const TDesC8& aSetMaskData,
       
   201                          TDes8& aHeaderData)
       
   202     {
       
   203     aHeaderData.Zero(); 
       
   204     aResultData.Zero();
       
   205     return SendReceive( EhspsRestoreDefault, TIpcArgs(&aResultData, &aSetMaskData, &aHeaderData) ); 
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // RhspsClientSession::RemoveTheme
       
   210 // Theme removal
       
   211 // (other items were commented in a header).
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 EXPORT_C TInt RhspsClientSession::RemoveTheme(TDes8& aResultData, const TDesC8& aSetMaskData)
       
   215     {
       
   216     aResultData.Zero();
       
   217     return SendReceive(EhspsRemoveTheme, TIpcArgs(&aResultData, &aSetMaskData));  
       
   218     }
       
   219 
       
   220 /* Client Request service */
       
   221 // -----------------------------------------------------------------------------
       
   222 // RhspsClientSession::GetODT
       
   223 // (other items were commented in a header).
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 EXPORT_C TInt RhspsClientSession::GetODT(
       
   227 		TDes8& aResultData, 
       
   228 		const ThspsConfiguration& aConfiguration,
       
   229 		const TDesC8& aRequestData, 
       
   230 		TDes& aODTPath)
       
   231     {
       
   232     // Setup packaged input for the service               
       
   233     TPckgC<ThspsConfiguration> packagedStruct(aConfiguration);
       
   234         
       
   235     aResultData.Zero();
       
   236     aODTPath.Zero();
       
   237     return SendReceive(EhspsGetODT,TIpcArgs(&aResultData, &packagedStruct, &aRequestData, &aODTPath )); 
       
   238     }
       
   239   
       
   240 // -----------------------------------------------------------------------------
       
   241 // RhspsClientSession::GetODTUpdate
       
   242 // (other items were commented in a header).
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 EXPORT_C void RhspsClientSession::GetODTUpdate(TDes8& aResultData,
       
   246                                                TDes8& aRequestNotifyData,
       
   247                                                TDes8& aHeaderData,   
       
   248                                                TRequestStatus& aStatus)
       
   249     {
       
   250     aHeaderData.Zero();
       
   251     aResultData.Zero();
       
   252     aRequestNotifyData.Zero();
       
   253     TIpcArgs args;
       
   254     args.Set(0, &aResultData );
       
   255     args.Set(1, &aRequestNotifyData);
       
   256     args.Set(2, &aHeaderData);
       
   257   
       
   258     SendReceive(EhspsGetODTUpdate, args, aStatus);  
       
   259     }
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // RhspsClientSession::AccessResourceFile
       
   263 // (other items were commented in a header).
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 EXPORT_C TInt RhspsClientSession::AccessResourceFile(TDes8& aResultData,
       
   267 		const ThspsConfiguration& aConfiguration, const TDesC& aFileName, TInt& aFileHandle)
       
   268     {
       
   269     // Setup packaged input for the service               
       
   270     TPckgC<ThspsConfiguration> packagedStruct(aConfiguration);
       
   271            
       
   272     // Setup packaged output from the service
       
   273     TPckgBuf<TInt> packagedFileHandle(0);
       
   274 
       
   275     aResultData.Zero();
       
   276     
       
   277     //IPC slots and contents:
       
   278     //#0 (unused?)
       
   279     //#1 uids in a struct
       
   280     //#2 the file name to open
       
   281     //#3 the handle to the RFile that will be filled in by the server
       
   282             
       
   283     //The return value contains the handle to the RFs that can be used to access the file    
       
   284     TInt fileServerHandle = SendReceive(
       
   285     		EhspsAccessResourceFile,
       
   286     		TIpcArgs(&aResultData, &packagedStruct, &aFileName, &packagedFileHandle)
       
   287     		);        
       
   288     
       
   289     // Set received file handle
       
   290     aFileHandle=packagedFileHandle();
       
   291     
       
   292     return fileServerHandle;
       
   293     }
       
   294 // -----------------------------------------------------------------------------
       
   295 // RhspsClientSession::CopyResourceFiles
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 EXPORT_C TInt RhspsClientSession::CopyResourceFiles( TDes8& aResultData, TDesC& aODTPath, 
       
   300 													TDesC& aDestinationPath )
       
   301 	{
       
   302 	aResultData.Zero();
       
   303 	return SendReceive( EhspsCopyResources, TIpcArgs( &aResultData, &aODTPath, &aDestinationPath ));
       
   304 	}
       
   305 
       
   306 /* Generic functions */
       
   307 // -----------------------------------------------------------------------------
       
   308 // RhspsClientSession::CancelRequest
       
   309 // (other items were commented in a header).
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 EXPORT_C void RhspsClientSession::CancelRequest(TInt aCancelRequestMessage, 
       
   313                                                           TDes8& aResultData, TInt aAppUid )
       
   314     {
       
   315     aResultData.Zero();
       
   316     SendReceive(aCancelRequestMessage, TIpcArgs(&aResultData, aAppUid ));
       
   317     }
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // RhspsClientSession::GetNextHeader
       
   321 // (other items were commented in a header).
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 EXPORT_C TInt RhspsClientSession::GetNextHeader( TDes8& aResultData, TDes8& aHeaderData )
       
   325     {
       
   326     aHeaderData.Zero();
       
   327     aResultData.Zero();
       
   328     TIpcArgs args;
       
   329     args.Set( 0, &aResultData );
       
   330     args.Set( 1, &KNullDesC8 );
       
   331     args.Set( 2, &aHeaderData );
       
   332     return SendReceive( EhspsGetNextHeader, args ); 
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // RhspsClientSession::AddPlugin
       
   337 // Adds a plugin configuration into the defined application configuration
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 EXPORT_C TInt RhspsClientSession::AddPlugin( TDes8& aResultData, const ThpsParamAddPlugin& aParams, TInt& aNewPluginId )
       
   341     {            
       
   342     aResultData.Zero();                          
       
   343     TPckgC<ThpsParamAddPlugin> packagedStruct(aParams);    
       
   344     TPckg<TInt> idDes( aNewPluginId );    
       
   345     return SendReceive(EhspsAddPlugin, TIpcArgs(&aResultData, &packagedStruct, &idDes));             
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // RhspsClientSession::RemovePlugin
       
   350 // Removes a plugin configuration from the defined application configuration
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 EXPORT_C TInt RhspsClientSession::RemovePlugin( TDes8& aResultData, 
       
   354 		const ThpsParamRemovePlugin& aParams )
       
   355     {            
       
   356     aResultData.Zero();                          
       
   357     TPckgC<ThpsParamRemovePlugin> packagedStruct(aParams);            
       
   358     return SendReceive(EhspsRemovePlugin, TIpcArgs(&aResultData, &packagedStruct));             
       
   359     }
       
   360 
       
   361 // -----------------------------------------------------------------------------
       
   362 // RhspsClientSession::SetActivePlugin
       
   363 // Set plugin configuration active.
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 EXPORT_C TInt RhspsClientSession::SetActivePlugin( TDes8& aResultData, 
       
   367         const ThpsParamSetActivePlugin& aParams )
       
   368     {            
       
   369     
       
   370     aResultData.Zero();                          
       
   371     TPckgC<ThpsParamSetActivePlugin> packagedStruct( aParams );            
       
   372     return SendReceive( EhspsSetActivePlugin, TIpcArgs( &aResultData, &packagedStruct ) );
       
   373     }
       
   374 
       
   375 // -----------------------------------------------------------------------------
       
   376 // RhspsClientSession::ReplacePlugin
       
   377 // Replaces a plugin configuration in the active application configuration
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 EXPORT_C TInt RhspsClientSession::ReplacePlugin( 
       
   381         TDes8& aResultData, 
       
   382         const ThspsParamReplacePlugin& aParams )
       
   383     {            
       
   384     aResultData.Zero();                          
       
   385     TPckgC<ThspsParamReplacePlugin> packagedStruct(aParams);            
       
   386     return SendReceive(EhspsReplacePlugin, TIpcArgs(&aResultData, &packagedStruct));             
       
   387     }
       
   388 
       
   389 // -----------------------------------------------------------------------------
       
   390 // RhspsClientSession::GetPluginOdt
       
   391 // Returns odt path accoring given uid
       
   392 // -----------------------------------------------------------------------------
       
   393 //
       
   394 EXPORT_C TInt RhspsClientSession::GetPluginOdt( TDes8& aResultData, 
       
   395 		const ThspsParamGetPluginOdt& aParams, 
       
   396 		TDes& aOdtPath )
       
   397     {
       
   398     aResultData.Zero();     
       
   399     TPckgC<ThspsParamGetPluginOdt> packagedStruct(aParams);    
       
   400     return SendReceive( EhspsGetPluginOdt, TIpcArgs(&aResultData, &packagedStruct, &aOdtPath) );             
       
   401     }
       
   402 
       
   403 // -----------------------------------------------------------------------------
       
   404 // RhspsClientSession::SetPluginSettings
       
   405 // Personalizes settings in a plugin configuration
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 EXPORT_C TInt RhspsClientSession::SetPluginSettings( TDes8& aResultData,
       
   409         TDes8& aSearchMaskData,
       
   410         ThspsParamSetPluginSettings aParams,
       
   411         TDes8& aDomData )
       
   412     {
       
   413     aResultData.Zero();                          
       
   414     TPckgC<ThspsParamSetPluginSettings> packagedStruct(aParams);  
       
   415     return SendReceive(EhspsSetPluginSettings, TIpcArgs( &aResultData, &aSearchMaskData, &packagedStruct, &aDomData ));  
       
   416     }
       
   417 
       
   418 // -----------------------------------------------------------------------------
       
   419 // RhspsClientSession::MovePlugins
       
   420 // Updates plugin positions within a configuration
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 EXPORT_C TInt RhspsClientSession::MovePlugins( TDes8& aResultData, const ThpsParamMovePlugins& aParams )
       
   424     {
       
   425     aResultData.Zero();                          
       
   426     TPckgC<ThpsParamMovePlugins> packagedStruct(aParams);            
       
   427     return SendReceive(EhspsMovePlugins, TIpcArgs(&aResultData, &packagedStruct));             
       
   428     }
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 // RhspsClientSession::SetConfState
       
   432 // Updates configuration state
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 EXPORT_C TInt RhspsClientSession::SetConfState( 
       
   436     TDes8& aResultData, 
       
   437     const ThspsParamSetConfState& aParams )
       
   438     {
       
   439     aResultData.Zero();                          
       
   440     TPckgC<ThspsParamSetConfState> packagedStruct( aParams );            
       
   441     return SendReceive( EhspsSetConfState, TIpcArgs( &aResultData, &packagedStruct ) );             
       
   442     }
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // RhspsClientSession::ReinstallConf
       
   446 // Updates configuration state
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 EXPORT_C TInt RhspsClientSession::ReinstallConf( 
       
   450     TDes8& aResultData, 
       
   451     const ThspsParamReinstallConf& aParams )
       
   452     {
       
   453     aResultData.Zero();                          
       
   454     TPckgC<ThspsParamReinstallConf> packagedStruct( aParams );            
       
   455     return SendReceive( EhspsReinstallConf, TIpcArgs( &aResultData, &packagedStruct ) );             
       
   456     }
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // RhspsClientSession::RestoreActiveAppConf
       
   460 // Restores active application configuration
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 EXPORT_C TInt RhspsClientSession::RestoreActiveAppConf( 
       
   464     TDes8& aResultData, 
       
   465     const ThspsParamRestoreActiveAppConf& aParams )
       
   466     {
       
   467     aResultData.Zero();                          
       
   468     TPckgC<ThspsParamRestoreActiveAppConf> packagedStruct( aParams );            
       
   469     return SendReceive( EhspsRestoreActiveAppConf, TIpcArgs( &aResultData, &packagedStruct ) );             
       
   470     }
       
   471 
       
   472 // end of file
       
   473