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