5cf678781d73e426b12743e57e0c19f6e76c4158
[apps/native/volume-app.git] / src / volume.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  * 
4  * Licensed under the Flora License, Version 1.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *     http://www.tizenopensource.org/license
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include <stdio.h>
19
20 #include "volume.h"
21 #include "_util_log.h"
22 #include "_util_efl.h"
23 #include "_logic.h"
24
25 struct text_part {
26         char *part;
27         char *msgid;
28 };
29
30 static int lang_changed(void *data)
31 {
32         return _lang_changed(data);
33 }
34
35 static int app_create(void *data)
36 {
37         struct appdata *ad = data;
38
39         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
40
41         _app_create(ad);
42
43         lang_changed(ad);
44
45         /* add system event callback */
46         appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
47                         lang_changed, ad);
48
49         /* appcore measure time example */
50         printf("from AUL to %s(): %d msec\n", __func__,
51                         appcore_measure_time_from("APP_START_TIME"));
52
53         appcore_measure_start();
54         return 0;
55 }
56
57 static int app_terminate(void *data)
58 {
59         struct appdata *ad = data;
60
61         if (ad->win)
62                 evas_object_del(ad->win);
63
64         return 0;
65 }
66
67 static int app_pause(void *data)
68 {
69         _app_pause(data);
70         return 0;
71 }
72
73 static int app_resume(void *data)
74 {
75         return 0;
76 }
77
78 static int app_reset(bundle *b, void *data)
79 {
80         struct appdata *ad = data;
81
82         if (ad->flag_launching == EINA_TRUE) {
83                 return 0;
84         }
85         ad->flag_launching = EINA_TRUE;
86
87         if (syspopup_has_popup(b)) {
88                 _D("has popup\n");
89                 _app_reset(b, data);
90         } else {
91                 _D("has not popup\n");
92                 _app_reset(b, data);
93         }
94         /* appcore measure time example */
95         printf("from AUL to %s(): %d msec\n", __func__,
96                         appcore_measure_time_from("APP_START_TIME"));
97         printf("from create to %s(): %d msec\n", __func__,
98                         appcore_measure_time());
99
100         if (ad->win)
101                 elm_win_activate(ad->win);
102
103         ad->flag_launching = EINA_FALSE;
104
105         return 0;
106 }
107
108 int main(int argc, char *argv[])
109 {
110         struct appdata ad;
111         struct appcore_ops ops = {
112                 .create = app_create,
113                 .terminate = app_terminate,
114                 .pause = app_pause,
115                 .resume = app_resume,
116                 .reset = app_reset,
117         };
118
119         /* appcore measure time example */
120         printf("from AUL to %s(): %d msec\n", __func__,
121                         appcore_measure_time_from("APP_START_TIME"));
122
123         memset(&ad, 0x0, sizeof(struct appdata));
124         ops.data = &ad;
125
126         return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
127 }
128