ximpfw/tsrc/tsrcutils/processmaster/prfwtestprocessmaster.h
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2005 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: XIMP Framework Test Code prfwtestprocessmaster.h
       
    15  *
       
    16 */
       
    17 
       
    18 #ifndef PRFWTESTPROCESSMASTER_H__
       
    19 #define PRFWTESTPROCESSMASTER_H__
       
    20 
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <f32file.h>
       
    26 #include <e32base.h>
       
    27 
       
    28 #include "ximpserverdefs.h"
       
    29 #include "ximprootserverdefs.h"
       
    30 
       
    31 // CLASS DESCRIPTION
       
    32 
       
    33 /**
       
    34  * Test utility for managing Presence Engine processies
       
    35  */
       
    36 class PrfwTestProcessMaster
       
    37     {
       
    38     public: //enumerations
       
    39         enum TPEngProcessMasterEnums
       
    40             {
       
    41             EMsgSlot_Command = 1,
       
    42             EMsgSlot_Desc16Data = 2,
       
    43 
       
    44             EKillProcess = 100,
       
    45             EMaxMsgDataLength = 256
       
    46             };
       
    47 
       
    48     public: //Public functions
       
    49 
       
    50         /**
       
    51          *
       
    52          *
       
    53          *
       
    54          *
       
    55          *
       
    56          */
       
    57         static inline TInt KillPscServers();
       
    58         static inline TInt KillRootServer();
       
    59 
       
    60     private: //Helper functions
       
    61         static inline TInt DoKillServer( const TDesC& aServer );
       
    62 
       
    63     };
       
    64 
       
    65 
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // PrfwTestProcessMaster public functions
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 inline TInt PrfwTestProcessMaster::KillPscServers()
       
    73     {
       
    74     return PrfwTestProcessMaster::DoKillServer( NXIMPSrv::NName::KServerPattern );
       
    75     }
       
    76 
       
    77 inline TInt PrfwTestProcessMaster::KillRootServer()
       
    78     {
       
    79     return PrfwTestProcessMaster::DoKillServer( NRootSrv::NName::KServerPattern );
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // PrfwTestProcessMaster private functions
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 inline TInt PrfwTestProcessMaster::DoKillServer( const TDesC& aServer )
       
    87     {
       
    88     //Compose full executable name
       
    89     TFileName processMasterExe;
       
    90 
       
    91     // TODO this code shouldn't leave? does it? it was TRAP+L elsewhere.
       
    92     TFileName dllPath;
       
    93     Dll::FileName( dllPath );
       
    94     TParsePtrC dllPathParser( dllPath );
       
    95     processMasterExe.Insert( 0, dllPathParser.Drive() );
       
    96 
       
    97     processMasterExe.Append( KDC_PROGRAMS_DIR );
       
    98     processMasterExe.Append( _L("prfwtestprocessmaster.exe") );
       
    99 
       
   100     //Initialize ProcessMaster process
       
   101     RProcess processMaster;
       
   102     TInt err = processMaster.Create( processMasterExe, KNullDesC );
       
   103     if( err != KErrNone )
       
   104         {
       
   105         processMaster.Close();
       
   106         return err;
       
   107         }
       
   108 
       
   109     err = processMaster.SetParameter( PrfwTestProcessMaster::EMsgSlot_Command,
       
   110             PrfwTestProcessMaster::EKillProcess );
       
   111     if( err != KErrNone )
       
   112         {
       
   113         processMaster.Close();
       
   114         return err;
       
   115         }
       
   116 
       
   117 
       
   118     err = processMaster.SetParameter( PrfwTestProcessMaster::EMsgSlot_Desc16Data,
       
   119             aServer );
       
   120     if( err != KErrNone )
       
   121         {
       
   122         processMaster.Close();
       
   123         return err;
       
   124         }
       
   125 
       
   126     //Execute ProcessMaster
       
   127     TRequestStatus rendezvousStatus;
       
   128     processMaster.Rendezvous( rendezvousStatus );
       
   129     processMaster.Resume();
       
   130     User::WaitForRequest( rendezvousStatus );
       
   131     err = rendezvousStatus.Int();
       
   132 
       
   133 
       
   134     //Get exit statuses for debuging purposes
       
   135     TExitType exitType = processMaster.ExitType();
       
   136     TExitCategoryName exitCategory = processMaster.ExitCategory();
       
   137     TInt exitReason = processMaster.ExitReason();
       
   138 
       
   139     processMaster.Close();
       
   140 
       
   141     return err;
       
   142     }
       
   143 
       
   144 
       
   145 #endif // PRFWTESTPROCESSMASTER_H__
       
   146 
       
   147 //  End of File
       
   148