1722e53fa0fb3be6bb488e2a263f73a9a2395cd1
[platform/framework/web/crosswalk.git] / src / xwalk / application / tools / linux / xwalk_launcher_tizen.cc
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdio.h>
6 #include <string.h>
7 #if defined(OS_TIZEN_MOBILE)
8 #include <appcore/appcore-common.h>
9 #endif
10 #include "xwalk/application/tools/linux/xwalk_launcher_tizen.h"
11
12 enum app_event {
13   AE_UNKNOWN,
14   AE_CREATE,
15   AE_TERMINATE,
16   AE_PAUSE,
17   AE_RESUME,
18   AE_RESET,
19   AE_LOWMEM_POST,
20   AE_MEM_FLUSH,
21   AE_MAX
22 };
23
24 // Private struct from appcore-internal, necessary to get events from
25 // the system.
26 struct ui_ops {
27   void* data;
28   void (*cb_app)(enum app_event evnt, void* data, bundle* b);
29 };
30
31 static struct ui_ops appcore_ops;
32
33 static const char* event2str(enum app_event event) {
34   switch (event) {
35     case AE_UNKNOWN:
36       return "AE_UNKNOWN";
37     case AE_CREATE:
38       return "AE_CREATE";
39     case AE_TERMINATE:
40       return "AE_TERMINATE";
41     case AE_PAUSE:
42       return "AE_PAUSE";
43     case AE_RESUME:
44       return "AE_RESUME";
45     case AE_RESET:
46       return "AE_RESET";
47     case AE_LOWMEM_POST:
48       return "AE_LOWMEM_POST";
49     case AE_MEM_FLUSH:
50       return "AE_MEM_FLUSH";
51     case AE_MAX:
52       return "AE_MAX";
53   }
54
55   return "INVALID EVENT";
56 }
57
58 static void application_event_cb(enum app_event event, void* data, bundle* b) {
59   fprintf(stderr, "event %s\n", event2str(event));
60 }
61
62 int xwalk_appcore_init(int argc, char** argv, const char* name) {
63   appcore_ops.cb_app = application_event_cb;
64   appcore_ops.data = NULL;
65
66   return appcore_init(name, &appcore_ops, argc, argv);
67 }