javatools/javafinishjrtinstall/src.s60/main.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 2010 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:  This application is executed by the native installer
       
    15 *               after a new version of Jrt has been installed from
       
    16 *               .sisx package on top of older Jrt version (e.g. when
       
    17 *               updating Jrt 2.1 to Jrt 2.2 via IAD).
       
    18 *               This application restarts Java Captain so that new
       
    19 *               version of the Jrt dlls is taken into use.
       
    20 *               All running MIDlets exit when Java Captain closes.
       
    21 */
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <e32std.h>
       
    26 #include <unistd.h>
       
    27 #include <w32std.h>
       
    28 
       
    29 #include "comms.h"
       
    30 #include "commsclientendpoint.h"
       
    31 #include "commsmessage.h"
       
    32 #include "coremessages.h"
       
    33 #include "logger.h"
       
    34 #include "rtcmessages.h"
       
    35 
       
    36 using namespace java::comms;
       
    37 using namespace java::captain;
       
    38 
       
    39 
       
    40 void stopJavaCaptain()
       
    41 {
       
    42     CommsMessage message;
       
    43     message.setModuleId(PLUGIN_ID_JAVACAPTAIN_CORE_C);
       
    44     message.setMessageId(CORE_MSG_ID_STOP_JAVACAPTAIN);
       
    45     CommsClientEndpoint comms;
       
    46     comms.connect(IPC_ADDRESS_JAVA_CAPTAIN_C);
       
    47     int rc = comms.send(message);
       
    48     while (rc == 0)
       
    49     {
       
    50         sleep(1);
       
    51         WLOG(EJavaConverters, "javafinishjrtinstall: Waiting JavaCaptain to exit...");
       
    52         rc = comms.send(message);
       
    53     }
       
    54     comms.disconnect();
       
    55 }
       
    56 
       
    57 
       
    58 void startJavaCaptain()
       
    59 {
       
    60     _LIT(KJavaCaptainExe, "javacaptain.exe");
       
    61     _LIT(KJavaCaptainArg, "");
       
    62     RProcess proc;
       
    63     int err = proc.Create(KJavaCaptainExe, KJavaCaptainArg);
       
    64     if (err == KErrNone)
       
    65     {
       
    66         proc.Resume();
       
    67         LOG(EJavaConverters, EInfo, 
       
    68             "javafinishjrtinstall: startJavaCaptain javacaptain.exe was started ok");
       
    69     }
       
    70     else
       
    71     {
       
    72         ELOG1(EJavaConverters, 
       
    73             "javafinishjrtinstall: startJavaCaptain start javacaptain.exe failed: %d", err);
       
    74     }
       
    75     proc.Close();
       
    76 }
       
    77 
       
    78 
       
    79 /**
       
    80  * Create cleanup stack and run the cleaner code inside TRAP harness
       
    81  * to log unexpected leaves.
       
    82  */
       
    83 TInt E32Main()
       
    84 {
       
    85     CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
    86     stopJavaCaptain();
       
    87     startJavaCaptain();
       
    88     delete cleanupStack;
       
    89     return KErrNone;
       
    90 }