APPLY_RSA
[apps/home/ug-memo-efl.git] / src / memo_ug.c
1 /*
2 *
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://www.tizenopensource.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 #include <ui-gadget.h>
19 #include <Ecore_X.h>
20 #include <aul.h>
21 #include <supplement.h>
22 #include <memo-db.h>
23 #include "memo_ug.h"
24
25 static void _ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
26 {
27     Evas_Object *base, *win;
28     base = (Evas_Object *)ug_get_layout(ug);
29     if (base == NULL) {
30         return;
31     }
32
33     win = ug_get_window();
34     switch (mode) {
35     case UG_MODE_FULLVIEW:
36         evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
37         elm_win_resize_object_add(win, base);
38         /* disable effect */
39         //ug_disable_effect(ug);
40         evas_object_show(base);
41         break;
42     default:
43         break;
44     }
45 }
46
47 static void _ug_result_cb(ui_gadget_h ug, service_h service, void *priv)
48 {
49     service_dump(service);
50 }
51
52 static void _ug_destroy_cb(ui_gadget_h ug, void *priv)
53 {
54     if (ug != NULL) {
55         ug_destroy(ug);
56     }
57 }
58
59 /**
60  * ug_launch_common
61  *
62  * @description
63  *  This is a basic function which designed to invoke any ui gadget.
64  *
65  * @param[in]   service         a service type which will send to ug directly
66  * @param[in]   ug_name    UG name marco defined in memo_ug.h
67  * @return      void
68  */
69 void ug_launch_common(service_h service, char *ug_name)
70 {
71     ug_cbs_t cbs={0, };
72
73     cbs.layout_cb = _ug_layout_cb;
74     cbs.destroy_cb = _ug_destroy_cb;
75     cbs.result_cb = _ug_result_cb;
76     cbs.priv = NULL;
77
78     ug_create(NULL, ug_name, UG_MODE_FULLVIEW, service, &cbs);
79     service_destroy(service);
80 }
81
82 /**
83  * ug_launch_common_var
84  *
85  * @description
86  *  This function supply a variadic version of ug_launch_common_var.
87  *  The first and only required variable is the ug_name.
88  *  Its type is string, but the caller should use the macro name which defined in memo_ug.h
89  *  The other variables are optional, it should appear for key-value pair
90  *  The end of optional variables must be NULL.
91  *
92  * @param[in]   ug_name    UG name marco defined in memo_ug.h
93  * @param[in]   ...        pair of key and value, end with NULL
94  * @return      void
95  */
96 void ug_launch_common_var(char *ug_name, ...)
97 {
98         char *key = NULL;
99         char *val = NULL;
100         service_h service = NULL;
101         service_create(&service);
102
103         va_list ap;
104         va_start(ap, ug_name);
105         while (1) {
106                 key = va_arg(ap, char *);
107                 val = va_arg(ap, char *);
108
109                 if (key == NULL || val == NULL) {
110                         break;
111                 }
112                 service_add_extra_data(service, key, val);
113         }
114         va_end(ap);
115
116         ug_launch_common(service, ug_name);
117 }
118