javaruntimes/midp/runtimestarter/src/main.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009-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 class provides container for message.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /*
       
    20 
       
    21 MISSING FEATURES:
       
    22 
       
    23 Localized names for MIDlets
       
    24  The developer should be able to define localized names for MIDlets.
       
    25  The proposed format is described in RM-RIM CR 417-16269:
       
    26  Java: Support for localized application name.
       
    27  MIDP3 will define also format for the same purpose.
       
    28 
       
    29 */
       
    30 
       
    31 #include <unistd.h>
       
    32 
       
    33 #include "logger.h"
       
    34 #include "javaoslayer.h"
       
    35 #include "runtimeexception.h"
       
    36 #include "exceptionbase.h"
       
    37 
       
    38 #include "midpruntimestarter.h"
       
    39 
       
    40 #ifdef __SYMBIAN32__
       
    41 #include "javauids.h"
       
    42 #endif
       
    43 
       
    44 using namespace java::runtime;
       
    45 using namespace java::util;
       
    46 
       
    47 
       
    48 #ifndef __SYMBIAN32__
       
    49 extern "C"
       
    50 #endif //__SYMBIAN32__
       
    51 int dllMain(int argc, char *argv[])
       
    52 {
       
    53     JELOG(EJavaRuntime, "MIDP main()");
       
    54     LOG(EJavaRuntime, EInfo, "MipdRuntime started");
       
    55 #ifdef __SYMBIAN32__
       
    56 #ifndef _DEBUG
       
    57     // The only process allowed to start the MIDP is Java Captain.
       
    58     // Check is done only by release build.
       
    59     TSecureId sid = User::CreatorSecureId();
       
    60     if (sid != KJavaCaptainUid)
       
    61     {
       
    62         ELOG1(EJavaRuntime, "MipdRuntime main() creted by process having "
       
    63               "secure id: %X ", sid.iId);
       
    64         return -1;
       
    65     }
       
    66 #endif
       
    67 #endif
       
    68 
       
    69     JavaOsLayer::startUpTrace("Midp main", -1, -1);
       
    70     int result = -1;
       
    71     try
       
    72     {
       
    73         // MidpRuntimeStarter object is used to start the MIDP runtime.
       
    74         std::auto_ptr<MidpRuntimeStarter>
       
    75         starter(new MidpRuntimeStarter()); // codescanner::nonleavenew
       
    76         result = starter->start(argc, argv);
       
    77     }
       
    78     catch (RuntimeException& e)
       
    79     {
       
    80         ELOG1(EJavaRuntime, "MipdRuntime main() RuntimeException catched: %s ",
       
    81               e.toString().c_str());
       
    82     }
       
    83 
       
    84     catch (ExceptionBase& e)
       
    85     {
       
    86         ELOG1(EJavaRuntime, "MipdRuntime main() ExceptionBase catched: %s ",
       
    87               e.toString().c_str());
       
    88     }
       
    89 
       
    90     catch (std::exception& e)
       
    91     {
       
    92 
       
    93         ELOG1(EJavaRuntime, "MipdRuntime main() Exception %s catched", e.what());
       
    94     }
       
    95 
       
    96     LOG1(EJavaRuntime, EInfo, "MipdRuntime exited with status %d", result);
       
    97     return result;
       
    98 }
       
    99 
       
   100 
       
   101 #ifdef __SYMBIAN32__
       
   102 #include "javasymbianoslayer.h"
       
   103 
       
   104 /**
       
   105  * Finds exported methods of this dll. This is used by the utility
       
   106  * DynamicLibLoader.
       
   107  * @param funcName Name of the method the be searched.
       
   108  * @param indetifier A string identifier for different runtimes. This
       
   109  *        identifier is passed to the JVM args modifier.
       
   110  * @return valid function pointer to the searched methodon succes case, 0
       
   111  *         on error case.
       
   112  */
       
   113 EXPORT_C FuncPtr findDllMethod(const char* methodName)
       
   114 {
       
   115     FuncPtr ptr = 0;
       
   116     if (strcmp(methodName, "dllMain") == 0)
       
   117     {
       
   118         ptr = (FuncPtr)dllMain;
       
   119     }
       
   120     return ptr;
       
   121 }
       
   122 #endif //__SYMBIAN32__