power off: update the popup to use common functions
[platform/core/system/system-popup.git] / share / src / common.h
1 /*
2  *  system-popup
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20
21 #ifndef __COMMON_H_
22 #define __COMMON_H_
23
24 #include <Ecore_X.h>
25 #include <appcore-efl.h>
26 #include <Elementary.h>
27 #include <utilX.h>
28 #include <dlog.h>
29 #include <bundle.h>
30 #include <glib.h>
31 #include <syspopup.h>
32 #include <syspopup_caller.h>
33
34 #undef LOG_TAG
35 #define LOG_TAG "SYSTEM_APPS"
36 #define _D(fmt, args...)   SLOGD(fmt, ##args)
37 #define _E(fmt, args...)   SLOGE(fmt, ##args)
38 #define _I(fmt, args...)   SLOGI(fmt, ##args)
39
40 #define FREE(arg) \
41         do { \
42                 if(arg) { \
43                         free((void *)arg); \
44                         arg = NULL; \
45                 } \
46         } while (0);
47
48 #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
49
50 #define max(a,b) \
51         ({ __typeof__ (a) _a = (a); \
52            __typeof__ (b) _b = (b);  \
53            _a > _b ? _a : _b; })
54
55 struct appdata {
56         /* Common */
57         Evas_Object *win_main;
58         Evas_Object *layout_main;
59         Evas_Object *popup;
60         bundle      *b;
61
62         syspopup_handler handler;
63
64         /* For usbotg popup */
65         Evas_Object *storage_added_popup;
66         Evas_Object *storage_unmount_popup;
67         Evas_Object *camera_added_popup;
68         char *storage_added_path;
69         char *storage_unmount_path;
70
71         /* IPC by dbus */
72         E_DBus_Signal_Handler *edbus_handler;
73         E_DBus_Connection     *edbus_conn;
74
75 };
76
77 void popup_terminate(void);
78 void release_evas_object(Evas_Object **obj);
79 void object_cleanup(struct appdata *ad);
80 Evas_Object *create_win(const char *name);
81 Evas_Object *load_normal_popup(struct appdata *ad,
82                 char *title,
83                 char *content,
84                 char *lbtnText,
85                 Evas_Smart_Cb lbtn_cb,
86                 char *rbtnText,
87                 Evas_Smart_Cb rbtn_cb);
88 Evas_Object *load_popup_with_vertical_buttons(struct appdata *ad,
89                 char *title,
90                 char *content,
91                 char *ubtnText,
92                 Evas_Smart_Cb ubtn_cb,
93                 char *dbtnText,
94                 Evas_Smart_Cb dbtn_cb);
95 Evas_Object *load_scrollable_popup(struct appdata *ad,
96                 char *title,
97                 char *content,
98                 char *lbtnText,
99                 Evas_Smart_Cb lbtn_cb,
100                 char *rbtnText,
101                 Evas_Smart_Cb rbtn_cb);
102
103 void set_display(void);
104
105 /* Send dbus signal */
106 int broadcast_dbus_signal(const char *path,
107                 const char *interface,
108                 const char *name,
109                 const char *sig,
110                 char *param[]);
111
112 int reset_window_priority(Evas_Object *win, int priority);
113 int set_popup_focus(Evas_Object *win, bool focus);
114
115
116 #endif                          /* __COMMON_H__ */