bearermanagement/mpm/src/mpmlauncher.cpp
changeset 73 70ee5458c95d
parent 18 fcbbe021d614
equal deleted inserted replaced
72:0c32cf868819 73:70ee5458c95d
     1 /*
     1 /*
     2 * Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 /**
    18 /**
    19 @file mpmlauncher.cpp
    19 @file mpmlauncher.cpp
    20 Mobility Policy Manager client DLL entry point.
    20 Mobility Policy Manager client DLL entry point.
    21 */
    21 */
    22 
    22 
    23 // INCLUDE FILES
       
    24 #include <e32std.h>
    23 #include <e32std.h>
    25 #include "mpmlauncher.h"
    24 #include "mpmlauncher.h"
    26 #include "mpmlogger.h"
    25 #include "mpmlogger.h"
    27 
    26 
    28 // ============================= LOCAL FUNCTIONS ===============================
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
    27 
    32 // -----------------------------------------------------------------------------
    28 // -----------------------------------------------------------------------------
    33 // MPMLauncher::LaunchServer
    29 // MPMLauncher::LaunchServer
    34 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    35 //
    31 //
    36 TInt MPMLauncher::LaunchServer(
    32 TInt MPMLauncher::LaunchServer(
    37     const TDesC& aServerFileName,
    33         const TDesC& aServerFileName,
    38     const TUid& aServerUid2,
    34         const TUid& aServerUid2,
    39     const TUid& aServerUid3)
    35         const TUid& aServerUid3 )
    40     {
    36     {
    41     MPMLOGSTRING("MPMLauncher::LaunchServer")
    37     MPMLOGSTRING("MPMLauncher::LaunchServer")
    42     const TUidType serverUid(KNullUid,aServerUid2,aServerUid3);
    38     const TUidType serverUid( KNullUid, aServerUid2, aServerUid3 );
    43     RSemaphore semaphore;
    39     RSemaphore semaphore;
    44     TInt err( KErrNone );
    40     TInt err( KErrNone );
    45 
    41 
    46     err = semaphore.CreateGlobal( KMPMLauncherSemaphore, 0 );
    42     err = semaphore.CreateGlobal( KMPMLauncherSemaphore, 0 );
    47     if ( err != KErrNone )
    43     if ( err != KErrNone )
    48         {
    44         {
    49         // Creating semaphore failed, which means some other thread is
    45         // Creating semaphore failed, which means some other thread is
    50         // creating the server right. Propagate error KErrServerBusy
    46         // creating the server right now. Propagate error KErrServerBusy
    51         // to inform the client it should try connecting again.
    47         // to inform the client it should try connecting again.
    52         return KErrServerBusy;
    48         return KErrServerBusy;
    53         }
    49         }
    54     
    50 
    55     MPMLOGSTRING("Create a new server process")
    51     MPMLOGSTRING("Create a new server process")
    56     RProcess server;
    52     RProcess server;
    57     TInt r=server.Create(aServerFileName,KNullDesC,serverUid);
    53     TInt r = server.Create( aServerFileName, KNullDesC, serverUid );
    58     
    54 
    59     if ( r != KErrNone )
    55     if ( r != KErrNone )
    60         {
    56         {
    61         MPMLOGSTRING2("Server process creation returned error: %d", r)
    57         MPMLOGSTRING2("Server process creation returned error: %d", r)
    62         semaphore.Close();
    58         semaphore.Close();
    63         return r;
    59         return r;
    64         }
    60         }
    65     TRequestStatus stat;
    61     TRequestStatus stat;
    66     server.Rendezvous(stat);
    62     server.Rendezvous( stat );
    67     if ( stat != KRequestPending )
    63     if ( stat != KRequestPending )
    68         {
    64         {
    69         server.Kill(0);        // abort startup
    65         server.Kill( 0 ); // Abort startup.
    70         }
    66         }
    71     else
    67     else
    72         {
    68         {
    73         server.Resume();    // logon OK - start the server
    69         server.Resume(); // Start the server.
    74         }
    70         }
    75     User::WaitForRequest(stat);        // wait for start or death
    71     User::WaitForRequest( stat ); // Wait for start or death.
    76     // we can't use the 'exit reason' if the server panicked as this
    72     // We can't use the 'exit reason' if the server panicked as this
    77     // is the panic 'reason' and may be '0' which cannot be distinguished
    73     // is the panic 'reason' and may be '0' which cannot be distinguished
    78     // from KErrNone
    74     // from KErrNone.
    79     r = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int();
    75     r = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int();
    80     server.Close();
    76     server.Close();
    81     semaphore.Close();
    77     semaphore.Close();
    82     return r;
    78     return r;
    83     }
    79     }
    84 
    80 
    85 
    81 // End of File
    86 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
    87 
       
    88 
       
    89 //  End of File 
       
    90