2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
18 #include <appcore-efl.h>
19 #include <ui-gadget.h> /* ug_send_key_event */
26 static int heynoti_fd = -1;
28 static void on_time_format_update(appdata *ad)
30 Elm_Object_Item *top_it = elm_naviframe_top_item_get(ad->navigator);
31 Evas_Object *eo = elm_object_item_content_get(top_it);
33 Evas_Smart_Cb cb = evas_object_data_get(eo, "time_format_update_cb");
35 void *cb_data = evas_object_data_get(eo, "time_format_update_data");
36 cb(cb_data, NULL, NULL);
40 void memo_timezone_changed_cb(void *data)
46 on_time_format_update(ad);
49 int tzone_heynoti_init(void *data)
52 if((fd = heynoti_init()) < 0) {
55 if(heynoti_subscribe(fd, "setting_time_changed", memo_timezone_changed_cb, data)) {
58 if(heynoti_attach_handler(fd)) {
61 LOGD("tzone heynoti register success!\n");
65 void tzone_heynoti_fini()
72 heynoti_unsubscribe(fd, "setting_time_changed", memo_timezone_changed_cb);
76 static void win_del(void *data, Evas_Object *obj, void *event)
81 static int lang_changed(void *data)
86 static int region_changed(void *data)
89 /* time format 12/24 chanaged, update ICU */
92 on_time_format_update(ad);
96 static Evas_Object *create_win(const char *name)
101 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
102 elm_win_conformant_set(eo, EINA_TRUE);
104 elm_win_title_set(eo, name);
105 elm_win_borderless_set(eo, EINA_TRUE);
106 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
107 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
108 evas_object_resize(eo, w, h);
114 static void _on_reload_cb(void *data, Evas_Object *obj, void *event_info)
116 evas_object_del(obj);
120 void on_change(keynode_t *node, void *user_data)
122 appdata *ad = (appdata *)user_data;
123 int sync = vconf_keynode_get_int(node);
125 if (ad->popup == NULL) {
126 Evas_Object *popup = elm_popup_add(ad->win_main);
127 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
128 elm_object_text_set(popup, "Memo data changed unexpectedly, close application and reload!");
129 Evas_Object *btn1 = elm_button_add(popup);
130 elm_object_text_set(btn1, MEMO_I18N_YES);
131 elm_object_part_content_set(popup, "button1", btn1);
132 evas_object_smart_callback_add(btn1, "clicked", _on_reload_cb, popup);
133 evas_object_show(popup);
139 static int app_create_delay(void *data)
141 appdata *ad = (appdata *)data;
146 win = create_win(PACKAGE);
152 /* monitor update of memo database from external application */
154 if (vconf_get_int("memory/mobex_engine/memo_sync_status", &sync) == 0) {
155 if (sync == 1) { /* KIES syncing */
156 Evas_Object *popup = elm_popup_add(ad->win_main);
157 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
158 elm_object_text_set(popup, "Memo data changed unexpectedly, close application and reload!");
159 Evas_Object *btn1 = elm_button_add(popup);
160 elm_object_text_set(btn1, MEMO_I18N_YES);
161 elm_object_part_content_set(popup, "button1", btn1);
162 evas_object_smart_callback_add(btn1, "clicked", _on_reload_cb, popup);
163 evas_object_show(popup);
167 vconf_notify_key_changed("memory/mobex_engine/memo_sync_status", on_change, ad);
169 /* theme extension */
170 elm_theme_extension_add(NULL, EDJ_FILE);
173 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
176 memo_ug_init(ad->win_main);
179 Evas_Object *bg = elm_bg_add(win);
180 elm_bg_color_set(bg, 0, 0, 0); /* black */
181 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
182 elm_win_resize_object_add(win, bg);
183 evas_object_show(bg);
185 ad->ly_main = elm_layout_add(win);
186 elm_layout_theme_set(ad->ly_main, "layout", "application", "default");
187 evas_object_size_hint_weight_set(ad->ly_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
188 elm_win_resize_object_add(ad->win_main, ad->ly_main);
189 evas_object_show(ad->ly_main);
192 ad->navigator = elm_naviframe_add(ad->ly_main);
193 elm_object_part_content_set(ad->ly_main, "elm.swallow.content", ad->navigator);
195 if (ad->init_view == MEMO_LIST_VIEW) {
196 memo_load_list_view(ad);
197 } else if (ad->init_view == MEMO_DETAIL_VIEW) {
198 memo_load_detail_view(ad);
199 } else if (ad->init_view == MEMO_EDIT_VIEW) {
200 memo_load_edit_view(ad);
203 /* init internationalization */
204 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
210 appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE, region_changed, ad);
213 heynoti_fd = tzone_heynoti_init(ad);
215 /* add system event callback */
216 appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, lang_changed, ad);
221 static int app_create(void *data)
223 /* init memo database */
228 static int app_terminate(void *data)
231 /* fini memo database */
234 tzone_heynoti_fini();
236 evas_object_del(ad->win_main);
242 static int app_pause(void *data)
247 static int app_resume(void *data)
252 static int app_reset(bundle *bd, void *data)
254 appdata *ad = (appdata *)data;
256 if (ad->win_main != NULL) { /* memo has already launced. */
257 elm_win_activate(ad->win_main);
262 ad->init_view = MEMO_LIST_VIEW;
264 if (bd != NULL) { /* launch type check */
266 const char *s = bundle_get_val(bd, AUL_PARAM_ID);
269 memo_data_t *md = memo_get_data(id);
270 if (md != NULL) { /* launch detail view */
271 ad->init_view = MEMO_DETAIL_VIEW;
276 /* voice memo, launch edit view with specified text */
277 s = bundle_get_val(bd, "memo");
278 if (s != NULL) { /* launch edit text view */
279 ad->init_view = MEMO_EDIT_VIEW;
281 ad->init_str = strdup(s); /* ugh, edit text view will take over init_str, no need to free explicitly */
284 app_create_delay(ad);
285 evas_object_show(ad->win_main);
290 int main(int argc, char *argv[])
293 struct appcore_ops ops = {
294 .create = app_create,
295 .terminate = app_terminate,
297 .resume = app_resume,
301 memset(&ad, 0x0, sizeof(appdata));
304 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);