phonebookui/Phonebook2/ccapplication/ccapp/src/ccaappservice.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2007 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-side service implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <bldvariant.hrh>
       
    20 #include <apgcli.h>
       
    21 #include <eikenv.h>
       
    22 #include <eikappui.h>
       
    23 #include <AknServerApp.h>
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include "ccaappservice.h"
       
    27 #include "ccalogger.h"
       
    28 #include "ccauids.h"
       
    29 #include "ccaclientserverappipc.h"
       
    30 #include "ccaclientutils.h"
       
    31 #include "ccaparameter.h"
       
    32 
       
    33 // ---------------------------------------------------------
       
    34 // CCAAppService::CCAAppService
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 CCAAppService::CCAAppService()
       
    38 	{
       
    39 	if ( !iAppUi )
       
    40 	    {
       
    41 	    // Ignored CS warning ( Using CEikonEnv::Static )
       
    42 	    // There is no other way to do this
       
    43             iAppUi = (( CCCAAppAppUi* )CEikonEnv::Static()->EikAppUi() );
       
    44 	    }
       
    45 	}
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CCAAppService::~CCAAppService
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 CCAAppService::~CCAAppService()
       
    52 	{
       
    53 	}
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // CCAAppService::CreateL
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 void CCAAppService::CreateL()
       
    60 	{
       
    61 	CAknAppServiceBase::CreateL();
       
    62 	}
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // CCAAppService::ServiceL
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 void CCAAppService::ServiceL(const RMessage2& aMessage)
       
    69 	{
       
    70     CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ServiceL"));
       
    71     CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ServiceL: Funtion=%d"), aMessage.Function());
       
    72 
       
    73 	switch (aMessage.Function())
       
    74 		{
       
    75 		case ECCALaunchApplication:
       
    76 		    {
       
    77 		    TRAPD(err, ReadMsgL(aMessage));
       
    78             //Complete request with err
       
    79             CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ServiceL: ReadMsgL=%d"), err);
       
    80             aMessage.Complete(err);
       
    81 		    }
       
    82 		    break;
       
    83 
       
    84         case ECCAGetWindowGroupId:   
       
    85             {
       
    86             TInt windowGroupId = CCoeEnv::Static()->RootWin().Identifier();
       
    87             TPckg<TInt> ptr( windowGroupId );
       
    88             aMessage.Write( 0, ptr );
       
    89             aMessage.Complete( KErrNone );
       
    90             }
       
    91             break;
       
    92 
       
    93 		default:
       
    94 			CAknAppServiceBase::ServiceL(aMessage);
       
    95 			break;
       
    96 		}
       
    97 
       
    98     CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ServiceL: Done."));
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CCAAppService::ServiceError
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 void CCAAppService::ServiceError(
       
   106     const RMessage2& aMessage,
       
   107     TInt aError )
       
   108 	{
       
   109     CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ServiceError: aError=%d"), aError);
       
   110 	CAknAppServiceBase::ServiceError( aMessage, aError );
       
   111 	}
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CCAAppService::ReadMsgL
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CCAAppService::ReadMsgL( const RMessage2& aMessage )
       
   118 	{
       
   119     CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ReadMsgDataL"));
       
   120 
       
   121     const TInt clientSideDataLength = aMessage.GetDesLengthL( 0 );
       
   122     HBufC8* clientData = HBufC8::NewLC( clientSideDataLength );
       
   123     TPtr8 clientDataPtr( clientData->Des() );
       
   124     aMessage.Read( 0, clientDataPtr );
       
   125 
       
   126     RDesReadStream readStream( clientDataPtr );
       
   127     CleanupClosePushL( readStream );
       
   128 
       
   129     CCCAParameter* data = CCCAParameter::NewL();
       
   130     CleanupStack::PushL( data );
       
   131     data->InternalizeL( readStream );
       
   132 
       
   133     //PERFORMANCE LOGGING: 5. Parameter transferred/unpacked over AppServer
       
   134     WriteToPerfLog();    
       
   135     CleanupStack::Pop( data ); // data
       
   136     iAppUi->SetParameter( *data );//ownership transferred
       
   137     iAppUi->InitializePluginL();
       
   138     
       
   139 
       
   140     CleanupStack::PopAndDestroy( 2, clientData );// readStream, clientData
       
   141 
       
   142     CCA_DP( KCCAppLogFile, CCA_L( "CCAAppService::ReadMsgDataL: Done"));
       
   143 	}
       
   144 
       
   145 // end of file