diff -r e8e63152f320 -r 2a9601315dfc javamanager/javacaptain/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/src/main.cpp Mon May 03 12:27:20 2010 +0300 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: JavaCaptain Main +* +*/ + +#ifndef __SYMBIAN32__ +#include +#include +#include "signalhandler.h" +#endif /* __SYMBIAN32__ */ + +#include +#include +#include +#include + +#include "logger.h" +#include "monitor.h" + +#include "core.h" + +using namespace java::captain; +using namespace java::util; + +Monitor* monitor = NULL; + +#ifdef RD_JAVA_S60_RELEASE_9_2_ONWARDS +#include +void makeHomeDir() +{ + // open(filename) fails if c:\private\ does not exist in 9.2 + // This used to work in 5.0 + char* homeDir = "c:\\private\\200211DC"; + DIR* dir = opendir(homeDir); + if (dir != NULL) + { + closedir(dir); + } + else + { + int rc = mkdir(homeDir, S_IRWXU); + if (rc < 0) + { + WLOG2(EJavaCaptain, "creating %s failed, rc = %d", homeDir, rc); + } + } +} +#endif + +int main(int ac, char** av) +{ + JELOG2(EJavaCaptain); + +#ifdef RD_JAVA_S60_RELEASE_9_2_ONWARDS + makeHomeDir(); +#endif + + // check if started by IAD installation + if (ac == 2 && strcmp(av[1], "iad") == 0) + { + LOG(EJavaCaptain, EInfo, "creating iad boot event flag"); + int fd = open("iadboot.dat", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + if (fd < 0) + { + ELOG1(EJavaCaptain, "create boot event flag failed: %s", strerror(errno)); + } + else + { + close(fd); + } + } + +#ifndef __SYMBIAN32__ + sigset_t old, block; + sigemptyset(&old); + sigfillset(&block); + + if (!pthread_sigmask(SIG_BLOCK, &block, &old)) + { + SignalHandler sh; + std::puts("JavaCaptain Press Ctrl-C to exit"); +#endif /* __SYMBIAN32__ */ + + monitor = Monitor::createMonitor(); + Core* core = new Core(monitor); + core->start(); + +#ifndef __SYMBIAN32__ + sh.start(); +#endif /* __SYMBIAN32__ */ + + monitor->wait(); + core->stop(); + + delete core; + delete monitor; + +#ifndef __SYMBIAN32__ + sh.stop(); + pthread_sigmask(SIG_SETMASK, &old, NULL); + } +#endif /* __SYMBIAN32__ */ + + return 0; +} +