equal
deleted
inserted
replaced
13 * |
13 * |
14 * Description: JavaCommonUtils |
14 * Description: JavaCommonUtils |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 #include <errno.h> |
|
19 #include <fcntl.h> |
19 #include <iostream> |
20 #include <iostream> |
20 #include <sstream> |
21 #include <sstream> |
|
22 #include <unistd.h> |
21 #include <vector> |
23 #include <vector> |
22 |
24 |
23 #include <string.h> |
25 #include <string.h> |
24 |
26 |
25 #include <openssl/bio.h> |
27 #include <openssl/bio.h> |
30 #include "javacommonutils.h" |
32 #include "javacommonutils.h" |
31 #include "exceptionbase.h" |
33 #include "exceptionbase.h" |
32 #include "convertutf.h" |
34 #include "convertutf.h" |
33 |
35 |
34 using namespace java::util; |
36 using namespace java::util; |
|
37 |
|
38 // In Symbian working directory should be initalized to C:\private\<UID> by OpenC |
|
39 // But for some reason this does not seem to work if process binary is in rom. |
|
40 #ifdef __SYMBIAN32__ |
|
41 const char* const FIRST_BOOT_FILE = "c:\\private\\102033E6\\first_boot_done.dat"; |
|
42 #else |
|
43 const char* const FIRST_BOOT_FILE = "first_boot_done.dat"; |
|
44 #endif /* __SYMBIAN32__ */ |
|
45 |
|
46 bool JavaCommonUtils::mFirstBoot = false; |
35 |
47 |
36 OS_EXPORT int JavaCommonUtils::stringToInt(const std::string& str) |
48 OS_EXPORT int JavaCommonUtils::stringToInt(const std::string& str) |
37 { |
49 { |
38 // JELOG2(EUtils); |
50 // JELOG2(EUtils); |
39 // value = boost::lexical_cast<int>( str ); |
51 // value = boost::lexical_cast<int>( str ); |
370 |
382 |
371 return res; |
383 return res; |
372 } |
384 } |
373 |
385 |
374 |
386 |
|
387 OS_EXPORT int JavaCommonUtils::initIsFirstBoot() |
|
388 { |
|
389 struct stat fileStatBuf; |
|
390 if (stat(FIRST_BOOT_FILE, &fileStatBuf) == 0) |
|
391 { |
|
392 mFirstBoot = false; |
|
393 } |
|
394 else |
|
395 { |
|
396 mFirstBoot = true; |
|
397 |
|
398 // Create flag file so that next time we detect that first boot |
|
399 // has already been done |
|
400 int fd = open(FIRST_BOOT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); |
|
401 if (fd < 0) |
|
402 { |
|
403 return errno; |
|
404 } |
|
405 else |
|
406 { |
|
407 close(fd); |
|
408 } |
|
409 } |
|
410 |
|
411 return 0; |
|
412 } |
|
413 |
|
414 |
|
415 OS_EXPORT bool JavaCommonUtils::isFirstBoot() |
|
416 { |
|
417 return mFirstBoot; |
|
418 } |
|
419 |
|
420 |
375 char JavaCommonUtils::decodeOnePercentSeq(wchar_t first, wchar_t sec) |
421 char JavaCommonUtils::decodeOnePercentSeq(wchar_t first, wchar_t sec) |
376 { |
422 { |
377 // Handle one encoded %XY |
423 // Handle one encoded %XY |
378 char decodedCh = 0; |
424 char decodedCh = 0; |
379 wchar_t ch = first; |
425 wchar_t ch = first; |