customization/UISettingsSrv/client/src/UISettingsSrvClient.cpp
changeset 18 7d11f9a6646f
parent 4 75a71fdb4c92
child 21 c707676bf59f
equal deleted inserted replaced
4:75a71fdb4c92 18:7d11f9a6646f
     1 /*
       
     2 * Copyright (c) 2002-2004 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: Implementation of customization components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "UISettingsSrvConstants.h"
       
    22 #include "UISettingsSrvClient.h"
       
    23 
       
    24 #include "UISettingsSrv.h"
       
    25 #include "debug.h"
       
    26 
       
    27 #include <eikdll.h>
       
    28 #include <apacmdln.h>
       
    29 
       
    30 #include <apgcli.h> // apgrfx.lib
       
    31 
       
    32 
       
    33 // Create the server thread
       
    34 // This function is exported from the DLL and called from the client 
       
    35 LOCAL_C TInt StartServerL()
       
    36     {
       
    37 	RDEBUG("UISettingsSrv: Starting server...");
       
    38 
       
    39 	const TUidType serverUid(KNullUid,KNullUid,KUISettingsSrvUid);
       
    40 
       
    41 	// EPOC and EKA 2 is easy, we just create a new server process. Simultaneous
       
    42 	// launching of two such processes should be detected when the second one
       
    43 	// attempts to create the server object, failing with KErrAlreadyExists.
       
    44 	RProcess server;
       
    45 	//TInt r=server.Create(KHelloWorldServerImg,KNullDesC,serverUid);
       
    46 	TInt r = 0;
       
    47 //sf	TInt r=server.Create( KUISettingsSrvImg, KNullDesC );
       
    48 
       
    49 	CApaCommandLine * cmd = CApaCommandLine::NewLC();
       
    50 #if (defined(SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1) || !defined(SYMBIAN_HIDE_UI_FRAMEWORKS_V1)) && !defined(SYMBIAN_REMOVE_UI_FRAMEWORKS_V1)
       
    51 	// cmd->SetLibraryNameL( KUISettingsSrvImg ); // kpo not available in w20
       
    52 #else
       
    53 	cmd->SetExecutableNameL( KUISettingsSrvImg );
       
    54 #endif
       
    55 	cmd->SetDocumentNameL( KNullDesC );
       
    56 //sf-	cmd->SetCommandL( EApaCommandRun );
       
    57 	cmd->SetCommandL( EApaCommandBackground );
       
    58 
       
    59 #if (defined(SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1) || !defined(SYMBIAN_HIDE_UI_FRAMEWORKS_V1)) && !defined(SYMBIAN_REMOVE_UI_FRAMEWORKS_V1)
       
    60 	r = server.Create( KUISettingsSrvImg, cmd->FullCommandLine() );  // kpo not available in w20
       
    61 #else
       
    62 	r = server.Create( KUISettingsSrvImg, KNullDesC() );
       
    63 #endif
       
    64 
       
    65 
       
    66 	cmd->SetProcessEnvironmentL( server );
       
    67 
       
    68 
       
    69 
       
    70 	CleanupStack::PopAndDestroy( cmd );
       
    71 
       
    72 
       
    73 	if ( r != KErrNone )
       
    74 		{
       
    75 		RDEBUG_2( "UISettingsSrv: server start failed %d",r);
       
    76 		return r;
       
    77 		}
       
    78 	TRequestStatus stat;
       
    79 	server.Rendezvous( stat );
       
    80 	if (stat!=KRequestPending)
       
    81 		{
       
    82 		server.Kill(0);		// abort startup
       
    83 		}
       
    84 	else
       
    85 		{
       
    86 		server.Resume();	// logon OK - start the server
       
    87 		}
       
    88 	RDEBUG("UISettingsSrv: Started");
       
    89 
       
    90 	User::WaitForRequest( stat );		// wait for start or death
       
    91 	// we can't use the 'exit reason' if the server panicked as this
       
    92 	// is the panic 'reason' and may be '0' which cannot be distinguished
       
    93 	// from KErrNone
       
    94 	r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
       
    95 	server.Close();
       
    96 	return r;
       
    97     }
       
    98 
       
    99 
       
   100 
       
   101 
       
   102 	
       
   103 
       
   104 
       
   105 
       
   106 // ============================ MEMBER FUNCTIONS ===============================
       
   107 
       
   108 //**********************************
       
   109 //RUISettingsSrv
       
   110 //**********************************
       
   111 
       
   112 EXPORT_C RUISettingsSrv::RUISettingsSrv()
       
   113 	{
       
   114 	}
       
   115 
       
   116 
       
   117 // This is the standard retry pattern for server connection
       
   118 EXPORT_C TInt RUISettingsSrv::Connect()
       
   119 	{
       
   120 	TInt retry=2;
       
   121 	for (;;)
       
   122 		{
       
   123 		TInt r=CreateSession( KUISettingsSrvName, TVersion(0,0,0), 1 );
       
   124 		if ( r != KErrNotFound && r != KErrServerTerminated )
       
   125 			{
       
   126 			return r;
       
   127 			}
       
   128 		if ( --retry == 0 )
       
   129 			{
       
   130 			return r;
       
   131 			}
       
   132 		TRAPD( err, r = StartServerL() );
       
   133 		if( err != KErrNone )
       
   134 			{
       
   135 			return err;
       
   136 			}
       
   137 		if ( r != KErrNone && r != KErrAlreadyExists )
       
   138 			{
       
   139 			return r;
       
   140 			}
       
   141 		}
       
   142 	}
       
   143 
       
   144 // Return the client side version number.
       
   145 EXPORT_C TVersion RUISettingsSrv::Version(void) const
       
   146 	{
       
   147 	return(TVersion(KUISettingsSrvMajorVersionNumber,KUISettingsSrvMinorVersionNumber,KUISettingsSrvBuildVersionNumber));
       
   148 	}
       
   149 
       
   150 EXPORT_C TInt RUISettingsSrv::SetStartupImage( const TDesC& aImagePath )
       
   151 	{
       
   152 	TIpcArgs args( &aImagePath );
       
   153 	return SendReceive( EUISettingsSrvSetStartupImage, args );
       
   154 	}
       
   155 
       
   156 EXPORT_C TInt RUISettingsSrv::GetStartupImagePath( TDes& aImagePath )
       
   157 	{
       
   158 	TIpcArgs args( &aImagePath );
       
   159 	return SendReceive( EUISettingsSrvGetStartupImagePath, args );
       
   160 	}
       
   161 
       
   162 EXPORT_C TInt RUISettingsSrv::SetStartupText( const TDesC& aText )
       
   163     {
       
   164 	TIpcArgs args( &aText );
       
   165 	return SendReceive( EUISettingsSrvSetStartupText, args );
       
   166     }
       
   167 
       
   168 EXPORT_C HBufC* RUISettingsSrv::GetStartupTextL( )
       
   169     {
       
   170 	TInt len = 0;
       
   171 	TPckg<TInt> lenp( len );
       
   172 	TIpcArgs args1( &lenp );
       
   173 	
       
   174 	User::LeaveIfError( SendReceive( EUISettingsSrvGetStartupTextSize, args1 ) );
       
   175 	
       
   176 	HBufC* buf = HBufC::NewLC( len );
       
   177 	TPtr ptr( buf->Des() );
       
   178 	TIpcArgs args2( &ptr );
       
   179 	User::LeaveIfError( SendReceive( EUISettingsSrvGetStartupText, args2 ) );
       
   180 	CleanupStack::Pop( buf );
       
   181 
       
   182 	return buf;
       
   183     }
       
   184 
       
   185 EXPORT_C TInt RUISettingsSrv::SetStartupNoteType( TInt aType )
       
   186     {
       
   187 	TIpcArgs args( aType );
       
   188 	return SendReceive( EUISettingsSrvSetStartupNoteType, args );
       
   189     }
       
   190 
       
   191 EXPORT_C TInt RUISettingsSrv::GetStartupNoteType( TInt &aType )
       
   192     {
       
   193 	TPckg<TInt> typep( aType );
       
   194 	TIpcArgs args( &typep );
       
   195 	return SendReceive( EUISettingsSrvGetStartupNoteType, args );
       
   196     }
       
   197 
       
   198 /* EXPORT_C TInt RUISettingsSrv::UpdateShortcutTargetList()
       
   199     {
       
   200     return SendReceive( EUISettingsSrvUpdateShortcutList );
       
   201     }
       
   202 
       
   203 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetCount( TInt aRtMask, TInt &aCount )
       
   204     {
       
   205 	TPckg<TInt> countp( aCount );
       
   206 	TIpcArgs args( aRtMask, &countp );
       
   207 	return SendReceive( EUISettingsSrvGetShortcutCount, args );
       
   208     }
       
   209 
       
   210 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetType( TInt aRtMask, TInt aIndex, TInt& aType )
       
   211     {
       
   212 	TPckg<TInt> typep( aType );
       
   213 	TIpcArgs args( aRtMask, aIndex, &typep );
       
   214 	return SendReceive( EUISettingsSrvGetShortcutType, args );
       
   215     }
       
   216 
       
   217 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetCaption( TInt aRtMask, TInt aIndex, TDes& aCaption )
       
   218     {
       
   219 	TIpcArgs args( aRtMask, aIndex, &aCaption );
       
   220 	return SendReceive( EUISettingsSrvGetShortcutTargetCaption, args );
       
   221     }
       
   222 
       
   223 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetAppUid( TInt aRtMask, TInt aIndex, TInt& aUid )
       
   224     {
       
   225     TPckg<TInt> uidp( aUid );
       
   226 	TIpcArgs args( aRtMask, aIndex, &uidp );
       
   227 	return SendReceive( EUISettingsSrvGetShortcutAppUid, args );
       
   228     }
       
   229 
       
   230 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetIndex( TInt aRtMask, TScActionType aActionType, TInt& aIndex )
       
   231     {
       
   232     TPckg<TInt> indexp( aIndex );
       
   233 	TIpcArgs args( aRtMask, aActionType.iUid, &indexp );
       
   234 	return SendReceive( EUISettingsSrvGetShortcutIndexFromAT, args );
       
   235     }
       
   236 
       
   237 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetIndex( TInt aRtMask, TInt aUid, TInt& aIndex )
       
   238     {
       
   239     TPckg<TInt> indexp( aIndex );
       
   240 	TIpcArgs args( aRtMask, aUid, &indexp );
       
   241 	return SendReceive( EUISettingsSrvGetShortcutIndex, args );
       
   242     }
       
   243 
       
   244 EXPORT_C TInt RUISettingsSrv::SetShortcutTargetAppIndex( TInt aActionType, TInt aRtType, TInt aIndex )
       
   245     {
       
   246 	TIpcArgs args( aRtType, aActionType, aIndex );
       
   247 	return SendReceive( EUISettingsSrvSetShortcutTargetAppIndex, args );
       
   248     }
       
   249 
       
   250 EXPORT_C TInt RUISettingsSrv::GetShortcutRtType( TInt aActionType, TInt &aRtType )
       
   251     {
       
   252     TPckg<TInt> rttypep( aRtType );
       
   253 	TIpcArgs args( aActionType, &rttypep );
       
   254 	return SendReceive( EUISettingsSrvGetShortcutRtType, args );
       
   255     }
       
   256 
       
   257 EXPORT_C TInt RUISettingsSrv::SetShortcutTargetCaption( TInt aRtMask, TInt aIndex, const TDesC& aCaption)
       
   258     {
       
   259 	TIpcArgs args( aRtMask, aIndex, &aCaption );
       
   260 	return SendReceive( EUISettingsSrvSetShortcutTargetCaption, args );	
       
   261     }
       
   262 
       
   263 EXPORT_C TInt RUISettingsSrv::SetShortcutTargetBitmap( TInt aRtMask, TInt aIndex, const TDesC& aFileName, const TDesC8& aMimeType )
       
   264     {
       
   265 	TIpcArgs args( aRtMask, aIndex, &aFileName, &aMimeType );
       
   266 	return SendReceive( EUISettingsSrvSetShortcutTargetBitmap, args );
       
   267     }
       
   268 
       
   269 EXPORT_C TInt RUISettingsSrv::SetShortcutTargetMask( TInt aRtMask, TInt aIndex, const TDesC& aFileName, const TDesC8& aMimeType )
       
   270     {
       
   271 	TIpcArgs args( aRtMask, aIndex, &aFileName, &aMimeType );
       
   272 	return SendReceive( EUISettingsSrvSetShortcutTargetMask, args );
       
   273     }
       
   274 
       
   275 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetBitmap( TInt aRtMask, TInt aIndex, TDes& aFileName, TDes8& aMimeType )
       
   276     {
       
   277 	TIpcArgs args( aRtMask, aIndex, &aFileName, &aMimeType );
       
   278 	return SendReceive( EUISettingsSrvGetShortcutTargetBitmap, args );
       
   279     }
       
   280 
       
   281 EXPORT_C TInt RUISettingsSrv::GetShortcutTargetMask( TInt aRtMask, TInt aIndex, TDes& aFileName, TDes8& aMimeType )
       
   282     {
       
   283 	TIpcArgs args( aRtMask, aIndex, &aFileName, &aMimeType );
       
   284 	return SendReceive( EUISettingsSrvGetShortcutTargetMask, args );
       
   285     }
       
   286 */
       
   287 EXPORT_C TInt RUISettingsSrv::GetSoftkeyBitmap( TInt aSoftkeyId,
       
   288                                                 TDes& aFileName,
       
   289                                                 TDes8& aMimeType )
       
   290     {
       
   291 	TIpcArgs args( aSoftkeyId, &aFileName, &aMimeType );
       
   292 	return SendReceive( EUISettingsSrvGetSoftkeyBitmap, args );
       
   293     }
       
   294 
       
   295 EXPORT_C TInt RUISettingsSrv::GetSoftkeyMask( TInt aSoftkeyId,
       
   296                                               TDes& aFileName,
       
   297                                               TDes8& aMimeType )
       
   298     {
       
   299 	TIpcArgs args( aSoftkeyId, &aFileName, &aMimeType );
       
   300 	return SendReceive( EUISettingsSrvGetSoftkeyMask, args );
       
   301     }
       
   302 
       
   303 EXPORT_C TInt RUISettingsSrv::SetSoftkeyBitmap (
       
   304                                           TInt aSoftkeyId,
       
   305                                           const TDesC& aFileName,
       
   306                                           const TDesC8& aMimeType )
       
   307     {
       
   308 	TIpcArgs args( aSoftkeyId, &aFileName, &aMimeType );
       
   309 	return SendReceive( EUISettingsSrvSetSoftkeyBitmap, args );
       
   310     }
       
   311 
       
   312 EXPORT_C TInt RUISettingsSrv::SetSoftkeyMask (
       
   313                                           TInt aSoftkeyId,
       
   314                                           const TDesC& aFileName,
       
   315                                           const TDesC8& aMimeType )
       
   316     {
       
   317 	TIpcArgs args( aSoftkeyId, &aFileName, &aMimeType );
       
   318 	return SendReceive( EUISettingsSrvSetSoftkeyMask, args );
       
   319     }
       
   320 
       
   321 
       
   322 
       
   323 //  End of File