|
1 /* |
|
2 * Copyright (c) 2008 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: JavaCaptain Main |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __SYMBIAN32__ |
|
19 #include <signal.h> |
|
20 #include <pthread.h> |
|
21 #include "signalhandler.h" |
|
22 #endif /* __SYMBIAN32__ */ |
|
23 |
|
24 #include <string.h> |
|
25 #include <unistd.h> |
|
26 #include <fcntl.h> |
|
27 #include <errno.h> |
|
28 |
|
29 #include "logger.h" |
|
30 #include "monitor.h" |
|
31 |
|
32 #include "core.h" |
|
33 |
|
34 using namespace java::captain; |
|
35 using namespace java::util; |
|
36 |
|
37 Monitor* monitor = NULL; |
|
38 |
|
39 #ifdef RD_JAVA_S60_RELEASE_9_2_ONWARDS |
|
40 #include <dirent.h> |
|
41 void makeHomeDir() |
|
42 { |
|
43 // open(filename) fails if c:\private\<uid> does not exist in 9.2 |
|
44 // This used to work in 5.0 |
|
45 char* homeDir = "c:\\private\\200211DC"; |
|
46 DIR* dir = opendir(homeDir); |
|
47 if (dir != NULL) |
|
48 { |
|
49 closedir(dir); |
|
50 } |
|
51 else |
|
52 { |
|
53 int rc = mkdir(homeDir, S_IRWXU); |
|
54 if (rc < 0) |
|
55 { |
|
56 WLOG2(EJavaCaptain, "creating %s failed, rc = %d", homeDir, rc); |
|
57 } |
|
58 } |
|
59 } |
|
60 #endif |
|
61 |
|
62 int main(int ac, char** av) |
|
63 { |
|
64 JELOG2(EJavaCaptain); |
|
65 |
|
66 #ifdef RD_JAVA_S60_RELEASE_9_2_ONWARDS |
|
67 makeHomeDir(); |
|
68 #endif |
|
69 |
|
70 // check if started by IAD installation |
|
71 if (ac == 2 && strcmp(av[1], "iad") == 0) |
|
72 { |
|
73 LOG(EJavaCaptain, EInfo, "creating iad boot event flag"); |
|
74 int fd = open("iadboot.dat", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); |
|
75 if (fd < 0) |
|
76 { |
|
77 ELOG1(EJavaCaptain, "create boot event flag failed: %s", strerror(errno)); |
|
78 } |
|
79 else |
|
80 { |
|
81 close(fd); |
|
82 } |
|
83 } |
|
84 |
|
85 #ifndef __SYMBIAN32__ |
|
86 sigset_t old, block; |
|
87 sigemptyset(&old); |
|
88 sigfillset(&block); |
|
89 |
|
90 if (!pthread_sigmask(SIG_BLOCK, &block, &old)) |
|
91 { |
|
92 SignalHandler sh; |
|
93 std::puts("JavaCaptain Press Ctrl-C to exit"); |
|
94 #endif /* __SYMBIAN32__ */ |
|
95 |
|
96 monitor = Monitor::createMonitor(); |
|
97 Core* core = new Core(monitor); |
|
98 core->start(); |
|
99 |
|
100 #ifndef __SYMBIAN32__ |
|
101 sh.start(); |
|
102 #endif /* __SYMBIAN32__ */ |
|
103 |
|
104 monitor->wait(); |
|
105 core->stop(); |
|
106 |
|
107 delete core; |
|
108 delete monitor; |
|
109 |
|
110 #ifndef __SYMBIAN32__ |
|
111 sh.stop(); |
|
112 pthread_sigmask(SIG_SETMASK, &old, NULL); |
|
113 } |
|
114 #endif /* __SYMBIAN32__ */ |
|
115 |
|
116 return 0; |
|
117 } |
|
118 |