PECengine/PluginServer2/ClntSrc/RPEngPluginClient.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 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 class RPEngPluginClient
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  Include Files
       
    20 #include <eikdll.h>
       
    21 
       
    22 #include "RPEngPluginClient.h"
       
    23 #include "PEngPlgSrvCommon.h"
       
    24 #include "PresenceDebugPrint.h"
       
    25 #include "PEngServerStarter.h"
       
    26 #include <f32file.h>
       
    27 #include <e32uid.h>
       
    28 
       
    29 //MACROS
       
    30 #define RETURN_IF_ERROR( aErrorCode )\
       
    31     TInt eC(  aErrorCode );\
       
    32     if ( eC != KErrNone )\
       
    33         {\
       
    34         return eC;\
       
    35         }
       
    36 
       
    37 /*
       
    38  * How many message slots you need?
       
    39  * One for every asynchronous service, one for all synchronous services and one for cancel request.
       
    40  * For example if you have two asynchronous services and you have also synchronous services, you would need
       
    41  * 2 + 1 + 1 = 4 message slots.
       
    42  */
       
    43 const TUint KMessageSlotCount = 4;
       
    44 
       
    45 // DESTRUCTION
       
    46 EXPORT_C RPEngPluginClient::~RPEngPluginClient()
       
    47     {
       
    48     Close();
       
    49     }
       
    50 
       
    51 // CONSTRUCTION
       
    52 EXPORT_C RPEngPluginClient::RPEngPluginClient()
       
    53     {
       
    54 #if _BullseyeCoverage
       
    55 
       
    56 #if defined(__DLL__)
       
    57     // This is needed only for coverage builds to solve bullseye atexit problem.
       
    58     // __DLL__ guards are needed because in test cases this code is compiled as exe.
       
    59     Dll::SetTls( NULL );
       
    60 #endif
       
    61 
       
    62 #endif
       
    63     }
       
    64 
       
    65 EXPORT_C TInt RPEngPluginClient::Connect( TInt aOOMRate )
       
    66     {
       
    67     PENG_DP( D_PENG_LIT( "RPEngPluginClient::Connect start" ) );
       
    68     //Connects this RPEngStorageClient the server.
       
    69     //Launches new server process if one not yet running.
       
    70     return PEngServerStarter::ConnectServer( *this,
       
    71                                              KPEngPluginServerExe,
       
    72                                              TVersion( KClientVersionMajor,
       
    73                                                        KClientVersionMinor,
       
    74                                                        KClientVersionBuild ),
       
    75                                              KMessageSlotCount,
       
    76                                              KPEngPluginServerExe,
       
    77                                              aOOMRate );
       
    78     }
       
    79 
       
    80 TInt RPEngPluginClient::ConnectWithoutStarting()
       
    81     {
       
    82     PENG_DP( D_PENG_LIT( "RPEngPluginClient::ConnectWithoutStarting start" ) );
       
    83     TInt err = RSessionBase::CreateSession( KPEngPluginServerExe,
       
    84                                             TVersion( KClientVersionMajor,
       
    85                                                       KClientVersionMinor,
       
    86                                                       KClientVersionBuild ) );
       
    87 
       
    88     PENG_DP( D_PENG_LIT( "RPEngPluginClient::ConnectWithoutStarting end [%d]" ), err );
       
    89     return err;
       
    90     }
       
    91 
       
    92 EXPORT_C void RPEngPluginClient::Close()
       
    93     {
       
    94     //Do whatever is needed during cleanup.
       
    95     RSessionBase::Close();
       
    96     }
       
    97 
       
    98 TInt RPEngPluginClient::SetOnlineState( TBool aOnlineStatus )
       
    99     {
       
   100     PENG_DP( D_PENG_LIT( "RPEngPluginClient::SetOnlineState start" ) );
       
   101     // if we are online, load all plugins, otherways load only offline ones
       
   102     if ( !aOnlineStatus )
       
   103         {
       
   104         RETURN_IF_ERROR( Send( EPEngPlgSetStateOffline ) );
       
   105         }
       
   106     else
       
   107         {
       
   108         RETURN_IF_ERROR( Send( EPEngPlgSetStateOnline ) );
       
   109         }
       
   110 
       
   111     PENG_DP( D_PENG_LIT( "RPEngPluginClient::SetOnlineState end" ) );
       
   112     return KErrNone;
       
   113     }
       
   114 
       
   115 EXPORT_C TUint RPEngPluginClient::PluginCountL()
       
   116     {
       
   117     TInt pluginCount = SendReceive( EPEngPlgPluginCount );
       
   118     User::LeaveIfError( pluginCount );
       
   119 
       
   120     return pluginCount;
       
   121     }
       
   122 
       
   123 EXPORT_C TInt RPEngPluginClient::PluginUidL( TInt aIndex )
       
   124     {
       
   125     TIpcArgs msgArgs;
       
   126     msgArgs.Set( 0, aIndex ); // use slot 0 for the index
       
   127     TInt pluginUid = SendReceive( EPEngPlgPluginUid, msgArgs );
       
   128     User::LeaveIfError( pluginUid );
       
   129 
       
   130     return pluginUid;
       
   131     }
       
   132 
       
   133 TInt RPEngPluginClient::ShutdownServer()
       
   134     {
       
   135     PENG_DP( D_PENG_LIT( "RPEngPluginClient::ShutdownServer start" ) );
       
   136     TInt retVal = Send( EPEngPlgShutdownServer );
       
   137     Close();
       
   138 
       
   139     return retVal;
       
   140     }
       
   141 
       
   142 //  End of File