#include <app.h>
#include <vconf.h>
#include <unistd.h>
-#include <privilege-control.h>
#include <app_manager.h>
#include <signal.h>
#include <minicontrol-monitor.h>
#include <notification.h>
#include <app_preference.h>
#include <wifi.h>
-#include <tzsh.h>
+#include <tzsh_indicator_service.h>
#if 0
#include <app_manager_product.h>
#endif
#include "indicator.h"
#include "ticker.h"
-#define GRP_MAIN "indicator"
+#define GRP_NAME "indicator"
#define WIN_TITLE "Illume Indicator"
#define VCONF_PHONE_STATUS "memory/startapps/sequence"
};
-static int _window_new(void *data);
-static int _window_del(void *data);
+static indicator_error_e _start_indicator(void *data);
+static indicator_error_e _terminate_indicator(void *data);
+
static void _indicator_low_bat_cb(app_event_info_h event_info, void *data);
static void _indicator_lang_changed_cb(app_event_info_h event_info, void *data);
static void _indicator_region_changed_cb(app_event_info_h event_info, void *data);
{
ret_if(!data);
- _window_del((struct appdata *)data);
+ _terminate_indicator((struct appdata *)data);
}
static void _indicator_notify_pm_state_cb(keynode_t * node, void *data)
ecore_evas_data_set(ee,"indicator_app_data",data);
}
+/* FIXME */
+static void _indicator_service_cb(void *data, tzsh_indicator_service_h service, int angle, int opacity)
+{
+ _D("Indicator service callback");
+}
+
static void register_event_handler(void *data)
{
struct appdata *ad = data;
_register_event_handler_both(&(ad->win),data);
+ /* FIXME */
+ if (ad->indicator_service) {
+ tzsh_indicator_service_property_change_cb_set(ad->indicator_service, _indicator_service_cb, NULL);
+ }
+
#if 0
hdl = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _indicator_client_message_cb, (void *)ad);
ret_if(!hdl);
}
evas_object_size_hint_min_set(ad->win.layout, ad->win.w, ad->win.h);
- //evas_object_size_hint_weight_set(ad->win.layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ /* FIXME */
+ evas_object_size_hint_weight_set(ad->win.layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(ad->win.win, ad->win.layout);
evas_object_move(ad->win.layout, 0, 0);
evas_object_show(ad->win.layout);
}
+static void _create_box(win_info *win)
+{
+ ret_if(!win);
+
+ /* First, clear layout */
+ box_fini(win);
+
+ box_init(win);
+
+ return;
+}
+
+static indicator_error_e _tzsh_set(struct appdata* ad)
+{
+ tzsh_window tz_win;
+
+ retv_if(!ad, INDICATOR_ERROR_INVALID_PARAMETER);
+ retv_if(!ad->win.win, INDICATOR_ERROR_INVALID_PARAMETER);
+
+ ad->tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL);
+ retv_if(!ad->tzsh, INDICATOR_ERROR_FAIL);
+
+ tz_win = elm_win_window_id_get(ad->win.win);
+ if (!tz_win) {
+ tzsh_destroy(ad->tzsh);
+ _E("Failed to get Tizen window");
+ /* FIXME */
+ //return INDICATOR_ERROR_FAIL;
+ return INDICATOR_ERROR_NONE;
+ }
+
+ ad->indicator_service = tzsh_indicator_service_create(ad->tzsh, tz_win);
+ if (!ad->indicator_service) {
+ tzsh_destroy(ad->tzsh);
+ _E("Failed to create Tizen window indicator service");
+ return INDICATOR_ERROR_FAIL;
+ }
+
+ return INDICATOR_ERROR_NONE;
+}
+
+static void _tzsh_unset(struct appdata *ad)
+{
+ ret_if(!ad);
+
+ if (ad->indicator_service) {
+ tzsh_indicator_service_destroy(ad->indicator_service);
+ ad->indicator_service = NULL;
+ }
+
+ if (ad->tzsh) {
+ tzsh_destroy(ad->tzsh);
+ ad->tzsh = NULL;
+ }
+}
+
static Eina_Bool _indicator_listen_timer_cb(void* data)
{
win_info *win = data;
//win = (win_info*)data;
if (!elm_win_socket_listen(win->win , INDICATOR_SERVICE_NAME, 0, EINA_FALSE)) {
- _E("faile to elm_win_socket_listen() %x", win->win);
+ _E("failed to elm_win_socket_listen() %x", win->win);
return ECORE_CALLBACK_RENEW;
} else {
_D("listen success");
}
}
-static void _create_box(win_info *win)
-{
- ret_if(!win);
-
- /* First, clear layout */
- box_fini(win);
-
- box_init(win);
-
- return;
-}
-
-#define INDICATOR_HEIGHT_N4 96
-static void _create_win(void* data)
+static void _create_window(struct appdata *ad)
{
- struct appdata *ad = data;
Evas_Object *dummy_win = NULL;
- ret_if(!ad);
+ _D("Create window");
- _D("Window created");
-
- /* Create socket window */
ad->win.win = elm_win_add(NULL, "indicator", ELM_WIN_SOCKET_IMAGE);
ret_if(!(ad->win.win));
evas_object_del(dummy_win);
_D("Dummy window w, h (%d, %d)", ad->win.port_w, ad->win.land_w);
} else {
- _E("Critical error. Cannot create window");
+ _E("Critical error. Cannot create dummy window");
}
if (!elm_win_socket_listen(ad->win.win , INDICATOR_SERVICE_NAME, 0, EINA_FALSE)) {
s_info.listen_timer = ecore_timer_add(3, _indicator_listen_timer_cb, &(ad->win));
}
- /* FIXME */
- ad->win.h = INDICATOR_HEIGHT_N4;
- ad->win.w = ad->win.port_w;
- ad->win.evas = evas_object_evas_get(ad->win.win);
-
- _D("win_size = Original(%d, %d), Scaled(%lf, %lf)", ad->win.port_w, ad->win.h, ELM_SCALE_SIZE(ad->win.port_w), ELM_SCALE_SIZE(ad->win.h));
-#if 0 /* For test */
elm_win_alpha_set(ad->win.win , EINA_TRUE);
+ /* FIXME */
elm_win_borderless_set(ad->win.win , EINA_TRUE);
evas_object_size_hint_fill_set(ad->win.win , EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ad->win.win , 1.0, 0.5);
- Evas_Object *rect = evas_object_rectangle_add(ad->win.evas);
- evas_object_resize(rect, 1440, 96);
- evas_object_color_set(rect, 0, 0, 255, 255);
- evas_object_show(rect);
- evas_object_layer_set(rect, -256);
-#endif
- _create_layout(ad, EDJ_FILE0, GRP_MAIN);
+ evas_object_show(ad->win.win);
+
+}
+
+#define INDICATOR_HEIGHT_TM1 52
+static void _create_base_gui(void* data)
+{
+ struct appdata *ad = data;
+ Evas_Object *dummy_win = NULL;
+
+ ret_if(!ad);
+
+ _D("Start to create base gui");
+
+ _create_window(ad);
+
+ if (INDICATOR_ERROR_NONE != _tzsh_set(ad)) {
+ _E("Failed to set tzsh");
+ }
+
+ /* FIXME */
+ ad->win.h = INDICATOR_HEIGHT_TM1;
+ ad->win.w = ad->win.port_w;
+ ad->win.evas = evas_object_evas_get(ad->win.win);
+
+ //_D("win_size = Original(%d, %d), Scaled(%lf, %lf)", ad->win.port_w, ad->win.h, ELM_SCALE_SIZE(ad->win.port_w), ELM_SCALE_SIZE(ad->win.h));
+
+ _create_layout(ad, EDJ_FILE, GRP_NAME);
_create_box(&(ad->win));
ad->win.data = data;
- evas_object_show(ad->win.win);
+#if 0 /* For test */
+ Evas_Object *rect = evas_object_rectangle_add(ad->win.evas);
+ ret_if(!rect);
+ evas_object_resize(rect, 720, 52);
+ evas_object_color_set(rect, 0, 0, 255, 255);
+ evas_object_show(rect);
+ evas_object_layer_set(rect, -256);
+#endif
return;
}
ret_if(!ad);
memset(&(ad->win),0x00,sizeof(win_info));
-
- //ad->win_overlay = NULL;
}
static void _init_tel_info(void * data)
memset(&(ad->tel_info), 0x00, sizeof(telephony_info));
}
-static int _window_new(void *data)
+static indicator_error_e _start_indicator(void *data)
{
- retv_if(!data, NULL);
+ retv_if(!data, INDICATOR_ERROR_INVALID_PARAMETER);
_init_win_info(data);
_init_tel_info(data);
/* Create indicator window */
- _create_win(data);
+ _create_base_gui(data);
return INDICATOR_ERROR_NONE;
}
-static int _window_del(void *data)
+static indicator_error_e _terminate_indicator(void *data)
{
- struct appdata *ad = (struct appdata *)data;
+ struct appdata *ad = data;
- retif(data == NULL, FAIL, "Invalid parameter!");
+ retv_if(!ad, INDICATOR_ERROR_INVALID_PARAMETER);
modules_fini(data);
unregister_event_handler(ad);
box_fini(&(ad->win));
- evas_image_cache_flush(ad->win.evas);
- evas_object_del(ad->win.layout);
- ad->win.layout = NULL;
- evas_object_del(ad->win.win);
- ad->win.win = NULL;
+ if (ad->win.evas)
+ evas_image_cache_flush(ad->win.evas);
+
+ if (ad->win.layout) {
+ evas_object_del(ad->win.layout);
+ ad->win.layout = NULL;
+ }
- evas_object_del(ad->win_overlay);
- ad->win_overlay = NULL;
+ if (ad->win.win) {
+ evas_object_del(ad->win.win);
+ ad->win.win = NULL;
+ }
- if (ad) free(ad);
+ _tzsh_unset(ad);
+
+ if (ad)
+ free(ad);
elm_exit();
- return OK;
+
+ return INDICATOR_ERROR_NONE;
}
static void __indicator_set_showhide_press(int value, int line)
static bool app_create(void *data)
{
- struct appdata *ad = NULL;
+ struct appdata *ad = data;
int ret;
- ad = data;
- elm_app_base_scale_set(1.7);
+ retv_if(!ad, false);
+
+ elm_app_base_scale_set(2.6);
/* Signal handler */
struct sigaction act;
- memset(&act,0x00,sizeof(struct sigaction));
+ memset(&act, 0x00, sizeof(struct sigaction));
act.sa_sigaction = _signal_handler;
act.sa_flags = SA_SIGINFO;
ret = sigemptyset(&act.sa_mask);
if (ret < 0) {
- ERR("Failed to sigemptyset[%s]", strerror(errno));
+ _E("Failed to sigemptyset[%s]", strerror(errno));
}
ret = sigaddset(&act.sa_mask, SIGTERM);
if (ret < 0) {
- ERR("Failed to sigaddset[%s]", strerror(errno));
+ _E("Failed to sigaddset[%s]", strerror(errno));
}
ret = sigaction(SIGTERM, &act, NULL);
if (ret < 0) {
- ERR("Failed to sigaction[%s]", strerror(errno));
+ _E("Failed to sigaction[%s]", strerror(errno));
}
- ret = _window_new(ad);
+ ret = _start_indicator(ad);
if (ret != INDICATOR_ERROR_NONE) {
_D("Failed to create a new window!");
}
_D("Start indicator");
- ret = perm_app_set_privilege("org.tizen.", NULL, NULL);
- if (ret != PC_OPERATION_SUCCESS) {
- _E("[INDICATOR] Failed to set privilege (%d)", ret);
- }
-
event_callback.create = app_create;
event_callback.terminate = app_terminate;
event_callback.pause = app_pause;