summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYoungHun Cho <hoon.cho@samsung.com>2017-01-02 11:21:26 +0900
committerYoungHun Cho <hoon.cho@samsung.com>2017-01-02 11:21:26 +0900
commite9da500001fba0a0e4226702a9326a4ec9914d54 (patch)
tree750f1f1b6a34a1d54114df3bac1a60fe6b9d3c67 /src
parent385023ec42b328b44a6c33b0d681fa31a0fc3508 (diff)
downloadw3-home-e9da500001fba0a0e4226702a9326a4ec9914d54.tar.gz
w3-home-e9da500001fba0a0e4226702a9326a4ec9914d54.tar.bz2
w3-home-e9da500001fba0a0e4226702a9326a4ec9914d54.zip
delete files for commit
Change-Id: I20c999006b17d33f03b93d3510f5543929bf53ba Signed-off-by: YoungHun Cho <hoon.cho@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/add-viewer.c1326
-rwxr-xr-xsrc/add-viewer_index.c293
-rwxr-xr-xsrc/add-viewer_package.c988
-rwxr-xr-xsrc/add-viewer_pkgmgr.c642
-rwxr-xr-xsrc/add-viewer_ucol.c790
-rwxr-xr-xsrc/add-viewer_util.c393
-rwxr-xr-xsrc/apps/apps_animator.c99
-rwxr-xr-xsrc/apps/apps_callback_manager.c113
-rwxr-xr-xsrc/apps/apps_conf.c25
-rwxr-xr-xsrc/apps/apps_data_app_info.c57
-rwxr-xr-xsrc/apps/apps_data_db.c427
-rwxr-xr-xsrc/apps/apps_data_manager.c451
-rwxr-xr-xsrc/apps/apps_data_package_manager.c368
-rwxr-xr-xsrc/apps/apps_data_xml_manager.c102
-rwxr-xr-xsrc/apps/apps_db.c231
-rwxr-xr-xsrc/apps/apps_key_handler.c181
-rwxr-xr-xsrc/apps/apps_lang_changed_handler.c97
-rwxr-xr-xsrc/apps/apps_manager.c364
-rwxr-xr-xsrc/apps/apps_rotary_event_handler.c130
-rwxr-xr-xsrc/apps/apps_state.c106
-rwxr-xr-xsrc/apps/apps_state_edit.c405
-rwxr-xr-xsrc/apps/apps_state_normal.c372
-rwxr-xr-xsrc/apps/apps_state_reorder.c189
-rwxr-xr-xsrc/apps/apps_view_base.c267
-rwxr-xr-xsrc/apps/apps_view_circle.c508
-rwxr-xr-xsrc/apps/apps_view_circle_animator.c277
-rwxr-xr-xsrc/apps/apps_view_circle_icon.c233
-rwxr-xr-xsrc/apps/apps_view_circle_icon_page.c1152
-rwxr-xr-xsrc/apps/apps_view_circle_indicator.c258
-rwxr-xr-xsrc/apps/apps_view_circle_touch_handler.c438
-rwxr-xr-xsrc/apps/apps_view_conf.c65
-rwxr-xr-xsrc/bg.c210
-rwxr-xr-xsrc/clock.c527
-rwxr-xr-xsrc/clock/clock_manager.c29
-rwxr-xr-xsrc/critical_log.c250
-rwxr-xr-xsrc/db.c749
-rwxr-xr-xsrc/edit.c3672
-rwxr-xr-xsrc/effect.c122
-rwxr-xr-xsrc/gesture.c202
-rwxr-xr-xsrc/home_base_ui.c40
-rwxr-xr-xsrc/home_manager.c79
-rwxr-xr-xsrc/home_state_handler.c33
-rwxr-xr-xsrc/index.c828
-rwxr-xr-xsrc/item_info.c94
-rwxr-xr-xsrc/key.c225
-rwxr-xr-xsrc/lang.c145
-rwxr-xr-xsrc/layout.c1048
-rwxr-xr-xsrc/main.c42
-rwxr-xr-xsrc/mapbuf.c249
-rwxr-xr-xsrc/noti_broker.c646
-rwxr-xr-xsrc/notification/noti_action_buttons_view.c166
-rwxr-xr-xsrc/notification/noti_detail_view.c564
-rwxr-xr-xsrc/notification/noti_event_manager.c74
-rwxr-xr-xsrc/notification/noti_event_mgr.c86
-rwxr-xr-xsrc/notification/noti_manager.c35
-rwxr-xr-xsrc/notification/noti_panel_cover_view.c276
-rwxr-xr-xsrc/notification/noti_panel_mgr.c651
-rwxr-xr-xsrc/notification/noti_panel_page_view.c120
-rwxr-xr-xsrc/notification/noti_panel_stack_view.c358
-rwxr-xr-xsrc/notification/noti_popup_full_view.c268
-rwxr-xr-xsrc/notification/noti_popup_mgr.c111
-rwxr-xr-xsrc/notification/noti_popup_small_view.c245
-rwxr-xr-xsrc/notification/noti_time.c733
-rwxr-xr-xsrc/page.c998
-rwxr-xr-xsrc/page_info.c139
-rwxr-xr-xsrc/pkgmgr.c759
-rwxr-xr-xsrc/popup.c68
-rwxr-xr-xsrc/scroller.c3189
-rwxr-xr-xsrc/util.c1138
-rwxr-xr-xsrc/virtual_canvas.c203
-rwxr-xr-xsrc/widget.c925
-rwxr-xr-xsrc/widgets/widgets_manager.c29
-rwxr-xr-xsrc/win.c144
-rwxr-xr-xsrc/wms.c110
-rwxr-xr-xsrc/xml.c375
75 files changed, 0 insertions, 32301 deletions
diff --git a/src/add-viewer.c b/src/add-viewer.c
deleted file mode 100755
index f9219ce..0000000
--- a/src/add-viewer.c
+++ /dev/null
@@ -1,1326 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <widget_service.h>
-#include <widget_errno.h>
-
-#include <dlog.h>
-#include <system_settings.h>
-
-#include <Elementary.h>
-#include <efl_extension.h>
-#include <vconf.h>
-
-#include "util.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "add-viewer.h"
-#include "add-viewer_pkgmgr.h"
-#include "add-viewer_ucol.h"
-#include "add-viewer_package.h"
-#include "add-viewer_debug.h"
-#include "add-viewer_util.h"
-#include "add-viewer_index.h"
-#include "conf.h"
-// #include "dbox.h"
-
-#include "bg.h"
-#include "rotary.h"
-
-#if defined(LOG_TAG)
-#undef LOG_TAG
-#endif
-#define LOG_TAG "ADD_VIEWER"
-#define ADD_VIEWER_CLASS_NAME "add-viewer"
-
-int errno;
-
-static struct {
- Evas_Smart_Class sc;
- Evas_Smart *smart;
- Eina_List *add_viewer_list;
- int enable_dnd;
-} s_info = {
- .sc = EVAS_SMART_CLASS_INIT_NAME_VERSION(ADD_VIEWER_CLASS_NAME),
- .smart = NULL,
- .add_viewer_list = NULL,
- .enable_dnd = 0,
-};
-
-struct widget_data {
- Evas *e;
- Evas_Object *stage;
-
- Evas_Object *add_viewer;
- Evas_Object *parent;
-
- Evas_Object *scroller;
- Evas_Object *index;
- Evas_Object *progress;
-
- Evas_Object *bg;
-};
-
-struct click {
- struct widget_data *widget_data;
- struct add_viewer_package *package;
- int size;
- Ecore_Timer *long_press_timer;
- int x;
- int y;
-
- struct dnd {
- Evas_Object *obj;
- } dnd;
-
- struct geo {
- Evas_Object *obj;
- int x;
- int y;
- } geo;
-};
-
-static Evas_Object *winset_preview_add(struct widget_data *widget_data, Evas_Object *parent, struct add_viewer_package *package, const char *name, const char *appname, int widget_count, int type, int no_event);
-
-static inline void append_padding(Evas_Object *box, int padding)
-{
- Evas_Object *pad;
-
- pad = elm_box_add(box);
- if (!pad) {
- ErrPrint("Failed to create a pad\n");
- return;
- }
-
- evas_object_resize(pad, padding, 1);
- evas_object_size_hint_min_set(pad, ELM_SCALE_SIZE(padding), ELM_SCALE_SIZE(1));
- evas_object_show(pad);
- elm_box_pack_end(box, pad);
-}
-
-static Eina_Bool normal_loader_cb(struct widget_data *widget_data, void *container)
-{
- struct add_viewer_package *package;
- Evas_Object *thumb_item;
- Eina_List *l;
- char *name = NULL;
- char *appname = NULL;
- char *filter;
-
- l = (Eina_List *)evas_object_data_get(container, "list");
- if (!l) {
- l = add_viewer_package_list_handle();
- if (!l) {
- ErrPrint("Failed to get package handler\n");
- goto cancel;
- }
-
- evas_object_data_set(container, "list", l);
- }
-
- package = add_viewer_package_list_item(l);
-
- l = add_viewer_package_list_next(l);
- evas_object_data_set(container, "list", l);
- if (!package) {
- ErrPrint("Package list is not valid\n");
- goto out;
- }
-
- const char *widget_id = add_viewer_package_list_pkgname(package);
- if (widget_id) {
- if (!strcmp(widget_id, CALENDAR_NEXT_EVENT_WIDGET_ID)) {
- if (util_host_vender_id_get() == W_HOME_VENDOR_ID_LO) {
- ErrPrint("not supported:%s", widget_id);
- goto out;
- }
- }
- }
-
- int max_instance = add_viewer_package_get_max_instance_count(package);
- int num_instance = add_viewer_package_get_instance_count(package);
-
- DbgPrint("widget_id[%s] max_instance[%d] num_instance[%d]", widget_id, max_instance, num_instance);
-
- if (max_instance != 0 && (max_instance <= num_instance)) {
- ErrPrint("max instance:%d skipped:%d\n", max_instance, num_instance);
- goto out;
- }
-
- int widget_count = add_viewer_package_get_widget_count_in_package(package);
-
- filter = evas_object_data_get(container, "filter");
- if (filter) {
- name = (char *)add_viewer_package_list_name(package);
- appname = (char *)add_viewer_package_list_appname(package);
- if (add_viewer_ucol_case_search(name, filter) < 0) {
- goto out;
- }
- if (add_viewer_ucol_case_search(appname, filter) < 0) {
- goto out;
- }
-
- name = add_viewer_util_highlight_keyword(name, filter);
- appname = add_viewer_util_highlight_keyword(appname, filter);
-
- thumb_item = winset_preview_add(widget_data, container, package, name, appname, widget_count, WIDGET_SIZE_TYPE_2x2, 0);
- WarnPrint("Added: %p %s %s\n", thumb_item, name, appname);
- free(name);
- free(appname);
- } else {
- name = elm_entry_utf8_to_markup(add_viewer_package_list_name(package));
- appname = elm_entry_utf8_to_markup((char*)add_viewer_package_list_appname(package));
-
- thumb_item = winset_preview_add(widget_data, container, package, name, appname, widget_count, WIDGET_SIZE_TYPE_2x2, 0);
- WarnPrint("Added: %p %s %s\n", thumb_item, name, appname);
- free(name);
- free(appname);
- }
-
- evas_object_data_set(thumb_item, "package", package);
- elm_box_pack_end(container, thumb_item);
-
-out:
- if (l) {
- return ECORE_CALLBACK_RENEW;
- }
- DbgPrint("Loading is finished\n");
-
-cancel:
- (void)evas_object_data_del(container, "list");
- (void)evas_object_data_del(container, "loader");
- DbgPrint("There is no content");
-
- l = elm_box_children_get(container);
- if (!l) {
- /* TODO: "No content" show */
- } else {
- eina_list_free(l);
- /* TODO: "No content" hide */
- append_padding(container, 46);
- }
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static int reload_list_cb(struct add_viewer_package *package, void *data)
-{
- Eina_List *children;
- Eina_List *l;
- Evas_Object *tmp;
- Ecore_Timer *timer;
- Evas_Object *container;
- struct widget_data *widget_data = data;
- scroller_info_s *scroller_info = NULL;
-
- scroller_info = evas_object_data_get(widget_data->scroller, DATA_KEY_SCROLLER_INFO);
-
- container = scroller_info->box;
- children = elm_box_children_get(container);
- EINA_LIST_FREE(children, tmp) {
- elm_box_unpack(container, tmp);
- evas_object_del(tmp);
- }
-
- timer = evas_object_data_del(container, "loader");
- if (timer) {
- ecore_timer_del(timer);
- (void)evas_object_data_del(container, "list");
- }
-
- append_padding(container, 46);
-
- while (normal_loader_cb(widget_data, container) == ECORE_CALLBACK_RENEW);
- children = elm_box_children_get(container);
- if (children) {
- Evas_Object *pad1 = eina_list_nth(children, 0);
- Evas_Object *pad2 = eina_list_nth(children, eina_list_count(children) - 1);
-
- children = eina_list_remove(children, pad1);
- children = eina_list_remove(children, pad2);
-
- if (children) {
- add_viewer_index_update(widget_data->index, children);
- eina_list_free(children);
- }
- }
-
- l = add_viewer_package_list_handle();
- if (l) {
- elm_object_part_text_set(widget_data->bg, "empty", "");
- } else {
- elm_object_part_text_set(widget_data->bg, "empty", _("IDS_ST_BODY_EMPTY"));
- }
-
- /* To set the first focus */
- evas_object_smart_callback_call(widget_data->scroller, "scroll", NULL);
-
- return WIDGET_ERROR_NONE;
-}
-
-static void widget_add(Evas_Object *add_viewer)
-{
- struct widget_data *widget_data;
-
- widget_data = calloc(1, sizeof(*widget_data));
- if (!widget_data) {
- ErrPrint("Failed to allocate heap: %d\n", errno);
- return;
- }
-
- widget_data->e = evas_object_evas_get(add_viewer);
- if (!widget_data->e) {
- ErrPrint("Failed to get Evas\n");
- free(widget_data);
- return;
- }
-
- widget_data->stage = evas_object_rectangle_add(widget_data->e);
- if (!widget_data->stage) {
- ErrPrint("Failed to create a stage\n");
- free(widget_data);
- return;
- }
-
- widget_data->add_viewer = add_viewer;
-
- evas_object_color_set(widget_data->stage, 255, 255, 255, 255);
- evas_object_smart_data_set(widget_data->add_viewer, widget_data);
- evas_object_smart_member_add(widget_data->stage, widget_data->add_viewer);
-
- s_info.add_viewer_list = eina_list_append(s_info.add_viewer_list, widget_data);
-
- add_viewer_package_list_add_event_callback(NULL, PACKAGE_LIST_EVENT_RELOAD, reload_list_cb, widget_data);
- /* widget_data->parent is not yet initialized */
-}
-
-/**
- * \note
- * This callback can be called while initializing a widget.
- * It means, the element of a structure could be null.
- * so we have to validate it before delete it.
- */
-static void widget_del(Evas_Object *add_viewer)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- add_viewer_package_list_del_event_callback(NULL, PACKAGE_LIST_EVENT_RELOAD, reload_list_cb, widget_data);
-
- s_info.add_viewer_list = eina_list_remove(s_info.add_viewer_list, widget_data);
-
- if (widget_data->scroller) {
- evas_object_smart_member_del(widget_data->scroller);
- evas_object_del(widget_data->scroller);
- }
-
- if (widget_data->stage) {
- evas_object_smart_member_del(widget_data->stage);
- evas_object_del(widget_data->stage);
- }
-
- if (widget_data->bg) {
- evas_object_smart_member_del(widget_data->bg);
- evas_object_del(widget_data->bg);
- }
-
- free(widget_data);
-}
-
-static void widget_move(Evas_Object *add_viewer, Evas_Coord x, Evas_Coord y)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_move(widget_data->scroller, x, y);
- evas_object_move(widget_data->stage, x, y);
- evas_object_move(widget_data->bg, x, y);
-}
-
-static void widget_resize(Evas_Object *add_viewer, Evas_Coord w, Evas_Coord h)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_resize(widget_data->scroller, w, h);
- evas_object_resize(widget_data->stage, w, h);
- evas_object_resize(widget_data->bg, w, h);
-}
-
-static void widget_show(Evas_Object *add_viewer)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_show(widget_data->stage);
-}
-
-static void widget_hide(Evas_Object *add_viewer)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_hide(widget_data->stage);
-}
-
-static void widget_color_set(Evas_Object *add_viewer, int r, int g, int b, int a)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_color_set(widget_data->stage, r, g, b, a);
-}
-
-static void widget_clip_set(Evas_Object *add_viewer, Evas_Object *clip)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_clip_set(widget_data->stage, clip);
-}
-
-static void widget_clip_unset(Evas_Object *add_viewer)
-{
- struct widget_data *widget_data;
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Invalid widget\n");
- return;
- }
-
- evas_object_clip_unset(widget_data->stage);
-}
-
-HAPI void evas_object_add_viewer_init(void)
-{
- add_viewer_ucol_init();
- (void)add_viewer_package_init();
-
-}
-
-HAPI void evas_object_add_viewer_fini(void)
-{
- (void)add_viewer_package_fini();
- add_viewer_ucol_fini();
-}
-
-static Eina_Bool register_access_object_for_edje_part(Evas_Object *object, const char *part_name)
-{
- Evas_Object *edje;
- Evas_Object *content;
- Elm_Access_Action_Info info;
- Elm_Access_Action_Type action;
-
- edje = evas_object_data_get(object, "edje");
- if (!edje) {
- return EINA_TRUE;
- }
-
- content = elm_object_part_content_get(edje, part_name);
- if (!content) {
- return EINA_TRUE;
- }
-
- memset(&info, 0, sizeof(info));
-
- action = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
- info.highlight_cycle = EINA_FALSE;
- return elm_access_action(content, action, &info);
-}
-
-static inline int make_clicked_event(Evas_Object *part_obj)
-{
- Evas_Object *ao;
- Evas *e;
- int x;
- int y;
- int w;
- int h;
- double timestamp;
-
- ao = evas_object_data_get(part_obj, "access,object");
- if (!ao) {
- ErrPrint("Access object is not exists\n");
- return EINA_FALSE;
- }
-
- e = evas_object_evas_get(part_obj);
- if (!e) {
- ErrPrint("evas is not valid\n");
- return EINA_FALSE;
- }
-
- evas_object_geometry_get(part_obj, &x, &y, &w, &h);
- x += w / 2;
- y += h / 2;
-
- timestamp = ecore_time_get();
-
- evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
- evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 10, NULL);
- evas_event_feed_mouse_move(e, x, y, timestamp + 15, NULL);
- evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 20, NULL);
-
- return EINA_TRUE;
-}
-
-static Eina_Bool activate_cb(void *part_name, Evas_Object *ao, Elm_Access_Action_Info *action_info)
-{
- Eina_Bool ret;
- Evas_Object *part_object;
-
- part_object = evas_object_data_get(ao, "part,object");
- if (!part_object) {
- return EINA_FALSE;
- }
-
- if (part_name) {
- ret = register_access_object_for_edje_part(part_object, part_name);
- } else {
- ret = make_clicked_event(part_object);
- }
-
- return ret;
-}
-
-static char *_access_tab_to_add_cb(void *data, Evas_Object *obj)
-{
- char *tmp;
-
- tmp = strdup(_("IDS_KM_BODY_DOUBLE_TAP_TO_ADD"));
- if (!tmp) {
- ErrPrint("tmp is not exist\n");
- return NULL;
- }
-
- return tmp;
-}
-
-
-
-HAPI void winset_access_object_add(Evas_Object *parent, Evas_Object *layout, const char *size, const char *name)
-{
- Evas_Object *ao;
- Evas_Object *part;
- char *text;
- int len;
-
- len = strlen(name) + (size ? strlen(size) : 0) + 2;
- text = malloc(len);
- if (!text) {
- ErrPrint("Heap : %d\n", errno);
- return;
- }
-
- strncpy(text, name, len);
-
- ao = evas_object_data_get(layout, "access,object");
- if (ao) {
- elm_access_info_set(ao, ELM_ACCESS_INFO, text);
- free(text);
- return;
- }
-
- Evas_Object *edje;
- edje = elm_layout_edje_get(layout);
- part = (Evas_Object *)edje_object_part_object_get(edje, "preview,dbg");
- ao = elm_access_object_register(part, layout);
- if (!ao) {
- free(text);
- return;
- }
-
- elm_access_info_set(ao, ELM_ACCESS_INFO, text);
- free(text);
-
- elm_access_info_set(ao, ELM_ACCESS_TYPE, _("IDS_IDLE_HEADER_WIDGET"));
-
- elm_access_info_cb_set(ao, ELM_ACCESS_CONTEXT_INFO, _access_tab_to_add_cb, NULL);
-
- elm_object_focus_custom_chain_append(layout, ao, NULL);
-
- evas_object_data_set(ao, "part,object", layout);
- evas_object_data_set(ao, "parent", parent);
-
- elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_ACTIVATE, activate_cb, NULL);
-
- evas_object_data_set(layout, "access,object", ao);
-}
-
-static void _change_focus(Evas_Object *scroller, Evas_Object *focus_widget)
-{
- Evas_Object *pre_focus = NULL;
-
- pre_focus = evas_object_data_get(scroller, "focused");
- if (pre_focus == focus_widget) return;
-
- if (pre_focus) {
- elm_object_signal_emit(focus_widget, "show", "line");
- } else {
- elm_object_signal_emit(focus_widget, "show,no,vi", "line");
- }
- evas_object_data_set(scroller, "focused", focus_widget);
-
- if (pre_focus && pre_focus != focus_widget) {
- elm_object_signal_emit(pre_focus, "hide", "line");
- }
-}
-
-static void _widget_scroll_cb(void *data, Evas_Object *obj, void *event_info)
-{
- struct widget_data *widget_data = data;
- Evas_Object *box = NULL;
- Evas_Object *scroller = obj;
- Evas_Object *focus_widget = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- int h_page = 0;
- Evas_Coord y;
- Evas_Coord x;
-
- DbgPrint("==== widget scroller cb ====\n");
-
- if (!scroller) {
- ErrPrint("Failed to load the widget scroller\n");
- return;
- }
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
-
- box = scroller_info->box;
- if (!box) {
- return;
- }
-
- list = elm_box_children_get(box);
- if (!list) {
- return;
- }
-
- evas_object_geometry_get(box, &x, &y, NULL, NULL);
- x -= (ADD_VIEWER_PAGE_WIDTH >> 1);
- h_page = -(x / ADD_VIEWER_PAGE_WIDTH);
-
- focus_widget = eina_list_nth(list, h_page + 1);
- eina_list_free(list);
-
- if (!focus_widget) {
- ErrPrint("Failed to get the focused page in scroller\n");
- return;
- }
-
- _change_focus(widget_data->scroller, focus_widget);
- add_viewer_index_bringin(widget_data->index, focus_widget);
-}
-
-static int widget_data_setup(struct widget_data *widget_data, Evas_Object *parent)
-{
- scroller_info_s *scroller_info = NULL;
-
- widget_data->parent = parent;
-
- widget_data->bg = elm_layout_add(widget_data->parent);
- if (!widget_data->bg) {
- return WIDGET_ERROR_FAULT;
- }
-
- if (elm_layout_file_set(widget_data->bg, EDJE_FILE, "bg") != EINA_TRUE) {
- evas_object_del(widget_data->bg);
- widget_data->bg = NULL;
- return WIDGET_ERROR_FAULT;
- }
- evas_object_show(widget_data->bg);
-
- widget_data->scroller = scroller_create(widget_data->bg, widget_data->bg, ADD_VIEWER_PAGE_WIDTH, ADD_VIEWER_PAGE_HEIGHT, SCROLLER_INDEX_SINGULAR);
- if (!widget_data->scroller) {
- evas_object_del(widget_data->bg);
- widget_data->bg = NULL;
- return WIDGET_ERROR_FAULT;
- }
-
- scroller_info = evas_object_data_get(widget_data->scroller, DATA_KEY_SCROLLER_INFO);
- if (!scroller_info) {
- scroller_destroy(widget_data->bg);
- evas_object_del(widget_data->bg);
- return WIDGET_ERROR_FAULT;
- }
-
- scroller_info->scroller_type = WIDGETS_STATE_ADD;
- evas_object_smart_callback_add(widget_data->scroller, "scroll", _widget_scroll_cb, widget_data);
-
- scroller_init_rotary(widget_data->scroller);
-
- evas_object_smart_member_add(widget_data->bg, widget_data->add_viewer);
- evas_object_clip_set(widget_data->bg, widget_data->stage);
- evas_object_smart_member_add(widget_data->scroller, widget_data->add_viewer);
- evas_object_clip_set(widget_data->scroller, widget_data->stage);
-
- evas_object_data_set(widget_data->scroller, DATA_KEY_WIDGET_DATA, widget_data);
-
- widget_data->index = add_viewer_index_create(widget_data->bg);
- evas_object_show(widget_data->index);
- evas_object_smart_member_add(widget_data->index, widget_data->add_viewer);
- evas_object_clip_set(widget_data->index, widget_data->stage);
- elm_object_part_content_set(widget_data->bg, "index", widget_data->index);
-
- return WIDGET_ERROR_NONE;
-}
-
-static void del_cb(void *data, Evas *e, Evas_Object *container, void *event_info)
-{
- free(data);
-}
-
-static Eina_Bool long_press_cb(void *data)
-{
- struct click *cbdata = data;
- int x;
- int y;
- int widget_count = 0;
-
- evas_object_geometry_get(cbdata->geo.obj, &x, &y, NULL, NULL);
-
- if (cbdata->geo.x == x && cbdata->geo.y == y) {
- const char *name = NULL;
- const char *appname = NULL;
- Evas_Coord w;
- Evas_Coord h;
- struct add_viewer_event_info info = {
- .pkg_info = {
- .widget_id = add_viewer_package_list_pkgname(cbdata->package),
- .content = NULL,
- .size_type = cbdata->size,
- },
- .move = {
- .obj = NULL,
- },
- };
-
- name = add_viewer_package_list_name(cbdata->package);
- appname = add_viewer_package_list_appname(cbdata->package);
- widget_count = add_viewer_package_get_widget_count_in_package(cbdata->package);
-
- info.move.obj = winset_preview_add(cbdata->widget_data, cbdata->geo.obj, cbdata->package, name, appname, widget_count, cbdata->size, 1);
- if (!info.move.obj) {
- ErrPrint("Failed to create a preview object\n");
- } else {
- /* Register the DnD object to Click CB Data to move it from move function */
- cbdata->dnd.obj = info.move.obj;
-
- evas_object_smart_member_add(cbdata->dnd.obj, cbdata->widget_data->add_viewer);
- evas_object_clip_set(cbdata->dnd.obj, cbdata->widget_data->stage);
-
- elm_object_signal_emit(cbdata->geo.obj, "reset", "preview,dbg");
-
- evas_object_hide(cbdata->widget_data->scroller);
- evas_object_hide(cbdata->widget_data->bg);
-
- evas_object_resize(cbdata->dnd.obj, 222, 336);
- evas_object_geometry_get(cbdata->dnd.obj, NULL, NULL, &w, &h);
-
- evas_object_move(cbdata->dnd.obj, cbdata->x - (w >> 1), cbdata->y - (h >> 1));
-
- evas_object_smart_callback_call(cbdata->widget_data->add_viewer, "dnd", &info);
-
- }
- } else {
- DbgPrint("Object is moved\n");
- }
-
- cbdata->long_press_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void add_to_home_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- struct click *cbdata = data;
- struct add_viewer_event_info info = {
- .move = {
- .obj = NULL,
- },
-
- .pkg_info = {
- .widget_id = add_viewer_package_list_pkgname(cbdata->package),
- .content = NULL,
- .size_type = cbdata->size,
- .duplicated = add_viewer_package_is_skipped(cbdata->package),
- .image = elm_object_part_content_unset(obj, "preview"),
- }
- };
-
- evas_object_smart_callback_call(cbdata->widget_data->add_viewer, "selected", &info);
-
- elm_access_say(_("IDS_TTS_BODY_ITEM_ADDED"));
-}
-
-static void preview_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- struct click *cbdata = data;
- Evas_Event_Mouse_Down *down = event_info;
-
- evas_object_geometry_get(obj, &cbdata->geo.x, &cbdata->geo.y, NULL, NULL);
- cbdata->geo.obj = obj;
-
- if (s_info.enable_dnd) {
- int delay = 0.5;
- double fdelay;
-
- //delay = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT; /* default 0.5 sec */
- //if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay) != 0) {
- //delay = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT;
- //}
-
- fdelay = ((double)delay / 1000.0f);
- DbgPrint("Long press: %lf\n", fdelay);
-
- cbdata->long_press_timer = ecore_timer_add(fdelay, long_press_cb, cbdata);
- if (!cbdata->long_press_timer) {
- ErrPrint("Failed to add timer\n");
- }
- }
-
- cbdata->x = down->canvas.x;
- cbdata->y = down->canvas.y;
-}
-
-static void preview_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- struct click *cbdata = data;
-
- if (cbdata->long_press_timer) {
- DbgPrint("Long press timer object found\n");
- ecore_timer_del(cbdata->long_press_timer);
- cbdata->long_press_timer = NULL;
- add_to_home_cb(data, NULL, NULL, NULL);
- } else {
- if (cbdata->dnd.obj) {
- add_to_home_cb(data, NULL, NULL, NULL);
- evas_object_smart_member_del(cbdata->dnd.obj);
- evas_object_del(cbdata->dnd.obj);
- cbdata->dnd.obj = NULL;
-
- evas_object_show(cbdata->widget_data->scroller);
- evas_object_show(cbdata->widget_data->bg);
- }
- }
- DbgPrint("Return\n");
-}
-
-static void preview_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- struct click *cbdata = data;
- Evas_Event_Mouse_Move *move = event_info;
- int dx;
- int dy;
- int x;
- int y;
-
- evas_object_geometry_get(obj, &x, &y, NULL, NULL);
-
- dx = move->cur.canvas.x - move->prev.canvas.x;
- dy = move->cur.canvas.y - move->prev.canvas.y;
-
- if ((abs(dx) > 5 || abs(dy) > 2 || cbdata->geo.x != x || cbdata->geo.y != y) && cbdata->long_press_timer) {
- ecore_timer_del(cbdata->long_press_timer);
- cbdata->long_press_timer = NULL;
- }
-
- cbdata->x = move->cur.canvas.x;
- cbdata->y = move->cur.canvas.y;
-
- if (cbdata->dnd.obj) {
- Evas_Coord w;
- Evas_Coord h;
-
- evas_object_geometry_get(cbdata->dnd.obj, NULL, NULL, &w, &h);
-
- evas_object_move(cbdata->dnd.obj, move->cur.canvas.x - (w >> 1), move->cur.canvas.y - (h >> 1));
- }
-}
-
-static char *cur_locale(void)
-{
- char *language = NULL;
- language = vconf_get_str(VCONFKEY_LANGSET);
- if (language) {
- char *ptr = NULL;
-
- ptr = language;
- while (*ptr) {
- if (*ptr == '.') {
- *ptr = '\0';
- break;
- }
-
- if (*ptr == '_') {
- *ptr = '-';
- }
-
- ptr++;
- }
- } else {
- language = strdup("en-us");
- if (!language) {
- ErrPrint("Heap: %d\n", errno);
- }
- }
-
- return language;
-}
-
-static void _operator_name_slide_mode_set(Evas_Object *name)
-{
- Evas_Object *name_edje;
- Evas_Object *tb;
- Evas_Coord tb_w=0;
-
- if (name == NULL) {
- ErrPrint("paramter error!");
- }
-
- elm_label_slide_mode_set(name, ELM_LABEL_SLIDE_MODE_NONE);
-
- name_edje = elm_layout_edje_get(name);
- if (!name_edje) {
- ErrPrint("Failed to get label edje");
- return;
- }
-
- tb = (Evas_Object*)edje_object_part_object_get(name_edje, "elm.text");
- if (!tb) {
- ErrPrint("Failed to get label tb");
- return;
- }
-
- evas_object_textblock_size_native_get(tb, &tb_w, NULL);
-
- if((tb_w > 0) && (tb_w > ADD_VIEWER_TEXT_WIDTH)) {
- elm_label_slide_mode_set(name, ELM_LABEL_SLIDE_MODE_AUTO);
- }
- elm_label_slide_go(name);
-}
-
-static Evas_Object *winset_preview_add(struct widget_data *widget_data, Evas_Object *parent, struct add_viewer_package *package, const char *name, const char *appname, int widget_count, int type, int no_event)
-{
- const char *size_str;
- const char *icon_group;
- Evas_Object *preview;
- Evas_Object *thumbnail;
- Evas_Object *label;
- int w;
- int h;
- int ret;
- int idx;
- char *filename = NULL;
- Evas_Object *bg;
- char buf[512] = {0, };
-
- const char *widget_id = add_viewer_package_list_pkgname(package);
- if (widget_id) {
- if (!strcmp(widget_id, APPSHORTCUT_WIDGET_ID)) {
- if (util_host_vender_id_get() == W_HOME_VENDOR_ID_LO) {
- char preview_path[512] = {0,};
- char *locale = cur_locale();
- if (locale) {
- snprintf(preview_path, sizeof(preview_path) - 1, APPSHORTCUT_WIDGET_LOCALE_PREVIEW, locale);
- if (ecore_file_exists(preview_path) == EINA_TRUE) {
- filename = strdup(preview_path);
- }
- free(locale);
- }
- if (!filename) {
- if (ecore_file_exists(APPSHORTCUT_WIDGET_PREVIEW) == EINA_TRUE) {
- filename = strdup(APPSHORTCUT_WIDGET_PREVIEW);
- }
- }
- }
- }
- }
- if (!filename) {
- filename = widget_service_get_preview_image_path(add_viewer_package_list_pkgname(package), type);
- }
-
- switch (type) {
- case WIDGET_SIZE_TYPE_1x1:
- size_str = "preview,1x1";
- icon_group = "default,1x1";
- idx = 8;
- break;
- case WIDGET_SIZE_TYPE_2x2:
- size_str = "preview,2x2";
- icon_group = "default,2x2";
- idx = 8;
- break;
- case WIDGET_SIZE_TYPE_2x1:
- case WIDGET_SIZE_TYPE_4x1:
- case WIDGET_SIZE_TYPE_4x2:
- case WIDGET_SIZE_TYPE_4x3:
- case WIDGET_SIZE_TYPE_4x4:
- case WIDGET_SIZE_TYPE_4x5:
- case WIDGET_SIZE_TYPE_4x6:
- case WIDGET_SIZE_TYPE_EASY_1x1:
- case WIDGET_SIZE_TYPE_EASY_3x1:
- case WIDGET_SIZE_TYPE_EASY_3x3:
- default:
- /* Unsupported */
- free(filename);
- return NULL;
- }
-
- preview = elm_layout_add(parent);
- if (!preview) {
- ErrPrint("Failed to add a new layout\n");
- free(filename);
- return NULL;
- }
-
- ret = elm_layout_file_set(preview, EDJE_FILE, size_str);
- if (ret != EINA_TRUE) {
- ErrPrint("Failed to load a layout file\n");
- evas_object_del(preview);
- free(filename);
- return NULL;
- }
-
- bg = evas_object_rectangle_add(widget_data->e);
- if (bg) {
- elm_object_part_content_set(preview, "bg", bg);
- bg_register_object(preview);
- }
-
- /* Load image */
- if (filename) {
- thumbnail = evas_object_image_filled_add(evas_object_evas_get(preview));
- if (!thumbnail) {
- ErrPrint("Failed to add an image\n");
- evas_object_del(preview);
- free(filename);
- return NULL;
- }
-
- evas_object_image_file_set(thumbnail, filename, NULL);
- ret = evas_object_image_load_error_get(thumbnail);
- if (ret != EVAS_LOAD_ERROR_NONE) {
- ErrPrint("Failed to set file: %s\n", filename);
- evas_object_image_file_set(thumbnail, UNKNOWN_ICON, NULL);
- ret = evas_object_image_load_error_get(thumbnail);
- if (ret != EVAS_LOAD_ERROR_NONE) {
- ErrPrint("Failed to set file: %s\n", UNKNOWN_ICON);
- evas_object_del(thumbnail);
- evas_object_del(preview);
- free(filename);
- return NULL;
- }
- }
- evas_object_image_size_get(thumbnail, &w, &h);
- evas_object_image_fill_set(thumbnail, 0, 0, w, h);
- free(filename);
- } else {
- Evas_Object *icon_image;
-
- filename = (char *)add_viewer_package_list_icon(package);
- name = add_viewer_package_list_name(package);
-
- DbgPrint("Image file: [%s] (%s)\n", filename, name);
- icon_image = evas_object_image_filled_add(evas_object_evas_get(preview));
- if (!icon_image) {
- evas_object_del(preview);
- return NULL;
- }
-
- evas_object_image_file_set(icon_image, filename, NULL);
- ret = evas_object_image_load_error_get(icon_image);
- if (ret != EVAS_LOAD_ERROR_NONE) {
- evas_object_image_file_set(icon_image, UNKNOWN_ICON, NULL);
- ret = evas_object_image_load_error_get(icon_image);
- if (ret != EVAS_LOAD_ERROR_NONE) {
- ErrPrint("Failed to set file\n");
- evas_object_del(icon_image);
- evas_object_del(preview);
- return NULL;
- }
- }
- evas_object_image_size_get(icon_image, &w, &h);
- evas_object_image_fill_set(icon_image, 0, 0, w, h);
- //evas_object_image_preload(icon_image, EINA_TRUE);
-
- thumbnail = elm_layout_add(parent);
- if (!thumbnail) {
- evas_object_del(icon_image);
- evas_object_del(preview);
- ErrPrint("Failed to create a layout\n");
- return NULL;
- }
-
- if (elm_layout_file_set(thumbnail, EDJE_FILE, icon_group) != EINA_TRUE) {
- ErrPrint("Failed to load a file\n");
- evas_object_del(icon_image);
- evas_object_del(preview);
- evas_object_del(thumbnail);
- return NULL;
- }
-
- elm_object_part_content_set(thumbnail, "icon", icon_image);
- elm_object_part_text_set(thumbnail, "text", name);
- }
-
- elm_object_part_content_set(preview, "preview", thumbnail);
-
- if (!name) {
- name = add_viewer_package_list_name(package);
- }
-
- label = elm_label_add(preview);
- if (!label) {
- ErrPrint("Failed to create the label\n");
- evas_object_del(preview);
- evas_object_del(thumbnail);
- return NULL;
- }
- if (name) {
- snprintf(buf, sizeof(buf), "<align=center><color=#FFFFFF><font_size=30>%s</font_size></color></align>", name);
- } else {
- snprintf(buf, sizeof(buf), "<align=center><color=#FFFFFF>%s</color></align>", " ");
- }
- elm_object_text_set(label, buf);
- elm_object_style_set(label, "slide_short");
- elm_label_wrap_width_set(label, ADD_VIEWER_TEXT_WIDTH);
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- _operator_name_slide_mode_set(label);
- evas_object_show(label);
- elm_object_part_content_set(preview, "title", label);
-
- DbgPrint("[%s] Image %dx%d\n", name, w, h);
- edje_object_size_min_calc(elm_layout_edje_get(preview), &w, &h);
- evas_object_size_hint_min_set(preview, w, h);
- DbgPrint("[%s] Image min %dx%d\n", name, w, h);
-
- if (!no_event) {
- struct click *click_cbdata;
-
- click_cbdata = calloc(1, sizeof(*click_cbdata));
- if (!click_cbdata) {
- ErrPrint("Heap: %d \n", errno);
- evas_object_del(thumbnail);
- evas_object_del(preview);
- return NULL;
- }
-
- click_cbdata->package = package;
- click_cbdata->size = type;
- click_cbdata->widget_data = widget_data;
- elm_object_signal_callback_add(preview, "clicked", "preview", add_to_home_cb, click_cbdata);
- evas_object_event_callback_add(preview, EVAS_CALLBACK_MOUSE_DOWN, preview_down_cb, click_cbdata);
- evas_object_event_callback_add(preview, EVAS_CALLBACK_MOUSE_MOVE, preview_move_cb, click_cbdata);
- evas_object_event_callback_add(preview, EVAS_CALLBACK_MOUSE_UP, preview_up_cb, click_cbdata);
- evas_object_event_callback_add(preview, EVAS_CALLBACK_DEL, del_cb, click_cbdata);
-
- winset_access_object_add(parent, preview, size_str + idx, add_viewer_package_list_name(package));
- }
- elm_object_signal_emit(preview, "hide,im", "line");
- elm_object_signal_emit(preview, add_viewer_package_is_skipped(package) ? "show" : "hide", "duplicated");
- edje_object_message_signal_process(elm_layout_edje_get(preview));
-
- evas_object_show(preview);
- return preview;
-}
-
-HAPI Evas_Object *evas_object_add_viewer_add(Evas_Object *parent)
-{
- struct widget_data *widget_data;
- Evas_Object *add_viewer;
- Evas *e;
-
- if (!s_info.smart) {
- s_info.sc.add = widget_add;
- s_info.sc.del = widget_del;
- s_info.sc.move = widget_move;
- s_info.sc.resize = widget_resize;
- s_info.sc.show = widget_show;
- s_info.sc.hide = widget_hide;
- s_info.sc.color_set = widget_color_set;
- s_info.sc.clip_set = widget_clip_set;
- s_info.sc.clip_unset = widget_clip_unset;
-
- s_info.smart = evas_smart_class_new(&s_info.sc);
- if (!s_info.smart) {
- ErrPrint("Failed to create a new smart class\n");
- return NULL;
- }
- }
-
- e = evas_object_evas_get(parent);
- if (!e) {
- ErrPrint("Failed to get \"Evas\"\n");
- return NULL;
- }
-
- /*
- * Invoke widget_add callback
- */
- add_viewer = evas_object_smart_add(e, s_info.smart);
- if (!add_viewer) {
- ErrPrint("Failed to create a new object\n");
- return NULL;
- }
-
- widget_data = evas_object_smart_data_get(add_viewer);
- if (!widget_data) {
- ErrPrint("Failed to get smart data\n");
- evas_object_del(add_viewer);
- return NULL;
- }
-
- if (widget_data_setup(widget_data, parent) < 0) {
- ErrPrint("Failed to initiate the widget_data\n");
- evas_object_del(add_viewer);
- return NULL;
- }
-
- reload_list_cb(NULL, widget_data);
-
- return add_viewer;
-}
-
-HAPI void evas_object_add_viewer_conf_set(int type, int flag)
-{
- switch (type) {
- case ADD_VIEWER_CONF_DND:
- s_info.enable_dnd = flag;
- break;
- default:
- break;
- }
-}
-
-HAPI int evas_object_add_viewer_access_action(Evas_Object *obj, int type, void *info)
-{
- struct widget_data *widget_data;
-
- if (!evas_object_smart_type_check(obj, ADD_VIEWER_CLASS_NAME)) {
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- widget_data = evas_object_smart_data_get(obj);
- if (!widget_data) {
- return WIDGET_ERROR_FAULT;
- }
-
- elm_access_action(widget_data->scroller, type, info);
-
- return WIDGET_ERROR_NONE;
-}
-
-HAPI int evas_object_add_viewer_reload(void)
-{
- Eina_List *l;
- Eina_List *n;
- struct widget_data *widget_data;
-
- add_viewer_package_reload_name();
-
- EINA_LIST_FOREACH_SAFE(s_info.add_viewer_list, l, n, widget_data) {
- reload_list_cb(NULL, widget_data);
- }
-
- return 0;
-}
-
-HAPI int evas_object_add_viewer_page_move(Evas_Object *obj, int direction)
-{
- struct widget_data *widget_data;
-
- if (!evas_object_smart_type_check(obj, ADD_VIEWER_CLASS_NAME)) {
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- widget_data = evas_object_smart_data_get(obj);
- if (!widget_data) {
- return WIDGET_ERROR_FAULT;
- }
- if (!widget_data->scroller) {
- return WIDGET_ERROR_FAULT;
- }
-
- Evas_Object *box = elm_object_content_get(widget_data->scroller);
- if (!box) {
- return WIDGET_ERROR_FAULT;
- }
-
- Eina_List *list = elm_box_children_get(box);
- if (!list) {
- return WIDGET_ERROR_FAULT;
- }
-
- int x = 0, h_page = 0;
- evas_object_geometry_get(box, &x, NULL, NULL, NULL);
- x -= (ADD_VIEWER_PAGE_WIDTH >> 1);
- h_page = -(x / ADD_VIEWER_PAGE_WIDTH);
-
- if (direction == 0) {
- elm_scroller_page_bring_in(widget_data->scroller, h_page - 1, 0);
- } else {
- elm_scroller_page_bring_in(widget_data->scroller, h_page + 1, 0);
- }
- eina_list_free(list);
-
- return WIDGET_ERROR_NONE;
-}
-/* End of a file */
diff --git a/src/add-viewer_index.c b/src/add-viewer_index.c
deleted file mode 100755
index cf4aa5e..0000000
--- a/src/add-viewer_index.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define ADD_VIEWER_DATA_KEY_INDEX_INFO "a_d_k_i"
-#define INDEX_EVEN_ITEM_NUM 20
-#define INDEX_ODD_ITEM_NUM 19
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <dlog.h>
-#include <system_settings.h>
-
-#include <Elementary.h>
-#include <efl_extension.h>
-//#include <ui_extension.h>
-
-#include "conf.h"
-#include "layout_info.h"
-#include "util.h"
-#include "main.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "index_info.h"
-#include "index.h"
-#include "scroller.h"
-#include "log.h"
-
-#include "add-viewer.h"
-#include "add-viewer_pkgmgr.h"
-#include "add-viewer_ucol.h"
-#include "add-viewer_package.h"
-#include "add-viewer_debug.h"
-#include "add-viewer_util.h"
-
-typedef struct {
- Evas_Object *page;
- int index;
-} page_index_s;
-
-
-static const char *_item_style_get(int index, int even)
-{
- static const char g_it_style_odd[INDEX_ODD_ITEM_NUM][20] = {
- "item/odd_1",
- "item/odd_2",
- "item/odd_3",
- "item/odd_4",
- "item/odd_5",
- "item/odd_6",
- "item/odd_7",
- "item/odd_8",
- "item/odd_9",
- "item/odd_10",
- "item/odd_11",
- "item/odd_12",
- "item/odd_13",
- "item/odd_14",
- "item/odd_15",
- "item/odd_16",
- "item/odd_17",
- "item/odd_18",
- "item/odd_19",
- };
- static const char g_it_style_even[INDEX_EVEN_ITEM_NUM][20] = {
- "item/even_1",
- "item/even_2",
- "item/even_3",
- "item/even_4",
- "item/even_5",
- "item/even_6",
- "item/even_7",
- "item/even_8",
- "item/even_9",
- "item/even_10",
- "item/even_11",
- "item/even_12",
- "item/even_13",
- "item/even_14",
- "item/even_15",
- "item/even_16",
- "item/even_17",
- "item/even_18",
- "item/even_19",
- "item/even_20",
- };
-
- index = (index < 0) ? 0 : index;
- if (even) {
- index = (index >= INDEX_EVEN_ITEM_NUM) ? INDEX_EVEN_ITEM_NUM - 1 : index;
-
- return g_it_style_even[index];
- } else {
- index = (index >= INDEX_ODD_ITEM_NUM) ? INDEX_ODD_ITEM_NUM - 1 : index;
-
- return g_it_style_odd[index];
- }
-}
-
-
-
-HAPI void add_viewer_index_bringin(Evas_Object *index, Evas_Object *page)
-{
- Elm_Object_Item *idx_it = NULL;
- const Eina_List *l = NULL;
- index_info_s *index_info = NULL;
- page_index_s *page_index = NULL;
- int idx = 0;
- int found = 0;
-
- ret_if(!index);
- ret_if(!page);
-
- index_info = evas_object_data_get(index, ADD_VIEWER_DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
- ret_if(!index_info->page_index_list);
-
- EINA_LIST_FOREACH(index_info->page_index_list, l, page_index) {
- if (page_index->page == page) {
- idx = page_index->index;
- found = 1;
- break;
- }
- }
-
- if (!found) {
- ErrPrint("Cannot find a page(%p)", page);
- return;
- }
-
- idx_it = elm_index_item_find(index, (void *) idx);
- if (idx_it) {
- elm_index_item_selected_set(idx_it, EINA_TRUE);
- } else {
- ErrPrint("Critical, the index(%p) cannot find the page(%p:%d)", index, page, idx);
- }
-}
-
-
-
-HAPI Evas_Object *add_viewer_index_create(Evas_Object *layout)
-{
- Evas_Object *index = NULL;
- index_info_s *index_info = NULL;
-
- if (!layout) {
- ErrPrint("Null:layout");
- return NULL;
- }
-
- index = elm_index_add(layout);
- if (index) {
- elm_object_style_set(index, "circle");
-
- index_info = calloc(1, sizeof(index_info_s));
- if (!index_info) {
- ErrPrint("Cannot calloc for index_info");
- evas_object_del(index);
- return NULL;
- }
- evas_object_data_set(index, ADD_VIEWER_DATA_KEY_INDEX_INFO, index_info);
-
- evas_object_size_hint_weight_set(index, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(index, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_index_horizontal_set(index, EINA_TRUE);
- elm_index_autohide_disabled_set(index, EINA_TRUE);
- elm_index_level_go(index, 0);
- evas_object_show(index);
- } else {
- ErrPrint("Failed to add index");
- }
-
- return index;
-}
-
-
-
-HAPI void add_viewer_index_destroy(Evas_Object *index)
-{
- index_info_s *index_info = NULL;
- page_index_s *page_index = NULL;
-
- ret_if(!index);
-
- index_info = evas_object_data_del(index, ADD_VIEWER_DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
-
- if (index_info->page_index_list) {
- EINA_LIST_FREE(index_info->page_index_list, page_index) {
- free(page_index);
- }
- index_info->page_index_list = NULL;
- }
-
- free(index_info);
- elm_index_item_clear(index);
- evas_object_del(index);
-}
-
-
-
-static void _update_page(Evas_Object *index, const Eina_List *list)
-{
- index_info_s *index_info = NULL;
- page_index_s *page_index = NULL;
-
- ret_if(!index);
- ret_if(!list);
-
- index_info = evas_object_data_get(index, ADD_VIEWER_DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
-
- /* 0. Remove an old page_index_list */
- if (index_info->page_index_list) {
- EINA_LIST_FREE(index_info->page_index_list, page_index) {
- free(page_index);
- }
- index_info->page_index_list = NULL;
- }
-
- int total_inserted = eina_list_count(list);
- int style_even = 0;
- int style_base = 0;
- if (!(total_inserted % 2)) {
- style_even = 1;
- style_base = 10 - (total_inserted / 2);
- } else {
- style_base = 9 - (total_inserted / 2);
- }
-
- DbgPrint("total_inserted:%d style_base:%d", total_inserted, style_base);
-
- int index_number = 0;
- Evas_Object *page = NULL;
- Elm_Object_Item *idx_it = NULL;
- const Eina_List *l = NULL;
-
- EINA_LIST_FOREACH(list, l, page) {
- idx_it = elm_index_item_append(index, NULL, NULL, (void *) index_number);
- elm_object_item_style_set(idx_it, _item_style_get(style_base + index_number, style_even));
- DbgPrint("other:%d style:%s", style_base + index_number, _item_style_get(style_base + index_number, style_even));
- //elm_object_item_part_content_set(idx_it, "icon", _item_icon_get(index));
-
- page_index = calloc(1, sizeof(page_index_s));
- continue_if(!page_index);
-
- page_index->index = index_number;
- page_index->page = page;
- index_info->page_index_list = eina_list_append(index_info->page_index_list, page_index);
-
- index_number++;
- }
-}
-
-
-
-HAPI void add_viewer_index_update(Evas_Object *index, Eina_List *page_list)
-{
- index_info_s *index_info = NULL;
-
- ret_if(!index);
- ret_if(!page_list);
-
- DbgPrint("Index(%p) is clear", index);
- elm_index_item_clear(index);
-
- index_info = evas_object_data_get(index, ADD_VIEWER_DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
-
- elm_object_style_set(index, "circle");
-
- _update_page(index, page_list);
-
- elm_index_level_go(index, 0);
-}
-
- // End of file
diff --git a/src/add-viewer_package.c b/src/add-viewer_package.c
deleted file mode 100755
index 4e142f0..0000000
--- a/src/add-viewer_package.c
+++ /dev/null
@@ -1,988 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdbool.h>
-
-#include <Evas.h>
-#include <Eina.h>
-#include <dlog.h>
-
-#include <widget_service_internal.h>
-#include <widget_service.h>
-#include <widget_errno.h>
-#include <pkgmgr-info.h>
-
-#if defined(LOG_TAG)
-#undef LOG_TAG
-#endif
-#define LOG_TAG "ADD_VIEWER"
-
-#include "add-viewer_package.h"
-#include "add-viewer_debug.h"
-#include "add-viewer_ucol.h"
-#include "add-viewer_pkgmgr.h"
-
-static struct info {
- Eina_List *package_list;
- Eina_List *event_list;
- int initialized;
-} s_info = {
- .package_list = NULL,
- .event_list = NULL,
- .initialized = 0,
-};
-
-struct package_list_event {
- enum pkg_evt_type event;
- struct add_viewer_package *package;
- int (*cb)(struct add_viewer_package *package, void *data);
- void *data;
-};
-
-struct add_viewer_preview {
- int size_type;
- void *data;
-};
-
-struct add_viewer_package {
- enum {
- PACKAGE_VALID = 0xbeefbeef,
- PACKAGE_INVALID = 0xdeaddead,
- } valid;
-
- char *name; /*!< Display name */
- char *pkgname; /*!< Package name */
- char *icon;
- char *appname;
- int disabled;
- int skipped;
- char *pkgid;
- int max_instance;
-
- struct {
- char *key;
- char *data;
- } extra;
-
- enum package_type type;
- Eina_List *preview_list;
-
- void *data;
-};
-
-static inline int sort_cb(const void *a, const void *b)
-{
- int ret;
-
- ret = add_viewer_ucol_compare(add_viewer_package_list_name((struct add_viewer_package *)a), add_viewer_package_list_name((struct add_viewer_package *)b));
- return ret;
-}
-
-#if defined(CHECK_PRELOAD)
-static int is_preloaded(const char *pkgid)
-{
- int ret;
- bool preload;
- pkgmgrinfo_pkginfo_h handle;
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
- if (ret != PMINFO_R_OK) {
- return 0;
- }
-
- ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return 0;
- }
-
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return preload == true ? 1 : 0;
-}
-#endif
-
-static int load_name_and_icon(struct add_viewer_package *item)
-{
- char err_buf[256] = { 0, };
- item->name = widget_service_get_name(item->pkgname, NULL);
- item->icon = widget_service_get_icon(item->pkgname, NULL);
- if (item->icon && access(item->icon, R_OK) != 0) {
- char *new_icon;
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("%s - %s\n", item->icon,err_buf );
- new_icon = strdup(RESDIR"/image/unknown.png");
- if (new_icon) {
- free(item->icon);
- item->icon = new_icon;
- } else {
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n",err_buf );
- }
- }
-
- if (!item->name || !item->icon) {
- char *pkgname;
- pkgmgrinfo_appinfo_h ai;
- int ret;
-
- pkgname = widget_service_get_main_app_id(item->pkgname);
- if (!pkgname) {
- ErrPrint("%s has no appid\n", item->pkgname);
- return -EINVAL;
- }
-
- ret = pkgmgrinfo_appinfo_get_appinfo(pkgname, &ai);
- free((char *)pkgname);
-
- if (ret != PMINFO_R_OK) {
- ErrPrint("Failed to get appinfo: %s\n", add_viewer_package_list_pkgname(item));
- if (!item->name) {
- ret = add_viewer_package_list_set_name(item, add_viewer_package_list_pkgname(item));
- if (ret != 0) {
- return ret;
- }
- }
-
- if (!item->icon) {
- ret = add_viewer_package_list_set_icon(item, RESDIR"/image/unknown.png");
- if (ret != 0) {
- return ret;
- }
- }
-
- s_info.package_list = eina_list_sorted_insert(s_info.package_list, sort_cb, item);
- return 0;
- }
-
- if (!item->icon) {
- char *icon;
- ret = pkgmgrinfo_appinfo_get_icon(ai, &icon);
- if (ret != PMINFO_R_OK || !icon || access(icon, R_OK) != 0) {
- ErrPrint("Fail to get the icon path %s - %d\n", icon, errno);
- icon = RESDIR"/image/unknown.png";
- }
-
- ret = add_viewer_package_list_set_icon(item, icon);
- if (ret != 0) {
- pkgmgrinfo_appinfo_destroy_appinfo(ai);
- return ret;
- }
- }
-
- if (!item->name) {
- char *name;
- ret = pkgmgrinfo_appinfo_get_label(ai, &name);
- if (ret != PMINFO_R_OK || !name) {
- name = item->pkgname;
- }
-
- ret = add_viewer_package_list_set_name(item, name);
- if (ret != 0) {
- pkgmgrinfo_appinfo_destroy_appinfo(ai);
- return ret;
- }
- }
-
- pkgmgrinfo_appinfo_destroy_appinfo(ai);
- }
-
- return 0;
-}
-
-static int widget_list_callback(const char *appid, const char *widget_id, int is_prime, void *data)
-{
- struct add_viewer_package *item;
- int cnt;
- int *size_types;
- int ret;
- int valid_size;
- struct add_viewer_preview *preview;
- char err_buf[256] = { 0, };
- Eina_List *preview_list = NULL;
-
- if (!widget_id || !appid) {
- ErrPrint("widget_id(%p) appid(%p) is not valid", widget_id, appid);
- return 0;
- }
-
-
- cnt = WIDGET_NR_OF_SIZE_LIST;
- ret = widget_service_get_supported_size_types(widget_id, &cnt, &size_types);
- if (ret != WIDGET_ERROR_NONE) {
- ErrPrint("Size is not valid: %s\n", widget_id);
- return 0;
- }
-
-#if defined(CHECK_PRELOAD)
- int preloaded = 0;
- if (cnt > 0) {
- /*!
- * If there are small size box,
- * we should check whether it is preloaded or not.
- * If it is preloaded packages, we have not to display it on the list.
- */
- switch (size_types[0]) {
- case WIDGET_SIZE_TYPE_2x2:
- preloaded = is_preloaded(appid);
- break;
- case WIDGET_SIZE_TYPE_1x1:
- case WIDGET_SIZE_TYPE_2x1:
- default:
- break;
- }
- }
-#endif
-
- valid_size = 0;
- while (--cnt >= 0) {
- preview = NULL;
-
- switch (size_types[cnt]) {
- case WIDGET_SIZE_TYPE_2x2:
-#if defined(CHECK_PRELOAD)
- if (preloaded) {
- continue;
- }
-#endif
- preview = calloc(1, sizeof(*preview));
- if (!preview) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- EINA_LIST_FREE(preview_list, preview) {
- free(preview);
- }
- free(size_types);
- return -ENOMEM;
- }
-
- valid_size++;
- preview->size_type = size_types[cnt];
- preview->data = NULL;
- preview_list = eina_list_append(preview_list, preview);
- break;
- case WIDGET_SIZE_TYPE_1x1:
- case WIDGET_SIZE_TYPE_2x1:
- case WIDGET_SIZE_TYPE_4x1:
- case WIDGET_SIZE_TYPE_4x2:
- case WIDGET_SIZE_TYPE_4x3:
- case WIDGET_SIZE_TYPE_4x4:
- case WIDGET_SIZE_TYPE_4x5:
- case WIDGET_SIZE_TYPE_4x6:
- case WIDGET_SIZE_TYPE_EASY_1x1:
- case WIDGET_SIZE_TYPE_EASY_3x1:
- case WIDGET_SIZE_TYPE_EASY_3x3:
- break;
- default:
- break;
- }
- }
-
- if (!valid_size) {
- DbgPrint("Has no valid size: %s\n", widget_id);
- free(size_types);
- return 0;
- }
-
- item = calloc(1, sizeof(*item));
- if (!item) {
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- EINA_LIST_FREE(preview_list, preview) {
- free(preview);
- }
- free(size_types);
- return -ENOMEM;
- }
-
- item->pkgname = strdup(widget_id);
- if (!item->pkgname) {
- strerror_r(errno,err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- free(item);
- EINA_LIST_FREE(preview_list, preview) {
- free(preview);
- }
- free(size_types);
- return -ENOMEM;
- }
-
- item->pkgid = strdup(appid);
- if (!item->pkgid) {
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n",err_buf );
- free(item->pkgname);
- free(item);
- EINA_LIST_FREE(preview_list, preview) {
- free(preview);
- }
- free(size_types);
- return -ENOMEM;
- }
-
- item->type = PACKAGE_TYPE_BOX;
- item->preview_list = preview_list;
- ret = load_name_and_icon(item);
- if (ret < 0) {
- free(item->pkgid);
- free(item->name);
- free(item->icon);
- free(item->pkgname);
- free(item);
- EINA_LIST_FREE(preview_list, preview) {
- free(preview);
- }
- free(size_types);
- return ret;
- }
- item->valid = PACKAGE_VALID;
- s_info.package_list = eina_list_sorted_insert(s_info.package_list, sort_cb, item);
- free(size_types);
- return 0;
-}
-
-static void invoke_update_event_callback(struct add_viewer_package *package)
-{
- struct package_list_event *item;
- Eina_List *l;
- Eina_List *n;
-
- EINA_LIST_FOREACH_SAFE(s_info.event_list, l, n, item) {
- if (item->package == package && item->event == PACKAGE_LIST_EVENT_UPDATE) {
- if (item->cb(package, item->data) < 0) {
- s_info.event_list = eina_list_remove(s_info.event_list, item);
- free(item);
- }
- }
- }
-}
-
-static void invoke_del_event_callback(struct add_viewer_package *package)
-{
- struct package_list_event *item;
- Eina_List *l;
- Eina_List *n;
-
- EINA_LIST_FOREACH_SAFE(s_info.event_list, l, n, item) {
- if (item->package == package && item->event == PACKAGE_LIST_EVENT_DEL) {
- if (item->cb(package, item->data) < 0) {
- s_info.event_list = eina_list_remove(s_info.event_list, item);
- free(item);
- }
- }
- }
-}
-
-static void invoke_reload_event_callback(void)
-{
- struct package_list_event *item;
- Eina_List *l;
- Eina_List *n;
-
- EINA_LIST_FOREACH_SAFE(s_info.event_list, l, n, item) {
- if (item->event == PACKAGE_LIST_EVENT_RELOAD) {
- if (item->cb(NULL, item->data) < 0) {
- s_info.event_list = eina_list_remove(s_info.event_list, item);
- free(item);
- }
- }
- }
-}
-
-static void package_delete(struct add_viewer_package *package)
-{
- struct add_viewer_preview *preview;
-
- s_info.package_list = eina_list_remove(s_info.package_list, package);
-
- DbgPrint("%s is deleted\n", package->pkgname);
-
- free(package->name);
- free(package->pkgid);
- free(package->appname);
- free(package->pkgname);
- free(package->icon);
- free(package->extra.key);
- free(package->extra.data);
-
- EINA_LIST_FREE(package->preview_list, preview) {
- free(preview);
- }
-
- free(package);
-}
-
-static int widget_add_by_pkgid_cb(const char *widget_id, int is_prime, void *data)
-{
- Eina_List *l;
- struct add_viewer_package *item;
- int exists = 0;
-
- DbgPrint("Add [%s]\n", widget_id);
-
- EINA_LIST_FOREACH(s_info.package_list, l, item) {
- if (!strcmp(item->pkgname, widget_id)) {
- exists = 1;
- break;
- }
- }
-
- if (!exists) {
- char *appid;
-
- appid = widget_service_get_package_id(widget_id);
- if (appid) {
- widget_list_callback(appid, widget_id, is_prime, NULL);
- free(appid);
- }
-
- EINA_LIST_FOREACH(s_info.package_list, l, item) {
- if (!strcmp(item->pkgname, widget_id)) {
- invoke_update_event_callback(item);
- break;
- }
- }
- }
-
- return 0;
-}
-
-static int widget_del_by_pkgid_cb(const char *widget_id, int is_prime, void *data)
-{
- Eina_List *l;
- Eina_List *n;
- struct add_viewer_package *item;
-
- DbgPrint("Del [%s]\n", widget_id);
-
- EINA_LIST_FOREACH_SAFE(s_info.package_list, l, n, item) {
- if (!strcmp(item->pkgname, widget_id)) {
- add_viewer_package_list_del(item);
- break;
- }
- }
-
- return 0;
-}
-
-static void widget_del_by_appid(const char *appid)
-{
- Eina_List *l;
- Eina_List *n;
- struct add_viewer_package *item;
-
- DbgPrint("Del [%s]\n", appid);
- EINA_LIST_FOREACH_SAFE(s_info.package_list, l, n, item) {
- if (!strcmp(item->pkgid, appid)) {
- DbgPrint("> Del [%s]\n", item->pkgname);
- add_viewer_package_list_del(item);
- /**
- * A pakcage can manage the several widgets
- * So we have to clean them all up
- * Don't break this loop until clear all of them.
- */
- }
- }
-}
-
-static int pkgmgr_install_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
- if (status != PKGMGR_STATUS_END) {
- return 0;
- }
-
- widget_service_get_widget_list_by_pkgid(pkgname, widget_add_by_pkgid_cb, NULL);
-
- invoke_reload_event_callback();
- return 0;
-}
-
-static int pkgmgr_uninstall_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
- if (status != PKGMGR_STATUS_START) {
- return 0;
- }
-
- if (widget_service_get_widget_list_by_pkgid(pkgname, widget_del_by_pkgid_cb, NULL) <= 0) {
- widget_del_by_appid(pkgname);
- }
-
- invoke_reload_event_callback();
- return 0;
-}
-
-static int pkgmgr_update_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
- if (status == PKGMGR_STATUS_START) {
- widget_service_get_widget_list_by_pkgid(pkgname, widget_del_by_pkgid_cb, NULL);
- } else if (status == PKGMGR_STATUS_END) {
- widget_service_get_widget_list_by_pkgid(pkgname, widget_add_by_pkgid_cb, NULL);
- }
-
- invoke_reload_event_callback();
- return 0;
-}
-
-HAPI int add_viewer_package_init(void)
-{
- int ret;
- int cnt = 0;
-
- if (s_info.initialized) {
- return 0;
- }
-
- s_info.initialized = 1;
-
- ret = add_viewer_pkgmgr_init();
- if (ret != WIDGET_ERROR_NONE && ret != WIDGET_ERROR_ALREADY_STARTED) {
- ErrPrint("Failed to initialize the pkgmgr\n");
- }
-
-
- ret = widget_service_get_widget_list(widget_list_callback, NULL);
- if (ret > 0) {
- cnt += ret;
- } else {
- ErrPrint("Failed to get widget list:%d\n", ret);
- }
-
-
- add_viewer_pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, pkgmgr_install_cb, NULL);
- add_viewer_pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, pkgmgr_update_cb, NULL);
- add_viewer_pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, pkgmgr_uninstall_cb, NULL);
-
- return 0;
-}
-
-HAPI int add_viewer_package_fini(void)
-{
- struct add_viewer_package *item;
- struct add_viewer_preview *preview;
-
- if (!s_info.initialized) {
- return 0;
- }
-
- add_viewer_pkgmgr_del_event_callback(PKGMGR_EVENT_INSTALL, pkgmgr_install_cb, NULL);
- add_viewer_pkgmgr_del_event_callback(PKGMGR_EVENT_UPDATE, pkgmgr_update_cb, NULL);
- add_viewer_pkgmgr_del_event_callback(PKGMGR_EVENT_UNINSTALL, pkgmgr_uninstall_cb, NULL);
-
- s_info.initialized = 0;
-
- EINA_LIST_FREE(s_info.package_list, item) {
- free(item->name);
- free(item->pkgid);
- free(item->pkgname);
- free(item->icon);
- free(item->extra.key);
- free(item->extra.data);
-
- EINA_LIST_FREE(item->preview_list, preview) {
- free(preview);
- }
-
- item->valid = PACKAGE_INVALID;
- free(item);
- }
-
- (void)add_viewer_pkgmgr_fini();
-
- return 0;
-}
-
-HAPI void *add_viewer_package_list_handle(void)
-{
- return s_info.package_list;
-}
-
-HAPI struct add_viewer_package *add_viewer_package_list_item(void *handle)
-{
- return eina_list_data_get(handle);
-}
-
-HAPI void *add_viewer_package_list_next(void *handle)
-{
- handle = eina_list_next(handle);
-
- if (!handle || s_info.package_list == handle) {
- return NULL;
- }
-
- return handle;
-}
-
-HAPI void *add_viewer_package_list_prev(void *handle)
-{
- if (!handle || handle == s_info.package_list) {
- return NULL;
- }
-
- return eina_list_prev(handle);
-}
-
-HAPI int add_viewer_package_list_add_event_callback(struct add_viewer_package *package, int event, int (*cb)(struct add_viewer_package *package, void *data), void *data)
-{
- struct package_list_event *item;
-
- item = calloc(1, sizeof(*item));
- if (!item) {
- ErrPrint("Heap: Fail to calloc - %d\n", errno);
- return -ENOMEM;
- }
-
- item->event = event;
- item->package = package;
- item->cb = cb;
- item->data = data;
-
- s_info.event_list = eina_list_append(s_info.event_list, item);
- return 0;
-}
-
-HAPI int add_viewer_package_list_del_event_callback(struct add_viewer_package *package, int event, int (*cb)(struct add_viewer_package *package, void *data), void *data)
-{
- Eina_List *l;
- Eina_List *n;
- struct package_list_event *item;
- int cnt = 0;
-
- EINA_LIST_FOREACH_SAFE(s_info.event_list, l, n, item) {
- if (item->package == package && item->cb == cb && item->data == data && item->event == event) {
- cnt++;
-
- s_info.event_list = eina_list_remove(s_info.event_list, item);
- free(item);
- }
- }
-
- return cnt > 0 ? 0 : -ENOENT;
-}
-
-HAPI void add_viewer_package_list_del(struct add_viewer_package *package)
-{
- invoke_del_event_callback(package);
- package_delete(package);
-}
-
-HAPI const char *add_viewer_package_list_name(struct add_viewer_package *package)
-{
- return package->name;
-}
-
-HAPI const char *add_viewer_package_list_appname(struct add_viewer_package *package)
-{
- return package->appname;
-}
-
-HAPI const char *add_viewer_package_list_pkgname(struct add_viewer_package *package)
-{
- return package->pkgname;
-}
-
-HAPI const char *add_viewer_package_list_pkgid(struct add_viewer_package *package)
-{
- return package->pkgid;
-}
-
-HAPI const char *add_viewer_package_list_icon(struct add_viewer_package *package)
-{
- return package->icon;
-}
-
-HAPI int add_viewer_package_list_type(struct add_viewer_package *package)
-{
- return package->type;
-}
-
-HAPI const char *add_viewer_package_list_extra_key(struct add_viewer_package *package)
-{
- return package->extra.key;
-}
-
-HAPI const char *add_viewer_package_list_extra_data(struct add_viewer_package *package)
-{
- return package->extra.data;
-}
-
-HAPI int add_viewer_package_is_valid(struct add_viewer_package *package)
-{
- return package->valid == PACKAGE_VALID;
-}
-
-HAPI int add_viewer_package_list_set_name(struct add_viewer_package *package, const char *name)
-{
- char *new_name;
-
- if (name) {
- new_name = strdup(name);
- if (!new_name) {
- ErrPrint("Heap: Fail to strdup - %d \n", errno);
- return -ENOMEM;
- }
- } else {
- new_name = NULL;
- }
-
- if (package->name) {
- free(package->name);
- }
-
- package->name = new_name;
- return 0;
-}
-
-HAPI int add_viewer_package_list_set_pkgname(struct add_viewer_package *package, const char *pkgname)
-{
- char *new_name;
-
- if (pkgname) {
- new_name = strdup(pkgname);
- if (!new_name) {
- ErrPrint("Heap: Fail to strdup - %d \n", errno);
- return -ENOMEM;
- }
- } else {
- new_name = NULL;
- }
-
- if (package->pkgname) {
- free(package->pkgname);
- }
-
- package->pkgname = new_name;
- return 0;
-}
-
-HAPI int add_viewer_package_list_set_icon(struct add_viewer_package *package, const char *icon)
-{
- char *new_name;
-
- if (icon) {
- new_name = strdup(icon);
- if (!new_name) {
- ErrPrint("Heap: Fail to strdup - %d\n", errno);
- return -ENOMEM;
- }
- } else {
- new_name = NULL;
- }
-
- if (package->icon) {
- free(package->icon);
- }
-
- package->icon = new_name;
- return 0;
-}
-
-HAPI int add_viewer_package_list_set_appname(struct add_viewer_package *package, const char *appname)
-{
- char *new_name;
- char err_buf[256] = { 0, };
- if (appname) {
- new_name = strdup(appname);
- if (!new_name) {
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n",err_buf );
- return -ENOMEM;
- }
- } else {
- new_name = NULL;
- }
-
- if (package->appname) {
- free(package->appname);
- }
-
- package->appname = new_name;
- return 0;
-}
-
-HAPI int add_viewer_package_get_widget_count_in_package(struct add_viewer_package *package)
-{
- if (!package) {
- return 0;
- }
- if (!package->pkgid) {
- return 0;
- }
-
- int count = 0;
- Eina_List *l;
- struct add_viewer_package *package_node = NULL;
-
- EINA_LIST_FOREACH(s_info.package_list, l, package_node) {
- if (package_node) {
- if (package_node->pkgid) {
- if (!strcmp(package_node->pkgid, package->pkgid)) {
- count++;
- }
- }
- }
- }
-
- return count;
-}
-
-int add_viewer_package_get_instance_count(struct add_viewer_package *package)
-{
- if (package == NULL) {
- ErrPrint("Invalid parameter");
- return 0;
- }
-
- return widget_service_get_instance_count(package->pkgname, NULL, NULL);
-}
-
-HAPI int add_viewer_package_get_max_instance_count(struct add_viewer_package *package)
-{
- if (package == NULL) {
- ErrPrint("Invalid parameter");
- return 0;
- }
-
- return widget_service_get_widget_max_count(package->pkgname);
-}
-
-HAPI void *add_viewer_package_list_preview_list(struct add_viewer_package *package)
-{
- return package->preview_list;
-}
-
-HAPI struct add_viewer_preview *add_viewer_package_list_preview(struct add_viewer_package *package, void *handle)
-{
- return eina_list_data_get(handle);
-}
-
-HAPI void *add_viewer_package_list_preview_next(struct add_viewer_package *package, void *handle)
-{
- handle = eina_list_next(handle);
- if (!handle || handle == package->preview_list) {
- return NULL;
- }
-
- return handle;
-}
-
-HAPI void *add_viewer_package_list_preview_prev(struct add_viewer_package *package, void *handle)
-{
- if (!handle || handle == package->preview_list) {
- return NULL;
- }
-
- handle = eina_list_prev(handle);
- return handle;
-}
-
-HAPI int add_viewer_package_list_preview_size(struct add_viewer_preview *preview)
-{
- return preview->size_type;
-}
-
-HAPI void *add_viewer_package_list_preview_data(struct add_viewer_preview *preview)
-{
- return preview->data;
-}
-
-HAPI void add_viewer_package_list_preview_set_data(struct add_viewer_preview *preview, void *data)
-{
- preview->data = data;
-}
-
-HAPI int add_viewer_package_is_disabled(struct add_viewer_package *package)
-{
- return package->disabled;
-}
-
-HAPI void add_viewer_package_set_disabled(struct add_viewer_package *package, int flag)
-{
- package->disabled = flag;
-}
-
-HAPI void add_viewer_package_set_skip(struct add_viewer_package *package, int skip)
-{
- if (skip == 0) {
- if (package->skipped > 0) {
- package->skipped--;
- }
- } else {
- package->skipped++;
- }
-}
-
-HAPI int add_viewer_package_is_skipped(struct add_viewer_package *package)
-{
- return package->skipped;
-}
-
-HAPI void *add_viewer_package_data(struct add_viewer_package *package)
-{
- return package->data;
-}
-
-HAPI void add_viewer_package_set_data(struct add_viewer_package *package, void *data)
-{
- package->data = data;
-}
-
-HAPI struct add_viewer_package *add_viewer_package_find(const char *widget_id)
-{
- Eina_List *l;
- struct add_viewer_package *package;
-
- EINA_LIST_FOREACH(s_info.package_list, l, package) {
- if (!strcmp(package->pkgname, widget_id)) {
- return package;
- }
- }
-
- return NULL;
-}
-
-HAPI int add_viewer_package_reload_name(void)
-{
- char *name;
- char *icon;
- struct add_viewer_package *package;
- Eina_List *new_list = NULL;
-
-
- EINA_LIST_FREE(s_info.package_list, package) {
- name = package->name;
- icon = package->icon;
- if (load_name_and_icon(package) < 0) {
- ErrPrint("Unable to reload name: %s\n", package->pkgid);
- package->name = name;
- package->icon = icon;
- } else {
- free(name);
- free(icon);
- }
-
- new_list = eina_list_sorted_insert(new_list, sort_cb, package);
- }
-
-
- s_info.package_list = new_list;
- return 0;
-}
-
-/* End of a file */
diff --git a/src/add-viewer_pkgmgr.c b/src/add-viewer_pkgmgr.c
deleted file mode 100755
index 3bed852..0000000
--- a/src/add-viewer_pkgmgr.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include <dlog.h>
-#include <package-manager.h>
-#include <widget_errno.h>
-
-#include <Ecore.h>
-#include <Evas.h> /* util.h */
-
-#include "add-viewer_package.h" /* util.h */
-#include "add-viewer_util.h"
-#include "add-viewer_debug.h"
-#include "add-viewer_pkgmgr.h"
-
-#define DbgFree(a) free(a)
-
-#if defined(LOG_TAG)
-#undef LOG_TAG
-#endif
-#define LOG_TAG "ADD_VIEWER"
-
-struct item {
- char *pkgname;
- char *icon;
-
- enum pkgmgr_event_type type;
- enum pkgmgr_status status;
-};
-
-static struct {
- pkgmgr_client *listen_pc;
- Eina_List *item_list;
-
- Eina_List *install_event;
- Eina_List *uninstall_event;
- Eina_List *update_event;
- Eina_List *download_event;
- Eina_List *recover_event;
-} s_info = {
- .listen_pc = NULL,
- .item_list = NULL,
-
- .install_event = NULL,
- .uninstall_event = NULL,
- .update_event = NULL,
- .download_event = NULL,
- .recover_event = NULL,
-};
-
-struct event_item {
- int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data);
- void *data;
-};
-
-static inline void invoke_install_event_handler(const char *pkgname, enum pkgmgr_status status, double value)
-{
- Eina_List *l;
- struct event_item *item;
-
- EINA_LIST_FOREACH(s_info.install_event, l, item) {
- if (item->cb) {
- item->cb(pkgname, status, value, item->data);
- }
- }
-}
-
-static inline void invoke_uninstall_event_handler(const char *pkgname, enum pkgmgr_status status, double value)
-{
- Eina_List *l;
- struct event_item *item;
-
- EINA_LIST_FOREACH(s_info.uninstall_event, l, item) {
- if (item->cb) {
- item->cb(pkgname, status, value, item->data);
- }
- }
-}
-
-static inline void invoke_update_event_handler(const char *pkgname, enum pkgmgr_status status, double value)
-{
- Eina_List *l;
- struct event_item *item;
-
- EINA_LIST_FOREACH(s_info.update_event, l, item) {
- if (item->cb) {
- item->cb(pkgname, status, value, item->data);
- }
- }
-}
-
-static inline void invoke_download_event_handler(const char *pkgname, enum pkgmgr_status status, double value)
-{
- Eina_List *l;
- struct event_item *item;
-
- EINA_LIST_FOREACH(s_info.download_event, l, item) {
- if (item->cb) {
- item->cb(pkgname, status, value, item->data);
- }
- }
-}
-
-static inline void invoke_recover_event_handler(const char *pkgname, enum pkgmgr_status status, double value)
-{
- Eina_List *l;
- struct event_item *item;
-
- EINA_LIST_FOREACH(s_info.recover_event, l, item) {
- if (item->cb) {
- item->cb(pkgname, status, value, item->data);
- }
- }
-}
-
-static inline void invoke_callback(const char *pkgname, struct item *item, double value)
-{
- switch (item->type) {
- case PKGMGR_EVENT_DOWNLOAD:
- invoke_download_event_handler(pkgname, item->status, value);
- break;
- case PKGMGR_EVENT_UNINSTALL:
- invoke_uninstall_event_handler(pkgname, item->status, value);
- break;
- case PKGMGR_EVENT_INSTALL:
- invoke_install_event_handler(pkgname, item->status, value);
- break;
- case PKGMGR_EVENT_UPDATE:
- invoke_update_event_handler(pkgname, item->status, value);
- break;
- case PKGMGR_EVENT_RECOVER:
- invoke_recover_event_handler(pkgname, item->status, value);
- break;
- default:
- ErrPrint("Unknown type: %d\n", item->type);
- break;
- }
-}
-
-static inline int is_valid_status(struct item *item, const char *status)
-{
- const char *expected_status;
-
- switch (item->type) {
- case PKGMGR_EVENT_DOWNLOAD:
- expected_status = "download";
- break;
- case PKGMGR_EVENT_UNINSTALL:
- expected_status = "uninstall";
- break;
- case PKGMGR_EVENT_INSTALL:
- expected_status = "install";
- break;
- case PKGMGR_EVENT_UPDATE:
- expected_status = "update";
- break;
- case PKGMGR_EVENT_RECOVER:
- expected_status = "recover";
- break;
- default:
- return 0;
- }
-
- return !strcasecmp(status, expected_status);
-}
-
-static struct item *find_item(const char *pkgname)
-{
- Eina_List *l;
- struct item *item;
-
- if (!pkgname) {
- ErrPrint("Package name is not valid\n");
- return NULL;
- }
-
- EINA_LIST_FOREACH(s_info.item_list, l, item) {
- if (strcmp(item->pkgname, pkgname)) {
- continue;
- }
-
- return item;
- }
-
- DbgPrint("Package %s is not found\n", pkgname);
- return NULL;
-}
-
-static int start_cb(const char *pkgname, const char *val, void *data)
-{
- struct item *item;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = calloc(1, sizeof(*item));
- if (!item) {
- char err_buf[256] = { 0, };
- ErrPrint("Heap: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- item->pkgname = strdup(pkgname);
- if (!item->pkgname) {
- char err_buf[256] = { 0, };
- ErrPrint("Heap: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
- DbgFree(item);
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- item->status = PKGMGR_STATUS_START;
-
- if (!strcasecmp(val, "download")) {
- item->type = PKGMGR_EVENT_DOWNLOAD;
- } else if (!strcasecmp(val, "uninstall")) {
- item->type = PKGMGR_EVENT_UNINSTALL;
- } else if (!strcasecmp(val, "install")) {
- item->type = PKGMGR_EVENT_INSTALL;
- } else if (!strcasecmp(val, "update")) {
- item->type = PKGMGR_EVENT_UPDATE;
- } else if (!strcasecmp(val, "recover")) {
- item->type = PKGMGR_EVENT_RECOVER;
- } else {
- DbgFree(item->pkgname);
- DbgFree(item);
- ErrPrint("Invalid val: %s\n", val);
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- s_info.item_list = eina_list_append(s_info.item_list, item);
-
- invoke_callback(pkgname, item, 0.0f);
- return WIDGET_ERROR_NONE;
-}
-
-static int icon_path_cb(const char *pkgname, const char *val, void *data)
-{
- struct item *item;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- return WIDGET_ERROR_NOT_EXIST;
- }
-
- if (item->icon) {
- DbgFree(item->icon);
- }
-
- item->icon = strdup(val);
- if (!item->icon) {
- char err_buf[256] = { 0, };
- ErrPrint("Heap: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- return WIDGET_ERROR_NONE;
-}
-
-static int command_cb(const char *pkgname, const char *val, void *data)
-{
- struct item *item;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- return WIDGET_ERROR_NOT_EXIST;
- }
-
- if (!is_valid_status(item, val)) {
- DbgPrint("Invalid status: %d, %s\n", item->type, val);
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- item->status = PKGMGR_STATUS_COMMAND;
- invoke_callback(pkgname, item, 0.0f);
- return WIDGET_ERROR_NONE;
-}
-
-static int error_cb(const char *pkgname, const char *val, void *data)
-{
- /* val = error */
- struct item *item;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- return WIDGET_ERROR_NOT_EXIST;
- }
-
- item->status = PKGMGR_STATUS_ERROR;
- invoke_callback(pkgname, item, 0.0f);
- return WIDGET_ERROR_NONE;
-}
-
-static int change_pkgname_cb(const char *pkgname, const char *val, void *data)
-{
- struct item *item;
- char *new_pkgname;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- return WIDGET_ERROR_NOT_EXIST;
- }
-
- new_pkgname = strdup(val);
- if (!new_pkgname) {
- char err_buf[256] = { 0, };
- ErrPrint("Heap: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- DbgFree(item->pkgname);
- item->pkgname = new_pkgname;
- return WIDGET_ERROR_NONE;
-}
-
-static int download_cb(const char *pkgname, const char *val, void *data)
-{
- /* val = integer */
- struct item *item;
- double value;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- DbgPrint("ITEM is not started from the start_cb\n");
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- if (item->type != PKGMGR_EVENT_DOWNLOAD) {
- DbgPrint("TYPE is not \"download\" : %d\n", item->type);
- item->type = PKGMGR_EVENT_DOWNLOAD;
- }
-
- switch (item->status) {
- case PKGMGR_STATUS_START:
- case PKGMGR_STATUS_COMMAND:
- item->status = PKGMGR_STATUS_PROCESSING;
- case PKGMGR_STATUS_PROCESSING:
- break;
- default:
- ErrPrint("Invalid state [%s, %s]\n", pkgname, val);
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- if (val) {
- if (sscanf(val, "%lf", &value) != 1) {
- value = (double)WIDGET_ERROR_INVALID_PARAMETER;
- }
- } else {
- value = (double)WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- invoke_download_event_handler(pkgname, item->status, value);
- return WIDGET_ERROR_NONE;
-}
-
-static int progress_cb(const char *pkgname, const char *val, void *data)
-{
- /* val = integer */
- struct item *item;
- double value;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- ErrPrint("ITEM is not started from the start_cb\n");
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- switch (item->status) {
- case PKGMGR_STATUS_START:
- case PKGMGR_STATUS_COMMAND:
- item->status = PKGMGR_STATUS_PROCESSING;
- case PKGMGR_STATUS_PROCESSING:
- break;
- default:
- ErrPrint("Invalid state [%s, %s]\n", pkgname, val);
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- if (val) {
- if (sscanf(val, "%lf", &value) != 1) {
- value = (double)WIDGET_ERROR_INVALID_PARAMETER;
- }
- } else {
- value = (double)WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- invoke_callback(pkgname, item, value);
- return WIDGET_ERROR_NONE;
-}
-
-static int end_cb(const char *pkgname, const char *val, void *data)
-{
- struct item *item;
-
- DbgPrint("[%s] %s\n", pkgname, val);
-
- item = find_item(pkgname);
- if (!item) {
- return WIDGET_ERROR_NOT_EXIST;
- }
-
- item->status = !strcasecmp(val, "ok") ? PKGMGR_STATUS_END : PKGMGR_STATUS_ERROR;
-
- invoke_callback(pkgname, item, 0.0f);
-
- s_info.item_list = eina_list_remove(s_info.item_list, item);
- DbgFree(item->icon);
- DbgFree(item->pkgname);
- DbgFree(item);
- return WIDGET_ERROR_NONE;
-}
-
-static struct pkgmgr_handler {
- const char *key;
- int (*func)(const char *package, const char *val, void *data);
-} handler[] = {
- { "install_percent", progress_cb },
- { "download_percent", download_cb },
- { "start", start_cb },
- { "end", end_cb },
- { "change_pkg_name", change_pkgname_cb },
- { "icon_path", icon_path_cb },
- { "command", command_cb },
- { "error", error_cb },
- { NULL, NULL },
-};
-
-static int pkgmgr_cb(uid_t target_uid, int req_id, const char *type, const char *pkgname, const char *key, const char *val, const void *pmsg, void *data)
-{
- register int i;
- int ret;
-
- for (i = 0; handler[i].key; i++) {
- if (strcasecmp(key, handler[i].key)) {
- continue;
- }
-
- ret = handler[i].func(pkgname, val, data);
- if (ret < 0) {
- DbgPrint("REQ[%d] pkgname[%s], type[%s], key[%s], val[%s], ret = %d\n",
- req_id, pkgname, type, key, val, ret);
- }
- }
-
- return WIDGET_ERROR_NONE;
-}
-
-HAPI int add_viewer_pkgmgr_init(void)
-{
- if (s_info.listen_pc) {
- return WIDGET_ERROR_ALREADY_STARTED;
- }
-
- s_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
- if (!s_info.listen_pc) {
- ErrPrint("Failed to client_new\n");
- return WIDGET_ERROR_FAULT;
- }
-
- if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) < 0) {
- ErrPrint("Failed to add listener\n");
- return WIDGET_ERROR_FAULT;
- }
-
- return WIDGET_ERROR_NONE;
-}
-
-HAPI int add_viewer_pkgmgr_fini(void)
-{
- struct event_item *item;
- struct item *ctx;
-
- if (!s_info.listen_pc) {
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK) {
- return WIDGET_ERROR_FAULT;
- }
-
- s_info.listen_pc = NULL;
-
- EINA_LIST_FREE(s_info.download_event, item) {
- DbgFree(item);
- }
-
- EINA_LIST_FREE(s_info.uninstall_event, item) {
- DbgFree(item);
- }
-
- EINA_LIST_FREE(s_info.install_event, item) {
- DbgFree(item);
- }
-
- EINA_LIST_FREE(s_info.update_event, item) {
- DbgFree(item);
- }
-
- EINA_LIST_FREE(s_info.recover_event, item) {
- DbgFree(item);
- }
-
- EINA_LIST_FREE(s_info.item_list, ctx) {
- DbgFree(ctx->pkgname);
- DbgFree(ctx->icon);
- DbgFree(ctx);
- }
-
- return WIDGET_ERROR_NONE;
-}
-
-HAPI int add_viewer_pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data)
-{
- struct event_item *item;
-
- item = calloc(1, sizeof(*item));
- if (!item) {
- ErrPrint("Heap: Fail to calloc - %d \n", errno);
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- item->cb = cb;
- item->data = data;
-
- switch (type) {
- case PKGMGR_EVENT_DOWNLOAD:
- s_info.download_event = eina_list_prepend(s_info.download_event, item);
- break;
- case PKGMGR_EVENT_UNINSTALL:
- s_info.uninstall_event = eina_list_prepend(s_info.uninstall_event, item);
- break;
- case PKGMGR_EVENT_INSTALL:
- s_info.install_event = eina_list_prepend(s_info.install_event, item);
- break;
- case PKGMGR_EVENT_UPDATE:
- s_info.update_event = eina_list_prepend(s_info.update_event, item);
- break;
- case PKGMGR_EVENT_RECOVER:
- s_info.recover_event = eina_list_prepend(s_info.recover_event, item);
- break;
- default:
- DbgFree(item);
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- return WIDGET_ERROR_NONE;
-}
-
-HAPI void *add_viewer_pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data)
-{
- struct event_item *item;
- Eina_List *l;
- void *cbdata = NULL;
-
- switch (type) {
- case PKGMGR_EVENT_DOWNLOAD:
- EINA_LIST_FOREACH(s_info.download_event, l, item) {
- if (item->cb == cb && item->data == data) {
- s_info.download_event = eina_list_remove(s_info.download_event, item);
- cbdata = item->data;
- DbgFree(item);
- break;
- }
- }
- break;
- case PKGMGR_EVENT_UNINSTALL:
- EINA_LIST_FOREACH(s_info.uninstall_event, l, item) {
- if (item->cb == cb && item->data == data) {
- s_info.uninstall_event = eina_list_remove(s_info.uninstall_event, item);
- cbdata = item->data;
- DbgFree(item);
- break;
- }
- }
- break;
- case PKGMGR_EVENT_INSTALL:
- EINA_LIST_FOREACH(s_info.install_event, l, item) {
- if (item->cb == cb && item->data == data) {
- s_info.install_event = eina_list_remove(s_info.install_event, item);
- cbdata = item->data;
- DbgFree(item);
- break;
- }
- }
- break;
- case PKGMGR_EVENT_UPDATE:
- EINA_LIST_FOREACH(s_info.update_event, l, item) {
- if (item->cb == cb && item->data == data) {
- s_info.update_event = eina_list_remove(s_info.update_event, item);
- cbdata = item->data;
- DbgFree(item);
- break;
- }
- }
- break;
- case PKGMGR_EVENT_RECOVER:
- EINA_LIST_FOREACH(s_info.recover_event, l, item) {
- if (item->cb == cb && item->data == data) {
- s_info.recover_event = eina_list_remove(s_info.recover_event, item);
- cbdata = item->data;
- DbgFree(item);
- break;
- }
- }
- break;
- default:
- ErrPrint("Invalid type\n");
- break;
- }
-
- return cbdata;
-}
-
-/* End of a file */
diff --git a/src/add-viewer_ucol.c b/src/add-viewer_ucol.c
deleted file mode 100755
index fbc9e6d..0000000
--- a/src/add-viewer_ucol.c
+++ /dev/null
@@ -1,790 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-
-#include <ctype.h>
-
-#include <Eina.h>
-#include <dlog.h>
-#include <Evas.h>
-
-#include <unicode/ucol.h>
-#include <unicode/ustring.h>
-#include <unicode/usearch.h>
-
-#include "add-viewer_debug.h"
-#include "add-viewer_ucol.h"
-#include "add-viewer_package.h"
-#include "add-viewer_util.h"
-
-#if defined(LOG_TAG)
-#undef LOG_TAG
-#endif
-#define LOG_TAG "ADD_VIEWER"
-
-static struct info {
- UCollator *coll;
- enum LANGUAGE lang;
- char *env_lang;
-} s_info = {
- .coll = NULL,
- .lang = LANG_ENGLISH,
- .env_lang = NULL,
-};
-
-HAPI int add_viewer_ucol_init(void)
-{
- const char *env;
- UErrorCode status = U_ZERO_ERROR;
-
- env = getenv("LANG");
- if (env) {
- if (!strcasecmp(env, "en_US.utf-8")) {
- s_info.lang = LANG_ENGLISH;
- s_info.env_lang = "en_US.utf-8";
- } else if (!strcasecmp(env, "ja_JP.utf-8")) {
- s_info.lang = LANG_JAPANESS;
- s_info.env_lang = "ja_JP.utf-8";
- } else if (!strcasecmp(env, "ko_KR.utf-8")) {
- s_info.lang = LANG_KOREAN;
- s_info.env_lang = "ko_KR.utf-8";
- }
- }
-
- s_info.coll = ucol_open(NULL, &status);
- if (U_FAILURE(status)) {
- ErrPrint("Failed to open ucol (%d)\n", status);
- ucol_close(s_info.coll);
- s_info.coll = NULL;
- }
-
- status = U_ZERO_ERROR;
- ucol_setAttribute(s_info.coll, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
- if (U_FAILURE(status)) {
- ErrPrint("Failed to open ucol (%d)\n", status);
- ucol_close(s_info.coll);
- s_info.coll = NULL;
- }
-
- ucol_setStrength(s_info.coll, UCOL_PRIMARY);
- return 0;
-}
-
-static inline UChar *to_UTF16(const char *src, int *out_len)
-{
- UChar *res;
- UErrorCode status = U_ZERO_ERROR;
- int len;
-
- u_strFromUTF8(NULL, 0, &len, src, -1, &status);
-
- res = malloc((len + 1) * sizeof(*res));
- if (!res) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- return NULL;
- }
-
- status = U_ZERO_ERROR;
- u_strFromUTF8(res, len + 1, &len, src, -1, &status);
- if (U_FAILURE(status)) {
- ErrPrint("Unable to convert(%s) to UTF16(%s)\n", src, u_errorName(status));
- free(res);
- return NULL;
- }
- res[len] = (UChar)0;
-
- if (out_len) {
- *out_len = len;
- }
- return res;
-}
-
-static inline char *to_UTF8(UChar *src, int *out_len)
-{
- char *res;
- UErrorCode status = U_ZERO_ERROR;
- int len;
-
- u_strToUTF8(NULL, 0, &len, src, -1, &status);
-
- res = malloc((len + 1) * sizeof(*res));
- if (!res) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- return NULL;
- }
-
- status = U_ZERO_ERROR;
- u_strToUTF8(res, len + 1, &len, src, -1, &status);
- if (U_FAILURE(status)) {
- ErrPrint("Unable to convert to UTF8(%s)\n", u_errorName(status));
- free(res);
- return NULL;
- }
- res[len] = '\0';
-
- if (out_len) {
- *out_len = len;
- }
-
- return res;
-}
-
-static inline int hangul_to_jamo(const char *index)
-{
- Eina_Unicode *ret;
- Eina_Unicode tmp = 0;
- int base = 0xAC00;
- int last = 0xD79F;
- int a;
- static int table[] = {
- 0x00003131, 0x00003131,
- 0x00003134,
- 0x00003137, 0x00003137,
- 0x00003139,
- 0x00003141,
- 0x00003142, 0x00003142,
- 0x00003145, 0x00003145,
- 0x00003147,
- 0x00003148, 0x00003148,
- 0x0000314a,
- 0x0000314b,
- 0x0000314c,
- 0x0000314d,
- 0x0000314e,
- /*
- 0xb184e3, 0xb284e3, 0xb484e3, 0xb784e3, 0xb884e3, 0xb984e3,
- 0x8185e3, 0x8285e3, 0x8385e3, 0x8585e3, 0x8685e3, 0x8785e3,
- 0x8885e3, 0x8985e3, 0x8a85e3, 0x8b85e3, 0x8c85e3, 0x8d85e3,
- 0x8e85e3,
- */
- };
-
- ret = eina_unicode_utf8_to_unicode(index, &a);
- if (ret) {
- tmp = *ret;
- free(ret);
- }
-
- if (tmp < base || tmp > last) {
- return tmp;
- }
-
- tmp = tmp - base;
- a = tmp / (21 * 28);
- return table[a];
-}
-
-#define __isalpha(a) (((a) >= 'a' && (a) <= 'z') || ((a) >= 'A' && (a) <= 'Z'))
-#define __tolower(a) (((a) >= 'A' && (a) <= 'Z') ? (a) + 32 : (a))
-
-HAPI int add_viewer_ucol_compare_first_letters(const char *name, const char *letters)
-{
- if (!letters) {
- ErrPrint("letter is NULL");
- return -1;
- }
-
- if (s_info.lang == LANG_KOREAN) {
- int jamo_name;
- int jamo_letters = 0;
- Eina_Unicode *ucs;
-
- jamo_name = hangul_to_jamo(name);
-
- ucs = eina_unicode_utf8_to_unicode(letters, &jamo_letters);
- if (ucs) {
- jamo_letters = (int)*ucs;
- free(ucs);
- }
-
- if (__isalpha(jamo_letters)) {
- if (!__isalpha(jamo_name)) {
- //DbgPrint("%d - %d (%s, %s)\n", jamo_name, jamo_letters, name, letters);
- return -1;
- }
-
- return __tolower(jamo_name) - __tolower(jamo_letters);
- }
-
- return jamo_name - jamo_letters;
- }
-
- return add_viewer_ucol_ncompare(name, letters, strlen(letters));
-}
-
-HAPI int add_viewer_ucol_is_alpha(const char *name)
-{
- Eina_Unicode *ucs;
- int len;
- int letter = 0;
-
- ucs = eina_unicode_utf8_to_unicode(name, &len);
- if (ucs) {
- letter = (int)*ucs;
- free(ucs);
- }
-
- return __isalpha(letter);
-}
-
-HAPI int add_viewer_ucol_detect_lang(int ch)
-{
-// int result;
- int lang;
-// int status;
-// int size;
-
- /*
- u_strToUpper((UChar *)&ch, 1, (UChar *)&result, -1, NULL, &status);
- if (U_FAILURE(status)) {
- ErrPrint("u_strToLower: %s\n", u_errorName(status));
- return LANG_UNKNOWN;
- }
-
- size = unorm_normalize((UChar *)&result, 1, UNORM_NFD, 0, (UChar *)&result, 1, &status);
- if (U_FAILURE(status)) {
- ErrPrint("unorm_normalize: %s\n", u_errorName(status));
- return LANG_UNKNOWN;
- }
- */
-
- lang = ublock_getCode(ch);
- switch (lang) {
- case UBLOCK_HIRAGANA:
- case UBLOCK_KATAKANA:
- case UBLOCK_KATAKANA_PHONETIC_EXTENSIONS:
- case UBLOCK_JAVANESE:
- case UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS:
- lang = LANG_JAPANESS;
- break;
- case UBLOCK_HANGUL_JAMO:
- case UBLOCK_HANGUL_COMPATIBILITY_JAMO:
- case UBLOCK_HANGUL_SYLLABLES:
- case UBLOCK_HANGUL_JAMO_EXTENDED_A:
- case UBLOCK_HANGUL_JAMO_EXTENDED_B:
- lang = LANG_KOREAN;
- break;
- case UBLOCK_BASIC_LATIN: // = 1, /*[0000]*/
- case UBLOCK_LATIN_1_SUPPLEMENT: // =2, /*[0080]*/
- case UBLOCK_LATIN_EXTENDED_A: // =3, /*[0100]*/
- case UBLOCK_LATIN_EXTENDED_B: // =4, /*[0180]*/
- case UBLOCK_LATIN_EXTENDED_ADDITIONAL: // =38, /*[1E00]*/
- lang = LANG_ENGLISH;
- break;
- case UBLOCK_CJK_RADICALS_SUPPLEMENT: //=58, /*[2E80]*/
- case UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION: //=61, /*[3000]*/
- case UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS: //=68, /*[3200]*/
- case UBLOCK_CJK_STROKES: // =130, /*[31C0]*/
- case UBLOCK_CJK_COMPATIBILITY: // =69, /*[3300]*/
- case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A: //=70, /*[3400]*/
- case UBLOCK_CJK_UNIFIED_IDEOGRAPHS: //=71, /*[4E00]*/
- case UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS: //=79, /*[F900]*/
- case UBLOCK_CJK_COMPATIBILITY_FORMS: //=83, /*[FE30]*/
- case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B : // =94, /*[20000]*/
- case UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT: // =95, /*[2F800]*/
- case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C: // =197, /*[2A700]*/
- case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D: // =209, /*[2B740]*/
- lang = LANG_CHINESS;
- break;
- default:
- DbgPrint("Detected unknown: %d\n", lang);
- lang = LANG_UNKNOWN;
- break;
- }
-
- return lang;
-}
-
-static char *ucol_toupper(const char *haystack)
-{
- UChar *_haystack;
- UChar *u_haystack;
- int haystack_len;
- UErrorCode status = U_ZERO_ERROR;
- int ret;
- char *utf8_ret;
-
- u_haystack = to_UTF16(haystack, &haystack_len);
- if (!u_haystack) {
- // Error will be printed by to_UTF16
- return NULL;
- }
-
- haystack_len = u_strToUpper(NULL, 0, u_haystack, -1, NULL, &status);
-
- _haystack = malloc(sizeof(*_haystack) * (haystack_len + 1));
- if (!_haystack) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- free(u_haystack);
- return NULL;
- }
-
- //ret = u_strFoldCase((UChar *)_haystack, haystack_len, (UChar *)haystack, -1, U_FOLD_CASE_DEFAULT, &status);
- status = U_ZERO_ERROR;
- ret = u_strToUpper(_haystack, haystack_len + 1, u_haystack, -1, NULL, &status);
- free(u_haystack);
- if (U_FAILURE(status)) {
- ErrPrint("upper: %s\n", u_errorName(status));
- free(_haystack);
- return NULL;
- }
-
- utf8_ret = to_UTF8(_haystack, &ret);
- free(_haystack);
-
- return utf8_ret;
-}
-
-HAPI int add_viewer_ucol_case_ncompare(const char *src, const char *dest, int len)
-{
- char *_src;
- char *_dest;
- int ret;
-
- if (!src || !dest || len <= 0) {
- return -EINVAL;
- }
-
- if (!s_info.coll) {
- ErrPrint("Fallback to strncasecmp\n");
- return strncasecmp(src, dest, len);
- }
-
- _src = ucol_toupper(src);
- if (!_src) {
- return -EFAULT;
- }
-
- _dest = ucol_toupper(dest);
- if (!_dest) {
- free(_src);
- return -EFAULT;
- }
-
- ret = add_viewer_ucol_ncompare(_src, _dest, len);
-
- free(_src);
- free(_dest);
- return ret;
-}
-
-HAPI int add_viewer_ucol_ncompare(const char *src, const char *dest, int len)
-{
- UChar *src_uni;
- UChar *dest_uni;
- UCollationResult res;
- int32_t dest_len;
- int32_t src_len;
- char *tmp;
-
- if (!src || !dest || len <= 0) {
- return -EINVAL;
- }
-
- if (!s_info.coll) {
- ErrPrint("Fallback to strcmp\n");
- return strncmp(src, dest, len);
- }
-
- tmp = malloc(len + 1);
- if (!tmp) {
- ErrPrint("Heap: Fail to malloc - %d \n", errno);
- return strncmp(src, dest, len);
- }
- strncpy(tmp, dest, len);
- tmp[len] = '\0';
-
- /* To get the ucs16 len */
- src_uni = to_UTF16(tmp, &len);
- free(tmp);
- if (!src_uni) {
- ErrPrint("Failed get utf16\n");
- return strncmp(src, dest, len);
- }
- free(src_uni);
-
- src_uni = to_UTF16(src, &src_len);
- if (!src_uni) {
- ErrPrint("SRC: Failed to convert to UTF16\n");
- return strncmp(src, dest, len);
- }
-
- dest_uni = to_UTF16(dest, &dest_len);
- if (!dest_uni) {
- ErrPrint("DEST: Failed to convert to UTF16\n");
- free(src_uni);
- return strncmp(src, dest, len);
- }
-
- switch (s_info.lang) {
- case LANG_JAPANESS:
- if (__isalpha(*src_uni) && !__isalpha(*dest_uni)) {
- res = UCOL_GREATER;
- } else if (!__isalpha(*src_uni) && __isalpha(*dest_uni)) {
- res = UCOL_LESS;
- } else {
- int src_lang;
- int dest_lang;
-
- src_lang = add_viewer_ucol_detect_lang(*src_uni);
- dest_lang = add_viewer_ucol_detect_lang(*dest_uni);
-
- if (src_lang == LANG_JAPANESS && dest_lang != LANG_JAPANESS) {
- res = UCOL_LESS;
- } else if (src_lang != LANG_JAPANESS && dest_lang == LANG_JAPANESS) {
- res = UCOL_GREATER;
- } else {
- res = ucol_strcoll(s_info.coll, (UChar *)src_uni, len, (UChar *)dest_uni, len);
- }
- }
- break;
- case LANG_KOREAN:
- if (__isalpha(*src_uni) && !__isalpha(*dest_uni)) {
- res = UCOL_GREATER;
- } else if (!__isalpha(*src_uni) && __isalpha(*dest_uni)) {
- res = UCOL_LESS;
- } else {
- int src_lang;
- int dest_lang;
-
- src_lang = add_viewer_ucol_detect_lang(*src_uni);
- dest_lang = add_viewer_ucol_detect_lang(*dest_uni);
-
- if (src_lang == LANG_KOREAN && dest_lang != LANG_KOREAN) {
- res = UCOL_LESS;
- } else if (src_lang != LANG_KOREAN && dest_lang == LANG_KOREAN) {
- res = UCOL_GREATER;
- } else {
- res = ucol_strcoll(s_info.coll, (UChar *)src_uni, len, (UChar *)dest_uni, len);
- }
- }
- break;
- case LANG_ENGLISH:
- default:
- /*
- if (__isalpha(*src_uni) && !__isalpha(*dest_uni)) {
- res = UCOL_LESS;
- } else if (!__isalpha(*src_uni) && __isalpha(*dest_uni)) {
- res = UCOL_GREATER;
- } else {
- */
- res = ucol_strcoll(s_info.coll, (UChar *)src_uni, len, (UChar *)dest_uni, len);
- /*
- }
- */
- }
-
- free(src_uni);
- free(dest_uni);
-
- switch (res) {
- case UCOL_LESS:
- return -1;
-
- case UCOL_EQUAL:
- return 0;
-
- case UCOL_GREATER:
- return 1;
-
- default:
- DbgPrint("%s ? %s\n", src, dest);
- return 0;
- }
-}
-
-HAPI int add_viewer_ucol_case_compare(const char *src, const char *dest)
-{
- char *_src;
- char *_dest;
- int ret;
-
- if (!src || !dest) {
- return -EINVAL;
- }
-
- if (!s_info.coll) {
- ErrPrint("Fallback to strcasecmp\n");
- return strcasecmp(src, dest);
- }
-
- _src = ucol_toupper(src);
- if (!_src) {
- return -EFAULT;
- }
-
- _dest = ucol_toupper(dest);
- if (!_dest) {
- free(_src);
- return -EFAULT;
- }
-
- ret = add_viewer_ucol_compare(_src, _dest);
- free(_src);
- free(_dest);
- return ret;
-}
-
-HAPI int add_viewer_ucol_compare(const char *src, const char *dest)
-{
- UChar *src_uni;
- UChar *dest_uni;
- UCollationResult res;
- int32_t dest_len = 0;
- int32_t src_len = 0;
- int len;
-
- if (!src || !dest) {
- return -EINVAL;
- }
-
- if (!s_info.coll) {
- ErrPrint("Fallback to strcmp\n");
- return strcmp(src, dest);
- }
-
- src_uni = to_UTF16(src, &src_len);
- if (!src_uni) {
- ErrPrint("SRC: Failed to convert to UTF16\n");
- return strcmp(src, dest);
- }
-
- dest_uni = to_UTF16(dest, &dest_len);
- if (!dest_uni) {
- ErrPrint("DEST: Failed to convert to UTF16\n");
- free(src_uni);
- return strcmp(src, dest);
- }
-
- len = src_len > dest_len ? dest_len : src_len;
-
- switch (s_info.lang) {
- case LANG_JAPANESS:
- if (__isalpha(*src_uni) && !__isalpha(*dest_uni)) {
- res = UCOL_GREATER;
- } else if (!__isalpha(*src_uni) && __isalpha(*dest_uni)) {
- res = UCOL_LESS;
- } else {
- int src_lang;
- int dest_lang;
-
- src_lang = add_viewer_ucol_detect_lang(*src_uni);
- dest_lang = add_viewer_ucol_detect_lang(*dest_uni);
-
- if (src_lang == LANG_JAPANESS && dest_lang != LANG_JAPANESS) {
- res = UCOL_LESS;
- } else if (src_lang != LANG_JAPANESS && dest_lang == LANG_JAPANESS) {
- res = UCOL_GREATER;
- } else {
- res = ucol_strcoll(s_info.coll, (UChar *)src_uni, len, (UChar *)dest_uni, len);
- }
- }
- break;
- case LANG_KOREAN:
- if (__isalpha(*src_uni) && !__isalpha(*dest_uni)) {
- res = UCOL_GREATER;
- } else if (!__isalpha(*src_uni) && __isalpha(*dest_uni)) {
- res = UCOL_LESS;
- } else {
- int src_lang;
- int dest_lang;
-
- src_lang = add_viewer_ucol_detect_lang(*src_uni);
- dest_lang = add_viewer_ucol_detect_lang(*dest_uni);
-
- if (src_lang == LANG_KOREAN && dest_lang != LANG_KOREAN) {
- res = UCOL_LESS;
- } else if (src_lang != LANG_KOREAN && dest_lang == LANG_KOREAN) {
- res = UCOL_GREATER;
- } else {
- res = ucol_strcoll(s_info.coll, (UChar *)src_uni, len, (UChar *)dest_uni, len);
- }
- }
- break;
- case LANG_ENGLISH:
- default:
- if (__isalpha(*src_uni) && !__isalpha(*dest_uni)) {
- res = UCOL_LESS;
- } else if (!__isalpha(*src_uni) && __isalpha(*dest_uni)) {
- res = UCOL_GREATER;
- } else {
- res = ucol_strcoll(s_info.coll, (UChar *)src_uni, len, (UChar *)dest_uni, len);
- }
- }
-
- free(src_uni);
- free(dest_uni);
-
- switch (res) {
- case UCOL_LESS:
- return -1;
-
- case UCOL_EQUAL:
- if (src_len > dest_len) {
- return 1;
- } else if (src_len == dest_len) {
- return 0;
- }
-
- return -1;
-
- case UCOL_GREATER:
- return 1;
-
- default:
- DbgPrint("%s ? %s\n", src, dest);
- return 0;
- }
-}
-
-HAPI int add_viewer_ucol_case_search(const char *haystack, const char *needle)
-{
- char *_haystack;
- char *_needle;
- const char *ptr;
- int len;
- int needle_len;
- int idx;
- int ret;
-
- if (!haystack || !needle) {
- return -EINVAL;
- }
-
- if (!s_info.coll) {
- ErrPrint("Fallback to strcasestr\n");
- ptr = strcasestr(haystack, needle);
- if (!ptr) {
- return -ENOENT;
- }
-
- return (int)(ptr - haystack);
- }
-
- _haystack = ucol_toupper(haystack);
- if (!_haystack) {
- // Error will be printed by ucol_toupper
- return -EFAULT;
- }
-
- _needle = ucol_toupper(needle);
- if (!_needle) {
- // Error will be printed by ucol_toupper
- free(_haystack);
- return -EFAULT;
- }
-
- needle_len = strlen(_needle);
- len = strlen(_haystack) - needle_len;
- if (len == 0) {
- ret = add_viewer_ucol_compare(_haystack, _needle);
- free(_needle);
- free(_haystack);
- return ret == 0 ? 0 : -ENOENT;
- } else if (len < 0) {
- free(_haystack);
- free(_needle);
- return -ENOENT;
- }
-
- for (idx = 0; idx <= len; ) {
- ret = add_viewer_ucol_ncompare(_haystack + idx, _needle, needle_len);
- if (ret == 0) {
- free(_haystack);
- free(_needle);
- return idx;
- }
-
- idx += add_viewer_util_get_utf8_len(_haystack[idx]);
- }
-
- free(_haystack);
- free(_needle);
- return -ENOENT;
-}
-
-HAPI int add_viewer_ucol_search(const char *haystack, const char *needle)
-{
- int ret;
- int len;
- const char *ptr;
- int idx;
- int needle_len;
-
- if (!haystack || !needle) {
- return -EINVAL;
- }
-
- if (!s_info.coll) {
- ErrPrint("Fallback to strstr\n");
- ptr = strstr(haystack, needle);
- if (!ptr) {
- return -ENOENT;
- }
-
- return (int)(ptr - haystack);
- }
-
- needle_len = strlen(needle);
- len = strlen(haystack) - needle_len;
- if (len == 0) {
- return add_viewer_ucol_compare(haystack, needle) == 0 ? 0 : -ENOENT;
- } else if (len < 0) {
- return -ENOENT;
- }
-
- for (idx = 0; idx < len;) {
- ret = add_viewer_ucol_ncompare(haystack + idx, needle, needle_len);
- if (ret == 0) {
- return idx;
- }
-
- idx += add_viewer_util_get_utf8_len(haystack[idx]);
- }
-
- return -ENOENT;
-}
-
-HAPI int add_viewer_ucol_fini(void)
-{
- if (s_info.coll) {
- ucol_close(s_info.coll);
- s_info.coll = NULL;
- }
- return 0;
-}
-
-HAPI const int add_viewer_ucol_current_lang(void)
-{
- return s_info.lang;
-}
-
-/* End of a file */
diff --git a/src/add-viewer_util.c b/src/add-viewer_util.c
deleted file mode 100755
index 1c0aca2..0000000
--- a/src/add-viewer_util.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-#include <Elementary.h>
-#include <dlog.h>
-#include <device/display.h>
-#include <appsvc.h>
-#include <widget_service.h>
-#include <app.h>
-#if defined(USE_APP_MANAGER)
-#include <app_manager.h>
-#endif
-
-
-#include "add-viewer_debug.h"
-#include "add-viewer_package.h"
-#include "add-viewer_util.h"
-#include "add-viewer_ucol.h"
-
-#if defined(LOG_TAG)
-#undef LOG_TAG
-#endif
-#define LOG_TAG "ADD_VIEWER"
-
-#define MATCH_COLOR "#ee00eeff"
-
-static struct {
- char *setup;
- struct {
- int r;
- int g;
- int b;
- int a;
- } matched_color;
-} s_info = {
- .setup = NULL,
- .matched_color = {
- .r = 0xee,
- .g = 0x00,
- .b = 0xee,
- .a = 0xff,
- },
-};
-
-struct result_data {
- struct add_viewer_package *package;
- int size;
-};
-
-extern int appsvc_allow_transient_app(bundle *b, Ecore_X_Window id);
-
-#if defined(USE_APP_MANAGER)
-static void app_ctx_cb(app_context_h app_context, app_context_event_e event, void *user_data)
-{
- char *pkgname = NULL;
-
- if (app_context_get_app_id(app_context, &pkgname) != APP_MANAGER_ERROR_NONE) {
- ErrPrint("Failed to get pkgname\n");
- return;
- }
-
- if (!pkgname) {
- ErrPrint("Failed to get package name\n");
- return;
- }
-
- switch (event) {
- case APP_CONTEXT_EVENT_LAUNCHED:
- break;
- case APP_CONTEXT_EVENT_TERMINATED:
- /*!
- * \note
- * This must be called later than response callback
- */
- if (s_info.setup && !strcmp(pkgname, s_info.setup)) {
- ErrPrint("Setup app is terminated [%s]\n", s_info.setup);
- free(s_info.setup);
- s_info.setup = NULL;
- elm_exit();
- }
- break;
- default:
- break;
- }
-
- free(pkgname);
- return;
-}
-#else
-#include <aul.h>
-
-extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data);
-
-int _dead_cb(int pid, void *data)
-{
- char pkgname[256];
-
- if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
- ErrPrint("Failed to get pkgname for %d\n", pid);
- return 0;
- }
-
- if (s_info.setup && !strcmp(pkgname, s_info.setup)) {
- ErrPrint("Setup app is terminated [%s]\n", s_info.setup);
- free(s_info.setup);
- s_info.setup = NULL;
- elm_exit();
- }
-
- return 0;
-}
-#endif
-
-HAPI int add_viewer_util_init(void)
-{
-#if defined(USE_APP_MANAGER)
- app_manager_set_app_context_event_cb(app_ctx_cb, NULL);
-#else
- aul_listen_app_dead_signal(_dead_cb, NULL);
-#endif
- return 0;
-}
-
-HAPI int add_viewer_util_fini(void)
-{
-#if defined(USE_APP_MANAGER)
- app_manager_unset_app_context_event_cb();
-#endif
- return 0;
-}
-
-static void response_callback(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
-{
- struct result_data *res_data = user_data;
- char *content_info = NULL;
-
- if (s_info.setup) {
- free(s_info.setup);
- s_info.setup = NULL;
- }
-
- if (result != APP_CONTROL_RESULT_SUCCEEDED) {
- ErrPrint("Operation is canceled: %d\n", result);
- elm_exit();
- return;
- }
-
- app_control_get_extra_data(reply, EXTRA_KEY_CONTENT_INFO , &content_info);
-
- /**
- * \TODO
- * Use this content_info to add a new widget
- */
-
- free(res_data);
-
- /**
- * If the box is successfully added, do we need to terminate this?
- */
-}
-
-HAPI int add_viewer_util_add_to_home(struct add_viewer_package *package, int size, int use_noti)
-{
- int ret = -EINVAL;
- char *setup;
-
- setup = widget_service_get_app_id_of_setup_app(add_viewer_package_list_pkgname(package));
- if (setup) {
- app_control_h service;
- struct result_data *res_data;
-
- if (s_info.setup) {
- ErrPrint("Setup is already launched: %s\n", s_info.setup);
- free(s_info.setup);
- s_info.setup = NULL;
- }
-
- DbgPrint("Setup App: %s\n", setup);
-
- res_data = malloc(sizeof(*res_data));
- if (!res_data) {
- free(setup);
- return -ENOMEM;
- }
-
- res_data->package = package;
- res_data->size = size;
-
- ret = app_control_create(&service);
- if (ret != APP_CONTROL_ERROR_NONE) {
- free(setup);
- free(res_data);
- return -EFAULT;
- }
-
- ret = app_control_set_app_id(service, setup);
- if (ret != APP_CONTROL_ERROR_NONE) {
- free(setup);
- free(res_data);
- app_control_destroy(service);
- return -EFAULT;
- }
-
- ret = app_control_set_operation(service, SERVICE_OPERATION_WIDGET_SETUP);
- if (ret != APP_CONTROL_ERROR_NONE) {
- free(setup);
- free(res_data);
- app_control_destroy(service);
- return -EFAULT;
- }
-
- ret = app_control_send_launch_request(service, response_callback, res_data);
-
- app_control_destroy(service);
-
- if (ret != APP_CONTROL_ERROR_NONE) {
- free(res_data);
- free(setup);
- } else {
- s_info.setup = setup;
- }
- } else {
- /**
- * \TODO
- * Create a new widget without content_info
- */
- }
-
- return ret;
-}
-
-HAPI int add_viewer_util_is_lcd_off(void)
-{
- display_state_e state;
-
- if (device_display_get_state(&state) != 0) {
- ErrPrint("Idle lock state is not valid\n");
- state = DISPLAY_STATE_NORMAL; /* UNLOCK */
- }
-
- return state == DISPLAY_STATE_SCREEN_OFF;
-}
-
-HAPI char *add_viewer_util_highlight_keyword(const char *name, const char *filter)
-{
- char *highlighted_name;
- int filter_len;
- int name_len;
- int target_idx = 0;
- int tag_len;
- int ret_len;
- const int amp_len = strlen("&amp;");
- const char *org_name = name;
-
- if (!name) {
- ErrPrint("Cannot get name");
- return NULL;
- }
-
- if (!filter) {
- ErrPrint("Cannot get filter");
- return NULL;
- }
-
- filter_len = strlen(filter);
- name_len = strlen(name);
- tag_len = strlen("<font color="MATCH_COLOR"></font>");
- ret_len = name_len + 1;
-
- highlighted_name = malloc(ret_len);
- if (!highlighted_name) {
- char err_buf[256] = { 0, };
- ErrPrint("Heap: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
- return NULL;
- }
-
- while (*name) {
- if (*name == '&') {
- char *tmp;
-
- ret_len += amp_len;
- tmp = realloc(highlighted_name, ret_len);
- if (!tmp) {
- ErrPrint("Heap: Fail to realloc - %d \n", errno);
- free(highlighted_name);
- return NULL;
- }
- highlighted_name = tmp;
-
- /*!
- * Manipulate tagging
- */
- strncpy(highlighted_name + target_idx, "&amp;", amp_len);
- target_idx += amp_len;
- name++;
- } else if ((name_len - (int)(name - org_name)) < filter_len) {
- int idx_len;
-
- idx_len = name_len - (int)(name - org_name);
-
- strncpy(highlighted_name + target_idx, name, idx_len);
- target_idx += idx_len;
- name += idx_len;
- } else if (!add_viewer_ucol_case_ncompare(name, filter, filter_len)) {
- char *tmp;
-
- ret_len += tag_len;
- tmp = realloc(highlighted_name, ret_len);
- if (!tmp) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Heap: %s\n", err_buf);
- free(highlighted_name);
- return NULL;
- }
- highlighted_name = tmp;
-
- /*!
- * Manipulate tagging
- */
- tmp = malloc(filter_len + 1);
- if (!tmp) {
- ErrPrint("Heap: Fail to malloc - %d \n", errno);
- free(highlighted_name);
- return NULL;
- }
- strncpy(tmp, name, filter_len); /* Keep original string */
- tmp[filter_len] = '\0';
-
- target_idx += snprintf(highlighted_name + target_idx, ret_len - target_idx,
- "<font color=#%02x%02x%02x%02x>%s</font>",
- s_info.matched_color.r,
- s_info.matched_color.g,
- s_info.matched_color.b,
- s_info.matched_color.a,
- tmp
- );
- free(tmp);
- name += filter_len;
- } else {
- int idx_len;
-
- idx_len = add_viewer_util_get_utf8_len(*name);
- strncpy(highlighted_name + target_idx, name, idx_len);
- target_idx += idx_len;
- name += idx_len;
- }
- }
-
- highlighted_name[target_idx] = '\0';
- return highlighted_name;
-}
-
-HAPI int add_viewer_util_get_utf8_len(char ch)
-{
- int idx_len;
- if ((ch & 0x80) == 0x00) {
- idx_len = 1;
- } else if ((ch & 0xE0) == 0xC0) {
- idx_len = 2;
- } else if ((ch & 0xF0) == 0xE0) {
- idx_len = 3;
- } else if ((ch & 0xFC) == 0xF8) {
- idx_len = 4;
- } else if ((ch & 0xFE) == 0xFC) {
- idx_len = 5;
- } else if ((ch & 0xFF) == 0xFE) {
- idx_len = 6;
- } else {
- idx_len = 1;
- }
-
- return idx_len;
-}
-
-/* End of a file */
diff --git a/src/apps/apps_animator.c b/src/apps/apps_animator.c
deleted file mode 100755
index 28d6997..0000000
--- a/src/apps/apps_animator.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_animator.h"
-#include "apps/apps_view.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_icon.h"
-#include "util.h"
-#include "log.h"
-
-#define ANIMATION_STOP_TIME 3.0
-
-static struct __animator_s {
- bool is_ongoing;
- Ecore_Timer *stop_timer;
- void(*stop_cb)(void);
-} s_info = {
- .is_ongoing = false,
- .stop_timer = NULL,
- .stop_cb = NULL,
-};
-
-static Eina_Bool __animation_time_over(void *data);
-static void __animation_stop(void);
-
-bool apps_animator_is_ongoing(void)
-{
- return s_info.is_ongoing;
-}
-
-void apps_animator_start(void(*stop_cb)(void))
-{
- if (s_info.is_ongoing) {
- apps_animator_stop();
- }
-
- s_info.is_ongoing = true;
- s_info.stop_cb = stop_cb;
-
-
- if (s_info.stop_timer != NULL) {
- ecore_timer_del(s_info.stop_timer);
- s_info.stop_timer = NULL;
- }
-
- s_info.stop_timer = ecore_timer_add(ANIMATION_STOP_TIME, __animation_time_over, NULL);
-}
-
-void apps_animator_complete(void)
-{
- ecore_timer_del(s_info.stop_timer);
- s_info.stop_timer = NULL;
-
- s_info.is_ongoing = false;
- s_info.stop_cb = NULL;
-}
-
-void apps_animator_stop(void)
-{
- ecore_timer_del(s_info.stop_timer);
- s_info.stop_timer = NULL;
-
- __animation_stop();
-}
-
-static Eina_Bool __animation_time_over(void *data)
-{
- _D("animation time over");
-
- s_info.stop_timer = NULL;
-
- __animation_stop();
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void __animation_stop(void)
-{
- if (s_info.stop_cb != NULL) {
- (*s_info.stop_cb)();
- }
-
- s_info.is_ongoing = false;
- s_info.stop_cb = NULL;
-}
diff --git a/src/apps/apps_callback_manager.c b/src/apps/apps_callback_manager.c
deleted file mode 100755
index 89983d2..0000000
--- a/src/apps/apps_callback_manager.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "log.h"
-#include "apps/apps_callback_manager.h"
-
-apps_callback_t *apps_callback_manager_new(void)
-{
- apps_callback_t *callback_stack = NULL;
- callback_stack = (apps_callback_t *)malloc(sizeof(apps_callback_t));
- callback_stack->cb_count = 0;
-
- return callback_stack;
-}
-
-void apps_callback_manager_free(apps_callback_t *callback_stack)
-{
- free(callback_stack);
-}
-
-bool apps_callback_manager_register_cb(apps_callback_t *cb_stack, void(*cb)(void *data))
-{
- int idx = 0;
-
- if (cb_stack == NULL) {
- _E("cb_stack is null");
- return false;
- }
-
- if (cb_stack->cb_count >= MAX_KEY_CB_CNT) {
- _E("cb stack is full");
- return false;
- }
-
- for (idx = 0; idx < cb_stack->cb_count; idx++) {
- if (cb == cb_stack->cb_list[idx]) {
- _E("%p cb is already registered", cb);
- return false;
- }
- }
- cb_stack->cb_list[cb_stack->cb_count] = cb;
- cb_stack->cb_count += 1;
-
- _D("current cb is %d", cb_stack->cb_count);
-
- return true;
-}
-
-void apps_callback_manager_deregister_cb(apps_callback_t *cb_stack, void(*cb)(void *data))
-{
- int idx = 0;
- int cur = 0;
-
- if (cb_stack == NULL) {
- _E("cb_stack is null");
- return ;
- }
-
- if (cb_stack->cb_count == 0) {
- _E("cb stack is empty");
- return ;
- }
-
- for (idx = 0; idx < cb_stack->cb_count; idx++) {
- if (cb == cb_stack->cb_list[idx]) {
- cb_stack->cb_list[idx] = NULL;
- break;
- }
- }
-
- if (idx == cb_stack->cb_count) {
- _E("%p cb is not found", cb);
- return ;
- }
-
- for (cur = idx + 1; cur < cb_stack->cb_count; cur++) {
- cb_stack->cb_list[cur - 1] = cb_stack->cb_list[cur];
- cb_stack->cb_list[cur] = NULL;
- }
-
- cb_stack->cb_count -= 1;
-
- _D("current cb is %d", cb_stack->cb_count);
-}
-
-void apps_callback_manager_execute_cb(apps_callback_t *cb_stack, void *data)
-{
- int idx = 0;
-
- if (cb_stack == NULL) {
- _D("cb_stack is null");
- return ;
- }
-
- for (idx = 0; idx < cb_stack->cb_count; idx++) {
- if (cb_stack->cb_list != NULL) {
- (*cb_stack->cb_list[idx])(data);
- }
- }
-}
diff --git a/src/apps/apps_conf.c b/src/apps/apps_conf.c
deleted file mode 100755
index bf2ed22..0000000
--- a/src/apps/apps_conf.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_conf.h"
-
-const COLOR DARK_BG = { 0, 0, 0, 255 };
-const COLOR TRANCEPARENT_BG = { 0, 0, 0, 0 };
-const COLOR INDICATOR_UNIT_FOCUS = { 255, 255, 255, 255 };
-const COLOR INDICATOR_UNIT_UNFOCUS = { 255, 255, 255, 75 };
-const COLOR ICON_DEFAULT = { 255, 255, 255, 255 };
-const COLOR ICON_DIM = { 255, 255, 255, 127 };
-const char *FONT_DEFAULT = "<font_size=%d><color=#FFFFFFFF><shadow_color=#000000FF>%s</shadow_color></color></font_size>";
diff --git a/src/apps/apps_data_app_info.c b/src/apps/apps_data_app_info.c
deleted file mode 100755
index 8d633ce..0000000
--- a/src/apps/apps_data_app_info.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include "log.h"
-#include "util.h"
-#include "apps/apps_data.h"
-
-void apps_data_app_info_free_item(APP_INFO *item)
-{
- if(item == NULL) {
- _D("item is already null");
- return ;
- }
-
- free(item->app_id);
- item->app_id = NULL;
-
- free(item->pkg_id);
- item->pkg_id = NULL;
-
- free(item->label);
- item->label = NULL;
-
- free(item->icon_path);
- item->icon_path = NULL;
-
- free(item);
- item = NULL;
-}
-
-void apps_data_app_info_free_list(Eina_List *list)
-{
- APP_INFO *item;
- if (list == NULL) {
- _D("list is already null");
- return ;
- }
-
- EINA_LIST_FREE(list, item) {
- apps_data_app_info_free_item(item);
- }
- list = NULL;
-}
diff --git a/src/apps/apps_data_db.c b/src/apps/apps_data_db.c
deleted file mode 100755
index 8bce374..0000000
--- a/src/apps/apps_data_db.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <tizen.h>
-#include <sqlite3.h>
-
-#include "apps/apps_data_db.h"
-#include "apps/apps_conf.h"
-#include "util.h"
-#include "log.h"
-
-static struct __data_db {
- sqlite3 *db_connector;
-} s_info = {
- .db_connector = NULL,
-};
-
-#define APPS_DB_NAME ".apps-data.db"
-#define QUERY_MAXLEN 4096
-
-enum {
- COL_ID = 0,
- COL_APPLICATION_ID,
- COL_PACKAGE_ID,
- COL_LABEL,
- COL_ICON_PATH,
- COL_INDEX,
-};
-
-enum {
- COL_KEY = 1,
- COL_VALUE,
-};
-
-#define CREATE_APPS_ICON_TABLE "create table if not exists apps_icon(\
- id INTEGER PRIMARY KEY AUTOINCREMENT,\
- appId TEXT,\
- pkgId TEXT,\
- label TEXT,\
- iconPath TEXT,\
- iconIndex INTEGER);"
-
-#define CREATE_APPS_DATA_TABLE "create table if not exists apps_data(\
- id INTEGER PRIMARY KEY AUTOINCREMENT,\
- key TEXT,\
- value TEXT);"
-
-#define UPDATE_APPS_ICON_TABLE "UPDATE apps_icon set \
- appId='%s',\
- pkgId='%s',\
- label='%s',\
- iconPath='%s',\
- iconIndex=%d WHERE id = %d"
-
-#define UPDATE_APPS_DATA_TABLE "UPDATE apps_data set \
- value='%s' WHERE key = '%s'"
-
-#define INSERT_APPS_ICON_TABLE "INSERT into apps_icon \
- (appId, pkgId, label, iconPath, iconIndex)\
- VALUES('%s','%s','%s','%s',%d)"
-
-#define INSERT_APPS_DATA_TABLE "INSERT into apps_data \
- (key, value)\
- VALUES('%s','%s')"
-
-#define SELECT_ITEM_ICON "SELECT * FROM apps_icon;"
-#define SELECT_ITEM_DATA "SELECT * FROM apps_data WHERE key = '%s';"
-
-static bool __init_db_connector(void);
-static bool __create_db_file(void);
-static bool __open_db_connector(void);
-static void __close_db_connector(void);
-static int __insert_data_value(char *key, char *value);
-static bool __update_data_value(char *key, char *value);
-
-ERROR_E apps_data_db_manager_init(void)
-{
- _D("%s", __func__);
-
- if (!__init_db_connector() || s_info.db_connector == NULL) {
- _E("failed to initialize db");
- goto __fail;
- }
-
- return ERROR_NONE;
-
-__fail:
- return ERROR_FAILED;
-}
-
-void apps_data_db_manager_fini(void)
-{
- __close_db_connector();
-}
-
-bool apps_data_db_icon_update(APP_INFO *item)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!__open_db_connector()) {
- return false;
- }
-
- snprintf(query, QUERY_MAXLEN, UPDATE_APPS_ICON_TABLE,
- item->app_id,
- item->pkg_id,
- item->label,
- item->icon_path,
- item->index,
- item->db_id);
- int ret = sqlite3_prepare(s_info.db_connector, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", query, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return false;
- }
-
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
- __close_db_connector();
-
- return true;
-}
-
-int apps_data_db_icon_insert(APP_INFO *item)
-{
- int id = INVALID_VALUE;
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!__open_db_connector()) {
- return INVALID_VALUE;
- }
-
- snprintf(query, QUERY_MAXLEN, INSERT_APPS_ICON_TABLE,
- item->app_id,
- item->pkg_id,
- item->label,
- item->icon_path,
- item->index);
-
- int ret = sqlite3_prepare(s_info.db_connector, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", query, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return INVALID_VALUE;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
- id = (int)sqlite3_last_insert_rowid(s_info.db_connector);
-
- __close_db_connector();
- return id;
-}
-
-bool apps_data_db_icon_delete(APP_INFO *item)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!__open_db_connector())
- return false;
-
- snprintf(query, QUERY_MAXLEN, "DELETE FROM apps_icon WHERE id=%d", item->db_id);
- int ret = sqlite3_prepare(s_info.db_connector, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", query, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return false;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
-
- __close_db_connector();
- return true;
-}
-
-bool apps_data_db_icon_delete_all(void)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!__open_db_connector())
- return false;
-
- snprintf(query, QUERY_MAXLEN, "DELETE FROM apps_icon");
- int ret = sqlite3_prepare(s_info.db_connector, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", query, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return false;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
-
- __close_db_connector();
- return true;
-}
-
-Eina_List *apps_data_db_get_icon_list(void)
-{
- Eina_List *list = NULL;
- sqlite3_stmt *stmt;
- const char *str = NULL;
-
- if (!__open_db_connector())
- return NULL;
-
- int ret = sqlite3_prepare_v2(s_info.db_connector, SELECT_ITEM_ICON, strlen(SELECT_ITEM_ICON), &stmt, NULL);
-
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", SELECT_ITEM_ICON, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return NULL;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- APP_INFO *item = (APP_INFO *)malloc(sizeof(APP_INFO));
- memset(item, 0, sizeof(APP_INFO));
-
- item->db_id = sqlite3_column_int(stmt, COL_ID);
-
- str = (const char *) sqlite3_column_text(stmt, COL_APPLICATION_ID);
- item->app_id = (!str || !strlen(str)) ? NULL : strdup(str);
-
- str = (const char *) sqlite3_column_text(stmt, COL_PACKAGE_ID);
- item->pkg_id = (!str || !strlen(str)) ? NULL : strdup(str);
-
- str = (const char *) sqlite3_column_text(stmt, COL_LABEL);
- item->label = (!str) ? NULL : strdup(str);
-
- str = (const char *)sqlite3_column_text(stmt, COL_ICON_PATH);
- item->icon_path = (!str || !strlen(str)) ? NULL : strdup(str);
-
- item->index = sqlite3_column_int(stmt, COL_INDEX);
-
- list = eina_list_append(list, item);
- }
- sqlite3_finalize(stmt);
- __close_db_connector();
-
- return list;
-}
-
-char *apps_data_db_get_data(char *key)
-{
- char *value = NULL;
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- const char *str = NULL;
-
- if (!__open_db_connector())
- return false;
-
- snprintf(query, QUERY_MAXLEN, SELECT_ITEM_DATA, key);
-
- int ret = sqlite3_prepare_v2(s_info.db_connector, query, QUERY_MAXLEN, &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", SELECT_ITEM_DATA, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return NULL;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- str = (const char *) sqlite3_column_text(stmt, COL_VALUE);
- value = (!str || !strlen(str)) ? NULL : strdup(str);
- }
- sqlite3_finalize(stmt);
- __close_db_connector();
-
- return value;
-}
-
-void apps_data_db_set_data(char *key, char *value)
-{
- char *v = NULL;
- if (key == NULL || value == NULL) {
- _E("key or value is null");
- return ;
- }
-
- v = apps_data_db_get_data(key);
- if (v != NULL) {
- free(v);
- __update_data_value(key, value);
- return ;
- }
-
- __insert_data_value(key, value);
- free(v);
-}
-
-static bool __init_db_connector(void)
-{
- _D("%s", __func__);
-
- const char *db_path = util_get_data_file_path(APPS_DB_NAME);
-
- if (s_info.db_connector != NULL) {
- _E("db connector is not null");
- return true;
- }
-
- if (ecore_file_exists(db_path) == EINA_TRUE) {
- _D("db file exist");
- return __open_db_connector();
- }
-
- return __create_db_file();
-}
-
-static bool __create_db_file(void)
-{
- char *errMsg = NULL;
- int ret = -1;
- const char *db_path = util_get_data_file_path(APPS_DB_NAME);
-
- ret = sqlite3_open(db_path, &s_info.db_connector);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%d] : path [%s]", ret, db_path);
- return false;
- }
- ret = sqlite3_exec(s_info.db_connector, "PRAGMA journal_mode = PERSIST",
- NULL, NULL, &errMsg);
- if (ret != SQLITE_OK) {
- _E("SQL error(%d) : %s", ret, errMsg);
- sqlite3_free(errMsg);
- return false;
- }
-
- ret = sqlite3_exec(s_info.db_connector, CREATE_APPS_ICON_TABLE, NULL, NULL, &errMsg);
- if (ret != SQLITE_OK) {
- LOGE("SQL error(%d) : %s", ret, errMsg);
- sqlite3_free(errMsg);
- return false;
- }
-
- ret = sqlite3_exec(s_info.db_connector, CREATE_APPS_DATA_TABLE, NULL, NULL, &errMsg);
- if (ret != SQLITE_OK) {
- LOGE("SQL error(%d) : %s", ret, errMsg);
- sqlite3_free(errMsg);
- return false;
- }
-
- return true;
-}
-
-static bool __open_db_connector(void)
-{
- int ret = -1;
- const char *db_path = util_get_data_file_path(APPS_DB_NAME);
-
- ret = sqlite3_open(db_path, &s_info.db_connector);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%d] : path [%s]", ret, util_get_data_file_path(APPS_DB_NAME));
- return false;
- }
-
- return true;
-}
-
-static void __close_db_connector(void)
-{
- if (s_info.db_connector != NULL) {
- sqlite3_exec(s_info.db_connector, "COMMIT TRANSACTION", NULL, NULL, NULL);
- sqlite3_close(s_info.db_connector);
- s_info.db_connector = NULL;
- }
-}
-
-static bool __update_data_value(char *key, char *value)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!__open_db_connector()) {
- return false;
- }
-
- snprintf(query, QUERY_MAXLEN, UPDATE_APPS_DATA_TABLE, value, key);
- int ret = sqlite3_prepare(s_info.db_connector, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", query, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return false;
- }
-
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
- __close_db_connector();
-
- return true;
-}
-
-static int __insert_data_value(char *key, char *value)
-{
- int idx = INVALID_VALUE;
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!__open_db_connector()) {
- return INVALID_VALUE;
- }
-
- snprintf(query, QUERY_MAXLEN, INSERT_APPS_DATA_TABLE, key, value);
-
- int ret = sqlite3_prepare(s_info.db_connector, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite error : [%s,%s]", query, sqlite3_errmsg(s_info.db_connector));
- __close_db_connector();
- return INVALID_VALUE;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
- idx = (int)sqlite3_last_insert_rowid(s_info.db_connector);
-
- __close_db_connector();
- return idx;
-}
diff --git a/src/apps/apps_data_manager.c b/src/apps/apps_data_manager.c
deleted file mode 100755
index c449669..0000000
--- a/src/apps/apps_data_manager.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-
-#include "log.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view.h"
-#include "apps/apps_data.h"
-#include "apps/apps_data_app_info.h"
-#include "apps/apps_data_db.h"
-#include "apps/apps_data_xml.h"
-#include "apps/apps_data_package_manager.h"
-#include "apps/apps_callback_manager.h"
-#include "apps/apps_lang_changed_handler.h"
-
-static struct __data_manager{
- Eina_List *app_list;
- apps_callback_t *app_info_cb_stack;
-} s_info = {
- .app_list = NULL,
- .app_info_cb_stack = NULL,
-};
-
-static void __append_initial_data(Eina_List *list);
-static void __add_data_index(Eina_List *list);
-static void __add_data_fixed_index(Eina_List *list);
-static void __sort_app_data(void);
-static int __compare_app_data(const void *a, const void *b);
-static Eina_List *__rearrange_index(Eina_List *list);
-static void __icon_db_update(void);
-static void __icon_label_update_cb(void *data);
-
-static void __data_print();
-
-ERROR_E apps_data_init(void)
-{
- Eina_List *db_list = NULL;
- Eina_List *pkg_list = NULL;
- Eina_List *xml_list = NULL;
-
- _D("%s", __func__);
-
- s_info.app_info_cb_stack = apps_callback_manager_new();
- if (s_info.app_info_cb_stack == NULL) {
- _E("Failed to allocate memory for back key cb stack");
- return ERROR_FAILED;
- }
-
- if (apps_data_package_manager_init() != ERROR_NONE) {
- _E("failed to initialize package manager");
- return ERROR_FAILED;
- }
-
- pkg_list = apps_data_package_manager_get_list();
- if (pkg_list == NULL) {
- _E("failed to get package list");
- apps_data_package_manager_fini();
- return ERROR_FAILED;
- }
-
- __append_initial_data(pkg_list);
- __data_print();
-
- if (apps_data_db_manager_init() != ERROR_NONE) {
- _E("failed to initialize db manager");
- return ERROR_FAILED;
- }
-
- db_list = apps_data_db_get_icon_list();
- if (db_list != NULL) {
- _D("add icon index by db data");
- __add_data_index(db_list);
- }
- __data_print();
-
- xml_list = apps_data_xml_get_data_list();
- if (xml_list != NULL) {
- _D("add fixed index by xml data");
- __add_data_fixed_index(xml_list);
- }
- __sort_app_data();
- __data_print();
-
- apps_lang_changed_handler_register_label_update_cb(__icon_label_update_cb);
- return ERROR_NONE;
-}
-
-void apps_data_fini(void)
-{
- _D("%s", __func__);
-
- apps_lang_changed_handler_register_label_update_cb(__icon_label_update_cb);
- apps_data_db_manager_fini();
- apps_data_package_manager_fini();
-}
-
-Eina_List* apps_data_get_applist(void)
-{
- return s_info.app_list;
-}
-
-void apps_data_insert_appinfo(APP_INFO *item)
-{
- _D("%s", __func__);
-
- if (item == NULL) {
- _E("item is null");
- return ;
- }
-
- s_info.app_list = eina_list_append(s_info.app_list, item);
- item->index = eina_list_count(s_info.app_list) - 1;
- item->db_id = apps_data_db_icon_insert(item);
-
- __sort_app_data();
-}
-
-void apps_data_delete_appinfo_by_pkg_id(const char *pkg_id)
-{
- _D("%s", __func__);
-
- Eina_List *find_list = NULL;
- APP_INFO *item = NULL;
- Eina_List *delete_list = NULL;
-
- if (s_info.app_list == NULL) {
- _D("app list is NULL");
- return;
- }
-
- EINA_LIST_FOREACH(s_info.app_list, find_list, item) {
- if (!strcmp(pkg_id, item->pkg_id)){
- delete_list = eina_list_append(delete_list,item);
- }
- }
-
- find_list = NULL;
- item = NULL;
- EINA_LIST_FOREACH(delete_list, find_list, item) {
- s_info.app_list = eina_list_remove(s_info.app_list, item);
- apps_data_db_icon_delete(item);
- apps_data_app_info_free_item(item);
- }
- eina_list_free(delete_list);
-
- __sort_app_data();
-}
-
-int apps_data_get_focus_pos(void)
-{
- int idx = 0;
- char *value = apps_data_db_get_data(KEY_FOCUS_POS);
- if (value == NULL) {
- goto __init_value;
- }
-
- idx = atoi(value);
- free(value);
-
- if (idx < 0) {
- goto __init_value;
- }
-
- return idx;
-
-__init_value:
- apps_data_set_focus_pos(0);
- return 0;
-}
-
-void apps_data_set_focus_pos(int idx)
-{
- char value[10];
- snprintf(value, sizeof(value), "%d", idx);
-
- apps_data_db_set_data(KEY_FOCUS_POS, value);
-}
-
-int apps_data_get_focus_page(void)
-{
- int idx = 0;
- char *value = apps_data_db_get_data(KEY_FOCUS_PAGE);
- if (value == NULL) {
- goto __init_value;
- }
- idx = atoi(value);
- free(value);
-
- if (idx < 0) {
- goto __init_value;
- }
-
- return idx;
-__init_value:
- apps_data_set_focus_page(0);
- return 0;
-}
-
-void apps_data_set_focus_page(int idx)
-{
- char value[10];
- snprintf(value, sizeof(value), "%d", idx);
-
- apps_data_db_set_data(KEY_FOCUS_PAGE, value);
-}
-
-int apps_data_get_list_count(void)
-{
- return eina_list_count(s_info.app_list);
-}
-
-APP_INFO *apps_data_get_nth_app_info(int idx)
-{
- return eina_list_nth(s_info.app_list, idx);
-}
-
-bool apps_data_register_data_changed_cb(void(*changed_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.app_info_cb_stack, changed_cb);
-
- return ret;
-}
-
-void apps_data_deregister_data_changed_cb(void(*changed_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.app_info_cb_stack, changed_cb);
-}
-
-void apps_data_update_list_order(void)
-{
- __sort_app_data();
-}
-
-static void __append_initial_data(Eina_List *list)
-{
- Eina_List *find_list = NULL;
- APP_INFO *find_item = NULL;
-
- EINA_LIST_FOREACH(list, find_list, find_item) {
- s_info.app_list = eina_list_append(s_info.app_list, find_item);
- find_item->index = INVALID_VALUE;
- }
-}
-
-static void __add_data_index(Eina_List *list)
-{
- Eina_List *list_i = NULL, *list_j = NULL;
- APP_INFO *item_i = NULL, *item_j = NULL;
-
- EINA_LIST_FOREACH(list, list_i, item_i) {
- list_j = NULL;
- item_j = NULL;
- EINA_LIST_FOREACH(s_info.app_list, list_j, item_j) {
- if (!strcmp(item_j->app_id, item_i->app_id)) {
- item_j->index = item_i->index;
- break;
- }
- }
- }
-}
-
-static void __add_data_fixed_index(Eina_List *list)
-{
- Eina_List *list_i = NULL, *list_j = NULL;
- APP_INFO *item_i = NULL, *item_j = NULL;
- int stack[2048];
- int top = 0;
- memset(stack, 0, sizeof(int)*2048);
-
- EINA_LIST_FOREACH(list, list_i, item_i) {
- list_j = NULL;
- item_j = NULL;
-
- int idx;
- bool exist = false;
- for (idx = 0; idx < top; idx++) {
- if (stack[idx] == item_i->primary_index) {
- exist = true;
- break;
- }
- }
- if (exist == true)
- continue;
-
- EINA_LIST_FOREACH(s_info.app_list, list_j, item_j) {
- if (!strcmp(item_i->app_id, item_j->app_id)) {
- item_j->primary_index = item_i->primary_index;
- if (top < 2047) {
- stack[++top] = item_j->primary_index;
- }
- break;
- }
- }
- }
-}
-
-static Eina_List *__rearrange_index(Eina_List *list)
-{
- int idx = 0;
- Eina_List *find_list = NULL;
- APP_INFO *find_item = NULL;
-
- list = eina_list_sort(list, eina_list_count(list), __compare_app_data);
-
- idx = 0;
- EINA_LIST_FOREACH(list, find_list, find_item) {
- find_item->index = idx;
- idx += 1;
- }
-
- return list;
-}
-
-static void __sort_app_data(void)
-{
- Eina_List *primary_list = NULL;
- Eina_List *normal_list = NULL;
- Eina_List *find_list = NULL;
- APP_INFO *find_item = NULL;
- APP_INFO *primary_item = NULL;
- APP_INFO *normal_item = NULL;
- int idx = 0, primary_idx = 0, normal_idx = 0;
- int primary_count = 0, normal_count = 0;
-
- normal_list = __rearrange_index(normal_list);
- primary_list = __rearrange_index(primary_list);
-
- EINA_LIST_FOREACH(s_info.app_list, find_list, find_item) {
- if (find_item->primary_index == INVALID_VALUE) {
- normal_list = eina_list_append(normal_list, find_item);
- } else {
- primary_list = eina_list_append(primary_list, find_item);
- }
- }
- normal_count = eina_list_count(normal_list);
- primary_count = eina_list_count(primary_list);
-
- s_info.app_list = eina_list_free(s_info.app_list);
-
- idx = 0;
- primary_idx = 0, normal_idx = 0;
- while (primary_idx < primary_count && normal_idx < normal_count) {
- primary_item = eina_list_nth(primary_list, primary_idx);
- normal_item = eina_list_nth(normal_list, normal_idx);
-
- if (idx == primary_item->primary_index) {
- s_info.app_list = eina_list_append(s_info.app_list, primary_item);
- idx += 1;
- primary_idx += 1;
- continue;
- }
-
- s_info.app_list = eina_list_append(s_info.app_list, normal_item);
- idx += 1;
- normal_idx += 1;
- }
-
- while (primary_idx < primary_count) {
- primary_item = eina_list_nth(primary_list, primary_idx);
- s_info.app_list = eina_list_append(s_info.app_list, primary_item);
- primary_idx += 1;
- }
- while (normal_idx < normal_count) {
- normal_item = eina_list_nth(normal_list, normal_idx);
- s_info.app_list = eina_list_append(s_info.app_list, normal_item);
- normal_idx += 1;
- }
-
- s_info.app_list = __rearrange_index(s_info.app_list);
-
- __icon_db_update();
- apps_callback_manager_execute_cb(s_info.app_info_cb_stack, NULL);
-}
-
-static int __compare_app_data(const void *a, const void *b)
-{
- APP_INFO *item1 = (APP_INFO *)a;
- APP_INFO *item2 = (APP_INFO *)b;
-
- if (item1->primary_index == item2->primary_index) {
- if (item1->index == item2->index) {
- return strcmp(item1->label, item2->label);
- }
-
- return item1->index < item2->index ? -1 : 1;
- }
-
- return item1->primary_index < item2->primary_index ? -1 : 1;
-}
-
-static void __icon_db_update(void)
-{
- Eina_List *list = NULL;
- APP_INFO *item = NULL;
-
- if (apps_data_db_icon_delete_all() == false) {
- _E("failed to delete icon db table");
- return ;
- }
-
- EINA_LIST_FOREACH(s_info.app_list, list, item) {
- apps_data_db_icon_insert(item);
- }
-}
-
-static void __icon_label_update_cb(void *data)
-{
- Eina_List *find_list = NULL;
- APP_INFO *item = NULL;
-
- EINA_LIST_FOREACH(s_info.app_list, find_list, item) {
- apps_data_package_manager_update_label(&item);
- }
-
- __icon_db_update();
- apps_callback_manager_execute_cb(s_info.app_info_cb_stack, NULL);
-}
-
-static void __data_print()
-{
- Eina_List *find_list = NULL;
- APP_INFO *item = NULL;
- int i = 0 ;
-
- if (s_info.app_list == NULL) {
- _D("app list is NULL");
- return;
- }
-
- _D("================================= ");
- EINA_LIST_FOREACH(s_info.app_list, find_list, item) {
- _D("[%d] %s(%s) , index : %d, fixed index : %d", i++, item->label, item->app_id, item->index, item->primary_index);
- }
- _D("================================= ");
-}
diff --git a/src/apps/apps_data_package_manager.c b/src/apps/apps_data_package_manager.c
deleted file mode 100755
index 6dcdbc8..0000000
--- a/src/apps/apps_data_package_manager.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <package_manager.h>
-#include <app_manager.h>
-
-#include "log.h"
-#include "util.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_data.h"
-#include "apps/apps_data_package_manager.h"
-#include "apps/apps_data_app_info.h"
-#include "apps/apps_callback_manager.h"
-
-static package_manager_h package_manager_handle = NULL;
-
-#ifdef APPS_TEST
-static char test_icon_label[17][30] = { "alarm", "apps", "atntmessages", "buddy", "recent", "calculator",
- "contacts", "email", "findmycar", "findmydevice", "gallery", "gallery_delta",
- "phone", "shealth", "timer", "traffic", "voicememo" };
-static void __test_fill_icon(APP_INFO **item, int idx);
-#endif
-
-static struct __package_manager_s {
- apps_callback_t *package_manager_uninstall_end_cb_stack;
-} s_info = {
- .package_manager_uninstall_end_cb_stack = NULL,
-};
-
-static void __event_cb(
- const char *type,
- const char *package,
- package_manager_event_type_e event_type,
- package_manager_event_state_e event_state,
- int progress,
- package_manager_error_e error,
- void *user_data);
-static void __install_cb(const char* package);
-static void __uninstall_cb(const char* package);
-static bool __fill_appinfo(app_info_h app_handle, APP_INFO **item);
-static bool __get_app_info_from_package(package_info_app_component_type_e comp_type, const char *app_id, void *data);
-static bool __get_appinfo_from_app_handle(app_info_h app_handle, void *data);
-
-ERROR_E apps_data_package_manager_init(void)
-{
- _D("%s", __func__);
-
- int ret;
- ret = package_manager_create(&package_manager_handle);
- if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- _E("failed to create package manager[%d]", ret);
- goto __fail;
- }
-
- ret = package_manager_set_event_status(package_manager_handle, PACKAGE_MANAGER_STATUS_TYPE_INSTALL|PACKAGE_MANAGER_STATUS_TYPE_UNINSTALL);
- if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- _E("failed to set event status[%d]", ret);
- goto __fail;
- }
-
- ret = package_manager_set_event_cb(package_manager_handle, __event_cb, NULL);
- if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- _E("failed to set event callback[%d]", ret);
- goto __fail;
- }
-
- s_info.package_manager_uninstall_end_cb_stack = apps_callback_manager_new();
- if (s_info.package_manager_uninstall_end_cb_stack == NULL) {
- _E("Failed to allocate memory for package manager end cb stack");
- goto __fail;
- }
-
- return ERROR_NONE;
-
-__fail:
- if (package_manager_handle != NULL) {
- package_manager_destroy(package_manager_handle);
- package_manager_handle = NULL;
- }
- return ERROR_FAILED;
-}
-
-void apps_data_package_manager_fini(void)
-{
- if (package_manager_handle != NULL) {
- package_manager_destroy(package_manager_handle);
- package_manager_handle = NULL;
- }
-
- apps_callback_manager_free(s_info.package_manager_uninstall_end_cb_stack);
-
- s_info.package_manager_uninstall_end_cb_stack = NULL;
-}
-
-bool apps_package_manager_register_uninstall_end_progress_cb(void(*uninstall_end_progress_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.package_manager_uninstall_end_cb_stack, uninstall_end_progress_cb);
-
- return ret;
-}
-
-void apps_package_manager_deregister_uninstall_end_progress_cb(void(*uninstall_end_progress_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.package_manager_uninstall_end_cb_stack, uninstall_end_progress_cb);
-}
-
-void apps_data_package_manager_update_label(APP_INFO **item)
-{
- app_info_h app_info = NULL;
- int ret;
- ret = app_manager_get_app_info((*item)->app_id, &app_info);
- if (ret != APP_MANAGER_ERROR_NONE) {
- _E("Failed to get app info from [%s]", (*item)->app_id);
- return;
- }
-
- if ((*item)->label)
- free((*item)->label);
-
- ret = app_info_get_label(app_info, &(*item)->label);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("Failed to get label from [%s]", (*item)->app_id);
- return;
- }
-}
-
-Eina_List *apps_data_package_manager_get_list(void)
-{
- _D("%s", __func__);
-
- Eina_List *list = NULL;
- int ret;
- app_info_filter_h handle = NULL;
-
- ret = app_info_filter_create(&handle);
- if (ret != APP_MANAGER_ERROR_NONE) {
- _E("failed to create app info filter[%d]", ret);
- return NULL;
- }
-
- app_info_filter_add_bool(handle, PACKAGE_INFO_PROP_APP_NODISPLAY , false);
- app_info_filter_foreach_appinfo(handle, __get_appinfo_from_app_handle, &list);
-
-#ifdef APPS_TEST
- {
- int i = 0;
- APP_INFO *item = NULL;
- for (i = 0; i < 17; i++) {
- __test_fill_icon(&item, i%17);
- list = eina_list_append(list, item);
- }
- }
-#endif
-
- return list;
-}
-
-static void __event_cb(
- const char *type,
- const char *package,
- package_manager_event_type_e event_type,
- package_manager_event_state_e event_state,
- int progress,
- package_manager_error_e error,
- void *user_data)
-{
- if (event_state == PACKAGE_MANAGER_EVENT_STATE_STARTED) {
- _D("pkg:%s event type:%d state:PACKAGE_MANAGER_EVENT_STATE_STARTED", package, event_type);
- } else if (event_state == PACKAGE_MANAGER_EVENT_STATE_PROCESSING) {
- _D("pkg:%s event type:%d PACKAGE_MANAGER_EVENT_STATE_PROCESSING", package, event_type);
- } else if (event_state == PACKAGE_MANAGER_EVENT_STATE_COMPLETED) {
- _D("pkg:%s event type:%d PACKAGE_MANAGER_EVENT_STATE_COMPLETED", package, event_type);
- if (event_type == PACKAGE_MANAGER_EVENT_TYPE_INSTALL) {
- __install_cb(package);
- } else if (event_type == PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL) {
- __uninstall_cb(package);
- apps_callback_manager_execute_cb(s_info.package_manager_uninstall_end_cb_stack, NULL);
- } else if (event_type == PACKAGE_MANAGER_EVENT_TYPE_UPDATE) {
- _D("UPDATE - %s", package);
- } else {
- _E("not supported event type %d", event_type);
- }
- } else {
- _E("pkg:%s type:%d state:PACKAGE_MANAGER_EVENT_STATE_COMPLETED: FAILED", package, event_type);
- }
-}
-
-static void __install_cb(const char* package)
-{
- _D("%s", __func__);
-
- package_info_h package_info = NULL;
-
- int ret = PACKAGE_MANAGER_ERROR_NONE;
- ret = package_info_create(package, &package_info);
- if (PACKAGE_MANAGER_ERROR_NONE != ret) {
- LOGE("Failed to create pakcage info for %s", package);
- return;
- }
-
- ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, __get_app_info_from_package, NULL);
- if (PACKAGE_MANAGER_ERROR_NONE != ret) {
- LOGE("Failed to install app from %s", package);
- return;
- }
- package_info_destroy(package_info);
-}
-
-static void __uninstall_cb(const char* package)
-{
- _D("%s", __func__);
-
- apps_data_delete_appinfo_by_pkg_id(package);
-}
-
-static bool __get_app_info_from_package(package_info_app_component_type_e comp_type, const char *app_id, void *data)
-{
- int ret = PACKAGE_MANAGER_ERROR_NONE;
- app_info_h app_info = NULL;
- APP_INFO *item = NULL;
-
- ret = app_manager_get_app_info(app_id, &app_info);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("Failed to get app_info, return: [%d]", ret);
- return false;
- }
-
- if (__fill_appinfo(app_info, &item)) {
- apps_data_insert_appinfo(item);
- }
- app_info_destroy(app_info);
-
- return true;
-}
-
-static bool __get_appinfo_from_app_handle(app_info_h app_handle, void *data)
-{
- Eina_List **list = (Eina_List **)data;
- APP_INFO *item = NULL;
- if (__fill_appinfo(app_handle, &item)) {
- *list = eina_list_append(*list, item);
- }
-
- return true;
-}
-
-static bool __fill_appinfo(app_info_h app_handle, APP_INFO **item)
-{
- bool nodisplay = false;
- int ret;
- package_info_h p_handle = NULL;
-
- APP_INFO *new_item = (APP_INFO *)malloc(sizeof(APP_INFO));
- if (new_item == NULL) {
- _E("memory allocation is failed!!!");
- return false;
- }
-
- memset(new_item, 0, sizeof(APP_INFO));
- *item = new_item;
-
- new_item->db_id = INVALID_VALUE;
- new_item->index = INVALID_VALUE;
- new_item->primary_index = INVALID_VALUE;
-
- app_info_is_nodisplay(app_handle, &nodisplay);
- if (nodisplay) {
- _D("skip nodisplay app");
- goto __fail;
- }
-
- ret = app_info_get_app_id(app_handle, &new_item->app_id);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("app_info_get_app_id return [%d] %s", ret, new_item->app_id);
- goto __fail;
- }
-
- ret = app_info_get_package(app_handle, &new_item->pkg_id);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("app_info_get_package return [%d] %s", ret, new_item->pkg_id);
- goto __fail;
- }
-
- ret = app_info_get_label(app_handle, &new_item->label);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("app_info_get_label return [%d] %s", ret, new_item->label);
- goto __fail;
- }
-
- ret = app_info_get_icon(app_handle, &new_item->icon_path);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("app_info_get_icon return [%d]", ret);
- goto __fail;
- }
-
- if (new_item->icon_path == NULL || ecore_file_can_read(new_item->icon_path) == EINA_FALSE) {
- if (new_item->icon_path != NULL) {
- free(new_item->icon_path);
- }
-
- new_item->icon_path = (char *)malloc(FILE_PATH_MAX * sizeof(char));
- if (new_item->icon_path == NULL) {
- _E("memory allocation is failed!!!");
- goto __fail;
- }
- snprintf(new_item->icon_path, FILE_PATH_MAX, "%s", util_get_res_file_path(IMAGE_DIR"/unknown.png"));
- }
-
- ret = package_manager_get_package_info(new_item->pkg_id, &p_handle);
- if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- _E("Failed to inialize package handle for item : %s", new_item->pkg_id);
- goto __fail;
- }
-
- ret = package_info_is_removable_package(p_handle, &new_item->is_removable);
- if (PACKAGE_MANAGER_ERROR_NONE != ret) {
- _E("package_info_is_removable_package return [%d]", ret);
- goto __fail;
- }
-
- return true;
-
-__fail:
- apps_data_app_info_free_item(new_item);
- *item = NULL;
-
- return false;
-}
-
-#ifdef APPS_TEST
-static void __test_fill_icon(APP_INFO **item, int idx)
-{
- char label[TEXT_MAX] = { 0, };
- APP_INFO *new_item = (APP_INFO *)malloc(sizeof(APP_INFO));
- memset(new_item, 0, sizeof(APP_INFO));
- *item = new_item;
-
- new_item->db_id = INVALID_VALUE;
- new_item->index = INVALID_VALUE;
- new_item->primary_index = INVALID_VALUE;
-
- snprintf(label, sizeof(label), "org.tizen.%s", test_icon_label[idx]);
- new_item->app_id = strdup(label);
- new_item->pkg_id = strdup(label);
- new_item->label = strdup(test_icon_label[idx]);
- new_item->icon_path = (char *)malloc(FILE_PATH_MAX * sizeof(char));
- snprintf(label, sizeof(label), "%s%s.png", "/usr/apps/org.tizen.w-home/res/images/", test_icon_label[idx]);
- snprintf(new_item->icon_path, FILE_PATH_MAX, "%s", label);
-
- new_item->is_removable = 1;
-}
-#endif
diff --git a/src/apps/apps_data_xml_manager.c b/src/apps/apps_data_xml_manager.c
deleted file mode 100755
index b070ce4..0000000
--- a/src/apps/apps_data_xml_manager.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <tizen.h>
-#include <libxml/xmlreader.h>
-
-#include "apps/apps_data.h"
-#include "apps/apps_data_xml.h"
-#include "apps/apps_data_app_info.h"
-#include "util.h"
-#include "log.h"
-
-#define DEFAULT_ORDER_FILE "apps_default_order.xml"
-
-typedef enum {
- _APPS_XML_INVALID,
- _APPS_XML_APP_ID,
- _APPS_XML_POSITION
-} APPS_XML_TYPE;
-
-Eina_List *apps_data_xml_get_data_list(void)
-{
- xmlTextReaderPtr reader = NULL;
- Eina_List *list = NULL;
-
- int ret = -1;
- const char *name = NULL, *value = NULL;
-
- APP_INFO *item = NULL;
- APPS_XML_TYPE data_type = _APPS_XML_INVALID;
-
- reader = xmlReaderForFile(util_get_res_file_path(DEFAULT_ORDER_FILE), NULL, 0);
- if (reader == NULL) {
- _E("xmlReaderForFile : %s failed", util_get_res_file_path(DEFAULT_ORDER_FILE));
- return NULL;
- }
-
- while ((ret = xmlTextReaderRead(reader)) == 1) {
- int dep = 0;
- int node_type = 0;
-
- dep = xmlTextReaderDepth(reader);
- node_type = xmlTextReaderNodeType(reader);
- if (-1 == dep || -1 == node_type)
- continue;
-
- name = (const char*) xmlTextReaderConstName(reader);
- if (!name)
- continue;
-
- value = (const char*) xmlTextReaderConstValue(reader);
-
- if (dep == 1 && node_type == 1) {
- item = (APP_INFO *)malloc(sizeof(APP_INFO));
- if (item == NULL) {
- _E("memory allocation is failed!!!");
- apps_data_app_info_free_list(list);
- xmlFreeTextReader(reader);
- return NULL;
- }
- memset(item, 0, sizeof(APP_INFO));
- } else if(dep == 1 && node_type == 15) {
- if (item != NULL) {
- list = eina_list_append(list, item);
- item = NULL;
- }
- } else if (dep == 2 && node_type == 1 ) {
- if (strcmp(name, "app_id") == 0) {
- data_type = _APPS_XML_APP_ID;
- } else if (strcmp(name, "position") == 0) {
- data_type = _APPS_XML_POSITION;
- } else {
- data_type = _APPS_XML_INVALID;
- }
- } else if (dep == 3 && node_type == 3) {
- if (data_type == _APPS_XML_APP_ID) {
- item->app_id = strdup(value);
- } else if(data_type == _APPS_XML_POSITION) {
- item->primary_index = atoi(value);
- }
- }
- }
- if (item != NULL) {
- apps_data_app_info_free_item(item);
- }
- xmlFreeTextReader(reader);
-
- return list;
-}
diff --git a/src/apps/apps_db.c b/src/apps/apps_db.c
deleted file mode 100755
index f84f511..0000000
--- a/src/apps/apps_db.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <sqlite3.h>
-
-#include "log.h"
-#include "util.h"
-#include "apps/apps_data.h"
-#include "apps/apps_db.h"
-
-#define APPS_DB_NAME ".apps-data.db"
-#define QUERY_MAXLEN 4096
-static sqlite3 *apps_db = NULL;
-
-enum {
- COL_ID = 0,
- COL_APPLICATION_ID,
- COL_PACKAGE_ID,
- COL_LABEL,
- COL_ICON,
- COL_POSITION,
-};
-
-#define CREATE_APPS_DB_TABLE "create table if not exists apps(\
- id INTEGER PRIMARY KEY AUTOINCREMENT,\
- appId TEXT,\
- pkgId TEXT,\
- label TEXT,\
- iconPath TEXT,\
- position TEXT);"
-
-#define UPDATE_APPS_DB_TABLE "UPDATE apps set \
- appId='%s',\
- pkgId='%s',\
- label='%s',\
- iconPath='%s,\
- position=%d' WHERE id = %d"
-
-#define INSERT_APPS_DB_TABLE "INSERT into apps \
- (appId, pkgId, label, iconPath, position)\
- VALUES('%s','%s','%s','%s',%d)"
-
-#define SELECT_ITEM "SELECT * FROM apps;"
-
-static bool _apps_db_open(void);
-
-bool apps_db_create(void)
-{
- char *errMsg;
- int ret;
- const char *db_path = util_get_data_file_path(APPS_DB_NAME);
- FILE *fp = fopen(db_path, "r");
- if (fp) {
- fclose(fp);
- _APPS_E("Apps DB[%s] exist", db_path);
- return false;
- }
-
- ret = sqlite3_open(db_path, &apps_db);
- if (ret != SQLITE_OK) {
- _APPS_E("sqlite error : [%d] : path [%s]", ret, db_path);
- return false;
- }
- ret = sqlite3_exec(apps_db, "PRAGMA journal_mode = PERSIST",
- NULL, NULL, &errMsg);
- if (ret != SQLITE_OK) {
- _APPS_E("SQL error(%d) : %s", ret, errMsg);
- sqlite3_free(errMsg);
- return false;
- }
-
- ret = sqlite3_exec(apps_db, CREATE_APPS_DB_TABLE, NULL, NULL, &errMsg);
- if (ret != SQLITE_OK) {
- _APPS_E("SQL error(%d) : %s", ret, errMsg);
- sqlite3_free(errMsg);
- return false;
- }
-
- return true;
-}
-
-bool apps_db_close(void)
-{
- if (apps_db) {
- sqlite3_exec(apps_db, "COMMIT TRANSACTION", NULL, NULL, NULL);
- sqlite3_close(apps_db);
- apps_db = NULL;
- }
- return true;
-}
-
-bool apps_db_update(apps_data_s *item)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!_apps_db_open())
- return false;
-
- snprintf(query, QUERY_MAXLEN, UPDATE_APPS_DB_TABLE,
- item->app_id,
- item->pkg_id,
- item->label,
- item->icon,
- item->position,
- item->db_id);
- int ret = sqlite3_prepare(apps_db, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _APPS_E("sqlite error : [%s,%s]", query, sqlite3_errmsg(apps_db));
- return false;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
- apps_db_close();
- return true;
-
-}
-
-bool apps_db_insert(apps_data_s *item)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!_apps_db_open())
- return false;
-
- snprintf(query, QUERY_MAXLEN, INSERT_APPS_DB_TABLE,
- item->app_id,
- item->pkg_id,
- item->label,
- item->icon,
- item->position);
-
- int ret = sqlite3_prepare(apps_db, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _APPS_E("sqlite error : [%s,%s]", query, sqlite3_errmsg(apps_db));
- return false;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
- item->db_id = (int)sqlite3_last_insert_rowid(apps_db);
-
- apps_db_close();
- return true;
-}
-
-bool apps_db_delete(apps_data_s *item)
-{
- char query[QUERY_MAXLEN];
- sqlite3_stmt *stmt;
- if (!_apps_db_open())
- return false;
-
- snprintf(query, QUERY_MAXLEN, "DELETE FROM apps WHERE id=%d", item->db_id);
- int ret = sqlite3_prepare(apps_db, query, QUERY_MAXLEN , &stmt, NULL);
- if (ret != SQLITE_OK) {
- _APPS_E("sqlite error : [%s,%s]", query, sqlite3_errmsg(apps_db));
- return false;
- }
- sqlite3_step(stmt);
- sqlite3_finalize(stmt);
-
- apps_db_close();
- return true;
-}
-
-bool apps_db_get_list(Eina_List **apps_db_list)
-{
- sqlite3_stmt *stmt;
- const char *str = NULL;
-
- if (!_apps_db_open())
- return false;
-
- int ret = sqlite3_prepare_v2(apps_db, SELECT_ITEM, strlen(SELECT_ITEM), &stmt, NULL);
- if (ret != SQLITE_OK) {
- _APPS_E("sqlite error : [%s,%s]", SELECT_ITEM, sqlite3_errmsg(apps_db));
- return false;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- apps_data_s *item = (apps_data_s *)malloc(sizeof(apps_data_s));
- memset(item, 0, sizeof(apps_data_s));
-
- item->db_id = sqlite3_column_int(stmt, COL_ID);
-
- str = (const char *) sqlite3_column_text(stmt, COL_APPLICATION_ID);
- item->app_id = (!str || !strlen(str)) ? NULL : strdup(str);
-
- str = (const char *) sqlite3_column_text(stmt, COL_PACKAGE_ID);
- item->pkg_id = (!str || !strlen(str)) ? NULL : strdup(str);
-
- str = (const char *) sqlite3_column_text(stmt, COL_LABEL);
- item->label = (!str) ? NULL : strdup(str);
-
- str = (const char *)sqlite3_column_text(stmt, COL_ICON);
- item->icon = (!str || !strlen(str)) ? NULL : strdup(str);
-
- item->position = sqlite3_column_int(stmt, COL_POSITION);
- *apps_db_list = eina_list_append(*apps_db_list, item);
- }
- sqlite3_finalize(stmt);
- apps_db_close();
-
- return true;
-}
-
-static bool _apps_db_open(void)
-{
- if (!apps_db) {
- int ret;
- ret = sqlite3_open(util_get_data_file_path(APPS_DB_NAME), &apps_db);
- if (ret != SQLITE_OK) {
- _APPS_E("sqlite error : [%d] : path [%s]", ret, util_get_data_file_path(APPS_DB_NAME));
- return false;
- }
- }
- return true;
-}
diff --git a/src/apps/apps_key_handler.c b/src/apps/apps_key_handler.c
deleted file mode 100755
index 1a358f2..0000000
--- a/src/apps/apps_key_handler.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Ecore.h>
-#include <Elementary.h>
-
-#include "log.h"
-#include "apps/apps_key_handler.h"
-#include "apps/apps_callback_manager.h"
-
-static struct __key_handler_s {
- bool pressed;
- Ecore_Event_Handler *press_handler;
- Ecore_Event_Handler *release_handler;
- apps_callback_t *back_cb_stack;
- apps_callback_t *home_cb_stack;
-} s_info = {
- .pressed = 0,
- .press_handler = NULL,
- .release_handler = NULL,
- .back_cb_stack = NULL,
- .home_cb_stack = NULL,
-};
-
-static Eina_Bool __key_release_cb(void *data, int type, void *event);
-static Eina_Bool __key_press_cb(void *data, int type, void *event);
-static void __back_key(void);
-static void __home_key(void);
-static void __destroy_key_handler(void);
-
-ERROR_E apps_key_handler_init(void)
-{
- _D("%s", __func__);
-
- if (s_info.release_handler == NULL) {
- s_info.release_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, __key_release_cb, NULL);
- if (s_info.release_handler == NULL) {
- _E("Failed to register a key up event handler");
- goto __fail;
- }
- }
-
- if (s_info.press_handler == NULL) {
- s_info.press_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __key_press_cb, NULL);
- if (!s_info.press_handler) {
- _E("Failed to register a key down event handler");
- goto __fail;
- }
- }
-
- s_info.back_cb_stack = apps_callback_manager_new();
- if (s_info.back_cb_stack == NULL) {
- _E("Failed to allocate memory for back key cb stack");
- goto __fail;
- }
-
- s_info.home_cb_stack = apps_callback_manager_new();
- if (s_info.home_cb_stack == NULL) {
- _E("Failed to allocate memory for home key cb stack");
- goto __fail;
- }
-
- s_info.pressed = false;
-
- return ERROR_NONE;
-
-__fail:
- __destroy_key_handler();
-
- return ERROR_FAILED;
-}
-
-void apps_key_handler_fini(void)
-{
- __destroy_key_handler();
-}
-
-bool apps_key_handler_register_back_key_cb(void(*key_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.back_cb_stack, key_cb);
-
- return ret;
-}
-
-void apps_key_handler_deregister_back_key_cb(void(*key_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.back_cb_stack, key_cb);
-}
-
-bool apps_key_handler_register_home_key_cb(void(*key_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.home_cb_stack, key_cb);
-
- return ret;
-}
-
-void apps_key_handler_deregister_home_key_cb(void(*key_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.home_cb_stack, key_cb);
-}
-
-void apps_key_handler_press_home_key(void)
-{
- __home_key();
-}
-
-static Eina_Bool __key_release_cb(void *data, int type, void *event)
-{
- Evas_Event_Key_Up *ev = event;
-
- _D("Key(%s) released %d", ev->keyname, s_info.pressed);
-
- if (s_info.pressed == false) {
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if (!strcmp(ev->keyname, KEY_BACK)) {
- __back_key();
- }
-
- s_info.pressed = false;
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool __key_press_cb(void *data, int type, void *event)
-{
- Evas_Event_Key_Down *ev = event;
-
- _D("Key(%s) pressed %d", ev->keyname, s_info.pressed);
-
- s_info.pressed = true;
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void __back_key(void)
-{
- apps_callback_manager_execute_cb(s_info.back_cb_stack, NULL);
-}
-
-static void __home_key(void)
-{
- apps_callback_manager_execute_cb(s_info.home_cb_stack, NULL);
-}
-
-static void __destroy_key_handler(void)
-{
- if (s_info.release_handler != NULL) {
- ecore_event_handler_del(s_info.release_handler);
- s_info.release_handler = NULL;
- }
-
- if (s_info.press_handler != NULL) {
- ecore_event_handler_del(s_info.press_handler);
- s_info.press_handler = NULL;
- }
-
- apps_callback_manager_free(s_info.back_cb_stack);
- apps_callback_manager_free(s_info.home_cb_stack);
-
- s_info.back_cb_stack = NULL;
- s_info.home_cb_stack = NULL;
-}
diff --git a/src/apps/apps_lang_changed_handler.c b/src/apps/apps_lang_changed_handler.c
deleted file mode 100755
index 5c163d5..0000000
--- a/src/apps/apps_lang_changed_handler.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Ecore.h>
-#include <Elementary.h>
-
-#include "log.h"
-#include "apps/apps_lang_changed_handler.h"
-#include "apps/apps_data.h"
-#include "apps/apps_callback_manager.h"
-
-static struct _lang_changed_handler_s {
- app_event_handler_h lang_changed_handler;
- apps_callback_t *lang_changed_cb_stack;
-} s_info = {
- .lang_changed_handler = NULL,
- .lang_changed_cb_stack = NULL,
-};
-
-static void __lang_changed_cb(app_event_info_h event_info, void *user_data);
-static void __destroy_lang_changed_handler(void);
-
-ERROR_E apps_lang_changed_handler_init(void)
-{
- _D("%s", __func__);
-
- if (s_info.lang_changed_handler == NULL) {
- ui_app_add_event_handler(&s_info.lang_changed_handler, APP_EVENT_LANGUAGE_CHANGED, __lang_changed_cb, NULL);
- if (s_info.lang_changed_handler == NULL) {
- _E("Failed to register a language changed event handler");
- goto __fail;
- }
- }
-
- s_info.lang_changed_cb_stack = apps_callback_manager_new();
- if (s_info.lang_changed_cb_stack == NULL) {
- _E("Failed to allocate memory for language changed cb stack");
- goto __fail;
- }
-
- return ERROR_NONE;
-
-__fail:
- __destroy_lang_changed_handler();
-
- return ERROR_FAILED;
-}
-
-void apps_lang_changed_handler_fini(void)
-{
- __destroy_lang_changed_handler();
-}
-
-bool apps_lang_changed_handler_register_label_update_cb(void(*icon_label_update_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.lang_changed_cb_stack, icon_label_update_cb);
-
- return ret;
-}
-
-void apps_lang_changed_handler_deregister_label_update_cb(void(*icon_label_update_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.lang_changed_cb_stack, icon_label_update_cb);
-}
-
-static void __lang_changed_cb(app_event_info_h event_info, void *user_data)
-{
- _D("Apps Language Changed");
- apps_callback_manager_execute_cb(s_info.lang_changed_cb_stack, NULL);
-}
-
-static void __destroy_lang_changed_handler(void)
-{
- if (s_info.lang_changed_handler != NULL) {
- ui_app_remove_event_handler(s_info.lang_changed_handler);
- s_info.lang_changed_handler = NULL;
- }
-
- apps_callback_manager_free(s_info.lang_changed_cb_stack);
-
- s_info.lang_changed_cb_stack = NULL;
-}
diff --git a/src/apps/apps_manager.c b/src/apps/apps_manager.c
deleted file mode 100755
index b0eca50..0000000
--- a/src/apps/apps_manager.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <badge.h>
-
-#include "log.h"
-#include "apps/apps.h"
-#include "apps/apps_view.h"
-#include "apps/apps_data.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_state.h"
-#include "apps/apps_key_handler.h"
-#include "apps/apps_lang_changed_handler.h"
-#include "apps/apps_rotary_event_handler.h"
-
-static struct __control_manager_s {
- Evas_Object *main_win;
- APPS_STATE *normal_state;
- APPS_STATE *edit_state;
- APPS_STATE *reorder_state;
- APPS_STATE *prev_state;
- APPS_STATE *current_state;
- int is_visible;
-} s_info = {
- .main_win = NULL,
- .normal_state = NULL,
- .edit_state = NULL,
- .reorder_state = NULL,
- .prev_state = NULL,
- .current_state = NULL,
- .is_visible = false,
-};
-
-void __apps_control_manager_set_state(APPS_STATE *state);
-APPS_STATE *__apps_control_manager_get_normal_state(void);
-APPS_STATE *__apps_control_manager_get_edit_state(void);
-APPS_STATE *__apps_control_manager_get_reorder_state(void);
-APPS_STATE *__apps_control_manager_get_current_state(void);
-
-static bool __create_apps_state(void);
-static void __destroy_apps_state(void);
-static void __add_window_focused_cb(void);
-static void __add_window_unfocused_cb(void);
-static void __view_focused_cb(void *data, Evas_Object *obj, void *event_info);
-static void __view_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
-static void __back_key_cb(void *data);
-static void __home_key_cb(void *data);
-static void __cw_cb(void *data);
-static void __ccw_cb(void *data);
-static void __app_data_changed_cb(void *data);
-static void __badge_changed_cb(unsigned int action, const char *pkgname, unsigned int count, void *data);
-static void __register_badge_changed_cb(void);
-static void __deregister_badge_changed_cb(void);
-
-bool apps_is_visible(void)
-{
- return s_info.is_visible;
-}
-
-ERROR_E apps_init(void)
-{
- _D("%s", __func__);
-
- if (apps_key_handler_init() != ERROR_NONE) {
- _E("failed to initialize key handler");
- return ERROR_FAILED;
- }
-
- if (apps_lang_changed_handler_init() != ERROR_NONE) {
- _E("failed to initialize event handler");
- return ERROR_FAILED;
- }
-
- if (apps_data_init() != ERROR_NONE) {
- _E("failed to initialize apps_data");
- return ERROR_FAILED;
- }
-
- if (apps_view_init() != ERROR_NONE) {
- _E("failed to initialize apps_view");
- return ERROR_FAILED;
- }
- s_info.main_win = apps_view_get_main_window();
- if (s_info.main_win == NULL) {
- _E("main window is null");
- return ERROR_FAILED;
- }
- __add_window_focused_cb();
- __add_window_unfocused_cb();
-
- if (apps_rotary_event_handler_init(s_info.main_win) == EINA_FALSE) {
- _E("failed to initialize rotary event");
- return ERROR_FAILED;
- }
- apps_rotary_event_handler_register_cw_cb(__cw_cb);
- apps_rotary_event_handler_register_ccw_cb(__ccw_cb);
-
- if (!__create_apps_state()) {
- _E("failed to create apps state");
- return ERROR_FAILED;
- }
-
- __register_badge_changed_cb();
- apps_data_register_data_changed_cb(__app_data_changed_cb);
-
- return ERROR_NONE;
-}
-
-void apps_fini(void)
-{
- _D("%s", __func__);
-
- apps_data_deregister_data_changed_cb(__app_data_changed_cb);
- __deregister_badge_changed_cb();
- __destroy_apps_state();
- apps_rotary_event_handler_fini();
- apps_view_fini();
- apps_data_fini();
- apps_key_handler_fini();
- apps_lang_changed_handler_fini();
-}
-
-void apps_resume(void)
-{
- /*if (s_info.current_state != NULL) {
- (*s_info.current_state->step_in)();
- }*/
-}
-
-void apps_pause(void)
-{
- /*if (s_info.current_state != NULL) {
- (*s_info.current_state->step_out)();
- }*/
-}
-
-void apps_show(void)
-{
- _D("Show APPS");
-
- s_info.current_state = s_info.normal_state;
- s_info.normal_state->show_up();
-
- s_info.is_visible = true;
-}
-
-void apps_hide(void)
-{
- _D("Hide APPS");
-
- apps_view_hide();
- s_info.is_visible = false;
-
- if (s_info.current_state != NULL) {
- (*s_info.current_state->step_out)(NULL);
- s_info.current_state = NULL;
- }
-}
-
-void __apps_control_manager_set_state(APPS_STATE *state)
-{
- s_info.prev_state = s_info.current_state;
-
- if (s_info.current_state != NULL) {
- (*s_info.current_state->step_out)((void *) state);
- }
-
- s_info.current_state = state;
-
- (*state->step_in)();
-}
-
-APPS_STATE *__apps_control_manager_get_normal_state(void)
-{
- return s_info.normal_state;
-}
-
-APPS_STATE *__apps_control_manager_get_edit_state(void)
-{
- return s_info.edit_state;
-}
-
-APPS_STATE *__apps_control_manager_get_reorder_state(void)
-{
- return s_info.reorder_state;
-}
-
-APPS_STATE *__apps_control_manager_get_current_state(void)
-{
- return s_info.current_state;
-}
-
-static bool __create_apps_state(void)
-{
- _D("%s", __func__);
-
- s_info.normal_state = apps_state_create_normal();
- if (s_info.normal_state == NULL) {
- _E("failed to create normal state");
- goto __fail;
- }
-
- s_info.edit_state = apps_state_create_edit();
- if (s_info.edit_state == NULL) {
- _E("failed to create edit state");
- goto __fail;
- }
-
- s_info.reorder_state = apps_state_create_reorder();
- if (s_info.reorder_state == NULL) {
- _E("failed to create edit state");
- goto __fail;
- }
-
- s_info.current_state = NULL;
-
- return true;
-
-__fail:
- __destroy_apps_state();
- return false;
-}
-
-static void __destroy_apps_state(void)
-{
- apps_state_destroy(s_info.normal_state);
- apps_state_destroy(s_info.edit_state);
- apps_state_destroy(s_info.reorder_state);
- s_info.normal_state = NULL;
- s_info.edit_state = NULL;
- s_info.reorder_state = NULL;
- s_info.current_state = NULL;
-}
-
-static void __add_window_focused_cb(void)
-{
- if (s_info.main_win == NULL) {
- _E("main window is null");
- return ;
- }
-
- evas_object_smart_callback_add(s_info.main_win, "focused", __view_focused_cb, NULL);
-}
-
-static void __add_window_unfocused_cb(void)
-{
- if (s_info.main_win == NULL) {
- _E("main window is null");
- return ;
- }
-
- evas_object_smart_callback_add(s_info.main_win, "unfocused", __view_unfocused_cb, NULL);
-}
-
-static void __view_focused_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("apps view is focused");
-
- if (apps_key_handler_register_back_key_cb(__back_key_cb) == false) {
- _E("back key cb is not registered");
- }
-
- if (apps_key_handler_register_home_key_cb(__home_key_cb) == false) {
- _E("home key cb is not registered");
- }
-
- apps_rotary_event_handler_activated_set(EINA_TRUE);
-
- if (s_info.current_state != NULL) {
- (*s_info.current_state->resume_cb)();
- }
-}
-
-static void __view_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("apps view is unfocused");
-
- if (s_info.current_state != NULL) {
- (*s_info.current_state->pause_cb)();
- }
-
- apps_key_handler_deregister_back_key_cb(__back_key_cb);
- apps_key_handler_deregister_home_key_cb(__home_key_cb);
-
- apps_rotary_event_handler_activated_set(EINA_FALSE);
-}
-
-static void __back_key_cb(void *data)
-{
- if (s_info.current_state != NULL) {
- (*s_info.current_state->back_key_cb)();
- }
-}
-
-static void __home_key_cb(void *data)
-{
- if (s_info.current_state != NULL) {
- (*s_info.current_state->home_key_cb)();
- }
-}
-
-static void __cw_cb(void *data)
-{
- if (s_info.current_state != NULL) {
- (*s_info.current_state->cw_rotation_cb)();
- }
-}
-
-static void __ccw_cb(void *data)
-{
- if (s_info.current_state != NULL) {
- (*s_info.current_state->ccw_rotation_cb)();
- }
-}
-
-static void __app_data_changed_cb(void *data)
-{
- if (s_info.current_state != NULL) {
- (*s_info.current_state->app_data_changed_cb)();
- }
-}
-
-
-static void __badge_changed_cb(unsigned int action, const char *pkgname, unsigned int count, void *data)
-{
- if (s_info.current_state != NULL) {
- (*s_info.current_state->app_badge_changed_cb)();
- }
-}
-
-static void __register_badge_changed_cb(void)
-{
- int ret = BADGE_ERROR_NONE;
- ret = badge_register_changed_cb(__badge_changed_cb, NULL);
-
- if (ret != BADGE_ERROR_NONE) {
- _E("badge_register_changed_cb failed [%d]", ret);
- }
-}
-
-static void __deregister_badge_changed_cb(void)
-{
- int ret = BADGE_ERROR_NONE;
- ret = badge_unregister_changed_cb(__badge_changed_cb);
-
- if (ret != BADGE_ERROR_NONE) {
- _E("badge_unregister_changed_cb failed [%d]", ret);
- }
-}
-
diff --git a/src/apps/apps_rotary_event_handler.c b/src/apps/apps_rotary_event_handler.c
deleted file mode 100755
index 1735ce6..0000000
--- a/src/apps/apps_rotary_event_handler.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <efl_extension.h>
-
-#include "log.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_rotary_event_handler.h"
-#include "apps/apps_callback_manager.h"
-#include "apps/apps_animator.h"
-
-static struct __key_handler_s {
- Evas_Object *base_object;
- apps_callback_t *cw_cb_stack;
- apps_callback_t *ccw_cb_stack;
-} s_info = {
- .base_object = NULL,
- .cw_cb_stack = NULL,
- .ccw_cb_stack = NULL,
-};
-
-static Eina_Bool __rotation_cb(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *rotary_info);
-static void __destroy_handler(void);
-
-Eina_Bool apps_rotary_event_handler_init(Evas_Object *base_obj)
-{
- s_info.base_object = base_obj;
-
- s_info.cw_cb_stack = apps_callback_manager_new();
- if (s_info.cw_cb_stack == NULL) {
- _E("Failed to allocate memory for cw cb stack");
- goto __fail;
- }
-
- s_info.ccw_cb_stack = apps_callback_manager_new();
- if (s_info.cw_cb_stack == NULL) {
- _E("Failed to allocate memory for cw cb stack");
- goto __fail;
- }
-
- if (eext_rotary_object_event_callback_add(base_obj, __rotation_cb, NULL) == EINA_FALSE) {
- _E("Failed to add rotary event callback");
- goto __fail;
- }
-
- return EINA_TRUE;
-
-__fail:
- __destroy_handler();
- return EINA_FALSE;
-}
-
-void apps_rotary_event_handler_fini(void)
-{
- eext_rotary_object_event_callback_del(s_info.base_object, __rotation_cb);
- s_info.base_object = NULL;
-
- __destroy_handler();
-}
-
-void apps_rotary_event_handler_activated_set(Eina_Bool set)
-{
- eext_rotary_object_event_activated_set(s_info.base_object, set);
-}
-
-bool apps_rotary_event_handler_register_cw_cb(void(*cw_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.cw_cb_stack, cw_cb);
-
- return ret;
-}
-
-void apps_rotary_event_handler_deregister_cw_cb(void(*cw_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.cw_cb_stack, cw_cb);
-}
-
-bool apps_rotary_event_handler_register_ccw_cb(void(*ccw_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.ccw_cb_stack, ccw_cb);
-
- return ret;
-}
-
-void apps_rotary_event_handler_deregister_ccw_cb(void(*ccw_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.ccw_cb_stack, ccw_cb);
-}
-
-static Eina_Bool __rotation_cb(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *rotary_info)
-{
- if (apps_animator_is_ongoing()) {
- _D("rotation event is skipped because animation is ongoing");
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if (rotary_info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
- apps_callback_manager_execute_cb(s_info.cw_cb_stack, NULL);
- } else {
- apps_callback_manager_execute_cb(s_info.ccw_cb_stack, NULL);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void __destroy_handler(void)
-{
- apps_callback_manager_free(s_info.cw_cb_stack);
- apps_callback_manager_free(s_info.ccw_cb_stack);
-
- s_info.cw_cb_stack = NULL;
- s_info.ccw_cb_stack = NULL;
-}
diff --git a/src/apps/apps_state.c b/src/apps/apps_state.c
deleted file mode 100755
index c5e898c..0000000
--- a/src/apps/apps_state.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-
-#include "log.h"
-#include "apps/apps_data.h"
-#include "apps/apps_state.h"
-#include "apps/apps_view_icon.h"
-
-static void __dummy_resume_cb(void) { _D("do nothing"); }
-static void __dummy_pause_cb(void) { _D("do nothing"); }
-static void __dummy_step_in(void) { _D("do nothing"); }
-static void __dummy_step_out(void *next_state) { _D("do nothing"); }
-static void __dummy_show_up(void) { _D("do nothing"); }
-static void __dummy_back_key_cb(void) { _D("do nothing"); }
-static void __dummy_home_key_cb(void) { _D("do nothing"); }
-static void __dummy_cw_rotation_cb(void) { _D("do nothing"); }
-static void __dummy_ccw_rotation_cb(void) { _D("do nothing"); }
-static void __dummy_app_data_changed_cb(void) { _D("do nothing"); }
-static void __dummy_app_badge_changed_cb(void) { _D("do nothing"); }
-
-static void __dummy_drop_icon_cb(void) { _D("do nothing"); }
-static void __dummy_drag_hold_next_cb(void) { _D("do nothing"); }
-static void __dummy_drag_hold_prev_cb(void) { _D("do nothing"); }
-static void __dummy_drag_hold_icon_cb(int picked_icon_idx, int hold_icon_idx) { _D("do nothing"); }
-static void __dummy_tap_next_cb(void) { _D("do nothing"); }
-static void __dummy_tap_prev_cb(void) { _D("do nothing"); }
-static void __dummy_tap_app_icon_cb(APP_INFO *app_info, int pos) { _D("do nothing"); }
-static void __dummy_tap_focus_text_cb(APPS_ICON_INFO *icon_info, int pos) { _D("do nothing"); }
-static void __dummy_tap_empty_area_cb(void) { _D("do nothing"); }
-static void __dummy_tap_hold_next_cb(void) { _D("do nothing"); }
-static void __dummy_tap_hold_prev_cb(void) { _D("do nothing"); }
-static void __dummy_tap_hold_app_icon_cb(void) { _D("do nothing"); }
-static void __dummy_tap_hold_focus_text_cb(void) { _D("do nothing"); }
-static void __dummy_tap_hold_empty_area_cb(void) { _D("do nothing"); }
-static void __dummy_swipe_left_cb(void) { _D("do nothing"); }
-static void __dummy_swipe_right_cb(void) { _D("do nothing"); }
-
-APPS_STATE *__apps_state_new(void)
-{
- APPS_STATE *state = (APPS_STATE *)malloc(sizeof(APPS_STATE));
- if(state == NULL) {
- _E("failed to malloc");
- return NULL;
- }
-
- state->resume_cb = __dummy_resume_cb;
- state->pause_cb = __dummy_pause_cb;
- state->step_in = __dummy_step_in;
- state->step_out = __dummy_step_out;
- state->show_up = __dummy_show_up;
- state->back_key_cb = __dummy_back_key_cb;
- state->home_key_cb = __dummy_home_key_cb;
- state->cw_rotation_cb = __dummy_cw_rotation_cb;
- state->ccw_rotation_cb = __dummy_ccw_rotation_cb;
- state->app_data_changed_cb = __dummy_app_data_changed_cb;
- state->app_badge_changed_cb = __dummy_app_badge_changed_cb;
-
- state->view_callback.drop_icon = __dummy_drop_icon_cb;
- state->view_callback.drag_hold_next = __dummy_drag_hold_next_cb;
- state->view_callback.drag_hold_prev = __dummy_drag_hold_prev_cb;
- state->view_callback.drag_hold_icon = __dummy_drag_hold_icon_cb;
- state->view_callback.tap_next = __dummy_tap_next_cb;
- state->view_callback.tap_prev = __dummy_tap_prev_cb;
- state->view_callback.tap_app_icon = __dummy_tap_app_icon_cb;
- state->view_callback.tap_focus_text = __dummy_tap_focus_text_cb;
- state->view_callback.tap_empty_area = __dummy_tap_empty_area_cb;
- state->view_callback.tap_hold_next = __dummy_tap_hold_next_cb;
- state->view_callback.tap_hold_prev = __dummy_tap_hold_prev_cb;
- state->view_callback.tap_hold_app_icon = __dummy_tap_hold_app_icon_cb;
- state->view_callback.tap_hold_focus_text = __dummy_tap_hold_focus_text_cb;
- state->view_callback.tap_hold_empty_area = __dummy_tap_hold_empty_area_cb;
- state->view_callback.swipe_left = __dummy_swipe_left_cb;
- state->view_callback.swipe_right = __dummy_swipe_right_cb;
-
- return state;
-}
-
-void __apps_state_free(APPS_STATE *state)
-{
- if (state == NULL) {
- _D("state is already null");
- return ;
- }
-
- free(state);
-}
-
-void apps_state_destroy(APPS_STATE *state)
-{
- __apps_state_free(state);
-}
diff --git a/src/apps/apps_state_edit.c b/src/apps/apps_state_edit.c
deleted file mode 100755
index 4010f77..0000000
--- a/src/apps/apps_state_edit.c
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <efl_extension.h>
-#include <package_manager.h>
-
-#include "util.h"
-#include "log.h"
-#include "apps/apps_view.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_state.h"
-#include "apps/apps_data.h"
-#include "apps/apps_data_package_manager.h"
-
-#define POPUP_CANCEL_IMAGE_PATH IMAGE_DIR"/tw_ic_popup_btn_delete.png"
-#define POPUP_OK_IMAGE_PATH IMAGE_DIR"/tw_ic_popup_btn_check.png"
-#define APPS_POPUP_EDJE_PATH EDJE_DIR"/circle/apps_popup.edj"
-#define PROGRESS_STOP_TIME 0.5
-
-static void __step_in(void);
-static void __step_out(void *next_state);
-static void __pause_cb(void);
-static void __back_key_cb(void);
-static void __turn_next_page(void);
-static void __turn_prev_page(void);
-static void __popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info);
-static void __progress_popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info);
-static void __uninstall_cancel_cb(void *data, Evas_Object *obj, void *event_info);
-static void __uninstall_app(APP_INFO *app_info, int pos);
-static void __open_uninstall_popup(char *app_id, char *pkg_id, char *icon_path);
-static void __set_state_normal(void);
-static void __set_state_reorder(void);
-static void __page_changed(void *data);
-static void __app_data_changed_cb();
-static void __uninstall_start_progress();
-static void __uninstall_end_progress();
-static Eina_Bool __progress_time_over(void *data);
-
-extern APPS_STATE *__apps_state_new(void);
-extern void __apps_control_manager_set_state(APPS_STATE *state);
-extern APPS_STATE *__apps_control_manager_get_normal_state(void);
-extern APPS_STATE *__apps_control_manager_get_reorder_state(void);
-
-static struct __edit_state_s {
- APPS_STATE *state;
- Evas_Object *popup;
- Evas_Object *progress_popup;
- Ecore_Timer *progress_timer;
- int progress_timer_count;
- int uninstall_complete;
-} s_info = {
- .state = NULL,
- .popup = NULL,
- .progress_popup = NULL,
- .progress_timer = NULL,
- .progress_timer_count = 0,
- .uninstall_complete = 0,
-};
-
-APPS_STATE *apps_state_create_edit(void)
-{
- _D("%s", __func__);
-
- APPS_STATE *state = __apps_state_new();
- if (state == NULL) {
- _E("failed to create state");
- return NULL;
- }
-
- state->step_in = __step_in;
- state->step_out = __step_out;
-
- state->pause_cb = __pause_cb;
-
- state->back_key_cb = __back_key_cb;
- state->cw_rotation_cb = __turn_next_page;
- state->ccw_rotation_cb = __turn_prev_page;
- state->app_data_changed_cb = __app_data_changed_cb;
-
- state->view_callback.tap_next = __turn_next_page;
- state->view_callback.tap_prev = __turn_prev_page;
- state->view_callback.tap_app_icon = __uninstall_app;
- state->view_callback.tap_hold_app_icon = __set_state_reorder;
- state->view_callback.swipe_left = __turn_next_page;
- state->view_callback.swipe_right = __turn_prev_page;
-
- s_info.state = state;
-
- return state;
-}
-
-static void __step_in(void)
-{
- _D("%s", __func__);
-
- apps_view_occupy_touch_callback(&(s_info.state->view_callback));
- apps_view_set_focus_text_edit();
- apps_view_set_editable_icon();
- apps_view_show_delete_button();
- apps_view_register_page_changed_cb(__page_changed);
-}
-
-static void __step_out(void *next_state)
-{
- _D("%s", __func__);
-
- APPS_STATE *reorder_state = __apps_control_manager_get_reorder_state();
-
- apps_view_deregister_page_changed_cb(__page_changed);
- apps_view_hide_delete_button();
- apps_view_occupy_touch_callback(NULL);
-
- if (((APPS_STATE *) next_state) != reorder_state) {
- apps_view_set_focus_text_none();
- apps_view_unset_editable_icon();
- }
-}
-
-static void __pause_cb(void)
-{
- if (s_info.popup != NULL) {
- __uninstall_cancel_cb(NULL, NULL, NULL);
- }
-
- __set_state_normal();
-}
-
-static void __back_key_cb(void)
-{
- if (s_info.popup != NULL) {
- __uninstall_cancel_cb(NULL, NULL, NULL);
- return ;
- }
-
- __set_state_normal();
-}
-
-static void __turn_next_page(void)
-{
- if (s_info.popup != NULL) {
- return ;
- }
-
- apps_view_turn_next_page();
-}
-
-static void __turn_prev_page(void)
-{
- if (s_info.popup != NULL) {
- return ;
- }
-
- apps_view_turn_prev_page();
-}
-
-static void __popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("%s", __func__);
-
- if (obj == NULL) {
- return;
- }
-
- evas_object_del(obj);
- obj = NULL;
-
- s_info.popup = NULL;
-
-}
-
-static void __progress_popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("%s", __func__);
-
- if (obj == NULL) {
- return;
- }
-
- evas_object_del(obj);
- obj = NULL;
-
- s_info.progress_popup = NULL;
-
-}
-
-static void __uninstall_cancel_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("%s", __func__);
-
- if (s_info.popup == NULL) {
- return;
- }
-
- elm_popup_dismiss(s_info.popup);
- s_info.popup = NULL;
-}
-
-static void __uninstall_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("%s", __func__);
-
- int id = 0;
- char *pkg_id = (char*)data;
- package_manager_request_h request;
-
- elm_popup_dismiss(s_info.popup);
- s_info.popup = NULL;
-
- __uninstall_start_progress();
- apps_package_manager_register_uninstall_end_progress_cb(__uninstall_end_progress);
-
- if (package_manager_request_create(&request) != PACKAGE_MANAGER_ERROR_NONE) {
- _E("Could not create unistall request. App: %s", pkg_id);
- return;
- }
- int ret = package_manager_request_set_mode(request, PACKAGE_MANAGER_REQUEST_MODE_DEFAULT);
- if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- _E("Could not set request mode. App: %s", pkg_id);
- return;
- }
- if (package_manager_request_uninstall(request, pkg_id, &id) != PACKAGE_MANAGER_ERROR_NONE) {
- LOGE("Could not uninstall application. App: %s", pkg_id);
- return;
- }
- if (package_manager_request_destroy(request) != PACKAGE_MANAGER_ERROR_NONE) {
- LOGE("Could not destroy unistall request. App: %s", pkg_id);
- return;
- }
-
-}
-
-static void __uninstall_app(APP_INFO *app_info, int pos)
-{
- if (app_info->is_removable) {
- __open_uninstall_popup(app_info->app_id, app_info->pkg_id, app_info->icon_path);
- }
-}
-
-static void __open_uninstall_popup(char *app_id, char *pkg_id, char *icon_path)
-{
- Evas_Object *popup;
- Evas_Object *btn;
- Evas_Object *icon;
- Evas_Object *layout;
-
- popup = elm_popup_add(apps_view_get_main_window());
- elm_object_style_set(popup, "circle");
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_smart_callback_add(popup, "dismissed", __popup_dismissed_cb, NULL);
-
- layout = elm_layout_add(popup);
- elm_layout_file_set(layout, util_get_res_file_path(APPS_POPUP_EDJE_PATH), "popup_uninstall");
- elm_object_part_text_set(layout, "elm.text.title", _("IDS_COM_POP_UNINSTALL_Q"));
-
- icon = elm_image_add(popup);
- elm_image_file_set(icon, icon_path, NULL);
- evas_object_size_hint_min_set(icon, APPS_ICON_W, APPS_ICON_H);
- evas_object_size_hint_max_set(icon, APPS_ICON_W, APPS_ICON_H);
- elm_object_part_content_set(layout, "elm.swallow.content", icon);
-
- elm_object_content_set(popup, layout);
-
- btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup/circle/left");
- evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_content_set(popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked", __uninstall_cancel_cb, NULL);
-
- icon = elm_image_add(btn);
- elm_image_file_set(icon, util_get_res_file_path(POPUP_CANCEL_IMAGE_PATH), NULL);
- evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_content_set(btn, "elm.swallow.content", icon);
- evas_object_show(icon);
-
- btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup/circle/right");
- evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_content_set(popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked", __uninstall_cb, pkg_id);
-
- icon = elm_image_add(btn);
- elm_image_file_set(icon, util_get_res_file_path(POPUP_OK_IMAGE_PATH), NULL);
- evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_content_set(btn, "elm.swallow.content", icon);
- evas_object_show(icon);
-
- s_info.popup = popup;
- evas_object_show(popup);
-}
-
-static void __set_state_normal(void)
-{
- APPS_STATE *normal_state = __apps_control_manager_get_normal_state();
- __apps_control_manager_set_state(normal_state);
-}
-
-static void __set_state_reorder(void)
-{
- APPS_STATE *reorder_state = __apps_control_manager_get_reorder_state();
- __apps_control_manager_set_state(reorder_state);
-}
-
-static void __page_changed(void *data)
-{
- _D("%s", __func__);
-
- apps_view_set_editable_icon();
- apps_view_show_delete_button();
-}
-
-static void __app_data_changed_cb()
-{
- _D("%s", __func__);
-
- apps_view_reload_page();
-
- apps_view_set_focus_text_edit();
- apps_view_show_delete_button();
-}
-
-static void __close_uninstall_progress()
-{
- elm_popup_dismiss(s_info.progress_popup);
- s_info.progress_popup = NULL;
- if (s_info.progress_timer != NULL) {
- ecore_timer_del(s_info.progress_timer);
- s_info.progress_timer = NULL;
- s_info.progress_timer_count = 0;
- }
-}
-
-static Eina_Bool __progress_time_over(void *data)
-{
- s_info.progress_timer_count++;
- if (s_info.progress_timer_count >= 2 && s_info.uninstall_complete == 1) {
- _D("It's the time for HIDING progress");
- __close_uninstall_progress();
- return ECORE_CALLBACK_CANCEL;
- } else if (s_info.progress_timer_count >= 4 && s_info.uninstall_complete == 0) {
- _D("Uninstall copletion is delaying, hide progress popup");
- __close_uninstall_progress();
- return ECORE_CALLBACK_CANCEL;
- }
-
- return ECORE_CALLBACK_RENEW;
-}
-
-static void __uninstall_start_progress()
-{
- _D("%s", __func__);
- Evas_Object *progress_popup = NULL;
- Evas_Object *progress_bar = NULL;
- Evas_Object *layout = NULL;
-
-
- progress_popup = elm_popup_add(apps_view_get_main_window());
- elm_object_style_set(progress_popup, "circle");
- evas_object_smart_callback_add(progress_popup, "dismissed", __progress_popup_dismissed_cb, NULL);
-
- layout = elm_layout_add(progress_popup);
- elm_layout_file_set(layout, util_get_res_file_path(APPS_POPUP_EDJE_PATH), "popup_progressbar");
- elm_object_content_set(progress_popup, layout);
- elm_object_part_text_set(layout, "elm.text.title", _("IDS_COM_POP_UNINSTALLING_ING"));
- evas_object_show(layout);
-
- progress_bar = elm_progressbar_add(layout);
- elm_object_style_set(progress_bar, "process/popup/small");
- evas_object_size_hint_align_set(progress_bar, EVAS_HINT_FILL, 0.5);
- evas_object_size_hint_weight_set(progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_progressbar_pulse(progress_bar, EINA_TRUE);
- elm_object_part_content_set(layout, "elm.swallow.content", progress_bar);
- evas_object_show(progress_bar);
-
- evas_object_show(progress_popup);
-
- s_info.progress_popup = progress_popup;
- s_info.progress_timer = ecore_timer_add(PROGRESS_STOP_TIME, __progress_time_over, NULL);
- s_info.uninstall_complete = 0;
-}
-
-static void __uninstall_end_progress()
-{
- _D("%s", __func__);
-
- s_info.uninstall_complete = 1;
- if (s_info.progress_timer_count > 2) {
- _D("Hide progress popup, deletion is a little bit late");
- __close_uninstall_progress();
- }
- apps_package_manager_deregister_uninstall_end_progress_cb(__uninstall_end_progress);
-}
diff --git a/src/apps/apps_state_normal.c b/src/apps/apps_state_normal.c
deleted file mode 100755
index ea63d4a..0000000
--- a/src/apps/apps_state_normal.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <package_manager.h>
-#include <Elementary.h>
-
-#include "log.h"
-#include "apps/apps.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_data.h"
-#include "apps/apps_state.h"
-#include "apps/apps_view.h"
-#include "apps/apps_view_icon.h"
-
-#define JUMP_COUNT 3
-#define JUMP_TIME_LIMIT 0.23
-#define QUEUE_SIZE 20
-#define ROTARY_EVENT_SKIP_TIME 1.0
-
-static void __step_in(void);
-static void __step_out(void *next_state);
-static void __back_key_cb(void);
-static void __show_up(void);
-static void __move_focus_next(void);
-static void __move_focus_prev(void);
-static void __show_up_complete(void *data);
-static void __page_changed(void *data);
-
-static void __cw_jump_cb(void);
-static void __ccw_jump_cb(void);
-
-static void __turn_next_page(void);
-static void __turn_prev_page(void);
-static void __execute_app(APP_INFO *app_info, int pos);
-static void __execute_focus_icon(APPS_ICON_INFO *icon_info, int pos);
-static void __set_state_edit(void);
-static void __tap_hold_view(void);
-static void __app_data_changed_cb(void);
-static void __app_badge_changed_cb(void);
-static void __push(double time);
-static double __read(int offset);
-static bool __is_jump_start_point(void);
-static bool __is_jump_end_point(void);
-static void __add_rotary_event_skip_timer(void);
-static void __delete_rotary_event_skip_timer(void);
-static Eina_Bool __rotary_event_skip_cb(void *data);
-
-extern APPS_STATE *__apps_state_new(void);
-extern void __apps_control_manager_set_state(APPS_STATE *state);
-extern APPS_STATE *__apps_control_manager_get_edit_state(void);
-
-static struct __normal_state_s {
- APPS_STATE *state;
- double time_queue[QUEUE_SIZE];
- int queue_front;
- Ecore_Timer *skip_timer;
-} s_info = {
- .state = NULL,
- .time_queue = { 0.0, },
- .queue_front = 0,
- .skip_timer = NULL,
-};
-
-APPS_STATE *apps_state_create_normal(void)
-{
- _D("%s", __func__);
-
- APPS_STATE *state = __apps_state_new();
- if (state == NULL) {
- _E("failed to create state");
- return NULL;
- }
-
- state->step_in = __step_in;
- state->step_out = __step_out;
- state->back_key_cb = __back_key_cb;
- state->show_up = __show_up;
- state->cw_rotation_cb = __move_focus_next;
- state->ccw_rotation_cb = __move_focus_prev;
- state->app_data_changed_cb = __app_data_changed_cb;
- state->app_badge_changed_cb = __app_badge_changed_cb;
-
- state->view_callback.tap_next = __turn_next_page;
- state->view_callback.tap_prev = __turn_prev_page;
- state->view_callback.tap_app_icon = __execute_app;
- state->view_callback.tap_focus_text = __execute_focus_icon;
- state->view_callback.tap_hold_next = __set_state_edit;
- state->view_callback.tap_hold_prev = __set_state_edit;
- state->view_callback.tap_hold_app_icon = __tap_hold_view;
- state->view_callback.tap_hold_focus_text = __set_state_edit;
- state->view_callback.tap_hold_empty_area = __set_state_edit;
- state->view_callback.swipe_left = __turn_next_page;
- state->view_callback.swipe_right = __turn_prev_page;
-
- s_info.state = state;
-
- return state;
-}
-
-static void __step_in(void)
-{
- _D("%s", __func__);
-
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
-
- apps_view_show_badge_count();
-
- apps_view_occupy_touch_callback(&(s_info.state->view_callback));
- apps_view_register_page_changed_cb(__page_changed);
-}
-
-static void __step_out(void *next_state)
-{
- _D("%s", __func__);
-
- __delete_rotary_event_skip_timer();
-
- apps_view_deregister_page_changed_cb(__page_changed);
- apps_view_occupy_touch_callback(NULL);
-
- apps_view_hide_badge_count();
-
- apps_view_hide_focus();
- apps_view_set_focus_text_none();
-}
-
-static void __back_key_cb(void)
-{
- _D("%s", __func__);
-
- apps_hide();
-}
-
-static void __move_focus_next(void)
-{
- double current_time = ecore_time_get();
- if (s_info.skip_timer != NULL) {
- _D("skip rotary event");
- return ;
- }
-
- __push(current_time);
-
- if (__is_jump_end_point()) {
- __cw_jump_cb();
- return ;
- }
-
- apps_view_move_focus_next();
-}
-
-static void __move_focus_prev(void)
-{
- double current_time = ecore_time_get();
- if (s_info.skip_timer != NULL) {
- _D("skip rotary event");
- return ;
- }
-
- __push(-current_time);
-
- if (__is_jump_start_point()) {
- __ccw_jump_cb();
- return ;
- }
-
- apps_view_move_focus_prev();
-}
-
-static void __show_up(void)
-{
- _D("%s", __func__);
-
- apps_view_set_focus_text_icon();
-
- apps_view_register_page_changed_cb(__page_changed);
- apps_view_register_show_complete_cb(__show_up_complete);
-
- apps_view_show_up();
-}
-
-static void __show_up_complete(void *data)
-{
- _D("%s", __func__);
-
- apps_view_deregister_show_complete_cb(__show_up_complete);
-
- __step_in();
-}
-
-static void __page_changed(void *data)
-{
- _D("%s", __func__);
-
- __step_out(NULL);
- apps_view_register_show_complete_cb(__show_up_complete);
-}
-
-static void __cw_jump_cb(void)
-{
- _D("%s", __func__);
-
- apps_view_move_focus_end();
- __add_rotary_event_skip_timer();
-}
-
-static void __ccw_jump_cb(void)
-{
- _D("%s", __func__);
-
- apps_view_move_focus_start();
- __add_rotary_event_skip_timer();
-}
-
-static void __turn_next_page(void)
-{
- apps_view_turn_next_page();
-}
-
-static void __turn_prev_page(void)
-{
- apps_view_turn_prev_page();
-}
-
-static void __execute_app(APP_INFO *app_info, int pos)
-{
- app_control_h app_control_handle = NULL;
-
- apps_data_set_focus_pos(pos);
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
-
- if (app_control_create(&app_control_handle) != APP_CONTROL_ERROR_NONE) {
- _E("[FAILED][app_control_create]");
- return;
- }
-
- if (app_control_set_operation(app_control_handle, APP_CONTROL_OPERATION_MAIN) != APP_CONTROL_ERROR_NONE) {
- _E("[FAILED][app_control_set_operation]");
- app_control_destroy(app_control_handle);
- return;
- }
-
- if (app_control_set_app_id(app_control_handle, app_info->app_id) != APP_CONTROL_ERROR_NONE) {
- _E("[FAILED][app_control_set_app_id]");
- app_control_destroy(app_control_handle);
- return;
- }
-
- if (app_control_send_launch_request(app_control_handle, NULL, NULL) != APP_CONTROL_ERROR_NONE) {
- _E("[FAILED][app_control_send_launch_request]");
- app_control_destroy(app_control_handle);
- return;
- }
- app_control_destroy(app_control_handle);
-}
-
-static void __execute_focus_icon(APPS_ICON_INFO *icon_info, int pos)
-{
- if (icon_info->icon_type == ICON_TYPE_NEXT) {
- __turn_next_page();
- } else if (icon_info->icon_type == ICON_TYPE_PREV) {
- __turn_prev_page();
- } else if (icon_info->icon_type == ICON_TYPE_APP){
- APP_INFO *info = apps_data_get_nth_app_info(icon_info->icon_idx);
- if (info != NULL) {
- __execute_app(info, pos);
- }
- }
-}
-
-static void __set_state_edit(void)
-{
- APPS_STATE *edit_state = __apps_control_manager_get_edit_state();
- __apps_control_manager_set_state(edit_state);
-}
-
-static void __tap_hold_view(void)
-{
- __set_state_edit();
-}
-
-static void __app_data_changed_cb(void)
-{
- _D("%s", __func__);
-
- apps_view_reload_page();
-
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
- apps_view_show_badge_count();
-}
-
-static void __app_badge_changed_cb(void)
-{
- apps_view_show_badge_count();
-}
-
-static void __push(double cur_time)
-{
- s_info.time_queue[s_info.queue_front] = cur_time;
- s_info.queue_front = (s_info.queue_front + 1) % QUEUE_SIZE;
-}
-
-static double __read(int offset)
-{
- int idx = (QUEUE_SIZE + s_info.queue_front - 1 + offset) % QUEUE_SIZE;
- return s_info.time_queue[idx];
-}
-
-static bool __is_jump_start_point(void)
-{
- int i = 0;
- double history[JUMP_COUNT];
- for (i = 0; i < JUMP_COUNT; i++) {
- history[i] = __read(-i);
- if (history[i] >= 0.0)
- return false;
- }
-
- return (history[JUMP_COUNT - 1] - history[0]) <= JUMP_TIME_LIMIT;
-}
-
-static bool __is_jump_end_point(void)
-{
- int i = 0;
- double history[JUMP_COUNT];
- for (i = 0; i < JUMP_COUNT; i++) {
- history[i] = __read(-i);
- if (history[i] <= 0.0)
- return false;
- }
-
- return (history[0] - history[JUMP_COUNT - 1]) <= JUMP_TIME_LIMIT;
-}
-
-static void __add_rotary_event_skip_timer(void)
-{
- __delete_rotary_event_skip_timer();
-
- s_info.skip_timer = ecore_timer_add(ROTARY_EVENT_SKIP_TIME, __rotary_event_skip_cb, NULL);
-}
-
-static void __delete_rotary_event_skip_timer(void)
-{
- if (s_info.skip_timer != NULL) {
- ecore_timer_del(s_info.skip_timer);
- s_info.skip_timer = NULL;
- }
-}
-
-static Eina_Bool __rotary_event_skip_cb(void *data)
-{
- s_info.skip_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
-}
-
diff --git a/src/apps/apps_state_reorder.c b/src/apps/apps_state_reorder.c
deleted file mode 100755
index ee1c53e..0000000
--- a/src/apps/apps_state_reorder.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "log.h"
-#include "apps/apps_view.h"
-#include "apps/apps_state.h"
-
-static void __step_in(void);
-static void __step_out(void *next_state);
-static void __pause_cb(void);
-static void __back_key_cb(void);
-static void __cw_rotation_cb(void);
-static void __ccw_rotation_cb(void);
-static void __app_data_changed_cb(void);
-static void __drop_icon(void);
-static void __drag_hold_next(void);
-static void __drag_hold_prev(void);
-static void __drag_hold_icon(int picked_icon_idx, int hold_icon_idx);
-static void __push_animation_complete(void *data);
-static void __set_state_edit(void);
-static void __page_changed(void *data);
-
-extern APPS_STATE *__apps_state_new(void);
-extern void __apps_control_manager_set_state(APPS_STATE *state);
-extern APPS_STATE *__apps_control_manager_get_edit_state(void);
-extern bool __apps_view_circle_icon_pick_up(void);
-extern void __apps_view_circle_icon_pick_up_cancel(void);
-
-static struct __reorder_state_s {
- APPS_STATE *state;
- APP_INFO *picked_app;
-} s_info = {
- .state = NULL,
- .picked_app = NULL,
-};
-
-APPS_STATE *apps_state_create_reorder(void)
-{
- _D("%s", __func__);
-
- APPS_STATE *state = __apps_state_new();
- if (state == NULL) {
- _E("failed to create state");
- return NULL;
- }
-
- state->step_in = __step_in;
- state->step_out = __step_out;
-
- state->pause_cb = __pause_cb;
-
- state->back_key_cb = __back_key_cb;
- state->cw_rotation_cb = __cw_rotation_cb;
- state->ccw_rotation_cb = __ccw_rotation_cb;
- state->app_data_changed_cb = __app_data_changed_cb;
-
- state->view_callback.drop_icon = __drop_icon;
- state->view_callback.drag_hold_next = __drag_hold_next;
- state->view_callback.drag_hold_prev = __drag_hold_prev;
- state->view_callback.drag_hold_icon = __drag_hold_icon;
-
- s_info.state = state;
-
- return state;
-}
-
-static void __step_in(void)
-{
- bool ret = false;
-
- apps_view_set_focus_text_edit();
- apps_view_occupy_touch_callback(&(s_info.state->view_callback));
-
- apps_view_register_page_changed_cb(__page_changed);
-
- ret = __apps_view_circle_icon_pick_up();
- if (ret == false) {
- _E("Failed to pick the icon up");
- __set_state_edit();
- }
-}
-
-static void __step_out(void *next_state)
-{
- __apps_view_circle_icon_pick_up_cancel();
- apps_view_reload_page();
- apps_view_occupy_touch_callback(NULL);
- apps_view_set_focus_text_none();
-}
-
-static void __pause_cb(void)
-{
- __set_state_edit();
-}
-
-static void __back_key_cb(void)
-{
- __set_state_edit();
-}
-
-static void __cw_rotation_cb(void)
-{
- __set_state_edit();
-}
-
-static void __ccw_rotation_cb(void)
-{
- __set_state_edit();
-}
-
-static void __app_data_changed_cb(void)
-{
- _D("%s", __func__);
-
- apps_view_reload_page();
-
- apps_view_set_editable_icon();
-}
-
-static void __drop_icon(void)
-{
- _D("%s", __func__);
-
- __set_state_edit();
-}
-
-static void __drag_hold_next(void)
-{
- apps_view_turn_next_page();
-}
-
-static void __drag_hold_prev(void)
-{
- apps_view_turn_prev_page();
-}
-
-static void __drag_hold_icon(int picked_icon_idx, int hold_icon_idx)
-{
- int idx = picked_icon_idx > hold_icon_idx ? picked_icon_idx - 1 : picked_icon_idx + 1;
- int inc = picked_icon_idx > hold_icon_idx ? -1 : 1;
- Eina_List *app_list = apps_data_get_applist();
-
- _D("move icon %d >>>>> %d", picked_icon_idx, hold_icon_idx);
- apps_view_register_show_complete_cb(__push_animation_complete);
-
- APP_INFO *item = eina_list_nth(app_list, picked_icon_idx);
- item->index = hold_icon_idx;
- while (idx != hold_icon_idx + inc) {
- APP_INFO *item = eina_list_nth(app_list, idx);
- item->index -= inc;
-
- idx += inc;
- }
-}
-
-static void __push_animation_complete(void *data)
-{
- _D("%s", __func__);
-
- apps_view_deregister_show_complete_cb(__push_animation_complete);
-
- apps_data_update_list_order();
-}
-
-static void __set_state_edit(void)
-{
- APPS_STATE *edit_state = __apps_control_manager_get_edit_state();
- __apps_control_manager_set_state(edit_state);
-}
-
-static void __page_changed(void *data)
-{
- _D("%s", __func__);
-
- apps_view_set_editable_icon();
-}
diff --git a/src/apps/apps_view_base.c b/src/apps/apps_view_base.c
deleted file mode 100755
index 9d93fc4..0000000
--- a/src/apps/apps_view_base.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_view.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_edje_conf.h"
-#include "apps/apps_callback_manager.h"
-#include "apps/apps_view_circle_touch_handler.h"
-#include "log.h"
-#include "util.h"
-
-#define __WINDOW_SHOW_ISSUE_WIN_SHOW_TIME
-
-static struct __apps_view_s {
- Evas_Object *base_win;
- Evas_Object *base_layout;
- Evas_Object *icon_page_layout;
- Evas_Object *indicator_layout;
- apps_callback_t *show_complete_cb_stack;
-#ifdef __WINDOW_SHOW_ISSUE_WIN_SHOW_TIME
- Ecore_Idler *window_show_handler;
-#endif
-} s_info = {
- .base_win = NULL,
- .base_layout = NULL,
- .icon_page_layout = NULL,
- .indicator_layout = NULL,
- .show_complete_cb_stack = NULL,
-#ifdef __WINDOW_SHOW_ISSUE_WIN_SHOW_TIME
- .window_show_handler = NULL,
-#endif
-};
-
-void __apps_view_base_show_complete(void);
-
-static ERROR_E __create_ui_object(void);
-static void __destroy_ui_object(void);
-static Evas_Object* __create_base_window(void);
-
-extern void __apps_view_circle_init(void);
-extern Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win);
-extern Evas_Object *__apps_view_circle_icon_page_create(Evas_Object* base_layout);
-extern Evas_Object *__apps_view_circle_indicator_create(
- Evas_Object* base_layout,
- apps_callback_t *page_count_changed_cb_stack,
- apps_callback_t *page_focus_changed_cb_stack);
-extern void __apps_view_circle_icon_page_destroy(Evas_Object* icon_page_layout);
-extern void __apps_view_circle_indicator_destory(Evas_Object* indicator_layout);
-extern void __apps_view_circle_icon_show_up(APPS_DIRECTION start_direction);
-extern void __apps_view_circle_icon_page_get(void);
-extern apps_callback_t *__apps_view_circle_icon_get_page_count_cb_stack(void);
-extern apps_callback_t *__apps_view_circle_icon_get_page_focus_cb_stack(void);
-extern void __apps_view_circle_icon_hide(void);
-
-ERROR_E apps_view_init(void)
-{
- _D("%s", __func__);
-
- if (__create_ui_object() != ERROR_NONE) {
- goto __fail;
- }
-
- if (apps_view_circle_touch_handler_init() != ERROR_NONE) {
- goto __fail;
- }
-
- s_info.show_complete_cb_stack = apps_callback_manager_new();
- if (s_info.show_complete_cb_stack == NULL) {
- _E("Failed to allocate memory for show complete cb stack");
- goto __fail;
- }
-
- __apps_view_circle_init();
-
- return ERROR_NONE;
-
-__fail :
- apps_view_circle_touch_handler_fini();
- __destroy_ui_object();
- return ERROR_FAILED;
-}
-
-void apps_view_fini(void)
-{
- _D("%s", __func__);
-
- apps_callback_manager_free(s_info.show_complete_cb_stack);
- s_info.show_complete_cb_stack = NULL;
- apps_view_circle_touch_handler_fini();
- __destroy_ui_object();
-}
-
-Evas_Object *apps_view_get_main_window(void)
-{
- return s_info.base_win;
-}
-
-static ERROR_E __create_ui_object(void)
-{
- _D("%s", __func__);
-
- s_info.base_win = __create_base_window();
- if (s_info.base_win == NULL)
- goto __fail;
-
- s_info.base_layout = __apps_view_circle_create_base_layout(s_info.base_win);
- if (s_info.base_layout == NULL)
- goto __fail;
-
- s_info.icon_page_layout = __apps_view_circle_icon_page_create(s_info.base_layout);
- if (s_info.icon_page_layout == NULL)
- goto __fail;
-
- s_info.indicator_layout = __apps_view_circle_indicator_create(s_info.base_layout,
- __apps_view_circle_icon_get_page_count_cb_stack(),
- __apps_view_circle_icon_get_page_focus_cb_stack());
- if (s_info.indicator_layout == NULL)
- goto __fail;
-
- return ERROR_NONE;
-
-__fail:
- __destroy_ui_object();
- return ERROR_FAILED;
-}
-
-static void __destroy_ui_object(void)
-{
- __apps_view_circle_indicator_destory(s_info.indicator_layout);
- __apps_view_circle_icon_page_destroy(s_info.icon_page_layout);
- destroy_evas_object(s_info.base_layout);
- destroy_evas_object(s_info.base_win);
-
- s_info.indicator_layout = NULL;
- s_info.icon_page_layout = NULL;
- s_info.base_layout = NULL;
- s_info.base_win = NULL;
-}
-
-static Evas_Object* __create_base_window(void)
-{
- _D("%s", __func__);
-
- Evas_Object * win;
- int w, h;
- elm_config_accel_preference_set("3d");
- win = elm_win_util_standard_add(APPS, APPS);
- if (win == NULL) {
- _E("Failed to add apps window");
- goto __fail;
- }
- elm_win_screen_size_get(win, NULL, NULL, &w, &h);
- if (!apps_view_conf_is_supported_resolution(w, h)) {
- _E("%dx%d is not supported", w, h);
- goto __fail;
- }
- apps_view_conf_set_resolution(w, h);
-
-#ifdef __WINDOW_SHOW_ISSUE_WIN_SHOW_TIME
- evas_object_resize(win, w, h);
- evas_object_hide(win);
-#else
- evas_object_hide(win);
-#endif
- return win;
-
-__fail:
- destroy_evas_object(win);
- return NULL;
-}
-
-#ifdef __WINDOW_SHOW_ISSUE_WIN_SHOW_TIME
-static Eina_Bool __window_show_cb(void *data)
-{
- _D("%s", __func__);
-
- evas_object_show(s_info.indicator_layout);
- evas_object_show(s_info.icon_page_layout);
-
- evas_object_show(s_info.base_layout);
- evas_object_show(s_info.base_win);
- elm_win_activate(s_info.base_win);
-
- __apps_view_circle_icon_page_get();
- __apps_view_circle_icon_show_up(RIGHT);
-
- s_info.window_show_handler = NULL;
-
- return ECORE_CALLBACK_CANCEL;
-}
-#endif
-
-void apps_view_show_up(void)
-{
- _D("%s", __func__);
-
-#ifdef __WINDOW_SHOW_ISSUE_WIN_SHOW_TIME
- if (s_info.window_show_handler != NULL) {
- ecore_idler_del(s_info.window_show_handler);
- s_info.window_show_handler = NULL;
- }
-
- s_info.window_show_handler = ecore_idler_add(__window_show_cb, NULL);
- if (s_info.window_show_handler == NULL) {
- _E("Failed to add apps show idler");
- __destroy_ui_object();
- return ;
- }
-#else
- evas_object_show(s_info.indicator_layout);
- evas_object_show(s_info.icon_page_layout);
-
- evas_object_show(s_info.base_layout);
- evas_object_show(s_info.base_win);
- elm_win_activate(s_info.base_win);
-
- __apps_view_circle_icon_page_get();
- __apps_view_circle_icon_show_up(RIGHT);
-#endif
-}
-
-void apps_view_hide(void)
-{
- evas_object_hide(s_info.base_win);
- evas_object_hide(s_info.base_layout);
- __apps_view_circle_icon_hide();
- evas_object_hide(s_info.icon_page_layout);
- evas_object_hide(s_info.indicator_layout);
-}
-
-bool apps_view_register_show_complete_cb(void(*show_complete_cb)(void *data))
-{
- bool ret = false;
-
- ret = apps_callback_manager_register_cb(s_info.show_complete_cb_stack, show_complete_cb);
- if (ret == false) {
- _E("Failed to register show complete cb");
- }
-
- return ret;
-}
-
-void apps_view_deregister_show_complete_cb(void(*show_complete_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.show_complete_cb_stack, show_complete_cb);
-}
-
-void __apps_view_base_show_complete(void)
-{
- _D("%s", __func__);
-
- apps_callback_manager_execute_cb(s_info.show_complete_cb_stack, NULL);
-}
diff --git a/src/apps/apps_view_circle.c b/src/apps/apps_view_circle.c
deleted file mode 100755
index ae62c2d..0000000
--- a/src/apps/apps_view_circle.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_animator.h"
-#include "apps/apps_view.h"
-#include "apps/apps_view_icon.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_edje_conf.h"
-#include "apps/apps_data.h"
-#include "apps/apps_conf.h"
-#include "util.h"
-#include "log.h"
-
-static struct __view_circle_s {
- Evas_Object *base_layout;
- Evas_Object *focus_point;
- bool is_enable_focus_text;
- APPS_VIEW_CALLBACK *callback;
-} s_info = {
- .base_layout = NULL,
- .focus_point = NULL,
- .is_enable_focus_text = true,
- .callback = NULL,
-};
-
-double ICON_ANGLE[APPS_ICON_COUNT_PER_PAGE] = {
- APPS_ICON_BASE_ANGLE * 1, APPS_ICON_BASE_ANGLE * 2,
- APPS_ICON_BASE_ANGLE * 3, APPS_ICON_BASE_ANGLE * 4,
- APPS_ICON_BASE_ANGLE * 5, APPS_ICON_BASE_ANGLE * 6,
- APPS_ICON_BASE_ANGLE * 7, APPS_ICON_BASE_ANGLE * 8,
- APPS_ICON_BASE_ANGLE * 9, APPS_ICON_BASE_ANGLE * 10,
-};
-
-#define BASE_LAYOUT_EDJE EDJE_DIR"/circle/apps_base_layout_circle.edj"
-#define FOCUS_POINT_IMAGE_PATH IMAGE_DIR"/b_home_screen_focus_point.png"
-
-void __apps_view_circle_init(void);
-Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win);
-void __apps_view_circle_get_pos(int radius, double angle, int *x, int *y);
-void __apps_view_circle_swipe_left(void);
-void __apps_view_circle_swipe_right(void);
-void __apps_view_circle_tap_hold_focus_text(void);
-void __apps_view_circle_tap_hold_empty_area(void);
-void __apps_view_circle_tap_hold_icon(int touch_area);
-void __apps_view_circle_focus_text_press(void);
-void __apps_view_circle_focus_text_release(void);
-
-static Evas_Object *__create_size_setter(Evas_Object *layout, COLOR color);
-static Evas_Object *__create_focus_point(Evas_Object *layout);
-static void __set_focus_text(char *label);
-static void __move_focus_next(void);
-static void __move_focus_prev(void);
-static void __move_focus_start(void);
-static void __move_focus_end(void);
-static void __show_focus_point(void);
-static void __hide_focus_point(void);
-static void __set_focus_dim();
-static void __set_focus_default();
-
-extern void __apps_view_circle_icon_show_focus(void);
-extern void __apps_view_circle_icon_hide_focus(void);
-extern void __apps_view_circle_animator_focus_point_bound(
- Evas_Object *layout, double cur_angle, APPS_ROTATION rotation,
- int radius, int layout_width, int layout_height, double duration, void(*cb)(void));
-extern void __apps_view_circle_icon_get_info_by_pos(APPS_ICON_INFO *icon, int page, int pos);
-extern int __apps_view_circle_icon_get_current_icon_count(void);
-extern void __apps_view_circle_icon_set_touch_callback(APPS_VIEW_CALLBACK *callback);
-extern void __apps_view_circle_animator_rotation(
- Eina_List *layout_list, Eina_List *cur_angle_list, Eina_List *dest_angle_list,
- int radius, int layout_width, int layout_height, double duration, ANIMATOR_OPTION option, void(*cb)(void));
-
-void apps_view_show_focus(void)
-{
- _D("%s", __func__);
-
- __show_focus_point();
- __apps_view_circle_icon_show_focus();
-}
-
-void apps_view_hide_focus(void)
-{
- _D("%s", __func__);
-
- __hide_focus_point();
- __apps_view_circle_icon_hide_focus();
-}
-
-void apps_view_set_focus_text_none(void)
-{
- __set_focus_default();
- __set_focus_text("");
-}
-
-void apps_view_set_focus_text_edit(void)
-{
- __set_focus_default();
- __set_focus_text(_("IDS_HS_TBOPT_EDIT_MODE"));
-}
-
-void apps_view_set_focus_text_icon(void)
-{
- _D("%s", __func__);
-
- APPS_ICON_INFO item;
- int page = apps_data_get_focus_page();
- int pos = apps_data_get_focus_pos();
-
- __apps_view_circle_icon_get_info_by_pos(&item, page, pos);
-
- __set_focus_default();
-
- if (item.icon_type == ICON_TYPE_INIT) __set_focus_text("");
- else if (item.icon_type == ICON_TYPE_PREV) __set_focus_text(_("IDS_IDLE_OPT_SMARTSEARCH_PREV_PAGE"));
- else if (item.icon_type == ICON_TYPE_NEXT) __set_focus_text(_("IDS_IDLE_OPT_SMARTSEARCH_NEXT_PAGE"));
- else if (item.icon_type == ICON_TYPE_APP) {
- APP_INFO *app = apps_data_get_nth_app_info(item.icon_idx);
- if (app == NULL) __set_focus_text("");
- else __set_focus_text(app->label);
- }
-}
-
-void apps_view_move_focus_next(void)
-{
- _D("%s", __func__);
-
- APPS_ICON_INFO item;
- int page = apps_data_get_focus_page();
- int pos = apps_data_get_focus_pos();
-
- __apps_view_circle_icon_get_info_by_pos(&item, page, pos);
-
- if (item.icon_type == ICON_TYPE_INIT) {
- _E("failed to get focus icon");
- } else if (item.icon_type == ICON_TYPE_NEXT) {
- apps_view_turn_next_page();
- } else {
- if (item.icon_idx == apps_data_get_list_count() - 1) {
- __apps_view_circle_animator_focus_point_bound(
- s_info.focus_point, ICON_ANGLE[pos], CLOCKWISE,
- APPS_FOCUS_POINT_RADIUS, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H, APPS_FOCUS_BOUND_TIME, __show_focus_point);
- } else {
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
-
- layout_list = eina_list_append(layout_list, s_info.focus_point);
- cur_angle_list = eina_list_append(cur_angle_list, &ICON_ANGLE[pos]);
- dest_angle_list = eina_list_append(dest_angle_list, &ICON_ANGLE[pos + 1]);
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_FOCUS_POINT_RADIUS, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H, APPS_FOCUS_MOVE_TIME, ANIMATION_OPTION_DEFAULT, __move_focus_next);
- }
- }
-}
-
-void apps_view_move_focus_end(void)
-{
- _D("%s", __func__);
-
- int cur_pos = apps_data_get_focus_pos();
- int end_pos = __apps_view_circle_icon_get_current_icon_count() - 1;
-
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
-
- layout_list = eina_list_append(layout_list, s_info.focus_point);
- cur_angle_list = eina_list_append(cur_angle_list, &ICON_ANGLE[cur_pos]);
- dest_angle_list = eina_list_append(dest_angle_list, &ICON_ANGLE[end_pos]);
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_FOCUS_POINT_RADIUS, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H, APPS_FOCUS_JUMP_TIME, ANIMATION_OPTION_DEFAULT, __move_focus_end);
-}
-
-void apps_view_move_focus_prev(void)
-{
- _D("%s", __func__);
-
- APPS_ICON_INFO item;
- int page = apps_data_get_focus_page();
- int pos = apps_data_get_focus_pos();
-
- __apps_view_circle_icon_get_info_by_pos(&item, page, pos);
-
- if (item.icon_type == ICON_TYPE_INIT) {
- _E("failed to get focus icon");
- } else if (item.icon_type == ICON_TYPE_PREV) {
- apps_view_turn_prev_page();
- } else {
- if (item.icon_idx == 0) {
- __apps_view_circle_animator_focus_point_bound(
- s_info.focus_point, ICON_ANGLE[0], COUNT_CLOCKWISE,
- APPS_FOCUS_POINT_RADIUS, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H, APPS_FOCUS_BOUND_TIME, __show_focus_point);
- } else {
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
-
- layout_list = eina_list_append(layout_list, s_info.focus_point);
- cur_angle_list = eina_list_append(cur_angle_list, &ICON_ANGLE[pos]);
- dest_angle_list = eina_list_append(dest_angle_list, &ICON_ANGLE[pos - 1]);
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_FOCUS_POINT_RADIUS, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H, APPS_FOCUS_MOVE_TIME, ANIMATION_OPTION_DEFAULT, __move_focus_prev);
- }
- }
-}
-
-void apps_view_move_focus_start(void)
-{
- _D("%s", __func__);
-
- int cur_pos = apps_data_get_focus_pos();
-
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
-
- layout_list = eina_list_append(layout_list, s_info.focus_point);
- cur_angle_list = eina_list_append(cur_angle_list, &ICON_ANGLE[cur_pos]);
- dest_angle_list = eina_list_append(dest_angle_list, &ICON_ANGLE[0]);
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_FOCUS_POINT_RADIUS, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H, APPS_FOCUS_JUMP_TIME, ANIMATION_OPTION_DEFAULT, __move_focus_start);
-}
-
-void apps_view_occupy_touch_callback(APPS_VIEW_CALLBACK *callback)
-{
- s_info.callback = callback;
- __apps_view_circle_icon_set_touch_callback(callback);
-}
-
-void __apps_view_circle_init(void)
-{
- apps_data_set_focus_page(0);
- apps_data_set_focus_pos(0);
-}
-
-Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win)
-{
- _D("%s", __func__);
-
- Evas_Object *layout = NULL;
- Evas_Object *size_setter = NULL;
-
- layout = elm_layout_add(base_win);
- if (layout == NULL) {
- _E("Failed to add apps layout");
- goto __fail;
- }
-
- if (!elm_layout_file_set(layout, util_get_res_file_path(BASE_LAYOUT_EDJE), BASE_LAYOUT)) {
- _E("Failed to set layout file");
- goto __fail;
- }
-
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(base_win, layout);
- evas_object_hide(layout);
-
- size_setter = __create_size_setter(layout, DARK_BG);
- if (size_setter == NULL) {
- _E("Failed to create size setter");
- goto __fail;
- }
- elm_object_part_content_set(layout, SIZE_SETTER, size_setter);
-
- s_info.focus_point = __create_focus_point(layout);
- if (s_info.focus_point == NULL) {
- _E("Failed to create focus point");
- goto __fail;
- }
-
- s_info.base_layout = layout;
-
- return layout;
-
-__fail:
- destroy_evas_object(s_info.focus_point);
- destroy_evas_object(size_setter);
- destroy_evas_object(layout);
-
- s_info.focus_point = NULL;
- return NULL;
-}
-
-void __apps_view_circle_get_pos(int radius, double angle, int *x, int *y)
-{
- *x = radius * sin(angle * PI / 180);
- *y = radius * cos(angle * PI / 180);
-
- *x = *x + WINDOW_CENTER_X;
- *y = WINDOW_CENTER_Y - *y;
-}
-
-void __apps_view_circle_swipe_left(void)
-{
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->swipe_left)();
-}
-
-void __apps_view_circle_swipe_right(void)
-{
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->swipe_right)();
-}
-
-void __apps_view_circle_tap_hold_focus_text(void)
-{
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->tap_hold_focus_text)();
-}
-
-void __apps_view_circle_tap_hold_empty_area(void)
-{
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->tap_hold_empty_area)();
-}
-
-void __apps_view_circle_tap_hold_icon(int touch_area)
-{
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->tap_hold_app_icon)();
-}
-
-void __apps_view_circle_set_focus_text_enable(bool is_enable)
-{
- s_info.is_enable_focus_text = is_enable;
-}
-
-void __apps_view_circle_focus_text_press(void)
-{
- if (s_info.is_enable_focus_text == false) {
- return ;
- }
-
- __set_focus_dim();
-}
-
-void __apps_view_circle_focus_text_release(void)
-{
- if (s_info.is_enable_focus_text == false) {
- return ;
- }
-
- __set_focus_default();
-}
-
-static Evas_Object *__create_size_setter(Evas_Object *layout, COLOR color)
-{
- Evas_Object *rect = NULL;
-
- rect = evas_object_rectangle_add(evas_object_evas_get(layout));
- if (rect == NULL) {
- return NULL;
- }
-
- evas_object_size_hint_min_set(rect, WINDOW_W, WINDOW_H);
- evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_color_set(rect, color.r, color.g, color.b, color.a);
-
- return rect;
-}
-
-static Evas_Object *__create_focus_point(Evas_Object *layout)
-{
- Evas_Object *focus_point = NULL;
-
- focus_point = elm_image_add(layout);
- if (focus_point == NULL) {
- _E("Failed to add focus point image");
- return NULL;
- }
-
- if (EINA_FALSE == elm_image_file_set(focus_point, util_get_res_file_path(FOCUS_POINT_IMAGE_PATH), NULL)) {
- _E("Failed to set focus point image file");
- evas_object_del(focus_point);
- return NULL;
- }
-
- evas_object_resize(focus_point, APPS_FOCUS_POINT_W, APPS_FOCUS_POINT_H);
- evas_object_move(focus_point, OUTSIDE_X, OUTSIDE_Y);
-
- evas_object_repeat_events_set(focus_point, EINA_TRUE);
-
- evas_object_hide(focus_point);
-
- return focus_point;
-}
-
-static void __set_focus_text(char *label)
-{
- char text[TEXT_MAX] = { 0, };
- snprintf(text, sizeof(text), FONT_DEFAULT, TEXT_SIZE_FOCUS_LABEL, label);
- elm_object_part_text_set(s_info.base_layout, FOCUS_TEXT, text);
-}
-
-static void __move_focus_next(void)
-{
- int cur = apps_data_get_focus_pos();
- apps_data_set_focus_pos(cur + 1);
-
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
-}
-
-static void __move_focus_end(void)
-{
- apps_data_set_focus_pos(__apps_view_circle_icon_get_current_icon_count() - 1);
-
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
-}
-
-static void __move_focus_prev(void)
-{
- int cur = apps_data_get_focus_pos();
- apps_data_set_focus_pos(cur - 1);
-
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
-}
-
-static void __move_focus_start(void)
-{
- apps_data_set_focus_pos(0);
-
- apps_view_set_focus_text_icon();
- apps_view_show_focus();
-}
-
-static void __show_focus_point(void)
-{
- _D("%s", __func__);
-
- int x = 0;
- int y = 0;
- int pos = apps_data_get_focus_pos();
- __apps_view_circle_get_pos(APPS_FOCUS_POINT_RADIUS, ICON_ANGLE[pos], &x, &y);
-
- x -= APPS_FOCUS_POINT_W / 2;
- y -= APPS_FOCUS_POINT_H / 2;
-
- evas_object_move(s_info.focus_point, x, y);
- evas_object_show(s_info.focus_point);
-}
-
-static void __hide_focus_point(void)
-{
- _D("%s", __func__);
-
- evas_object_move(s_info.focus_point, OUTSIDE_X, OUTSIDE_Y);
- evas_object_hide(s_info.focus_point);
-}
-
-static void __set_focus_dim()
-{
- Evas_Object *edje = NULL;
-
- edje = elm_layout_edje_get(s_info.base_layout);
- edje_object_signal_emit(edje, SIGNAL_APPS_FOCUS_TEXT_PRESSED, SIGNAL_SOURCE);
-
- evas_object_color_set(s_info.focus_point, ICON_DIM.r, ICON_DIM.g, ICON_DIM.b, ICON_DIM.a);
-}
-
-static void __set_focus_default()
-{
- Evas_Object *edje = NULL;
-
- edje = elm_layout_edje_get(s_info.base_layout);
- edje_object_signal_emit(edje, SIGNAL_APPS_FOCUS_TEXT_RELEASED, SIGNAL_SOURCE);
-
- evas_object_color_set(s_info.focus_point, ICON_DEFAULT.r, ICON_DEFAULT.g, ICON_DEFAULT.b, ICON_DEFAULT.a);
-}
diff --git a/src/apps/apps_view_circle_animator.c b/src/apps/apps_view_circle_animator.c
deleted file mode 100755
index b1f6ad5..0000000
--- a/src/apps/apps_view_circle_animator.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_view.h"
-#include "apps/apps_animator.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_icon.h"
-#include "util.h"
-#include "log.h"
-
-static struct __circle_animator_s {
- Eina_List *layout_list;
- Eina_List *cur_angle_list;
- Eina_List *dest_angle_list;
- int radius;
- int layout_width;
- int layout_height;
- double duration;
- Evas_Object *layout;
- Ecore_Timer *show_timer;
- int dest_x;
- int dest_y;
- int current_step;
- double current_angle;
- APPS_ROTATION rotaty_direction;
- ANIMATOR_OPTION option;
- void(*complete_cb)(void);
-} s_info = {
- .layout_list = NULL,
- .cur_angle_list = NULL,
- .dest_angle_list = NULL,
- .radius = 0,
- .layout_width = 0,
- .layout_height = 0,
- .duration = 0.0,
- .layout = NULL,
- .show_timer = NULL,
- .dest_x = 0,
- .dest_y = 0,
- .current_step = 0,
- .current_angle = 0.0,
- .rotaty_direction = 0,
- .option = ANIMATION_OPTION_DEFAULT,
- .complete_cb = NULL,
-};
-
-void __apps_view_circle_animator_rotation(
- Eina_List *layout_list, Eina_List *cur_angle_list, Eina_List *dest_angle_list,
- int radius, int layout_width, int layout_height, double duration, ANIMATOR_OPTION option, void(*cb)(void));
-static Eina_Bool __rotation_cb(void *data);
-
-#define ICON_MOVE_STEP_LEN 5
-#define ICON_MOVE_INTERVAL 0.01
-
-void __apps_view_circle_animator_focus_point_bound(
- Evas_Object *layout, double cur_angle, APPS_ROTATION rotation,
- int radius, int layout_width, int layout_height, double duration, void(*cb)(void));
-void __apps_view_circle_animator_icon_move_to_blank(
- Evas_Object *layout, int x, int y, double duration, void(*cb)(void));
-
-static Eina_Bool __focus_point_bound_cb(void *data);
-static Eina_Bool __icon_move_to_blank_cb(void *data);
-static void __animator_init(void);
-static void __animator_stop(void);
-
-extern void __apps_view_circle_get_pos(int radius, double angle, int *x, int *y);
-
-void __apps_view_circle_animator_rotation(
- Eina_List *layout_list, Eina_List *cur_angle_list, Eina_List *dest_angle_list,
- int radius, int layout_width, int layout_height, double duration, ANIMATOR_OPTION option, void(*cb)(void))
-{
- __animator_stop();
- apps_animator_start(__animator_stop);
-
- s_info.layout_list = layout_list;
- s_info.cur_angle_list = cur_angle_list;
- s_info.dest_angle_list = dest_angle_list;
- s_info.radius = radius;
- s_info.layout_width = layout_width;
- s_info.layout_height = layout_height;
- s_info.duration = duration;
- s_info.option = option;
- s_info.complete_cb = cb;
-
- s_info.current_step = 1;
- s_info.show_timer = ecore_timer_add(APPS_ANIMATION_INTERVAL, __rotation_cb, NULL);
-}
-
-static Eina_Bool __rotation_cb(void *data)
-{
- int idx = 0;
- int count = eina_list_count(s_info.layout_list);
- int len = s_info.duration / APPS_ANIMATION_INTERVAL;
-
- for (idx = 0; idx < count; idx++) {
- int x = 0;
- int y = 0;
- Evas_Object *layout = eina_list_nth(s_info.layout_list, idx);
- double *cur_angle = eina_list_nth(s_info.cur_angle_list, idx);
- double *dest_angle = eina_list_nth(s_info.dest_angle_list, idx);
-
- double angle = *cur_angle + ((*dest_angle - *cur_angle) / len * s_info.current_step);
- __apps_view_circle_get_pos(s_info.radius, angle, &x, &y);
-
- x -= s_info.layout_width / 2;
- y -= s_info.layout_height / 2;
-
- evas_object_raise(layout);
- evas_object_move(layout, x, y);
-
- if (s_info.option == ANIMATION_OPTION_PUSING && idx == 0) {
- int alpha = 255 - (s_info.current_step * 13);
- evas_object_color_set(layout, 255, 255, 255, alpha < 0 ? 0 : alpha);
- }
- }
-
- if (s_info.current_step >= len) {
- (*s_info.complete_cb)();
-
- __animator_init();
- apps_animator_complete();
- return ECORE_CALLBACK_CANCEL;
- }
-
- s_info.current_step += 1;
- return ECORE_CALLBACK_RENEW;
-}
-
-void __apps_view_circle_animator_focus_point_bound(
- Evas_Object *layout, double cur_angle, APPS_ROTATION rotation,
- int radius, int layout_width, int layout_height, double duration, void(*cb)(void))
-{
- __animator_stop();
- apps_animator_start(__animator_stop);
-
- s_info.layout = layout;
- s_info.current_angle = cur_angle;
- s_info.rotaty_direction = rotation;
- s_info.radius = radius;
- s_info.layout_width = layout_width;
- s_info.layout_height = layout_height;
- s_info.duration = duration;
- s_info.complete_cb = cb;
-
- s_info.current_step = 1;
- s_info.show_timer = ecore_timer_add(APPS_ANIMATION_INTERVAL, __focus_point_bound_cb, NULL);
-}
-
-void __apps_view_circle_animator_icon_move_to_blank(
- Evas_Object *layout, int x, int y, double duration, void(*cb)(void))
-{
- __animator_stop();
- apps_animator_start(__animator_stop);
-
- s_info.layout = layout;
- s_info.dest_x = x;
- s_info.dest_y = y;
- s_info.duration = duration;
- s_info.complete_cb = cb;
-
- s_info.current_step = 1;
- s_info.show_timer = ecore_timer_add(APPS_ANIMATION_INTERVAL, __icon_move_to_blank_cb, NULL);
-}
-
-static Eina_Bool __focus_point_bound_cb(void *data)
-{
- int x = 0;
- int y = 0;
- int len = s_info.duration / APPS_ANIMATION_INTERVAL;
- const int bound_step = (len / 6);
- const int stand_step = (len / 6 * 4);
-
- double angle = (APPS_ICON_BASE_ANGLE / 2);
-
- if (s_info.current_step <= bound_step) {
- angle = (angle / bound_step) * s_info.current_step;
- } else if (s_info.current_step > bound_step + stand_step) {
- angle = (angle / bound_step) * (len - s_info.current_step);
- }
-
- angle = s_info.current_angle + s_info.rotaty_direction * angle;
-
- __apps_view_circle_get_pos(s_info.radius, angle, &x, &y);
-
- x -= s_info.layout_width / 2;
- y -= s_info.layout_height / 2;
-
- evas_object_move(s_info.layout, x, y);
-
- if (s_info.current_step >= len) {
- (*s_info.complete_cb)();
- __animator_init();
- apps_animator_complete();
- return ECORE_CALLBACK_CANCEL;
- }
-
- s_info.current_step += 1;
- return ECORE_CALLBACK_RENEW;
-}
-
-static Eina_Bool __icon_move_to_blank_cb(void *data)
-{
- int x = 0;
- int y = 0;
- int cur_x = 0;
- int cur_y = 0;
- int step = 0;
- int len = s_info.duration / APPS_ANIMATION_INTERVAL;
-
- evas_object_geometry_get(s_info.layout, &cur_x, &cur_y, NULL, NULL);
-
- step = len - s_info.current_step + 1;
-
- x = cur_x + ((s_info.dest_x - cur_x) / step);
- y = cur_y + ((s_info.dest_y - cur_y) / step);
-
- evas_object_move(s_info.layout, x, y);
-
- if (s_info.current_step >= len) {
- (*s_info.complete_cb)();
-
- __animator_init();
- apps_animator_complete();
- return ECORE_CALLBACK_CANCEL;
- }
-
- s_info.current_step += 1;
- return ECORE_CALLBACK_RENEW;
-}
-
-static void __animator_init(void)
-{
- s_info.layout_list = eina_list_free(s_info.layout_list);
- s_info.cur_angle_list = eina_list_free(s_info.cur_angle_list);
- s_info.dest_angle_list = eina_list_free(s_info.dest_angle_list);
- s_info.radius = 0;
- s_info.layout_width = 0;
- s_info.layout_height = 0;
- s_info.duration = 0.0;
- s_info.layout = NULL;
- s_info.show_timer = NULL;
- s_info.dest_x = 0;
- s_info.dest_y = 0;
- s_info.current_step = 0;
- s_info.current_angle = 0.0;
- s_info.rotaty_direction = 0;
- s_info.option = ANIMATION_OPTION_DEFAULT;
- s_info.complete_cb = NULL;
-}
-
-static void __animator_stop(void)
-{
- if (s_info.show_timer != NULL) {
- ecore_timer_del(s_info.show_timer);
- }
-
- if (s_info.complete_cb != NULL) {
- (*s_info.complete_cb)();
- }
-
- __animator_init();
-}
-
diff --git a/src/apps/apps_view_circle_icon.c b/src/apps/apps_view_circle_icon.c
deleted file mode 100755
index 751d892..0000000
--- a/src/apps/apps_view_circle_icon.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_view.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_icon.h"
-#include "apps/apps_view_edje_conf.h"
-#include "apps/apps_data.h"
-#include "util.h"
-#include "log.h"
-
-#define APPS_ICON_EDJE EDJE_DIR"/circle/apps_icon_layout.edj"
-#define ICON_PATH_PREV IMAGE_DIR"/b_home_screen_icon_right.png"
-#define ICON_PATH_NEXT IMAGE_DIR"/b_home_screen_icon_left.png"
-#define ICON_PATH_BLANK IMAGE_DIR"/b_home_screen_icon_empty.png"
-
-APPS_ICON_INFO *__apps_view_circle_icon_create(Evas_Object *parent);
-void __apps_view_circle_icon_destroy(APPS_ICON_INFO *info);
-void __apps_view_icon_destroy(Evas_Object *layout);
-void __apps_view_circle_icon_set_prev_icon(APPS_ICON_INFO *info);
-void __apps_view_circle_icon_set_next_icon(APPS_ICON_INFO *info);
-void __apps_view_circle_icon_set_app_icon(APPS_ICON_INFO *info, int icon_idx);
-void __apps_view_circle_icon_set_blank_icon(APPS_ICON_INFO *info);
-void __apps_view_circle_icon_set_focused(APPS_ICON_INFO *info, bool is_focused);
-
-APPS_ICON_INFO *__apps_view_circle_icon_create(Evas_Object *parent)
-{
- APPS_ICON_INFO *info = NULL;
- Evas_Object *layout = NULL;
- Evas_Object *size_setter = NULL;
-
- info = (APPS_ICON_INFO *)malloc(sizeof(APPS_ICON_INFO));
- if (info == NULL) {
- _E("Failed to allocate memory for APPS_ICON_INFO");
- return NULL;
- }
-
- layout = elm_layout_add(parent);
- if (layout == NULL) {
- _E("Failed to add layout for icon");
- goto __fail;
- }
-
- if (!elm_layout_file_set(layout, util_get_res_file_path(APPS_ICON_EDJE), APPS_ICON_LAYOUT)) {
- _E("Failed to set layout file");
- goto __fail;
- }
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_hide(layout);
-
- size_setter = evas_object_rectangle_add(layout);
- if (size_setter == NULL) {
- _E("Failed to add size setter for icon layout");
- goto __fail;
- }
- evas_object_color_set(size_setter, 255, 255, 255, 0);
- evas_object_size_hint_min_set(size_setter, APPS_ICON_W, APPS_ICON_H);
- evas_object_size_hint_max_set(size_setter, APPS_ICON_W, APPS_ICON_H);
- evas_object_resize(size_setter, APPS_ICON_W, APPS_ICON_H);
- elm_object_part_content_set(layout, SIZE_SETTER, size_setter);
-
- info->layout = layout;
- info->icon_idx = INVALID_VALUE;
- info->icon_type = ICON_TYPE_INIT;
- info->is_editable = true;
-
- return info;
-
-__fail:
- destroy_evas_object(size_setter);
- destroy_evas_object(layout);
- free(info);
-
- return NULL;
-}
-
-void __apps_view_circle_icon_destroy(APPS_ICON_INFO *info)
-{
- if (info != NULL) {
- destroy_evas_object(info->layout);
- free(info);
- }
-}
-
-void __apps_view_icon_destroy(Evas_Object *layout)
-{
- destroy_evas_object(layout);
-}
-
-void __apps_view_circle_icon_set_prev_icon(APPS_ICON_INFO *info)
-{
- Evas_Object *icon_img = NULL;
-
- if (info == NULL || info->layout == NULL) {
- _E("icon info is null");
- return ;
- }
-
- icon_img = elm_image_add(info->layout);
- if (icon_img == NULL) {
- _E("failed to create elm_image");
- return ;
- }
-
- if (!elm_image_file_set(icon_img, util_get_res_file_path(ICON_PATH_PREV), NULL)) {
- _E("failed to set image file to app icon");
- evas_object_del(icon_img);
- return ;
- }
- elm_object_part_content_set(info->layout, APPS_ICON, icon_img);
- evas_object_color_set(info->layout, ICON_DEFAULT.r, ICON_DEFAULT.g, ICON_DEFAULT.b, ICON_DEFAULT.a);
-
- info->icon_idx = INVALID_VALUE;
- info->icon_type = ICON_TYPE_PREV;
-}
-
-void __apps_view_circle_icon_set_next_icon(APPS_ICON_INFO *info)
-{
- Evas_Object *icon_img = NULL;
- if (info == NULL || info->layout == NULL) {
- _E("icon info is null");
- return ;
- }
-
- icon_img = elm_image_add(info->layout);
- if (icon_img == NULL) {
- _E("failed to create elm_image");
- return ;
- }
-
- if (!elm_image_file_set(icon_img, util_get_res_file_path(ICON_PATH_NEXT), NULL)) {
- _E("failed to set image file to app icon");
- evas_object_del(icon_img);
- return ;
- }
- elm_object_part_content_set(info->layout, APPS_ICON, icon_img);
- evas_object_color_set(info->layout, ICON_DEFAULT.r, ICON_DEFAULT.g, ICON_DEFAULT.b, ICON_DEFAULT.a);
-
- info->icon_idx = INVALID_VALUE;
- info->icon_type = ICON_TYPE_NEXT;
-}
-
-void __apps_view_circle_icon_set_app_icon(APPS_ICON_INFO *info, int icon_idx)
-{
- Evas_Object *icon_img = NULL;
- APP_INFO *app_info = NULL;
-
- if (info == NULL || info->layout == NULL) {
- _E("icon info is null");
- return ;
- }
-
- app_info = apps_data_get_nth_app_info(icon_idx);
- if (app_info == NULL) {
- _E("app info is null");
- return ;
- }
-
- icon_img = elm_image_add(info->layout);
- if (icon_img == NULL) {
- _E("failed to create elm_image");
- return ;
- }
-
- if (!elm_image_file_set(icon_img, app_info->icon_path, NULL)) {
- _E("failed to set image file to app icon");
- evas_object_del(icon_img);
- return ;
- }
- elm_object_part_content_set(info->layout, APPS_ICON, icon_img);
- evas_object_color_set(info->layout, ICON_DEFAULT.r, ICON_DEFAULT.g, ICON_DEFAULT.b, ICON_DEFAULT.a);
-
- info->icon_idx = icon_idx;
- info->icon_type = ICON_TYPE_APP;
-}
-
-void __apps_view_circle_icon_set_blank_icon(APPS_ICON_INFO *info)
-{
- Evas_Object *icon_img = NULL;
- if (info == NULL || info->layout == NULL) {
- _E("icon info is null");
- return ;
- }
-
- icon_img = elm_image_add(info->layout);
- if (icon_img == NULL) {
- _E("failed to create elm_image");
- return ;
- }
-
- if (!elm_image_file_set(icon_img, util_get_res_file_path(ICON_PATH_BLANK), NULL)) {
- _E("failed to set image file to app icon");
- evas_object_del(icon_img);
- return ;
- }
- elm_object_part_content_set(info->layout, APPS_ICON, icon_img);
- evas_object_color_set(info->layout, ICON_DIM.r, ICON_DIM.g, ICON_DIM.b, ICON_DIM.a);
-
- info->icon_type = ICON_TYPE_BLANK;
- info->icon_idx = INVALID_VALUE;
-}
-
-void __apps_view_circle_icon_set_focused(APPS_ICON_INFO *info, bool is_focused)
-{
- Evas_Object *edje = NULL;
-
- if (info == NULL || info->layout == NULL) {
- _E("icon info is null");
- return ;
- }
-
- edje = elm_layout_edje_get(info->layout);
- if (is_focused) {
- edje_object_signal_emit(edje, SIGNAL_APPS_ICON_FOCUSED, SIGNAL_SOURCE);
- } else {
- edje_object_signal_emit(edje, SIGNAL_APPS_ICON_DEFAULT, SIGNAL_SOURCE);
- }
-}
-
diff --git a/src/apps/apps_view_circle_icon_page.c b/src/apps/apps_view_circle_icon_page.c
deleted file mode 100755
index 277f2e3..0000000
--- a/src/apps/apps_view_circle_icon_page.c
+++ /dev/null
@@ -1,1152 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <badge.h>
-
-#include "apps/apps_view_circle_touch_handler.h"
-#include "apps/apps_animator.h"
-#include "apps/apps_view.h"
-#include "apps/apps_view_icon.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_edje_conf.h"
-#include "apps/apps_callback_manager.h"
-#include "util.h"
-#include "log.h"
-
-enum {
- APPS_ICON_MSG_VISIBILITY = 0,
- APPS_ICON_MSG_POSITION = 1,
- APPS_ICON_MSG_DIGIT = 2,
- APPS_ICON_MSG_MAX,
-};
-
-static struct __circle_icon_page_s {
- Evas_Object *layout;
- Evas_Object *grid;
- APPS_ICON_INFO *picked_icon;
- int page_count;
- int current_page;
- int current_icon_count;
- APPS_ICON_INFO *icon_info[APPS_ICON_COUNT_PER_PAGE];
- apps_callback_t *page_count_cb_stack;
- apps_callback_t *page_focus_cb_stack;
- APPS_VIEW_CALLBACK *callback;
-} s_info = {
- .layout = NULL,
- .grid = NULL,
- .picked_icon = NULL,
- .page_count = INVALID_VALUE,
- .current_page = INVALID_VALUE,
- .current_icon_count = 0,
- .icon_info = { NULL, },
- .page_count_cb_stack = NULL,
- .page_focus_cb_stack = NULL,
- .callback = NULL,
-};
-
-extern double ICON_ANGLE[APPS_ICON_COUNT_PER_PAGE];
-
-#define APPS_ICON_PAGE_EDJE EDJE_DIR"/circle/apps_icon_page.edj"
-
-Evas_Object *__apps_view_circle_icon_page_create(Evas_Object* base_layout);
-void __apps_view_circle_icon_page_destroy(void);
-apps_callback_t *__apps_view_circle_icon_get_page_count_cb_stack(void);
-apps_callback_t *__apps_view_circle_icon_get_page_focus_cb_stack(void);
-void __apps_view_circle_icon_show_focus(void);
-void __apps_view_circle_icon_hide_focus(void);
-void __apps_view_circle_icon_bound(APPS_ROTATION rotation);
-void __apps_view_circle_icon_show_up(APPS_DIRECTION start_direction);
-void __apps_view_circle_icon_page_get(void);
-void __apps_view_circle_icon_get_info_by_pos(APPS_ICON_INFO *icon, int page, int pos);
-int __apps_view_circle_icon_get_current_icon_count(void);
-void __apps_view_circle_tap_focus_text(void);
-void __apps_view_circle_tap_icon(int touch_area);
-void __apps_view_circle_icon_press(int touch_area);
-void __apps_view_circle_icon_release(int touch_area);
-void __apps_view_circle_icon_hide(void);
-void __apps_view_circle_icon_set_badge(Evas_Object *icon_layout, int visibility, int position, int count);
-void __apps_view_circle_icon_set_edit_btn(Evas_Object *icon_layout, int visibility, int position);
-void __apps_view_circle_icon_set_touch_callback(APPS_VIEW_CALLBACK *callback);
-bool __apps_view_circle_icon_pick_up(void);
-void __apps_view_circle_icon_pick_up_cancel(void);
-void __apps_view_circle_icon_drag(int cur_x, int cur_y);
-void __apps_view_circle_icon_drag_hold(int hold_area);
-void __apps_view_circle_hold_up(void);
-
-static Evas_Object *__create_layout(Evas_Object *base_layout);
-static Evas_Object *__create_grid(Evas_Object *layout);
-static bool __create_icon_group(Evas_Object *grid);
-static void __destroy_icon_group(void);
-static int __get_page_count(void);
-static void __get_page_icon_idx(int page, int *from_idx, int *to_idx);
-static void __page_set(void);
-static void __tap_icon(int pos);
-static void __press_icon(int pos);
-static void __release_icon(int pos);
-static int __get_badge_length(int data);
-static int __get_badge_count(char *app_id);
-static void __set_icon_color(Evas_Object *icon_layout, COLOR color);
-static void __icon_drop(void);
-static void __icon_drop_cb(void);
-static int __get_blank_position(void);
-static void __push_icon(int push_area);
-static void __move_icon_group(int from, int to, APPS_ROTATION rotation, ANIMATOR_OPTION option);
-static void __move_icon_complete_cb(void);
-static void __destroy_picked_icon(void);
-
-extern APPS_ICON_INFO *__apps_view_circle_icon_create(Evas_Object *parent);
-extern void __apps_view_icon_destroy(Evas_Object *layout);
-extern void __apps_view_circle_icon_set_focused(APPS_ICON_INFO *info, bool is_focused);
-extern void __apps_view_circle_icon_set_prev_icon(APPS_ICON_INFO *info);
-extern void __apps_view_circle_icon_set_next_icon(APPS_ICON_INFO *info);
-extern void __apps_view_circle_icon_set_app_icon(APPS_ICON_INFO *info, int icon_idx);
-extern void __apps_view_circle_get_pos(int radius, double angle, int *x, int *y);
-extern void __apps_view_base_show_complete(void);
-extern int __apps_view_circle_touch_handler_get_tap_hold_area(void);
-extern void __apps_view_circle_icon_set_blank_icon(APPS_ICON_INFO *info);
-extern void __apps_view_circle_icon_destroy(APPS_ICON_INFO *info);
-extern void __apps_view_circle_animator_icon_move_to_blank(
- Evas_Object *layout, int x, int y, double duration, void(*cb)(void));
-extern void __apps_view_circle_animator_rotation(
- Eina_List *layout_list, Eina_List *cur_angle_list, Eina_List *dest_angle_list,
- int radius, int layout_width, int layout_height, double duration, ANIMATOR_OPTION option, void(*cb)(void));
-extern void __apps_view_circle_set_focus_text_enable(bool is_enable);
-
-bool apps_view_register_page_changed_cb(void(*page_changed_cb)(void *data))
-{
- bool ret = false;
- ret = apps_callback_manager_register_cb(s_info.page_focus_cb_stack, page_changed_cb);
- if (ret == false) {
- _E("Failed to register page changed cb");
- }
-
- return ret;
-}
-
-void apps_view_deregister_page_changed_cb(void(*page_changed_cb)(void *data))
-{
- apps_callback_manager_deregister_cb(s_info.page_focus_cb_stack, page_changed_cb);
-}
-
-APPS_ICON_INFO *apps_view_get_focus_icon_info(void)
-{
- int pos = apps_data_get_focus_pos();
- if (pos >= s_info.current_icon_count) {
- int count = s_info.current_icon_count - 1;
- pos = (count < 0) ? 0 : count;
- apps_data_set_focus_pos(pos);
- }
-
- return s_info.icon_info[pos];
-}
-
-void apps_view_turn_next_page(void)
-{
- _D("%s", __func__);
- int page = apps_data_get_focus_page();
-
- if (page == s_info.page_count - 1) {
- __apps_view_circle_icon_bound(CLOCKWISE);
- return ;
- }
-
- apps_data_set_focus_page(page + 1);
- apps_data_set_focus_pos(1);
-
- __apps_view_circle_icon_page_get();
- __apps_view_circle_icon_show_up(RIGHT);
-}
-
-void apps_view_turn_prev_page(void)
-{
- _D("%s", __func__);
-
- int page = apps_data_get_focus_page();
- if (page == 0) {
- __apps_view_circle_icon_bound(COUNT_CLOCKWISE);
- return ;
- }
-
- apps_data_set_focus_page(page - 1);
- apps_data_set_focus_pos(APPS_ICON_COUNT_PER_PAGE - 2);
-
- __apps_view_circle_icon_page_get();
- __apps_view_circle_icon_show_up(LEFT);
-}
-
-void apps_view_show_delete_button(void)
-{
- int pos = 0;
- for (pos = 0; pos < s_info.current_icon_count; pos++) {
- if (s_info.icon_info[pos]->icon_type == ICON_TYPE_APP) {
- APP_INFO *info = apps_data_get_nth_app_info(s_info.icon_info[pos]->icon_idx);
-
- if (info->is_removable) {
- int button_pos = pos <= APPS_ICON_POS_RIGHT ? APPS_ICON_EDIT_BTN_POSITION_LEFT : APPS_ICON_EDIT_BTN_POSITION_RIGHT;
- __apps_view_circle_icon_set_edit_btn(s_info.icon_info[pos]->layout, APPS_ICON_EDIT_BTN_SHOW, button_pos);
- } else {
- __apps_view_circle_icon_set_edit_btn(s_info.icon_info[pos]->layout, APPS_ICON_EDIT_BTN_HIDE, 0);
- }
- } else {
- __apps_view_circle_icon_set_edit_btn(s_info.icon_info[pos]->layout, APPS_ICON_EDIT_BTN_HIDE, 0);
- }
- }
-}
-
-void apps_view_hide_delete_button(void)
-{
- int pos = 0;
- for (pos = 0; pos < APPS_ICON_COUNT_PER_PAGE; pos++) {
- __apps_view_circle_icon_set_edit_btn(s_info.icon_info[pos]->layout, APPS_ICON_EDIT_BTN_HIDE, 0);
- }
-}
-
-void apps_view_set_editable_icon(void)
-{
- _D("%s", __func__);
-
- int pos = 0;
- for (pos = 0; pos < APPS_ICON_COUNT_PER_PAGE; pos++) {
- if (s_info.icon_info[pos]->icon_type == ICON_TYPE_APP) {
- APP_INFO *info = apps_data_get_nth_app_info(s_info.icon_info[pos]->icon_idx);
-
- if (info->primary_index == INVALID_VALUE) {
- s_info.icon_info[pos]->is_editable = true;
- __set_icon_color(s_info.icon_info[pos]->layout, ICON_DEFAULT);
- } else {
- s_info.icon_info[pos]->is_editable = false;
- __set_icon_color(s_info.icon_info[pos]->layout, ICON_DIM);
- }
- } else {
- s_info.icon_info[pos]->is_editable = false;
- __set_icon_color(s_info.icon_info[pos]->layout, ICON_DEFAULT);
- }
- }
-
- __apps_view_circle_set_focus_text_enable(false);
-}
-
-void apps_view_unset_editable_icon(void)
-{
- _D("%s", __func__);
-
- int pos = 0;
- for (pos = 0; pos < APPS_ICON_COUNT_PER_PAGE; pos++) {
- s_info.icon_info[pos]->is_editable = true;
- __set_icon_color(s_info.icon_info[pos]->layout, ICON_DEFAULT);
- }
-
- __apps_view_circle_set_focus_text_enable(true);
-}
-
-void apps_view_show_badge_count(void)
-{
- int pos = 0;
- for (pos = 0; pos < s_info.current_icon_count; pos++) {
- if (s_info.icon_info[pos]->icon_type == ICON_TYPE_APP) {
- APP_INFO *info = apps_data_get_nth_app_info(s_info.icon_info[pos]->icon_idx);
- if (info != NULL) {
- int badge_count = __get_badge_count(info->app_id);
- int badge_position = pos <= APPS_ICON_POS_RIGHT ? APPS_ICON_BADGE_POSITION_LEFT : APPS_ICON_BADGE_POSITION_RIGHT;
- if (badge_count == 0) {
- __apps_view_circle_icon_set_badge(s_info.icon_info[pos]->layout, APPS_ICON_BADGE_HIDE, 0, 0);
- } else {
- __apps_view_circle_icon_set_badge(s_info.icon_info[pos]->layout, APPS_ICON_BADGE_SHOW, badge_position, badge_count);
- }
- }
- } else {
- __apps_view_circle_icon_set_badge(s_info.icon_info[pos]->layout, APPS_ICON_BADGE_HIDE, 0, 0);
- }
- }
-}
-
-void apps_view_hide_badge_count(void)
-{
- int pos = 0;
- for (pos = 0; pos < APPS_ICON_COUNT_PER_PAGE; pos++) {
- __apps_view_circle_icon_set_badge(s_info.icon_info[pos]->layout, APPS_ICON_BADGE_HIDE, 0, 0);
- }
-}
-
-void apps_view_reload_page(void)
-{
- __apps_view_circle_icon_page_get();
- __page_set();
-}
-
-Evas_Object *__apps_view_circle_icon_page_create(Evas_Object* base_layout)
-{
- _D("%s", __func__);
- s_info.layout = __create_layout(base_layout);
- if (s_info.layout == NULL) {
- _E("Failed to create icon page layout");
- goto __fail;
- }
-
- s_info.grid = __create_grid(s_info.layout);
- if (s_info.grid == NULL) {
- _E("Failed to create icon page grid");
- goto __fail;
- }
-
- if (!__create_icon_group(s_info.grid)) {
- _E("Failed to create icon group");
- goto __fail;
- }
-
- s_info.page_count_cb_stack = apps_callback_manager_new();
- if (s_info.page_count_cb_stack == NULL) {
- _E("Failed to allocate memory for page count cb stack");
- goto __fail;
- }
-
- s_info.page_focus_cb_stack = apps_callback_manager_new();
- if (s_info.page_focus_cb_stack == NULL) {
- _E("Failed to allocate memory for page focus cb stack");
- goto __fail;
- }
-
- return s_info.layout;
-
-__fail:
- __apps_view_circle_icon_page_destroy();
- return NULL;
-}
-
-void __apps_view_circle_icon_page_destroy(void)
-{
- apps_callback_manager_free(s_info.page_focus_cb_stack);
- apps_callback_manager_free(s_info.page_count_cb_stack);
- __destroy_icon_group();
- destroy_evas_object(s_info.grid);
- destroy_evas_object(s_info.layout);
-
- s_info.page_focus_cb_stack = NULL;
- s_info.page_count_cb_stack = NULL;
- s_info.grid = NULL;
- s_info.layout = NULL;
-}
-
-apps_callback_t *__apps_view_circle_icon_get_page_count_cb_stack(void)
-{
- return s_info.page_count_cb_stack;
-}
-
-apps_callback_t *__apps_view_circle_icon_get_page_focus_cb_stack(void)
-{
- return s_info.page_focus_cb_stack;
-}
-
-void __apps_view_circle_icon_show_focus(void)
-{
- int i = 0;
- int pos = apps_data_get_focus_pos();
- if (pos >= s_info.current_icon_count) {
- pos = s_info.current_icon_count - 1;
- apps_data_set_focus_pos(pos);
- }
-
- for (i = 0; i < s_info.current_icon_count; i++) {
- __apps_view_circle_icon_set_focused(s_info.icon_info[i], i == pos);
- }
-}
-
-void __apps_view_circle_icon_hide_focus(void)
-{
- int i = 0;
- for (i = 0; i < s_info.current_icon_count; i++) {
- __apps_view_circle_icon_set_focused(s_info.icon_info[i], false);
- }
-}
-
-void __apps_view_circle_icon_bound(APPS_ROTATION rotation)
-{
- _D("%s", __func__);
-
- int i = 0;
- int idx = rotation == CLOCKWISE ? 0 : s_info.current_icon_count - 1;
- const double angle_unit = (APPS_ICON_BASE_ANGLE / 2.0) / s_info.current_icon_count;
- static double dest_angle[APPS_ICON_COUNT_PER_PAGE] = { 0.0, };
-
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
-
- for (i = 0; i < s_info.current_icon_count; i++) {
- dest_angle[i] = ICON_ANGLE[idx] + ((angle_unit * i) * rotation);
- layout_list = eina_list_append(layout_list, s_info.icon_info[idx]->layout);
- cur_angle_list = eina_list_append(cur_angle_list, &ICON_ANGLE[idx]);
- dest_angle_list = eina_list_append(dest_angle_list, &dest_angle[i]);
-
- idx += rotation;
- }
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_ICON_RADIUS, APPS_ICON_W, APPS_ICON_H, APPS_ICON_BOUND_TIME, ANIMATION_OPTION_DEFAULT, __page_set);
-}
-
-/*
- * This function must be executed after '__apps_view_circle_icon_page_get'
- */
-void __apps_view_circle_icon_show_up(APPS_DIRECTION start_direction)
-{
- _D("%s", __func__);
-
- int idx = 0, inc = 1;
- double *current_angle = &ICON_ANGLE[0];
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
- if (start_direction == LEFT) {
- idx = s_info.current_icon_count - 1;
- current_angle = &ICON_ANGLE[idx];
- inc = -1;
- }
- while (idx >= 0 && idx < s_info.current_icon_count) {
- int x = 0;
- int y = 0;
- __apps_view_circle_get_pos(APPS_ICON_RADIUS, *current_angle, &x, &y);
-
- x -= APPS_ICON_W / 2;
- y -= APPS_ICON_H / 2;
- evas_object_move(s_info.icon_info[idx]->layout, x, y);
- evas_object_raise(s_info.icon_info[idx]->layout);
- evas_object_show(s_info.icon_info[idx]->layout);
-
- layout_list = eina_list_append(layout_list, s_info.icon_info[idx]->layout);
- cur_angle_list = eina_list_append(cur_angle_list, current_angle);
- dest_angle_list = eina_list_append(dest_angle_list, &ICON_ANGLE[idx]);
-
- idx += inc;
- }
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_ICON_RADIUS, APPS_ICON_W, APPS_ICON_H, APPS_ICON_SHOW_TIME, ANIMATION_OPTION_DEFAULT, __page_set);
-}
-
-void __apps_view_circle_icon_page_get(void)
-{
- _D("%s", __func__);
-
- int i;
- int idx = 0;
- int from = 0, to = 0;
- int page_count = __get_page_count();
- int current = apps_data_get_focus_page();
- int changed_current;
-
- __get_page_icon_idx(current, &from, &to);
-
- for (i = 0; i < APPS_ICON_COUNT_PER_PAGE; i++) {
- elm_grid_unpack(s_info.grid, s_info.icon_info[i]->layout);
- }
-
- changed_current = apps_data_get_focus_page();
- if (current != changed_current) {
- current = changed_current;
- }
-
- if (current > 0) {
- __apps_view_circle_icon_set_prev_icon(s_info.icon_info[idx]);
- idx += 1;
- }
-
- for (i = 0; i < to - from + 1; i++) {
- if (s_info.picked_icon != NULL && s_info.picked_icon->icon_idx == from + i) {
- __apps_view_circle_icon_set_blank_icon(s_info.icon_info[idx]);
- } else {
- __apps_view_circle_icon_set_app_icon(s_info.icon_info[idx], from + i);
- }
-
- idx += 1;
- }
-
- if (current < page_count - 1) {
- __apps_view_circle_icon_set_next_icon(s_info.icon_info[APPS_ICON_COUNT_PER_PAGE - 1]);
- idx += 1;
- }
-
- s_info.current_icon_count = idx;
-
- for (i = idx; i < APPS_ICON_COUNT_PER_PAGE; i++) {
- evas_object_hide(s_info.icon_info[i]->layout);
- evas_object_move(s_info.icon_info[i]->layout, OUTSIDE_X, OUTSIDE_Y);
- s_info.icon_info[i]->icon_idx = INVALID_VALUE;
- s_info.icon_info[i]->icon_type = ICON_TYPE_INIT;
- }
-
- if (s_info.page_count != page_count) {
- s_info.page_count = page_count;
- apps_callback_manager_execute_cb(s_info.page_count_cb_stack, &s_info.page_count);
- }
-
- if (s_info.current_page != current) {
- s_info.current_page = current;
- }
- apps_callback_manager_execute_cb(s_info.page_focus_cb_stack, &s_info.current_page);
-}
-
-void __apps_view_circle_icon_get_info_by_pos(APPS_ICON_INFO *icon, int page, int pos)
-{
- int from = 0, to = 0;
-
- int page_count = __get_page_count();
- __get_page_icon_idx(page, &from, &to);
-
- if (pos >= s_info.current_icon_count) {
- pos = s_info.current_icon_count - 1;
- apps_data_set_focus_pos(pos);
- }
-
- icon->icon_type = ICON_TYPE_INIT;
- icon->layout = NULL;
- icon->icon_idx = INVALID_VALUE;
- if (page > 0 && pos == 0) {
- icon->icon_type = ICON_TYPE_PREV;
- } else if (page < page_count - 1 && pos == APPS_ICON_COUNT_PER_PAGE - 1) {
- icon->icon_type = ICON_TYPE_NEXT;
- icon->icon_idx = INVALID_VALUE;
- } else {
- APP_INFO *item = NULL;
- int idx = page > 0 ? from + pos - 1 : from + pos;
- item = apps_data_get_nth_app_info(idx);
-
- if (item != NULL) {
- icon->icon_type = ICON_TYPE_APP;
- icon->icon_idx = item->index;
- }
- }
-}
-
-int __apps_view_circle_icon_get_current_icon_count(void)
-{
- return s_info.current_icon_count;
-}
-
-void __apps_view_circle_tap_focus_text(void)
-{
- _D("%s", __func__);
-
- APPS_ICON_INFO *icon_info = NULL;
- int pos = apps_data_get_focus_pos();
- if (pos >= s_info.current_icon_count) {
- int count = s_info.current_icon_count - 1;
- pos = (count < 0) ? 0 : count;
- apps_data_set_focus_pos(pos);
- }
- icon_info = s_info.icon_info[pos];
-
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->tap_focus_text)(icon_info, pos);
-}
-
-void __apps_view_circle_tap_icon(int touch_area)
-{
- _D("%s", __func__);
-
- if (touch_area >= s_info.current_icon_count || touch_area < 0) {
- _E("touch area is wrong");
- return ;
- }
- __tap_icon(touch_area);
-}
-
-void __apps_view_circle_icon_press(int touch_area)
-{
- _D("%s", __func__);
-
- if (touch_area >= s_info.current_icon_count || touch_area < 0) {
- _E("touch area is wrong");
- return ;
- }
-
- if (s_info.icon_info[touch_area]->is_editable == false) {
- _E("editable is false");
- return;
- }
-
- __press_icon(touch_area);
-}
-
-void __apps_view_circle_icon_release(int touch_area)
-{
- _D("%s", __func__);
-
- if (touch_area >= s_info.current_icon_count || touch_area < 0) {
- _E("touch area is wrong");
- return ;
- }
-
- if (s_info.icon_info[touch_area]->is_editable == false) {
- _E("editable is false");
- return;
- }
-
- __release_icon(touch_area);
-}
-
-void __apps_view_circle_icon_hide(void)
-{
- int i = 0;
- for (i = 0; i < APPS_ICON_COUNT_PER_PAGE; i++) {
- evas_object_hide(s_info.icon_info[i]->layout);
- evas_object_move(s_info.icon_info[i]->layout, OUTSIDE_X, OUTSIDE_Y);
- s_info.icon_info[i]->icon_idx = INVALID_VALUE;
- s_info.icon_info[i]->icon_type = ICON_TYPE_INIT;
- }
-}
-
-bool __apps_view_circle_icon_pick_up(void)
-{
- _D("%s", __func__);
-
- Evas_Object *edje_obj = NULL;
- APPS_ICON_INFO *picked_icon_info = NULL;
- int touch_area = 0;
- int x, y;
-
- touch_area = __apps_view_circle_touch_handler_get_tap_hold_area();
- if (touch_area < ICON_0 || touch_area > ICON_9) {
- _E("Failed to get tap hold area");
- return false;
- }
-
- if (s_info.icon_info[touch_area]->icon_type != ICON_TYPE_APP) {
- _E("icon type is not APP");
- return false;
- }
-
- if (s_info.icon_info[touch_area]->is_editable == false) {
- _E("editable is false");
- return false;
- }
-
- picked_icon_info = __apps_view_circle_icon_create(s_info.grid);
- if (picked_icon_info == NULL) {
- _E("Failed to create picked icon info");
- return false;
- }
- picked_icon_info->icon_idx = s_info.icon_info[touch_area]->icon_idx;
- picked_icon_info->icon_type = s_info.icon_info[touch_area]->icon_type;
- picked_icon_info->is_editable = s_info.icon_info[touch_area]->is_editable;
-
- __apps_view_circle_icon_set_blank_icon(s_info.icon_info[touch_area]);
- __apps_view_circle_icon_set_app_icon(picked_icon_info, picked_icon_info->icon_idx);
-
- evas_object_geometry_get(s_info.icon_info[touch_area]->layout, &x, &y, NULL, NULL);
- evas_object_move(picked_icon_info->layout, x, y);
- evas_object_show(picked_icon_info->layout);
-
- edje_obj = elm_layout_edje_get(picked_icon_info->layout);
- edje_object_signal_emit(edje_obj, SIGNAL_APPS_ICON_FOCUSED_PRESSED, SIGNAL_SOURCE);
- __set_icon_color(picked_icon_info->layout, ICON_DIM);
-
- evas_object_raise(picked_icon_info->layout);
-
- s_info.picked_icon = picked_icon_info;
-
- return true;
-}
-
-void __apps_view_circle_icon_pick_up_cancel(void)
-{
- __destroy_picked_icon();
-}
-
-void __apps_view_circle_icon_drag(int cur_x, int cur_y)
-{
- int x, y;
- if (s_info.picked_icon == NULL || s_info.picked_icon->layout == NULL) {
- return;
- }
- x = cur_x - (APPS_ICON_W / 2);
- y = cur_y - (APPS_ICON_H / 2) - APPS_ICON_PICKED_MOVE_OFFSET_H;
-
- evas_object_move(s_info.picked_icon->layout, x, y);
-}
-
-void __apps_view_circle_icon_drag_hold(int hold_area)
-{
- _D("%s", __func__);
-
- if (s_info.icon_info[hold_area]->icon_type == ICON_TYPE_NEXT) {
- if (s_info.callback != NULL) {
- (*s_info.callback->drag_hold_next)();
- }
- } else if (s_info.icon_info[hold_area]->icon_type == ICON_TYPE_PREV) {
- if (s_info.callback != NULL) {
- (*s_info.callback->drag_hold_prev)();
- }
- } else if (s_info.icon_info[hold_area]->icon_type == ICON_TYPE_APP) {
- __push_icon(hold_area);
- }
-}
-
-void __apps_view_circle_hold_up(void)
-{
- _D("%s", __func__);
-
- if (s_info.picked_icon != NULL && s_info.picked_icon->layout != NULL) {
- __icon_drop();
- return;
- }
-}
-
-void __apps_view_circle_icon_set_badge(Evas_Object *icon_layout, int visibility, int position, int count)
-{
- Evas_Object *edje_obj = elm_layout_edje_get(icon_layout);
- Edje_Message_String_Int_Set *badge_msg = alloca(sizeof(Edje_Message_String_Int_Set) + (3 * sizeof(int)));
- char num[128] = { 0, };
- int digit = 0;
-
- if (count <= 999) {
- snprintf(num, sizeof(num), "%d", count);
- } else {
- snprintf(num, sizeof(num), "%d+", 999);
- }
-
- digit = __get_badge_length(count);
-
- badge_msg->str = num;
- badge_msg->count = APPS_ICON_MSG_MAX;
- badge_msg->val[APPS_ICON_MSG_VISIBILITY] = visibility;
- badge_msg->val[APPS_ICON_MSG_POSITION] = position;
- badge_msg->val[APPS_ICON_MSG_DIGIT] = ((digit > 3) ? 3 : digit);
-
- edje_object_message_send(edje_obj, EDJE_MESSAGE_STRING_INT_SET, APPS_ICON_BADGE_ID, badge_msg);
-}
-
-void __apps_view_circle_icon_set_touch_callback(APPS_VIEW_CALLBACK *callback)
-{
- s_info.callback = callback;
-}
-
-void __apps_view_circle_icon_set_edit_btn(Evas_Object *icon_layout, int visibility, int position)
-{
- Evas_Object *edje_obj = elm_layout_edje_get(icon_layout);
- Edje_Message_Int_Set *edit_btn_msg = alloca(sizeof(Edje_Message_Int_Set) + (2 * sizeof(int)));
-
- edit_btn_msg->count = APPS_ICON_MSG_MAX - 1;
- edit_btn_msg->val[APPS_ICON_MSG_VISIBILITY] = visibility;
- edit_btn_msg->val[APPS_ICON_MSG_POSITION] = position;
-
- edje_object_message_send(edje_obj, EDJE_MESSAGE_INT_SET, APPS_ICON_EDIT_BTN_ID, edit_btn_msg);
-}
-
-static Evas_Object *__create_layout(Evas_Object *base_layout)
-{
- Evas_Object *layout = NULL;
- Evas_Object *size_setter = NULL;
-
- layout = elm_layout_add(base_layout);
- if (layout == NULL) {
- _E("Failed to add icon page layout");
- goto __fail;
- }
-
- if (!elm_layout_file_set(layout, util_get_res_file_path(APPS_ICON_PAGE_EDJE), APPS_ICON_PAGE_LAYOUT)) {
- _E("Failed to set layout file");
- goto __fail;
- }
- evas_object_size_hint_align_set(layout, 0, 0);
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_hide(layout);
-
- size_setter = evas_object_rectangle_add(evas_object_evas_get(layout));
- if (size_setter == NULL) {
- _E("Failed to create size setter");
- goto __fail;
- }
- evas_object_size_hint_min_set(size_setter, WINDOW_W, WINDOW_H);
- evas_object_size_hint_align_set(size_setter, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(size_setter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_color_set(size_setter, 0, 0, 0, 0);
- elm_object_part_content_set(layout, SIZE_SETTER, size_setter);
-
- return layout;
-
-__fail:
- destroy_evas_object(size_setter);
- destroy_evas_object(layout);
-
- return NULL;
-}
-
-static Evas_Object *__create_grid(Evas_Object *layout)
-{
- Evas_Object *grid = elm_grid_add(layout);
- if (grid == NULL) {
- _E("Failed to add indicator grid");
- return NULL;
- }
- evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_grid_size_set(grid, WINDOW_W, WINDOW_H);
-
- elm_layout_content_set(layout, APPS_ICON_PAGE_GRID, grid);
-
- return grid;
-}
-
-static bool __create_icon_group(Evas_Object *grid)
-{
- int i;
- for (i = 0; i < APPS_ICON_COUNT_PER_PAGE; i++) {
- if (s_info.icon_info[i] != NULL) {
- _E("icon info is not null");
- goto __fail;
- }
-
- s_info.icon_info[i] = __apps_view_circle_icon_create(grid);
- }
-
- return true;
-
-__fail:
- __destroy_icon_group();
-
- return false;
-}
-
-static void __destroy_icon_group(void)
-{
- int i = 0;
- for (i = 0; i < APPS_ICON_COUNT_PER_PAGE; i++) {
- __apps_view_icon_destroy(s_info.icon_info[i]->layout);
- s_info.icon_info[i]->layout = NULL;
- }
-}
-
-static int __get_page_count(void)
-{
- int page_cnt = 1;
- int item_count_per_page = APPS_ICON_COUNT_PER_PAGE;
- int item_count = apps_data_get_list_count();
-
- while(item_count > item_count_per_page) {
- item_count = item_count - (item_count_per_page - 1);
- if (item_count_per_page == APPS_ICON_COUNT_PER_PAGE) {
- item_count_per_page -= 1;
- }
- page_cnt += 1;
- }
-
- return page_cnt;
-}
-
-/*
- * first page is 0
- */
-static void __get_page_icon_idx(int page, int *from_idx, int *to_idx)
-{
- int page_count = __get_page_count();
- int last_icon_idx = apps_data_get_list_count() - 1;
- int last_page_from = (page_count - 1) * (APPS_ICON_COUNT_PER_PAGE - 2) + 1;
-
- if (page > page_count - 1) {
- page = page_count - 1;
- apps_data_set_focus_page(page);
- }
-
- if (page_count == 1) {
- *from_idx = 0;
- *to_idx = last_icon_idx;
- } else if (page == 0) {
- *from_idx = 0;
- *to_idx = *from_idx + (APPS_ICON_COUNT_PER_PAGE - 1) - 1;
- } else if (page == page_count - 1) {
- *from_idx = last_page_from;
- *to_idx = last_icon_idx;
- } else {
- *from_idx = page * (APPS_ICON_COUNT_PER_PAGE - 2) + 1;
- *to_idx = *from_idx + (APPS_ICON_COUNT_PER_PAGE - 2) - 1;
- }
-}
-
-static void __page_set(void)
-{
- _D("%s", __func__);
-
- int i = 0;
- for (i = 0; i < s_info.current_icon_count; i++) {
- int x = 0;
- int y = 0;
- __apps_view_circle_get_pos(APPS_ICON_RADIUS, ICON_ANGLE[i], &x, &y);
-
- x -= APPS_ICON_W / 2;
- y -= APPS_ICON_H / 2;
-
- evas_object_show(s_info.icon_info[i]->layout);
- elm_grid_pack(s_info.grid, s_info.icon_info[i]->layout, x, y, APPS_ICON_W, APPS_ICON_H);
- }
-
- __apps_view_base_show_complete();
-}
-
-static void __tap_icon(int pos)
-{
- APPS_ICON_INFO *icon_info = s_info.icon_info[pos];
- APP_INFO *app_info = NULL;
-
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- if (icon_info->icon_type == ICON_TYPE_INIT) {
- _E("focus pos is wrong");
- return ;
- }
-
- if (icon_info->icon_type == ICON_TYPE_NEXT) {
- (*s_info.callback->tap_next)();
- return ;
- }
-
- if (icon_info->icon_type == ICON_TYPE_PREV) {
- (*s_info.callback->tap_prev)();
- return ;
- }
-
- app_info = apps_data_get_nth_app_info(icon_info->icon_idx);
- if(app_info == NULL) {
- _E("focus app info is null");
- return ;
- }
-
- (*s_info.callback->tap_app_icon)(app_info, pos);
-}
-
-static void __press_icon(int pos)
-{
- _D("%s", __func__);
-
- __set_icon_color(s_info.icon_info[pos]->layout, ICON_DIM);
-}
-
-static void __release_icon(int pos)
-{
- _D("%s", __func__);
-
- __set_icon_color(s_info.icon_info[pos]->layout, ICON_DEFAULT);
-}
-
-static int __get_badge_length(int data)
-{
- int len = 1, i;
-
- if (data < 0) data *= (-1);
-
- for (i = 0; ; i++, len++) {
- if ((data /= 10) <= 0)
- break;
- }
- return(len);
-}
-
-static int __get_badge_count(char *app_id)
-{
- unsigned int to_be_displayed = 0;
- int result = BADGE_ERROR_NONE;
- unsigned int badge_count = 0;
-
-#ifdef APPS_TEST
- {
- if (!strcmp(app_id, "org.tizen.alarm")) return 9;
- if (!strcmp(app_id, "org.tizen.apps")) return 19;
- if (!strcmp(app_id, "org.tizen.atntmessages")) return 2367;
- if (!strcmp(app_id, "org.tizen.calculator")) return 344;
- if (!strcmp(app_id, "org.tizen.email")) return 1002;
- if (!strcmp(app_id, "org.tizen.findmydevice")) return 289;
- if (!strcmp(app_id, "org.tizen.gallery_delta")) return 1;
- if (!strcmp(app_id, "org.tizen.shealth")) return 2;
- if (!strcmp(app_id, "org.tizen.voicememo")) return 45;
- }
-#endif
-
- result = badge_get_display(app_id, &to_be_displayed);
- if (result != BADGE_ERROR_NONE) {
- _E("badge_get_display error %d", result);
- return 0;
- }
- if (!to_be_displayed) {
- return 0;
- }
-
- result = badge_get_count(app_id, &badge_count);
- if (result != BADGE_ERROR_NONE) {
- _E("badge_get_count error %d", result);
- badge_count = 0;
- }
-
- return (int)badge_count;
-}
-
-static void __set_icon_color(Evas_Object *icon_layout, COLOR color)
-{
- Evas_Object *icon = NULL;
-
- icon = elm_object_part_content_get(icon_layout, APPS_ICON);
- if (icon == NULL) {
- _E("Failed to get icon");
- return;
- }
-
- evas_object_color_set(icon, color.r, color.g, color.b, color.a);
-}
-
-static void __icon_drop(void)
-{
- _D("%s", __func__);
-
- Evas_Object *edje_obj = NULL;
- int blank_pos = INVALID_VALUE;
-
- if (apps_animator_is_ongoing()) {
- apps_animator_stop();
- }
-
- edje_obj = elm_layout_edje_get(s_info.picked_icon->layout);
- edje_object_signal_emit(edje_obj, SIGNAL_APPS_ICON_DEFAULT, SIGNAL_SOURCE);
-
- __set_icon_color(s_info.picked_icon->layout, ICON_DEFAULT);
-
- blank_pos = __get_blank_position();
- if (blank_pos >= ICON_0 && blank_pos <= ICON_9) {
- int x, y;
- __apps_view_circle_get_pos(APPS_ICON_RADIUS, ICON_ANGLE[blank_pos], &x, &y);
- x -= APPS_ICON_W / 2;
- y -= APPS_ICON_H / 2;
- __apps_view_circle_animator_icon_move_to_blank(s_info.picked_icon->layout, x, y,
- APPS_ICON_MOVE_TIME, __icon_drop_cb);
- return;
- }
-
- __icon_drop_cb();
-}
-
-static void __icon_drop_cb(void)
-{
- __destroy_picked_icon();
-
- if (s_info.callback == NULL) {
- _E("view callback is null");
- return ;
- }
-
- (*s_info.callback->drop_icon)();
-}
-
-static int __get_blank_position(void)
-{
- int pos = 0;
-
- for (pos = 0; pos < s_info.current_icon_count; pos++) {
- if (s_info.icon_info[pos]->icon_type == ICON_TYPE_BLANK) {
- return pos;
- }
- }
-
- return INVALID_VALUE;
-}
-
-static void __push_icon(int push_area)
-{
- int blank_pos = __get_blank_position();
- int picked_icon_idx = 0;
-
- if (s_info.picked_icon == NULL) {
- _E("picked icon is null");
- return ;
- }
-
- picked_icon_idx = s_info.picked_icon->icon_idx;
-
- if (s_info.icon_info[push_area]->is_editable == false) {
- _D("icon is not editable");
- return ;
- }
-
- apps_view_circle_touch_handler_block_event();
-
- if (s_info.callback != NULL) {
- (*s_info.callback->drag_hold_icon)(s_info.picked_icon->icon_idx, s_info.icon_info[push_area]->icon_idx);
- }
- s_info.picked_icon->icon_idx = s_info.icon_info[push_area]->icon_idx;
-
- if (blank_pos == INVALID_VALUE) {
- if (picked_icon_idx < s_info.icon_info[push_area]->icon_idx) {
- __move_icon_group(1, push_area, COUNT_CLOCKWISE, ANIMATION_OPTION_PUSING);
- } else {
- __move_icon_group(s_info.current_icon_count - 1, push_area, CLOCKWISE, ANIMATION_OPTION_PUSING);
- }
- } else if (blank_pos > push_area) {
- evas_object_hide(s_info.icon_info[blank_pos]->layout);
-
- __move_icon_group(blank_pos - 1, push_area, CLOCKWISE, ANIMATION_OPTION_DEFAULT);
- } else if (blank_pos < push_area) {
- evas_object_hide(s_info.icon_info[blank_pos]->layout);
-
- __move_icon_group(blank_pos + 1, push_area, COUNT_CLOCKWISE, ANIMATION_OPTION_DEFAULT);
- }
-}
-
-static void __move_icon_group(int from, int to, APPS_ROTATION rotation, ANIMATOR_OPTION option)
-{
- Eina_List *layout_list = NULL;
- Eina_List *cur_angle_list = NULL;
- Eina_List *dest_angle_list = NULL;
- int idx = from;
- int dest_idx = from + rotation;
-
- while (dest_idx != to) {
- if (s_info.icon_info[dest_idx]->icon_type == ICON_TYPE_APP && !s_info.icon_info[dest_idx]->is_editable) {
- dest_idx -= rotation;
- continue;
- }
-
- if (s_info.icon_info[idx]->is_editable) {
- _D("add icon to animation queue (%d->%d)", idx, dest_idx);
-
- layout_list = eina_list_append(layout_list, s_info.icon_info[idx]->layout);
- cur_angle_list = eina_list_append(cur_angle_list, &ICON_ANGLE[idx]);
- dest_angle_list = eina_list_append(dest_angle_list, &ICON_ANGLE[dest_idx]);
- dest_idx -= rotation;
- }
-
- idx -= rotation;
- }
-
- __apps_view_circle_animator_rotation(layout_list, cur_angle_list, dest_angle_list,
- APPS_ICON_RADIUS, APPS_ICON_W, APPS_ICON_H, APPS_ICON_PUSH_TIME, option, __move_icon_complete_cb);
-}
-
-static void __move_icon_complete_cb(void)
-{
- __apps_view_base_show_complete();
- apps_view_circle_touch_handler_unblock_event();
-}
-
-static void __destroy_picked_icon(void)
-{
- __apps_view_circle_icon_destroy(s_info.picked_icon);
- s_info.picked_icon = NULL;
-}
diff --git a/src/apps/apps_view_circle_indicator.c b/src/apps/apps_view_circle_indicator.c
deleted file mode 100755
index 16a123e..0000000
--- a/src/apps/apps_view_circle_indicator.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_view.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_edje_conf.h"
-#include "apps/apps_callback_manager.h"
-#include "util.h"
-#include "log.h"
-
-#define APPS_INDICATOR_EDJE EDJE_DIR"/circle/apps_indicator.edj"
-#define APPS_INDICATOR_IMAGE_PATH IMAGE_DIR"/home_indicator_horizontal_dot.png"
-
-static struct __circle_indicator_s {
- int cur_unit;
- int unit_count;
- Evas_Object *layout;
- Evas_Object *grid;
- Evas_Object *unit[APPS_INDICATOR_MAX_COUNT];
- apps_callback_t *page_count_changed_cb_stack;
- apps_callback_t *page_focus_changed_cb_stack;
-} s_info = {
- .cur_unit = 0,
- .unit_count = 0,
- .layout = NULL,
- .grid = NULL,
- .unit = { NULL, },
- .page_count_changed_cb_stack = NULL,
- .page_focus_changed_cb_stack = NULL,
-};
-
-Evas_Object *__apps_view_circle_indicator_create(
- Evas_Object* base_layout,
- apps_callback_t *page_count_changed_cb_stack,
- apps_callback_t *page_focus_changed_cb_stack);
-void __apps_view_circle_indicator_destory(Evas_Object* indicator_layout);
-
-static Evas_Object *__create_layout(Evas_Object *base_layout);
-static Evas_Object *__create_grid(Evas_Object *layout);
-static bool __create_unit(Evas_Object *grid);
-static void __page_focus_changed_cb(void *data);
-static void __page_count_changed_cb(void *data);
-static double __get_unit_angle(int unit_count, int page_idx);
-
-extern void __apps_view_circle_get_pos(int radius, double angle, int *x, int *y);
-
-Evas_Object *__apps_view_circle_indicator_create(
- Evas_Object* base_layout,
- apps_callback_t *page_count_changed_cb_stack,
- apps_callback_t *page_focus_changed_cb_stack)
-{
- _D("%s", __func__);
- s_info.layout = __create_layout(base_layout);
- if (s_info.layout == NULL) {
- _E("Failed to create indicator layout");
- goto __fail;
- }
-
- s_info.grid = __create_grid(s_info.layout);
- if (s_info.grid == NULL) {
- _E("Failed to create indicator grid");
- goto __fail;
- }
-
- if (!__create_unit(s_info.grid)) {
- _E("Failed to create indicator unit");
- goto __fail;
- }
- apps_callback_manager_register_cb(page_count_changed_cb_stack, __page_count_changed_cb);
- apps_callback_manager_register_cb(page_focus_changed_cb_stack, __page_focus_changed_cb);
- return s_info.layout;
-
-__fail:
- __apps_view_circle_indicator_destory(s_info.layout);
- return NULL;
-}
-
-void __apps_view_circle_indicator_destory(Evas_Object* indicator_layout)
-{
- int i = 0;
-
- apps_callback_manager_deregister_cb(s_info.page_focus_changed_cb_stack, __page_focus_changed_cb);
- apps_callback_manager_deregister_cb(s_info.page_count_changed_cb_stack, __page_count_changed_cb);
-
- for (i = 0; i < APPS_INDICATOR_MAX_COUNT; i++) {
- destroy_evas_object(s_info.unit[i]);
- s_info.unit[i] = NULL;
- }
- destroy_evas_object(s_info.grid);
- destroy_evas_object(s_info.layout);
-
- s_info.grid = NULL;
- s_info.layout = NULL;
-}
-
-static Evas_Object *__create_layout(Evas_Object *base_layout)
-{
- Evas_Object *layout = NULL;
- Evas_Object *size_setter = NULL;
-
- layout = elm_layout_add(base_layout);
- if (layout == NULL) {
- _E("Failed to add indicator layout");
- goto __fail;
- }
-
- if (!elm_layout_file_set(layout, util_get_res_file_path(APPS_INDICATOR_EDJE), APPS_INDICATOR_LAYOUT)) {
- _E("Failed to set layout file");
- goto __fail;
- }
-
- evas_object_size_hint_align_set(layout, 0, 0);
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_hide(layout);
-
- size_setter = evas_object_rectangle_add(evas_object_evas_get(layout));
- if (size_setter == NULL) {
- _E("Failed to create size setter");
- goto __fail;
- }
- evas_object_size_hint_min_set(size_setter, WINDOW_W, WINDOW_H);
- evas_object_size_hint_weight_set(size_setter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(size_setter, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_color_set(size_setter, 0, 0, 0, 0);
- elm_object_part_content_set(layout, SIZE_SETTER, size_setter);
-
- return layout;
-
-__fail:
- destroy_evas_object(size_setter);
- destroy_evas_object(layout);
-
- return NULL;
-}
-
-static Evas_Object *__create_grid(Evas_Object *layout)
-{
- Evas_Object *grid = elm_grid_add(layout);
- if (grid == NULL) {
- _E("Failed to add indicator grid");
- return NULL;
- }
- evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_grid_size_set(grid, WINDOW_W, WINDOW_H);
-
- elm_layout_content_set(layout, APPS_INDICATOR_GRID, grid);
-
- return grid;
-}
-
-static bool __create_unit(Evas_Object *grid)
-{
- int i = 0;
- for (i = 0; i < APPS_INDICATOR_MAX_COUNT; i++) {
- s_info.unit[i] = elm_image_add(grid);
- if (s_info.unit[i] == NULL) {
- _E("Failed to add indicator unit image");
- return false;
- }
-
- if (EINA_FALSE == elm_image_file_set(s_info.unit[i], util_get_res_file_path(APPS_INDICATOR_IMAGE_PATH), NULL)) {
- _E("Failed to set indicator unit image file");
- return false;
- }
-
- evas_object_resize(s_info.unit[i], APPS_INDICATOR_UNIT_W, APPS_INDICATOR_UNIT_H);
- evas_object_move(s_info.unit[i], OUTSIDE_X, OUTSIDE_Y);
- evas_object_show(s_info.unit[i]);
- }
-
- return true;
-}
-
-static void __page_focus_changed_cb(void *data)
-{
- int i = 0;
- int *focus_unit = (int *)data;
- if (focus_unit == NULL || focus_unit < 0) {
- _E("focus page is wrong");
- return ;
- }
-
- if (*focus_unit > APPS_INDICATOR_MAX_COUNT -1) {
- *focus_unit = APPS_INDICATOR_MAX_COUNT -1;
- }
-
- _D("focus page is changed [%d -> %d]", s_info.cur_unit, *focus_unit);
-
- for (i = 0; i < s_info.unit_count; i++) {
- if (i == *focus_unit) {
- evas_object_color_set(s_info.unit[i], INDICATOR_UNIT_FOCUS.r, INDICATOR_UNIT_FOCUS.g, INDICATOR_UNIT_FOCUS.b, INDICATOR_UNIT_FOCUS.a);
- } else {
- evas_object_color_set(s_info.unit[i], INDICATOR_UNIT_UNFOCUS.r, INDICATOR_UNIT_UNFOCUS.g, INDICATOR_UNIT_UNFOCUS.b, INDICATOR_UNIT_UNFOCUS.a);
- }
- }
-
- s_info.cur_unit = *focus_unit;
-}
-
-static void __page_count_changed_cb(void *data)
-{
- int i = 0;
- int *page_cnt = (int *)data;
- if (page_cnt == NULL || page_cnt < 0) {
- _E("page count is wrong");
- return ;
- }
-
- if(*page_cnt > APPS_INDICATOR_MAX_COUNT) {
- *page_cnt = APPS_INDICATOR_MAX_COUNT;
- }
-
- _D("page count is changed [%d -> %d]", s_info.unit_count, *page_cnt);
-
- for (i = 0; i < s_info.unit_count; i++) {
- elm_grid_unpack(s_info.grid, s_info.unit[i]);
- evas_object_move(s_info.unit[i], OUTSIDE_X, OUTSIDE_Y);
- }
-
- for (i = 0; i < *page_cnt; i++) {
- int x = 0;
- int y = 0;
- double angle = __get_unit_angle(*page_cnt, i);
- __apps_view_circle_get_pos(APPS_INDICATOR_UNIT_RADIUS, angle, &x, &y);
- x -= (APPS_INDICATOR_UNIT_W/2);
- y -= (APPS_INDICATOR_UNIT_H/2);
- elm_grid_pack(s_info.grid, s_info.unit[i],
- x, y,
- APPS_INDICATOR_UNIT_W, APPS_INDICATOR_UNIT_H);
- }
-
- s_info.unit_count = *page_cnt;
-}
-
-static double __get_unit_angle(int unit_count, int page_idx)
-{
- int center = unit_count / 2;
- double angle = (page_idx - center) * APPS_INDICATOR_UNIT_ANGLE;
- if ((unit_count % 2) == 0)
- angle += APPS_INDICATOR_UNIT_ANGLE / 2.0;
-
- return angle;
-}
diff --git a/src/apps/apps_view_circle_touch_handler.c b/src/apps/apps_view_circle_touch_handler.c
deleted file mode 100755
index b59d859..0000000
--- a/src/apps/apps_view_circle_touch_handler.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apps/apps_view.h"
-#include "apps/apps_conf.h"
-#include "apps/apps_animator.h"
-#include "apps/apps_view_callback.h"
-#include "apps/apps_view_conf.h"
-#include "apps/apps_view_edje_conf.h"
-#include "apps/apps_view_circle_touch_handler.h"
-#include "util.h"
-#include "log.h"
-
-#define LONG_PRESS_TIME 0.75
-#define HOLD_TIME 1.00
-#define BLOCK_TIME 3.0
-
-#define TOUCHAREA_LAYOUT_EDJE EDJE_DIR"/circle/apps_touch_area.edj"
-
-const double radian_to_degree = 57.29577951;
-const double area_angle[12] = { 14.0, 35.0, 33.0, 32.5, 32.5, 33.0, 33.0, 32.5, 32.5, 33.0, 35.0, 14.0 };
-
-static struct __touch_area_s {
- Evas_Object *layout;
- bool pressed;
- bool long_pressed;
- bool is_block_event;
- int pressed_area_idx;
- int hold_area_idx;
- Evas_Point down;
- Evas_Point move;
- Evas_Point up;
- Ecore_Timer *long_press_timer;
- Ecore_Timer *hold_timer;
- Ecore_Timer *block_timer;
-} s_info = {
- .layout = NULL,
- .pressed = false,
- .long_pressed = false,
- .is_block_event = false,
- .pressed_area_idx = INVALID_VALUE,
- .hold_area_idx = INVALID_VALUE,
- .down = { -1, -1 },
- .move = { -1, -1 },
- .up = { -1, -1 },
- .long_press_timer = NULL,
- .hold_timer = NULL,
- .block_timer = NULL,
-};
-
-int __apps_view_circle_touch_handler_get_tap_hold_area(void);
-
-static void __down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void __move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void __up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static Eina_Bool __long_press_timer_cb(void *data);
-static Eina_Bool __hold_timer_cb(void *data);
-static double __get_distance(int x1, int y1, int x2, int y2);
-static int __get_area_index(int x, int y);
-static void __add_long_press_timer(void *data);
-static void __delete_long_press_timer(void);
-static void __add_hold_timer(void *data);
-static void __delete_hold_timer(void);
-static void __add_block_timer(void);
-static void __delete_block_timer(void);
-
-extern void __apps_view_circle_icon_press(int touch_area);
-extern void __apps_view_circle_icon_release(int touch_area);
-extern void __apps_view_circle_tap_focus_text(void);
-extern void __apps_view_circle_tap_icon(int touch_area);
-extern void __apps_view_circle_tap_hold_focus_text(void);
-extern void __apps_view_circle_tap_hold_empty_area(void);
-extern void __apps_view_circle_tap_hold_icon(int touch_area);
-extern void __apps_view_circle_icon_drag_hold(int hold_area);
-extern void __apps_view_circle_icon_drag(int cur_x, int cur_y);
-extern void __apps_view_circle_hold_up(void);
-extern void __apps_view_circle_swipe_left(void);
-extern void __apps_view_circle_swipe_right(void);
-extern void __apps_view_circle_focus_text_press(void);
-extern void __apps_view_circle_focus_text_release(void);
-
-ERROR_E apps_view_circle_touch_handler_init(void)
-{
- _D("%s", __func__);
-
- Evas_Object *base_win = apps_view_get_main_window();
-
- Evas_Object *layout = NULL;
- Evas_Object *size_setter = NULL;
-
- layout = elm_layout_add(base_win);
- if (layout == NULL) {
- _E("Failed to add apps touch area layout");
- goto __fail;
- }
-
- if (!elm_layout_file_set(layout, util_get_res_file_path(TOUCHAREA_LAYOUT_EDJE), APPS_TOUCH_AREA)) {
- _E("Failed to set touch area layout file");
- goto __fail;
- }
-
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(layout);
-
- size_setter = evas_object_rectangle_add(evas_object_evas_get(layout));
- if (size_setter == NULL) {
- _E("Failed to create size setter");
- goto __fail;
- }
- evas_object_size_hint_min_set(size_setter, WINDOW_W, WINDOW_H);
- evas_object_size_hint_weight_set(size_setter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(size_setter, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_color_set(size_setter, TRANCEPARENT_BG.r, TRANCEPARENT_BG.g, TRANCEPARENT_BG.b, TRANCEPARENT_BG.a);
- elm_object_part_content_set(layout, SIZE_SETTER, size_setter);
-
- evas_object_event_callback_add(size_setter, EVAS_CALLBACK_MOUSE_DOWN, __down_cb, NULL);
- evas_object_event_callback_add(size_setter, EVAS_CALLBACK_MOUSE_MOVE, __move_cb, NULL);
- evas_object_event_callback_add(size_setter, EVAS_CALLBACK_MOUSE_UP, __up_cb, NULL);
-
- s_info.layout = layout;
-
- return ERROR_NONE;
-
-__fail:
- destroy_evas_object(size_setter);
- destroy_evas_object(layout);
-
- return ERROR_NONE;
-}
-
-void apps_view_circle_touch_handler_fini(void)
-{
- destroy_evas_object(s_info.layout);
- s_info.layout = NULL;
-}
-
-void apps_view_circle_touch_handler_block_event(void)
-{
- s_info.is_block_event = true;
-
- __add_block_timer();
-}
-
-void apps_view_circle_touch_handler_unblock_event(void)
-{
- s_info.is_block_event = false;
-
- __delete_block_timer();
-}
-
-int __apps_view_circle_touch_handler_get_tap_hold_area(void)
-{
- int touch_area = 0;
-
- if (!s_info.long_pressed) {
- return INVALID_VALUE;
- }
-
- touch_area = __get_area_index(s_info.down.x, s_info.down.y);
-
- return touch_area;
-}
-
-static void __down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Down *ev = event_info;
-
- if (apps_animator_is_ongoing()) {
- _D("skip touch down. animation is ongoing.");
- return ;
- }
-
- if (s_info.is_block_event) {
- _D("skip touch down. touch event is blocked");
- return ;
- }
-
- s_info.pressed = true;
-
- _D("down(%d, %d)", ev->output.x, ev->output.y);
-
- s_info.down.x = s_info.move.x = ev->output.x;
- s_info.down.y = s_info.move.y = ev->output.y;
-
- s_info.pressed_area_idx = __get_area_index(ev->output.x, ev->output.y);
- if (s_info.pressed_area_idx >= ICON_0 && s_info.pressed_area_idx <= ICON_9) {
- __apps_view_circle_icon_press(s_info.pressed_area_idx);
- } else if (s_info.pressed_area_idx == TEXT_AREA) {
- __apps_view_circle_focus_text_press();
- }
-
- __add_long_press_timer(&s_info.pressed_area_idx);
-}
-
-static void __move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Move *ev = event_info;
- if (!s_info.pressed) {
- return;
- }
-
- s_info.move.x = ev->cur.output.x;
- s_info.move.y = ev->cur.output.y;
-
- if (s_info.long_pressed) {
- int area = __get_area_index(s_info.move.x, s_info.move.y);
- __apps_view_circle_icon_drag(s_info.move.x, s_info.move.y);
-
- if (s_info.hold_area_idx != area) {
- s_info.hold_area_idx = area;
- __add_hold_timer(&s_info.hold_area_idx);
- }
-
- return ;
- }
-
- if (__get_distance(s_info.down.x, s_info.move.x, s_info.down.y, s_info.move.y) > APPS_TOUCH_MOVE_MIN_DISTANCE) {
- __delete_long_press_timer();
- return ;
- }
-}
-
-static void __up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Up *ev = event_info;
- int touch_area = __get_area_index(ev->output.x, ev->output.y);
- double move_distance = 0.0;
- if (!s_info.pressed) {
- return;
- }
-
- s_info.pressed = false;
- __delete_long_press_timer();
-
- s_info.hold_area_idx = INVALID_VALUE;
- __delete_hold_timer();
-
- _D("up(%d, %d)", ev->output.x, ev->output.y);
-
- s_info.up.x = ev->output.x;
- s_info.up.y = ev->output.y;
-
- if (s_info.pressed_area_idx >= ICON_0 && s_info.pressed_area_idx <= ICON_9) {
- __apps_view_circle_icon_release(s_info.pressed_area_idx);
- } else if(s_info.pressed_area_idx == TEXT_AREA) {
- __apps_view_circle_focus_text_release();
- }
-
- if (s_info.long_pressed) {
- s_info.long_pressed = false;
- __apps_view_circle_hold_up();
- return ;
- }
-
- move_distance = __get_distance(s_info.down.x, s_info.up.x, s_info.down.y, s_info.up.y);
- if (touch_area == s_info.pressed_area_idx && move_distance <= APPS_TOUCH_MOVE_MIN_DISTANCE) {
- if (touch_area == TEXT_AREA) {
- __apps_view_circle_tap_focus_text();
- } else if (touch_area >= ICON_0 && touch_area <= ICON_9) {
- __apps_view_circle_tap_icon(touch_area);
- }
- return ;
- }
-
- if (s_info.up.x - s_info.down.x > APPS_SWIPE_MIN_DISTANCE) {
- __apps_view_circle_swipe_right();
- } else if (s_info.down.x - s_info.up.x > APPS_SWIPE_MIN_DISTANCE) {
- __apps_view_circle_swipe_left();
- }
-}
-
-static Eina_Bool __long_press_timer_cb(void *data)
-{
- int touch_area = *((int*)data);
- if (!s_info.pressed) {
- s_info.long_press_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
-
- if (s_info.is_block_event) {
- s_info.long_press_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
-
- _D("page long press");
-
- s_info.long_pressed = true;
-
- if (touch_area == TEXT_AREA) {
- __apps_view_circle_tap_hold_focus_text();
- } else if (touch_area == EMPTY_AREA) {
- __apps_view_circle_tap_hold_empty_area();
- } else if (touch_area >= ICON_0 && touch_area <= ICON_9) {
- __apps_view_circle_tap_hold_icon(touch_area);
- }
-
- s_info.long_press_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool __hold_timer_cb(void *data)
-{
- int hold_area = *((int*)data);
- if (!s_info.long_pressed) {
- s_info.hold_timer = NULL;
- s_info.hold_area_idx = INVALID_VALUE;
- return ECORE_CALLBACK_CANCEL;
- }
-
- if (s_info.is_block_event) {
- s_info.hold_timer = NULL;
- s_info.hold_area_idx = INVALID_VALUE;
- return ECORE_CALLBACK_CANCEL;
- }
-
- _D("drag hold %d", hold_area);
-
- if (hold_area >= ICON_0 && hold_area <= ICON_9) {
- __apps_view_circle_icon_drag_hold(hold_area);
- }
-
- return ECORE_CALLBACK_RENEW;
-}
-
-static Eina_Bool __block_timer_cb(void *data)
-{
- s_info.is_block_event = false;
-
- s_info.block_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
-}
-
-static double __get_distance(int x1, int x2, int y1, int y2)
-{
- return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
-}
-
-static int __get_area_index(int x, int y)
-{
- int idx = 1;
- double touch_angle = 0.0;
- double angle = 0.0;
- double radius = __get_distance(x, WINDOW_CENTER_X, y, WINDOW_CENTER_Y);
-
- if (radius < APPS_FOCUS_TEXT_RADIUS) {
- return TEXT_AREA;
- }
-
- if (radius < APPS_EMPTY_AREA_RADIUS) {
- return EMPTY_AREA;
- }
-
- touch_angle = atan((double)(WINDOW_CENTER_Y - y) / (WINDOW_CENTER_X - x)) * radian_to_degree;
-
- if (x >= WINDOW_CENTER_X) {
- touch_angle += 90.0;
- } else {
- touch_angle += 270.0;
- }
-
- angle = area_angle[0];
- for (idx = 1; idx <= APPS_ICON_COUNT_PER_PAGE; idx++) {
- if (touch_angle >= angle && touch_angle < angle + area_angle[idx]) {
- return idx - 1;
- }
- angle += area_angle[idx];
- }
-
- return EMPTY_AREA;
-}
-
-static void __add_long_press_timer(void *data)
-{
- __delete_long_press_timer();
-
- s_info.long_press_timer = ecore_timer_add(LONG_PRESS_TIME, __long_press_timer_cb, data);
- if (s_info.long_press_timer == NULL) {
- _E("Failed to add page long press timer");
- }
-}
-
-static void __delete_long_press_timer(void)
-{
- if (s_info.long_press_timer != NULL) {
- ecore_timer_del(s_info.long_press_timer);
- s_info.long_press_timer = NULL;
- }
-}
-
-static void __add_hold_timer(void *data)
-{
- __delete_hold_timer();
-
- s_info.hold_timer = ecore_timer_add(LONG_PRESS_TIME, __hold_timer_cb, data);
- if (s_info.hold_timer == NULL) {
- _E("Failed add hold timer");
- }
-}
-
-static void __delete_hold_timer(void)
-{
- if (s_info.hold_timer != NULL) {
- ecore_timer_del(s_info.hold_timer);
- s_info.hold_timer = NULL;
- }
-}
-
-static void __add_block_timer(void)
-{
- __delete_block_timer();
-
- s_info.block_timer = ecore_timer_add(BLOCK_TIME, __block_timer_cb, NULL);
- if (s_info.block_timer == NULL) {
- _E("Failed add block timer");
- }
-}
-
-static void __delete_block_timer(void)
-{
- if (s_info.block_timer != NULL) {
- ecore_timer_del(s_info.block_timer);
- s_info.block_timer = NULL;
- }
-}
diff --git a/src/apps/apps_view_conf.c b/src/apps/apps_view_conf.c
deleted file mode 100755
index 5dfc96a..0000000
--- a/src/apps/apps_view_conf.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-
-#include "log.h"
-#include "apps/apps_conf.h"
-
-static int window_width = 360;
-static int window_height = 360;
-static double resolution_scale_h = 1.0;
-static double resolution_scale_w = 1.0;
-
-static int supported_resolution[10][2] = { {320, 320}, {360, 360}, {360, 480}, {0, 0}, };
-
-int _get_window_h(void)
-{
- return window_height;
-}
-
-int _get_window_w(void)
-{
- return window_width;
-}
-
-double _get_resolution_scale_h()
-{
- return resolution_scale_h;
-}
-
-double _get_resolution_scale_w()
-{
- return resolution_scale_w;
-}
-
-void apps_view_conf_set_resolution(int w, int h)
-{
- window_width = w;
- window_height = h;
- resolution_scale_w = (double)window_width / 360;
- resolution_scale_h = (double)window_height / 360;
-}
-
-bool apps_view_conf_is_supported_resolution(int w, int h)
-{
- int idx = 0;
- for (idx = 0; supported_resolution[idx][0] > 0; idx++) {
- if (w == supported_resolution[idx][0] && h == supported_resolution[idx][1])
- break;
- }
- return supported_resolution[idx][0] == 0 ? false : true;
-}
diff --git a/src/bg.c b/src/bg.c
deleted file mode 100755
index 50839c4..0000000
--- a/src/bg.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdbool.h>
-#include <Elementary.h>
-#include <Evas.h>
-#include <vconf.h>
-#include <dlog.h>
-#include <bundle.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "bg.h"
-#include "dbus.h"
-
-#define VCONFKEY_WMS_BG_MODE "db/wms/home_bg_mode"
-#define VCONFKEY_WMS_BG_PALETTE "db/wms/home_bg_palette"
-#define VCONFKEY_WMS_BG_GALLERY "db/wms/home_bg_gallery"
-#define BG_DEFAULT_ALPHA 127
-
-
-
-typedef enum {
- BG_TYPE_COLOR = 0,
- BG_TYPE_IMAGE,
- BG_TYPE_GALLERY,
- BG_TYPE_MAX,
-} bg_type_e;
-
-
-
-static bg_type_e _get_bg_type(void)
-{
- /* 0 : Color, 1 : Image, 2 : Gallery */
- int val = -1;
-
- if(vconf_get_int(VCONFKEY_WMS_BG_MODE, &val) < 0) {
- _E("Failed to get WMS_HOME_BG_MODE");
- return BG_TYPE_IMAGE;
- }
-
- return val;
-}
-
-
-
-HAPI void bg_set_rgb(Evas_Object *bg, const char *buf)
-{
- int rgb;
- int r;
- int g;
- int b;
-
- ret_if(!bg);
- ret_if(!buf);
-
- rgb = strtoul(buf, NULL, 16);
-
- r = (rgb & 0x00FF0000) >> 16;
- g = (rgb & 0x0000FF00) >> 8;
- b = rgb & 0x000000FF;
-
- elm_bg_color_set(bg, r, g, b);
- elm_bg_file_set(bg, NULL, NULL);
-}
-
-
-
-#define DEFAULT_BG_PATH "/opt/share/settings/Wallpapers/Home_default.png"
-static void _change_bg(keynode_t *node, void *data)
-{
- bg_type_e bg_type = BG_TYPE_IMAGE;
- Evas_Object *win = data;
- Evas_Object *bg;
- char *buf = NULL;
-
- if (node) {
- _D("BG is changed by vconf");
- }
-
- bg = evas_object_data_get(win, DATA_KEY_BG);
- if (!bg) {
- _E("Cannot get bg");
- return;
- }
-
- bg_type = _get_bg_type();
- switch (bg_type) {
- case BG_TYPE_COLOR:
- buf = vconf_get_str(VCONFKEY_WMS_BG_PALETTE);
- break_if(!buf);
-
- bg_set_rgb(bg, buf);
- break;
- case BG_TYPE_IMAGE:
- case BG_TYPE_GALLERY:
- buf = vconf_get_str(VCONFKEY_BGSET);
- buf = (buf == NULL) ? strdup(DEFAULT_BG_PATH) : buf;
- break_if(!buf);
-
- if (elm_bg_file_set(bg, buf, NULL) == EINA_FALSE) {
- _E("Failed to set BG file:%s", buf);
- } else {
- _D("BG is changed to %s", buf);
- }
- _W("file size:%lld", ecore_file_size(buf));
- break;
- default:
- _E("Cannot reach here");
- break;
- }
- _W("BG : [%d, %s]", bg_type, buf);
- free(buf);
-
- home_dbus_lcd_on_signal_send(EINA_FALSE);
-}
-
-
-
-static void _bg_down_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_info)
-{
- _D("BG is pressed");
-}
-
-
-
-static void _bg_up_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_info)
-{
- _D("BG is released");
-}
-
-
-
-HAPI Evas_Object *bg_create(Evas_Object *win)
-{
- Evas_Object *bg = NULL;
-
-#if 0
- bg = app_get_preinitialized_background();
- if (!bg) bg = elm_bg_add(win);
-#else
- bg = elm_bg_add(win);
-#endif
- retv_if(!bg, NULL);
-
- elm_bg_option_set(bg, ELM_BG_OPTION_SCALE);
- elm_win_resize_object_add(win, bg);
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(bg);
- evas_object_data_set(win, DATA_KEY_BG, bg);
- evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_DOWN, _bg_down_cb, NULL);
- evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_UP, _bg_up_cb, NULL);
-
- if (vconf_notify_key_changed(VCONFKEY_WMS_BG_MODE, _change_bg, win) < 0) {
- _E("Failed to register the VCONFKEY_WMS_BG_MODE callback");
- }
-
- /* Changing the bg after setting DATA_KEY_BG */
- _change_bg(NULL, win);
-
- return bg;
-}
-
-
-
-HAPI void bg_destroy(Evas_Object *win)
-{
- Evas_Object *bg = NULL;
-
- if (vconf_ignore_key_changed(VCONFKEY_WMS_BG_MODE, _change_bg) < 0) {
- _E("Failed to ignore the VCONFKEY_WMS_BG_MODE callback");
- }
-
- evas_object_event_callback_del(bg, EVAS_CALLBACK_MOUSE_DOWN, _bg_down_cb);
- evas_object_event_callback_del(bg, EVAS_CALLBACK_MOUSE_UP, _bg_up_cb);
- bg = evas_object_data_del(win, DATA_KEY_BG);
- ret_if(!bg);
- evas_object_del(bg);
-}
-
-
-
-HAPI void bg_register_object(Evas_Object *obj)
-{
- Evas_Object *bg;
-
- bg = elm_object_part_content_get(obj, "bg");
- if (bg) {
- evas_object_color_set(bg, 0, 0, 0, 0);
- }
-}
-
-
-
-// End of a file
diff --git a/src/clock.c b/src/clock.c
deleted file mode 100755
index 0cedd6a..0000000
--- a/src/clock.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <efl_extension.h>
-#include <watch_control.h>
-#include <vconf.h>
-#include <pkgmgr-info.h>
-#include <pkgmgrinfo_type.h>
-#include <Pepper_Efl.h>
-#include <appsvc.h>
-#include <app_control_internal.h>
-
-#include "conf.h"
-#include "clock_service.h"
-#include "layout.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "page.h"
-#include "notification/noti_panel_mgr.h"
-
-static struct {
- Evas_Object *cur_watch;
- Evas_Object *clock_page;
- int pid;
- int launched;
-} clock_info_s = {
- .cur_watch = NULL,
- .clock_page = NULL,
- .pid = -1,
- .launched = 0,
-};
-
-static struct {
- int is_left;
- int is_right;
-} indicator_data = {
- .is_left = 0,
- .is_right = 0
-};
-
-#define IMG_FLIGHT_MODE IMAGEDIR"/basic_clock_comp_indi_airplanemode.png"
-#define IMG_DND_ICON IMAGEDIR"/basic_clock_comp_indi_donotdisturb.png"
-#define PRIVATE_DATA_KEY_CLOCK_LAYOUT "data_key_clock_layout"
-
-static Evas_Object *_scroller_get(void)
-{
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
-
- if (win != NULL) {
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- if (layout != NULL) {
- scroller = elm_object_part_content_get(layout, "scroller");
- }
- }
-
- return scroller;
-}
-
-
-static void _del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *page = obj;
- Evas_Object *layout = data;
- Evas_Object *obj_sub = NULL;
- ret_if(!page);
- ret_if(!layout);
-
- obj_sub = elm_object_part_content_unset(layout, "clock_bg");
- if (obj_sub != NULL) {
- evas_object_del(obj_sub);
- }
- obj_sub = elm_object_part_content_unset(layout, "event_blocker");
- if (obj_sub != NULL) {
- evas_object_del(obj_sub);
- }
-}
-
-static void _clock_set_dnd_icon(int is_dnd_mode, Evas_Object *layout)
-{
- Evas_Object *image = NULL;
- image = elm_image_add(layout);
-
- if (is_dnd_mode) {
- elm_image_file_set(image, IMG_DND_ICON, NULL);
- if (indicator_data.is_left == 0) {
- indicator_data.is_left = 1;
- elm_object_part_content_set(layout, "indicator.1", image);
- elm_object_signal_emit(layout, "show", "indicator.icon.1");
- } else if (indicator_data.is_right == 0) {
- indicator_data.is_right = 1;
- elm_object_part_content_set(layout, "indicator.2", image);
- elm_object_signal_emit(layout, "show", "indicator.icon.2");
- }
- } else {
- if (indicator_data.is_right == 1) {
- indicator_data.is_right = 0;
- elm_object_signal_emit(layout, "hide", "indicator.icon.2");
- } else if (indicator_data.is_left == 1) {
- if (indicator_data.is_right == 2) {
- indicator_data.is_left = indicator_data.is_right;
- indicator_data.is_right = 0;
-
- elm_image_file_set(image, IMG_FLIGHT_MODE, NULL);
- elm_object_part_content_set(layout, "indicator.1", image);
- elm_object_signal_emit(layout, "hide", "indicator.icon.2");
- } else {
- indicator_data.is_left = 0;
- elm_object_signal_emit(layout, "hide", "indicator.icon.1");
- }
- }
- }
-}
-
-static void _clock_set_flight_mode_icon(int is_flight_mode, Evas_Object *layout)
-{
- Evas_Object *image = NULL;
- image = elm_image_add(layout);
-
- if (is_flight_mode) {
- elm_image_file_set(image, IMG_FLIGHT_MODE, NULL);
- if (indicator_data.is_left == 0) {
- indicator_data.is_left = 2;
- elm_object_part_content_set(layout, "indicator.1", image);
- elm_object_signal_emit(layout, "show", "indicator.icon.1");
- } else if (indicator_data.is_right == 0) {
- indicator_data.is_right = 2;
- elm_object_part_content_set(layout, "indicator.2", image);
- elm_object_signal_emit(layout, "show", "indicator.icon.2");
- }
- } else {
- if (indicator_data.is_right == 2) {
- indicator_data.is_right = 0;
- elm_object_signal_emit(layout, "hide", "indicator.icon.2");
- } else if (indicator_data.is_left == 2) {
- if (indicator_data.is_right == 1) {
- indicator_data.is_left = indicator_data.is_right;
- indicator_data.is_right = 0;
-
- elm_image_file_set(image, IMG_DND_ICON, NULL);
- elm_object_part_content_set(layout, "indicator.1", image);
- elm_object_signal_emit(layout, "hide", "indicator.icon.2");
- } else {
- indicator_data.is_left = 0;
- elm_object_signal_emit(layout, "hide", "indicator.icon.1");
- }
- }
- }
-}
-
-static void _clock_set_dnd_status_changed_cb(keynode_t *node EINA_UNUSED, void *data)
-{
- ret_if(!data);
- Evas_Object *layout = data;
-
- int is_dnd_mode = 0;
- int ret = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, &is_dnd_mode);
-
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, ret);
- return;
- }
-
- _clock_set_dnd_icon(is_dnd_mode, layout);
-}
-
-static void _clock_set_flight_mode_status_changed_cb(keynode_t *node EINA_UNUSED, void *data)
-{
- ret_if(!data);
- Evas_Object *layout = data;
-
- int is_flight_mode = 0;
- int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight_mode);
-
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_TELEPHONY_FLIGHT_MODE, ret);
- return;
- }
-
- _clock_set_flight_mode_icon(is_flight_mode, layout);
-}
-
-static void _clock_set_noti_indicator_changed_cb(keynode_t *node EINA_UNUSED, void *data)
-{
- ret_if(!data);
- Evas_Object *layout = data;
-
- int is_set_noti_indicator = 0;
- int ret = vconf_get_bool(VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, &is_set_noti_indicator);
-
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, ret);
- return;
- }
-
- if (is_set_noti_indicator)
- clock_service_set_noti_indicator_icon();
- else
- elm_object_signal_emit(layout, "hide", "noti.indicator.icon");
-}
-
-static void _set_vconf_key_changed_cb(Evas_Object *layout)
-{
- int is_flight_mode = 0, is_dnd_mode = 0, is_set_noti_indicator = 0, ret = 0;
-
- ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight_mode);
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_TELEPHONY_FLIGHT_MODE, ret);
- return;
- }
- if (is_flight_mode)
- _clock_set_flight_mode_icon(is_flight_mode, layout);
-
- ret = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, &is_dnd_mode);
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, ret);
- return;
- }
- if (is_dnd_mode)
- _clock_set_dnd_icon(is_dnd_mode, layout);
-
- ret = vconf_get_bool(VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, &is_set_noti_indicator);
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, ret);
- return;
- }
- if (is_set_noti_indicator)
- clock_service_set_noti_indicator_icon();
-
- vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, _clock_set_flight_mode_status_changed_cb, layout);
- vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, _clock_set_dnd_status_changed_cb, layout);
- vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, _clock_set_noti_indicator_changed_cb, layout);
-}
-
-int clock_service_check_noti_indicator_enable()
-{
- int ret, is_set_noti_indicator;
-
- ret = vconf_get_bool(VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, &is_set_noti_indicator);
- if (ret < 0) {
- _E("Failed to get vconfkey(%s) : %d", VCONFKEY_SETAPPL_NOTIFICATION_INDICATOR, ret);
- return 0;
- }
-
- return is_set_noti_indicator;
-}
-
-void clock_service_set_noti_indicator_icon()
-{
- Evas_Object *layout = evas_object_data_get(main_get_info()->clock_focus, "data_key_clock_layout");
- ret_if(!layout);
-
- Eina_Bool result = EINA_FALSE;
- result = noti_panel_mgr_check_focused_page();
-
- if (!result)
- elm_object_signal_emit(layout, "show", "noti.indicator.icon");
- else
- elm_object_signal_emit(layout, "hide", "noti.indicator.icon");
-}
-
-static Evas_Object *_clock_view_add(Evas_Object *parent, Evas_Object *item)
-{
- Eina_Bool ret = EINA_TRUE;
- Evas_Object *page = NULL;
- Evas_Object *layout = NULL;
- Evas_Object *bg = NULL;
- Evas_Object *evb = NULL;
- retv_if(parent == NULL, NULL);
-
- layout = elm_layout_add(parent);
- goto_if(layout == NULL, ERR);
- ret = elm_layout_file_set(layout, PAGE_CLOCK_EDJE_FILE, "clock_page");
- goto_if(ret == EINA_FALSE, ERR);
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(layout);
-
- bg = evas_object_rectangle_add(main_get_info()->e);
- goto_if(bg == NULL, ERR);
- evas_object_size_hint_min_set(bg, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_size_hint_max_set(bg, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_color_set(bg, 0, 0, 0, 0);
- evas_object_show(bg);
- elm_object_part_content_set(layout, "clock_bg", bg);
-
- evb = evas_object_rectangle_add(main_get_info()->e);
- goto_if(evb == NULL, ERR);
- evas_object_size_hint_min_set(evb, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_size_hint_weight_set(evb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_color_set(evb, 0, 0, 0, 0);
- evas_object_show(evb);
- elm_object_part_content_set(layout, "event_blocker", evb);
-
- if (item != NULL) {
- elm_access_object_unregister(item);
- evas_object_size_hint_min_set(item, 360, 360);
- evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(item);
- elm_object_part_content_set(layout, "item", item);
- evas_object_repeat_events_set(item, EINA_TRUE);
- }
-
- page = page_create(parent
- , layout
- , NULL, NULL
- , main_get_info()->root_w, main_get_info()->root_h
- , PAGE_CHANGEABLE_BG_OFF, PAGE_REMOVABLE_OFF);
- goto_if(page == NULL, ERR);
-
- page_set_effect(page, page_effect_none, page_effect_none);
- evas_object_event_callback_add(page, EVAS_CALLBACK_DEL, _del_cb, layout);
- main_get_info()->clock_focus = page;
-
- evas_object_data_set(main_get_info()->clock_focus, PRIVATE_DATA_KEY_CLOCK_LAYOUT, layout);
-
- _set_vconf_key_changed_cb(layout);
-
- return page;
-
-ERR:
- if (bg != NULL) evas_object_del(bg);
- if (evb != NULL) evas_object_del(evb);
- if (layout != NULL) evas_object_del(layout);
-
- return NULL;
-}
-
-
-
-static void _clock_view_exchange(Evas_Object *item)
-{
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(clock_info_s.clock_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- if (item != NULL) {
- elm_access_object_unregister(item);
- evas_object_size_hint_min_set(item, 360, 360);
- evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(item);
- elm_object_part_content_set(page_info->item, "item", item);
- evas_object_repeat_events_set(item, EINA_TRUE);
- }
-}
-
-
-static int _try_to_launch(const char *clock_pkgname)
-{
- app_control_h watch_control = NULL;
-
- int clock_app_pid = 0;
- bundle *b;
-
- if(!clock_pkgname) {
- clock_pkgname = "org.tizen.classic-watch";
- }
-
- clock_info_s.launched = 0;
-
- watch_manager_get_app_control(clock_pkgname, &watch_control);
- app_control_to_bundle(watch_control, &b);
- clock_app_pid = appsvc_run_service(b, 0, NULL, NULL); /* Get pid of launched watch-app */
- _D("appsvc_run_service returns [%d]", clock_app_pid);
- clock_info_s.pid = clock_app_pid;
- app_control_destroy(watch_control);
-
- retv_if(clock_app_pid < 0, -1);
-
- _D("Succeed to launch : %s", clock_pkgname);
-
- return 0;
-}
-
-static void _wms_clock_vconf_cb(keynode_t *node, void *data)
-{
- char *clock_pkgname = NULL;
- int ret = 0;
-
- clock_pkgname = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE);
- if(!clock_pkgname)
- clock_pkgname = "org.tizen.classic-watch";
-
- _D("clock = (%s), is set", clock_pkgname);
- ret = _try_to_launch(clock_pkgname);
-
- if (ret < 0) {
- _E("Fail to launch the watch, retry to launch the default watch");
- _try_to_launch("org.tizen.classic-watch");
- return;
- }
-}
-
-void clock_try_to_launch(int pid)
-{
- _D("pid[%d] clock_info_s.pid[%d[", pid, clock_info_s.pid);
- if (pid != clock_info_s.pid) {
- _D("Dead process is not faulted clock");
- return;
- }
-
- clock_info_s.pid = -1;
-
- if (clock_info_s.launched == 0) {
- _D("clock could not be launched. Use default clock");
- _try_to_launch("org.tizen.classic-watch");
- } else {
- clock_info_s.launched = 0;
- _D("clock is dead. try to relaunch the clock");
- _wms_clock_vconf_cb(NULL, NULL);
- }
-}
-
-static void __watch_added(void *data, Evas_Object *obj, void *event_info)
-{
- _D("watch added");
- Evas_Object *clock = (Evas_Object *)event_info;
- Evas_Object *page = NULL;
- Evas_Object *scroller = (Evas_Object *)data;
-
- if (!clock) {
- _E("Fail to create the clock");
- return;
- }
-
- if (clock_info_s.cur_watch) {
- watch_manager_send_terminate(clock_info_s.cur_watch);
- _clock_view_exchange(clock);
- } else {
- page = _clock_view_add(scroller, clock);
- if (!page) {
- _E("Fail to create the page");
- evas_object_del(clock);
- return;
- }
- if (scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER) != W_HOME_ERROR_NONE) {
- _E("Fail to push the page into scroller");
- }
- clock_info_s.clock_page = page;
- }
-
- clock_info_s.cur_watch = clock;
- clock_info_s.launched = 1;
-}
-
-static void __watch_removed(void *data, Evas_Object *obj, void *event_info)
-{
- _D("watch removed");
- Evas_Object *clock = (Evas_Object *)event_info;
- if (clock)
- evas_object_del(clock);
-}
-
-
-
-void clock_service_init(Evas_Object *win)
-{
- Evas_Object *scroller = _scroller_get();
- char *pkg_name = NULL;
- int ret = 0;
-
- ret_if(!scroller);
-
- ret = vconf_notify_key_changed(VCONFKEY_WMS_CLOCKS_SET_IDLE, _wms_clock_vconf_cb, NULL);
- if (ret < 0)
- _E("Failed to ignore the vconf callback(WMS_CLOCKS_SET_IDLE) : %d", ret);
-
- pkg_name = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE);
-
- if(!pkg_name)
- {
- _D("Failed to get vconf string, launching default clock");
- pkg_name = "org.tizen.classic-watch";
- }
-
- _D("clock = (%s), is set", pkg_name);
-
- watch_manager_init(win);
- evas_object_smart_callback_add(win, WATCH_SMART_SIGNAL_ADDED, __watch_added, scroller);
- evas_object_smart_callback_add(win, WATCH_SMART_SIGNAL_REMOVED, __watch_removed, scroller);
-
- ret = _try_to_launch(pkg_name);
- if (ret < 0) {
- _E("Failed to launch:%s", pkg_name);
- goto done;
- }
-
- return;
-
-done:
- _D("Launching default clock");
- pkg_name = "org.tizen.classic-watch";
-
- ret = _try_to_launch(pkg_name);
- if (ret < 0) {
- _E("Failed to launch:%s", pkg_name);
- goto done;
- }
-}
-
-
-
-void clock_service_fini(void)
-{
- _D("clock service is finished");
- watch_manager_fini();
-}
diff --git a/src/clock/clock_manager.c b/src/clock/clock_manager.c
deleted file mode 100755
index 34cf2d6..0000000
--- a/src/clock/clock_manager.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "clock.h"
-
-ERROR_E clock_init(void)
-{
- _D("%s", __func__);
-
- return ERROR_NONE;
-}
-
-void clock_fini(void)
-{
-
-}
diff --git a/src/critical_log.c b/src/critical_log.c
deleted file mode 100755
index 8e39302..0000000
--- a/src/critical_log.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <string.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include <dlog.h>
-#include <Eina.h>
-#include <widget_errno.h>
-
-#include "util.h"
-#include "critical_log.h"
-
-#if !defined(SECURE_LOGD)
-#define SECURE_LOGD LOGD
-#endif
-
-#if !defined(SECURE_LOGW)
-#define SECURE_LOGW LOGW
-#endif
-
-#if !defined(SECURE_LOGE)
-#define SECURE_LOGE LOGE
-#endif
-
-#if !defined(DbgPrint)
-#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg)
-#endif
-
-#if !defined(ErrPrint)
-#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg)
-#endif
-
-#if !defined(WarnPrint)
-#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg)
-#endif
-
-#define DbgFree(a) free(a)
-
-#define SLAVE_LOG_PATH "/tmp/.w-home_log/"
-#define MAX_LOG_LINE 80
-#define MAX_LOG_FILE 3
-
-#define CRITICAL_SECTION_BEGIN(handle) \
-do { \
- int ret; \
- ret = pthread_mutex_lock(handle); \
- if (ret != 0) \
- { \
- char err_buf[256] = { 0, }; \
- strerror_r(errno, err_buf, sizeof(err_buf)); \
- ErrPrint("Failed to lock: %s\n", err_buf); \
- } \
-} while (0)
-
-#define CRITICAL_SECTION_END(handle) \
-do { \
- int ret; \
- ret = pthread_mutex_unlock(handle); \
- if (ret != 0) \
- { \
- char err_buf[256] = { 0, }; \
- strerror_r(errno, err_buf, sizeof(err_buf)); \
- ErrPrint("Failed to unlock: %s\n", err_buf); \
- } \
-} while (0)
-
-static struct {
- FILE *fp;
- int file_id;
- int nr_of_lines;
- char *filename;
- pthread_mutex_t cri_lock;
-} s_info = {
- .fp = NULL,
- .file_id = 0,
- .nr_of_lines = 0,
- .filename = NULL,
- .cri_lock = PTHREAD_MUTEX_INITIALIZER,
-};
-
-
-
-static inline void rotate_log(void)
-{
- char *filename;
- int namelen;
-
- if (s_info.nr_of_lines < MAX_LOG_LINE) {
- return;
- }
-
- if (!s_info.filename) {
- return;
- }
-
- s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE;
-
- namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 30;
- filename = malloc(namelen);
- if (filename) {
- snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, s_info.filename, getpid());
-
- if (s_info.fp) {
- if (fclose(s_info.fp) != 0) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("fclose: %s\n", err_buf);
- }
- }
-
- s_info.fp = fopen(filename, "w+");
- if (!s_info.fp) {
- ErrPrint("Failed to open a file: %s\n", filename);
- }
-
- DbgFree(filename);
- }
-
- s_info.nr_of_lines = 0;
-}
-
-
-
-HAPI int critical_log(const char *func, int line, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- if (!s_info.fp) {
- return WIDGET_ERROR_IO_ERROR;
- }
-
- CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
-
- fprintf(s_info.fp, "%lf [%s:%d] ", util_timestamp(), util_basename((char *)func), line);
-
- va_start(ap, fmt);
- ret = vfprintf(s_info.fp, fmt, ap);
- va_end(ap);
-
- fflush(s_info.fp);
-
- s_info.nr_of_lines++;
- rotate_log();
-
- CRITICAL_SECTION_END(&s_info.cri_lock);
- return ret;
-}
-
-
-
-HAPI int critical_log_init(const char *name)
-{
- int namelen;
- char *filename;
- char err_buf[256] = { 0, };
-
- if (!name) {
- ErrPrint("name is NULL");
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- if (mkdir(SLAVE_LOG_PATH, 0755) < 0) {
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("mkdir(%s) returns: %s\n", SLAVE_LOG_PATH,err_buf );
- }
-
- if (s_info.fp) {
- return WIDGET_ERROR_NONE;
- }
-
- s_info.filename = strdup(name);
- if (!s_info.filename) {
- ErrPrint("Failed to create a log file\n");
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 30;
-
- filename = malloc(namelen);
- if (!filename) {
- ErrPrint("Failed to create a log file\n");
- DbgFree(s_info.filename);
- s_info.filename = NULL;
- return WIDGET_ERROR_OUT_OF_MEMORY;
- }
-
- snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, name, getpid());
-
- s_info.fp = fopen(filename, "w+");
- if (!s_info.fp) {
- char err_buf[256] = { 0, };
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("Failed to open log: %s\n", err_buf);
- DbgFree(s_info.filename);
- s_info.filename = NULL;
- DbgFree(filename);
- return WIDGET_ERROR_IO_ERROR;
- }
-
- DbgFree(filename);
- return WIDGET_ERROR_NONE;
-}
-
-
-
-HAPI void critical_log_fini(void)
-{
- char err_buf[256] = { 0, };
- if (s_info.filename) {
- DbgFree(s_info.filename);
- s_info.filename = NULL;
- }
-
- if (s_info.fp) {
- if (fclose(s_info.fp) != 0) {
- strerror_r(errno, err_buf, sizeof(err_buf));
- ErrPrint("fclose: %s\n", err_buf);
- }
- s_info.fp = NULL;
- }
-}
-
-
-
-/* End of a file */
diff --git a/src/db.c b/src/db.c
deleted file mode 100755
index 44fe7e9..0000000
--- a/src/db.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <bundle.h>
-#include <Evas.h>
-#include <db-util.h>
-#include <sqlite3.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <Eina.h>
-#include <dlog.h>
-#include <vconf.h>
-#include <app_preference.h>
-#include <app_common.h>
-#include <widget_viewer_evas.h> // WIDGET_VIEWER_EVAS_DEFAULT_PERIOD
-
-#include "util.h"
-#include "db.h"
-#include "log.h"
-#include "page_info.h"
-
-#define retv_with_dbmsg_if(expr, val) do { \
- if (expr) { \
- _E("%s", sqlite3_errmsg(db_info.db)); \
- return (val); \
- } \
-} while (0)
-
-
-
-static struct {
- sqlite3 *db;
- char *db_file;
-} db_info = {
- .db = NULL,
- .db_file = NULL,
-};
-
-struct stmt {
- sqlite3_stmt *stmt;
-};
-
-#define CREATE_HOME_TABLE " \
- PRAGMA journal_mode = PERSIST; \
- CREATE TABLE IF NOT EXISTS home ( \
- id TEXT,\
- subid TEXT,\
- ordering INTEGER);"
-
-HAPI w_home_error_e db_init(db_file_e db_file)
-{
- int r;
- char *errmsg = NULL;
- char *app_data_path = NULL;
- char db_file_path[PATH_MAX] = { 0, };
-
- retv_if(!db_file, W_HOME_ERROR_FAIL);
- db_close();
-
- /* Getting app data path */
- app_data_path = app_get_data_path();
-
- if (app_data_path == NULL) {
- _E("fail to get app data path");
- return W_HOME_ERROR_FAIL;
- }
-
- switch (db_file) {
- case DB_FILE_NORMAL:
- snprintf(db_file_path, PATH_MAX, "%s.home.db", app_data_path);
- break;
- case DB_FILE_TTS:
- snprintf(db_file_path, PATH_MAX, "%s.home_tts.db", app_data_path);
- break;
- default:
- _E("Invalid db_file");
- }
-
- db_info.db_file = strdup(db_file_path);
-
- free(app_data_path);
-
- if (db_info.db_file == NULL) {
- _E("fail to get db_path");
- return W_HOME_ERROR_INVALID_PARAMETER;
- }
- r = sqlite3_open_v2(db_info.db_file, &db_info.db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL);
- if (r) {
- db_util_close(db_info.db);
- _E("fail to open db %d", r);
- return W_HOME_ERROR_DB_FAILED;
- }
-
- r = sqlite3_exec(db_info.db, CREATE_HOME_TABLE, NULL, NULL, &errmsg);
-
- if (r != SQLITE_OK) {
- _E("query error(%d)(%s)", r, errmsg);
- sqlite3_free(errmsg);
- db_util_close(db_info.db);
- return W_HOME_ERROR_DB_FAILED;
- }
- return W_HOME_ERROR_NONE;
-}
-
-
-HAPI w_home_error_e db_open(const char *db_file)
-{
- int ret;
-
- retv_if(!db_file, W_HOME_ERROR_INVALID_PARAMETER);
- if (db_info.db) {
- return W_HOME_ERROR_NONE;
- }
-
- ret = db_util_open(db_file, &db_info.db, DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK)
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(ret != SQLITE_OK, W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI stmt_h *db_prepare(const char *query)
-{
- stmt_h *handle;
- int ret;
-
- retv_if(!query, NULL);
-
- handle = calloc(1, sizeof(stmt_h));
- retv_if(!handle, NULL);
-
- ret = sqlite3_prepare_v2(db_info.db, query, strlen(query), &(handle->stmt), NULL);
- if (ret != SQLITE_OK) {
- free(handle);
- _E("%s, %s", query, sqlite3_errmsg(db_info.db));
- return NULL;
- }
-
- return handle;
-}
-
-
-
-HAPI w_home_error_e db_bind_bool(stmt_h *handle, int idx, bool value)
-{
- int ret;
-
- retv_if(!handle, W_HOME_ERROR_FAIL);
-
- ret = sqlite3_bind_int(handle->stmt, idx, (int) value);
- if (ret != SQLITE_OK)
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(ret != SQLITE_OK, W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e db_bind_int(stmt_h *handle, int idx, int value)
-{
- int ret;
-
- retv_if(!handle, W_HOME_ERROR_FAIL);
-
- ret = sqlite3_bind_int(handle->stmt, idx, value);
- if (ret != SQLITE_OK)
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(ret != SQLITE_OK, W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e db_bind_str(stmt_h *handle, int idx, const char *str)
-{
- int ret;
-
- retv_if(!handle, W_HOME_ERROR_FAIL);
- retv_if(!str, W_HOME_ERROR_FAIL);
-
- ret = sqlite3_bind_text(handle->stmt, idx, str, strlen(str), SQLITE_TRANSIENT);
- if (ret != SQLITE_OK)
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(ret != SQLITE_OK, W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e db_next(stmt_h *handle)
-{
- int ret;
-
- retv_if(!handle, W_HOME_ERROR_FAIL);
-
- ret = sqlite3_step(handle->stmt);
- switch (ret) {
- case SQLITE_ROW:
- return W_HOME_ERROR_NONE;
- case SQLITE_DONE:
- return W_HOME_ERROR_NO_DATA;
- default:
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(1, W_HOME_ERROR_FAIL);
- }
-}
-
-
-
-HAPI bool db_get_bool(stmt_h *handle, int index)
-{
- retv_if(!handle, false);
- return (bool) sqlite3_column_int(handle->stmt, index);
-}
-
-
-
-HAPI int db_get_int(stmt_h *handle, int index)
-{
- retv_if(!handle, 0);
- return sqlite3_column_int(handle->stmt, index);
-}
-
-
-HAPI const char *db_get_str(stmt_h *handle, int index)
-{
- retv_if(!handle, NULL);
- return (const char *) sqlite3_column_text(handle->stmt, index);
-}
-
-
-
-HAPI w_home_error_e db_reset(stmt_h *handle)
-{
- int ret;
-
- retv_if(!handle, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(!handle->stmt, W_HOME_ERROR_INVALID_PARAMETER);
-
- ret = sqlite3_reset(handle->stmt);
- if (ret != SQLITE_OK)
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(ret != SQLITE_OK, W_HOME_ERROR_FAIL);
-
- sqlite3_clear_bindings(handle->stmt);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e db_finalize(stmt_h *handle)
-{
- int ret;
-
- retv_if(!handle, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(!handle->stmt, W_HOME_ERROR_INVALID_PARAMETER);
-
- ret = sqlite3_finalize(handle->stmt);
- if (ret != SQLITE_OK)
- _E("%s", sqlite3_errmsg(db_info.db));
- retv_with_dbmsg_if(ret != SQLITE_OK, W_HOME_ERROR_FAIL);
- free(handle);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e db_exec(const char *query)
-{
- retv_if(!query, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(!db_info.db, W_HOME_ERROR_FAIL);
-
- stmt_h *handle = db_prepare(query);
- retv_if(!handle, W_HOME_ERROR_FAIL);
-
- goto_if(W_HOME_ERROR_FAIL == db_next(handle), ERROR);
- if (W_HOME_ERROR_NONE != db_finalize(handle))
- return W_HOME_ERROR_FAIL;
-
- return W_HOME_ERROR_NONE;
-
-ERROR:
- if (handle) db_finalize(handle);
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-HAPI void db_close(void)
-{
- if (!db_info.db) {
- _D("DB is already NULL");
- return;
- }
- sqlite3_close(db_info.db);
- db_info.db = NULL;
-}
-
-
-
-HAPI w_home_error_e db_begin_transaction(void)
-{
- int ret = -1;
-
- ret = sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL);
-
- while (SQLITE_BUSY == ret) {
- sleep(1);
- ret = sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL);
- }
-
- if (SQLITE_OK != ret) {
- _E("sqlite3_exec() Failed(%d)", ret);
- return W_HOME_ERROR_FAIL;
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-#define COMMIT_TRY_MAX 3
-HAPI w_home_error_e db_end_transaction(bool success)
-{
- int ret = -1;
- int i = 0;
- char *errmsg = NULL;
-
- if (success) {
- ret = sqlite3_exec(db_info.db, "COMMIT TRANSACTION", NULL, NULL, &errmsg);
- if (ret != SQLITE_OK) {
- _E("sqlite3_exec(COMMIT) Failed(%d, %s)", ret, errmsg);
- sqlite3_free(errmsg);
-
- while (SQLITE_BUSY == ret && i < COMMIT_TRY_MAX) {
- i++;
- sleep(1);
- ret = sqlite3_exec(db_info.db, "COMMIT TRANSACTION", NULL, NULL, NULL);
- }
-
- if (ret != SQLITE_OK) {
- _E("sqlite3_exec() Failed(%d)", ret);
- ret = sqlite3_exec(db_info.db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite3_exec() Failed(%d)", ret);
- }
-
- return W_HOME_ERROR_FAIL;
- }
- }
- } else {
- ret = sqlite3_exec(db_info.db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- _E("sqlite3_exec() Failed(%d)", ret);
- return W_HOME_ERROR_FAIL;
- }
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-#define HOME_TABLE "home"
-#define QUERY_INSERT_ITEM "INSERT INTO "HOME_TABLE" "\
- "(id, subid, ordering) "\
- "VALUES "\
- "('%s', '%s', %d);"
-HAPI int db_insert_item(const char *id, const char *subid, int ordering)
-{
- char *query;
-
- retv_if(!id, -1);
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- if (subid) {
- _D("Insert the item[%s:%s:%d]", id, subid, ordering);
- query = sqlite3_mprintf(QUERY_INSERT_ITEM, id, subid, ordering);
- } else {
- _D("Insert the item[%s:%d]", id, ordering);
- query = sqlite3_mprintf(QUERY_INSERT_ITEM, id, "", ordering);
- }
- retv_if(query == NULL, -1);
-
- if (db_exec(query) != W_HOME_ERROR_NONE) {
- _E("Cannot execute query.[%s]", query);
- sqlite3_free(query);
- return -1;
- }
-
- sqlite3_free(query);
-
- /* keep the home DB opened */
-
- return 0;
-}
-
-
-
-#define QUERY_UPDATE_ITEM "UPDATE "HOME_TABLE" SET ordering=%d WHERE id='%s' and subid='%s'"
-HAPI int db_update_item(const char *id, const char *subid, int ordering)
-{
- char *query;
-
- retv_if(!id, -1);
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- if (subid) {
- _D("Update the item[%s:%s:%d]", id, subid, ordering);
- query = sqlite3_mprintf(QUERY_UPDATE_ITEM, ordering, id, subid);
- } else {
- _D("Update the item[%s:%d]", id, ordering);
- query = sqlite3_mprintf(QUERY_UPDATE_ITEM, ordering, id, "");
- }
- retv_if(query == NULL, -1);
-
- if (db_exec(query) != W_HOME_ERROR_NONE) {
- _E("Cannot execute query.[%s]", query);
- sqlite3_free(query);
- return -1;
- }
-
- sqlite3_free(query);
-
- /* keep the home DB opened */
-
- return 0;
-}
-
-
-
-#define QUERY_UPDATE_ITEM_BY_ORDERING "UPDATE "HOME_TABLE" SET id='%s', subid='%s' WHERE ordering=%d"
-HAPI int db_update_item_by_ordering(const char *id, const char *subid, int ordering)
-{
- char *query = NULL;
-
- retv_if(!id, -1);
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- if (subid) {
- _SD("Update the item[%s:%s:%d]", id, subid, ordering);
- query = sqlite3_mprintf(QUERY_UPDATE_ITEM_BY_ORDERING, id, subid, ordering);
- } else {
- _SD("Update the item[%s:%d]", id, ordering);
- query = sqlite3_mprintf(QUERY_UPDATE_ITEM_BY_ORDERING, id, "", ordering);
- }
- retv_if(query == NULL, -1);
-
- if (db_exec(query) != W_HOME_ERROR_NONE) {
- _E("Cannot execute query.[%s]", query);
- sqlite3_free(query);
- return -1;
- }
-
- sqlite3_free(query);
-
- /* keep the home DB opened */
-
- return 0;
-}
-
-
-
-#define QUERY_REMOVE_ITEM "DELETE FROM "HOME_TABLE" WHERE id='%s' and subid='%s'"
-HAPI int db_remove_item(const char *id, const char *subid)
-{
- char *query;
-
- retv_if(!id, -1);
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- if (subid) {
- _D("Remove the item[%s:%s]", id, subid);
- query = sqlite3_mprintf(QUERY_REMOVE_ITEM, id, subid);
- } else {
- _D("Remove the item[%s]", id);
- query = sqlite3_mprintf(QUERY_REMOVE_ITEM, id, "");
- }
- retv_if(query == NULL, -1);
-
- if (db_exec(query) != W_HOME_ERROR_NONE) {
- _E("Cannot execute query.[%s]", query);
- sqlite3_free(query);
- return -1;
- }
-
- sqlite3_free(query);
-
- /* keep the home DB opened */
-
- return 0;
-}
-
-
-
-#define QUERY_REMOVE_ITEM_AFTER_MAX "DELETE FROM "HOME_TABLE" WHERE ordering > %d"
-HAPI int db_remove_item_after_max(int max)
-{
- char *query;
-
- _D("Remove the item after max[%d]", max);
-
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- query = sqlite3_mprintf(QUERY_REMOVE_ITEM_AFTER_MAX, max);
- retv_if(query == NULL, -1);
-
- if (db_exec(query) != W_HOME_ERROR_NONE) {
- _E("Cannot execute query.[%s]", query);
- sqlite3_free(query);
- return -1;
- }
-
- sqlite3_free(query);
-
- /* keep the home DB opened */
-
- return 0;
-}
-
-
-
-#define QUERY_REMOVE_ALL_ITEM "DELETE FROM "HOME_TABLE
-HAPI int db_remove_all_item(void)
-{
- char *query;
-
- _D("Remove all the item");
-
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- query = sqlite3_mprintf(QUERY_REMOVE_ALL_ITEM);
- retv_if(query == NULL, -1);
-
- if (db_exec(query) != W_HOME_ERROR_NONE) {
- _E("Cannot execute query.[%s]", query);
- sqlite3_free(query);
- return -1;
- }
-
- sqlite3_free(query);
-
- if (preference_set_string(VCONF_KEY_HOME_LOGGING, ";") != 0) {
- _SE("Failed to set %s as NULL", VCONF_KEY_HOME_LOGGING);
- } else {
- _SD("Set %s as ';'", VCONF_KEY_HOME_LOGGING);
- }
-
- /* keep the home DB opened */
-
- return 0;
-}
-
-
-
-#define QUERY_COUNT_ITEM "SELECT COUNT(*) FROM "HOME_TABLE" WHERE id=? and subid=?"
-HAPI int db_count_item(const char *id, const char *subid)
-{
- stmt_h *st;
- int count;
-
- retv_if(id == NULL, -1);
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- st = db_prepare(QUERY_COUNT_ITEM);
- retv_if(st == NULL, -1);
-
- if (db_bind_str(st, 1, id) != W_HOME_ERROR_NONE) {
- _E("db_bind_str error");
- db_finalize(st);
- return -1;
- }
-
- if (subid) {
- if (db_bind_str(st, 2, subid) != W_HOME_ERROR_NONE) {
- _E("db_bind_str error");
- db_finalize(st);
- return -1;
- }
- } else {
- if (db_bind_str(st, 2, "") != W_HOME_ERROR_NONE) {
- _E("db_bind_str error");
- db_finalize(st);
- return -1;
- }
- }
-
- if (db_next(st) == W_HOME_ERROR_FAIL) {
- _E("db_next error");
- db_finalize(st);
- return -1;
- }
-
- count = db_get_int(st, 0);
- db_finalize(st);
-
- /* keep the home DB opened */
-
- return count;
-}
-
-
-
-#define QUERY_COUNT_ORDERING "SELECT COUNT(*) FROM "HOME_TABLE" WHERE ordering=?"
-HAPI int db_count_ordering(int ordering)
-{
- stmt_h *st;
- int count;
-
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), -1);
-
- st = db_prepare(QUERY_COUNT_ORDERING);
- retv_if(st == NULL, -1);
-
- if (db_bind_int(st, 1, ordering) != W_HOME_ERROR_NONE) {
- _E("db_bind_str error");
- db_finalize(st);
- return -1;
- }
-
- if (db_next(st) == W_HOME_ERROR_FAIL) {
- _E("db_next error");
- db_finalize(st);
- return -1;
- }
-
- count = db_get_int(st, 0);
- db_finalize(st);
-
- /* keep the home DB opened */
-
- return count;
-}
-
-
-
-#define QUERY_SELECT_PAGE "SELECT id, subid, ordering FROM "HOME_TABLE" ORDER BY ordering ASC"
-HAPI Eina_List *db_write_list(void)
-{
- stmt_h *st = NULL;
- Eina_List *page_info_list = NULL;
- page_info_s *page_info = NULL;
- const char *id;
- const char *subid;
-
- retv_if(W_HOME_ERROR_NONE !=
- db_open(db_info.db_file), NULL);
-
- st = db_prepare(QUERY_SELECT_PAGE);
- goto_if(NULL == st, ERROR);
-
- while (W_HOME_ERROR_NONE == db_next(st)) {
- id = db_get_str(st, 0);
- subid = db_get_str(st, 1);
-
- page_info = page_info_create(id, subid, WIDGET_VIEWER_EVAS_DEFAULT_PERIOD);
- goto_if(!page_info, ERROR);
-
- page_info->ordering = db_get_int(st, 2);
- page_info->removable = page_info_is_removable(id);
- page_info_list = eina_list_append(page_info_list, page_info);
- }
-
- db_finalize(st);
-
- return page_info_list;
-
-ERROR:
- page_info_list_destroy(page_info_list);
- db_finalize(st);
-
- return NULL;
-}
-
-
-
-HAPI w_home_error_e db_read_list(Eina_List *page_info_list)
-{
- const char *logging = NULL;
- const Eina_List *l, *ln;
- Eina_Strbuf *strbuf = NULL;
- page_info_s *page_info = NULL;
- int ordering = 0;
-
- retv_if(!page_info_list, W_HOME_ERROR_INVALID_PARAMETER);
-
- _W("push all the pages into the DB");
-
- db_remove_all_item();
- strbuf = eina_strbuf_new();
- retv_if(!strbuf, W_HOME_ERROR_FAIL);
-
- EINA_LIST_FOREACH_SAFE(page_info_list, l, ln, page_info) {
- continue_if(!page_info);
- if (!page_info->id) continue;
-
- db_insert_item(page_info->id, page_info->subid, ordering);
- if (ordering) {
- eina_strbuf_append_char(strbuf, ';');
- }
- eina_strbuf_append(strbuf, page_info->id);
- ordering++;
- }
-
- logging = eina_strbuf_string_get(strbuf);
- if (logging) {
- _SD("Logging : [%s]", logging);
- if (preference_set_string(VCONF_KEY_HOME_LOGGING, logging) != 0) {
- _E("Failed to set %s as %s", VCONF_KEY_HOME_LOGGING, logging);
- }
- }
- eina_strbuf_free(strbuf);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-// End of file.
diff --git a/src/edit.c b/src/edit.c
deleted file mode 100755
index afb9876..0000000
--- a/src/edit.c
+++ /dev/null
@@ -1,3672 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <stdbool.h>
-#include <app.h>
-
-#include <dlog.h>
-#include <bundle.h>
-#include <unicode/unum.h>
-#include <unicode/ustring.h>
-#include <vconf.h>
-#include <widget_viewer_evas.h>
-#include <app_control.h>
-#include <circle/efl_extension_rotary.h>
-
-#include "util.h"
-#include "conf.h"
-#include "db.h"
-#include "wms.h"
-#include "page.h"
-#include "page_info.h"
-#include "edit_info.h"
-#include "effect.h"
-#include "key.h"
-#include "layout_info.h"
-#include "layout.h"
-#include "widget.h"
-#include "log.h"
-#include "main.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "edit.h"
-#include "gesture.h"
-#include "index.h"
-#include "noti_broker.h"
-#include "add-viewer.h"
-
-#define PRIVATE_DATA_KEY_EDIT_DISABLE_REORDERING "p_e_l"
-#define PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT "p_fo"
-#define PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE "p_uf"
-#define PRIVATE_DATA_KEY_PAGE_LONGPRESS_TIMER "p_p_lp_t"
-#define PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL "p_it_ani_d"
-#define PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING "p_it_ani_mv"
-#define PRIVATE_DATA_KEY_PAGE_PRESSED "p_i_p"
-#define PRIVATE_DATA_KEY_PAGE_DOWN_X "p_i_dx"
-#define PRIVATE_DATA_KEY_PAGE_DOWN_Y "p_i_dy"
-#define PRIVATE_DATA_KEY_PAGE_X_FOR_MOVING "p_i_x_mv"
-#define PRIVATE_DATA_KEY_PAGE_Y_FOR_MOVING "p_i_y_mv"
-#define PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM "p_i_x"
-#define PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM "p_i_y"
-#define PRIVATE_DATA_KEY_PAGE_W "p_i_w"
-#define PRIVATE_DATA_KEY_PAGE_H "p_i_h"
-#define PRIVATE_DATA_KEY_PAGE_INNER "p_pg_in"
-#define PRIVATE_DATA_KEY_PROXY_BG "p_pr_bg"
-#define PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING "p_sc_an_mv"
-#define PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING "p_sc_pg_mv"
-#define PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING "p_sc_r_mv"
-#define PRIVATE_DATA_KEY_SCROLLER_PRESS_PAGE "p_sc_p"
-#define PRIVATE_DATA_KEY_SCROLLER_X "p_sc_x"
-#define PRIVATE_DATA_KEY_EDIT_SYNC_IS_DONE "pdke_s_d"
-#define PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED "pdke_il"
-#define PRIVATE_DATA_KEY_EDIT_ITEM_IS_MOVED "pdke_im"
-#define PRIVATE_DATA_KEY_DIVIDE_FACTOR "pdk_df"
-#define PRIVATE_DATA_KEY_ANIM_FOR_MINIFY "p_a_mi"
-#define PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE "p_a_en"
-#define PRIVATE_DATA_KEY_EDIT_DO_NOT_SUPPORT_ENLARGE_EFFECT "pdk_dnsee"
-#define SHORTCUT_WIDGET_ID "org.tizen.apptray-widget"
-#define SHORTCUT_APP_ID "org.tizen.apptray-widget-app"
-
-#define MOVE_THRESHOLD 5
-#define SLIPPED_LENGTH 40
-
-static void _destroy_proxy_bg(Evas_Object *clip_bg);
-static Evas_Object *_create_proxy_bg(Evas_Object *item);
-
-
-
-static char *_access_tab_to_move_cb(void *data, Evas_Object *obj)
-{
- char *tmp;
-
- tmp = strdup(_("IDS_COM_BODY_TAP_AND_HOLD_A_WIDGET_TO_MOVE_IT_ABB"));
- retv_if(!tmp, NULL);
-
- return tmp;
-}
-
-
-
-static char *_access_plus_button_name_cb(void *data, Evas_Object *obj)
-{
- char *tmp;
-
- tmp = strdup(_("IDS_HS_BODY_ADD_WIDGET"));
- retv_if(!tmp, NULL);
-
- return tmp;
-}
-
-
-
-/* Caution : Do not create & destroy an item */
-static void _scroller_read_page_list(Evas_Object *scroller, Eina_List *page_info_list)
-{
- Evas_Object *before_page = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!scroller);
- ret_if(!page_info_list);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- before_page = scroller_info->center;
-
- EINA_LIST_FOREACH_SAFE(page_info_list, l, ln, page_info) {
- continue_if(!page_info);
- continue_if(!page_info->page);
-
- elm_box_unpack(scroller_info->box, page_info->page);
- elm_box_pack_after(scroller_info->box, page_info->page, before_page);
- before_page = page_info->page;
- }
-}
-
-
-
-static Eina_List *_scroller_write_page_list(Evas_Object *edit_scroller)
-{
- Evas_Object *page = NULL;
- Evas_Object *tmp = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- page_info_s *page_info = NULL;
- page_info_s *dup_page_info = NULL;
- Eina_List *list = NULL;
- Eina_List *page_info_list = NULL;
- const Eina_List *l, *ln;
-
- retv_if(!edit_scroller, NULL);
-
- edit_scroller_info = evas_object_data_get(edit_scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!edit_scroller_info, NULL);
-
- list = elm_box_children_get(edit_scroller_info->box);
- retv_if(!list, NULL);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- continue_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) continue;
- if (!page_info->id) continue;
- if (PAGE_DIRECTION_RIGHT != page_info->direction) continue;
-
- dup_page_info = page_info_dup(page_info);
- continue_if(!dup_page_info);
-
- tmp = evas_object_data_get(dup_page_info->page, DATA_KEY_REAL_PAGE);
- if (tmp) dup_page_info->page = tmp;
- page_info_list = eina_list_append(page_info_list, dup_page_info);
- }
- eina_list_free(list);
-
- return page_info_list;
-}
-
-
-
-static Evas_Object *_content_set_page_inner(Evas_Object *proxy_page)
-{
- Evas_Object *page_inner = NULL;
- page_info_s *page_info = NULL;
-
- page_inner = evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_INNER);
- retv_if(!page_inner, NULL);
-
- elm_object_part_content_set(proxy_page, "inner", page_inner);
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- scroller_unfreeze(page_info->scroller);
-
- return proxy_page;
-}
-
-
-
-static Evas_Object *_content_unset_page_inner(Evas_Object *proxy_page)
-{
- Evas_Object *page_inner = NULL;
- page_info_s *page_info = NULL;
-
- page_inner = elm_object_part_content_unset(proxy_page, "inner");
- retv_if(!page_inner, NULL);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_INNER, page_inner);
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- elm_object_signal_emit(page_inner, "on,zoom", "inner");
-
- scroller_freeze(page_info->scroller);
-
- return proxy_page;
-}
-
-
-
-/* This function SHOULD be called related to edit_destroy_layout */
-static void _sync_from_edit_to_normal(void *layout)
-{
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
- Eina_List *page_info_list = NULL;
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- page_info_list = _scroller_write_page_list(edit_info->scroller);
- if (page_info_list) {
- db_read_list(page_info_list);
- _scroller_read_page_list(layout_info->scroller, page_info_list);
- page_info_list_destroy(page_info_list);
- } else {
- db_remove_all_item();
- }
-
- evas_object_data_set(layout, PRIVATE_DATA_KEY_EDIT_SYNC_IS_DONE, (void *) 1);
-
- multi_index_update(layout_info->scroller);
-}
-
-
-
-static void _clicked_noti_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *proxy_page = data;
- Evas_Object *effect_page = NULL;
- Evas_Object *page = NULL;
- Evas_Object *scroller = NULL;
- Evas_Object *layout = NULL;
-
- layout_info_s *layout_info = NULL;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- if (evas_object_data_del(page_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED)) return;
-
- layout = page_info->layout;
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- scroller = layout_info->scroller;
-
- effect_page = edit_create_enlarge_effect_page(proxy_page);
- if (effect_page) edit_enlarge_effect_page(effect_page);
-
- page = evas_object_data_get(proxy_page, DATA_KEY_REAL_PAGE);
- ret_if(!page);
- scroller_region_show_center_of(scroller, page, SCROLLER_FREEZE_OFF, NULL, NULL, NULL, NULL);
-}
-
-
-static void _clicked_widget_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *proxy_page = data;
- Evas_Object *effect_page = NULL;
- Evas_Object *page = NULL;
- Evas_Object *scroller = NULL;
- Evas_Object *layout = NULL;
-
- layout_info_s *layout_info = NULL;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- if (evas_object_data_get(page_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED)) return;
-
- layout = page_info->layout;
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- scroller = layout_info->scroller;
-
- effect_page = edit_create_enlarge_effect_page(proxy_page);
- if (effect_page) edit_enlarge_effect_page(effect_page);
-
- page = evas_object_data_get(proxy_page, DATA_KEY_REAL_PAGE);
- ret_if(!page);
- scroller_region_show_center_of(scroller, page, SCROLLER_FREEZE_OFF, _sync_from_edit_to_normal, layout, NULL, NULL);
-}
-
-
-
-#define ANIM_RATE 4
-#define ANIM_RATE_SPARE ANIM_RATE - 1
-static Eina_Bool _anim_move_page_to_empty_position(void *data)
-{
- Evas_Object *proxy_page = data;
- page_info_s *page_info = NULL;
- Evas_Object *scroller = NULL;
- Evas_Object *page_inner = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_INNER);
- int cur_x, cur_y, end_x, end_y;
- int vec_x, vec_y;
-
- goto_if(!data, ERROR);
- if(!page_inner) {
- _D("page_inner was not unset");
- goto ERROR;
- }
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- goto_if(!page_info, ERROR);
- scroller = page_info->scroller;
-
- evas_object_geometry_get(page_inner, &cur_x, &cur_y, NULL, NULL);
- end_x = (int)evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM);
- end_y = (int)evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM);
-
- if (cur_y == end_y && cur_x == end_x) {
- goto_if (NULL == _content_set_page_inner(proxy_page), ERROR);
- /* unfreeze the scroller after setting the content */
- if (scroller) scroller_unfreeze(scroller);
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- edit_change_focus(scroller, proxy_page);
-
- return ECORE_CALLBACK_CANCEL;
- }
- vec_y = (end_y - cur_y)/ANIM_RATE;
- if (0 == vec_y) {
- if (end_y - cur_y < 0) vec_y = -1;
- else if (end_y - cur_y > 0) vec_y = 1;
- }
- cur_y += vec_y;
-
- vec_x = (end_x - cur_x)/ANIM_RATE;
- if (0 == vec_x) {
- if (end_x - cur_x < 0) vec_x = -1;
- else if (end_x - cur_x > 0) vec_x = 1;
- }
- cur_x += vec_x;
-
- evas_object_move(page_inner, cur_x, cur_y);
-
- return ECORE_CALLBACK_RENEW;
-
-ERROR:
- if (proxy_page) {
- if (scroller) scroller_unfreeze(scroller);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM);
-
- }
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Eina_Bool _longpress_timer_cb(void *data)
-{
- Evas_Object *proxy_page = NULL;
- page_info_s *proxy_page_info = NULL;
- Ecore_Timer *timer;
-
- proxy_page = data;
- retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- retv_if(!proxy_page_info, ECORE_CALLBACK_CANCEL);
-
- timer = evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_LONGPRESS_TIMER);
- if (timer) ecore_timer_del(timer);
- else return ECORE_CALLBACK_CANCEL;
-
- evas_object_data_set(proxy_page_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED, (void *) 1);
-
- if (evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_EDIT_DISABLE_REORDERING)) {
- _D("long-press is not supported on this page");
- scroller_freeze(proxy_page_info->scroller);
- util_create_toast_popup(proxy_page_info->scroller, _("IDS_HS_TPOP_CANNOT_REORDER_NOTIFICATION_BOARD_ITEMS"));
- return ECORE_CALLBACK_CANCEL;
- }
-
- _D("longpress start for proxy_page(%p)", proxy_page);
-
- page_unfocus(proxy_page);
- scroller_disable_focus_on_scroll(proxy_page_info->scroller);
- scroller_disable_index_on_scroll(proxy_page_info->scroller);
-
- retv_if(!evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_PRESSED), ECORE_CALLBACK_CANCEL);
- retv_if(!_content_unset_page_inner(proxy_page), ECORE_CALLBACK_CANCEL);
-
- elm_object_signal_emit(proxy_page_info->layout, "show", "checker");
- scroller_bring_in_center_of(proxy_page_info->scroller, proxy_page, SCROLLER_FREEZE_ON, NULL, NULL, NULL, NULL);
- effect_play_vibration();
- evas_object_data_set(proxy_page, DATA_KEY_PICKED_UP_PAGE, (void *) 1);
-
- return ECORE_CALLBACK_CANCEL;
-
-}
-
-
-
-static void _down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Down *ei = event_info;
- Evas_Object *proxy_page = data;
- Evas_Object *page_current = NULL;
- Evas_Object *page_inner = NULL;
- Ecore_Timer *timer = NULL;
- Ecore_Animator *anim = NULL;
- page_info_s *page_info = NULL;
-
- int x = ei->output.x;
- int y = ei->output.y;
- int inner_x, inner_y, inner_w, inner_h;
- int sx;
-
- _D("edit : Down (%d, %d)", x, y);
-
- ret_if(!proxy_page);
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- if (scroller_is_scrolling(page_info->scroller)) return;
-
- anim = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- if (anim) return;
-
- page_current = scroller_get_focused_page(page_info->scroller);
- ret_if(!page_current);
- if (proxy_page != page_current) return;
-
- page_inner = elm_object_part_content_get(proxy_page, "inner");
- if (!page_inner) {
- page_inner = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_INNER);
- ret_if(!page_inner);
- elm_object_part_content_set(proxy_page, "inner", page_inner);
- }
-
- evas_object_data_set(page_info->scroller, PRIVATE_DATA_KEY_SCROLLER_PRESS_PAGE, proxy_page);
- evas_object_data_set(page_info->scroller, DATA_KEY_EVENT_UPPER_PAGE, proxy_page);
-
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_PRESSED, (void *) 1);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_DOWN_X, (void *) x);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_DOWN_Y, (void *) y);
-
- evas_object_geometry_get(page_inner, &inner_x, &inner_y, &inner_w, &inner_h);
-
- /* this data key is used the destination in animation of item's set.
- If the destination of animation can be changed, you set the changed value in _up_cb or other function */
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM, (void *) inner_x);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM, (void *) inner_y);
-
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_MOVING, (void *) inner_x);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_MOVING, (void *) inner_y);
-
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_W, (void *) inner_w);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_H, (void *) inner_h);
-
- elm_scroller_region_get(page_info->scroller, &sx, NULL, NULL, NULL);
- sx += inner_x;
- evas_object_data_set(page_info->scroller, PRIVATE_DATA_KEY_SCROLLER_X, (void *) sx);
- evas_object_data_del(page_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED);
-
- timer = ecore_timer_add(LONGPRESS_TIME, _longpress_timer_cb, proxy_page);
- if (timer) evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_LONGPRESS_TIMER, timer);
- else _E("Cannot add a timer");
-}
-
-
-
-static void _call_object(Evas_Object *proxy_page, int cur_x, int cur_y)
-{
- Evas_Object *parent = NULL;
- Evas_Object *tmp = NULL;
- Eina_List *obj_list = NULL;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->scroller);
-
- obj_list = evas_tree_objects_at_xy_get(main_get_info()->e, NULL, cur_x, cur_y);
- ret_if(!obj_list);
-
- EINA_LIST_FREE(obj_list, tmp) {
- parent = tmp;
- while (parent) {
- if (evas_object_data_get(parent, DATA_KEY_EVENT_UPPER_IS_ON)) {
- Evas_Object *old_obj = evas_object_data_get(page_info->scroller, DATA_KEY_EVENT_UPPER_PAGE);
- if (old_obj != parent) {
- _D("Call upper_end(%p) & upper_start(%p)", old_obj, parent);
- evas_object_smart_callback_call(old_obj, "upper_end", NULL);
- evas_object_smart_callback_call(parent, "upper_start", NULL);
- evas_object_data_set(page_info->scroller, DATA_KEY_EVENT_UPPER_PAGE, parent);
- } else {
- evas_object_smart_callback_call(parent, "upper", proxy_page);
- }
-
- eina_list_free(obj_list);
- return;
- }
-
- parent = evas_object_smart_parent_get(parent);
- if (parent == page_info->scroller) {
- evas_object_data_set(page_info->scroller, DATA_KEY_EVENT_UPPER_PAGE, parent);
- break;
- }
- }
- }
-}
-
-
-
-static void _move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Move *ei = event_info;
- Evas_Object *proxy_page = data;
- Evas_Object *page_inner = NULL;
- Ecore_Timer *timer = NULL;
- page_info_s *page_info = NULL;
- Ecore_Animator *anim = NULL;
-
- int down_x, down_y, inner_x, inner_y;
- int cur_x, cur_y, vec_x, vec_y;
-
- ret_if(!proxy_page);
- if (!evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_PRESSED)) {
- return;
- }
-
- anim = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- if (anim) return;
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- cur_x = ei->cur.output.x;
- cur_y = ei->cur.output.y;
-
- down_x = (int) evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_DOWN_X);
- down_y = (int) evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_DOWN_Y);
-
- inner_x = (int) evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_MOVING);
- inner_y = (int) evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_MOVING);
-
- vec_x = cur_x - down_x;
- vec_y = cur_y - down_y;
-
- inner_x += vec_x;
- inner_y += vec_y;
-
- timer = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_LONGPRESS_TIMER);
- if (timer && (abs(vec_x) >= LONGPRESS_THRESHOLD || abs(vec_y) >= LONGPRESS_THRESHOLD)) {
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_LONGPRESS_TIMER);
- ecore_timer_del(timer);
- return;
- }
-
- page_inner = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_INNER);
- if (!page_inner) return;
-
- evas_object_move(page_inner, inner_x, inner_y);
-
- _call_object(proxy_page, cur_x, cur_y);
-}
-
-
-
-static void _up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *proxy_page = data;
- Evas_Object *old_obj;
- Evas_Object *page_current;
- Evas_Event_Mouse_Up *ei = event_info;
- Ecore_Timer *timer = NULL;
- page_info_s *page_info = NULL;
- Ecore_Animator *anim = NULL;
-
- int x = ei->output.x;
- int y = ei->output.y;
-
- _D("edit : Up (%p) (%d, %d)", proxy_page, x, y);
-
- ret_if(!proxy_page);
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- page_current = scroller_get_picked_up_page(page_info->scroller);
- ret_if(!page_current);
- if (page_current != proxy_page) return;
-
- scroller_enable_focus_on_scroll(page_info->scroller);
- scroller_enable_index_on_scroll(page_info->scroller);
-
- if (evas_object_data_del(page_info->scroller, PRIVATE_DATA_KEY_EDIT_ITEM_IS_MOVED)
- && main_get_info()->is_tts)
- {
- elm_access_say(_("IDS_TTS_BODY_ITEM_MOVED"));
- }
-
- elm_object_signal_emit(page_info->layout, "hide", "checker");
-
- evas_object_data_del(page_info->scroller, PRIVATE_DATA_KEY_SCROLLER_PRESS_PAGE);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_PRESSED);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_DOWN_X);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_DOWN_Y);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_MOVING);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_MOVING);
- evas_object_data_del(proxy_page, DATA_KEY_PICKED_UP_PAGE);
-
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_W);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_H);
- old_obj = evas_object_data_del(page_info->scroller, DATA_KEY_EVENT_UPPER_PAGE);
- if (old_obj) {
- _D("Call upper_end & upper_start");
- evas_object_smart_callback_call(old_obj, "upper_end", NULL);
- }
-
- timer = evas_object_data_del(page_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
- if (timer) ecore_timer_del(timer);
-
- timer = evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_LONGPRESS_TIMER);
- if (timer) {
- ecore_timer_del(timer);
- timer = NULL;
- return;
- }
-
- anim = evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- if (anim) {
- ecore_animator_del(anim);
- anim = NULL;
- }
-
- if (evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_EDIT_DISABLE_REORDERING)) {
- _D("long-press is not supported on this page");
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- scroller_unfreeze(page_info->scroller);
- edit_change_focus(page_info->scroller, page_current);
- return;
- }
-
- anim = ecore_animator_add(_anim_move_page_to_empty_position, proxy_page);
- ret_if(NULL == anim);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING, anim);
- if (evas_object_data_get(page_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED)) {
- elm_object_signal_emit(page_info->page_inner, "reset,zoom", "inner");
- }
-}
-
-
-
-static key_cb_ret_e _add_viewer_back_key_cb(void *data)
-{
- _W("");
- Evas_Object *layout = data;
- layout_info_s *layout_info = NULL;
-
- retv_if(!layout, KEY_CB_RET_CONTINUE);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout, KEY_CB_RET_CONTINUE);
-
- if (layout_info->edit) {
- edit_info_s *edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- scroller_init_rotary(edit_info->scroller);
- elm_object_tree_focus_allow_set(layout_info->edit, EINA_TRUE);
- } else {
- scroller_init_rotary(layout_info->scroller);
- layout_add_mouse_cb(layout);
- elm_object_tree_focus_allow_set(layout_info->scroller, EINA_TRUE);
- }
- edit_destroy_add_viewer(layout);
-
- return KEY_CB_RET_STOP;
-}
-
-
-
-static key_cb_ret_e _add_viewer_home_key_cb(void *data)
-{
- _D("Add viewer recieve home key event");
- Evas_Object *layout = data;
- layout_info_s *layout_info = NULL;
-
- retv_if(!layout, KEY_CB_RET_CONTINUE);
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, KEY_CB_RET_CONTINUE);
-
- edit_destroy_add_viewer(layout);
- if (layout_info->edit) {
- edit_destroy_layout(layout);
- } else {
- scroller_init_rotary(layout_info->scroller);
- layout_add_mouse_cb(layout);
- elm_object_tree_focus_allow_set(layout_info->scroller, EINA_TRUE);
- }
-
- scroller_bring_in_by_push_type(layout_info->scroller, SCROLLER_PUSH_TYPE_CENTER, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
-
- return KEY_CB_RET_STOP;
-}
-
-
-
-static char *_access_remove_button_name_cb(void *data, Evas_Object *obj)
-{
- char *tmp;
-
- tmp = strdup(_("IDS_COM_BUTTON_REMOVE_ABB"));
- retv_if(!tmp, NULL);
- return tmp;
-}
-
-static void _edit_button_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- // Launch the app-shortcut launcher app
- _D("_edit_button_click_cb" );
- Evas_Object *layout =data;
- layout_info_s *layout_info = NULL;
- Evas_Object* focus_page = NULL;
- page_info_s *page_info = NULL;
- const char *widget_id = NULL;
- const char *content_info = NULL;
-
- if(!layout) {
- _E("layout is null " );
- return;
- }
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- if(!layout_info || !layout_info->scroller) {
- _E("layout info is null " );
- return;
- }
-
- focus_page = scroller_get_focused_page(layout_info->scroller);
- if(!focus_page) {
- _E("focus page is null " );
- return;
- }
-
- page_info = evas_object_data_get(focus_page , DATA_KEY_PAGE_INFO);
- if(!page_info ) {
- _E("focus page_info is null " );
- return;
- }
-
- widget_id = widget_viewer_evas_get_widget_id(page_info->item);
- if(!widget_id) {
- _E("widget id is null " );
- return;
- }
-
- content_info = widget_viewer_evas_get_content_info(page_info->item);
-
- app_control_h service = NULL;
-
- ret_if(APP_CONTROL_ERROR_NONE != app_control_create(&service));
- ret_if(NULL == service);
-
- app_control_set_operation(service, APP_CONTROL_OPERATION_MAIN);
- app_control_add_extra_data(service, "instance_id", widget_id);
- if (content_info) {
- app_control_add_extra_data(service, "content_info", content_info);
- }
- app_control_set_app_id(service, SHORTCUT_APP_ID);
-
- int ret = app_control_send_launch_request(service, NULL, NULL);
- if (APP_CONTROL_ERROR_NONE != ret) {
- _E("error");
- app_control_destroy(service);
- return;
- }
-
- app_control_destroy(service);
- //util_launch_app(SHORTCUT_APP_ID, NULL, NULL);
-}
-
-
-#define PROXY_ITEM_EDJ EDJEDIR"/edit.edj"
-#define PROXY_ITEM_GROUP "proxy_item"
-Evas_Object *_create_proxy_item(Evas_Object *edit_scroller, Evas_Object *real_page)
-{
- Evas_Object *proxy_item = NULL;
- Evas_Object *proxy_image = NULL;
- page_info_s *page_info = NULL;
- Eina_Bool ret;
-
- retv_if(!edit_scroller, NULL);
- retv_if(!real_page, NULL);
-
- page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- /* Proxy Item */
- proxy_item = elm_layout_add(edit_scroller);
- retv_if(!proxy_item, NULL);
-
- ret = elm_layout_file_set(proxy_item, PROXY_ITEM_EDJ, PROXY_ITEM_GROUP);
- if (EINA_FALSE == ret) {
- _E("cannot set the file into the layout");
- evas_object_del(proxy_item);
- return NULL;
- }
- evas_object_repeat_events_set(proxy_item, EINA_TRUE);
-
- /* Proxy Image */
- proxy_image = evas_object_image_filled_add(main_get_info()->e);
- if (!proxy_item) {
- _E("Cannot add an image");
- evas_object_del(proxy_image);
- return NULL;
- }
-
- ret = evas_object_image_source_set(proxy_image, page_info->item);
- if(EINA_FALSE == ret) _E("Cannot set the source into the proxy image");
-
- evas_object_image_source_visible_set(proxy_image, EINA_FALSE);
- evas_object_image_source_clip_set(proxy_image, EINA_FALSE);
-
- elm_object_part_content_set(proxy_item, "proxy_item", proxy_image);
-
- evas_object_repeat_events_set(proxy_image, EINA_TRUE);
- evas_object_size_hint_weight_set(proxy_image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(proxy_image, ITEM_EDIT_WIDTH, ITEM_EDIT_HEIGHT);
- evas_object_resize(proxy_image, ITEM_EDIT_WIDTH, ITEM_EDIT_HEIGHT);
- evas_object_show(proxy_image);
-
- _D("Create a proxy item(%p)", proxy_item);
-
- return proxy_item;
-}
-
-
-
-static void _destroy_proxy_item(Evas_Object *proxy_item)
-{
- Evas_Object *proxy_image = NULL;
-
- ret_if(!proxy_item);
-
- proxy_image = elm_object_part_content_unset(proxy_item, "proxy_item");
- if (proxy_image) {
- evas_object_image_source_visible_set(proxy_image, EINA_TRUE);
- evas_object_del(proxy_image);
- }
-
- _D("Destroy a proxy item(%p)", proxy_item);
-
- evas_object_del(proxy_item);
-}
-
-
-
-HAPI void edit_change_focus(Evas_Object *edit_scroller, Evas_Object *page_current)
-{
- Evas_Object *page_focused = NULL;
- page_info_s *page_info = NULL;
- page_info_s *focused_page_info = NULL;
- layout_info_s *layout_info = NULL;
- int unfocusable = 0;
-
- ret_if(!edit_scroller);
- if(!page_current) {
- evas_object_data_set(edit_scroller, PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT, NULL);
- return;
- }
-
- page_focused = evas_object_data_get(edit_scroller, PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT);
- if (page_focused == page_current) return;
-
- page_info = evas_object_data_get(page_current, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->page_inner);
- ret_if(!page_info->item);
- if(page_info->layout)
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
-
- if (layout_info)
- {
- if(page_info->id)
- {
- if (strcmp(page_info->id, SHORTCUT_WIDGET_ID) == 0) {
- _D( " Showing edit button for page %s", page_info->id);
- elm_object_signal_emit(layout_info->edit, "edit,show", "edit");
- }
- else {
- _D( " Hiding edit button for page %s", page_info->id);
- elm_object_signal_emit(layout_info->edit, "edit,hide", "edit");
- }
-
- }
- else
- {
- _D( " Hiding edit button for page %s", page_info->id);
- elm_object_signal_emit(layout_info->edit, "edit,hide", "edit");
- }
- }
-
- /* Blocker has to be disabled even if this is unfocusable */
- elm_object_signal_emit(page_info->page_inner, "disable", "blocker");
-
- evas_object_data_set(edit_scroller, PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT, page_current);
-
- if(page_focused) {
- focused_page_info = evas_object_data_get(page_focused, DATA_KEY_PAGE_INFO);
- if (!focused_page_info) goto OUT;
- if (!focused_page_info->page_inner) goto OUT;
- if (!focused_page_info->item) goto OUT;
-
- unfocusable = (int) evas_object_data_get(page_focused, PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE);
- if (!unfocusable) {
- elm_object_signal_emit(focused_page_info->page_inner, "deselect", "cover");
- elm_object_signal_emit(focused_page_info->page_inner, "deselect", "line");
- elm_object_signal_emit(focused_page_info->page_inner, "hide", "del");
- }
- elm_object_signal_emit(focused_page_info->page_inner, "enable", "blocker");
- }
-
-OUT:
- /* Unfocusable page */
- unfocusable = (int) evas_object_data_get(page_current, PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE);
- if (unfocusable) return;
-
- /* Focusable page */
- elm_object_signal_emit(page_info->page_inner, "select", "cover");
- elm_object_signal_emit(page_info->page_inner, "select", "line");
- if (page_info->removable) {
- elm_object_signal_emit(page_info->page_inner, "show", "del");
- }
-}
-
-
-
-static void _remove_widget(Evas_Object *page)
-{
- Evas_Object *proxy_page = NULL;
- Evas_Object *page_current = NULL;
- Evas_Object *focused_page = NULL;
-
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- edit_scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- /* Proxy DBox */
- proxy_page = evas_object_data_get(page, DATA_KEY_PROXY_PAGE);
- ret_if(!proxy_page);
-
- focused_page = evas_object_data_get(edit_info->scroller, PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT);
- if (proxy_page == focused_page) {
- evas_object_data_set(edit_info->scroller, PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT, NULL);
- }
-
- scroller_pop_page(edit_info->scroller, proxy_page);
- edit_destroy_proxy_page(proxy_page);
- edit_arrange_plus_page(layout_info->edit);
-
- /* Real DBox */
- scroller_pop_page(layout_info->scroller, page);
- /**
- * @note
- * Delete a box permanently only if a user deletes it.
- */
- widget_viewer_evas_set_permanent_delete(page_info->item, 1);
- evas_object_del(page_info->item);
- page_destroy(page);
- page_arrange_plus_page(layout_info->scroller, 0);
-
- page_current = scroller_get_focused_page(edit_info->scroller);
- ret_if(!page_current);
-
- scroller_region_show_page(edit_info->scroller, page_current, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
- edit_change_focus(edit_info->scroller, page_current);
-}
-
-
-
-static Eina_Bool _minify_widget_anim_cb(void *data)
-{
- Evas_Object *proxy_page = data;
- int w, h;
-
- retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
- evas_object_geometry_get(proxy_page, NULL, NULL, &w, &h);
-
- w -= SLIPPED_LENGTH;
- evas_object_size_hint_min_set(proxy_page, w, h);
-
- if (w <= 0) {
- Evas_Object *real_page = evas_object_data_get(proxy_page, DATA_KEY_REAL_PAGE);
-
- /* This has to be executed before _remove_widget */
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL);
-
- if (real_page) _remove_widget(real_page);
- return ECORE_CALLBACK_CANCEL;
- }
-
- return ECORE_CALLBACK_RENEW;
-
-}
-
-
-
-static void _del_widget_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *proxy_page = data;
- Evas_Object *page_inner = NULL;
- Ecore_Animator *anim = NULL;
-
- _D("Del is clicked");
-
- ret_if(!proxy_page);
- page_inner = elm_object_part_content_unset(proxy_page, "inner");
- ret_if(!page_inner);
-
- evas_object_hide(page_inner);
-
- anim = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL);
- if (anim) return;
-
- anim = ecore_animator_add(_minify_widget_anim_cb, proxy_page);
- if (anim) evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL, anim);
- else _E("Cannot add an animator");
-
- elm_access_say(_("IDS_TTS_BODY_ITEM_REMOVED"));
-}
-
-
-
-static Evas_Object *_add_widget_in_normal(Evas_Object *layout, const char *id, const char *subid)
-{
- Evas_Object *page = NULL;
- Evas_Object *item = NULL;
- Eina_List *page_info_list = NULL;
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!layout, NULL);
- retv_if(!id, NULL);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- /* Real DBox */
- item = widget_create(layout_info->scroller, id, NULL, WIDGET_VIEWER_EVAS_DEFAULT_PERIOD);
- retv_if(!item, NULL);
- widget_viewer_evas_disable_loading(item);
- evas_object_resize(item, scroller_info->page_width, scroller_info->page_height);
- evas_object_size_hint_min_set(item, scroller_info->page_width, scroller_info->page_height);
- evas_object_show(item);
-
- page = page_create(layout_info->scroller
- , item
- , id, NULL
- , scroller_info->page_width, scroller_info->page_height
- , PAGE_CHANGEABLE_BG_ON, PAGE_REMOVABLE_ON);
- goto_if(!page, ERROR);
- widget_add_callback(item, page);
- page_set_effect(page, page_effect_none, page_effect_none);
-
- scroller_push_page(layout_info->scroller, page, SCROLLER_PUSH_TYPE_LAST);
- page_arrange_plus_page(layout_info->scroller, 1);
-
- page_info_list = scroller_write_list(layout_info->scroller);
- if (page_info_list) {
- db_read_list(page_info_list);
- scroller_read_list(layout_info->scroller, page_info_list);
- page_info_list_destroy(page_info_list);
- }
-
- scroller_region_show_page(layout_info->scroller, page, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
-
- return page;
-
-ERROR:
- widget_destroy(item);
- return NULL;
-
-}
-
-
-static Evas_Object *add_widget_in_edit(Evas_Object *layout, const char *id, const char *subid)
-{
- Evas_Object *proxy_page = NULL;
- Evas_Object *page = NULL;
- Evas_Object *page_inner = NULL;
- Evas_Object *item = NULL;
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
- scroller_info_s *scroller_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- page_info_s *proxy_page_info = NULL;
- page_info_s *plus_page_info = NULL;
-
- retv_if(!layout, NULL);
- retv_if(!id, NULL);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, NULL);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- edit_scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!edit_scroller_info, NULL);
-
- plus_page_info = evas_object_data_get(edit_scroller_info->plus_page, DATA_KEY_PAGE_INFO);
- retv_if(!plus_page_info, NULL);
-
- /* Real DBox */
- item = widget_create(layout_info->scroller, id, NULL, WIDGET_VIEWER_EVAS_DEFAULT_PERIOD);
- goto_if(!item, ERROR);
- widget_viewer_evas_disable_loading(item);
- evas_object_resize(item, scroller_info->page_width, scroller_info->page_height);
- evas_object_size_hint_min_set(item, scroller_info->page_width, scroller_info->page_height);
- evas_object_show(item);
-
- page = page_create(layout_info->scroller
- , item
- , id, NULL
- , scroller_info->page_width, scroller_info->page_height
- , PAGE_CHANGEABLE_BG_ON, PAGE_REMOVABLE_ON);
- goto_if(!page, ERROR);
- widget_add_callback(item, page);
- page_set_effect(page, page_effect_none, page_effect_none);
-
- scroller_push_page_before(layout_info->scroller, page, scroller_info->plus_page);
- page_arrange_plus_page(layout_info->scroller, 1);
-
- page_inner = elm_object_part_content_unset(page, "inner");
- if (page_inner) evas_object_move(page_inner, 0, 0);
- else _E("Cannot get the page_inner");
-
- /* Proxy DBox */
- proxy_page = edit_create_proxy_page(edit_info->scroller, page, PAGE_CHANGEABLE_BG_ON);
- goto_if(!proxy_page, ERROR);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- goto_if(!proxy_page_info, ERROR);
- goto_if(!edit_info->plus_page, ERROR);
-
- elm_object_signal_emit(proxy_page_info->page_inner, "select", "cover_clipper");
-
- scroller_push_page_before_edit(layout_info->scroller, edit_info->scroller, proxy_page, edit_info->plus_page);
- edit_arrange_plus_page(layout_info->edit);
-
- evas_object_smart_callback_add(proxy_page_info->focus, "clicked", _clicked_widget_cb, proxy_page);
- evas_object_smart_callback_add(proxy_page_info->remove_focus, "clicked", _del_widget_cb, proxy_page);
-
- if (edit_scroller_info->single_index) {
- index_update(edit_scroller_info->single_index, edit_info->scroller, INDEX_BRING_IN_NONE);
- }
-
- index_bring_in_page(edit_scroller_info->single_index, proxy_page);
- edit_change_focus(edit_info->scroller, proxy_page);
- scroller_region_show_page(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
- elm_object_signal_emit(plus_page_info->page_inner, "deselect", "line");
- elm_object_signal_emit(plus_page_info->page_inner, "deselect", "cover");
- elm_object_signal_emit(plus_page_info->page_inner, "enable", "blocker");
-
- return page;
-
-ERROR:
- if (page) {
- _remove_widget(page);
- }
- return NULL;
-}
-
-
-
-static Eina_Bool _fire_timer_cb(void *data)
-{
- Evas_Object *real_page = data;
- retv_if(!real_page, ECORE_CALLBACK_CANCEL);
- noti_broker_event_fire_to_plugin(EVENT_SOURCE_EDITING, EVENT_TYPE_NOTI_DELETE, real_page);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static void _remove_noti(Evas_Object *real_page)
-{
- Evas_Object *edit_scroller = NULL;
- Evas_Object *proxy_page = NULL;
- Evas_Object *page_current = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- page_info_s *page_info = NULL;
- page_info_s *proxy_page_info = NULL;
- Ecore_Timer *fire_timer = NULL;
-
- ret_if(!real_page);
-
- page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- proxy_page = evas_object_data_get(real_page, DATA_KEY_PROXY_PAGE);
- ret_if(!proxy_page);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!proxy_page_info);
-
- edit_scroller = proxy_page_info->scroller;
- ret_if(!edit_scroller);
-
- edit_scroller_info = evas_object_data_get(edit_scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- /* Proxy */
- scroller_pop_page(edit_scroller, proxy_page);
- edit_destroy_proxy_page(proxy_page);
-
- page_current = scroller_get_focused_page(edit_scroller);
- if (!page_current) {
- _D("No focused page");
- return;
- }
-
- edit_change_focus(edit_scroller, page_current);
-
- /* Noti */
- fire_timer = ecore_timer_add(0.1f, _fire_timer_cb, real_page);
- if (!fire_timer) {
- _E("Cannot add a timer");
- noti_broker_event_fire_to_plugin(EVENT_SOURCE_EDITING, EVENT_TYPE_NOTI_DELETE, real_page);
- }
-}
-
-
-
-static Eina_Bool _minify_noti_anim_cb(void *data)
-{
- Evas_Object *proxy_page = data;
- int w, h;
-
- retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
- evas_object_geometry_get(proxy_page, NULL, NULL, &w, &h);
-
- w -= SLIPPED_LENGTH;
- evas_object_size_hint_min_set(proxy_page, w, h);
-
- if (w <= 0) {
- Evas_Object *real_page = NULL;
-
- /* This has to be executed before _remove_noti */
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL);
-
- real_page = evas_object_data_get(proxy_page, DATA_KEY_REAL_PAGE);
- if (real_page) _remove_noti(real_page);
-
- return ECORE_CALLBACK_CANCEL;
- }
-
- return ECORE_CALLBACK_RENEW;
-}
-
-
-
-static void _del_noti_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *proxy_page = data;
- Evas_Object *page_inner = NULL;
- Ecore_Animator *anim = NULL;
-
- _D("Del is clicked");
-
- ret_if(!proxy_page);
-
- page_inner = elm_object_part_content_unset(proxy_page, "inner");
- ret_if(!page_inner);
- evas_object_hide(page_inner);
-
- anim = evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL);
- if (anim) return;
-
- anim = ecore_animator_add(_minify_noti_anim_cb, proxy_page);
- if (anim) evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_DEL, anim);
- else _E("Cannot add an animator");
-}
-
-
-
-#define SLIPPED_LENGTH_BEFORE 15
-static Eina_Bool _anim_move_page_before_cb(void *data)
-{
- Evas_Object *scroller = data;
- Evas_Object *page = NULL;
- Evas_Object *rect = NULL;
- scroller_info_s *scroller_info = NULL;
- int w, h;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- page = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING);
- evas_object_geometry_get(page, NULL, NULL, &w, &h);
-
- w += SLIPPED_LENGTH_BEFORE;
- evas_object_size_hint_min_set(page, w, h);
- if (w >= PAGE_EDIT_WIDTH) {
- evas_object_size_hint_min_set(page, PAGE_EDIT_WIDTH, PAGE_EDIT_HEIGHT);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING);
- rect = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING);
-
- if (rect) {
- elm_box_unpack(scroller_info->box, rect);
- evas_object_del(rect);
- } else _E("Cannot get the rect");
-
- if (scroller_info->single_index) {
- index_update(scroller_info->single_index, scroller, INDEX_BRING_IN_NONE);
- index_bring_in_page(scroller_info->single_index, page);
- }
- return ECORE_CALLBACK_CANCEL;
- }
- return ECORE_CALLBACK_RENEW;
-}
-
-
-
-HAPI w_home_error_e edit_push_page_before(Evas_Object *scroller, Evas_Object *page, Evas_Object *before)
-{
- Evas_Object *rect = NULL;
- scroller_info_s *scroller_info = NULL;
- Ecore_Animator *anim = NULL;
-
- retv_if(!scroller, W_HOME_ERROR_FAIL);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- anim = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING);
- if (anim) return W_HOME_ERROR_FAIL;
-
- rect = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING);
- if (rect) {
- elm_box_unpack(scroller_info->box, rect);
- evas_object_del(rect);
- }
-
- rect = evas_object_rectangle_add(main_get_info()->e);
- retv_if(!rect, W_HOME_ERROR_FAIL);
- evas_object_size_hint_min_set(rect, PAGE_EDIT_WIDTH, PAGE_EDIT_HEIGHT);
- evas_object_color_set(rect, 0, 0, 0, 0);
- evas_object_show(rect);
-
- elm_box_pack_after(scroller_info->box, rect, page);
- elm_box_unpack(scroller_info->box, page);
- if (before) elm_box_pack_before(scroller_info->box, page, before);
- else elm_box_pack_end(scroller_info->box, page);
-
- evas_object_size_hint_min_set(page, 1, PAGE_EDIT_HEIGHT);
-
- scroller_bring_in_page(scroller, page, SCROLLER_FREEZE_ON, SCROLLER_BRING_TYPE_ANIMATOR);
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING, page);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING, rect);
-
- anim = ecore_animator_add(_anim_move_page_before_cb, scroller);
- retv_if(!anim, W_HOME_ERROR_FAIL);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING, anim);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_EDIT_ITEM_IS_MOVED, (void *) 1);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-#define SLIPPED_LENGTH_AFTER 30
-static Eina_Bool _anim_move_page_after_cb(void *data)
-{
- Evas_Object *scroller = data;
- Evas_Object *page = NULL;
- Evas_Object *rect = NULL;
- scroller_info_s *scroller_info = NULL;
- int w, h;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- rect = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING);
- retv_if(!rect, ECORE_CALLBACK_CANCEL);
- evas_object_geometry_get(rect, NULL, NULL, &w, &h);
-
- w -= SLIPPED_LENGTH_AFTER;
- evas_object_size_hint_min_set(rect, w, h);
- if (w <= 0) {
- page = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING);
- elm_box_unpack(scroller_info->box, rect);
- scroller_bring_in_page(scroller, page, SCROLLER_FREEZE_ON, SCROLLER_BRING_TYPE_INSTANT);
- evas_object_del(rect);
-
- if (scroller_info->single_index) {
- index_update(scroller_info->single_index, scroller, INDEX_BRING_IN_NONE);
- index_bring_in_page(scroller_info->single_index, page);
- }
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING);
- return ECORE_CALLBACK_CANCEL;
- }
- return ECORE_CALLBACK_RENEW;
-}
-
-
-
-HAPI w_home_error_e edit_push_page_after(Evas_Object *scroller, Evas_Object *page, Evas_Object *after)
-{
- Evas_Object *rect = NULL;
- scroller_info_s *scroller_info = NULL;
- Ecore_Animator *anim = NULL;
-
- retv_if(!scroller, W_HOME_ERROR_FAIL);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- anim = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING);
- if (anim) return W_HOME_ERROR_FAIL;
-
- rect = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING);
- if (rect) {
- elm_box_unpack(scroller_info->box, rect);
- evas_object_del(rect);
- }
-
- rect = evas_object_rectangle_add(main_get_info()->e);
- retv_if(!rect, W_HOME_ERROR_FAIL);
- evas_object_size_hint_min_set(rect, PAGE_EDIT_WIDTH, PAGE_EDIT_HEIGHT);
- evas_object_color_set(rect, 0, 0, 0, 0);
- evas_object_show(rect);
-
- elm_box_pack_before(scroller_info->box, rect, page);
- elm_box_unpack(scroller_info->box, page);
- if (after) elm_box_pack_after(scroller_info->box, page, after);
- else elm_box_pack_start(scroller_info->box, page);
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_PAGE_FOR_MOVING, page);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_RECT_FOR_MOVING, rect);
-
- anim = ecore_animator_add(_anim_move_page_after_cb, scroller);
- retv_if(!anim, W_HOME_ERROR_FAIL);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_ANIM_FOR_MOVING, anim);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_EDIT_ITEM_IS_MOVED, (void *) 1);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static Eina_Bool _move_timer_cb(void *data)
-{
- Evas_Object *proxy_page = data;
- Evas_Object *pressed_page = NULL;
- page_info_s *page_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- int idx_above_page = -1;
- int idx_below_page = -1;
- int inner_x, inner_y, sx;
-
- retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, ECORE_CALLBACK_CANCEL);
- retv_if(!page_info->scroller, ECORE_CALLBACK_CANCEL);
- evas_object_data_del(page_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
-
- evas_object_geometry_get(page_info->page_inner, &inner_x, &inner_y, NULL, NULL);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM, (void *) inner_x);
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM, (void *) inner_y);
-
- elm_scroller_region_get(page_info->scroller, &sx, NULL, NULL, NULL);
- sx += inner_x;
- evas_object_data_set(page_info->scroller, PRIVATE_DATA_KEY_SCROLLER_X, (void *)sx);
-
- idx_below_page = scroller_seek_page_position(page_info->scroller, proxy_page);
- retv_if(-1 == idx_below_page, ECORE_CALLBACK_CANCEL);
-
- pressed_page = evas_object_data_get(page_info->scroller, PRIVATE_DATA_KEY_SCROLLER_PRESS_PAGE);
- retv_if(!pressed_page, ECORE_CALLBACK_CANCEL);
-
- idx_above_page = scroller_seek_page_position(page_info->scroller, pressed_page);
- retv_if(-1 == idx_above_page, ECORE_CALLBACK_CANCEL);
-
- if (idx_above_page < idx_below_page) {
- scroller_move_page_prev(page_info->scroller, pressed_page, proxy_page, pressed_page);
- } else {
- scroller_move_page_next(page_info->scroller, proxy_page, pressed_page, pressed_page);
- }
-
- scroller_bring_in_center_of(page_info->scroller, pressed_page, SCROLLER_FREEZE_ON, NULL, NULL, NULL, NULL);
-
- edit_scroller_info = evas_object_data_get(page_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!edit_scroller_info, ECORE_CALLBACK_CANCEL);
-
- /* Update index */
- retv_if(!edit_scroller_info->single_index, ECORE_CALLBACK_CANCEL);
- index_update(edit_scroller_info->single_index, page_info->scroller, INDEX_BRING_IN_NONE);
- index_bring_in_page(edit_scroller_info->single_index, pressed_page);
-
- _D("Move an proxy_page(%p, %d) to (%d)", proxy_page, idx_below_page, idx_above_page);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-#define TIME_MOVE_ITEM 0.1f
-static void _upper_start_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *proxy_page = obj;
- Evas_Object *pressed_page = NULL;
- Ecore_Timer *timer = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!proxy_page);
-
- page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- pressed_page = evas_object_data_get(page_info->scroller, PRIVATE_DATA_KEY_SCROLLER_PRESS_PAGE);
- ret_if(!pressed_page);
-
- if (proxy_page == pressed_page) {
- timer = evas_object_data_del(page_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
- if (timer) ecore_timer_del(timer);
- return;
- }
-
- _D("Upper start : %p", proxy_page);
-
- timer = evas_object_data_del(page_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
- if (timer) ecore_timer_del(timer);
-
- timer = ecore_timer_add(TIME_MOVE_ITEM, _move_timer_cb, proxy_page);
- if (timer) evas_object_data_set(page_info->scroller, DATA_KEY_EVENT_UPPER_TIMER, timer);
- else _E("Cannot add a timer");
-}
-
-
-
-static void _upper_cb(void *data, Evas_Object *obj, void *event_info)
-{
- _D("===Upper cb===");
-}
-
-
-
-static void _upper_end_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *page = obj;
- page_info_s *page_info = NULL;
- Ecore_Timer *timer = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- _D("Upper end : %p", page);
-
- timer = evas_object_data_del(page_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
- if (timer) ecore_timer_del(timer);
-}
-
-
-
-Evas_Object *edit_create_proxy_page(Evas_Object *edit_scroller, Evas_Object *real_page, page_changeable_bg_e changable_color)
-{
- Evas_Object *proxy_page = NULL;
- Evas_Object *proxy_item = NULL;
- Evas_Object *remove_focus = NULL;
- page_info_s *page_info = NULL;
- page_info_s *proxy_page_info = NULL;
-
- retv_if(!edit_scroller, NULL);
- retv_if(!real_page, NULL);
-
- page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- /* Proxy item */
- proxy_item = _create_proxy_item(edit_scroller, real_page);
- retv_if(!proxy_item, NULL);
-
- /* Proxy Page */
- proxy_page = page_create(edit_scroller
- , proxy_item
- , page_info->id, page_info->subid
- , PAGE_EDIT_WIDTH, PAGE_EDIT_HEIGHT
- , changable_color, page_info->removable);
- if (!proxy_page) {
- _E("Cannot create a page");
- _destroy_proxy_item(proxy_item);
- return NULL;
- }
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- if (!proxy_page_info) {
- _E("Cannot get the proxy_page_info");
- page_destroy(proxy_page);
- _destroy_proxy_item(proxy_item);
- return NULL;
- }
- elm_object_signal_emit(proxy_page_info->page_inner, "enable", "blocker");
-
- remove_focus = elm_button_add(proxy_page_info->page_inner);
- retv_if(!remove_focus, NULL);
-
- elm_object_style_set(remove_focus, "focus");
- elm_object_part_content_set(proxy_page_info->page_inner, "remove_focus", remove_focus);
- elm_access_info_cb_set(remove_focus, ELM_ACCESS_INFO, _access_remove_button_name_cb, NULL);
- proxy_page_info->remove_focus = remove_focus;
-
- evas_object_data_set(proxy_page, DATA_KEY_REAL_PAGE, real_page);
- evas_object_data_set(real_page, DATA_KEY_PROXY_PAGE, proxy_page);
-
- proxy_page_info->direction = page_info->direction;
- if (PAGE_DIRECTION_CENTER == page_info->direction) return proxy_page;
-
- evas_object_event_callback_add(proxy_page_info->page_inner, EVAS_CALLBACK_MOUSE_DOWN, _down_cb, proxy_page);
- evas_object_event_callback_add(proxy_page_info->page_inner, EVAS_CALLBACK_MOUSE_MOVE, _move_cb, proxy_page);
- evas_object_event_callback_add(proxy_page_info->page_inner, EVAS_CALLBACK_MOUSE_UP, _up_cb, proxy_page);
- evas_object_smart_callback_add(proxy_page, "upper_start", _upper_start_cb, NULL);
- evas_object_smart_callback_add(proxy_page, "upper", _upper_cb, NULL);
- evas_object_smart_callback_add(proxy_page, "upper_end", _upper_end_cb, NULL);
-
- return proxy_page;
-}
-
-
-
-void edit_destroy_proxy_page(Evas_Object *proxy_page)
-{
- Evas_Object *real_page = NULL;
- page_info_s *proxy_page_info = NULL;
- Ecore_Animator *anim = NULL;
-
- ret_if(!proxy_page);
-
- real_page = evas_object_data_del(proxy_page, DATA_KEY_REAL_PAGE);
- if (real_page) evas_object_data_del(real_page, DATA_KEY_PROXY_PAGE);
-
- anim = evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_ANIM_FOR_MOVING);
- if (anim) {
- ecore_animator_del(anim);
- anim = NULL;
- if (NULL == _content_set_page_inner(proxy_page)) _E("cannot set the page");
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_X_FOR_ANIM);
- evas_object_data_del(proxy_page, PRIVATE_DATA_KEY_PAGE_Y_FOR_ANIM);
- }
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!proxy_page_info);
-
- if (proxy_page_info->remove_focus) {
- evas_object_del(proxy_page_info->remove_focus);
- proxy_page_info->remove_focus = NULL;
- }
-
- if (proxy_page_info->item) {
- _destroy_proxy_item(proxy_page_info->item);
- }
- page_destroy(proxy_page);
-}
-
-
-
-static Eina_Bool _enlarge_widget_anim_cb(void *data)
-{
- Evas_Object *effect_page = data;
- Evas_Object *bg_rect = NULL;
-
- int cur_x, cur_y, cur_w, cur_h;
- int end_x, end_y, end_w, end_h;
- int vec_x, vec_y, vec_w, vec_h;
- int divide_factor;
-
- goto_if(!effect_page, OUT);
-
- bg_rect = evas_object_data_get(effect_page, DATA_KEY_BG);
- goto_if(!bg_rect, OUT);
-
- end_w = main_get_info()->root_w;
- end_h = main_get_info()->root_h;
-
- end_x = 0;
- end_y = 0;
-
- evas_object_geometry_get(effect_page, &cur_x, &cur_y, &cur_w, &cur_h);
-
- divide_factor = (int) evas_object_data_get(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR);
- if (divide_factor > 1) {
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *) divide_factor - 1);
- }
-
- vec_x = (end_x - cur_x) / divide_factor;
- vec_y = (end_y - cur_y) / divide_factor;
- vec_w = (end_w - cur_w) / divide_factor;
- vec_h = (end_h - cur_h) / divide_factor;
-
- if (!vec_x) vec_x = -1;
- if (!vec_y) vec_y = -1;
- if (!vec_w) vec_w = 1;
- if (!vec_h) vec_h = 1;
-
- cur_x += vec_x;
- cur_y += vec_y;
- cur_w += vec_w;
- cur_h += vec_h;
-
- if (cur_x < end_x) {
- goto OUT;
- }
-
- evas_object_move(effect_page, cur_x, cur_y);
- evas_object_resize(effect_page, cur_w, cur_h);
- evas_object_move(bg_rect, cur_x, cur_y);
- evas_object_resize(bg_rect, cur_w, cur_h);
-
- return ECORE_CALLBACK_RENEW;
-
-OUT:
- if (effect_page) {
- evas_object_data_del(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE);
- evas_object_data_del(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR);
- evas_object_data_del(effect_page, DATA_KEY_BG);
-
- edit_destroy_add_viewer(main_get_info()->layout);
- _destroy_proxy_bg(bg_rect);
- evas_object_del(effect_page);
- }
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-#define DIVIDE_FACTOR 5
-HAPI void edit_enlarge_effect_widget(void *effect_page)
-{
- Evas_Object *clip_bg = NULL;
- Ecore_Animator *anim = NULL;
-
- anim = evas_object_data_get(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE);
- if (anim) {
- _D("You've already an animator");
- return;
- }
-
- evas_object_raise(effect_page);
-
- anim = ecore_animator_add(_enlarge_widget_anim_cb, effect_page);
- if (anim) {
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE, anim);
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *) DIVIDE_FACTOR);
- } else {
- clip_bg = evas_object_data_del(effect_page, DATA_KEY_BG);
- if (clip_bg) _destroy_proxy_bg(clip_bg);
- evas_object_del(effect_page);
- }
-}
-
-
-
-static void _widget_selected_cb(void *data, Evas_Object *add_viewer, void *event_info)
-{
- Evas_Object *layout = data;
- Evas_Object *clip_bg = NULL;
- layout_info_s *layout_info = NULL;
- struct add_viewer_event_info *e = event_info;
-
- _D("Selected: %s", e->pkg_info.widget_id);
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- if (layout_info->edit) {
- edit_info_s *edit_info = NULL;
-
- evas_object_del(e->pkg_info.image);
- if (!add_widget_in_edit(layout, e->pkg_info.widget_id, e->pkg_info.content)) {
- _E("Cannot add widget in edit mode");
- }
- edit_destroy_add_viewer(layout);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- if (!edit_info) {
- _E("Failed to get edit info");
- return;
- }
- scroller_init_rotary(edit_info->scroller);
- elm_object_tree_focus_allow_set(layout_info->edit, EINA_TRUE);
- } else {
- clip_bg = _create_proxy_bg(e->pkg_info.image);
- ret_if(!clip_bg);
- evas_object_data_set(e->pkg_info.image, DATA_KEY_BG, clip_bg);
- edit_enlarge_effect_widget(e->pkg_info.image);
-
- if (!_add_widget_in_normal(layout, e->pkg_info.widget_id, e->pkg_info.content)) {
- _E("Cannot add widget in widget scroller");
- }
-
- scroller_init_rotary(layout_info->scroller);
- elm_object_tree_focus_allow_set(layout_info->scroller, EINA_TRUE);
- layout_add_mouse_cb(layout);
- }
-
- /* Only for right layout */
- wms_change_favorite_order(W_HOME_WMS_BACKUP);
-}
-
-
-
-HAPI Evas_Object *edit_create_add_viewer(Evas_Object *layout)
-{
- Evas_Object *add_viewer = NULL;
- layout_info_s *layout_info = NULL;
-
- retv_if(!layout, NULL);
-
- if (evas_object_data_get(layout, DATA_KEY_ADD_VIEWER)) {
- _D("There is already the add-viewer");
- return NULL;
- }
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- add_viewer = evas_object_add_viewer_add(layout);
- retv_if(!add_viewer, NULL);
-
- evas_object_size_hint_weight_set(add_viewer, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(add_viewer, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_resize(add_viewer, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_smart_callback_add(add_viewer, "selected", _widget_selected_cb, layout);
- evas_object_show(add_viewer);
- elm_object_part_content_set(layout, "add_viewer", add_viewer);
- elm_object_signal_emit(layout, "show", "add_viewer");
-
- if (layout_info->edit) {
- elm_object_tree_focus_allow_set(layout_info->edit, EINA_FALSE);
- } else {
- elm_object_tree_focus_allow_set(layout_info->scroller, EINA_FALSE);
- layout_del_mouse_cb(layout);
- }
- elm_object_tree_focus_allow_set(add_viewer, EINA_TRUE);
-
- evas_object_data_set(layout, DATA_KEY_ADD_VIEWER, add_viewer);
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_BACK, _add_viewer_back_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_HOME, _add_viewer_home_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
-
-
- return add_viewer;
-}
-
-
-
-static void _del_add_viewer(void *data, Evas_Object *o, const char *emission, const char *source)
-{
- Evas_Object *add_viewer = NULL;
- Evas_Object *layout = data;
- layout_info_s *layout_info = NULL;
-
- ret_if(!layout);
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- add_viewer = elm_object_part_content_unset(layout, "add_viewer");
- ret_if(!add_viewer);
-
- elm_object_tree_focus_allow_set(add_viewer, EINA_FALSE);
-
- evas_object_del(add_viewer);
- elm_object_signal_callback_del(layout, "add_viewer,hide", "add_viewer", _del_add_viewer);
-}
-
-
-
-HAPI void edit_destroy_add_viewer(Evas_Object *layout)
-{
- Evas_Object *add_viewer = NULL;
- layout_info_s *layout_info = NULL;
-
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- add_viewer = evas_object_data_del(layout, DATA_KEY_ADD_VIEWER);
- if (!add_viewer) return;
-
-#if 0
- gesture_unregister_cb(BEZEL_DOWN, _add_viewer_bezel_down_cb);
-#endif
- key_unregister_cb(KEY_TYPE_BACK, _add_viewer_back_key_cb);
- key_unregister_cb(KEY_TYPE_HOME, _add_viewer_home_key_cb);
-
- if (layout_info->edit) elm_object_signal_emit(layout, "hide", "add_viewer");
- else elm_object_signal_emit(layout, "hide,instant", "add_viewer");
-
- edje_object_message_signal_process(elm_layout_edje_get(layout));
-
- elm_object_signal_callback_add(layout, "add_viewer,hide", "add_viewer", _del_add_viewer, layout);
-}
-
-
-
-/* You have to free the returned value */
-HAPI char *edit_get_count_str_from_icu(int count)
-{
- char *p = NULL;
- char *ret_str = NULL;
- char *locale = NULL;
- char res[LOCALE_LEN] = { 0, };
-
- UErrorCode status = U_ZERO_ERROR;
- UNumberFormat *num_fmt;
- UChar result[20] = { 0, };
-
- uint32_t number = count;
- int32_t len = (int32_t) (sizeof(result) / sizeof((result)[0]));
-
- locale = vconf_get_str(VCONFKEY_REGIONFORMAT);
- retv_if(!locale, NULL);
-
- if(locale[0] != '\0') {
- p = strstr(locale, ".UTF-8");
- if (p) *p = 0;
- }
-
- num_fmt = unum_open(UNUM_DEFAULT, NULL, -1, locale, NULL, &status);
- unum_format(num_fmt, number, result, len, NULL, &status);
- u_austrcpy(res, result);
- unum_close(num_fmt);
-
- ret_str = strdup(res);
- free(locale);
- return ret_str;
-}
-
-
-
-static void _plus_item_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- edit_info_s *edit_info = NULL;
- layout_info_s *layout_info = data;
-
- _D("Clicked the plus item");
-
- ret_if(!layout_info);
- ret_if(!layout_info->edit);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- edit_change_focus(edit_info->scroller, NULL);
-
- if (!edit_create_add_viewer(edit_info->layout)) {
- _E("Cannot add the add-viewer");
- }
-
- effect_play_sound();
-}
-
-
-
-static void _plus_item_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->page_inner);
- ret_if(!page_info->item);
-
- elm_object_signal_emit(page_info->item, "edit,press", "plus");
- elm_object_signal_emit(page_info->item, "edit,press", "plus_ef");
-}
-
-
-
-static void _plus_item_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->page_inner);
- ret_if(!page_info->item);
-
- elm_object_signal_emit(page_info->item, "edit,release", "plus");
- elm_object_signal_emit(page_info->item, "edit,release", "plus_ef");
-}
-
-
-
-void _destroy_plus_page(Evas_Object *edit)
-{
- edit_info_s *edit_info = NULL;
- page_info_s *page_info = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!edit);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
- ret_if(!edit_info->scroller);
- ret_if(!edit_info->plus_page);
-
- scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- page_info = evas_object_data_get(edit_info->plus_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- evas_object_del(page_info->item);
-
- evas_object_data_del(edit_info->plus_page, DATA_KEY_REAL_PAGE);
- evas_object_data_del(edit_info->plus_page, PRIVATE_DATA_KEY_EDIT_DO_NOT_SUPPORT_ENLARGE_EFFECT);
- page_destroy(edit_info->plus_page);
-
- edit_info->plus_page = NULL;
- scroller_info->plus_page = NULL;
-}
-
-
-
-#define PLUS_ITEM_EDJ EDJEDIR"/page.edj"
-#define PLUS_ITEM_GROUP "plus_item"
-Evas_Object *_create_plus_page(Evas_Object *edit)
-{
- Evas_Object *page = NULL;
- Evas_Object *plus_item = NULL;
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
- page_info_s *page_info = NULL;
- scroller_info_s *scroller_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- Eina_Bool ret;
-
- retv_if(!edit, NULL);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, NULL);
-
- layout_info = evas_object_data_get(edit_info->layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- edit_scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!edit_scroller_info, NULL);
-
- plus_item = elm_layout_add(edit_info->scroller);
- goto_if(!plus_item, ERROR);
-
- ret = elm_layout_file_set(plus_item, PLUS_ITEM_EDJ, PLUS_ITEM_GROUP);
- goto_if(EINA_FALSE == ret, ERROR);
- evas_object_size_hint_weight_set(plus_item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(plus_item, ITEM_EDIT_WIDTH, ITEM_EDIT_HEIGHT);
- evas_object_show(plus_item);
-
- elm_object_part_text_set(plus_item, "plus_text", _("IDS_HS_BODY_ADD_WIDGET"));
-
- page = page_create(edit_info->scroller,
- plus_item,
- NULL, NULL,
- edit_scroller_info->page_width, edit_scroller_info->page_height,
- PAGE_CHANGEABLE_BG_OFF, PAGE_REMOVABLE_OFF);
- if (!page) {
- _E("Cannot create the page");
- evas_object_del(plus_item);
- return NULL;
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- goto_if(!page_info, ERROR);
- goto_if(!page_info->page_inner, ERROR);
-
- elm_object_signal_emit(page_info->page_inner, "enable", "blocker");
- elm_object_signal_emit(plus_item, "show,edit", "plus_item");
-
- elm_access_info_cb_set(page_info->focus, ELM_ACCESS_TYPE, NULL, NULL);
- elm_access_info_cb_set(page_info->focus, ELM_ACCESS_INFO, _access_plus_button_name_cb, NULL);
- elm_object_signal_callback_add(plus_item, "click", "plus_item", _plus_item_clicked_cb, layout_info);
- elm_object_signal_callback_add(plus_item, "down", "plus_item", _plus_item_down_cb, page);
- elm_object_signal_callback_add(plus_item, "up", "plus_item", _plus_item_up_cb, page);
-
-
- evas_object_data_set(page, DATA_KEY_REAL_PAGE, scroller_info->plus_page);
- evas_object_data_set(page, PRIVATE_DATA_KEY_EDIT_DO_NOT_SUPPORT_ENLARGE_EFFECT, (void *) 1);
- evas_object_data_set(scroller_info->plus_page, DATA_KEY_PROXY_PAGE, page);
-
- edit_info->plus_page = page;
- edit_scroller_info->plus_page = page;
-
- return page;
-
-ERROR:
- _destroy_plus_page(edit);
- return NULL;
-}
-
-
-static w_home_error_e _scroller_push_right_page(Evas_Object *edit, Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- edit_info_s *edit_info = NULL;
- page_info_s *page_info = NULL;
- int count = 0;
-
- retv_if(!edit, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(!scroller, W_HOME_ERROR_INVALID_PARAMETER);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, W_HOME_ERROR_FAIL);
-
- EINA_LIST_FREE(list, page) {
- Evas_Object *proxy_page = NULL;
- page_info_s *proxy_page_info = NULL;
- Evas_Object *page_inner;
-
- continue_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) continue;
- if (PAGE_DIRECTION_RIGHT != page_info->direction) continue;
- if (page == scroller_info->plus_page) continue;
-
- page_inner = elm_object_part_content_unset(page, "inner");
- if (!page_inner) {
- elm_object_part_content_set(page, "inner", page_info->page_inner);
- page_inner = elm_object_part_content_unset(page, "inner");
- if (!page_inner) {
- _E("Fault - Impossible");
- page_inner = page_info->page_inner;
- }
- }
- evas_object_move(page_inner, 0, 0);
-
- proxy_page = edit_create_proxy_page(edit_info->scroller, page, PAGE_CHANGEABLE_BG_ON);
- continue_if(!proxy_page);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- if (!proxy_page_info) {
- _E("Cannot get the page_info");
- edit_destroy_proxy_page(proxy_page);
- continue;
- }
- elm_object_signal_emit(proxy_page_info->page_inner, "select", "cover_clipper");
-
- elm_access_info_cb_set(proxy_page_info->focus, ELM_ACCESS_CONTEXT_INFO, _access_tab_to_move_cb, NULL);
- evas_object_smart_callback_add(proxy_page_info->focus, "clicked", _clicked_widget_cb, proxy_page);
- evas_object_smart_callback_add(proxy_page_info->remove_focus, "clicked", _del_widget_cb, proxy_page);
-
- scroller_push_page(edit_info->scroller, proxy_page, SCROLLER_PUSH_TYPE_LAST);
- count++;
- }
-
- /* Plus page */
- if (count < MAX_WIDGET) {
- Evas_Object *plus_page = NULL;
- plus_page = _create_plus_page(edit);
- retv_if(!plus_page, W_HOME_ERROR_FAIL);
- scroller_push_page(edit_info->scroller, plus_page, SCROLLER_PUSH_TYPE_LAST);
- edit_arrange_plus_page(edit);
- } else {
- _D("Widget reached MAX count");
- edit_info->is_max = 1;
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static void _scroller_pop_right_page(Evas_Object *edit)
-{
- Evas_Object *proxy_page = NULL;
- Evas_Object *real_page = NULL;
- Eina_List *edit_list = NULL;
- edit_info_s *edit_info = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *proxy_page_info = NULL;
- page_info_s *real_page_info = NULL;
-
- ret_if(!edit);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- if (edit_info->plus_page) {
- evas_object_data_del(edit_info->plus_page, DATA_KEY_REAL_PAGE);
- evas_object_data_del(scroller_info->plus_page, DATA_KEY_PROXY_PAGE);
- _destroy_plus_page(edit);
- }
-
- edit_list = elm_box_children_get(scroller_info->box);
- if (!edit_list) {
- _D("There is no page");
- return;
- }
-
- EINA_LIST_FREE(edit_list, proxy_page) {
- continue_if(!proxy_page);
-
- elm_box_unpack(scroller_info->box, proxy_page);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- continue_if(!proxy_page_info);
-
- real_page = evas_object_data_get(proxy_page, DATA_KEY_REAL_PAGE);
- continue_if(!real_page);
-
- real_page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- continue_if(!real_page_info);
-
- elm_object_part_content_set(real_page, "inner", real_page_info->page_inner);
-
- edit_destroy_proxy_page(proxy_page);
- }
-}
-
-
-
-#define PRIVATE_DATA_KEY_SCROLLER_PAD_BF "p_sc_pbf"
-#define PRIVATE_DATA_KEY_SCROLLER_PAD_AF "p_sc_paf"
-static void _add_padding(Evas_Object *edit_scroller)
-{
- Evas_Object *pad_bf, *pad_af;
- scroller_info_s *edit_scroller_info = NULL;
-
- ret_if(!edit_scroller);
-
- edit_scroller_info = evas_object_data_get(edit_scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- pad_bf = evas_object_rectangle_add(main_get_info()->e);
- ret_if(!pad_bf);
- evas_object_size_hint_min_set(pad_bf, PAGE_EDIT_SIDE_PAD_WIDTH, PAGE_EDIT_HEIGHT);
- evas_object_color_set(pad_bf, 0, 0, 0, 0);
- evas_object_show(pad_bf);
- elm_box_pack_start(edit_scroller_info->box_layout, pad_bf);
- evas_object_data_set(edit_scroller, PRIVATE_DATA_KEY_SCROLLER_PAD_BF, pad_bf);
-
- pad_af = evas_object_rectangle_add(main_get_info()->e);
- ret_if(!pad_af);
- evas_object_size_hint_min_set(pad_af, PAGE_EDIT_SIDE_PAD_WIDTH, PAGE_EDIT_HEIGHT);
- evas_object_color_set(pad_af, 0, 0, 0, 0);
- evas_object_show(pad_af);
- elm_box_pack_end(edit_scroller_info->box_layout, pad_af);
- evas_object_data_set(edit_scroller, PRIVATE_DATA_KEY_SCROLLER_PAD_AF, pad_af);
-}
-
-
-
-static void _remove_padding(Evas_Object *edit_scroller)
-{
- Evas_Object *pad_bf, *pad_af;
-
- ret_if(!edit_scroller);
-
- pad_bf = evas_object_data_del(edit_scroller, PRIVATE_DATA_KEY_SCROLLER_PAD_BF);
- if (pad_bf) evas_object_del(pad_bf);
-
- pad_af = evas_object_data_del(edit_scroller, PRIVATE_DATA_KEY_SCROLLER_PAD_AF);
- if (pad_af) evas_object_del(pad_af);
-}
-
-
-
-static void _edit_scroll_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *edit_scroller = obj;
- Evas_Object *page_current = NULL;
- scroller_info_s *edit_scroller_info = NULL;
-
- ret_if(!edit_scroller);
-
- edit_scroller_info = evas_object_data_get(edit_scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- if (evas_object_data_get(edit_scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED)) return;
- if (!edit_scroller_info->scroll_cover) return;
-
- page_current = scroller_get_focused_page(edit_scroller);
- ret_if(!page_current);
- edit_change_focus(edit_scroller, page_current);
-}
-
-
-
-static w_home_error_e _scroller_push_left_page(Evas_Object *edit, Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- edit_info_s *edit_info = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!edit, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(!scroller, W_HOME_ERROR_INVALID_PARAMETER);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, W_HOME_ERROR_FAIL);
-
- EINA_LIST_FREE(list, page) {
- Evas_Object *proxy_page = NULL;
- page_info_s *proxy_page_info = NULL;
-
- continue_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) continue;
- if (PAGE_DIRECTION_LEFT != page_info->direction) continue;
-
- proxy_page = edit_create_proxy_page(edit_info->scroller, page, PAGE_CHANGEABLE_BG_OFF);
- continue_if(!proxy_page);
-
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_EDIT_DISABLE_REORDERING, (void *) 1);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- if (!proxy_page_info) {
- _E("Cannot get the page_info");
- edit_destroy_proxy_page(proxy_page);
- continue;
- }
-
- if (scroller_info->center_neighbor_left == page) {
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE, (void *) 1);
- elm_object_signal_emit(proxy_page_info->page_inner, "disable", "cover");
- }
- elm_object_signal_emit(proxy_page_info->page_inner, "select", "cover_clipper");
-
- elm_access_info_cb_set(proxy_page_info->focus, ELM_ACCESS_CONTEXT_INFO, _access_tab_to_move_cb, NULL);
-
- evas_object_smart_callback_add(proxy_page_info->focus, "clicked", _clicked_noti_cb, proxy_page);
- evas_object_smart_callback_add(proxy_page_info->remove_focus, "clicked", _del_noti_cb, proxy_page);
-
- scroller_push_page(edit_info->scroller, proxy_page, SCROLLER_PUSH_TYPE_CENTER_LEFT);
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static void _scroller_pop_left_page(Evas_Object *edit)
-{
- Evas_Object *edit_page = NULL;
- Eina_List *edit_list = NULL;
- edit_info_s *edit_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!edit);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- edit_scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- edit_list = elm_box_children_get(edit_scroller_info->box);
- ret_if(!edit_list);
-
- EINA_LIST_FREE(edit_list, edit_page) {
- continue_if(!edit_page);
-
- page_info = evas_object_data_get(edit_page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- evas_object_data_del(edit_page, PRIVATE_DATA_KEY_EDIT_DISABLE_REORDERING);
- evas_object_data_del(edit_page, PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE);
- scroller_pop_page(edit_info->scroller, edit_page);
- edit_destroy_proxy_page(edit_page);
- }
-}
-
-
-
-static char *_access_page_num_cb(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- page_info_s *page_info = NULL;
- scroller_info_s *scroller_info = NULL;
- Eina_List *list = NULL;
- int count = 0;
- int cur = 0;
- char number[BUFSZE];
- char *tmp;
-
- retv_if(NULL == scroller, NULL);
-
- page = scroller_get_focused_page(scroller);
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, NULL);
-
- count = eina_list_count(list);
- cur = scroller_seek_page_position(scroller, page) + 1;
-
- snprintf(number, sizeof(number), _("IDS_AT_BODY_PAGE_P1SD_OF_P2SD_T_TTS"), cur, count);
-
- tmp = strdup(number);
- if (!tmp) return NULL;
- return tmp;
-}
-
-
-
-static void _edit_anim_stop_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- Evas_Object *press_page = NULL;
- char *tmp = NULL;
-
- _D("stop the scroller(%p) animation", scroller);
-
- ret_if(!scroller);
-
- if (!main_get_info()->is_tts) return;
-
- press_page = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_PRESS_PAGE);
- ret_if(!press_page);
-
- tmp = _access_page_num_cb(scroller);
- if (tmp) {
- elm_access_say(tmp);
- free(tmp);
- }
-}
-
-
-
-#define EDIT_EDJ EDJEDIR"/edit.edj"
-#define EDIT_GROUP "edit"
-HAPI Evas_Object *_create_right_layout(Evas_Object *layout)
-{
- Evas_Object *edit = NULL;
- Evas_Object *edit_scroller = NULL;
-
- layout_info_s *layout_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- edit_info_s *edit_info = NULL;
- Eina_Bool ret;
-
- retv_if(!layout, NULL);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- edit = elm_layout_add(layout);
- retv_if(NULL == edit, NULL);
-
- edit_info = calloc(1, sizeof(edit_info_s));
- if (!edit_info) {
- _E("Cannot calloc for edit_info");
- free(edit_info);
- return NULL;
- }
- evas_object_data_set(edit, DATA_KEY_EDIT_INFO, edit_info);
-
- ret = elm_layout_file_set(edit, EDIT_EDJ, EDIT_GROUP);
- if (EINA_FALSE == ret) {
- _E("cannot set the file into the layout");
- free(edit_info);
- evas_object_del(edit);
- return NULL;
- }
- evas_object_size_hint_weight_set(edit, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(edit, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_resize(edit, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_show(edit);
-
- layout_del_mouse_cb(layout);
-
- edit_scroller = scroller_create(layout, edit, PAGE_EDIT_WIDTH, PAGE_EDIT_HEIGHT, SCROLLER_INDEX_SINGULAR);
- if (!edit_scroller) {
- _E("Cannot create edit_scroller");
- free(edit_info);
- evas_object_del(edit);
- return NULL;
- }
- evas_object_smart_callback_add(edit_scroller, "scroll", _edit_scroll_cb, NULL);
- evas_object_smart_callback_add(edit_scroller, "scroll,anim,stop", _edit_anim_stop_cb, NULL);
- _add_padding(edit_scroller);
-
- elm_object_part_content_set(layout, "edit", edit);
- elm_object_part_content_set(edit, "scroller", edit_scroller);
- elm_object_signal_callback_add(edit, "edit_click", "", _edit_button_click_cb, layout);
-
- edit_info->layout = layout;
- layout_info->edit = edit;
-
- edit_scroller_info = evas_object_data_get(edit_scroller, DATA_KEY_SCROLLER_INFO);
- if (!edit_scroller_info) {
- _E("Cannot create scroller");
- scroller_destroy(edit);
- free(edit_info);
- evas_object_del(edit);
- return NULL;
- }
- edit_info->scroller = edit_scroller;
- edit_scroller_info->scroller_type = WIDGETS_STATE_REMOVE;
-
- edit_scroller_info->single_index = single_index_create(edit, edit_scroller, PAGE_DIRECTION_RIGHT);
- if (!edit_scroller_info->single_index) _E("Cannot create the right index");
- else elm_object_part_content_set(edit, "index", edit_scroller_info->single_index);
-
- _scroller_push_right_page(edit, layout_info->scroller);
-
- scroller_init_rotary(edit_info->scroller);
-
- return edit;
-}
-
-
-
-HAPI void _destroy_right_layout(Evas_Object *layout)
-{
- layout_info_s *layout_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- scroller_info_s *scroller_info = NULL;
- edit_info_s *edit_info = NULL;
-
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
- ret_if(!layout_info->edit);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- if (!evas_object_data_get(layout, PRIVATE_DATA_KEY_EDIT_SYNC_IS_DONE)) {
- _sync_from_edit_to_normal(layout);
- }
- evas_object_data_del(layout, PRIVATE_DATA_KEY_EDIT_SYNC_IS_DONE);
-
- layout_add_mouse_cb(layout);
-
- edit_scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- if (edit_scroller_info->single_index) {
- index_destroy(edit_scroller_info->single_index);
- }
-
- _scroller_pop_right_page(layout_info->edit);
- _remove_padding(edit_info->scroller);
-
- evas_object_data_del(edit_info->scroller, PRIVATE_DATA_KEY_EDIT_FOCUS_OBJECT);
- evas_object_data_del(edit_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED);
- scroller_destroy(layout_info->edit);
-
- evas_object_del(layout_info->edit);
- free(edit_info);
- layout_info->edit = NULL;
-
- /* Only for right layout */
- wms_change_favorite_order(W_HOME_WMS_BACKUP);
-}
-
-
-
-#define EDIT_EDJ EDJEDIR"/edit.edj"
-#define EDIT_GROUP "edit"
-HAPI Evas_Object *_create_left_layout(Evas_Object *layout)
-{
- Evas_Object *edit = NULL;
- Evas_Object *edit_scroller = NULL;
- Evas_Object *box = NULL;
-
- layout_info_s *layout_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- edit_info_s *edit_info = NULL;
- Eina_Bool ret;
-
- retv_if(!layout, NULL);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- edit = elm_layout_add(layout);
- retv_if(NULL == edit, NULL);
-
- edit_info = calloc(1, sizeof(edit_info_s));
- if (!edit_info) {
- _E("Cannot calloc for edit_info");
- free(edit_info);
- return NULL;
- }
- evas_object_data_set(edit, DATA_KEY_EDIT_INFO, edit_info);
-
- ret = elm_layout_file_set(edit, EDIT_EDJ, EDIT_GROUP);
- if (EINA_FALSE == ret) {
- _E("cannot set the file into the layout");
- free(edit_info);
- evas_object_del(edit);
- return NULL;
- }
- evas_object_size_hint_weight_set(edit, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(edit, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_resize(edit, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_show(edit);
-
- layout_del_mouse_cb(layout);
-
- evas_object_smart_callback_call(layout, LAYOUT_SMART_SIGNAL_EDIT_ON, layout);
-
- edit_scroller = scroller_create(layout, edit, PAGE_EDIT_WIDTH, PAGE_EDIT_HEIGHT, SCROLLER_INDEX_SINGULAR);
- if (!edit_scroller) {
- _E("Cannot create edit_scroller");
- free(edit_info);
- evas_object_del(edit);
- return NULL;
- }
- evas_object_smart_callback_add(edit_scroller, "scroll", _edit_scroll_cb, NULL);
- _add_padding(edit_scroller);
-
- box = elm_object_content_get(edit_scroller);
- evas_object_size_hint_align_set(box, 1.0, 0.5);
-
- elm_object_part_content_set(layout, "edit", edit);
- elm_object_part_content_set(edit, "scroller", edit_scroller);
-
- edit_info->layout = layout;
- edit_info->scroller = edit_scroller;
-
- layout_info->edit = edit;
-
- edit_scroller_info = evas_object_data_get(edit_scroller, DATA_KEY_SCROLLER_INFO);
- if (!edit_scroller_info) {
- _E("Cannot create scroller");
- scroller_destroy(layout);
- free(layout_info);
- evas_object_del(layout);
- return NULL;
- }
- edit_info->scroller = edit_scroller;
-
- edit_scroller_info->single_index = single_index_create(edit, edit_scroller, PAGE_DIRECTION_LEFT);
- if (!edit_scroller_info->single_index) _E("Cannot create the left index");
- else elm_object_part_content_set(edit, "index", edit_scroller_info->single_index);
-
- _scroller_push_left_page(edit, layout_info->scroller);
-
- return edit;
-}
-
-
-
-HAPI void _destroy_left_layout(Evas_Object *layout)
-{
- layout_info_s *layout_info = NULL;
- scroller_info_s *edit_scroller_info = NULL;
- edit_info_s *edit_info = NULL;
-
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
- ret_if(!layout_info->edit);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- edit_scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!edit_scroller_info);
-
- _scroller_pop_left_page(layout_info->edit);
- _remove_padding(edit_info->scroller);
-
- if (edit_scroller_info->single_index) {
- index_destroy(edit_scroller_info->single_index);
- }
-
- scroller_destroy(layout_info->edit);
-
- layout_add_mouse_cb(layout);
-
- free(edit_info);
- evas_object_data_del(layout_info->edit, DATA_KEY_EDIT_INFO);
- evas_object_del(layout_info->edit);
- layout_info->edit = NULL;
-
- evas_object_smart_callback_call(layout, LAYOUT_SMART_SIGNAL_EDIT_OFF, layout);
-}
-
-
-
-static key_cb_ret_e _edit_back_key_cb(void *data)
-{
- _W("");
- Evas_Object *layout = data;
- Evas_Object *effect_page = NULL;
- Evas_Object *proxy_page = NULL;
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- Evas_Object *page = NULL;
-
- retv_if(!layout, KEY_CB_RET_CONTINUE);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, KEY_CB_RET_CONTINUE);
-
- if (!layout_info->edit) {
- _D("Layout is not edited");
- return KEY_CB_RET_CONTINUE;
- }
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- goto_if(!edit_info, OUT);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- goto_if(!scroller_info, OUT);
-
- proxy_page = scroller_get_focused_page(edit_info->scroller);
- if (!proxy_page) goto OUT;
- if (evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_EDIT_DO_NOT_SUPPORT_ENLARGE_EFFECT)) goto OUT;
-
- effect_page = edit_create_enlarge_effect_page(proxy_page);
- if (effect_page) edit_enlarge_effect_page(effect_page);
- else goto OUT;
-
- page = evas_object_data_get(proxy_page, DATA_KEY_REAL_PAGE);
- scroller_region_show_center_of(layout_info->scroller, page, SCROLLER_FREEZE_OFF, _sync_from_edit_to_normal, layout, NULL, NULL);
-
- return KEY_CB_RET_STOP;
-
-OUT:
- if (edit_info && !scroller_get_right_page(edit_info->scroller, proxy_page)) {
- Evas_Object *real_page = NULL;
- int i = 0;
-
- _D("The proxy page(%p) does not have the right neighbor.", proxy_page);
-
- elm_scroller_last_page_get(layout_info->scroller, &i, NULL);
- real_page = scroller_get_page_at(layout_info->scroller, i);
- if (real_page) {
- _D("The last real page is (%p)", real_page);
- scroller_region_show_page(layout_info->scroller, real_page, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_INSTANT);
- if (scroller_info && scroller_info->plus_page == real_page) {
- _D("The last page is the plus page");
- page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- if (page_info) {
- if (page_info->item) elm_object_signal_emit(page_info->item, "show,widget,ani", "plus_item");
- elm_object_signal_emit(page_info->page_inner, "deselect", "line");
- }
- }
- }
- }
- edit_destroy_layout(layout);
- return KEY_CB_RET_STOP;
-}
-
-
-
-static key_cb_ret_e _edit_home_key_cb(void *data)
-{
- Evas_Object *layout = data;
- Evas_Object *effect_page = NULL;
- Evas_Object *proxy_page = NULL;
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
-
- retv_if(!layout, KEY_CB_RET_CONTINUE);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, KEY_CB_RET_CONTINUE);
-
- if (!layout_info->edit) {
- _D("Layout is not edited");
- return KEY_CB_RET_CONTINUE;
- }
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- goto_if(!edit_info, OUT);
-
- if (evas_object_data_get(edit_info->scroller, PRIVATE_DATA_KEY_EDIT_IS_LONGPRESSED)) return KEY_CB_RET_STOP;
-
- proxy_page = scroller_get_focused_page(edit_info->scroller);
- if (!proxy_page) goto OUT;
- if (evas_object_data_get(proxy_page, PRIVATE_DATA_KEY_EDIT_DO_NOT_SUPPORT_ENLARGE_EFFECT)) goto OUT;
-
- effect_page = edit_create_enlarge_effect_page(proxy_page);
- if (effect_page) edit_enlarge_effect_page(effect_page);
- else goto OUT;
-
- scroller_bring_in_by_push_type(layout_info->scroller, SCROLLER_PUSH_TYPE_CENTER, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
-
- return KEY_CB_RET_STOP;
-
-OUT:
- edit_destroy_layout(layout);
- return KEY_CB_RET_CONTINUE;
-}
-
-
-
-static void _destroy_proxy_bg(Evas_Object *clip_bg)
-{
- Evas_Object *proxy_bg = NULL;
-
- proxy_bg = evas_object_data_del(clip_bg, PRIVATE_DATA_KEY_PROXY_BG);
- if(proxy_bg) evas_object_del(proxy_bg);
- evas_object_del(clip_bg);
-}
-
-
-
-static Evas_Object *_create_proxy_bg(Evas_Object *item)
-{
- Evas_Object *bg = NULL;
- Evas_Object *clip_bg = NULL;
- Evas_Object *proxy_bg = NULL;
- Eina_Bool ret;
- int x, y, w, h;
-
- clip_bg = evas_object_rectangle_add(main_get_info()->e);
- retv_if(!clip_bg, NULL);
-
- evas_object_geometry_get(item, &x, &y, &w, &h);
- evas_object_resize(clip_bg, w, h);
- evas_object_move(clip_bg, x, y);
- evas_object_color_set(clip_bg, 255, 255, 255, 255);
- evas_object_show(clip_bg);
-
- bg = evas_object_data_get(main_get_info()->win, DATA_KEY_BG);
- goto_if(!bg, ERROR);
-
- proxy_bg = evas_object_image_filled_add(main_get_info()->e);
- goto_if(!proxy_bg, ERROR);
-
- evas_object_data_set(clip_bg, PRIVATE_DATA_KEY_PROXY_BG, proxy_bg);
-
- ret = evas_object_image_source_set(proxy_bg, bg);
- goto_if(EINA_FALSE == ret, ERROR);
- evas_object_image_source_visible_set(proxy_bg, EINA_TRUE);
- evas_object_image_source_clip_set(proxy_bg, EINA_FALSE);
- evas_object_resize(proxy_bg, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_move(proxy_bg, 0, 0);
- evas_object_show(proxy_bg);
-
- evas_object_clip_set(proxy_bg, clip_bg);
-
- return clip_bg;
-
-ERROR:
- _destroy_proxy_bg(clip_bg);
- return NULL;
-}
-
-
-
-HAPI Evas_Object *edit_create_layout(Evas_Object *layout, edit_mode_e edit_mode)
-{
- Evas_Object *edit = NULL;
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
-
- retv_if(!layout, NULL);
-
- _W("Create the edit layout");
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_BACK, _edit_back_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_HOME, _edit_home_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
-
- switch (edit_mode) {
- case EDIT_MODE_LEFT:
- edit = _create_left_layout(layout);
- break;
- case EDIT_MODE_CENTER:
- break;
- case EDIT_MODE_RIGHT:
- edit = _create_right_layout(layout);
- break;
- default:
- _E("Cannot reach here");
- break;
- }
- elm_object_signal_emit(layout, "show", "edit");
- elm_object_signal_emit(edit, "init", "edit");
- elm_object_signal_emit(layout, "hide", "scroller");
-
- evas_object_data_set(layout, DATA_KEY_EDIT_MODE, (void *) edit_mode);
- layout_info->edit = edit;
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- if (edit_info && edit_info->scroller) {
- scroller_focus(edit_info->scroller);
- } else _E("Cannot get the edit_info & edit_info->scroller");
-
- elm_object_tree_focus_allow_set(layout_info->scroller, EINA_FALSE);
- /* If you want to set the EINA_TRUE in this API,
- you have to control the tree focus set when using content_set or content_unset API
- in the layout that elm_object_tree_focus_allow_set is EINA_TRUE*/
- elm_object_tree_focus_allow_set(layout_info->edit, EINA_TRUE);
-
- return edit;
-}
-
-
-
-HAPI void edit_destroy_layout(void *layout)
-{
- layout_info_s *layout_info = NULL;
- edit_mode_e edit_mode = (int) evas_object_data_del(layout, DATA_KEY_EDIT_MODE);
-
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
- ret_if(!layout_info->edit);
-
- key_unregister_cb(KEY_TYPE_BACK, _edit_back_key_cb);
- key_unregister_cb(KEY_TYPE_HOME, _edit_home_key_cb);
-#if 0
- gesture_unregister_cb(BEZEL_DOWN, _edit_bezel_down_cb);
-#endif
-
- elm_object_tree_focus_allow_set(layout_info->scroller, EINA_TRUE);
- elm_object_tree_focus_allow_set(layout_info->edit, EINA_FALSE);
-
- _D("Destroy the edit layout : %d", edit_mode);
-
- switch (edit_mode) {
- case EDIT_MODE_LEFT:
- _destroy_left_layout(layout);
- break;
- case EDIT_MODE_CENTER:
- break;
- case EDIT_MODE_RIGHT:
- _destroy_right_layout(layout);
- break;
- default:
- _E("Cannot reach here");
- break;
- }
-
- layout_info->edit = NULL;
-
- scroller_init_rotary(layout_info->scroller);
-
- elm_object_signal_emit(layout, "hide", "edit");
- elm_object_signal_emit(layout, "show", "scroller");
-}
-
-
-
-static Eina_Bool _minify_page_anim_cb(void *data)
-{
- Evas_Object *effect_page = data;
- Evas_Object *end_page = NULL;
- Evas_Object *page_inner = NULL;
-
- page_info_s *end_page_info = NULL;
-
- int cur_x, cur_y, cur_w, cur_h;
- int end_x, end_y, end_w, end_h;
- int vec_x, vec_y, vec_w, vec_h;
- int divide_factor;
-
- retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
-
- end_page = evas_object_data_get(effect_page, DATA_KEY_PROXY_PAGE);
- retv_if(!end_page, ECORE_CALLBACK_CANCEL);
-
- end_page_info = evas_object_data_get(end_page, DATA_KEY_PAGE_INFO);
- goto_if(!end_page_info, ERROR);
-
- page_inner = end_page_info->page_inner;
- goto_if(!page_inner, ERROR);
-
- evas_object_geometry_get(page_inner, &end_x, &end_y, &end_w, &end_h);
- evas_object_geometry_get(effect_page, &cur_x, &cur_y, &cur_w, &cur_h);
-
- divide_factor = (int) evas_object_data_get(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR);
- if (divide_factor > 2) {
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *) divide_factor - 1);
- }
-
- vec_x = (end_x - cur_x) / divide_factor;
- vec_y = (end_y - cur_y) / divide_factor;
- vec_w = (end_w - cur_w) / divide_factor;
- vec_h = (end_h - cur_h) / divide_factor;
-
- if (!vec_x) vec_x = 1;
- if (!vec_y) vec_y = 1;
- if (!vec_w) vec_w = -1;
- if (!vec_h) vec_h = -1;
-
- cur_x += vec_x;
- cur_y += vec_y;
- cur_w += vec_w;
- cur_h += vec_h;
-
- if (cur_x > end_x) cur_x = end_x;
- if (cur_y > end_y) cur_y = end_y;
- if (cur_w < end_w) cur_w = end_w;
- if (cur_h < end_h) cur_h = end_h;
-
- if (cur_x >= end_x) {
- evas_object_data_del(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_MINIFY);
- evas_object_data_del(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR);
- edit_destroy_minify_effect_page(effect_page);
- return ECORE_CALLBACK_CANCEL;
- }
-
- evas_object_move(effect_page, cur_x, cur_y);
- evas_object_resize(effect_page, cur_w, cur_h);
-
- return ECORE_CALLBACK_RENEW;
-
-ERROR:
- _E("Critical! Effect page will be removed.");
- evas_object_del(effect_page);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Eina_Bool _enlarge_page_anim_cb(void *data)
-{
- Evas_Object *effect_page = data;
- Evas_Object *bg_rect = NULL;
- Evas_Object *layout = NULL;
- Evas_Object *real_page = NULL;
- page_info_s *page_info = NULL;
- layout_info_s *layout_info = NULL;
-
- int cur_x, cur_y, cur_w, cur_h;
- int end_x, end_y, end_w, end_h;
- int vec_x, vec_y, vec_w, vec_h;
- int divide_factor;
- double rel;
-
- retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
-
- layout = main_get_info()->layout;
- retv_if(!layout, ECORE_CALLBACK_CANCEL);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, ECORE_CALLBACK_CANCEL);
- retv_if(!layout_info->scroller, ECORE_CALLBACK_CANCEL);
-
- bg_rect = evas_object_data_get(effect_page, DATA_KEY_BG);
- goto_if(!bg_rect, OUT);
-
- real_page = evas_object_data_get(effect_page, DATA_KEY_REAL_PAGE);
- goto_if(!real_page, OUT);
-
- page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- goto_if(!page_info, OUT);
-
- rel = (double) main_get_info()->root_w / ITEM_EDIT_WIDTH;
- end_w = PAGE_EDIT_WIDTH * rel;
- end_h = PAGE_EDIT_HEIGHT * rel;
-
- end_x = (end_w - main_get_info()->root_w) / -2;
- end_y = (end_h - main_get_info()->root_h) / -2;
-
- evas_object_geometry_get(effect_page, &cur_x, &cur_y, &cur_w, &cur_h);
-
- divide_factor = (int) evas_object_data_get(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR);
- if (divide_factor > 1) {
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *) divide_factor - 1);
- }
-
- vec_x = (end_x - cur_x) / divide_factor;
- vec_y = (end_y - cur_y) / divide_factor;
- vec_w = (end_w - cur_w) / divide_factor;
- vec_h = (end_h - cur_h) / divide_factor;
-
- if (!vec_x) vec_x = -1;
- if (!vec_y) vec_y = -1;
- if (!vec_w) vec_w = 1;
- if (!vec_h) vec_h = 1;
-
- cur_x += vec_x;
- cur_y += vec_y;
- cur_w += vec_w;
- cur_h += vec_h;
-
- if (cur_x < end_x) {
- goto OUT;
- }
-
- evas_object_move(effect_page, cur_x, cur_y);
- evas_object_resize(effect_page, cur_w, cur_h);
- evas_object_move(bg_rect, cur_x, cur_y);
- evas_object_resize(bg_rect, cur_w, cur_h);
-
- return ECORE_CALLBACK_RENEW;
-
-OUT:
- evas_object_data_del(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE);
- evas_object_data_del(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR);
-
- edit_destroy_layout(layout);
- /* Layout has to be updated before after destroying the layout */
- edje_object_message_signal_process(elm_layout_edje_get(layout));
- edit_destroy_enlarge_effect_page(effect_page);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-HAPI void edit_minify_effect_page(void *effect_page)
-{
- Ecore_Animator *anim = NULL;
-
- ret_if(!effect_page);
-
- anim = evas_object_data_get(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_MINIFY);
- if (anim) {
- _D("You've already an animator");
- return;
- }
-
- anim = ecore_animator_add(_minify_page_anim_cb, effect_page);
- if (anim) {
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_MINIFY, anim);
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *) DIVIDE_FACTOR);
- } else {
- edit_destroy_minify_effect_page(effect_page);
- }
-}
-
-
-
-HAPI Evas_Object *edit_create_minify_effect_page(Evas_Object *page)
-{
- Evas_Object *effect_page = NULL;
- page_info_s *page_info = NULL;
- Eina_Bool ret;
- double rel;
- int width, height, x, y;
-
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- if (page_info->removable) {
- elm_object_signal_emit(page_info->page_inner, "hide", "del");
- }
-
- elm_object_signal_emit(page_info->page_inner, "deselect", "cover");
- elm_object_signal_emit(page_info->page_inner, "deselect", "cover_clipper");
- elm_object_signal_emit(page_info->page_inner, "deselect", "line");
- edje_object_message_signal_process(elm_layout_edje_get(page_info->page_inner));
-
- if (evas_object_data_get(page, PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE)) {
- elm_object_signal_emit(page_info->page_inner, "disable", "cover");
- elm_object_signal_emit(page_info->page_inner, "deselect", "line");
- } else {
- elm_object_signal_emit(page_info->page_inner, "select", "cover");
- elm_object_signal_emit(page_info->page_inner, "select", "line");
- }
- elm_object_signal_emit(page_info->page_inner, "select", "cover_clipper");
- scroller_disable_cover_on_scroll(page_info->scroller);
-
- effect_page = evas_object_image_filled_add(main_get_info()->e);
- retv_if(!effect_page, NULL);
-
- ret = evas_object_image_source_set(effect_page, page);
- if (EINA_FALSE == ret) {
- _E("Cannot set the source into the proxy image");
- evas_object_del(effect_page);
- return NULL;
- }
- evas_object_image_source_visible_set(effect_page, EINA_FALSE);
- evas_object_image_source_clip_set(effect_page, EINA_FALSE);
-
- rel = (double) main_get_info()->root_w / ITEM_EDIT_WIDTH;
- width = PAGE_EDIT_WIDTH * rel;
- height = PAGE_EDIT_HEIGHT * rel;
-
- x = (width - main_get_info()->root_w) / -2;
- y = (height - main_get_info()->root_h) / -2;
-
- evas_object_size_hint_min_set(effect_page, width, height);
- evas_object_resize(effect_page, width, height);
- evas_object_move(effect_page, x, y);
- evas_object_show(effect_page);
-
- evas_object_data_set(effect_page, DATA_KEY_PROXY_PAGE, page);
-
- return effect_page;
-
-}
-
-
-
-HAPI void edit_destroy_minify_effect_page(Evas_Object *effect_page)
-{
- Evas_Object *page = NULL;
- Evas_Object *page_current = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!effect_page);
-
- page = evas_object_data_del(effect_page, DATA_KEY_PROXY_PAGE);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- scroller_enable_cover_on_scroll(page_info->scroller);
-
- if (page_info->removable) {
- elm_object_signal_emit(page_info->page_inner, "show", "del");
- }
-
- evas_object_image_source_visible_set(effect_page, EINA_TRUE);
- evas_object_del(effect_page);
-
- page_current = scroller_get_focused_page(page_info->scroller);
- ret_if(!page_current);
- edit_change_focus(page_info->scroller, page_current);
-}
-
-
-
-HAPI void edit_enlarge_effect_page(void *effect_page)
-{
- Evas_Object *real_page = NULL;
- layout_info_s *layout_info = NULL;
- page_info_s *page_info = NULL;
- Ecore_Animator *anim = NULL;
-
- ret_if(!effect_page);
-
- real_page = evas_object_data_get(effect_page, DATA_KEY_REAL_PAGE);
- goto_if(!real_page, ERROR);
-
- page_info = evas_object_data_get(real_page, DATA_KEY_PAGE_INFO);
- goto_if(!page_info, ERROR);
- goto_if(!page_info->layout, ERROR);
-
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
- goto_if(!layout_info, ERROR);
- goto_if(!layout_info->scroller, ERROR);
-
- anim = evas_object_data_get(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE);
- if (anim) {
- _D("You've already an animator");
- return;
- }
-
- anim = ecore_animator_add(_enlarge_page_anim_cb, effect_page);
- if (anim) {
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_ANIM_FOR_ENLARGE, anim);
- evas_object_data_set(effect_page, PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *) DIVIDE_FACTOR);
- } else {
- edit_destroy_enlarge_effect_page(effect_page);
- }
-
- edje_object_message_signal_process(elm_layout_edje_get(page_info->layout));
-
- return;
-
-ERROR:
- _E("Destroy the effect page(%p)", effect_page);
- edit_destroy_enlarge_effect_page(effect_page);
-}
-
-
-
-HAPI Evas_Object *edit_create_enlarge_effect_page(Evas_Object *page)
-{
- Evas_Object *clip_bg = NULL;
- Evas_Object *effect_page = NULL;
- Evas_Object *real_page = NULL;
- page_info_s *page_info = NULL;
- layout_info_s *layout_info = NULL;
- Eina_Bool ret;
- int x, y, w, h;
-
- retv_if(!page, NULL);
-
- if (main_get_info()->layout) {
- layout_info = evas_object_data_get(main_get_info()->layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
- if (layout_info->edit) elm_object_signal_emit(layout_info->edit, "hide", "edit");
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- real_page = evas_object_data_get(page, DATA_KEY_REAL_PAGE);
- retv_if(!real_page, NULL);
-
- if (page_info->removable) {
- elm_object_signal_emit(page_info->page_inner, "hide", "del");
- }
-
- elm_object_signal_emit(page_info->page_inner, "deselect", "cover");
- elm_object_signal_emit(page_info->page_inner, "deselect", "cover_clipper");
- elm_object_signal_emit(page_info->page_inner, "deselect,im", "line");
- edje_object_message_signal_process(elm_layout_edje_get(page_info->page_inner));
-
- clip_bg = _create_proxy_bg(page_info->item);
- retv_if(!clip_bg, NULL);
-
- effect_page = evas_object_image_filled_add(main_get_info()->e);
- if (!effect_page) {
- _E("Cannot add effect page");
- _destroy_proxy_bg(clip_bg);
- return NULL;
- }
-
- evas_object_data_set(effect_page, DATA_KEY_REAL_PAGE, real_page);
- evas_object_data_set(effect_page, DATA_KEY_BG, clip_bg);
-
- ret = evas_object_image_source_set(effect_page, page_info->page_inner);
- if (EINA_FALSE == ret) {
- _E("Cannot set the source into the effect image");
- edit_destroy_enlarge_effect_page(effect_page);
- return NULL;
- }
- evas_object_image_source_visible_set(effect_page, EINA_FALSE);
- evas_object_image_source_clip_set(effect_page, EINA_FALSE);
-
- evas_object_geometry_get(page, &x, &y, &w, &h);
-
- evas_object_resize(effect_page, w, h);
- evas_object_move(effect_page, x, y);
- evas_object_show(effect_page);
-
- return effect_page;
-}
-
-
-
-HAPI void edit_destroy_enlarge_effect_page(Evas_Object *effect_page)
-{
- Evas_Object *page = NULL;
- Evas_Object *clip_bg = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!effect_page);
-
- clip_bg = evas_object_data_del(effect_page, DATA_KEY_BG);
- if (clip_bg) _destroy_proxy_bg(clip_bg);
-
- page = evas_object_data_del(effect_page, DATA_KEY_REAL_PAGE);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- evas_object_image_source_visible_set(effect_page, EINA_TRUE);
- evas_object_del(effect_page);
-}
-
-
-
-static Evas_Object *_create_refresh_left_page(Evas_Object *edit, Evas_Object *page)
-{
- Evas_Object *proxy_page = NULL;
- page_info_s *proxy_page_info = NULL;
- edit_info_s *edit_info = NULL;
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!page, NULL);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, NULL);
-
- layout_info = evas_object_data_get(edit_info->layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- proxy_page = edit_create_proxy_page(edit_info->scroller, page, PAGE_CHANGEABLE_BG_OFF);
- retv_if(!proxy_page, NULL);
-
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_EDIT_DISABLE_REORDERING, (void *) 1);
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- goto_if(!proxy_page_info, ERROR);
-
- if (scroller_info->center_neighbor_left == page) {
- evas_object_data_set(proxy_page, PRIVATE_DATA_KEY_EDIT_UNFOCUSABLE, (void *) 1);
- elm_object_signal_emit(proxy_page_info->page_inner, "disable", "cover");
- elm_object_signal_emit(proxy_page_info->page_inner, "select", "cover_clipper");
- }
-
- elm_access_info_cb_set(proxy_page_info->focus, ELM_ACCESS_CONTEXT_INFO, _access_tab_to_move_cb, NULL);
-
- evas_object_smart_callback_add(proxy_page_info->focus, "clicked", _clicked_noti_cb, proxy_page);
- evas_object_smart_callback_add(proxy_page_info->remove_focus, "clicked", _del_noti_cb, proxy_page);
-
- proxy_page_info->direction = PAGE_DIRECTION_LEFT;
-
- return proxy_page;
-
-ERROR:
- if (proxy_page) {
- edit_destroy_proxy_page(proxy_page);
- }
- return NULL;
-}
-
-
-
-static Evas_Object *_create_refresh_right_page(Evas_Object *edit, Evas_Object *page)
-{
- Evas_Object *proxy_page = NULL;
- page_info_s *proxy_page_info = NULL;
- edit_info_s *edit_info = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(edit, NULL);
- retv_if(page, NULL);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, NULL);
-
- scroller_info = evas_object_data_get(edit_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- proxy_page = edit_create_proxy_page(edit_info->scroller, page, PAGE_CHANGEABLE_BG_ON);
- retv_if(!proxy_page, NULL);
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- goto_if(!proxy_page_info, ERROR);
-
- evas_object_smart_callback_add(proxy_page_info->focus, "clicked", _clicked_widget_cb, proxy_page);
- evas_object_smart_callback_add(proxy_page_info->remove_focus, "clicked", _del_widget_cb, proxy_page);
-
- proxy_page_info->direction = PAGE_DIRECTION_RIGHT;
-
- return proxy_page;
-
-ERROR:
- if (proxy_page) {
- edit_destroy_proxy_page(proxy_page);
- }
- return NULL;
-}
-
-
-
-HAPI void edit_refresh_scroller(Evas_Object *edit, page_direction_e direction)
-{
- Evas_Object *page = NULL;
- Evas_Object *proxy_page = NULL;
- Eina_List *list = NULL;
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- edit_info_s *edit_info = NULL;
- layout_info_s *layout_info = NULL;
- page_info_s *page_info = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!edit);
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- layout_info = evas_object_data_get(edit_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- /*Add proxy page which didn't exist in eidt scroller list*/
- switch (direction) {
- case PAGE_DIRECTION_LEFT:
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- continue_if(!page);
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
- if (page_info->direction != PAGE_DIRECTION_LEFT) continue;
- proxy_page = evas_object_data_get(page, DATA_KEY_PROXY_PAGE);
- if (!proxy_page) {
- proxy_page = _create_refresh_left_page(edit, page);
- break_if(!proxy_page);
- } else scroller_pop_page(edit_info->scroller, proxy_page);
- scroller_push_page(edit_info->scroller, proxy_page, SCROLLER_PUSH_TYPE_CENTER_LEFT);
- }
- break;
- case PAGE_DIRECTION_RIGHT:
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- continue_if(!page);
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
- if (page_info->direction != PAGE_DIRECTION_RIGHT) continue;
- proxy_page = evas_object_data_get(page, DATA_KEY_PROXY_PAGE);
- if (!proxy_page) {
- proxy_page = _create_refresh_right_page(edit, page);
- break_if(!proxy_page);
- if (edit_info->plus_page) {
- scroller_push_page_before(edit_info->scroller, proxy_page, edit_info->plus_page);
- } else {
- scroller_push_page_before(edit_info->scroller, proxy_page, NULL);
- }
- }
- }
- break;
- default:
- break;
- }
- eina_list_free(list);
-}
-
-
-
-HAPI void edit_arrange_plus_page(Evas_Object *edit)
-{
- edit_info_s *edit_info = NULL;
- page_info_s *page_info = NULL;
- int count = 0;
-
- ret_if(!edit);
-
- _D("Arrange the plus page");
-
- edit_info = evas_object_data_get(edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
- ret_if(!edit_info->scroller);
-
- count = scroller_count_direction(edit_info->scroller, PAGE_DIRECTION_RIGHT);
-
- if (count > MAX_WIDGET) {
- _D("Disable the plus page(%p), count:%d", edit_info->plus_page, count);
-
- scroller_pop_page(edit_info->scroller, edit_info->plus_page);
- evas_object_hide(edit_info->plus_page);
-
- edit_info->is_max = 1;
- } else {
- _D("Enable the plus page, count:%d", count);
-
- if (edit_info->is_max) {
- if (!edit_info->plus_page) {
- edit_info->plus_page = _create_plus_page(edit);
- ret_if(!edit_info->plus_page);
- }
- scroller_push_page(edit_info->scroller, edit_info->plus_page, SCROLLER_PUSH_TYPE_LAST);
- evas_object_show(edit_info->plus_page);
- edit_info->is_max = 0;
- }
- }
- page_info = evas_object_data_get(edit_info->plus_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- elm_object_focus_allow_set(page_info->focus, 1 - edit_info->is_max);
-}
-
-
-
-// End of this file
diff --git a/src/effect.c b/src/effect.c
deleted file mode 100755
index 3fb3af1..0000000
--- a/src/effect.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <feedback.h>
-#include <vconf.h>
-#include <Evas.h>
-#include <Ecore.h>
-#include <elm_theme.h>
-#include <bundle.h>
-#include <dlog.h>
-#include <runtime_info.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "effect.h"
-
-
-static struct {
- bool sound_status;
- int is_feedback_initialized;
-} effect_info = {
- .sound_status = 0,
- .is_feedback_initialized = 0,
-};
-
-
-
-HAPI inline void effect_set_sound_status(bool status)
-{
- effect_info.sound_status = status;
-}
-
-
-
-HAPI inline int effect_get_sound_status(void)
-{
- return effect_info.sound_status;
-}
-
-
-
-HAPI w_home_error_e effect_init(void)
-{
- retv_if(1 == effect_info.is_feedback_initialized, W_HOME_ERROR_NONE);
- retv_if(0 != feedback_initialize(), W_HOME_ERROR_FAIL);
- //retv_if(runtime_info_get_value_bool(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, &effect_info.sound_status) < 0, W_HOME_ERROR_FAIL);
-
- effect_info.is_feedback_initialized = 1;
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void effect_fini(void)
-{
- ret_if(0 == effect_info.is_feedback_initialized);
- ret_if(0 != feedback_deinitialize());
-
- effect_info.is_feedback_initialized = 0;
-}
-
-
-
-HAPI void effect_play_sound(void)
-{
- int state = main_get_info()->state;
-
- if (APP_STATE_PAUSE == state)
- {
- _D("Do not play sound");
- return;
- }
-
- if (effect_info.is_feedback_initialized == 0) {
- effect_init();
- }
-
- //ret_if(runtime_info_get_value_bool(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, &effect_info.sound_status) < 0);
-
- if (effect_info.sound_status) {
- //feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TOUCH_TAP);
- }
-}
-
-
-
-HAPI void effect_play_vibration(void)
-{
- int state = main_get_info()->state;
-
- if (APP_STATE_PAUSE == state)
- {
- _D("Do not play vibration");
- return;
- }
-
- if (effect_info.is_feedback_initialized == 0) {
- effect_init();
- }
-
- feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_HOLD);
-}
-
-
-
-// End of a file
diff --git a/src/gesture.c b/src/gesture.c
deleted file mode 100755
index df53a8a..0000000
--- a/src/gesture.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Evas.h>
-#include <stdio.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <Ecore.h>
-#include <Ecore_Evas.h>
-#include <Elementary.h>
-#include <dd-display.h>
-#include <bundle.h>
-#include <dlog.h>
-#include <stdbool.h>
-
-#include "util.h"
-#include "main.h"
-#include "log.h"
-#include "gesture.h"
-#include "effect.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "layout.h"
-#include "layout_info.h"
-//#include "tutorial.h"
-#include "dbus.h"
-#include "apps/apps.h"
-
-#define LCD_ON_REASON_GESTURE "gesture"
-#define VCONFKEY_SIMPLE_CLOCK_STATUS "db/setting/simpleclock_mode"
-#define VCONFKEY_RESERVED_APPS_STATUS "memory/starter/reserved_apps_status"
-
-#define CB_LIST_MAX 3
-
-static Eina_List *cbs_list[CB_LIST_MAX];
-
-typedef struct {
- void (*result_cb)(void *);
- void *result_data;
-} gesture_cb_s;
-
-static Evas_Object *_layout_get(void) {
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
-
- if (win != NULL) {
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- }
-
- return layout;
-}
-
-static Evas_Object *_scroller_get(void) {
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
-
- if (win != NULL) {
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- if (layout != NULL) {
- scroller = elm_object_part_content_get(layout, "scroller");
- }
- }
-
- return scroller;
-}
-
-static void _clock_show(void)
-{
- int is_clock_displayed = 0;
-
- Evas_Object *scroller = _scroller_get();
- ret_if(scroller == NULL);
- Evas_Object *layout = _layout_get();
- ret_if(layout == NULL);
-#if 0
- if (tutorial_is_exist() == 1) {
- return ;
- }
-#endif
- /* delete edit/addviewer layout */
- layout_set_idle(layout);
-
- if (is_clock_displayed == 0) {
- scroller_bring_in_by_push_type(scroller, SCROLLER_PUSH_TYPE_CENTER, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_INSTANT_SHOW);
- }
-
- int w, h;
- Evas *e;
- Ecore_Evas *ee;
- //Ecore_X_GC gc;
- ee = ecore_evas_ecore_evas_get(evas_object_evas_get(main_get_info()->win));
- e = ecore_evas_get(ee);
- evas_output_viewport_get(e, NULL, NULL, &w, &h);
- evas_obscured_clear(e);
- evas_damage_rectangle_add(e, 0, 0, w, h);
- ecore_evas_manual_render(ee);
- elm_win_raise(main_get_info()->win);
-
- apps_hide();
-}
-
-#define ALPM_MANAGER_STATUS_SHOW "show"
-#define ALPM_MANAGER_STATUS_HIDE "hide"
-static void _alpm_manager_status_changed_cb(void *user_data, void *event_info)
-{
- char *status = event_info;
- ret_if(status == NULL);
-
- _W("alpm status:%s", status);
-
- if (strcmp(status, ALPM_MANAGER_STATUS_SHOW) == 0) {
- // do nothing
- } else if (strcmp(status, ALPM_MANAGER_STATUS_SIMPLE_HIDE) == 0) {
- _clock_show();
- _W("clock show");
- }
-}
-
-
-
-HAPI void home_gesture_init(void)
-{
- if (home_dbus_register_cb(DBUS_EVENT_ALPM_MANAGER_STATE_CHANGED, _alpm_manager_status_changed_cb, NULL) != W_HOME_ERROR_NONE) {
- _E("Failed to register alpm manager status changed cb");
- }
-}
-
-HAPI void home_gesture_fini(void)
-{
- home_dbus_unregister_cb(DBUS_EVENT_ALPM_MANAGER_STATE_CHANGED, _alpm_manager_status_changed_cb);
-}
-
-
-
-HAPI w_home_error_e gesture_register_cb(
- int mode,
- void (*result_cb)(void *), void *result_data)
-{
- retv_if(NULL == result_cb, W_HOME_ERROR_INVALID_PARAMETER);
-
- gesture_cb_s *cb = calloc(1, sizeof(gesture_cb_s));
- retv_if(!cb, W_HOME_ERROR_FAIL);
-
- cb->result_cb = result_cb;
- cb->result_data = result_data;
-
- cbs_list[mode] = eina_list_append(cbs_list[mode], cb);
- retv_if(NULL == cbs_list[mode], W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void gesture_unregister_cb(
- int mode,
- void (*result_cb)(void *))
-{
- const Eina_List *l;
- const Eina_List *n;
- gesture_cb_s *cb;
- EINA_LIST_FOREACH_SAFE(cbs_list[mode], l, n, cb) {
- continue_if(NULL == cb);
- if (result_cb != cb->result_cb) {
- continue;
- }
- cbs_list[mode] = eina_list_remove(cbs_list[mode], cb);
- free(cb);
- return;
- }
-}
-
-
-
-extern void gesture_execute_cbs(int mode)
-{
- const Eina_List *l;
- const Eina_List *n;
- gesture_cb_s *cb;
- EINA_LIST_FOREACH_SAFE(cbs_list[mode], l, n, cb) {
- continue_if(n);
- cb->result_cb(cb->result_data);
- }
-}
-
-
diff --git a/src/home_base_ui.c b/src/home_base_ui.c
deleted file mode 100755
index 671b55a..0000000
--- a/src/home_base_ui.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "home_base_ui.h"
-
-static struct {
- home_base_ui_t *base_ui;
-} s_info = {
- .base_ui = NULL,
-};
-
-static home_base_ui_t *__create_base_ui(void);
-
-home_base_ui_t *home_base_ui_get(void)
-{
- if (!s_info.base_ui) {
- s_info.base_ui = __create_base_ui();
- }
-
- return s_info.base_ui;
-}
-
-static home_base_ui_t *__create_base_ui(void)
-{
- return NULL;
-}
-
diff --git a/src/home_manager.c b/src/home_manager.c
deleted file mode 100755
index e6f73da..0000000
--- a/src/home_manager.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "home_manager.h"
-#include "home_state_handler.h"
-#include "error_type.h"
-
-#include "apps/apps.h"
-#include "clock/clock.h"
-#include "notification/noti.h"
-#include "widgets/widgets.h"
-
-bool home_create_cb(void *data)
-{
- home_state_set(CREATE);
-
- if (clock_init() != ERROR_NONE) {
- _E("failed to initialize clock");
- }
-
- if (noti_init() != ERROR_NONE) {
- _E("failed to initialize notification");
- }
-
- if (!widgets_init() != ERROR_NONE) {
- _E("failed to initialize widgets");
- }
-
- if (apps_init() != ERROR_NONE) {
- _E("failed to initialize apps");
- }
-
- return true;
-}
-
-void home_app_control_cb(app_control_h app_control, void *data)
-{
-
-}
-
-void home_resume_cb(void *data)
-{
- home_state_set(RESUME);
-
-}
-
-void home_pause_cb(void *data)
-{
- home_state_set(PAUSE);
-
-}
-
-void home_terminate_cb(void *data)
-{
- home_state_set(TERMINATE);
-
- apps_fini();
- widgets_fini();
- noti_fini();
- clock_fini();
-}
-
-void home_language_changed_cb(app_event_info_h event_info, void *user_data)
-{
-
-}
diff --git a/src/home_state_handler.c b/src/home_state_handler.c
deleted file mode 100755
index 15f7ac6..0000000
--- a/src/home_state_handler.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "home_state_handler.h"
-
-static struct {
- home_state_e state;
-} s_info = {
- .state = INIT,
-};
-
-void home_state_set(home_state_e state)
-{
- s_info.state = state;
-}
-
-home_state_e home_state_get(void)
-{
- return s_info.state;
-}
diff --git a/src/index.c b/src/index.c
deleted file mode 100755
index 68e5180..0000000
--- a/src/index.c
+++ /dev/null
@@ -1,828 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdbool.h>
-#include <Elementary.h>
-#include <bundle.h>
-#include <dlog.h>
-
-#include "conf.h"
-#include "layout_info.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "index_info.h"
-#include "index.h"
-#include "scroller.h"
-
-
-
-typedef struct {
- Evas_Object *page;
- int index;
-} page_index_s;
-
-
-
-#define INDEX_ODD_ITEM_NUM 19
-#define INDEX_EVEN_ITEM_NUM 20
-static const char *_index_style_get(int index, int even)
-{
- static const char g_it_style_odd[INDEX_ODD_ITEM_NUM][20] = {
- "item/odd_1",
- "item/odd_2",
- "item/odd_3",
- "item/odd_4",
- "item/odd_5",
- "item/odd_6",
- "item/odd_7",
- "item/odd_8",
- "item/odd_9",
- "item/odd_10",
- "item/odd_11",
- "item/odd_12",
- "item/odd_13",
- "item/odd_14",
- "item/odd_15",
- "item/odd_16",
- "item/odd_17",
- "item/odd_18",
- "item/odd_19",
- };
- static const char g_it_style_even[INDEX_EVEN_ITEM_NUM][20] = {
- "item/even_1",
- "item/even_2",
- "item/even_3",
- "item/even_4",
- "item/even_5",
- "item/even_6",
- "item/even_7",
- "item/even_8",
- "item/even_9",
- "item/even_10",
- "item/even_11",
- "item/even_12",
- "item/even_13",
- "item/even_14",
- "item/even_15",
- "item/even_16",
- "item/even_17",
- "item/even_18",
- "item/even_19",
- "item/even_20",
- };
-
- index = (index < 0) ? 0 : index;
- if (even) {
- index = (index >= INDEX_EVEN_ITEM_NUM) ? INDEX_EVEN_ITEM_NUM - 1 : index;
-
- return g_it_style_even[index];
- } else {
- index = (index >= INDEX_ODD_ITEM_NUM) ? INDEX_ODD_ITEM_NUM - 1 : index;
-
- return g_it_style_odd[index];
- }
-}
-
-
-
-HAPI void index_bring_in_page(Evas_Object *index, Evas_Object *page)
-{
- Elm_Object_Item *idx_it = NULL;
- const Eina_List *l = NULL;
- index_info_s *index_info = NULL;
- page_index_s *page_index = NULL;
- int idx = 0;
- int found = 0;
-
- ret_if(!index);
- ret_if(!page);
-
- index_info = evas_object_data_get(index, DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
- ret_if(!index_info->page_index_list);
-
- EINA_LIST_FOREACH(index_info->page_index_list, l, page_index) {
- if (page_index->page == page) {
- idx = page_index->index;
- found = 1;
- break;
- }
- }
-
- if (!found) {
- _E("Cannot find a page(%p)", page);
- return;
- }
-
- idx_it = elm_index_item_find(index, (void *) idx);
- if (idx_it) {
- elm_index_item_selected_set(idx_it, EINA_TRUE);
- } else {
- _E("Critical, the index(%p) cannot find the page(%p:%d)", index, page, idx);
- }
-}
-
-
-
-HAPI void multi_index_bring_in_page(struct index_st *index, Evas_Object *page)
-{
- _D("Multi index page bring in");
- const Eina_List *l = NULL;
- page_index_s *page_index = NULL;
- layout_info_s *layout_info = NULL;
- int idx = 0;
- int found = 0;
- int i;
- int inserted_count = 0;
-
- ret_if(!index);
- ret_if(!page);
-
- ret_if(!index->index_info);
- ret_if(!index->index_info->page_index_list);
-
-
- layout_info = evas_object_data_get(index->index_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
- ret_if(evas_object_data_get(index->index_info->layout, DATA_KEY_ADD_VIEWER));
-
- inserted_count = scroller_count_direction(index->index_info->scroller, index->index_info->direction);
-
- EINA_LIST_FOREACH(index->index_info->page_index_list, l, page_index) {
- if (page_index->page == page) {
- idx = page_index->index;
- found = 1;
- break;
- }
- }
- if (!found) {
- _E("Cannot find a page(%p)", page);
-
- for (i = 0; i < inserted_count; i++)
- {
- elm_object_signal_emit(index->unit[i], "show", "index");
- }
- return;
- }
-
- for (i = 0; i < inserted_count; i++)
- {
- if (idx == i) {
- elm_object_signal_emit(index->unit[i], "selected", "index");
- } else {
- elm_object_signal_emit(index->unit[i], "show", "index");
- }
- }
-}
-
-
-
-HAPI Evas_Object *index_create(Evas_Object *layout, Evas_Object *scroller, page_direction_e direction)
-{
- Evas_Object *index = NULL;
- scroller_info_s *scroller_info = NULL;
- index_info_s *index_info = NULL;
-
- retv_if(!layout, NULL);
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- index = elm_index_add(layout);
- retv_if(!index, NULL);
- elm_object_style_set(index, "circle");
-
- index_info = calloc(1, sizeof(index_info_s));
- if (!index_info) {
- _E("Cannot calloc for index_info");
- evas_object_del(index);
- return NULL;
- }
- evas_object_data_set(index, DATA_KEY_INDEX_INFO, index_info);
-
- evas_object_size_hint_weight_set(index, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(index, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- elm_object_style_set(index, "thumbnail");
- elm_index_horizontal_set(index, EINA_TRUE);
- elm_index_autohide_disabled_set(index, EINA_TRUE);
- elm_index_level_go(index, 0);
- evas_object_show(index);
-
- index_info->direction = direction;
- index_info->layout = layout;
- index_info->scroller = scroller;
-
- return index;
-}
-
-
-
-#define PAGE_INDICATOR_EDJ EDJEDIR"/page_indicator.edj"
-#define GROUP_INDICATOR "indicator_dot"
-#define GROUP_CENTER "clock"
-HAPI struct index_st *multi_index_create(Evas_Object *layout, Evas_Object *scroller, page_direction_e direction)
-{
- struct index_st *index = NULL;
- scroller_info_s *scroller_info = NULL;
- int count = 0;
- int i = 0;
- char *group = NULL;
- int size = 0;
-
- retv_if(!layout, NULL);
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- index = calloc(1, sizeof(struct index_st));
- if (!index) {
- _E("Cannot calloc for index_info");
- return NULL;
- }
-
- if (direction == PAGE_DIRECTION_CENTER) {
- count = 1;
- group = GROUP_CENTER;
- size = CLOCK_UNIT_SIZE;
- } else {
- count = INDICATOR_MAX_COUNT;
- group = GROUP_INDICATOR;
- size = INDICATOR_UNIT_SIZE;
- }
-
- for (i = 0; i < count; i++)
- {
- int ret;
- index->unit[i] = elm_layout_add(scroller);
- if (!index->unit[i]) {
- _E("Failed to layout for indicator dot");
- return NULL;
- }
- ret = elm_layout_file_set(index->unit[i], PAGE_INDICATOR_EDJ, group);
- if (ret == EINA_FALSE) {
- _E("Failed to set layout image file for indicator dot");
- return NULL;
- }
-
- evas_object_size_hint_min_set(index->unit[i], size, size);
- evas_object_size_hint_max_set(index->unit[i], size, size);
- evas_object_resize(index->unit[i], size, size);
- evas_object_move(index->unit[i], WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- evas_object_show(index->unit[i]);
- }
-
- index->index_info = calloc(1, sizeof(index_info_s));
- if (!index->index_info) {
- _E("Cannot calloc for index_info");
- return NULL;
- }
-
- index->index_info->direction = direction;
- index->index_info->layout = layout;
- index->index_info->scroller = scroller;
-
- return index;
-}
-
-HAPI Evas_Object *single_index_create(Evas_Object *layout, Evas_Object *scroller, page_direction_e direction)
-{
- Evas_Object *index = NULL;
- scroller_info_s *scroller_info = NULL;
- index_info_s *index_info = NULL;
-
- retv_if(!layout, NULL);
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- index = elm_index_add(layout);
- retv_if(!index, NULL);
- elm_object_style_set(index, "circle");
-
- index_info = calloc(1, sizeof(index_info_s));
- if (!index_info) {
- _E("Cannot calloc for index_info");
- evas_object_del(index);
- return NULL;
- }
- evas_object_data_set(index, DATA_KEY_INDEX_INFO, index_info);
-
- evas_object_size_hint_weight_set(index, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(index, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- elm_index_horizontal_set(index, EINA_TRUE);
- elm_index_autohide_disabled_set(index, EINA_TRUE);
- elm_index_level_go(index, 0);
- evas_object_show(index);
-
- index_info->direction = direction;
- index_info->layout = layout;
- index_info->scroller = scroller;
-
- return index;
-}
-
-
-
-
-HAPI void multi_index_destroy(struct index_st *index)
-{
- page_index_s *page_index = NULL;
-
- ret_if(!index);
- ret_if(!index->index_info);
-
- if (index->index_info->page_index_list) {
- EINA_LIST_FREE(index->index_info->page_index_list, page_index) {
- free(page_index);
- }
- index->index_info->page_index_list = NULL;
- }
-
- free(index->index_info);
- free(index);
-}
-
-
-
-HAPI void index_destroy(Evas_Object *index)
-{
- index_info_s *index_info = NULL;
- page_index_s *page_index = NULL;
-
- ret_if(!index);
-
- index_info = evas_object_data_del(index, DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
-
- if (index_info->page_index_list) {
- EINA_LIST_FREE(index_info->page_index_list, page_index) {
- free(page_index);
- }
- index_info->page_index_list = NULL;
- }
-
- free(index_info);
- elm_index_item_clear(index);
- evas_object_del(index);
-}
-
-
-
-static void _update_left(Evas_Object *scroller, struct index_st *index, const Eina_List *list)
-{
- Evas_Object *page = NULL;
- Eina_List *reverse_list = NULL;
-
- page_info_s *page_info = NULL;
- page_index_s *page_index = NULL;
- scroller_info_s *scroller_info = NULL;
-
- int page_index_inserting = 0;
- int cur_inserted = 0;
- int cur_count = 0;
- int total_inserted = 0;
- char part_name[1024];
- int i;
-
- ret_if(!index);
- ret_if(!list);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- /* 0. Remove an old page_index_list */
- if (index->index_info->page_index_list) {
- EINA_LIST_FREE(index->index_info->page_index_list, page_index) {
- free(page_index);
- }
- index->index_info->page_index_list = NULL;
- }
-
- /* 1. Make indexes (cur/center/other) */
- total_inserted = scroller_count_direction(scroller, PAGE_DIRECTION_LEFT);
-
- if (total_inserted > INDICATOR_MAX_COUNT) {
- total_inserted = INDICATOR_MAX_COUNT;
- }
-
- for (i = 0; i < MAX_WIDGET; i++) {
- Evas_Object *indi_unit = NULL;
- snprintf(part_name, sizeof(part_name), "left_indicator_%d", i);
- indi_unit = elm_object_part_content_unset(scroller_info->indicator_layout, part_name);
- if (!indi_unit) evas_object_move(indi_unit, WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- else evas_object_move(index->unit[i], WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- }
-
- reverse_list = eina_list_reverse_clone(list);
- ret_if(!reverse_list);
-
- total_inserted--;
- EINA_LIST_FREE(reverse_list, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (page_info->direction == index->index_info->direction) {
- if (total_inserted >= 0) {
- snprintf(part_name, sizeof(part_name), "left_indicator_%d", cur_inserted);
-
- elm_object_part_content_set(scroller_info->indicator_layout, part_name, index->unit[cur_inserted]);
- cur_inserted++;
- total_inserted--;
- }
- }
- cur_count++;
- _D("page:%p, total_inserted:%d", page, total_inserted);
- }
-
- /* 2. Make a new page_index_list */
- reverse_list = eina_list_reverse_clone(list);
- ret_if(!reverse_list);
-
- page_index_inserting = -1;
- EINA_LIST_FREE(reverse_list, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (index->index_info->direction == page_info->direction) {
- page_index = calloc(1, sizeof(page_index_s));
- continue_if(!page_index);
-
- if (page_index_inserting < INDICATOR_MAX_COUNT - 1) {
- page_index_inserting++;
- }
- page_index->page = page;
- page_index->index = page_index_inserting;
-
- _D("Index(%p-%d) is updating, page(%p-%d:%d)"
- , index, index->index_info->direction
- , page, page_info->direction, page_index_inserting);
-
- index->index_info->page_index_list = eina_list_append(index->index_info->page_index_list, page_index);
- }
-
- }
-}
-
-
-
-static void _update_right(Evas_Object *scroller, struct index_st *index, const Eina_List *list)
-{
- Evas_Object *page = NULL;
- const Eina_List *l = NULL;
-
- page_info_s *page_info = NULL;
- page_index_s *page_index = NULL;
- scroller_info_s *scroller_info = NULL;
-
- int page_index_inserting = 0;
- int cur_inserted = 0;
- int cur_count = 0, index_number = 0;
- int total_inserted = 0;
- char part_name[1024];
- int i;
-
- ret_if(!index);
- ret_if(!list);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- /* 0. Remove an old page_index_list */
- if (index->index_info->page_index_list) {
- EINA_LIST_FREE(index->index_info->page_index_list, page_index) {
- free(page_index);
- }
- index->index_info->page_index_list = NULL;
- }
-
- /* 1. Make indexes (cur/center/other) */
- total_inserted = scroller_count_direction(scroller, PAGE_DIRECTION_RIGHT);
-
- if (total_inserted > INDICATOR_MAX_COUNT) {
- total_inserted = INDICATOR_MAX_COUNT;
- }
-
- for (i = 0; i < MAX_WIDGET; i++) {
- Evas_Object *indi_unit = NULL;
- snprintf(part_name, sizeof(part_name), "right_indicator_%d", i);
- indi_unit = elm_object_part_content_unset(scroller_info->indicator_layout, part_name);
- if (!indi_unit) evas_object_move(indi_unit, WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- else evas_object_move(index->unit[i], WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- }
-
- EINA_LIST_FOREACH(list, l, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (page_info->direction == index->index_info->direction) {
- if (index_number < total_inserted) {
- snprintf(part_name, sizeof(part_name), "right_indicator_%d", cur_inserted);
- _D("Part_name: %s", part_name);
-
- elm_object_part_content_set(scroller_info->indicator_layout, part_name, index->unit[cur_inserted]);
- cur_inserted++;
- index_number++;
- }
- cur_count++;
- }
- _D("page:%p, total_inserted:%d", page, total_inserted);
- }
-
- /* 2. Make a new page_index_list */
- page_index_inserting = -1;
- EINA_LIST_FOREACH(list, l, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (index->index_info->direction == page_info->direction) {
- page_index = calloc(1, sizeof(page_index_s));
- continue_if(!page_index);
-
- page_index_inserting++;
- page_index->page = page;
- page_index->index = page_index_inserting;
-
- _D("Index(%p-%d) is updating, page(%p-%d:%d)"
- , index, index->index_info->direction
- , page, page_info->direction, page_index_inserting);
-
- index->index_info->page_index_list = eina_list_append(index->index_info->page_index_list, page_index);
- }
- }
-}
-
-
-
-static void _update_center(Evas_Object *scroller, struct index_st *index, const Eina_List *list)
-{
- Evas_Object *page = NULL;
- const Eina_List *l = NULL;
-
- page_info_s *page_info = NULL;
- page_index_s *page_index = NULL;
- scroller_info_s *scroller_info = NULL;
-
- int page_index_inserting = 0;
- int cur_inserted = 0;
- int total_inserted = 0;
- int i;
-
- ret_if(!index);
- ret_if(!list);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- /* 0. Remove an old page_index_list */
- if (index->index_info->page_index_list) {
- EINA_LIST_FREE(index->index_info->page_index_list, page_index) {
- free(page_index);
- }
- index->index_info->page_index_list = NULL;
- }
-
- /* 1. Make indexes (cur/center/other) */
- total_inserted = scroller_count_direction(scroller, PAGE_DIRECTION_CENTER);
-
- if (total_inserted > INDICATOR_MAX_COUNT) {
- total_inserted = INDICATOR_MAX_COUNT;
- }
-
- for (i = 0; i < total_inserted; i++) {
- Evas_Object *clock_unit = NULL;
- clock_unit = elm_object_part_content_unset(scroller_info->indicator_layout, "clock_indicator");
- if (!clock_unit) evas_object_move(clock_unit, WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- else evas_object_move(index->unit[i], WIDGET_OUTSIDE_X, WIDGET_OUTSIDE_Y);
- }
-
- for (i = 0; i < total_inserted; i++)
- {
- elm_object_part_content_set(scroller_info->indicator_layout, "clock_indicator", index->unit[cur_inserted]);
- }
-
- /* 2. Make a new page_index_list */
- page_index_inserting = -1;
- EINA_LIST_FOREACH(list, l, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (index->index_info->direction == page_info->direction) {
- page_index = calloc(1, sizeof(page_index_s));
- continue_if(!page_index);
-
- page_index_inserting++;
- page_index->page = page;
- page_index->index = page_index_inserting;
-
- _D("Index(%p-%d) is updating, page(%p-%d:%d)"
- , index, index->index_info->direction
- , page, page_info->direction, page_index_inserting);
-
- index->index_info->page_index_list = eina_list_append(index->index_info->page_index_list, page_index);
- }
- }
-}
-
-
-
-#define MAX_INDEX_NUMBER 15
-static void _update_single_index(Evas_Object *scroller, Evas_Object *index, const Eina_List *list)
-{
- Evas_Object *page = NULL;
- Elm_Object_Item *idx_it = NULL;
- const Eina_List *l = NULL;
-
- index_info_s *index_info = NULL;
- page_info_s *page_info = NULL;
- page_index_s *page_index = NULL;
- page_direction_e before_direction = PAGE_DIRECTION_MAX;
-
- int extra_idx = 0, page_index_inserting = 0;
- int cur_inserted = 0;
- int center_count = 0, other_count = 0, cur_count = 0, index_number = 0;
- int cur_start_idx = 0, cur_mid_idx = 0;
- int total_count = 0, total_inserted = 0;
-
- ret_if(!index);
- ret_if(!list);
-
- index_info = evas_object_data_get(index, DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
-
- /* 0. Remove an old page_index_list */
- if (index_info->page_index_list) {
- EINA_LIST_FREE(index_info->page_index_list, page_index) {
- free(page_index);
- }
- index_info->page_index_list = NULL;
- }
-
- /* 1. Make indexes (cur/center/other) */
- total_count = scroller_count(scroller);
- total_inserted = scroller_count_direction(scroller, PAGE_DIRECTION_RIGHT);
-
- if (total_inserted > MAX_INDEX_NUMBER) {
- total_inserted = MAX_INDEX_NUMBER;
- }
-
- int style_even = 0;
- int style_base = 0;
- if (!(total_inserted % 2)) {
- style_even = 1;
- style_base = 10 - (total_inserted / 2);
- } else {
- style_base = 9 - (total_inserted / 2);
- }
-
- _D("total_inserted:%d style_base:%d", total_inserted, style_base);
-
-
- EINA_LIST_FOREACH(list, l, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (index_number < total_inserted) {
- if (!cur_inserted) {
- cur_start_idx = index_number;
- }
-
- cur_inserted++;
- idx_it = elm_index_item_append(index, NULL, NULL, (void *) index_number);
-
- _D("Index style: %s", _index_style_get(style_base + index_number, style_even));
- elm_object_item_style_set(idx_it, _index_style_get(style_base + index_number, style_even));
-
- index_number++;
- }
- cur_count++;
- _D("page:%p, total_inserted:%d, idx_it:%p", page, total_inserted, idx_it);
- }
-
- cur_mid_idx = (cur_start_idx * 2 + cur_inserted - 1) / 2;
- extra_idx = total_count - other_count - center_count - cur_inserted;
-
- /* 2. Make a new page_index_list */
- page_index_inserting = -1;
- EINA_LIST_FOREACH(list, l, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- page_index = calloc(1, sizeof(page_index_s));
- continue_if(!page_index);
-
- if (before_direction == page_info->direction) {
- if (index_info->direction == page_info->direction) {
- if (page_index_inserting == cur_mid_idx && extra_idx > 0) {
- extra_idx--;
- } else {
- page_index_inserting++;
- }
- }
- } else {
- before_direction = page_info->direction;
- page_index_inserting++;
- }
-
- page_index->page = page;
- page_index->index = page_index_inserting;
-
- _D("Index(%p-%d) is updating, page(%p-%d:%d)(start:%d, mid:%d, extra:%d)"
- , index, index_info->direction
- , page, page_info->direction, page_index_inserting
- , 0, cur_mid_idx, extra_idx);
-
- index_info->page_index_list = eina_list_append(index_info->page_index_list, page_index);
- }
-}
-
-
-
-HAPI void multi_index_update(Evas_Object *scroller)
-{
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- struct index_st *index = NULL;
- int i;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- for (i = 0; i < PAGE_DIRECTION_ANY; i++)
- {
- index = scroller_info->index[i];
- if (PAGE_DIRECTION_LEFT == index->index_info->direction) {
- _update_left(scroller, index, list);
- } else if (PAGE_DIRECTION_RIGHT == index->index_info->direction) {
- _update_right(scroller, index, list);
- } else {
- _update_center(scroller, index, list);
- }
- }
-
- eina_list_free(list);
-}
-
-HAPI void index_update(Evas_Object *index, Evas_Object *scroller, index_bring_in_e after)
-{
- Evas_Object *page_current = NULL;
- Eina_List *list = NULL;
-
- scroller_info_s *scroller_info = NULL;
- index_info_s *index_info = NULL;
-
- ret_if(!index);
- ret_if(!scroller);
-
- _D("Index(%p) is clear", index);
- elm_index_item_clear(index);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- index_info = evas_object_data_get(index, DATA_KEY_INDEX_INFO);
- ret_if(!index_info);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- _update_single_index(scroller, index, list);
-
- eina_list_free(list);
-
- elm_index_level_go(index, 0);
-
- if (INDEX_BRING_IN_AFTER == after) {
- page_current = scroller_get_focused_page(scroller);
- ret_if(!page_current);
- index_bring_in_page(index, page_current);
- }
-}
-
-
- // End of file
diff --git a/src/item_info.c b/src/item_info.c
deleted file mode 100755
index 24c9224..0000000
--- a/src/item_info.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Evas.h>
-#include <stdlib.h>
-#include <bundle.h>
-#include <dlog.h>
-
-#include "log.h"
-#include "util.h"
-#include "item_info.h"
-
-HAPI item_info_s *item_info_create(const char *id, const char *subid)
-{
- item_info_s *item_info = NULL;
-
- item_info = calloc(1, sizeof(item_info_s));
- retv_if(!item_info, NULL);
-
- if (id) {
- item_info->id = strdup(id);
- if (!item_info->id) {
- free(item_info);
- return NULL;
- }
- }
-
- if (subid) {
- item_info->subid = strdup(subid);
- if (!item_info->subid) {
- free(item_info->id);
- free(item_info);
- return NULL;
- }
- }
-
- if (id && item_info_is_removable(id)) {
- item_info->removable = 1;
- }
-
- return item_info;
-}
-
-
-
-HAPI void item_info_destroy(item_info_s *item_info)
-{
- ret_if(!item_info);
-
- free(item_info->id);
- free(item_info->subid);
- free(item_info);
-}
-
-
-
-HAPI void item_info_list_destroy(Eina_List *item_info_list)
-{
- item_info_s *item_info = NULL;
-
- ret_if(!item_info_list);
-
- EINA_LIST_FREE(item_info_list, item_info) {
- continue_if(!item_info);
- item_info_destroy(item_info);
- }
-}
-
-
-
-#define APPID_APPS_WIDGET "org.tizen.apps-widget"
-HAPI int item_info_is_removable(const char *id)
-{
- retv_if(!id, 1);
- return strcmp(id, APPID_APPS_WIDGET);
-}
-
-
-
-// End of a file
diff --git a/src/key.c b/src/key.c
deleted file mode 100755
index 42527eb..0000000
--- a/src/key.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Ecore.h>
-#include <Elementary.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <dlog.h>
-#include <bundle.h>
-#include <efl_extension.h>
-#include "layout_info.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "key.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-
-
-
-#define CB_LIST_MAX 7
-static struct {
- Eina_Bool pressed;
- Ecore_Event_Handler *press_handler;
- Ecore_Event_Handler *release_handler;
-
- Eina_Bool register_handler;
- Ecore_Timer *long_press;
- Eina_Bool home_grabbed;
- Eina_List *cbs_list[CB_LIST_MAX];
-} key_info = {
- .pressed = 0,
- .press_handler = NULL,
- .release_handler = NULL,
-
- .register_handler = EINA_FALSE,
- .long_press = NULL,
- .home_grabbed = EINA_FALSE,
- .cbs_list = {NULL, },
-};
-
-
-
-typedef struct {
- key_cb_ret_e (*result_cb)(void *);
- void *result_data;
-} key_cb_s;
-
-
-
-HAPI w_home_error_e key_register_cb(
- int type,
- key_cb_ret_e (*result_cb)(void *), void *result_data)
-{
- retv_if(NULL == result_cb, W_HOME_ERROR_INVALID_PARAMETER);
-
- key_cb_s *cb = calloc(1, sizeof(key_cb_s));
- retv_if(NULL == cb, W_HOME_ERROR_FAIL);
-
- cb->result_cb = result_cb;
- cb->result_data = result_data;
-
- key_info.cbs_list[type] = eina_list_prepend(key_info.cbs_list[type], cb);
- retv_if(NULL == key_info.cbs_list[type], W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void key_unregister_cb(
- int type,
- key_cb_ret_e (*result_cb)(void *))
-{
-
- const Eina_List *l;
- const Eina_List *n;
- key_cb_s *cb;
- EINA_LIST_FOREACH_SAFE(key_info.cbs_list[type], l, n, cb) {
- continue_if(NULL == cb);
- if (result_cb != cb->result_cb) continue;
- key_info.cbs_list[type] = eina_list_remove(key_info.cbs_list[type], cb);
- free(cb);
- return;
- }
-}
-
-
-
-static void _execute_cbs(int type)
-{
- const Eina_List *l;
- const Eina_List *n;
- key_cb_s *cb;
- EINA_LIST_FOREACH_SAFE(key_info.cbs_list[type], l, n, cb) {
- continue_if(NULL == cb);
- continue_if(NULL == cb->result_cb);
- if (KEY_CB_RET_STOP == cb->result_cb(cb->result_data)) {
- _W("back key execution has been stopped");
- break;
- }
- }
-}
-
-
-
-#define HOME_KEY_ESC "XF86PowerOff"
-static Eina_Bool _key_release_cb(void *data, int type, void *event)
-{
- Evas_Event_Key_Up *ev = event;
-
- retv_if(EINA_FALSE == key_info.register_handler, ECORE_CALLBACK_PASS_ON);
- retv_if(NULL == ev, ECORE_CALLBACK_PASS_ON);
-
- _D("Key(%s) released %d", ev->keyname, key_info.pressed);
-
- if (key_info.pressed == EINA_FALSE) {
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if (!strcmp(ev->keyname, "XF86Back")) {
- _execute_cbs(KEY_TYPE_BACK);
- } else if (!strcmp(ev->keyname, "XF86Menu")) {
- _execute_cbs(KEY_TYPE_BEZEL_UP);
- } else if (!strcmp(ev->keyname, "XF86PowerOff")) {
- _execute_cbs(KEY_TYPE_ROTARY);
- }
-
- key_info.pressed = EINA_FALSE;
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-
-
-static Eina_Bool _key_press_cb(void *data, int type, void *event)
-{
- Evas_Event_Key_Down *ev = event;
-
- retv_if(EINA_FALSE == key_info.register_handler, ECORE_CALLBACK_PASS_ON);
- retv_if(NULL == ev, ECORE_CALLBACK_PASS_ON);
-
- key_info.pressed = EINA_TRUE;
- _D("Key pressed %d", key_info.pressed);
-
- retv_if(APP_STATE_PAUSE == main_get_info()->state, ECORE_CALLBACK_PASS_ON);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-
-
-HAPI void key_register(void)
-{
- if (!key_info.release_handler) {
- key_info.release_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL);
- if (!key_info.release_handler) {
- _E("Failed to register a key up event handler");
- }
- }
-
- if (!key_info.press_handler) {
- key_info.press_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL);
- if (!key_info.press_handler) {
- _E("Failed to register a key down event handler");
- }
- }
-
- if (elm_win_keygrab_set(main_get_info()->win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_TOPMOST) != 0) {
- _E("Failed to grab KEY_MENU");
- }
-
- key_info.pressed = EINA_FALSE;
- key_info.register_handler = EINA_TRUE;
-}
-
-
-
-HAPI void key_unregister(void)
-{
- if (key_info.long_press) {
- ecore_timer_del(key_info.long_press);
- key_info.long_press = NULL;
- }
-
- if (key_info.release_handler) {
- ecore_event_handler_del(key_info.release_handler);
- key_info.release_handler = NULL;
- }
-
- if (key_info.press_handler) {
- ecore_event_handler_del(key_info.press_handler);
- key_info.press_handler = NULL;
- }
-
- if (elm_win_keygrab_unset(main_get_info()->win, "XF86Menu", 0, 0) != 0) {
- _E("Failed to ungrab KEY_MENU");
- }
-
- key_info.register_handler = EINA_FALSE;
-}
-
-
-
-HAPI void key_cb_execute(int type)
-{
- _execute_cbs(type);
-}
-
-// End of a file
diff --git a/src/lang.c b/src/lang.c
deleted file mode 100755
index 52066c2..0000000
--- a/src/lang.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <bundle.h>
-#include <dlog.h>
-
-#include "log.h"
-#include "util.h"
-
-static Eina_List *lang_list;
-static Eina_List *cbs_list;
-
-typedef struct {
- Evas_Object *obj;
- const char *group;
- const char *id;
- int domain;
-} lang_element;
-
-typedef struct {
- w_home_error_e (*result_cb)(void *);
- void *result_data;
-} lang_cb_s;
-
-
-
-HAPI w_home_error_e lang_add_id(Evas_Object *obj, const char *group, const char *id, int domain)
-{
- lang_element *le;
-
- retv_if(NULL == obj, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == group, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == id, W_HOME_ERROR_INVALID_PARAMETER);
-
- le = malloc(sizeof(lang_element));
- retv_if(NULL == le, W_HOME_ERROR_FAIL);
-
- le->obj = obj;
- le->group = group;
- le->id = id;
- le->domain = domain;
-
- lang_list = eina_list_append(lang_list, le);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void lang_remove_id(Evas_Object *obj, const char *group)
-{
- const Eina_List *l;
- const Eina_List *n;
- lang_element *le;
-
- ret_if(NULL == obj);
- ret_if(NULL == group);
-
- EINA_LIST_FOREACH_SAFE(lang_list, l, n, le) {
- if (le->obj == obj && !strcmp(group, le->group)) {
- lang_list = eina_list_remove(lang_list, le);
- free(le);
- return;
- }
- }
-}
-
-
-
-HAPI w_home_error_e lang_register_cb(w_home_error_e (*result_cb)(void *), void *result_data)
-{
- retv_if(NULL == result_cb, W_HOME_ERROR_INVALID_PARAMETER);
-
- lang_cb_s *cb = calloc(1, sizeof(lang_cb_s));
- retv_if(NULL == cb, W_HOME_ERROR_FAIL);
-
- cb->result_cb = result_cb;
- cb->result_data = result_data;
-
- cbs_list = eina_list_append(cbs_list, cb);
- retv_if(NULL == cbs_list, W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void lang_unregister_cb(w_home_error_e (*result_cb)(void *))
-{
- const Eina_List *l;
- const Eina_List *n;
- lang_cb_s *cb;
- EINA_LIST_FOREACH_SAFE(cbs_list, l, n, cb) {
- continue_if(NULL == cb);
- if (result_cb != cb->result_cb) continue;
- cbs_list = eina_list_remove(cbs_list, cb);
- free(cb);
- return;
- }
-}
-
-
-
-HAPI void lang_refresh_ids(void)
-{
- const Eina_List *l;
- const Eina_List *n;
- lang_element *le;
- char *temp;
-
- EINA_LIST_FOREACH_SAFE(lang_list, l, n, le) {
- if (le->domain) {
- temp = dgettext("sys_string", le->id);
- } else {
- temp = _(le->id);
- }
-
- elm_object_part_text_set(le->obj, le->group, temp);
- }
-
- lang_cb_s *cb;
- EINA_LIST_FOREACH_SAFE(cbs_list, l, n, cb) {
- continue_if(NULL == cb);
- continue_if(NULL == cb->result_cb);
-
- if (W_HOME_ERROR_NONE != cb->result_cb(cb->result_data)) _E("There are some problems");
- }
-}
-
-// End of a file
diff --git a/src/layout.c b/src/layout.c
deleted file mode 100755
index f929674..0000000
--- a/src/layout.c
+++ /dev/null
@@ -1,1048 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <Evas.h>
-#include <stdbool.h>
-#include <bundle.h>
-#include <dlog.h>
-#include <widget_viewer_evas.h>
-#include <aul.h>
-
-#include "util.h"
-#include "conf.h"
-#include "log.h"
-#include "main.h"
-#include "db.h"
-#include "edit.h"
-#include "edit_info.h"
-#include "effect.h"
-#include "key.h"
-#include "layout.h"
-#include "layout_info.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "index.h"
-#include "util.h"
-#include "xml.h"
-#include "power_mode.h"
-#include "apps/apps.h"
-#include "gesture.h"
-#include "notification/notification.h"
-
-#define PRIVATE_DATA_KEY_LAYOUT_DOWN_X "p_l_x"
-#define PRIVATE_DATA_KEY_LAYOUT_DOWN_Y "p_l_y"
-#define PRIVATE_DATA_KEY_LAYOUT_PRESSED "p_l_ps"
-#define PRIVATE_DATA_KEY_LAYOUT_TIMER "p_l_t"
-#define PRIVATE_DATA_KEY_CHECKER_TYPE "ck_tp"
-#define PRIVATE_DATA_KEY_DOWN_X "dw_x"
-#define PRIVATE_DATA_KEY_DOWN_Y "dw_y"
-#define PRIVATE_DATA_KEY_LAYOUT_G_DOWN_Y "gdw_y"
-#define PRIVATE_DATA_KEY_LAYOUT_G_FKICKUP_DONE "gdw_f_d"
-#define PRIVATE_DATA_KEY_LEFT_CHECKER "top_ck"
-#define PRIVATE_DATA_KEY_RIGHT_CHECKER "bt_ck"
-#define PRIVATE_DATA_KEY_READY_TO_BEZEL_DOWN "pd_rt_bd"
-#define PRIVATE_DATA_KEY_CENTER_LONG_PRESSED "pd_c_l_p"
-#define PRIVATE_DATA_KEY_SHOW_INDEX_TIMER "pd_s_i_t"
-
-#define MOVE_LEFT -1
-#define MOVE_RIGHT 1
-
-#define THRESHOLD_BEZEL_UP_H 60
-#define THRESHOLD_BEZEL_DOWN_X_DIST 20
-#define THRESHOLD_BEZEL_UP_END_D_H 25
-#define THRESHOLD_BEZEL_UP_MOVE_D_H 25
-#define THRESHOLD_MOMENTUM_FLICK_Y 450
-#define LONGPRESS_GRAY_ZONE_W 50
-#define LONGPRESS_GRAY_ZONE_H 100
-
-static w_home_error_e _pause_result_cb(void *data)
-{
- Evas_Object *layout = data;
- Evas_Object *page = NULL;
- layout_info_s *layout_info = NULL;
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, W_HOME_ERROR_FAIL);
-
- page = scroller_get_focused_page(layout_info->scroller);
- retv_if(!page, W_HOME_ERROR_FAIL);
- page_focus(page);
-
- /* If TTS is on, use focus */
- if (main_get_info()->is_tts) {
- elm_object_tree_focus_allow_set(layout, EINA_FALSE);
- _D("tree_focus_allow_set layout(%p) as FALSE", layout);
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _resume_result_cb(void *data)
-{
- Evas_Object *layout = data;
- layout_info_s *layout_info = NULL;
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, W_HOME_ERROR_FAIL);
-
- if (layout_info->tutorial) {
- /* If TTS is on, use focus */
- if (main_get_info()->is_tts) {
- elm_object_tree_focus_allow_set(layout, EINA_FALSE);
- _D("tree_focus_allow_set layout(%p) as FALSE", layout);
- }
- } else {
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
-
- layout = evas_object_data_get(main_get_info()->win, DATA_KEY_LAYOUT);
- if (!layout) {
- return W_HOME_ERROR_FAIL;
- }
-
- /* If TTS is on, use focus */
- if (main_get_info()->is_tts) {
- elm_object_tree_focus_allow_set(layout, EINA_TRUE);
- _D("tree_focus_allow_set layout(%p) as TRUE", layout);
- }
-
- scroller = evas_object_data_get(layout, DATA_KEY_SCROLLER);
- if (!scroller) {
- return W_HOME_ERROR_FAIL;
- }
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _reset_result_cb(void *data)
-{
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static Eina_Bool _longpress_timer_cb(void *data)
-{
- int no_effect = 0;
- Evas_Object *layout = data;
- Evas_Object *proxy_page = NULL;
- Evas_Object *effect_page = NULL;
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- edit_info_s *edit_info = NULL;
-
- retv_if(!layout, ECORE_CALLBACK_CANCEL);
- evas_object_data_del(layout, PRIVATE_DATA_KEY_LAYOUT_TIMER);
-
- _D("Enter the edit mode");
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, ECORE_CALLBACK_CANCEL);
- retv_if(!layout_info->pressed_page, ECORE_CALLBACK_CANCEL);
-
- scroller_remove_index_hide_timer(layout_info->scroller);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- page_info = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, ECORE_CALLBACK_CANCEL);
-
- widget_viewer_evas_cancel_click_event(layout_info->pressed_item);
- if (!page_info->layout_longpress) {
- _D("long-press is not supported on this page");
- return ECORE_CALLBACK_CANCEL;
- }
-
- switch (page_info->direction) {
- case PAGE_DIRECTION_LEFT:
- _D("There is already a pressed item");
- evas_object_data_set(layout_info->pressed_page, DATA_KEY_PAGE_ONHOLD_COUNT, (void*)1);
- retv_if(!edit_create_layout(layout, EDIT_MODE_LEFT), ECORE_CALLBACK_CANCEL);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, ECORE_CALLBACK_CANCEL);
-
- proxy_page = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PROXY_PAGE);
- retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
- effect_page = edit_create_minify_effect_page(proxy_page);
- retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
-
- scroller_region_show_center_of(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, NULL, NULL, edit_minify_effect_page, effect_page);
- break;
- case PAGE_DIRECTION_CENTER:
- if (util_feature_enabled_get(FEATURE_CLOCK_SELECTOR) == 1) {
- } else {
- no_effect = 1;
- }
- break;
- case PAGE_DIRECTION_RIGHT:
- if (main_get_info()->is_tts) return ECORE_CALLBACK_CANCEL;
- if (layout_info->pressed_item) {
- _D("There is already a pressed item");
- widget_viewer_evas_feed_mouse_up_event(layout_info->pressed_item);
- }
- retv_if(!edit_create_layout(layout, EDIT_MODE_RIGHT), ECORE_CALLBACK_CANCEL);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- retv_if(!edit_info, ECORE_CALLBACK_CANCEL);
-
- proxy_page = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PROXY_PAGE);
- retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
- effect_page = edit_create_minify_effect_page(proxy_page);
- retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
-
- scroller_region_show_center_of(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, NULL, NULL, edit_minify_effect_page, effect_page);
-
- if (layout_info->pressed_page == scroller_info->plus_page) {
- evas_object_data_set(layout_info->pressed_item, DATA_KEY_IS_LONGPRESS, (void *)1);
- }
- break;
- default:
- _D("Cannot reach here");
- break;
- }
-
- if (no_effect == 0) {
- effect_play_vibration();
- }
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static void _down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Down *ei = event_info;
- Evas_Object *layout = obj;
- Ecore_Timer *timer = NULL;
-
- int is_gray_zone = 0;
- int x = ei->output.x;
- int y = ei->output.y;
-
- _D("Mouse is down on the layout");
-
- timer = evas_object_data_del(layout, PRIVATE_DATA_KEY_LAYOUT_TIMER);
- if (timer) ecore_timer_del(timer);
-
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_PRESSED, (void *) 1);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_DOWN_X, (void *) x);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_DOWN_Y, (void *) y);
-
- double longpress_time = LONGPRESS_TIME;
- layout_info_s *layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- if (layout_info != NULL) {
- Evas_Object *page = scroller_get_focused_page(layout_info->scroller);
- if (page != NULL) {
- page_info_s *page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (page_info != NULL) {
- if (page_info->direction == PAGE_DIRECTION_CENTER) {
- longpress_time = 0.4f;
- }
- }
- }
- }
-
- if ((x <= LONGPRESS_GRAY_ZONE_W) || (x >= (main_get_info()->root_w - LONGPRESS_GRAY_ZONE_W))) {
- is_gray_zone = 1;
- }
- if ((y <= LONGPRESS_GRAY_ZONE_H) || (y >= (main_get_info()->root_h - LONGPRESS_GRAY_ZONE_H))) {
- is_gray_zone = 1;
- }
- if (is_gray_zone == 1) {
- _W("we don't add a longpress timer, it's too close to home key");
- return;
- }
-
- timer = ecore_timer_add(longpress_time, _longpress_timer_cb, layout);
- if (timer) evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_TIMER, timer);
- else _E("Cannot add a timer");
-}
-
-
-
-static void _move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Move *ei = event_info;
- Evas_Object *layout = obj;
- Ecore_Timer *timer = NULL;
-
- int down_x, down_y, vec_x, vec_y;
- int cur_x = ei->cur.output.x;
- int cur_y = ei->cur.output.y;
-
- if (!evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_PRESSED)) return;
-
- down_x = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_DOWN_X);
- down_y = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_DOWN_Y);
-
- vec_x = cur_x - down_x;
- vec_y = cur_y - down_y;
-
- timer = evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_TIMER);
- if (timer && (abs(vec_x) >= LONGPRESS_THRESHOLD || abs(vec_y) >= LONGPRESS_THRESHOLD)) {
- evas_object_data_del(layout, PRIVATE_DATA_KEY_LAYOUT_TIMER);
- ecore_timer_del(timer);
- }
-}
-
-
-
-static void _up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout = obj;
- Ecore_Timer *timer = NULL;
- layout_info_s *layout_info = NULL;
-
- _D("Mouse is up on the layout");
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- timer = evas_object_data_del(layout, PRIVATE_DATA_KEY_LAYOUT_TIMER);
- if (timer) ecore_timer_del(timer);
-
- if (evas_object_data_del(layout, PRIVATE_DATA_KEY_CENTER_LONG_PRESSED) != NULL) {
- if (layout_info->scroller) {
- scroller_unfreeze(layout_info->scroller);
- scroller_bring_in_by_push_type(layout_info->scroller, SCROLLER_PUSH_TYPE_CENTER, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
- }
- }
-}
-
-
-
-#if 0
-static void _bezel_up_cb(void *data)
-{
- Evas_Object *layout = data;
- Evas_Object *scroller = NULL;
- Evas_Object *focused_page = NULL;
-
- _D("Bezel up cb");
-
- ret_if(!layout);
-
- scroller = evas_object_data_get(layout, DATA_KEY_SCROLLER);
- ret_if(!scroller);
-
- if (PAGE_DIRECTION_CENTER != scroller_get_current_page_direction(scroller)) {
- return;
- }
-
- if (util_feature_enabled_get(FEATURE_APPS) == 0) {
- elm_object_signal_emit(layout, "bottom,show", "layout");
- return;
- }
-
- if (util_feature_enabled_get(FEATURE_APPS_BY_BEZEL_UP) == 0) {
- return;
- }
-
- if (scroller_is_scrolling(scroller)) {
- return;
- }
-
- if (layout_is_edit_mode(layout)) {
- return;
- }
-
- focused_page = scroller_get_focused_page(scroller);
- if (focused_page != NULL) {
- evas_object_data_set(focused_page, DATA_KEY_PAGE_ONHOLD_COUNT, (void*)1);
- }
-
- apps_main_show_count_add();
- apps_main_launch(APPS_LAUNCH_SHOW);
-}
-
-static void _bezel_down_cb(void *data)
-{
- Evas_Object *layout = data;
- Evas_Object *focused_page = NULL;
- page_info_s *focused_page_info = NULL;
- layout_info_s *layout_info = NULL;
- int pid = 0;
- bundle *b = NULL;
-
- _D("Bezel down cb");
-
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- focused_page = scroller_get_focused_page(layout_info->scroller);
- ret_if(!focused_page);
-
- focused_page_info = evas_object_data_get(focused_page, DATA_KEY_PAGE_INFO);
- ret_if(!focused_page_info);
-
- if (focused_page_info->direction == PAGE_DIRECTION_CENTER) {
- _D("This page is clock!! show MOMENT BAR");
- pid = aul_launch_app("org.tizen.windicator", b);
- _D("aul_launch_app: %s(%d)", "org.tizen.windicator", pid);
- }
-}
-#endif
-
-
-
-HAPI void layout_add_mouse_cb(Evas_Object *layout)
-{
- evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_DOWN, _down_cb, NULL);
- evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_MOVE, _move_cb, NULL);
- evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_UP, _up_cb, NULL);
-}
-
-
-
-HAPI void layout_del_mouse_cb(Evas_Object *layout)
-{
- evas_object_event_callback_del(layout, EVAS_CALLBACK_MOUSE_DOWN, _down_cb);
- evas_object_event_callback_del(layout, EVAS_CALLBACK_MOUSE_MOVE, _move_cb);
- evas_object_event_callback_del(layout, EVAS_CALLBACK_MOUSE_UP, _up_cb);
-}
-
-
-
-Evas_Object *_get_proxy_page(Evas_Object *scroller)
-{
- Evas_Object *obj = NULL;
- Evas_Object *cur_page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int x, w;
- int half_line, whole_line, pad;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- pad = (scroller_info->root_width - scroller_info->page_width) / 2;
- half_line = scroller_info->root_width / 2;
- whole_line = scroller_info->root_width;
-
- list = elm_box_children_get(scroller_info->box);
- if (!list) return NULL;
-
- EINA_LIST_FREE(list, obj) {
- continue_if(!obj);
- if (cur_page) continue;
-
- page_info = evas_object_data_get(obj, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (!page_info->appended) {
- _D("Page(%p) is not appended yet", obj);
- continue;
- }
-
- evas_object_geometry_get(obj, &x, NULL, &w, NULL);
- if (!w) continue;
- if (x + w > half_line && x <= whole_line - pad) {
- cur_page = obj;
- } else if (x <= half_line && x >= pad) {
- cur_page = obj;
- }
- }
-
- return cur_page;
-}
-
-
-
-static Eina_Bool _move_timer_cb(void *data)
-{
- Evas_Object *scroller = data;
- Evas_Object *cur_page = NULL;
- Evas_Object *move_page = NULL;
- scroller_info_s *scroller_info = NULL;
- int checker_type = 0;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
- checker_type = (int)evas_object_data_get(scroller, PRIVATE_DATA_KEY_CHECKER_TYPE);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- cur_page = scroller_get_picked_up_page(scroller);
- if (MOVE_LEFT == checker_type) {
- move_page = scroller_get_left_page(scroller, cur_page);
- if (move_page && scroller_info->center != move_page) {
- elm_object_signal_emit(scroller_info->layout, "left,show", "layout");
- edit_push_page_before(scroller, cur_page, move_page);
- }
- } else {
- move_page = scroller_get_right_page(scroller, cur_page);
- if (move_page && scroller_info->plus_page != move_page) {
- elm_object_signal_emit(scroller_info->layout, "right,show", "layout");
- edit_push_page_after(scroller, cur_page, move_page);
- }
- }
-
- return ECORE_CALLBACK_RENEW;
-}
-
-
-
-#define TIME_MOVE_SCROLLER 0.7f
-static void _upper_start_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout = data;
- Evas_Object *checker = obj;
- Ecore_Timer *timer = NULL;
-
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
- int checker_type = 0;
-
- _D("Upper start for the checker");
-
- ret_if(!layout);
- ret_if(!checker);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- checker_type = (int) evas_object_data_get(checker, PRIVATE_DATA_KEY_CHECKER_TYPE);
- evas_object_data_set(edit_info->scroller, PRIVATE_DATA_KEY_CHECKER_TYPE, (void *)checker_type);
-
- timer = evas_object_data_del(edit_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
- if (timer) ecore_timer_del(timer);
-
- timer = ecore_timer_add(TIME_MOVE_SCROLLER, _move_timer_cb, edit_info->scroller);
- if (timer) evas_object_data_set(edit_info->scroller, DATA_KEY_EVENT_UPPER_TIMER, timer);
- else _E("Cannot add a timer");
-}
-
-
-
-static void _upper_end_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout = data;
- Evas_Object *checker = obj;
- Ecore_Timer *timer = NULL;
-
- layout_info_s *layout_info = NULL;
- edit_info_s *edit_info = NULL;
-
- _D("Upper end for the checker");
-
- ret_if(!checker);
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
- ret_if(!edit_info);
-
- timer = evas_object_data_del(edit_info->scroller, DATA_KEY_EVENT_UPPER_TIMER);
- if (timer) ecore_timer_del(timer);
- evas_object_data_del(edit_info->scroller, PRIVATE_DATA_KEY_CHECKER_TYPE);
-}
-
-
-
-static Evas_Event_Flags _flick_start_cb(void *data, void *event_info)
-{
- Evas_Object *layout = data;
- Elm_Gesture_Line_Info *ei = (Elm_Gesture_Line_Info *)event_info;
- retv_if(!layout, EVAS_EVENT_FLAG_NONE);
- retv_if(!ei, EVAS_EVENT_FLAG_NONE);
-
- if (ei->momentum.y1 <= THRESHOLD_BEZEL_UP_H) {
- evas_object_data_set(layout, PRIVATE_DATA_KEY_READY_TO_BEZEL_DOWN, (void *) 1);
- }
-
- return EVAS_EVENT_FLAG_NONE;
-}
-
-
-
-static Evas_Event_Flags _flick_move_cb(void *data, void *event_info)
-{
- int gesture_down_y = 0;
- Evas_Object *layout = data;
- Elm_Gesture_Line_Info *ei = (Elm_Gesture_Line_Info *)event_info;
- retv_if(!layout, EVAS_EVENT_FLAG_NONE);
- retv_if(!ei, EVAS_EVENT_FLAG_NONE);
-
- int is_flickup_done = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_G_FKICKUP_DONE);
- gesture_down_y = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_G_DOWN_Y);
- int vector_y = ei->momentum.y2 - ei->momentum.y1;
- int distance_x = abs( ei->momentum.x1 - ei->momentum.x2);
- int distance_y = abs(vector_y);
-
- if (vector_y < 0 &&
- (ei->momentum.my <= -THRESHOLD_MOMENTUM_FLICK_Y || distance_y >= THRESHOLD_BEZEL_UP_MOVE_D_H) &&
- distance_x < distance_y) {
- if (is_flickup_done == 0) {
- if (gesture_down_y >= (main_get_info()->root_h - THRESHOLD_BEZEL_UP_H)) {
- gesture_execute_cbs(BEZEL_UP);
- }
- evas_object_smart_callback_call(layout, LAYOUT_SMART_SIGNAL_FLICK_UP, layout);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_G_FKICKUP_DONE, (void *) 1);
- }
- }
-
- return EVAS_EVENT_FLAG_NONE;
-}
-
-
-
-static void _gesture_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Down *ei = event_info;
- Evas_Object *layout = obj;
-
- int y = ei->output.y;
-
- _D("Mouse is down on the gesture layer:%d", y);
-
- evas_object_data_del(layout, PRIVATE_DATA_KEY_LAYOUT_G_FKICKUP_DONE);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_G_DOWN_Y, (void *) y);
-
-}
-
-
-
-static Evas_Event_Flags _flick_end_cb(void *data, void *event_info)
-{
- int gesture_down_y = 0;
- Evas_Object *layout = data;
- Elm_Gesture_Line_Info *ei = (Elm_Gesture_Line_Info *)event_info;
- retv_if(!layout, EVAS_EVENT_FLAG_NONE);
- retv_if(!ei, EVAS_EVENT_FLAG_NONE);
-
- int is_flickup_done = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_G_FKICKUP_DONE);
- gesture_down_y = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_G_DOWN_Y);
- int vector_y = ei->momentum.y2 - ei->momentum.y1;
- int distance_x = abs( ei->momentum.x1 - ei->momentum.x2);
- int distance_y = abs(vector_y);
-
- if (evas_object_data_del(layout, PRIVATE_DATA_KEY_READY_TO_BEZEL_DOWN)
- && (distance_x <= THRESHOLD_BEZEL_DOWN_X_DIST)) {
- gesture_execute_cbs(BEZEL_DOWN);
- }
-
- if (vector_y < 0 &&
- distance_y >= THRESHOLD_BEZEL_UP_END_D_H && //cannot use momentum
- distance_x < distance_y) {
- if (is_flickup_done == 0) {
- if (gesture_down_y >= (main_get_info()->root_h - THRESHOLD_BEZEL_UP_H)) {
- gesture_execute_cbs(BEZEL_UP);
- }
- evas_object_smart_callback_call(layout, LAYOUT_SMART_SIGNAL_FLICK_UP, layout);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LAYOUT_G_FKICKUP_DONE, (void *) 1);
- }
- }
-
- return EVAS_EVENT_FLAG_NONE;
-}
-
-
-
-static void _attach_gesture_layer(Evas_Object *layout)
-{
- Evas_Object *gesture_layer = NULL;
- ret_if(!layout);
-
- gesture_layer = elm_gesture_layer_add(layout);
- ret_if(!gesture_layer);
-
- evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_DOWN, _gesture_down_cb, NULL);
-
- elm_gesture_layer_attach(gesture_layer, layout);
- elm_gesture_layer_cb_set(gesture_layer, ELM_GESTURE_N_FLICKS, ELM_GESTURE_STATE_START, _flick_start_cb, layout);
- elm_gesture_layer_cb_set(gesture_layer, ELM_GESTURE_N_FLICKS, ELM_GESTURE_STATE_END, _flick_end_cb, layout);
- elm_gesture_layer_cb_set(gesture_layer, ELM_GESTURE_N_FLICKS, ELM_GESTURE_STATE_MOVE, _flick_move_cb, layout);
-}
-
-
-
-static Evas_Object *_create_checker(Evas_Object *layout, int type)
-{
- Evas_Object *checker;
-
- retv_if(!layout, NULL);
-
- checker = elm_button_add(layout);
- evas_object_size_hint_weight_set(checker, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(checker, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_color_set(checker, 0, 0, 0, 0);
- if (MOVE_LEFT == type) {
- elm_object_part_content_set(layout, "left_checker", checker);
- evas_object_data_set(checker, PRIVATE_DATA_KEY_CHECKER_TYPE, (void *)MOVE_LEFT);
- } else if (MOVE_RIGHT == type) {
- elm_object_part_content_set(layout, "right_checker", checker);
- evas_object_data_set(checker, PRIVATE_DATA_KEY_CHECKER_TYPE, (void *)MOVE_RIGHT);
- }
- evas_object_data_set(checker, DATA_KEY_EVENT_UPPER_IS_ON, (void *) 1);
-
- evas_object_smart_callback_add(checker, "upper_start", _upper_start_cb, layout);
- evas_object_smart_callback_add(checker, "upper_end", _upper_end_cb, layout);
- evas_object_show(checker);
-
- return checker;
-}
-
-
-
-static void _destroy_checker(Evas_Object *checker)
-{
- evas_object_data_del(checker, DATA_KEY_EVENT_UPPER_IS_ON);
- evas_object_data_del(checker, PRIVATE_DATA_KEY_CHECKER_TYPE);
- evas_object_del(checker);
-}
-
-
-
-static key_cb_ret_e _back_key_cb(void *data)
-{
- _D("Home Back Key CB");
- Evas_Object *layout = data;
- Evas_Object *scroller = NULL;
-
- retv_if(!layout, KEY_CB_RET_CONTINUE);
-
- scroller = evas_object_data_get(layout, DATA_KEY_SCROLLER);
- retv_if(!scroller, KEY_CB_RET_CONTINUE);
-
- scroller_bring_in_by_push_type(scroller, SCROLLER_PUSH_TYPE_CENTER, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
-
- return KEY_CB_RET_STOP;
-}
-
-
-
-static key_cb_ret_e _home_key_cb(void *data)
-{
- _D("Home Power Key CB");
- Evas_Object *layout = data;
- Evas_Object *scroller = NULL;
-
- retv_if(!layout, KEY_CB_RET_CONTINUE);
-
- scroller = evas_object_data_get(layout, DATA_KEY_SCROLLER);
- retv_if(!scroller, KEY_CB_RET_CONTINUE);
-
- scroller_bring_in_by_push_type(scroller, SCROLLER_PUSH_TYPE_CENTER, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
-
- return KEY_CB_RET_STOP;
-}
-
-
-
-#define FILE_LAYOUT_EDJ EDJEDIR"/layout.edj"
-#define FILE_INDICATOR_LAYOUT_EDJ EDJEDIR"/page_indicator.edj"
-#define GROUP_LAYOUT "layout"
-#define GROUP_INDICATOR_LAYOUT "indicator_layout"
-HAPI Evas_Object *layout_create(Evas_Object *win)
-{
- Evas_Object *layout = NULL;
- Evas_Object *checker = NULL;
- Evas_Object *scroller = NULL;
- Evas_Object *indicator_layout = NULL;
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
- Eina_Bool ret;
- int i;
-
- retv_if(!win, NULL);
-
- layout = elm_layout_add(win);
- retv_if(NULL == layout, NULL);
-
- layout_info = calloc(1, sizeof(layout_info_s));
- if (!layout_info) {
- _E("Cannot calloc for layout_info");
- evas_object_del(layout);
- return NULL;
- }
- evas_object_data_set(layout, DATA_KEY_LAYOUT_INFO, layout_info);
- layout_info->win = win;
-
- ret = elm_layout_file_set(layout, FILE_LAYOUT_EDJ, GROUP_LAYOUT);
- if (EINA_FALSE == ret) {
- _E("cannot set the file into the layout");
- free(layout_info);
- evas_object_del(layout);
- return NULL;
- }
-
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(layout, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_resize(layout, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_show(layout);
-
- evas_object_data_set(win, DATA_KEY_LAYOUT, layout);
- evas_object_data_set(layout, DATA_KEY_WIN, win);
-
- if (W_HOME_ERROR_NONE != main_register_cb(APP_STATE_PAUSE, _pause_result_cb, layout)) {
- _E("Cannot register the pause callback");
- }
-
- if (W_HOME_ERROR_NONE != main_register_cb(APP_STATE_RESUME, _resume_result_cb, layout)) {
- _E("Cannot register the resume callback");
- }
-
- if (W_HOME_ERROR_NONE != main_register_cb(APP_STATE_RESET, _reset_result_cb, layout)) {
- _E("Cannot register the reset callback");
- }
-
-#if 0
- if (W_HOME_ERROR_NONE != gesture_register_cb(BEZEL_UP, _bezel_up_cb, layout)) {
- _E("Cannot register the gesture callback");
- }
- if (W_HOME_ERROR_NONE != gesture_register_cb(BEZEL_DOWN, _bezel_down_cb, layout)) {
- _E("Cannot register the gesture callback");
- }
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_BEZEL_UP, _bezel_up_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
-#endif
-
- layout_add_mouse_cb(layout);
-
- checker = _create_checker(layout, MOVE_LEFT);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_LEFT_CHECKER, checker);
-
- checker = _create_checker(layout, MOVE_RIGHT);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_RIGHT_CHECKER, checker);
-
- scroller = scroller_create(layout, layout, main_get_info()->root_w, main_get_info()->root_h, SCROLLER_INDEX_PLURAL);
- if (!scroller) {
- _E("Cannot create scroller");
- free(layout_info);
- evas_object_del(layout);
- return NULL;
- }
- elm_object_part_content_set(layout, "scroller", scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- if (!scroller_info) {
- _E("Cannot create scroller");
- scroller_destroy(layout);
- free(layout_info);
- evas_object_del(layout);
- return NULL;
- }
- layout_info->scroller = scroller;
-
- /* Scroller has to unpack all page_inners on scroll */
- scroller_info->unpack_page_inners_on_scroll = 1;
- scroller_info->scroll_effect = 1;
- scroller_info->scroller_type = WIDGETS_STATE_NORMAL;
-
- /* Grid for Page Indicator */
- indicator_layout= elm_layout_add(layout);
- elm_layout_file_set(indicator_layout, FILE_INDICATOR_LAYOUT_EDJ, GROUP_INDICATOR_LAYOUT);
- evas_object_show(indicator_layout);
- elm_object_part_content_set(layout, "indicator_layout", indicator_layout);
- scroller_info->indicator_layout = indicator_layout;
-
- Evas_Object *size_setter = NULL;
- size_setter = evas_object_rectangle_add(evas_object_evas_get(indicator_layout));
- evas_object_size_hint_min_set(size_setter, main_get_info()->root_w, main_get_info()->root_h);
- evas_object_size_hint_weight_set(size_setter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(size_setter, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_color_set(size_setter, 255, 255, 255, 0);
- evas_object_resize(size_setter, main_get_info()->root_w, main_get_info()->root_h);
- elm_object_part_content_set(indicator_layout, "size_setter", size_setter);
-
- for (i = 0; i < PAGE_DIRECTION_ANY; i++) {
- scroller_info->index[i] = multi_index_create(layout, scroller, i);
- }
- layout_hide_multi_index(scroller_info->indicator_layout);
-
- _attach_gesture_layer(layout);
-
- scroller_init_rotary(scroller);
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_BACK, _back_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_HOME, _home_key_cb, layout)) {
- _E("Cannot register the key callback");
- }
-
- return layout;
-}
-
-
-
-HAPI void layout_destroy(Evas_Object *win)
-{
- Evas_Object *layout = NULL;
- Evas_Object *checker = NULL;
- Evas_Object *scroller = NULL;
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
- Eina_List *page_info_list = NULL;
-
- ret_if(win);
-
- layout = evas_object_data_del(win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- scroller = evas_object_data_del(layout, DATA_KEY_SCROLLER);
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- if (scroller_info->index[PAGE_DIRECTION_LEFT]) {
- multi_index_destroy(scroller_info->index[PAGE_DIRECTION_LEFT]);
- }
-
- if (scroller_info->index[PAGE_DIRECTION_RIGHT]) {
- multi_index_destroy(scroller_info->index[PAGE_DIRECTION_RIGHT]);
- }
-
- scroller_pop_pages(scroller, PAGE_DIRECTION_ANY);
- scroller_destroy(layout);
-
- checker = evas_object_data_del(layout, PRIVATE_DATA_KEY_LEFT_CHECKER);
- if (checker) {
- _destroy_checker(checker);
- }
-
- checker = evas_object_data_del(layout, PRIVATE_DATA_KEY_RIGHT_CHECKER);
- if (checker) {
- _destroy_checker(checker);
- }
-
- main_unregister_cb(APP_STATE_PAUSE, _pause_result_cb);
- main_unregister_cb(APP_STATE_RESUME, _resume_result_cb);
- main_unregister_cb(APP_STATE_RESET, _reset_result_cb);
-#if 0
- gesture_unregister_cb(BEZEL_UP, _bezel_up_cb);
- gesture_unregister_cb(BEZEL_DOWN, _bezel_down_cb);
- key_unregister_cb(KEY_TYPE_BEZEL_UP, _bezel_up_key_cb);
-#endif
- key_unregister_cb(KEY_TYPE_HOME, _home_key_cb);
- key_unregister_cb(KEY_TYPE_BACK, _back_key_cb);
-
- evas_object_data_del(layout, DATA_KEY_WIN);
-
- layout_info = evas_object_data_del(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- page_info_list_destroy(page_info_list);
- free(layout_info);
-
- evas_object_del(layout);
-}
-
-
-
-HAPI void layout_show_multi_index(Evas_Object *indicator_layout)
-{
- ret_if(!indicator_layout);
-
- elm_object_signal_emit(indicator_layout, "show", "page_indicator");
-}
-
-
-
-HAPI void layout_hide_multi_index(Evas_Object *indicator_layout)
-{
- ret_if(!indicator_layout);
-
- elm_object_signal_emit(indicator_layout, "hide", "page_indicator");
-}
-
-
-
-HAPI int layout_is_edit_mode(Evas_Object *layout)
-{
- layout_info_s *layout_info = NULL;
-
- retv_if(!layout, 0);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, 0);
-
- return layout_info->edit? 1 : 0;
-}
-
-
-
-HAPI void layout_set_idle(Evas_Object *layout)
-{
- layout_info_s *layout_info = NULL;
-
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- if (evas_object_data_get(layout, DATA_KEY_ADD_VIEWER) != NULL) {
- _D("destroy a addviewer");
- edit_destroy_add_viewer(layout);
- }
-
- if (layout_info->edit != NULL) {
- _D("destroy a editing layout");
- edit_destroy_layout(layout);
- }
-}
-
-
-
-HAPI int layout_is_idle(Evas_Object *layout)
-{
- layout_info_s *layout_info = NULL;
-
- retv_if(!layout, 1);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, 1);
-
- if (evas_object_data_get(layout, DATA_KEY_ADD_VIEWER) != NULL) {
- _W("Addview is exist");
- return 0;
- }
-
- if (layout_info->edit != NULL) {
- _W("editing is in progress");
- return 0;
- }
-
- return 1;
-}
-// End of file
diff --git a/src/main.c b/src/main.c
deleted file mode 100755
index a7d0762..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "home_manager.h"
-
-int main(int argc, char *argv[])
-{
- char buf[256];
- ui_app_lifecycle_callback_s lifecycle_callback = {0, };
- app_event_handler_h event_handlers[5] = {NULL, };
-
- lifecycle_callback.create = home_create_cb;
- lifecycle_callback.app_control = home_app_control_cb;
- lifecycle_callback.resume = home_resume_cb;
- lifecycle_callback.pause = home_pause_cb;
- lifecycle_callback.terminate = home_terminate_cb;
-
- ui_app_add_event_handler(&event_handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL);
- ui_app_add_event_handler(&event_handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL);
- ui_app_add_event_handler(&event_handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL);
- ui_app_add_event_handler(&event_handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, home_language_changed_cb, NULL);
- ui_app_add_event_handler(&event_handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL);
-
- int ret = ui_app_main(argc, argv, &lifecycle_callback, &main_info);
- if (ret) {
- _E("app_main() is failed. err = %d", ret);
- }
- return ret;
-}
diff --git a/src/mapbuf.c b/src/mapbuf.c
deleted file mode 100755
index 56129c7..0000000
--- a/src/mapbuf.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <stdbool.h>
-#include <dlog.h>
-#include <bundle.h>
-
-#include "conf.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "mapbuf.h"
-
-#define PRIVATE_DATA_KEY_MAPBUF_ENABLED "p_mb_en"
-
-
-HAPI Evas_Object *mapbuf_get_mapbuf(Evas_Object *obj)
-{
- Evas_Object *mapbuf;
-
- if (obj == NULL) return NULL;
-
- mapbuf = evas_object_data_get(obj, DATA_KEY_MAPBUF);
- if (!mapbuf && evas_object_data_get(obj, DATA_KEY_PAGE)) {
- mapbuf = obj;
- }
-
- return mapbuf;
-}
-
-
-
-HAPI Evas_Object *mapbuf_get_page(Evas_Object *obj)
-{
- Evas_Object *page;
-
- retv_if(NULL == obj, NULL);
-
- page = evas_object_data_get(obj, DATA_KEY_PAGE);
- if (!page && evas_object_data_get(obj, DATA_KEY_MAPBUF)) {
- page = obj;
- }
-
- return page;
-}
-
-
-
-HAPI void mapbuf_set_color(Evas_Object *obj, int a)
-{
- Evas_Object *mapbuf = mapbuf_get_mapbuf(obj);
- ret_if(NULL == mapbuf);
-
- int i;
- for (i = 0; i < 4; i ++) {
- elm_mapbuf_point_color_set(mapbuf, i, a, a, a, a);
- }
-}
-
-
-
-static void _move_pages(Evas_Object *page)
-{
- ret_if(NULL == page);
-
- Evas_Object *scroller = evas_object_data_get(page, DATA_KEY_SCROLLER);
- if (NULL == scroller) return;
-
- Evas_Coord x, y;
- evas_object_geometry_get(scroller, &x, &y, NULL, NULL);
- evas_object_move(page, x, y);
-}
-
-
-
-HAPI w_home_error_e mapbuf_enable(Evas_Object *obj, int force)
-{
- Evas_Object *mapbuf = mapbuf_get_mapbuf(obj);
- retv_if(NULL == mapbuf, W_HOME_ERROR_FAIL);
-
- Evas_Object *page = mapbuf_get_page(obj);
- retv_if(NULL == page, W_HOME_ERROR_FAIL);
-
- if (force) {
- evas_object_data_set(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED, (void*)0);
- _move_pages(page);
- elm_mapbuf_enabled_set(mapbuf, 1);
- return W_HOME_ERROR_NONE;
- }
-
- int cnt = (int)evas_object_data_get(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED);
- cnt ++;
- evas_object_data_set(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED, (void*)cnt);
-
- if (cnt == 0) {
- if (!elm_mapbuf_enabled_get(mapbuf)) {
- _move_pages(page);
- elm_mapbuf_enabled_set(mapbuf, 1);
- }
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI int mapbuf_is_enabled(Evas_Object *obj)
-{
- Evas_Object *mapbuf;
- mapbuf = mapbuf_get_mapbuf(obj);
- if (!mapbuf) {
- return 0;
- }
-
- return elm_mapbuf_enabled_get(mapbuf);
-}
-
-
-
-HAPI int mapbuf_disable(Evas_Object *obj, int force)
-{
- Evas_Object *mapbuf;
- int cnt;
-
- mapbuf = mapbuf_get_mapbuf(obj);
- if (!mapbuf) {
- _D("Failed to get the mapbuf object");
- return W_HOME_ERROR_FAIL;
- }
-
- if (force) {
- evas_object_data_set(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED, (void*)-1);
- elm_mapbuf_enabled_set(mapbuf, 0);
- return W_HOME_ERROR_NONE;
- }
-
- cnt = (int)evas_object_data_get(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED);
- if (cnt == 0) {
- if (elm_mapbuf_enabled_get(mapbuf)) {
- elm_mapbuf_enabled_set(mapbuf, 0);
- }
- }
-
- cnt --;
- evas_object_data_set(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED, (void*)cnt);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI Evas_Object *mapbuf_bind(Evas_Object *box, Evas_Object *page)
-{
- Evas_Object *mapbuf;
-
- mapbuf = elm_mapbuf_add(box);
- if (!mapbuf) {
- _E("Failed to create a new mapbuf");
- return NULL;
- }
-
- elm_mapbuf_smooth_set(mapbuf, EINA_TRUE);
- elm_mapbuf_alpha_set(mapbuf, EINA_TRUE);
- elm_object_content_set(mapbuf, page);
-
- evas_object_data_set(page, DATA_KEY_MAPBUF, mapbuf);
- evas_object_data_set(mapbuf, DATA_KEY_PAGE, page);
-
- evas_object_show(mapbuf);
-
- return mapbuf;
-}
-
-
-
-HAPI Evas_Object *mapbuf_unbind(Evas_Object *obj)
-{
- Evas_Object *page;
- Evas_Object *mapbuf;
-
- page = evas_object_data_get(obj, DATA_KEY_PAGE);
- if (page) {
- mapbuf = obj;
- } else {
- page = obj;
- mapbuf = evas_object_data_get(obj, DATA_KEY_MAPBUF);
- }
-
- if (mapbuf) {
- elm_mapbuf_enabled_set(mapbuf, 0);
- evas_object_data_del(page, DATA_KEY_MAPBUF);
- evas_object_data_del(mapbuf, DATA_KEY_PAGE);
- evas_object_data_del(mapbuf, PRIVATE_DATA_KEY_MAPBUF_ENABLED);
- page = elm_object_content_unset(mapbuf);
- evas_object_del(mapbuf);
- }
- return page;
-}
-
-
-
-HAPI int mapbuf_can_be_made(Evas_Object *obj)
-{
- if (!main_get_info()->is_mapbuf) return 0;
-
- Evas_Object *page = evas_object_data_get(obj, DATA_KEY_PAGE);
- if (!page) page = obj;
- retv_if(NULL == page, 0);
-
- bool mapbuf_disabled_page = (bool) evas_object_data_get(page, DATA_KEY_MAPBUF_DISABLED_PAGE);
- if (mapbuf_disabled_page) return 0;
-
- return 1;
-}
-
-
-
-HAPI int mapbuf_can_be_on(Evas_Object *obj)
-{
- if (!main_get_info()->is_mapbuf) return 0;
-
- Evas_Object *page = evas_object_data_get(obj, DATA_KEY_PAGE);
- if (!page) page = obj;
- retv_if(NULL == page, 0);
-
- bool mapbuf_disabled_page = (bool) evas_object_data_get(page, DATA_KEY_MAPBUF_DISABLED_PAGE);
- if (mapbuf_disabled_page) return 0;
-
- return 1;
-}
-
-
-
-// End of a file
diff --git a/src/noti_broker.c b/src/noti_broker.c
deleted file mode 100755
index 1db7057..0000000
--- a/src/noti_broker.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdbool.h>
-#include <Elementary.h>
-#include <Evas.h>
-#include <dlfcn.h>
-#include <bundle.h>
-#include <dlog.h>
-
-#include "conf.h"
-#include "layout.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "page.h"
-#include "key.h"
-//#include "tutorial.h"
-#include "noti_broker.h"
-#include "apps/apps.h"
-#include "critical_log.h"
-
-#define NOTI_BROKER_ERROR_NONE 0
-#define NOTI_BROKER_ERROR_FAIL -1
-#define NOTI_BROKER_PLUGIN_PATH "/usr/lib/libnoti-sample.so"
-
-/*
- * Events, To notify events to plugin
- */
-const int EVENT_SOURCE_SCROLLER = 0x00000000;
-const int EVENT_SOURCE_VIEW = 0x00000001;
-const int EVENT_SOURCE_EDITING = 0x00000002;
-
-const int EVENT_RET_NONE = 0x00000000;
-const int EVENT_RET_CONTINUE = 0x00000004;
-const int EVENT_RET_STOP = 0x00000008;
-
-#define EVENT_TYPE_ANIM 0x00000000
-const int EVENT_TYPE_ANIM_START = EVENT_TYPE_ANIM | 0x0;
-const int EVENT_TYPE_ANIM_STOP = EVENT_TYPE_ANIM | 0x1;
-#define EVENT_TYPE_DRAG 0x00001000
-const int EVENT_TYPE_DRAG_START = EVENT_TYPE_DRAG | 0x0;
-const int EVENT_TYPE_DRAG_STOP = EVENT_TYPE_DRAG | 0x1;
-#define EVENT_TYPE_EDGE 0x00002000
-const int EVENT_TYPE_EDGE_LEFT = EVENT_TYPE_EDGE | 0x0;
-const int EVENT_TYPE_EDGE_RIGHT = EVENT_TYPE_EDGE | 0x1;
-#define EVENT_TYPE_EDIT 0x00004000
-const int EVENT_TYPE_EDIT_START = EVENT_TYPE_EDIT | 0x0;
-const int EVENT_TYPE_EDIT_STOP = EVENT_TYPE_EDIT | 0x1;
-#define EVENT_TYPE_NOTI 0x00008000
-const int EVENT_TYPE_NOTI_DELETE = EVENT_TYPE_NOTI | 0x0;
-const int EVENT_TYPE_NOTI_DELETE_ALL = EVENT_TYPE_NOTI | 0x1;
-#define EVENT_TYPE_MOUSE 0x00010000
-const int EVENT_TYPE_MOUSE_DOWN = EVENT_TYPE_MOUSE | 0x0;
-const int EVENT_TYPE_MOUSE_UP = EVENT_TYPE_MOUSE | 0x1;
-#define EVENT_TYPE_SCROLL 0x00020000
-const int EVENT_TYPE_SCROLLING = EVENT_TYPE_SCROLL | 0x0;
-#define EVENT_TYPE_KEY 0x00040000
-const int EVENT_TYPE_KEY_BACK = EVENT_TYPE_KEY | 0x0;
-#define EVENT_TYPE_APPS 0x00080000
-const int EVENT_TYPE_APPS_SHOW = EVENT_TYPE_APPS | 0x0;
-const int EVENT_TYPE_APPS_HIDE = EVENT_TYPE_APPS | 0x1;
-
-/*
- * Categories, To discrete views
- */
-const int CATEGORY_NOTIFICATION = 0x00000001;
-const int CATEGORY_DASHBOARD = 0x00000002;
-
-/*
- * Functions, To handle requests from plugin
- */
-#define FUNCTION_DEF(X) const int X = E_##X
-#define FUNCTION_VAL(X) E_##X
-enum {
- FUNCTION_VAL(FUNCTION_NONE) = 0x0,
- FUNCTION_VAL(FUNCTION_PAGE_CREATE) = 0x00000001,
- FUNCTION_VAL(FUNCTION_PAGE_DESTROY) = 0x00000002,
- FUNCTION_VAL(FUNCTION_PAGE_ADD) = 0x00000004,
- FUNCTION_VAL(FUNCTION_PAGE_REMOVE) = 0x00000008,
- FUNCTION_VAL(FUNCTION_PAGE_SHOW) = 0x00000010,
- FUNCTION_VAL(FUNCTION_PAGE_RELOAD) = 0x00000020,
- FUNCTION_VAL(FUNCTION_PAGE_ITEM_SET) = 0x00000040,
- FUNCTION_VAL(FUNCTION_PAGE_ITEM_GET) = 0x00000080,
- FUNCTION_VAL(FUNCTION_SCROLLER_LEFT_PAGE_GET) = 0x00000100,
- FUNCTION_VAL(FUNCTION_SCROLLER_RIGHT_PAGE_GET) = 0x00000200,
- FUNCTION_VAL(FUNCTION_SCROLLER_FOCUSED_PAGE_GET) = 0x00000400,
- FUNCTION_VAL(FUNCTION_WINDOW_ACTIVATE) = 0x00000800,
- FUNCTION_VAL(FUNCTION_WINDOW_GET) = 0x00001000,
- FUNCTION_VAL(FUNCTION_PAGE_SHOW_NO_DELAY) = 0x00002000,
- FUNCTION_VAL(FUNCTION_PAGE_FOCUS_OBJECT_GET) = 0x00004000,
- FUNCTION_VAL(FUNCTION_PAGE_REORDER) = 0x00008000,
-};
-FUNCTION_DEF(FUNCTION_NONE);
-FUNCTION_DEF(FUNCTION_PAGE_CREATE);
-FUNCTION_DEF(FUNCTION_PAGE_DESTROY);
-FUNCTION_DEF(FUNCTION_PAGE_ADD);
-FUNCTION_DEF(FUNCTION_PAGE_REMOVE);
-FUNCTION_DEF(FUNCTION_PAGE_SHOW);
-FUNCTION_DEF(FUNCTION_PAGE_SHOW_NO_DELAY);
-FUNCTION_DEF(FUNCTION_PAGE_RELOAD);
-FUNCTION_DEF(FUNCTION_PAGE_REORDER);
-FUNCTION_DEF(FUNCTION_PAGE_ITEM_SET);
-FUNCTION_DEF(FUNCTION_PAGE_ITEM_GET);
-FUNCTION_DEF(FUNCTION_PAGE_FOCUS_OBJECT_GET);
-FUNCTION_DEF(FUNCTION_SCROLLER_LEFT_PAGE_GET);
-FUNCTION_DEF(FUNCTION_SCROLLER_RIGHT_PAGE_GET);
-FUNCTION_DEF(FUNCTION_SCROLLER_FOCUSED_PAGE_GET);
-FUNCTION_DEF(FUNCTION_WINDOW_ACTIVATE);
-FUNCTION_DEF(FUNCTION_WINDOW_GET);
-
-
-struct broker_function {
- int function;
- int (*process) (const char *id, int category, void *view, void *data, void *result);
-};
-
-typedef struct _Noti_Broker_Plugin_Handler {
- int (*init) (void *parent, void *data);
- int (*fini) (void);
- int (*event) (int source, int event, void *data);
-} Noti_Broker_Plugin_Handler;
-
-static struct _s_info {
- int is_loaded;
- int is_initialized;
- void *dl_handler;
- Noti_Broker_Plugin_Handler handle;
-} s_info = {
- .is_loaded = 0,
- .is_initialized = 0,
- .dl_handler = NULL,
- .handle = {NULL,NULL,NULL},
-};
-
-static Evas_Object *_layout_get(void)
-{
- Evas_Object *win = main_get_info()->win;
- retv_if(win == NULL, NULL);
-
- return evas_object_data_get(win, DATA_KEY_LAYOUT);
-}
-
-static Evas_Object *_scroller_get(void)
-{
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
-
- if (win != NULL) {
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- if (layout != NULL) {
- scroller = elm_object_part_content_get(layout, "scroller");
- }
- }
-
- return scroller;
-}
-
-/*!
- * To handle requests from plugin
- */
-static int _handler_page_create(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = NULL;
- Evas_Object *scroller = _scroller_get();
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
-
- page_removable_e removable = PAGE_REMOVABLE_ON;
-
- if (category == CATEGORY_DASHBOARD) {
- removable = PAGE_REMOVABLE_OFF;
- }
-
- page = page_create(scroller
- , (Evas_Object*)view
- , NULL, NULL
- , main_get_info()->root_w, main_get_info()->root_h
- , PAGE_CHANGEABLE_BG_OFF, removable);
- if (page != NULL && result != NULL) {
- *((Evas_Object **)result) = page;
- page_set_effect(page, page_effect_none, page_effect_none);
-
- return NOTI_BROKER_ERROR_NONE;
- }
-
- return NOTI_BROKER_ERROR_FAIL;
-}
-
-static int _handler_page_destroy(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
-
- page_destroy(page);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_page_add(const char *id, int category, void *view, void *data, void *result)
-{
- int ret = W_HOME_ERROR_NONE;
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();;
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
-
- if (category == CATEGORY_NOTIFICATION) {
- ret = scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER_LEFT);
- } else if (category == CATEGORY_DASHBOARD) {
- ret = scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT);
- }
-
- return (ret == W_HOME_ERROR_NONE) ? NOTI_BROKER_ERROR_NONE : NOTI_BROKER_ERROR_FAIL;
-}
-
-static int _handler_page_remove(const char *id, int category, void *view, void *data, void *result)
-{
- int ret = NOTI_BROKER_ERROR_NONE;
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
-
- if (scroller_pop_page(scroller, page) == NULL) {
- _E("Failed to remove page(%p)", page);
- ret = NOTI_BROKER_ERROR_FAIL;
- }
- evas_object_hide(page);
-
- return ret;
-}
-
-static int _handler_page_show(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
- scroller_bring_in_page(scroller, page, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_ANIMATOR);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_page_show_no_delay(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
-
- scroller_bring_in_page(scroller, page, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_INSTANT_SHOW);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_page_reload(const char *id, int category, void *view, void *data, void *result)
-{
- int ret = W_HOME_ERROR_NONE;
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
-
- if (category == CATEGORY_NOTIFICATION) {
- ret = scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER_LEFT);
- } else if (category == CATEGORY_DASHBOARD) {
- if (scroller_pop_page(scroller, page) == NULL) {
- _E("Failed to pop page(%p)", page);
- }
- ret = scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT);
- }
-
- return (ret == W_HOME_ERROR_NONE) ? NOTI_BROKER_ERROR_NONE : NOTI_BROKER_ERROR_FAIL;
-}
-
-static int _handler_page_reorder(const char *id, int category, void *view, void *data, void *result)
-{
- Eina_List *list = data;
- Evas_Object *scroller = _scroller_get();
- retv_if(list == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
-
- scroller_reorder_with_list(scroller, list, PAGE_DIRECTION_LEFT);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_page_item_set(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- Evas_Object *item = data;
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(item == NULL, NOTI_BROKER_ERROR_FAIL);
-
- page_set_item(page, item);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_page_item_get(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(result == NULL, NOTI_BROKER_ERROR_FAIL);
-
- *((Evas_Object **)result) = page_get_item(page);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_page_focus_object_get(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- page_info_s *page_info = NULL;
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(result == NULL, NOTI_BROKER_ERROR_FAIL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(page_info == NULL, NOTI_BROKER_ERROR_FAIL);
- *((Evas_Object **)result) = page_info->focus;
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_scroller_left_page_get(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(result == NULL, NOTI_BROKER_ERROR_FAIL);
-
- *((Evas_Object **)result) = scroller_get_left_page(scroller, page);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_scroller_right_page_get(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *page = view;
- Evas_Object *scroller = _scroller_get();
- retv_if(page == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(result == NULL, NOTI_BROKER_ERROR_FAIL);
-
- *((Evas_Object **)result) = scroller_get_right_page(scroller, page);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_scroller_focused_page_get(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *scroller = _scroller_get();
- retv_if(scroller == NULL, NOTI_BROKER_ERROR_FAIL);
- retv_if(result == NULL, NOTI_BROKER_ERROR_FAIL);
-
- *((Evas_Object **)result) = scroller_get_focused_page(scroller);
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_window_activate(const char *id, int category, void *view, void *data, void *result)
-{
- Evas_Object *win = main_get_info()->win;
- retv_if(win == NULL, NOTI_BROKER_ERROR_FAIL);
- elm_win_activate(win);
-
- apps_hide();
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-static int _handler_window_get(const char *id, int category, void *view, void *data, void *result)
-{
- retv_if(result == NULL, NOTI_BROKER_ERROR_FAIL);
-
- *((Evas_Object **)result) = main_get_info()->win;
-
- return NOTI_BROKER_ERROR_NONE;
-}
-
-int noti_broker_request(int function, const char *id, int category, void *view, void *data, void *result)
-{
- //do something
- Evas_Object *scroller = _scroller_get();
- retv_if(scroller == NULL, -1);
-
- if (function == FUNCTION_PAGE_CREATE ||
- function == FUNCTION_PAGE_DESTROY ||
- function == FUNCTION_PAGE_ADD ||
- function == FUNCTION_PAGE_REMOVE ||
- function == FUNCTION_PAGE_SHOW ||
- function == FUNCTION_PAGE_RELOAD ||
- function == FUNCTION_PAGE_REORDER) {
- _W("%x %s %d %p %p %p", function, id, category, view, data, result);
- }
-
- static struct broker_function fn_table[] = {
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_CREATE),
- .process = _handler_page_create,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_DESTROY),
- .process = _handler_page_destroy,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_ADD),
- .process = _handler_page_add,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_REMOVE),
- .process = _handler_page_remove,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_SHOW),
- .process = _handler_page_show,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_RELOAD),
- .process = _handler_page_reload,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_REORDER),
- .process = _handler_page_reorder,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_ITEM_SET),
- .process = _handler_page_item_set,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_ITEM_GET),
- .process = _handler_page_item_get,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_SCROLLER_LEFT_PAGE_GET),
- .process = _handler_scroller_left_page_get,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_SCROLLER_RIGHT_PAGE_GET),
- .process = _handler_scroller_right_page_get,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_SCROLLER_FOCUSED_PAGE_GET),
- .process = _handler_scroller_focused_page_get,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_WINDOW_ACTIVATE),
- .process = _handler_window_activate,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_WINDOW_GET),
- .process = _handler_window_get,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_SHOW_NO_DELAY),
- .process = _handler_page_show_no_delay,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_PAGE_FOCUS_OBJECT_GET),
- .process = _handler_page_focus_object_get,
- },
- {
- .function = FUNCTION_VAL(FUNCTION_NONE),
- .process = NULL,
- },
- };
-
- int i = 0;
- int ret = NOTI_BROKER_ERROR_NONE;
- for (i = 0; fn_table[i].function != FUNCTION_VAL(FUNCTION_NONE); i++) {
- if (function == fn_table[i].function && fn_table[i].process != NULL) {
- ret = fn_table[i].process(id, category, view, data, result);
- }
- }
-
- return ret;
-}
-
-static void _scroller_evas_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- int event_type = (int)data;
-
- noti_broker_event_fire_to_plugin(EVENT_SOURCE_SCROLLER, event_type, event_info);
-}
-
-static void _layout_smart_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- int event_type = (int)data;
-
- noti_broker_event_fire_to_plugin(EVENT_SOURCE_VIEW, event_type, event_info);
-}
-
-static void _scroller_smart_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- int event_type = (int)data;
-
- noti_broker_event_fire_to_plugin(EVENT_SOURCE_SCROLLER, event_type, event_info);
-}
-
-static key_cb_ret_e _noti_broker_back_cb(void *data)
-{
- int ret = EVENT_RET_CONTINUE;
- ret = noti_broker_event_fire_to_plugin(EVENT_SOURCE_VIEW, EVENT_TYPE_KEY_BACK, NULL);
- if (ret == EVENT_RET_STOP) {
- _W("stop back key execution");
- return KEY_CB_RET_STOP;
- }
-
- _W("continue the back key execution");
- return KEY_CB_RET_CONTINUE;
-}
-
-static void _evas_object_events_register(Evas_Object *layout, Evas_Object *scroller)
-{
- evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_DOWN, _scroller_evas_cb, (void*)EVENT_TYPE_MOUSE_DOWN);
- evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP, _scroller_evas_cb, (void*)EVENT_TYPE_MOUSE_UP);
-
- evas_object_smart_callback_add(scroller, "scroll,anim,start", _scroller_smart_cb, (void*)EVENT_TYPE_ANIM_START);
- evas_object_smart_callback_add(scroller, "scroll,anim,stop", _scroller_smart_cb, (void*)EVENT_TYPE_ANIM_STOP);
- evas_object_smart_callback_add(scroller, "scroll,drag,start", _scroller_smart_cb, (void*)EVENT_TYPE_DRAG_START);
- evas_object_smart_callback_add(scroller, "scroll,drag,stop", _scroller_smart_cb, (void*)EVENT_TYPE_DRAG_STOP);
- evas_object_smart_callback_add(scroller, "edge,left", _scroller_smart_cb, (void*)EVENT_TYPE_EDGE_LEFT);
- evas_object_smart_callback_add(scroller, "edge,right", _scroller_smart_cb, (void*)EVENT_TYPE_EDGE_RIGHT);
- evas_object_smart_callback_add(scroller, "scroll", _scroller_smart_cb, (void*)EVENT_TYPE_SCROLL);
-
- evas_object_smart_callback_add(layout, LAYOUT_SMART_SIGNAL_EDIT_ON,
- _layout_smart_cb, (void *)EVENT_TYPE_EDIT_START);
- evas_object_smart_callback_add(layout, LAYOUT_SMART_SIGNAL_EDIT_OFF,
- _layout_smart_cb, (void *)EVENT_TYPE_EDIT_STOP);
-
- key_register_cb(KEY_TYPE_BACK, _noti_broker_back_cb, NULL);
-}
-
-Eina_Bool _init_timeout_cb(void *data)
-{
- if (s_info.is_initialized == 0) {
- _W("noti broker isn't initialized");
- noti_broker_init();
- }
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/*!
- * constructor/deconstructor
- */
-HAPI void noti_broker_load(void)
-{
- char *errmsg = NULL;
- void *dl_handle = NULL;
-
- _W("loading noti broker plugin start");
- dl_handle = dlopen(NOTI_BROKER_PLUGIN_PATH, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND);
- _W("loading noti broker plugin done");
-
- errmsg = dlerror();
- if (errmsg) {
- _E("dlerror(can be ignored): %s\n", errmsg);
- CRITICAL_LOG("dlopen failed: %s\n", errmsg);
- }
- ret_if(dl_handle == NULL);
-
- s_info.handle.init = dlsym(dl_handle, "noti_board_plugin_init");
- if (s_info.handle.init == NULL) {
- _E("Failed to find noti_board_plugin_init");
- goto ERR;
- }
-
- s_info.handle.fini = dlsym(dl_handle, "noti_board_plugin_fini");
- if (s_info.handle.fini == NULL) {
- _E("Failed to find noti_board_plugin_fini");
- goto ERR;
- }
-
- s_info.handle.event = dlsym(dl_handle, "noti_board_plugin_event");
- if (s_info.handle.event == NULL) {
- _E("Failed to find noti_board_plugin_event");
- goto ERR;
- }
-
- s_info.is_loaded = 1;
- s_info.dl_handler = dl_handle;
-
- ecore_timer_add(10.0f, _init_timeout_cb, NULL);
-
- return ;
-
-ERR:
- if (dl_handle) dlclose(dl_handle);
-}
-
-HAPI void noti_broker_init(void)
-{
- Evas_Object *layout = _layout_get();
- Evas_Object *scroller = _scroller_get();
- ret_if(s_info.is_loaded == 0);
- ret_if(s_info.is_initialized == 1);
- ret_if(layout == NULL);
- ret_if(scroller == NULL);
-
- s_info.is_initialized = 1;
- s_info.handle.init(scroller, scroller);
- _evas_object_events_register(layout, scroller);
-}
-
-HAPI void noti_broker_fini(void)
-{
- ret_if(s_info.is_loaded == 0);
- s_info.is_loaded = 0;
-
- s_info.handle.fini();
- s_info.is_initialized = 0;
-
- if (s_info.dl_handler != NULL) {
- dlclose(s_info.dl_handler);
- }
-}
-
-/*!
- * To notify events to plugin
- */
-HAPI int noti_broker_event_fire_to_plugin(int source, int event, void *data)
-{
- retv_if(s_info.is_loaded == 0, EVENT_RET_NONE);
-
- if (event == EVENT_TYPE_APPS_SHOW ||
- event == EVENT_TYPE_APPS_HIDE) {
- _W("source:%d event:%x", source, event);
- }
-
- return s_info.handle.event(source, event, data);
-}
diff --git a/src/notification/noti_action_buttons_view.c b/src/notification/noti_action_buttons_view.c
deleted file mode 100755
index 29785e1..0000000
--- a/src/notification/noti_action_buttons_view.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Notification API headers */
-#include <notification.h>
-#include <notification_internal.h>
-#include <notification_text_domain.h>
-#include <Elementary.h>
-#include <Ecore.h>
-#include <glib.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "notification/noti_action_buttons_view.h"
-#include "notification/noti_detail_view.h"
-#include "notification/noti_panel_mgr.h"
-
-#define IMG_OPEN_APP IMAGEDIR"/b_rich_noti_basic_more_go_to_app.png"
-#define IMG_CLEAR_ALL IMAGEDIR"/b_rich_noti_basic_more_delete.png"
-
-static app_control_h app_control_local = NULL;
-
-static void
-_more_option_opened(void *data, Evas_Object *obj, void *event_info)
-{
- _D("more option is opened!!!");
- noti_detail_view_set_back_key(EINA_TRUE);
-}
-
-static void
-_more_option_closed(void *data, Evas_Object *obj, void *event_info)
-{
- _D("more option is closed!!!");
- ret_if(!data);
-
- Evas_Object *circle_scroller = (Evas_Object *)data;
- noti_detail_view_set_back_key(EINA_FALSE);
- eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE);
-}
-
-static void
-_item_selected(void *data, Evas_Object *obj, void *event_info)
-{
- Eext_Object_Item *item = (Eext_Object_Item *)event_info;
- const char *main_text;
- const char *sub_text;
-
- /* Get the text in item text part */
- main_text = eext_more_option_item_part_text_get(item, "selector,main_text");
- sub_text = eext_more_option_item_part_text_get(item, "selector,sub_text");
- dlog_print(DLOG_INFO, LOG_TAG, "item[%p]:main text[%s](sub text[%s]) is selected!", item, main_text, sub_text);
-}
-
-static Eina_Bool _timer_cb(void *data)
-{
- noti_detail_view_destroy();
- return ECORE_CALLBACK_DONE;
-}
-
-
-static void
-_item_clicked(void *data, Evas_Object *obj, void *event_info)
-{
- ret_if(!data);
- const char *main_text;
- Eext_Object_Item *item = (Eext_Object_Item *)event_info;
-
- main_text = eext_more_option_item_part_text_get(item, "selector,main_text");
-
- app_control_h app_control = NULL;
- int ret;
-
- if (!strcmp(main_text, _("MIDS_SAPPS_BUTTON_OPEN_APP"))) {
- if (app_control_local) {
- ret = app_control_send_launch_request(app_control_local, NULL, NULL);
- ret_if(ret != APP_CONTROL_ERROR_NONE);
- goto OUT;
- } else {
- ret = app_control_create(&app_control);
- ret_if(ret != APP_CONTROL_ERROR_NONE);
-
- ret = app_control_set_app_id(app_control, data);
- goto_if(ret != APP_CONTROL_ERROR_NONE, OUT2);
-
- ret = app_control_send_launch_request(app_control, NULL, NULL);
- goto_if(ret != APP_CONTROL_ERROR_NONE, OUT2);
- goto OUT2;
- }
- } else if (!strcmp(main_text, _("IDS_COM_BODY_CLEAR_ALL"))) {
- noti_panel_mgr_destroy_page(data);
- ecore_timer_add(0.3, _timer_cb, NULL);
- util_create_toast_popup_from_noti(_("WDS_WNOTI_TPOP_NOTIFICATIONS_CLEARED_ABB"));
- goto OUT;
- }
-
-OUT2:
- app_control_destroy(app_control);
-OUT:
- return;
-}
-
-static void
-_create_option_items(Evas_Object *parent, int index)
-{
- ret_if(parent == NULL);
-
- Evas_Object *img = NULL;
-
- Eext_Object_Item *item = eext_more_option_item_append(parent);
- img = elm_image_add(parent);
-
- if (index % 2 == 0) {
- eext_more_option_item_part_text_set(item, "selector,main_text", _("MIDS_SAPPS_BUTTON_OPEN_APP"));
-
- elm_image_file_set(img, IMG_OPEN_APP, NULL);
- eext_more_option_item_part_content_set(item, "item,icon", img);
- } else if (index % 2 == 1) {
- eext_more_option_item_part_text_set(item, "selector,main_text", _("IDS_COM_BODY_CLEAR_ALL"));
-
- elm_image_file_set(img, IMG_CLEAR_ALL, NULL);
- eext_more_option_item_part_content_set(item, "item,icon", img);
- }
-
- return;
-}
-
-void noti_create_more_option(Evas_Object *parent, Evas_Object *circle_scroller)
-{
- ret_if(!parent);
- ret_if(!circle_scroller);
-
- Evas_Object *more_option = eext_more_option_add(parent);
- const char *appid = evas_object_data_get(parent, DATA_KEY_APP_ID);
- app_control_local = evas_object_data_get(parent, DATA_KEY_APP_CONTROL);
- bool pkg_validity = evas_object_data_get(parent, DATA_KEY_PKG_VALIDITY);
-
- int i;
- for (i = 0; i < 2; ++i) {
- /* DO NOT add the 'open app button' if the app id is not valid id */
- if (i == 0 && pkg_validity == false)
- continue;
- _create_option_items(more_option, i);
- }
-
- evas_object_smart_callback_add(more_option, "more,option,opened", _more_option_opened, NULL);
- evas_object_smart_callback_add(more_option, "more,option,closed", _more_option_closed, circle_scroller);
- evas_object_smart_callback_add(more_option, "item,selected", _item_selected, NULL);
- evas_object_smart_callback_add(more_option, "item,clicked", _item_clicked, appid);
-
- evas_object_move(more_option, 180, 180);
-}
diff --git a/src/notification/noti_detail_view.c b/src/notification/noti_detail_view.c
deleted file mode 100755
index 19b92a7..0000000
--- a/src/notification/noti_detail_view.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Notification API headers */
-#include <notification.h>
-#include <notification_internal.h>
-#include <notification_text_domain.h>
-#include <Elementary.h>
-#include <glib.h>
-#include <stdbool.h>
-#include <package_manager.h>
-#include <app_manager.h>
-
-#include "log.h"
-#include "key.h"
-#include "main.h"
-#include "notification/noti_detail_view.h"
-#include "notification/noti_action_buttons_view.h"
-#include "notification/noti_time.h"
-#include "notification/noti_panel_mgr.h"
-
-#define IMG_OPEN_APP IMAGEDIR"/b_rich_noti_basic_more_go_to_app.png"
-#define IMG_CLEAR_ALL IMAGEDIR"/b_rich_noti_basic_more_delete.png"
-
-static struct noti_detail_view_data_s {
- Evas_Object *win;
- Evas_Object *layout;
- Evas_Object *box;
-
- Evas_Object *title_label;
- Evas_Object *time_label;
- Evas_Object *contents_title_label;
- Evas_Object *paragraph_label;
-
- Evas_Object *conform;
- Evas_Object *scroller;
- Evas_Object *circle_scroller;
-
- Eina_List *item_list;
- Eext_Circle_Surface *circle_surface;
- Eina_Bool is_open_more_option;
- notification_h notification_local;
-
- app_control_h app_control;
-} _noti_detail_view_data_s = {
- .win = NULL,
- .conform = NULL,
- .scroller = NULL,
- .layout = NULL,
- .item_list = NULL,
- .notification_local = NULL,
- .is_open_more_option = EINA_FALSE,
- .title_label = NULL,
- .time_label = NULL,
- .contents_title_label = NULL,
- .paragraph_label = NULL,
- .app_control = NULL
-};
-
-#define DETAIL_VIEW_EDJE_FILE EDJEDIR"/noti_detail_view.edj"
-#define DETAIL_ITEM_VIEW_EDJE_FILE EDJEDIR"/noti_detail_item_view.edj"
-
-Eina_Bool noti_detail_view_is_open_detail_view_win()
-{
- if (_noti_detail_view_data_s.win != NULL)
- return EINA_TRUE;
-
- return EINA_FALSE;
-}
-
-Eina_Bool noti_detail_view_is_open_more_option()
-{
- return _noti_detail_view_data_s.is_open_more_option;
-}
-
-void noti_detail_view_set_back_key(Eina_Bool is_open_more_option)
-{
- _noti_detail_view_data_s.is_open_more_option = is_open_more_option;
-}
-
-void noti_detail_view_destroy()
-{
- _noti_detail_view_data_s.item_list = eina_list_free(_noti_detail_view_data_s.item_list);
-
- if (_noti_detail_view_data_s.app_control) {
- app_control_destroy(_noti_detail_view_data_s.app_control);
- _noti_detail_view_data_s.app_control = NULL;
- }
-
- if (_noti_detail_view_data_s.win != NULL) {
- evas_object_del(_noti_detail_view_data_s.win);
- _noti_detail_view_data_s.win = NULL;
- }
- if (_noti_detail_view_data_s.notification_local != NULL) {
- notification_free(_noti_detail_view_data_s.notification_local);
- _noti_detail_view_data_s.notification_local = NULL;
- }
-
- _noti_detail_view_data_s.is_open_more_option = EINA_FALSE;
-}
-
-static Evas_Object * _noti_create_detail_view_win()
-{
- Evas_Object *win = NULL;
-
- win = elm_win_util_standard_add("noti_detail_view", "noti_detail_view");
- if (win == NULL) {
- _E("elm_win_util_standard_add failed");
- goto OUT;
- }
- elm_win_autodel_set(win, EINA_TRUE);
-
-OUT:
- return win;
-}
-
-static Evas_Object* _noti_create_detail_view_conformant(Evas_Object *parent)
-{
- Evas_Object *conform = NULL;
-
- conform = elm_conformant_add(parent);
- if (conform == NULL) {
- _E("elm_conformant_add failed");
- goto OUT;
- }
-
- evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(parent, conform);
- evas_object_show(conform);
-
-OUT:
- return conform;
-}
-
-static Evas_Object* _noti_create_detail_view_layout(Evas_Object *parent)
-{
- Evas_Object *layout = NULL;
-
- layout = elm_layout_add(parent);
- if (layout == NULL) {
- _E("elm_layout_add failed");
- goto OUT;
- }
-
- elm_layout_file_set(layout, DETAIL_VIEW_EDJE_FILE, "win");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(layout);
-
-OUT:
- return layout;
-}
-
-static Evas_Object* _noti_create_detail_view_scroller(Evas_Object *parent)
-{
- Evas_Object *scroller = NULL;
-
- scroller = elm_scroller_add(parent);
- if (scroller == NULL) {
- _E("elm_scroller_add failed");
- goto OUT;
- }
-
- evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
- evas_object_show(scroller);
-
-OUT:
- return scroller;
-}
-
-static Evas_Object* _noti_create_detail_view_item_layout(const char* group)
-{
- Evas_Object *item_layout = NULL;
-
- item_layout = elm_layout_add(_noti_detail_view_data_s.box);
- if (item_layout == NULL) {
- _E("elm_layout_add failed");
- goto OUT;
- }
-
- elm_layout_file_set(item_layout, DETAIL_ITEM_VIEW_EDJE_FILE, group);
-
- evas_object_size_hint_weight_set(item_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(item_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(item_layout);
-
-OUT:
- return item_layout;
-}
-
-static Eina_Bool _timer_cb(void *data)
-{
- noti_detail_view_destroy();
- return ECORE_CALLBACK_DONE;
-}
-
-static void _noti_detail_view_clear_all_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- noti_panel_mgr_destroy_page(data);
- ecore_timer_add(0.3, _timer_cb, NULL);
- util_create_toast_popup_from_noti(_("WDS_WNOTI_TPOP_NOTIFICATIONS_CLEARED_ABB"));
-}
-
-static void _noti_detail_view_open_app_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- int ret;
-
- if (_noti_detail_view_data_s.app_control) {
- ret = app_control_send_launch_request(_noti_detail_view_data_s.app_control, NULL, NULL);
- ret_if(ret != APP_CONTROL_ERROR_NONE);
- } else {
- app_control_h app_control_local;
-
- ret = app_control_create(&app_control_local);
- ret_if(ret != APP_CONTROL_ERROR_NONE);
-
- ret = app_control_set_app_id(app_control_local, data);
- ret_if(ret != APP_CONTROL_ERROR_NONE);
-
- ret = app_control_send_launch_request(app_control_local, NULL, NULL);
- ret_if(ret != APP_CONTROL_ERROR_NONE);
-
- app_control_destroy(app_control_local);
- }
-
- return;
-}
-
-static Evas_Object * _noti_detail_view_set_label()
-{
- Evas_Object *label = NULL;
- label = elm_label_add(_noti_detail_view_data_s.box);
-
- elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
- elm_label_wrap_width_set(label, 294);
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(label);
-
- return label;
-}
-
-static void _noti_detail_view_box_pack_end()
-{
- Eina_List *l = NULL;
- Evas_Object *data;
-
- EINA_LIST_FOREACH(_noti_detail_view_data_s.item_list, l, data) {
- elm_box_pack_end(_noti_detail_view_data_s.box, data);
- }
-
- elm_box_recalculate(_noti_detail_view_data_s.box);
-}
-
-static bool _noti_detail_view_check_package_info(const char *package_id)
-{
- bool ret = false;
- package_info_h package_info = NULL;
-
- _D("package_id [%s]", package_id);
-
- if (package_manager_get_package_info (package_id, &package_info) == PACKAGE_MANAGER_ERROR_NONE) {
- _D("package_manager_get_package_info returns true for [%s]", package_id);
- ret = true;
- }
-
- if (package_info)
- package_info_destroy(package_info);
-
- return ret;
-}
-
-static void _noti_detail_view_set_contents(Eina_Bool is_popup)
-{
- char *title_text = NULL;
- char *content_text = NULL;
- char *content_title_text = NULL;
- char *text_time = NULL;
- char *icon_path = NULL;
- char buf[128] = {0, };
- char *appid;
-
- char *start_tag = "<font=BreezeSans:style=Regular color=#fafafa align=center wrap=mixed font_size=30>";
- char *start_tag_title = "<font=BreezeSans:style=Regular color=#fafafa align=center wrap=mixed font_size=36>";
- char *start_tag_time = "<font=BreezeSans:style=Regular color=#b5b5b5 align=center wrap=mixed font_size=24>";
- char *end_tag = "</font>";
- char *set_text = NULL;
- int buffer_size;
- bool is_valid_pkg_id = true;
-
- int ret = NOTIFICATION_ERROR_NONE;
- time_t time;
- Evas_Object *icon = NULL;
- Evas_Object *top_icon = NULL;
-
- ret = notification_get_pkgname(_noti_detail_view_data_s.notification_local, &appid);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- evas_object_data_set(_noti_detail_view_data_s.win, DATA_KEY_APP_ID, appid);
-
- /* If given pkg id is not available id, set DATA_KEY_PKG_VALIDITY with validity for hiding buttons */
- is_valid_pkg_id = _noti_detail_view_check_package_info(appid);
- evas_object_data_set(_noti_detail_view_data_s.win, DATA_KEY_PKG_VALIDITY, (const void*)is_valid_pkg_id);
-
- if (is_popup) {
- ret = notification_get_image(_noti_detail_view_data_s.notification_local, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- if (!icon_path || access(icon_path, R_OK) != 0) {
- _E("Failed to access an icon(%s)", icon_path);
- icon_path = DEFAULT_ICON;
- }
-
- Evas_Object *top_spacer_popup = _noti_create_detail_view_item_layout("detail_top_space_popup");
- ret_if(!top_spacer_popup);
-
- top_icon = elm_icon_add(top_spacer_popup);
- ret_if(!top_icon);
-
- if (elm_image_file_set(top_icon, icon_path, NULL) == EINA_FALSE) {
- _E("Icon file is not accessible (%s)", icon_path);
- evas_object_del(top_icon);
- } else {
- elm_image_preload_disabled_set(top_icon, EINA_TRUE);
- elm_image_smooth_set(top_icon, EINA_TRUE);
- elm_image_no_scale_set(top_icon, EINA_FALSE);
- }
-
- elm_object_part_content_set(top_spacer_popup, "top.icon", top_icon);
-
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list, top_spacer_popup);
- } else {
- Evas_Object *top_spacer = _noti_create_detail_view_item_layout("detail_top_space");
- ret_if(!top_spacer);
-
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list, top_spacer);
- }
-
- ret = notification_get_text(_noti_detail_view_data_s.notification_local, NOTIFICATION_TEXT_TYPE_TITLE, &title_text);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- ret = notification_get_text(_noti_detail_view_data_s.notification_local, NOTIFICATION_TEXT_TYPE_CONTENT, &content_text);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- ret = notification_get_text(_noti_detail_view_data_s.notification_local, NOTIFICATION_TEXT_TYPE_INFO_1, &content_title_text);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- ret = notification_get_time(_noti_detail_view_data_s.notification_local, &time);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- ret = notification_get_launch_option(_noti_detail_view_data_s.notification_local,
- NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &_noti_detail_view_data_s.app_control);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- if (_noti_detail_view_data_s.app_control)
- evas_object_data_set(_noti_detail_view_data_s.win, DATA_KEY_APP_CONTROL, _noti_detail_view_data_s.app_control);
-
- if (title_text) {
- buffer_size = strlen(start_tag_title)+strlen(title_text)+strlen(end_tag);
- set_text = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(set_text, buffer_size, "%s%s%s", start_tag_title, title_text, end_tag);
-
- _noti_detail_view_data_s.title_label = _noti_detail_view_set_label();
- elm_object_text_set(_noti_detail_view_data_s.title_label, set_text);
- elm_label_wrap_width_set(_noti_detail_view_data_s.title_label, 268);
- evas_object_size_hint_max_set(_noti_detail_view_data_s.title_label, 268, -1);
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list,
- _noti_detail_view_data_s.title_label);
-
- free(set_text);
- }
-
- if (time) {
- notification_time_to_string(&time, buf, sizeof(buf));
- text_time = elm_entry_utf8_to_markup(buf);
-
- if (text_time) {
- buffer_size = strlen(start_tag_time)+strlen(text_time)+strlen(end_tag);
- set_text = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(set_text, buffer_size, "%s%s%s", start_tag_time, text_time, end_tag);
-
- _noti_detail_view_data_s.time_label = _noti_detail_view_set_label();
- elm_object_text_set(_noti_detail_view_data_s.time_label, set_text);
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list,
- _noti_detail_view_data_s.time_label);
- free(text_time);
- free(set_text);
- }
- }
-
- if (content_title_text) {
- buffer_size = strlen(start_tag)+strlen(content_title_text)+strlen(end_tag);
- set_text = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(set_text, buffer_size, "%s%s%s", start_tag, content_title_text, end_tag);
-
- _noti_detail_view_data_s.contents_title_label = _noti_detail_view_set_label();
- elm_object_text_set(_noti_detail_view_data_s.contents_title_label, set_text);
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list,
- _noti_detail_view_data_s.contents_title_label);
-
- free(set_text);
- }
-
- /* Horizontal separator */
- Evas_Object *line = _noti_create_detail_view_item_layout("detail_line");
- ret_if(!line);
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list, line);
-
- if (content_text) {
- buffer_size = strlen(start_tag)+strlen(content_text)+strlen(end_tag);
- set_text = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(set_text, buffer_size, "%s%s%s", start_tag, content_text, end_tag);
-
- _noti_detail_view_data_s.paragraph_label = _noti_detail_view_set_label();
- elm_object_text_set(_noti_detail_view_data_s.paragraph_label, set_text);
- evas_object_size_hint_max_set(_noti_detail_view_data_s.paragraph_label, 294, -1);
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list,
- _noti_detail_view_data_s.paragraph_label);
- free(set_text);
- }
-
- _D("is_valid_pkg_id [%d]", is_valid_pkg_id);
- if (is_valid_pkg_id) {
- Evas_Object *bottom_spacer = _noti_create_detail_view_item_layout("detail_bottom_space");
- ret_if(!bottom_spacer);
-
- icon = elm_image_add(bottom_spacer);
-
- elm_image_file_set(icon, IMG_OPEN_APP, NULL);
- elm_object_part_content_set(bottom_spacer, "action,button", icon);
- elm_object_part_text_set(bottom_spacer, "actbtn,text", _("MIDS_SAPPS_BUTTON_OPEN_APP"));
-
- evas_object_smart_callback_add(icon, "clicked", _noti_detail_view_open_app_clicked_cb, appid);
-
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list, bottom_spacer);
- } else {
- Evas_Object *bottom_spacer = _noti_create_detail_view_item_layout("detail_bottom_space");
- ret_if(!bottom_spacer);
-
- icon = elm_image_add(bottom_spacer);
-
- elm_image_file_set(icon, IMG_CLEAR_ALL, NULL);
- elm_object_part_content_set(bottom_spacer, "action,button", icon);
- elm_object_part_text_set(bottom_spacer, "actbtn,text", _("IDS_COM_BODY_CLEAR_ALL"));
-
- evas_object_smart_callback_add(icon, "clicked", _noti_detail_view_clear_all_clicked_cb, appid);
-
- _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list, bottom_spacer);
- }
-}
-
-static Evas_Object* _noti_create_detail_view_circle_scroller(Evas_Object *scroller, Eext_Circle_Surface *surface)
-{
- Evas_Object *circle_scroller = NULL;
- circle_scroller = eext_circle_object_scroller_add(scroller, surface);
-
- if (circle_scroller == NULL) {
- _E("eext_circle_object_scroller_add failed");
- goto OUT;
- }
-
- eext_circle_object_scroller_policy_set(circle_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
- eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE);
-
-OUT:
- return circle_scroller;
-}
-
-static Evas_Object* _noti_create_detail_view_box(Evas_Object *parent)
-{
- Evas_Object *box = elm_box_add(parent);
-
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_align_set(box, 0.0, 0.0);
-
- elm_object_content_set(parent, box);
- evas_object_show(box);
-
- return box;
-}
-
-int noti_create_detail_view(notification_h notification, Eina_Bool is_popup)
-{
- int ret = W_HOME_ERROR_NONE;
-
- if (notification == NULL) {
- _E("notification is null");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- notification_clone(notification, &_noti_detail_view_data_s.notification_local);
-
- _noti_detail_view_data_s.win = _noti_create_detail_view_win();
- if (_noti_detail_view_data_s.win == NULL) {
- _E("_noti_create_detail_view_win failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_detail_view_data_s.conform = _noti_create_detail_view_conformant(_noti_detail_view_data_s.win);
- if (_noti_detail_view_data_s.conform == NULL) {
- _E("_noti_create_detail_view_conformant failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_detail_view_data_s.circle_surface = eext_circle_surface_conformant_add(_noti_detail_view_data_s.conform);
- if (_noti_detail_view_data_s.circle_surface == NULL) {
- _E("eext_circle_surface_conformant_add failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_detail_view_data_s.layout = _noti_create_detail_view_layout(_noti_detail_view_data_s.conform);
- if (_noti_detail_view_data_s.layout == NULL) {
- _E("_noti_create_detail_view_layout failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
- elm_object_content_set(_noti_detail_view_data_s.conform, _noti_detail_view_data_s.layout);
-
- _noti_detail_view_data_s.scroller = _noti_create_detail_view_scroller(_noti_detail_view_data_s.layout);
- if (_noti_detail_view_data_s.scroller == NULL) {
- _E("_noti_create_detail_view_scroller failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
- elm_object_part_content_set(_noti_detail_view_data_s.layout, "bg,scroller", _noti_detail_view_data_s.scroller);
-
- _noti_detail_view_data_s.circle_scroller = _noti_create_detail_view_circle_scroller(_noti_detail_view_data_s.scroller, _noti_detail_view_data_s.circle_surface);
- if (_noti_detail_view_data_s.circle_scroller == NULL) {
- _E("_noti_create_detail_view_circle_scroller failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_detail_view_data_s.box = _noti_create_detail_view_box(_noti_detail_view_data_s.scroller);
-
- _noti_detail_view_data_s.item_list = eina_list_free(_noti_detail_view_data_s.item_list);
- _noti_detail_view_set_contents(is_popup);
- _noti_detail_view_box_pack_end();
-
- noti_create_more_option(_noti_detail_view_data_s.win, _noti_detail_view_data_s.circle_scroller);
- evas_object_show(_noti_detail_view_data_s.win);
-
-OUT:
- return ret;
-}
diff --git a/src/notification/noti_event_manager.c b/src/notification/noti_event_manager.c
deleted file mode 100755
index 9559184..0000000
--- a/src/notification/noti_event_manager.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <notification.h>
-#include <notification_internal.h>
-
-#include "notification/noti_event_manager.h"
-
-static void __notification_changed_cb(void *data, notification_type_e type, notification_op *operation_list, int operation_count);
-
-ERROR_E noti_event_manager_init(void)
-{
- _D("%s", __func__);
-
- int ret = NOTIFICATION_ERROR_NONE;
-
- ret = notification_register_detailed_changed_cb(__notification_changed_cb, NULL);
-
- if (ret != NOTIFICATION_ERROR_NONE) {
- _E("notification_register_detailed_changed_cb failed [%d]", ret);
- return ERROR_FAILED;
- }
-
- return ERROR_NONE;
-}
-
-void noti_event_manager_fini(void)
-{
- int ret = NOTIFICATION_ERROR_NONE;
- ret = notification_unregister_detailed_changed_cb(__notification_changed_cb, NULL);
-
- if (ret != NOTIFICATION_ERROR_NONE) {
- _E("notification_unregister_detailed_changed_cb failed [%d]", ret);
- }
-}
-
-static void __notification_changed_cb(void *data, notification_type_e type, notification_op *operation_list, int operation_count)
-{
- if (operation_list == NULL || operation_count < 1) {
- _E("Invalid parameter");
- return;
- }
-
- int i = 0;
- int notification_id = 0;
- notification_op_type_e operation_type = 0;
- notification_h notification = NULL;
- for (i = 0; i < operation_count; i++) {
- notification_op_get_data(operation_list + i, NOTIFICATION_OP_DATA_NOTI, &notification);
- notification_op_get_data(operation_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &notification_id);
- notification_op_get_data(operation_list + i, NOTIFICATION_OP_DATA_TYPE, &operation_type);
-
- _D("notification id [%d], operation type [%d]", notification_id, operation_type);
- noti_panel_mgr_event_handler(operation_type, notification_id, notification);
- noti_popup_mgr_event_handler(operation_type, notification);
- }
-
- if (clock_service_check_noti_indicator_enable()) {
- clock_service_set_noti_indicator_icon();
- }
-}
diff --git a/src/notification/noti_event_mgr.c b/src/notification/noti_event_mgr.c
deleted file mode 100755
index 9644639..0000000
--- a/src/notification/noti_event_mgr.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/* Notification API headers */
-#include <notification.h>
-#include <notification_internal.h>
-#include <notification_text_domain.h>
-
-#include "log.h"
-#include "util.h"
-#include "clock_service.h"
-#include "notification/noti_event_mgr.h"
-#include "notification/noti_popup_mgr.h"
-#include "notification/noti_panel_mgr.h"
-
-static void _notification_changed_cb(void *data, notification_type_e type, notification_op *operation_list, int operation_count)
-{
- int i = 0;
- int notification_id = 0;
- notification_op_type_e operation_type = 0;
- notification_h notification = NULL;
-
- if (operation_list == NULL || operation_count < 1) {
- _E("Invalid parameter");
- return;
- }
- /* Generally, operation_list will have only one item */
- for (; i < operation_count; i++) {
- /* DO NOT FREE notification */
- notification_op_get_data(operation_list + i, NOTIFICATION_OP_DATA_NOTI, &notification);
- notification_op_get_data(operation_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &notification_id);
- notification_op_get_data(operation_list + i, NOTIFICATION_OP_DATA_TYPE, &operation_type);
-
- _D("notification id [%d], operation type [%d]", notification_id, operation_type);
- noti_panel_mgr_event_handler(operation_type, notification_id, notification);
- noti_popup_mgr_event_handler(operation_type, notification);
- }
- /* operation_list would be freed at notifciation API side */
-
- if (clock_service_check_noti_indicator_enable())
- clock_service_set_noti_indicator_icon();
-
- return;
-}
-
-int noti_event_mgr_init()
-{
- int ret = NOTIFICATION_ERROR_NONE;
-
- ret = notification_register_detailed_changed_cb(_notification_changed_cb, NULL);
-
- if (ret != NOTIFICATION_ERROR_NONE) {
- _E("notification_register_detailed_changed_cb failed [%d]", ret);
- return W_HOME_ERROR_FAIL;
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-void noti_event_mgr_fini()
-{
- int ret = NOTIFICATION_ERROR_NONE;
-
- ret = notification_unregister_detailed_changed_cb(_notification_changed_cb, NULL);
-
- if (ret != NOTIFICATION_ERROR_NONE) {
- _E("notification_unregister_detailed_changed_cb failed [%d]", ret);
- }
-}
diff --git a/src/notification/noti_manager.c b/src/notification/noti_manager.c
deleted file mode 100755
index 7caae32..0000000
--- a/src/notification/noti_manager.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "notification/noti.h"
-
-ERROR_E noti_init(void)
-{
- _D("%s", __func__);
-
- if (noti_event_manager_init() != ERROR_NONE) {
- _E("failed to initialize notification event manager");
- return ERROR_FAILED;
- }
-
-
- return ERROR_NONE;
-}
-
-void noti_fini(void)
-{
-
-}
diff --git a/src/notification/noti_panel_cover_view.c b/src/notification/noti_panel_cover_view.c
deleted file mode 100755
index 10ff972..0000000
--- a/src/notification/noti_panel_cover_view.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <notification.h>
-#include <notification_list.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "notification/noti_panel_cover_view.h"
-#include "notification/noti_detail_view.h"
-#include "notification/noti_panel_stack_view.h"
-#include "notification/noti_time.h"
-
-#define COVER_EDJE_FILE EDJEDIR"/noti_panel_cover_view.edj"
-
-static void _down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout = data;
- Evas_Event_Mouse_Down *ei = event_info;
-
- int x = ei->output.x;
- int y = ei->output.y;
-
- if(!layout) return;
- if (!obj) return;
-
- evas_object_data_set(obj, "down_x", (void *) x);
- evas_object_data_set(obj, "down_y", (void *) y);
- evas_object_data_set(obj, "move_y", (void *) y);
- evas_object_data_del(obj, "item_move");
-}
-
-
-
-static void _move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout = data;
- Evas_Object *edj_obj = NULL;
- Evas_Event_Mouse_Move *ei = event_info;
- int cur_x, cur_y, ori_x, ori_y;
- Edje_Message_Int msg;
-
- cur_x = ei->cur.output.x;
- cur_y = ei->cur.output.y;
-
- ori_y = (int)evas_object_data_get(obj, "down_y");
- ori_x = (int)evas_object_data_get(obj, "down_x");
-
- evas_object_data_set(obj, "move_y", (void *) cur_y);
-
- if (ori_y - cur_y < 10 || abs(ori_y - cur_y) < abs(ori_x - cur_x)) {
- elm_object_signal_emit(layout, "close", "trash");
- return;
- }
-
- if (!evas_object_data_get(obj, "item_move")) {
- elm_object_signal_emit(layout, "moved", "coverview");
- evas_object_data_set(obj, "item_move", (void *) 1);
- }
-
- if (cur_y <= 100) {
- elm_object_signal_emit(layout, "open", "trash");
- } else {
- elm_object_signal_emit(layout, "close", "trash");
- }
-
- msg.val = ori_y - cur_y;
- edj_obj = elm_layout_edje_get(layout);
-
- edje_object_message_send(edj_obj, EDJE_MESSAGE_INT, 2, &msg);
- if ((ori_y - cur_y) > 100) return;
- edje_object_message_send(edj_obj, EDJE_MESSAGE_INT, 1, &msg);
- edje_object_message_signal_process(edj_obj);
-}
-
-
-
-static void _up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout = data;
-
- if(!layout) return;
- if (!obj) return;
-
- evas_object_data_del(obj, "down_y");
- evas_object_data_del(obj, "move_y");
-
- elm_object_signal_emit(layout, "up", "coverview");
-}
-
-
-
-static void _coverview_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- notification_h noti = NULL;
- if (evas_object_data_get(obj, "item_move")) {
- _D("coverview is moving");
- return;
- }
-
- noti = evas_object_data_get(obj, "noti");
- noti_create_detail_view(noti, EINA_FALSE);
-}
-
-
-
-static void _morebutton_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- char *pkgname = NULL;
- notification_h noti = NULL;
- notification_list_h noti_list = NULL;
- app_control_h app_control = NULL;
- int ret;
-
- if (evas_object_data_get(obj, "item_move")) {
- _D("coverview is moving");
- return;
- }
-
- noti = evas_object_data_get(obj, "noti");
- ret_if(!noti);
-
- notification_get_pkgname(noti, &pkgname);
- ret_if(!pkgname);
-
- notification_get_detail_list(pkgname, -1, -1, 50, &noti_list);
- ret_if(!noti_list);
-
- ret = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
- ret_if(ret != NOTIFICATION_ERROR_NONE);
-
- noti_panel_stack_view_create(obj, pkgname, app_control, noti_list);
-}
-
-
-
-void noti_panel_cover_view_set_content(Evas_Object *cover_view, notification_h notification)
-{
- Evas_Object *bg = NULL;
- Evas_Object *icon = NULL;
- char *icon_path = NULL;
- char *bg_path = NULL;
- char *title = NULL;
- char *content = NULL;
- char *text_time = NULL;
- char buf[128] = {0, };
-
- time_t time;
- notification_h noti_clone;
- notification_h noti;
-
- ret_if(!cover_view);
- ret_if(!notification);
-
- notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &bg_path);
- notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path);
- notification_get_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, &title);
- notification_get_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
- notification_get_time(notification, &time);
-
- if (bg_path && access(bg_path, R_OK) == 0) {
- _D("bg image is added");
- bg = elm_image_add(cover_view);
- ret_if(!bg);
-
- elm_image_file_set(bg, bg_path, NULL);
- elm_image_smooth_set(bg, EINA_TRUE);
- elm_object_part_content_set(cover_view, "bg,image", bg);
- elm_object_signal_emit(cover_view, "show", "bg");
- }
-
- if (!icon_path || access(icon_path, R_OK) != 0) {
- _E("Failed to access an icon(%s)", icon_path);
- icon_path = DEFAULT_ICON;
- }
-
- icon = elm_icon_add(cover_view);
- ret_if(!icon);
-
- if (elm_image_file_set(icon, icon_path, NULL) == EINA_FALSE) {
- _E("Icon file is not accessible (%s)", icon_path);
- evas_object_del(icon);
- } else {
- elm_image_preload_disabled_set(icon, EINA_TRUE);
- elm_image_smooth_set(icon, EINA_TRUE);
- elm_image_no_scale_set(icon, EINA_FALSE);
- }
- elm_object_part_content_set(cover_view, "icon", icon);
-
- if (title)
- elm_object_part_text_set(cover_view, "title_text", title);
-
- if (time) {
- notification_time_to_string(&time, buf, sizeof(buf));
- text_time = elm_entry_utf8_to_markup(buf);
-
- if (text_time) {
- elm_object_part_text_set(cover_view, "time_text", text_time);
- free(text_time);
- }
- }
-
- if (content)
- elm_object_part_text_set(cover_view, "content_text", content);
-
- notification_clone(notification, &noti_clone);
- ret_if(!noti_clone);
-
- noti = evas_object_data_get(cover_view, "noti");
- if (noti)
- notification_free(noti);
-
- evas_object_data_set(cover_view, "noti", noti_clone);
-}
-
-
-
-Evas_Object *noti_panel_cover_view_create(Evas_Object *page_view)
-{
- Evas_Object *cover_view = NULL;
-
- retv_if(!page_view, NULL);
-
- cover_view = elm_layout_add(page_view);
- retv_if(!cover_view, NULL);
-
- elm_layout_file_set(cover_view, COVER_EDJE_FILE, "coverview");
- evas_object_size_hint_weight_set(cover_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(cover_view);
-
- evas_object_event_callback_add(cover_view, EVAS_CALLBACK_MOUSE_DOWN, _down_cb, page_view);
- evas_object_event_callback_add(cover_view, EVAS_CALLBACK_MOUSE_MOVE, _move_cb, page_view);
- evas_object_event_callback_add(cover_view, EVAS_CALLBACK_MOUSE_UP, _up_cb, page_view);
- elm_object_signal_callback_add(cover_view, "clicked", "coverview", _coverview_clicked_cb, NULL);
- elm_object_signal_callback_add(cover_view, "clicked", "morebutton", _morebutton_clicked_cb, NULL);
-
- return cover_view;
-}
-
-
-
-void noti_panel_cover_view_destroy(Evas_Object *cover_view)
-{
- notification_h noti = NULL;
-
- ret_if(!cover_view);
-
- noti = evas_object_data_del(cover_view, "noti");
- if (noti) {
- notification_free(noti);
- }
-
- evas_object_event_callback_del(cover_view, EVAS_CALLBACK_MOUSE_DOWN, _down_cb);
- evas_object_event_callback_del(cover_view, EVAS_CALLBACK_MOUSE_MOVE, _move_cb);
- evas_object_event_callback_del(cover_view, EVAS_CALLBACK_MOUSE_UP, _up_cb);
- elm_object_signal_callback_del(cover_view, "clicked", "coverview", _coverview_clicked_cb);
- elm_object_signal_callback_del(cover_view, "clicked", "morebutton", _morebutton_clicked_cb);
- evas_object_del(cover_view);
-}
-
diff --git a/src/notification/noti_panel_mgr.c b/src/notification/noti_panel_mgr.c
deleted file mode 100755
index ae79a9d..0000000
--- a/src/notification/noti_panel_mgr.c
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <notification.h>
-#include <notification_internal.h>
-#include <notification_list.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "page.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "key.h"
-#include "clock_service.h"
-#include "notification/noti_panel_mgr.h"
-#include "notification/noti_panel_page_view.h"
-#include "notification/noti_panel_stack_view.h"
-#include "notification/noti_detail_view.h"
-
-#define FIRST_NOTI 0
-#define MAX_PAGE 50
-#define PRIVATE_DATA_KEY_LIST "p_list"
-#define PRIVATE_DATA_KEY_LIST_LATEST "p_list_h"
-#define PRIVATE_DATA_KEY_LIST_OLDEST "p_list_o"
-#define PRIVATE_DATA_KEY_PKGNAME "p_pkgname"
-#define PRIVATE_DATA_KEY_PAGE "p_page"
-
-static struct info {
- Eina_List *page_list;
- Eina_Hash *h_table;
- int first_noti;
-} s_info = {
- .page_list = NULL,
- .h_table = NULL,
- .first_noti = 1,
-};
-
-static Evas_Object *_push_coverview(notification_h notification, scroller_push_type_e push_type);
-
-
-
-static Evas_Object *_find_page(char *pkgname)
-{
- Evas_Object *page = NULL;
- Evas_Object *tmp = NULL;
- const Eina_List *l;
-
- retv_if(!pkgname, NULL);
-
- EINA_LIST_FOREACH(s_info.page_list, l, tmp) {
- page_info_s *page_info = NULL;
- continue_if(!tmp);
- page_info = evas_object_data_get(tmp, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
- continue_if(!page_info->id);
-
- if(!strcmp(pkgname, page_info->id)) {
- _D("find noti page(%s)", pkgname);
- page = tmp;
- break;
- }
- }
- return page;
-}
-
-
-
-Eina_Bool noti_panel_mgr_check_focused_page()
-{
- Evas_Object *tmp = NULL;
- const Eina_List *l;
-
- EINA_LIST_FOREACH(s_info.page_list, l, tmp) {
- page_info_s *page_info = NULL;
- continue_if(!tmp);
- page_info = evas_object_data_get(tmp, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
- continue_if(!page_info->id);
-
- if (!page_info->is_focused_page)
- return EINA_FALSE;
- }
- return EINA_TRUE;
-}
-
-
-
-static Eina_Bool _push_new_page(void *data)
-{
- Evas_Object *scroller = data;
- Evas_Object *page = NULL;
- notification_list_h next_noti = NULL;
- notification_list_h cur_noti = NULL;
- notification_list_h head = NULL;
- notification_h noti = NULL;
- char *pkgname = NULL;
- int priv_id = -1;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- cur_noti = evas_object_data_get(scroller, PRIVATE_DATA_KEY_LIST);
- goto_if(!cur_noti, END);
-
- noti = notification_list_get_data(cur_noti);
- notification_get_id(noti, NULL, &priv_id);
-
- if (!eina_hash_find(s_info.h_table, &priv_id)) {
- notification_get_pkgname(noti, &pkgname);
- goto_if(!pkgname, END);
-
- page = evas_object_data_get(scroller, PRIVATE_DATA_KEY_PAGE);
- if (page) {
- char *new_pkgname = NULL;
- new_pkgname = evas_object_data_get(scroller, PRIVATE_DATA_KEY_PKGNAME);
- if (new_pkgname) {
- if (!strcmp(new_pkgname, pkgname)) {
- eina_hash_add(s_info.h_table, &priv_id, page);
- }
- }
- } else {
- _D("push old page (%s:%d)", pkgname, priv_id);
- page = _push_coverview(noti, SCROLLER_PUSH_TYPE_FIRST);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_PAGE, page);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_PKGNAME, pkgname);
- }
- }
-
- next_noti = notification_list_get_next(cur_noti);
- if (!next_noti) {
- _D("list is end");
- goto END;
- }
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST, next_noti);
-
- return ECORE_CALLBACK_RENEW;
-END:
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_LIST);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_PAGE);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_PKGNAME);
-
- head = evas_object_data_del(scroller, PRIVATE_DATA_KEY_LIST_LATEST);
- notification_free_list(head);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static void _find_new_notification(Evas_Object *scroller)
-{
- notification_list_h noti_list = NULL;
-
- notification_get_list(NOTIFICATION_TYPE_NONE, -1, &noti_list);
- ret_if(!noti_list);
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST, noti_list);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST_LATEST, noti_list);
- ecore_timer_add(0.01f, _push_new_page, scroller);
-}
-
-
-
-static void _destroy_max_page(void *data)
-{
- Evas_Object *page = data;
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
- page_info_s *page_info = NULL;
- int page_count = FIRST_NOTI;
-
- ret_if(!page);
- ret_if(!win);
-
- page_count = eina_list_count(s_info.page_list);
- _D("page count : %d", page_count);
-
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- ret_if(!scroller);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- while(eina_hash_del_by_data(s_info.h_table, page));
-
- if (page_count <= 1) {
- noti_panel_page_view_unset_coverview(page_info->item);
- if (page_info->id) {
- free(page_info->id);
- page_info->id = NULL;
- }
- s_info.first_noti = 1;
- } else {
- s_info.page_list = eina_list_remove(s_info.page_list, page);
- scroller_pop_page(scroller, page);
- page_destroy(page);
- }
-}
-
-
-
-static void _destroy_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- Evas_Object *page = data;
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
- page_info_s *page_info = NULL;
- int ret = 0;
- int page_count = FIRST_NOTI;
-
- ret_if(!page);
- ret_if(!win);
-
- page_count = eina_list_count(s_info.page_list);
- _D("page count : %d", page_count);
-
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- ret_if(!scroller);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- while(eina_hash_del_by_data(s_info.h_table, page));
-
- ret = notification_delete_all_by_type(page_info->id, NOTIFICATION_TYPE_NOTI);
- if (ret != NOTIFICATION_ERROR_NONE)
- _E("Fail to delete all notification");
-
- if (page_count <= 1) {
- noti_panel_page_view_unset_coverview(page_info->item);
- if (page_info->id) {
- free(page_info->id);
- page_info->id = NULL;
- }
- s_info.first_noti = 1;
- } else {
- s_info.page_list = eina_list_remove(s_info.page_list, page);
- scroller_pop_page(scroller, page);
- page_destroy(page);
- if (page_count >= MAX_PAGE) {
- _find_new_notification(scroller);
- }
- }
-}
-
-
-
-void noti_panel_mgr_destroy_page(char *pkgid)
-{
- Evas_Object *page = NULL;
- ret_if(!pkgid);
-
- page = _find_page(pkgid);
-
- _destroy_cb(page, NULL, NULL, NULL);
-}
-
-
-
-static Evas_Object *_push_page(scroller_push_type_e push_type)
-{
- Evas_Object *page = NULL;
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!win, NULL);
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- retv_if(!layout, NULL);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- retv_if(!scroller, NULL);
-
- page = noti_panel_page_view_create(scroller);
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- elm_object_signal_callback_add(page_info->item, "destroy", "coverview", _destroy_cb, page);
-
- s_info.page_list = eina_list_append(s_info.page_list, page);
-
- scroller_push_page(scroller, page, push_type);
-
- return page;
-}
-
-
-
-static Evas_Object *_push_coverview(notification_h notification, scroller_push_type_e push_type)
-{
- Evas_Object *page = NULL;
- page_info_s *page_info = NULL;
- notification_list_h noti_list = NULL;
-
- char *pkgname = NULL;
- int priv_id = -1;
- int noti_count = FIRST_NOTI;
- int page_count = FIRST_NOTI;
-
- retv_if(!notification, NULL);
-
- notification_get_pkgname(notification, &pkgname);
- retv_if(!pkgname, NULL);
-
- notification_get_id(notification, NULL, &priv_id);
- page_count = eina_list_count(s_info.page_list);
-
- notification_get_detail_list(pkgname, -1, -1, 50, &noti_list);
- noti_count = notification_list_get_count(noti_list);
-
- if (s_info.first_noti == 1) {
- page = eina_list_nth(s_info.page_list, 0);
- retv_if(!page, NULL);
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
- page_info->id = strdup(pkgname);
- retv_if(!page_info->id, NULL);
- s_info.first_noti = 0;
- } else {
- page = _find_page(pkgname);
- if (page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
- } else {
- if (page_count >= MAX_PAGE) {
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
- Evas_Object *oldest_page = NULL;
-
- retv_if(!win, NULL);
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- retv_if(!layout, NULL);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- retv_if(!scroller, NULL);
-
- oldest_page = scroller_get_page_at(scroller, 0);
- retv_if(!oldest_page, NULL);
- _destroy_max_page(oldest_page);
- }
- page = _push_page(push_type);
- retv_if(!page, NULL);
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
- page_info->id = strdup(pkgname);
- retv_if(!page_info->id, NULL);
- }
- }
-
- noti_panel_page_view_set_coverview(page_info->item, notification, noti_count);
- eina_hash_add(s_info.h_table, &priv_id, page);
-
- return page;
-}
-
-
-
-static void _pop_coverview(int notification_id)
-{
- Evas_Object *page = NULL;
- notification_list_h noti_list = NULL;
- notification_h notification = NULL;
- page_info_s *page_info = NULL;
-
- int noti_count = FIRST_NOTI;
- int page_count = FIRST_NOTI;
-
- page = eina_hash_find(s_info.h_table, &notification_id);
- if (!page) {
- _D("notificaion(%d) can not find the page", notification_id);
- return;
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- notification_get_detail_list(page_info->id, -1, -1, 50, &noti_list);
- noti_count = notification_list_get_count(noti_list);
- page_count = eina_list_count(s_info.page_list);
-
- _D("page count : %d, noti_count : %d", page_count, noti_count);
-
- if (noti_count == FIRST_NOTI) {
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
-
- ret_if(!win);
-
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- ret_if(!scroller);
-
- if (page_count <= 1) {
- noti_panel_page_view_unset_coverview(page_info->item);
- if (page_info->id) {
- free(page_info->id);
- page_info->id = NULL;
- }
- s_info.first_noti = 1;
- } else {
- s_info.page_list = eina_list_remove(s_info.page_list, page);
- scroller_pop_page(scroller, page);
- page_destroy(page);
- if (page_count >= MAX_PAGE) {
- _find_new_notification(scroller);
- }
- }
- } else {
- notification = notification_list_get_data(noti_list);
- ret_if(!notification);
- noti_panel_page_view_set_coverview(page_info->item, notification, noti_count);
- }
- eina_hash_del(s_info.h_table, &notification_id, page);
-}
-
-
-
-void noti_panel_mgr_event_handler(notification_op_type_e operation_type, int notification_id, notification_h notification)
-{
- /* TODO : implement to add a notification to notification panel */
- switch (operation_type) {
- case NOTIFICATION_OP_INSERT: /**< Notification inserted */
- case NOTIFICATION_OP_UPDATE: /**< Notification updated */
- ret_if(!_push_coverview(notification, SCROLLER_PUSH_TYPE_CENTER_LEFT));
- break;
- case NOTIFICATION_OP_DELETE: /**< Notification deleted */
- _pop_coverview(notification_id);
- if (noti_panel_stack_view_is_visible())
- noti_panel_stack_view_pop_page(notification_id);
- break;
- case NOTIFICATION_OP_DELETE_ALL: /**< Notifications deleted */
- break;
- case NOTIFICATION_OP_SERVICE_READY: /**< Notification service is ready */
- break;
- case NOTIFICATION_OP_NONE:
- default:
- break;
- }
-}
-
-
-
-static key_cb_ret_e _noti_back_key_cb(void *data)
-{
- _D("");
-
- if (!noti_detail_view_is_open_more_option()) {
- if (noti_detail_view_is_open_detail_view_win()) {
- noti_panel_stack_view_set_rotary_event(EINA_TRUE);
- noti_detail_view_destroy();
- goto END;
- }
- if (noti_panel_stack_view_is_visible()) {
- noti_panel_stack_view_destroy();
- goto END;
- }
- }
-
- return KEY_CB_RET_CONTINUE;
-
-END:
- return KEY_CB_RET_STOP;
-}
-
-
-
-static key_cb_ret_e _noti_home_key_cb(void *data)
-{
- _D("");
-
- if (noti_detail_view_is_open_detail_view_win())
- noti_detail_view_destroy();
-
- if (noti_panel_stack_view_is_visible())
- noti_panel_stack_view_destroy();
-
- return KEY_CB_RET_CONTINUE;
-}
-
-
-
-static w_home_error_e _lang_changed_cb(void *data)
-{
- Evas_Object *page = NULL;
- page_info_s *page_info = NULL;
-
- _D("Language is changed");
-
- if (s_info.first_noti) {
- page = eina_list_nth(s_info.page_list, 0);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, W_HOME_ERROR_FAIL);
-
- noti_panel_page_view_set_no_noti_text(page_info->item);
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static Eina_Bool _push_pages(void *data)
-{
- Evas_Object *scroller = data;
- notification_list_h next_noti = NULL;
- notification_list_h cur_noti = NULL;
- notification_list_h head = NULL;
- notification_h noti = NULL;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- cur_noti = evas_object_data_get(scroller, PRIVATE_DATA_KEY_LIST);
- goto_if(!cur_noti, END);
-
- noti = notification_list_get_data(cur_noti);
- retv_if(!_push_coverview(noti, SCROLLER_PUSH_TYPE_CENTER_LEFT), ECORE_CALLBACK_RENEW);
-
- next_noti = notification_list_get_prev(cur_noti);
- if (!next_noti) {
- _D("list is end");
- goto END;
- }
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST, next_noti);
-
- return ECORE_CALLBACK_RENEW;
-END:
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_LIST);
- head = evas_object_data_del(scroller, PRIVATE_DATA_KEY_LIST_LATEST);
- notification_free_list(head);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static void _sync_noti_list(Evas_Object *scroller)
-{
- notification_list_h noti_list = NULL;
- notification_list_h noti_oldest = NULL;
-
- notification_get_list(NOTIFICATION_TYPE_NONE, -1, &noti_list);
- ret_if(!noti_list);
-
- noti_oldest = notification_list_get_tail(noti_list);
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST, noti_oldest);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST_LATEST, noti_list);
- ecore_timer_add(0.01f, _push_pages, scroller);
-}
-
-
-
-void noti_panel_mgr_init(void)
-{
- Evas_Object *page = NULL;
- Evas_Object *win = main_get_info()->win;
- Evas_Object *layout = NULL;
- Evas_Object *scroller = NULL;
- page_info_s *page_info = NULL;
- Eina_Hash *hash = NULL;
-
- ret_if(!win);
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- ret_if(!scroller);
-
- hash = eina_hash_int32_new(NULL);
- ret_if(!hash);
- s_info.h_table = hash;
-
- page = noti_panel_page_view_create(scroller);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- s_info.page_list = eina_list_append(s_info.page_list, page);
-
- elm_object_signal_callback_add(page_info->item, "destroy", "coverview", _destroy_cb, page);
-
- scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER_LEFT);
-
- s_info.first_noti = 1;
- _sync_noti_list(scroller);
- if (clock_service_check_noti_indicator_enable())
- clock_service_set_noti_indicator_icon();
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_BACK, _noti_back_key_cb, NULL)) {
- _E("Cannot register the key callback");
- }
-
- if (W_HOME_ERROR_NONE != key_register_cb(KEY_TYPE_HOME, _noti_home_key_cb, NULL)) {
- _E("Cannot register the key callback");
- }
-
- main_register_cb(APP_STATE_LANGUAGE_CHANGED, _lang_changed_cb, NULL);
-}
-
-
-
-void noti_panel_mgr_fini(void)
-{
- if (s_info.h_table)
- eina_hash_free(s_info.h_table);
- key_unregister_cb(KEY_TYPE_BACK, _noti_back_key_cb);
- key_unregister_cb(KEY_TYPE_HOME, _noti_home_key_cb);
- main_unregister_cb(APP_STATE_LANGUAGE_CHANGED, _lang_changed_cb);
-
- if (s_info.page_list) {
- eina_list_free(s_info.page_list);
- s_info.page_list = NULL;
- }
-}
diff --git a/src/notification/noti_panel_page_view.c b/src/notification/noti_panel_page_view.c
deleted file mode 100755
index 2f3536d..0000000
--- a/src/notification/noti_panel_page_view.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdbool.h>
-#include <Elementary.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "page_info.h"
-#include "page.h"
-#include "scroller_info.h"
-#include "scroller.h"
-
-#include "notification/noti_panel_mgr.h"
-#include "notification/noti_panel_page_view.h"
-#include "notification/noti_panel_cover_view.h"
-
-#define PAGE_EDJE_FILE EDJEDIR"/noti_panel_page_view.edj"
-
-
-
-Evas_Object *noti_panel_page_view_create(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Evas_Object *page_view = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!scroller, NULL);
-
- page_view = elm_layout_add(scroller);
- retv_if(!page_view, NULL);
-
- elm_layout_file_set(page_view, PAGE_EDJE_FILE, "page_view");
- evas_object_size_hint_weight_set(page_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(page_view);
- elm_object_part_text_set(page_view, "no,noti,text", _("IDS_IM_POP_NO_NOTIFICATION"));
- elm_object_part_text_set(page_view, "no,noti,title", _("IDS_IM_HEADER_SET_NOTIFICATION"));
-
- elm_object_signal_emit(page_view, "show", "no,noti");
-
- page = page_create(scroller
- , page_view
- , NULL
- , NULL
- , main_get_info()->root_w, main_get_info()->root_h
- , PAGE_CHANGEABLE_BG_OFF, PAGE_REMOVABLE_OFF);
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
- page_info->layout_longpress = 0;
-
- return page;
-}
-
-
-
-void noti_panel_page_view_set_coverview(Evas_Object *page_view, notification_h notification, int count)
-{
- Evas_Object *cover_view = NULL;
- char buf[BUFSZE] = {0, };
-
- ret_if(!page_view);
- ret_if(!notification);
-
- elm_object_signal_emit(page_view, "hide", "no,noti");
-
- cover_view = elm_object_part_content_get(page_view, "coverview");
- if (!cover_view) {
- cover_view = noti_panel_cover_view_create(page_view);
- ret_if(!cover_view);
-
- elm_object_part_content_set(page_view, "coverview", cover_view);
- }
- if (count > 1) {
- elm_object_signal_emit(cover_view, "show", "more");
- snprintf(buf, sizeof(buf), "%d", count);
- elm_object_part_text_set(cover_view, "more_text", buf);
- } else elm_object_signal_emit(cover_view, "hide", "more");
-
- noti_panel_cover_view_set_content(cover_view, notification);
-}
-
-
-
-void noti_panel_page_view_unset_coverview(Evas_Object *page_view)
-{
- Evas_Object *cover_view = NULL;
- ret_if(!page_view);
-
- cover_view = elm_object_part_content_unset(page_view, "coverview");
- if (cover_view)
- noti_panel_cover_view_destroy(cover_view);
-
- elm_object_signal_emit(page_view, "show", "no,noti");
- noti_panel_page_view_set_no_noti_text(page_view);
-}
-
-
-
-void noti_panel_page_view_set_no_noti_text(Evas_Object *page_view)
-{
- ret_if(!page_view);
-
- elm_object_part_text_set(page_view, "no,noti,text", _("IDS_IM_POP_NO_NOTIFICATION"));
- elm_object_part_text_set(page_view, "no,noti,title", _("IDS_IM_HEADER_SET_NOTIFICATION"));
-}
diff --git a/src/notification/noti_panel_stack_view.c b/src/notification/noti_panel_stack_view.c
deleted file mode 100755
index 9744651..0000000
--- a/src/notification/noti_panel_stack_view.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <efl_extension.h>
-#include <notification.h>
-#include <notification_list.h>
-#include <notification_internal.h>
-#include <stdbool.h>
-#include <package_manager.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "notification/noti_panel_stack_view.h"
-#include "notification/noti_detail_view.h"
-#include "notification/noti_action_buttons_view.h"
-#include "notification/noti_time.h"
-
-#define STACK_EDJE_FILE EDJEDIR"/noti_panel_stack_view.edj"
-#define PRIVATE_DATA_KEY_LIST "p_list"
-#define PRIVATE_DATA_KEY_LIST_HEAD "p_list_h"
-#define PRIVATE_DATA_KEY_ID "p_id"
-#define PRIVATE_DATA_KEY_NOTI "p_noti"
-
-static struct info {
- Evas_Object *stackview;
- Evas_Object *box;
- Evas_Object *circle_scroller;
-} s_info = {
- .stackview = NULL,
- .box = NULL,
- .circle_scroller = NULL,
-};
-
-
-
-static void _stackpage_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- notification_h noti = data;
- ret_if(!noti);
-
- noti_create_detail_view(noti, EINA_FALSE);
-}
-
-
-
-static void _stack_view_create_page(notification_h notification)
-{
- Evas_Object *layout = NULL;
- Evas_Object *bg = NULL;
- char *title = NULL;
- char *content = NULL;
- char *text_time = NULL;
- char buf[128] = {0, };
- time_t time;
- int priv_id = -1;
- notification_h noti_clone = NULL;
-
- ret_if(!notification);
-
- layout = elm_layout_add(s_info.box);
- ret_if(!layout);
-
- elm_layout_file_set(layout, STACK_EDJE_FILE, "stackpage");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_min_set(layout, 360, 360);
- evas_object_show(layout);
-
- bg = evas_object_rectangle_add(evas_object_evas_get(layout));
- evas_object_resize(bg, 360, 360);
- evas_object_size_hint_min_set(bg, 360, 360);
- evas_object_color_set(bg, 255, 255, 255, 0);
- elm_object_part_content_set(layout, "bg", bg);
-
- notification_get_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, &title);
- notification_get_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
- notification_get_time(notification, &time);
- notification_get_id(notification, NULL, &priv_id);
-
- if (title)
- elm_object_part_text_set(layout, "title_text", title);
-
- if (time) {
- notification_time_to_string(&time, buf, sizeof(buf));
- text_time = elm_entry_utf8_to_markup(buf);
-
- if (text_time) {
- elm_object_part_text_set(layout, "time_text", text_time);
- free(text_time);
- }
- }
-
- if (content)
- elm_object_part_text_set(layout, "content_text", content);
-
- notification_clone(notification, &noti_clone);
- ret_if(!noti_clone);
-
- evas_object_data_set(layout, PRIVATE_DATA_KEY_ID, (void *)priv_id);
- evas_object_data_set(layout, PRIVATE_DATA_KEY_NOTI, noti_clone);
-
- elm_object_signal_callback_add(layout, "clicked", "stackpage", _stackpage_clicked_cb, noti_clone);
-
- elm_box_pack_end(s_info.box, layout);
-}
-
-
-
-static void _stack_view_destroy_page(Evas_Object *layout)
-{
- notification_h noti_clone = NULL;
- ret_if(!layout);
-
- elm_object_signal_callback_del(layout, "clicked", "stackpage", _stackpage_clicked_cb);
-
- evas_object_data_del(layout, PRIVATE_DATA_KEY_ID);
- noti_clone = evas_object_data_del(layout, PRIVATE_DATA_KEY_NOTI);
- if (noti_clone) {
- notification_free(noti_clone);
- }
- evas_object_del(layout);
-}
-
-
-
-static Eina_Bool _push_pages(void *data)
-{
- Evas_Object *scroller = data;
- notification_list_h next_noti = NULL;
- notification_list_h cur_noti = NULL;
- notification_list_h head = NULL;
- notification_h noti = NULL;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- cur_noti = evas_object_data_get(scroller, PRIVATE_DATA_KEY_LIST);
- goto_if(!cur_noti, END);
-
- noti = notification_list_get_data(cur_noti);
- _stack_view_create_page(noti);
-
- next_noti = notification_list_get_next(cur_noti);
- if (!next_noti) {
- _D("list is end");
- goto END;
- }
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST, next_noti);
-
- return ECORE_CALLBACK_RENEW;
-END:
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_LIST);
- head = evas_object_data_del(scroller, PRIVATE_DATA_KEY_LIST_HEAD);
- notification_free_list(head);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-void noti_panel_stack_view_pop_page(int priv_id)
-{
- Eina_List *list = NULL;
- const Eina_List *l = NULL;
- Evas_Object *page = NULL;
- Evas_Object *temp_page = NULL;
-
- list = elm_box_children_get(s_info.box);
- EINA_LIST_FOREACH(list, l, temp_page) {
- int id = -1;
- continue_if(!temp_page);
- id = (int) evas_object_data_get(temp_page, PRIVATE_DATA_KEY_ID);
- if (id != -1 && id == priv_id) {
- page = temp_page;
- break;
- }
- }
- eina_list_free(list);
- elm_box_unpack(s_info.box, page);
- _stack_view_destroy_page(page);
-}
-
-static bool _stack_view_is_valid_package_id(const char *pkg_id)
-{
- bool ret = false;
- package_info_h pkg_info = NULL;
-
- _D("package_id [%s]", pkg_id);
-
- if (package_manager_get_package_info (pkg_id, &pkg_info) == PACKAGE_MANAGER_ERROR_NONE) {
- _D("package_manager_get_package_info returns true for [%s]", pkg_id);
- ret = true;
- }
-
- if (pkg_info)
- package_info_destroy(pkg_info);
-
- return ret;
-}
-
-static Evas_Object *_stack_view_create_scroller(Evas_Object *stack_view, char *pkgid, app_control_h app_control)
-{
- Evas_Object *circle_scroller = NULL;
- Evas_Object *scroller = NULL;
- Evas_Object *box = NULL;
-
- retv_if(!stack_view, NULL);
- retv_if(!pkgid, NULL);
-
- scroller = elm_scroller_add(stack_view);
- retv_if(!scroller, NULL);
-
- elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON);
- elm_scroller_page_size_set(scroller, 360, 408);
- elm_scroller_page_scroll_limit_set(scroller, 0, 1);
- evas_object_show(scroller);
-
- circle_scroller = eext_circle_object_scroller_add(scroller, NULL);
- evas_object_move(circle_scroller, 0, 0);
- evas_object_resize(circle_scroller, 360, 360);
- evas_object_show(circle_scroller);
- eext_circle_object_scroller_policy_set(circle_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
- eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE);
- s_info.circle_scroller = circle_scroller;
-
- box = elm_box_add(scroller);
- goto_if(!box, ERROR);
- elm_box_horizontal_set(box, EINA_FALSE);
- elm_box_padding_set(box, 0, 48);
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_align_set(box, 0.5, 0.0);
- evas_object_show(box);
-
- elm_object_content_set(scroller, box);
- s_info.box = box;
-
- evas_object_data_set(stack_view, DATA_KEY_APP_CONTROL, app_control);
- evas_object_data_set(stack_view, DATA_KEY_APP_ID, pkgid);
-
- /* If given pkg id is not available id, set DATA_KEY_PKG_VALIDITY with validity for hiding buttons */
- bool is_valid_pkg_id = _stack_view_is_valid_package_id(pkgid);
-
- evas_object_data_set(stack_view, DATA_KEY_PKG_VALIDITY, (const void*)is_valid_pkg_id);
-
- noti_create_more_option(stack_view, circle_scroller);
-
- return scroller;
-
-ERROR:
- evas_object_del(scroller);
- return NULL;
-}
-
-
-
-Evas_Object *noti_panel_stack_view_create(Evas_Object *parent, char *pkgname, app_control_h app_control, notification_list_h noti_list)
-{
- Evas_Object *stack_view = NULL;
- Evas_Object *scroller = NULL;
-
- if (s_info.stackview) {
- _D("stack button is already clicked");
- return NULL;
- }
-
- _D("Create a stack view");
-
- retv_if(!noti_list, NULL);
- retv_if(!pkgname, NULL);
-
- stack_view = elm_layout_add(parent);
- retv_if(!stack_view, NULL);
-
- elm_layout_file_set(stack_view, STACK_EDJE_FILE, "stackview");
- evas_object_move(stack_view, 0, 0);
- evas_object_resize(stack_view, 360, 360);
- evas_object_show(stack_view);
-
- scroller = _stack_view_create_scroller(stack_view, pkgname, app_control);
- goto_if(!scroller, ERROR);
- elm_object_part_content_set(stack_view, "scroller", scroller);
-
- s_info.stackview = stack_view;
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST, noti_list);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_LIST_HEAD, noti_list);
- ecore_timer_add(0.01f, _push_pages, scroller);
-
- return stack_view;
-
-ERROR:
- evas_object_del(stack_view);
-
- return NULL;
-}
-
-
-
-void noti_panel_stack_view_destroy(void)
-{
- Eina_List *list = NULL;
- Evas_Object *page = NULL;
- app_control_h app_control = NULL;
-
- list = elm_box_children_get(s_info.box);
- EINA_LIST_FREE(list, page) {
- continue_if(!page);
- _stack_view_destroy_page(page);
- }
-
- s_info.box = NULL;
-
- evas_object_del(s_info.circle_scroller);
- s_info.circle_scroller = NULL;
-
- app_control = evas_object_data_get(s_info.stackview, DATA_KEY_APP_CONTROL);
- if (app_control) {
- app_control_destroy(app_control);
- app_control = NULL;
- }
-
- evas_object_del(s_info.stackview);
- s_info.stackview = NULL;
-}
-
-
-
-Eina_Bool noti_panel_stack_view_is_visible(void)
-{
- if (s_info.stackview) {
- return EINA_TRUE;
- }
- return EINA_FALSE;
-}
-
-
-
-void noti_panel_stack_view_set_rotary_event(Eina_Bool enable)
-{
- if (s_info.circle_scroller)
- eext_rotary_object_event_activated_set(s_info.circle_scroller, enable);
-}
diff --git a/src/notification/noti_popup_full_view.c b/src/notification/noti_popup_full_view.c
deleted file mode 100755
index 3d340cd..0000000
--- a/src/notification/noti_popup_full_view.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <Elementary.h>
-#include <app_common.h>
-#include <notification.h>
-#include "util.h"
-#include "log.h"
-#include "main.h"
-#include "notification/noti_detail_view.h"
-
-#define _NOTI_FULL_POPUP_VIEW_EDJ_FILE EDJEDIR"/noti_popup_full_view.edj"
-#define _NOTI_FULL_POPUP_VIEW_GROUP "noti_popup_full_view"
-
-#define _NOTI_FULL_POPUP_VIEW_AUTO_REMOVAL_INTERVAL 8.0f
-
-static struct noti_full_popup_view_info_t {
- Evas_Object *noti_win;
- Evas_Object *noti_layout;
- Ecore_Timer *timer;
- notification_h notification;
-} _noti_full_popup_view_info = {
- .noti_win = NULL,
- .noti_layout = NULL,
- .timer = NULL,
- .notification = NULL,
-};
-
-static void _noti_full_popup_view_set_icon(Evas_Object *noti_layout, const char *icon_path)
-{
- Evas_Object *icon = NULL;
- Eina_Bool err = EINA_FALSE;
- char unknown_icon_path[PATH_MAX] = { 0, };
-
- if (noti_layout == NULL) {
- _E("invalid parameter");
- goto OUT;
- }
-
- icon = elm_icon_add(noti_layout);
- if (icon == NULL) {
- _E("elm_icon_add failed");
- goto OUT;
- }
- _D("icon_path [%s]", icon_path);
- if (icon_path == NULL){
- snprintf(unknown_icon_path, PATH_MAX, "%s/%s", app_get_resource_path(), "images/unknown.png");
- _D("unknown_icon_path[%s]", unknown_icon_path);
- err = elm_image_file_set(icon, unknown_icon_path, NULL);
- }
- else
- err = elm_image_file_set(icon, icon_path, NULL);
-
- if (err == EINA_FALSE) {
- _E("elm_image_file_set failed");
- goto OUT;
- }
-
- elm_image_smooth_set(icon, EINA_TRUE);
- elm_object_part_content_set(noti_layout, "icon", icon);
- evas_object_show(icon);
-
-OUT:
- return;
-}
-
-void _noti_full_popup_view_set_bg_image(Evas_Object *noti_layout, const char *bg_image_path)
-{
- Evas_Object *bg_image = NULL;
- Eina_Bool err = EINA_FALSE;
-
- if (noti_layout == NULL || bg_image_path == NULL) {
- _E("invalid parameter");
- goto OUT;
- }
- bg_image = elm_image_add(noti_layout);
-
- if (bg_image == NULL) {
- _E("elm_image_add failed");
- goto OUT;
- }
-
- err = elm_image_file_set(bg_image, bg_image_path, NULL);
-
- if (err == EINA_FALSE) {
- _E("elm_image_file_set failed");
- goto OUT;
- }
-
- elm_image_smooth_set(bg_image, EINA_TRUE);
- elm_object_part_content_set(noti_layout, "bg,image", bg_image);
- evas_object_show(bg_image);
-
-OUT:
- return;
-}
-static Evas_Object *_noti_full_popup_view_create_layout(Evas_Object *win)
-{
- Evas_Object *noti_layout = NULL;
- Eina_Bool err = EINA_FALSE;
-
- retv_if(!win, NULL);
-
- noti_layout = elm_layout_add(win);
- if (noti_layout == NULL) {
- _E("elm_layout_add failed");
- goto OUT;
- }
-
- err = elm_layout_file_set(noti_layout, _NOTI_FULL_POPUP_VIEW_EDJ_FILE, _NOTI_FULL_POPUP_VIEW_GROUP);
-
- if (err == EINA_FALSE) {
- _E("elm_layout_file_set failed");
- evas_object_del(noti_layout);
- goto OUT;
- }
-
- evas_object_size_hint_weight_set(noti_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-OUT:
- return noti_layout;
-}
-
-
-static Evas_Object *_noti_full_popup_view_create_win()
-{
- Evas_Object *noti_win = NULL;
-
- noti_win = elm_win_add(NULL, "noti_full_popup", ELM_WIN_BASIC);
- if (noti_win == NULL) {
- _E("elm_win_add failed");
- goto OUT;
- }
- elm_win_alpha_set(noti_win, EINA_FALSE);
- elm_win_title_set(noti_win, "noti_full_popup");
- elm_win_borderless_set(noti_win, EINA_TRUE);
- elm_win_autodel_set(noti_win, EINA_TRUE);
-
- evas_object_move(noti_win, 0, 0);
- evas_object_resize(noti_win, main_get_info()->root_w, main_get_info()->root_h);
-OUT:
- return noti_win;
-}
-
-int noti_full_popup_view_destroy()
-{
- int ret = W_HOME_ERROR_FAIL;
-
- if (_noti_full_popup_view_info.noti_win != NULL) {
- evas_object_del(_noti_full_popup_view_info.noti_win);
- _noti_full_popup_view_info.noti_win = NULL;
- ret = W_HOME_ERROR_NONE;
- }
-
- if (_noti_full_popup_view_info.timer != NULL) {
- ecore_timer_del(_noti_full_popup_view_info.timer);
- _noti_full_popup_view_info.timer = NULL;
- }
-
- if (_noti_full_popup_view_info.notification != NULL) {
- notification_free(_noti_full_popup_view_info.notification);
- _noti_full_popup_view_info.notification = NULL;
- }
- return ret;
-}
-
-static void _noti_popup_full_view_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- noti_create_detail_view(_noti_full_popup_view_info.notification, EINA_TRUE);
- noti_full_popup_view_destroy();
-}
-
-static Eina_Bool _noti_full_popup_view_auto_removal_timer_cb(void *data)
-{
- _noti_full_popup_view_info.timer = NULL;
- noti_full_popup_view_destroy();
- return EINA_FALSE;
-}
-
-int noti_full_popup_view_create(notification_h notification)
-{
- _D("Creating full popup view");
- int ret = W_HOME_ERROR_NONE;
- char *main_text = NULL;
- char *icon_path = NULL;
- char *bg_image_path = NULL;
- Evas_Object *noti_win = NULL;
- Evas_Object *noti_layout = NULL;
-
- if (notification == NULL) {
- _E("notification is null");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- if (_noti_full_popup_view_info.noti_win != NULL) {
- _E("noti_full_popup_view is already existing. Destroy that first.");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- /* DO NOT FREE main_text and icon_path. These will be freed by notification_free */
- ret = notification_get_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, &main_text);
- _D("notification_get_text returns [%d][%s]", ret, main_text);
- ret = notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path);
- _D("notification_get_image returns [%d][%s]", ret, icon_path);
- ret = notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &bg_image_path);
- _D("notification_get_image returns [%d][%s]", ret, bg_image_path);
-
- notification_clone(notification, &_noti_full_popup_view_info.notification);
-
- /* Create window */
- noti_win = _noti_full_popup_view_create_win();
- if (noti_win == NULL) {
- _E("_noti_full_popup_view_create_win failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_full_popup_view_info.noti_win = noti_win;
-
- /* Create layout */
- noti_layout = _noti_full_popup_view_create_layout(noti_win);
-
- if (noti_layout == NULL) {
- _E("noti_full_popup_view_create_layout failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_full_popup_view_info.noti_layout = noti_layout;
-
- elm_win_resize_object_add(noti_win, noti_layout);
-
- /* Set notification contents */
- elm_object_part_text_set(noti_layout, "main_text", main_text);
- _noti_full_popup_view_set_icon(noti_layout, icon_path);
- _noti_full_popup_view_set_bg_image(noti_layout, bg_image_path);
-
- /* Show notification window */
- evas_object_show(noti_layout);
- evas_object_show(noti_win);
- elm_win_activate(noti_win);
-
- /* Register callback for mouse events */
- elm_object_signal_callback_add(noti_layout, "clicked", "noti_popup_full_view", _noti_popup_full_view_clicked_cb, NULL);
-
- /* Register callback function for auto removal */
- ecore_timer_add(_NOTI_FULL_POPUP_VIEW_AUTO_REMOVAL_INTERVAL, _noti_full_popup_view_auto_removal_timer_cb, NULL);
-
-OUT:
- return ret;
-}
diff --git a/src/notification/noti_popup_mgr.c b/src/notification/noti_popup_mgr.c
deleted file mode 100755
index 0c48479..0000000
--- a/src/notification/noti_popup_mgr.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <notification.h>
-#include <notification_type.h>
-/* TODO: Remove below dependencies after removing of redundant files */
-#include <Ecore.h>
-#include <Elementary.h>
-
-#include "util.h"
-#include "main.h"
-#include "log.h"
-#include "key.h"
-#include "notification/noti_popup_mgr.h"
-#include "notification/noti_popup_small_view.h"
-#include "notification/noti_popup_full_view.h"
-
-static void _noti_popup_mgr_show_popup_window(notification_h notification)
-{
- int is_popup_full_required = 1;
-
- if (notification == NULL) {
- _E("invalid parameter");
- return;
- }
-
- /* When clock is focused, full popup should be shown. */
- is_popup_full_required = main_is_clock_focused();
-
- if (is_popup_full_required) {
- /* Destroy existing popup */
- noti_full_popup_view_destroy();
- /* And create new one */
- noti_full_popup_view_create(notification);
- }
- else {
- /* Destroy existing popup */
- noti_small_popup_view_destroy();
- /* And create new one */
- noti_small_popup_view_create(notification);
- }
-
- return;
-}
-
-void noti_popup_mgr_event_handler(notification_op_type_e operation_type, notification_h notification)
-{
- /* TODO : implement to pop a notification window up */
- switch (operation_type) {
- case NOTIFICATION_OP_INSERT: /**< Notification inserted */
- _noti_popup_mgr_show_popup_window(notification);
- break;
- case NOTIFICATION_OP_UPDATE: /**< Notification updated */
- break;
- case NOTIFICATION_OP_DELETE: /**< Notification deleted */
- break;
- case NOTIFICATION_OP_DELETE_ALL: /**< Notifications deleted */
- break;
- case NOTIFICATION_OP_SERVICE_READY: /**< Notification service is ready */
- break;
- case NOTIFICATION_OP_NONE:
- default:
- break;
- }
-}
-
-static key_cb_ret_e _noti_popup_mgr_key_cb(void *data)
-{
- int ret = W_HOME_ERROR_NONE;
-
- ret = noti_full_popup_view_destroy();
-
- if (ret != W_HOME_ERROR_NONE )
- ret = noti_small_popup_view_destroy();
-
- /* W_HOME_ERROR_NONE means there was a popup, so callback chain should be stop */
- _D("key event handler [%d]", ret);
-
- if (ret == W_HOME_ERROR_NONE)
- return KEY_CB_RET_STOP;
-
- return KEY_CB_RET_CONTINUE;
-}
-
-void noti_popup_mgr_init()
-{
- /* Register callback function for home and back button */
- key_register_cb(KEY_TYPE_HOME, _noti_popup_mgr_key_cb, NULL);
- key_register_cb(KEY_TYPE_BACK, _noti_popup_mgr_key_cb, NULL);
-}
-
-
-void noti_popup_mgr_fini()
-{
- key_unregister_cb(KEY_TYPE_HOME, _noti_popup_mgr_key_cb);
- key_unregister_cb(KEY_TYPE_BACK, _noti_popup_mgr_key_cb);
-}
diff --git a/src/notification/noti_popup_small_view.c b/src/notification/noti_popup_small_view.c
deleted file mode 100755
index 4cd22c8..0000000
--- a/src/notification/noti_popup_small_view.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <Elementary.h>
-#include <app_common.h>
-#include <notification.h>
-#include "util.h"
-#include "log.h"
-#include "main.h"
-#include "notification/noti_detail_view.h"
-
-#define _NOTI_SMALL_POPUP_VIEW_EDJ_FILE EDJEDIR"/noti_popup_small_view.edj"
-#define _NOTI_SMALL_POPUP_VIEW_GROUP "noti_popup_small_view"
-
-#define _NOTI_SMALL_POPUP_VIEW_AUTO_REMOVAL_INTERVAL 3.0f
-
-static struct noti_small_popup_view_info_t {
- Evas_Object *noti_win;
- Evas_Object *noti_layout;
- Ecore_Timer *timer;
- notification_h notification;
-} _noti_small_popup_view_info = {
- .noti_win = NULL,
- .noti_layout = NULL,
- .timer = NULL,
- .notification = NULL,
-};
-
-static void _noti_small_popup_view_set_icon(Evas_Object *noti_layout, const char *icon_path)
-{
- Evas_Object *icon = NULL;
- Eina_Bool err = EINA_FALSE;
- char unknown_icon_path[PATH_MAX] = { 0, };
-
- if (noti_layout == NULL) {
- _E("invalid parameter");
- goto OUT;
- }
-
- icon = elm_icon_add(noti_layout);
- if (icon == NULL) {
- _E("elm_icon_add failed");
- goto OUT;
- }
-
- if (icon_path == NULL){
- snprintf(unknown_icon_path, PATH_MAX, "%s/%s", app_get_resource_path(), "images/unknown.png");
- _D("unknown_icon_path[%s]", unknown_icon_path);
- err = elm_image_file_set(icon, unknown_icon_path, NULL);
- }
- else
- err = elm_image_file_set(icon, icon_path, NULL);
-
- if (err == EINA_FALSE) {
- _E("elm_image_file_set failed");
- goto OUT;
- }
-
- elm_image_smooth_set(icon, EINA_TRUE);
- elm_object_part_content_set(noti_layout, "icon", icon);
- evas_object_show(icon);
-
-OUT:
- return;
-}
-
-static Evas_Object *_noti_small_popup_view_create_layout(Evas_Object *win)
-{
- Evas_Object *noti_layout = NULL;
- Eina_Bool err = EINA_FALSE;
-
- retv_if(!win, NULL);
-
- noti_layout = elm_layout_add(win);
- if (noti_layout == NULL) {
- _E("elm_layout_add failed");
- goto OUT;
- }
-
- err = elm_layout_file_set(noti_layout, _NOTI_SMALL_POPUP_VIEW_EDJ_FILE, _NOTI_SMALL_POPUP_VIEW_GROUP);
-
- if (err == EINA_FALSE) {
- _E("elm_layout_file_set failed");
- evas_object_del(noti_layout);
- goto OUT;
- }
-
- evas_object_size_hint_weight_set(noti_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-OUT:
- return noti_layout;
-}
-
-
-static Evas_Object *_noti_small_popup_view_create_win()
-{
- Evas_Object *noti_win = NULL;
-
- noti_win = elm_win_add(NULL, "noti_small_popup", ELM_WIN_BASIC);
- if (noti_win == NULL) {
- _E("elm_win_add failed");
- goto OUT;
- }
- elm_win_alpha_set(noti_win, EINA_TRUE);
- elm_win_title_set(noti_win, "noti_small_popup");
- elm_win_borderless_set(noti_win, EINA_TRUE);
- elm_win_autodel_set(noti_win, EINA_TRUE);
-
- evas_object_move(noti_win, 0, 0);
- evas_object_resize(noti_win, main_get_info()->root_w, main_get_info()->root_h);
-OUT:
- return noti_win;
-}
-
-int noti_small_popup_view_destroy()
-{
- int ret = W_HOME_ERROR_FAIL;
-
- if (_noti_small_popup_view_info.noti_win != NULL) {
- evas_object_del(_noti_small_popup_view_info.noti_win);
- _noti_small_popup_view_info.noti_win = NULL;
- ret = W_HOME_ERROR_NONE;
- }
-
- if (_noti_small_popup_view_info.timer != NULL) {
- ecore_timer_del(_noti_small_popup_view_info.timer);
- _noti_small_popup_view_info.timer = NULL;
- }
-
- if (_noti_small_popup_view_info.notification != NULL) {
- notification_free(_noti_small_popup_view_info.notification);
- _noti_small_popup_view_info.notification = NULL;
- }
- return ret;
-}
-
-static void _noti_small_popup_view_empty_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- _D("_noti_small_popup_view_empty_clicked_cb");
- noti_small_popup_view_destroy();
-}
-
-static void _noti_small_popup_view_image_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- _D("_noti_small_popup_view_image_clicked_cb");
- noti_create_detail_view(_noti_small_popup_view_info.notification, EINA_TRUE);
- noti_small_popup_view_destroy();
-}
-
-static Eina_Bool _noti_small_popup_view_auto_removal_timer_cb(void *data)
-{
- _D("timer event");
- _noti_small_popup_view_info.timer = NULL;
- noti_small_popup_view_destroy();
- return EINA_FALSE;
-}
-
-int noti_small_popup_view_create(notification_h notification)
-{
- _D("Creating small popup view");
- int ret = W_HOME_ERROR_NONE;
- char *main_text = NULL;
- char *icon_path = NULL;
- Evas_Object *noti_win = NULL;
- Evas_Object *noti_layout = NULL;
-
- if (notification == NULL) {
- _E("notification is null");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- if (_noti_small_popup_view_info.noti_win != NULL) {
- _E("noti_small_popup_view is already existing. Destroy that first.");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- /* DO NOT FREE main_text and icon_path. These will be freed by notification_free */
- ret = notification_get_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, &main_text);
- _D("notification_get_text returns [%d][%s]", ret, main_text);
- ret = notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path);
- _D("notification_get_image returns [%d][%s]", ret, icon_path);
-
- notification_clone(notification, &_noti_small_popup_view_info.notification);
-
- /* Create window */
- noti_win = _noti_small_popup_view_create_win();
- if (noti_win == NULL) {
- _E("_noti_small_popup_view_create_win failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_small_popup_view_info.noti_win = noti_win;
-
- /* Create layout */
- noti_layout = _noti_small_popup_view_create_layout(noti_win);
-
- if (noti_layout == NULL) {
- _E("noti_small_popup_view_create_layout failed");
- ret = W_HOME_ERROR_FAIL;
- goto OUT;
- }
-
- _noti_small_popup_view_info.noti_layout = noti_layout;
-
- elm_win_resize_object_add(noti_win, noti_layout);
-
- /* Set notification contents */
- elm_object_part_text_set(noti_layout, "main_text", main_text);
- _noti_small_popup_view_set_icon(noti_layout, icon_path);
-
- /* Show notification window */
- evas_object_show(noti_layout);
- evas_object_show(noti_win);
- elm_win_activate(noti_win);
-
- /* Register callback for mouse events */
- elm_object_signal_callback_add(noti_layout, "empty_clicked",
- "noti_popup_small_view", _noti_small_popup_view_empty_clicked_cb, NULL);
- elm_object_signal_callback_add(noti_layout, "image_clicked",
- "noti_popup_small_view", _noti_small_popup_view_image_clicked_cb, NULL);
-
- /* Register callback function for auto removal */
- ecore_timer_add(_NOTI_SMALL_POPUP_VIEW_AUTO_REMOVAL_INTERVAL, _noti_small_popup_view_auto_removal_timer_cb, NULL);
-
-OUT:
- return ret;
-}
diff --git a/src/notification/noti_time.c b/src/notification/noti_time.c
deleted file mode 100755
index 668e24f..0000000
--- a/src/notification/noti_time.c
+++ /dev/null
@@ -1,733 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-#include <unistd.h>
-#include <glib.h>
-#include <system_settings.h>
-
-#include <utils_i18n.h>
-#include <string.h>
-
-#include "util.h"
-#include "log.h"
-
-#define BUF_FORMATTER 64
-
-
-
-static struct {
- char *timezone;
- char *locale;
-
- i18n_udatepg_h generator;
- i18n_udate_format_h formatter_time;
- i18n_udate_format_h formatter_ampm;
- i18n_udate_format_h formatter_time_24;
- i18n_udate_format_h formatter_date;
-
- int timeformat;
- Eina_Bool is_pre;
-} notification_time_s = {
- .timezone = NULL,
- .locale = NULL,
-
- .generator = NULL,
- .formatter_time = NULL,
- .formatter_ampm = NULL,
- .formatter_time_24 = NULL,
- .formatter_date = NULL,
-
- .timeformat = 0,
- .is_pre = EINA_FALSE,
-};
-
-
-
-static char *_get_timezone(void)
-{
- char *timezone = NULL;
-
- int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &timezone);
- if (ret < 0) {
- _E("fail to get the locale time zone value(%d)", ret);
- }
-
- if (!timezone) {
- _E("system settings fail to get value: time zone");
- }
- _D("time zone : %s", timezone);
-
- return timezone;
-}
-
-
-
-static char *_get_locale(void)
-{
- char *locale = NULL;
- int ret = -1;
-
- ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &locale);
- if (ret < 0) {
- _E("fail to get the locale country value(%d)", ret);
- return strdup("en_US");
- }
-
- if (!locale) {
- _E("system settings fail to get value: region format");
- return strdup("en_US");
- }
- _D("locale is %s", locale);
-
- return locale;
-}
-
-
-
-static int _get_timeformat(void)
-{
- bool val = false;
- int ret = -1;
-
- ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &val);
- if (ret < 0) {
- _E("fail to get the timeformat(%d)", ret);
- }
-
- return val;
-}
-
-
-
-static i18n_udatepg_h _get_generator(void)
-{
- i18n_udatepg_h generator = NULL;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- status = i18n_ulocale_set_default(NULL);
- retv_if(status != I18N_ERROR_NONE, NULL);
-
- status = i18n_udatepg_create(notification_time_s.locale, &generator);
- if (status != I18N_ERROR_NONE) {
- _E("udatepg_creation is failed");
- return NULL;
- }
-
- _D("Get a generator success");
-
- return generator;
-}
-
-
-
-static i18n_udate_format_h _get_time_formatter(void)
-{
- i18n_uchar u_pattern[BUF_FORMATTER] = {0, };
- i18n_uchar u_timezone[BUF_FORMATTER] = {0, };
- i18n_uchar u_best_pattern[BUF_FORMATTER] = {0, };
- i18n_udate_format_h formatter = NULL;
-
- char a_best_pattern[BUF_FORMATTER] = {0, };
- char *a_best_pattern_fixed = NULL;
- char *saveptr1 = NULL, *saveptr2 = NULL;
-
- int32_t u_best_pattern_capacity;
- int32_t best_pattern_len;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- /* only 12 format */
- if (!i18n_ustring_copy_ua_n(u_pattern, "h:mm", sizeof(u_pattern))) {
- _E("ustring_copy() is failed.");
- return NULL;
- }
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
-
- status = i18n_udatepg_get_best_pattern(notification_time_s.generator, u_pattern, i18n_ustring_get_length(u_pattern),
- u_best_pattern, u_best_pattern_capacity, &best_pattern_len);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- /* remove am/pm of best pattern */
- retv_if(!i18n_ustring_copy_au(a_best_pattern, u_best_pattern), NULL);
- _D("best pattern [%s]", a_best_pattern);
-
- a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &saveptr1);
- a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &saveptr2);
- _D("best pattern fixed [%s]", a_best_pattern_fixed);
-
- if (a_best_pattern_fixed) {
- /* exception - da_DK */
- if (strncmp(notification_time_s.locale, "da_DK", 5) == 0
- || strncmp(notification_time_s.locale, "mr_IN", 5) == 0){
-
- char *a_best_pattern_changed = g_strndup("h:mm", 4);
- _D("best pattern is changed [%s]", a_best_pattern_changed);
- if (a_best_pattern_changed) {
- i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_changed);
- g_free(a_best_pattern_changed);
- }
- }
- else {
- retv_if(!i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_fixed), NULL);
- }
- }
-
- /* change char to UChar */
- retv_if(!i18n_ustring_copy_n(u_pattern, u_best_pattern, sizeof(u_pattern)), NULL);
-
- /* get formatter */
- i18n_ustring_copy_ua_n(u_timezone, notification_time_s.timezone, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, notification_time_s.locale, u_timezone, -1,
- u_pattern, -1, &formatter);
- if (!formatter) {
- _E("time_create() is failed.%d", status);
-
- return NULL;
- }
-
- _D("getting time formatter success");
- return formatter;
-}
-
-
-
-static i18n_udate_format_h _get_time_formatter_24(void)
-{
- i18n_uchar u_pattern[BUF_FORMATTER] = {0,};
- i18n_uchar u_timezone[BUF_FORMATTER] = {0,};
- i18n_uchar u_best_pattern[BUF_FORMATTER] = {0,};
- i18n_udate_format_h formatter = NULL;
-
- char a_best_pattern[BUF_FORMATTER] = {0.};
- char *a_best_pattern_fixed = NULL;
- char *saveptr1 = NULL, *saveptr2 = NULL;
-
- int32_t u_best_pattern_capacity;
- int32_t best_pattern_len;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- /* only 12 format */
- if (!i18n_ustring_copy_ua_n(u_pattern, "H:mm", sizeof(u_pattern))) {
- _E("ustring_copy() is failed.");
- return NULL;
- }
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
-
- status = i18n_udatepg_get_best_pattern(notification_time_s.generator, u_pattern, i18n_ustring_get_length(u_pattern),
- u_best_pattern, u_best_pattern_capacity, &best_pattern_len);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- /* remove am/pm of best pattern */
- retv_if(!i18n_ustring_copy_au(a_best_pattern, u_best_pattern), NULL);
- _D("best pattern [%s]", a_best_pattern);
-
- a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &saveptr1);
- a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &saveptr2);
- _D("best pattern fixed [%s]", a_best_pattern_fixed);
-
- if (a_best_pattern_fixed) {
- /* exception - pt_BR(HH'h'mm), id_ID, da_DK */
- if (strncmp(a_best_pattern_fixed, "HH'h'mm", 7) == 0
- || strncmp(notification_time_s.locale, "id_ID", 5) == 0
- || strncmp(notification_time_s.locale, "da_DK", 5) == 0
- || strncmp(notification_time_s.locale, "mr_IN", 5) == 0) {
-
- char *a_best_pattern_changed = g_strndup("HH:mm", 5);
- _D("best pattern is changed [%s]", a_best_pattern_changed);
- if (a_best_pattern_changed) {
- i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_changed);
- g_free(a_best_pattern_changed);
- }
- }
- else {
- retv_if(!i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_fixed), NULL);
- }
- }
-
- /* change char to UChar */
- retv_if(!i18n_ustring_copy_n(u_pattern, u_best_pattern, sizeof(u_pattern)), NULL);
-
- /* get formatter */
- i18n_ustring_copy_ua_n(u_timezone, notification_time_s.timezone, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, notification_time_s.locale, u_timezone, -1,
- u_pattern, -1, &formatter);
- if (!formatter) {
- _E("time24_create() is failed.");
- return NULL;
- }
-
- _D("Getting time formatter success");
-
- return formatter;
-}
-
-
-
-static i18n_udate_format_h _get_date_formatter(void)
-{
- i18n_uchar u_timezone[BUF_FORMATTER] = {0, };
- i18n_uchar u_skeleton[BUF_FORMATTER] = {0, };
- i18n_uchar u_best_pattern[BUF_FORMATTER] = {0, };
- i18n_udate_format_h formatter = NULL;
-
- int32_t u_best_pattern_capacity;
- int32_t skeleton_len = 0;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- i18n_ustring_copy_ua_n(u_skeleton, "Md", strlen("Md"));
- skeleton_len = i18n_ustring_get_length(u_skeleton);
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
- status = i18n_udatepg_get_best_pattern(notification_time_s.generator, u_skeleton, skeleton_len,
- u_best_pattern, u_best_pattern_capacity, &status);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- if (strncmp(notification_time_s.locale, "fi_FI", 5) == 0) {
- char *a_best_pattern_changed = g_strndup("ccc, d. MMM", 11);
- _D("date formatter best pattern is changed [%s]", a_best_pattern_changed);
- if (a_best_pattern_changed) {
- i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_changed);
- g_free(a_best_pattern_changed);
- }
- }
-
- i18n_ustring_copy_ua_n(u_timezone, notification_time_s.timezone, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, notification_time_s.locale, u_timezone, -1, u_best_pattern, -1, &formatter);
-
- if (!formatter) {
- _E("udate_create() is failed.");
- return NULL;
- }
-
- _D("getting date formatter success");
-
- return formatter;
-
-}
-
-
-
-static i18n_udate_format_h _get_ampm_formatter(void)
-{
- i18n_uchar u_timezone[BUF_FORMATTER] = {0, };
- i18n_uchar u_skeleton[BUF_FORMATTER] = {0, };
- i18n_uchar u_best_pattern[BUF_FORMATTER] = {0, };
- i18n_udate_format_h formatter = NULL;
-
- char a_best_pattern[BUF_FORMATTER] = {0, };
- int32_t skeleton_len = 0;
- int32_t u_best_pattern_capacity;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- i18n_ustring_copy_ua_n(u_skeleton, "hhmm", strlen("hhmm"));
- skeleton_len = i18n_ustring_get_length(u_skeleton);
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
- status = i18n_udatepg_get_best_pattern(notification_time_s.generator, u_skeleton, skeleton_len,
- u_best_pattern, u_best_pattern_capacity, &status);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- i18n_ustring_copy_au(a_best_pattern, u_best_pattern);
- i18n_ustring_copy_ua(u_best_pattern, "a");
-
- if (a_best_pattern[0] == 'a') {
- notification_time_s.is_pre = EINA_TRUE;
- } else {
- notification_time_s.is_pre = EINA_FALSE;
- }
-
- /* get formatter */
- i18n_ustring_copy_ua_n(u_timezone, notification_time_s.timezone, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, notification_time_s.locale, u_timezone, -1, u_best_pattern, -1, &formatter);
- if (!formatter) {
- _E("ampm_create() is failed.");
- return NULL;
- }
-
- _D("getting ampm formatter success");
-
- return formatter;
-}
-
-
-
-static void _set_formatters(void)
-{
- notification_time_s.generator = _get_generator();
- notification_time_s.formatter_time = _get_time_formatter();
- notification_time_s.formatter_ampm = _get_ampm_formatter();
- notification_time_s.formatter_time_24 = _get_time_formatter_24();
- notification_time_s.formatter_date = _get_date_formatter();
-}
-
-
-
-static void _remove_formatters(void)
-{
- if (notification_time_s.generator) {
- i18n_udatepg_destroy(notification_time_s.generator);
- notification_time_s.generator = NULL;
- }
-
- if (notification_time_s.formatter_time) {
- i18n_udate_destroy(notification_time_s.formatter_time);
- notification_time_s.formatter_time = NULL;
- }
-
- if (notification_time_s.formatter_ampm) {
- i18n_udate_destroy(notification_time_s.formatter_ampm);
- notification_time_s.formatter_ampm = NULL;
- }
-
- if (notification_time_s.formatter_time_24) {
- i18n_udate_destroy(notification_time_s.formatter_time_24);
- notification_time_s.formatter_time_24 = NULL;
- }
-
- if (notification_time_s.formatter_date) {
- i18n_udate_destroy(notification_time_s.formatter_date);
- notification_time_s.formatter_date = NULL;
- }
-}
-
-
-
-static i18n_uchar *_uastrcpy(const char *chars)
-{
- int len = 0;
- i18n_uchar *str = NULL;
-
- len = strlen(chars);
- str = (i18n_uchar *) malloc(sizeof(i18n_uchar) *(len + 1));
- if (!str) {
- return NULL;
- }
-
- i18n_ustring_copy_ua(str, chars);
-
- return str;
-}
-
-
-
-static void _set_timezone(const char *timezone)
-{
- int ec = I18N_ERROR_NONE;
- i18n_uchar *str = NULL;
-
- ret_if(!timezone);
-
- str = _uastrcpy(timezone);
-
- ec = i18n_ucalendar_set_default_timezone(str);
- if (ec != I18N_ERROR_NONE) {
- _E("ucal_setDefaultTimeZone() FAILED");
- }
- free(str);
-}
-
-
-
-static void _time_changed_cb(system_settings_key_e key, void *data)
-{
- _D("System setting key : %d", key);
-
- if (notification_time_s.locale) {
- free(notification_time_s.locale);
- notification_time_s.locale = NULL;
- }
- notification_time_s.locale = _get_locale();
-
- if (notification_time_s.timezone) {
- free(notification_time_s.timezone);
- notification_time_s.timezone = NULL;
- }
- notification_time_s.timezone = _get_timezone();
- notification_time_s.timeformat = _get_timeformat();
- _set_timezone(notification_time_s.timezone);
-
- _D("[%d][%s][%s]", notification_time_s.timeformat, notification_time_s.locale, notification_time_s.timezone);
-
- _remove_formatters();
- _set_formatters();
-}
-
-
-
-static void _register_settings(void)
-{
- int ret = -1;
-
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, _time_changed_cb, NULL);
- if (ret < 0) {
- _E("Failed to set time changed cb.(%d)", ret);
- }
-
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, _time_changed_cb, NULL);
- if (ret < 0) {
- _E("Failed to set language setting's changed cb.(%d)", ret);
- }
- notification_time_s.locale = _get_locale();
-
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, _time_changed_cb, NULL);
- if (ret < 0) {
- _E("Failed to set time zone change cb(%d)", ret);
- }
- notification_time_s.timezone = _get_timezone();
-
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, _time_changed_cb, NULL);
- if (ret < 0) {
- _E("Failed to set time format about 24 hour changed cb(%d).", ret);
- }
- notification_time_s.timeformat = _get_timeformat();
-}
-
-
-
-static void _unregister_settings(void)
-{
- int ret = -1;
-
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED);
- if (ret < 0) {
- _E("Failed to unset time changed(%d).", ret);
- }
-
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE);
- if (ret < 0) {
- _E("Failed to unset locale language(%d).", ret);
- }
-
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE);
- if (ret < 0) {
- _E("Failed to unset time zone changed cb(%d).", ret);
- }
-
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR);
- if (ret < 0) {
- _E("Failed to unset locale time format about 24 hour(%d).", ret);
- }
-}
-
-
-
-static int _get_date(time_t *intime, char *buf, int buf_len)
-{
- i18n_udate u_time = (i18n_udate)(*intime) * 1000;
- i18n_uchar u_formatted_str[BUF_FORMATTER] = {0, };
- int32_t u_formatted_str_capacity;
- int32_t formatted_str_len = -1;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- u_formatted_str_capacity =
- (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
-
- status = i18n_udate_format_date(notification_time_s.formatter_date, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- if (status != I18N_ERROR_NONE) {
- _E("udat_format() failed");
- return -1;
- }
-
- if (formatted_str_len <= 0) {
- _E("formatted_str_len is less than 0");
- }
-
- buf = i18n_ustring_copy_au_n(buf, u_formatted_str, (int32_t)buf_len);
- _SD("date:(%d)[%s][%d]", formatted_str_len, buf, *intime);
-
- return 0;
-}
-
-
-
-static int _get_ampm(time_t *intime, char *buf, int buf_len, int *ampm_len)
-{
- i18n_udate u_time = (i18n_udate) (*intime) * 1000;
- i18n_uchar u_formatted_str[BUF_FORMATTER] = {0,};
- int32_t u_formatted_str_capacity;
- int32_t formatted_str_len = -1;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- retv_if(!notification_time_s.formatter_ampm, -1);
-
- /* calculate formatted string capacity */
- u_formatted_str_capacity =
- (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
-
- /* formatting date using formatter */
- status = i18n_udate_format_date(notification_time_s.formatter_ampm, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- if (status != I18N_ERROR_NONE) {
- _E("udat_format() failed");
- return -1;
- }
-
- if (formatted_str_len <= 0) {
- _E("formatted_str_len is less than 0");
- }
-
-
- (*ampm_len) = i18n_ustring_get_length(u_formatted_str);
-
- buf = i18n_ustring_copy_au_n(buf, u_formatted_str, (int32_t)buf_len);
- _SD("ampm:(%d)[%s][%d]", formatted_str_len, buf, *intime);
-
- return 0;
-}
-
-
-
-static int _get_time(time_t *intime, char *buf, int buf_len, Eina_Bool is_time_24)
-{
- i18n_udate u_time = (i18n_udate) (*intime) * 1000;
- i18n_uchar u_formatted_str[BUF_FORMATTER] = {0,};
- int32_t u_formatted_str_capacity;
- int32_t formatted_str_len = -1;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- /* calculate formatted string capacity */
- u_formatted_str_capacity =
- (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
-
- /* fomatting date using formatter */
- if (is_time_24) {
- retv_if(notification_time_s.formatter_time_24 == NULL, -1);
- status = i18n_udate_format_date(notification_time_s.formatter_time_24, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- } else {
- retv_if(notification_time_s.formatter_time == NULL, -1);
- status = i18n_udate_format_date(notification_time_s.formatter_time, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- }
- if (status != I18N_ERROR_NONE) {
- _E("udat_format() failed");
- return -1;
- }
-
- if (formatted_str_len <= 0)
- _E("formatted_str_len is less than 0");
-
- buf = i18n_ustring_copy_au_n(buf, u_formatted_str, (int32_t)buf_len);
- _SD("time:(%d)[%s][%d]", formatted_str_len, buf, *intime);
-
- return 0;
-}
-
-static Eina_Bool _check_date(time_t *intime)
-{
- Eina_Bool result = EINA_FALSE;
-
- time_t current_time;
- char intime_date[128] = {0, };
- char current_date[128] = {0, };
-
- time(&current_time);
-
- _get_date(intime, intime_date, sizeof(intime_date));
- _get_date(&current_time, current_date, sizeof(current_date));
-
- if (!strcmp(intime_date, current_date))
- result = EINA_TRUE;
-
- return result;
-}
-
-w_home_error_e notification_time_to_string(time_t *time, char *string, int len)
-{
- char utc_date[BUFSZE] = {0, };
- char utc_time[BUFSZE] = {0, };
- char utc_ampm[BUFSZE] = {0, };
- char *time_str = NULL;
-
- int ampm_length = 0;
- Eina_Bool is_24hour = EINA_FALSE;
- Eina_Bool is_same_day = EINA_FALSE;
-
- retv_if(!string, W_HOME_ERROR_FAIL);
-
- _get_date(time, utc_date, sizeof(utc_date));
- if (notification_time_s.timeformat) {
- _get_time(time, utc_time, sizeof(utc_time), EINA_TRUE);
- is_24hour = EINA_TRUE;
- } else {
- _get_ampm(time, utc_ampm, sizeof(utc_ampm), &ampm_length);
- _get_time(time, utc_time, sizeof(utc_time), EINA_FALSE);
- is_24hour = EINA_FALSE;
- }
-
- _D("utc_date=%s, utc_time=%s, utc_ampm=[%d]%s", utc_date, utc_time, ampm_length, utc_ampm);
-
- is_same_day = _check_date(time);
-
- if (is_24hour == EINA_TRUE){
- time_str = g_strdup(utc_time);
- } else {
- if (notification_time_s.is_pre == EINA_TRUE) {
- if (is_same_day == EINA_TRUE)
- time_str = g_strdup_printf("%s %s", utc_ampm, utc_time);
- else
- time_str = g_strdup_printf("%s %s %s", utc_date, utc_ampm, utc_time);
- } else {
- if (is_same_day == EINA_TRUE)
- time_str = g_strdup_printf("%s %s", utc_time, utc_ampm);
- else
- time_str = g_strdup_printf("%s %s %s", utc_date, utc_time, utc_ampm);
- }
- }
- _D("time_str=%s", time_str);
-
- strncpy(string, time_str, len);
- string[len-1] = '\0';
- g_free(time_str);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-void notification_time_init(void)
-{
- _register_settings();
- _set_formatters();
-}
-
-
-
-void notification_time_fini(void)
-{
- _remove_formatters();
- _unregister_settings();
-}
-
-
-
diff --git a/src/page.c b/src/page.c
deleted file mode 100755
index ee4e4c7..0000000
--- a/src/page.c
+++ /dev/null
@@ -1,998 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <app.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <bundle.h>
-#include <dlog.h>
-#include <vconf.h>
-#include <widget_viewer_evas.h>
-
-#include "util.h"
-#include "conf.h"
-#include "edit.h"
-#include "edit_info.h"
-#include "effect.h"
-#include "layout.h"
-#include "layout_info.h"
-#include "log.h"
-#include "main.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "page.h"
-#include "scroller.h"
-#include "index.h"
-#include "bg.h"
-#include "add-viewer_package.h"
-
-#define PRIVATE_DATA_KEY_PAGE_ACCESS_OBJECT "pg_pd_ao"
-#define PRIVATE_DATA_KEY_PAGE_FOCUS_OBJECT "p_fo"
-#define PRIVATE_DATA_KEY_PAGE_LEFT_EFFECT "p_le"
-#define PRIVATE_DATA_KEY_PAGE_RIGHT_EFFECT "p_re"
-
-
-
-static void _move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *page = obj;
- page_info_s *page_info = NULL;
- Evas_Coord x, y, w, h;
-
- ret_if(!page);
-
- evas_object_geometry_get(page, &x, &y, &w, &h);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- page_info->appended = EINA_TRUE;
- _D("Page(%p) is appended into the scroller (%d:%d:%d:%d)", page, x, y, w, h);
-
- evas_object_event_callback_del(page, EVAS_CALLBACK_MOVE, _move_cb);
-}
-
-
-
-static void _down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Down *ei = event_info;
- Evas_Object *page = data;
-
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- int x = ei->output.x;
- int y = ei->output.y;
-
- _D("Down (%p)(%d, %d)", page, x, y);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- layout_info->pressed_page = page;
- layout_info->pressed_item = page_info->item;
- if (layout_info->pressed_page == scroller_info->plus_page) {
- evas_object_data_set(layout_info->pressed_item, DATA_KEY_IS_LONGPRESS, (void *)0);
- }
-}
-
-
-
-static void _up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Up *ei = event_info;
- Evas_Object *page = data;
-
- layout_info_s *layout_info = NULL;
- page_info_s *page_info = NULL;
-
- int x = ei->output.x;
- int y = ei->output.y;
-
- _D("Up (%p)(%d, %d)", page, x, y);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- layout_info->pressed_page = page;
- layout_info->pressed_item = NULL;
-
- if (evas_object_data_get(page, DATA_KEY_PAGE_ONHOLD_COUNT)) {
- evas_object_data_del(page, DATA_KEY_PAGE_ONHOLD_COUNT);
- ei->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
- _D("Event ON_HOLD flag set on a page(%p)", page);
- }
-}
-
-
-
-HAPI void page_destroy(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_del(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- evas_object_del(page_info->focus);
- evas_object_del(page_info->page_inner_area);
- evas_object_del(page_info->page_inner_bg);
-
- evas_object_data_del(page_info->page_inner, PRIVATE_DATA_KEY_PAGE_ACCESS_OBJECT);
- evas_object_data_del(page_info->page_inner, DATA_KEY_PAGE_INFO);
- evas_object_del(page_info->page_inner);
- evas_object_del(page_info->page_rect);
-
- evas_object_data_del(page, DATA_KEY_EVENT_UPPER_IS_ON);
-
- free(page_info->id);
- free(page_info->subid);
- free(page_info->title);
- free(page_info);
- evas_object_del(page);
-}
-
-
-
-static char *_access_page_num_cb(void *data, Evas_Object *obj)
-{
- Evas_Object *scroller = data;
- Evas_Object *page = NULL;
- page_info_s *page_info = NULL;
- scroller_info_s *scroller_info = NULL;
- Eina_List *list = NULL;
- int count = 0;
- int cur = 0;
- char number[BUFSZE];
- char *tmp;
-
- retv_if(NULL == scroller, NULL);
-
- page = scroller_get_focused_page(scroller);
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- if (PAGE_DIRECTION_CENTER == page_info->direction) {
- _D("This page is the center page");
- return NULL;
- }
-
- if (widget_viewer_evas_is_widget(page_get_item(page)) == 1) {
- if (page_info->need_to_read == EINA_FALSE) {
- return NULL;
- }
-
- if (page_info->need_to_unhighlight == EINA_TRUE) {
- return NULL;
- }
-
- if (!widget_viewer_evas_is_faulted(page_info->item)) {
- page_info->need_to_read = EINA_FALSE;
- }
- }
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, NULL);
-
- count = eina_list_count(list);
- cur = scroller_seek_page_position(scroller, page) + 1;
-
- snprintf(number, sizeof(number), _("IDS_AT_BODY_PAGE_P1SD_OF_P2SD_T_TTS"), cur, count);
-
- tmp = strdup(number);
- if (!tmp) return NULL;
- return tmp;
-}
-
-
-
-static char *_access_plus_button_name_cb(void *data, Evas_Object *obj)
-{
- char *tmp;
-
- tmp = strdup(_("IDS_HS_BODY_ADD_WIDGET"));
- retv_if(!tmp, NULL);
- return tmp;
-}
-
-
-
-#define PAGE_EDJE_FILE EDJEDIR"/page.edj"
-HAPI Evas_Object *page_create(Evas_Object *scroller
- , Evas_Object *item
- , const char *id
- , const char *subid
- , int width, int height
- , page_changeable_bg_e changeable_bg
- , page_removable_e removable)
-{
- Evas_Object *page = NULL;
- Evas_Object *focus = NULL;
- Evas_Object *page_rect = NULL;
- Evas_Object *page_inner = NULL;
- Evas_Object *page_inner_area = NULL;
- Evas_Object *page_inner_bg = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- page = elm_layout_add(scroller);
- retv_if(!page, NULL);
- elm_layout_file_set(page, PAGE_EDJE_FILE, "page");
- /* Do not have weight for unpacking from elm_box */
- evas_object_size_hint_weight_set(page, 0.0, EVAS_HINT_EXPAND);
- evas_object_size_hint_min_set(page, width, height);
- evas_object_move(page, -10000, -10000);
- evas_object_show(page);
- evas_object_event_callback_add(page, EVAS_CALLBACK_MOVE, _move_cb, NULL);
-
- page_info = calloc(1, sizeof(page_info_s));
- if (!page_info) {
- _E("Cannot calloc for page_info");
- evas_object_del(page);
- return NULL;
- }
- evas_object_data_set(page, DATA_KEY_PAGE_INFO, page_info);
- evas_object_data_set(page, DATA_KEY_EVENT_UPPER_IS_ON, (void *) 1);
-
- page_rect = evas_object_rectangle_add(main_get_info()->e);
- goto_if(!page_rect, ERROR);
- evas_object_size_hint_min_set(page_rect, width, height);
- evas_object_show(page_rect);
- elm_object_part_content_set(page, "bg", page_rect);
- evas_object_color_set(page_rect, 0, 0, 0, 0);
-
- page_inner = elm_layout_add(scroller);
- goto_if(NULL == page_inner, ERROR);
- elm_layout_file_set(page_inner, PAGE_EDJE_FILE, "page_inner");
- evas_object_size_hint_weight_set(page_inner, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_repeat_events_set(page_inner, EINA_TRUE);
- evas_object_show(page_inner);
- elm_object_part_content_set(page, "inner", page_inner);
- evas_object_event_callback_add(page_inner, EVAS_CALLBACK_MOUSE_DOWN, _down_cb, page);
- evas_object_event_callback_add(page_inner, EVAS_CALLBACK_MOUSE_UP, _up_cb, page);
- evas_object_data_set(page_inner, DATA_KEY_PAGE_INFO, page_info);
-
- page_inner_area = evas_object_rectangle_add(main_get_info()->e);
- goto_if(!page_inner_area, ERROR);
- evas_object_size_hint_min_set(page_inner_area, width, height);
- evas_object_resize(page_inner_area, width, height);
- evas_object_color_set(page_inner_area, 0, 0, 0, 0);
- evas_object_repeat_events_set(page_inner_area, EINA_TRUE);
- evas_object_show(page_inner_area);
- elm_object_part_content_set(page_inner, "area", page_inner_area);
-
- page_inner_bg = evas_object_rectangle_add(main_get_info()->e);
- goto_if(!page_inner_bg, ERROR);
- evas_object_size_hint_weight_set(page_inner_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_color_set(page_inner_bg, 0, 0, 0, 0);
- evas_object_repeat_events_set(page_inner_bg, EINA_TRUE);
- evas_object_show(page_inner_bg);
- elm_object_part_content_set(page_inner, "bg", page_inner_bg);
-
- if (item) {
- elm_object_part_content_set(page_inner, "item", item);
- }
-
- if (id) {
- page_info->id = strdup(id);
- if (!page_info->id) {
- _E("Critical, cannot strdup for id");
- }
- }
-
- if (subid) {
- page_info->subid = strdup(subid);
- if (!page_info->subid) {
- _E("Critical, cannot strdup for subid");
- }
- }
-
- if (changeable_bg) {
- bg_register_object(page_inner);
- }
-
- evas_object_data_set(page_inner, PRIVATE_DATA_KEY_PAGE_ACCESS_OBJECT, NULL);
-
- focus = elm_button_add(page_inner);
- retv_if(NULL == focus, NULL);
-
- elm_object_theme_set(focus, main_get_info()->theme);
- elm_object_style_set(focus, "transparent");
- elm_object_part_content_set(page_inner, "focus", focus);
-
- elm_access_info_cb_set(focus, ELM_ACCESS_TYPE, NULL, NULL);
- elm_access_info_cb_set(focus, ELM_ACCESS_STATE, _access_page_num_cb, scroller);
- evas_object_size_hint_weight_set(focus, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_focus_allow_set(focus, EINA_TRUE);
-
- page_info->width = width;
- page_info->height = height;
-
- page_info->layout = scroller_info->layout;
- page_info->scroller = scroller;
- page_info->page = page;
- page_info->page_rect = page_rect;
- page_info->page_inner = page_inner;
- page_info->page_inner_area = page_inner_area;
- page_info->page_inner_bg = page_inner_bg;
- page_info->item = item;
- page_info->removable = removable;
- page_info->focus = focus;
- page_info->layout_longpress = 1;
- page_info->appended = EINA_FALSE;
- page_info->need_to_read = EINA_FALSE;
- page_info->highlighted = EINA_FALSE;
-
- return page;
-
-ERROR:
- page_destroy(page);
- return NULL;
-}
-
-
-
-static void _plus_item_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- Evas_Object *layout = data;
- layout_info_s *layout_info = NULL;
-
- ret_if(!layout);
-
- _D("clicked plus page");
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- if (evas_object_data_get(obj, DATA_KEY_IS_LONGPRESS)) return;
-
- if (layout_info->pressed_item) {
- _D("There is already a pressed item");
- widget_viewer_evas_feed_mouse_up_event(layout_info->pressed_item);
- }
-
- scroller_remove_index_hide_timer(layout_info->scroller);
-
- if (!edit_create_add_viewer(layout)) _E("Cannot add the add-viewer");
-
- effect_play_sound();
-}
-
-
-
-static void _plus_item_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->item);
-
- elm_object_signal_emit(page_info->item, "press", "plus");
- elm_object_signal_emit(page_info->item, "press", "plus_ef");
-}
-
-
-
-static void _plus_item_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->item);
-
- elm_object_signal_emit(page_info->item, "release", "plus");
-}
-
-
-
-#define PLUS_ITEM_EDJ EDJEDIR"/page.edj"
-#define PLUS_ITEM_GROUP "plus_item"
-HAPI Evas_Object *page_create_plus_page(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Evas_Object *plus_item = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- Eina_Bool ret;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
- retv_if(scroller_info->plus_page, NULL);
-
- plus_item = elm_layout_add(scroller);
- retv_if(!plus_item, NULL);
-
- ret = elm_layout_file_set(plus_item, PLUS_ITEM_EDJ, PLUS_ITEM_GROUP);
- if (EINA_FALSE == ret) {
- _E("cannot set the file into the layout");
- evas_object_del(plus_item);
- return NULL;
- }
- evas_object_size_hint_weight_set(plus_item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(plus_item, 0.5, 0.5);
- evas_object_repeat_events_set(plus_item, EINA_TRUE);
- evas_object_show(plus_item);
- evas_object_data_set(plus_item, DATA_KEY_IS_LONGPRESS, (void *)0);
-
- elm_object_part_text_set(plus_item, "plus_text", _("IDS_HS_BODY_ADD_WIDGET"));
-
-#if !CIRCLE_TYPE
- elm_object_signal_emit(plus_item, "emul,normal", "plus");
-#endif
-
- page = page_create(scroller, plus_item, NULL, NULL, scroller_info->page_width, scroller_info->page_height, PAGE_CHANGEABLE_BG_OFF, PAGE_REMOVABLE_OFF);
- if (!page) {
- _E("Cannot create the page");
- evas_object_del(plus_item);
- return NULL;
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- goto_if(!page_info, ERROR);
- page_info->layout_longpress = 0;
-
- elm_access_info_cb_set(page_info->focus, ELM_ACCESS_INFO, _access_plus_button_name_cb, NULL);
- scroller_info->plus_page = page;
-
- elm_object_signal_emit(plus_item, "show,widget", "plus_item");
- elm_object_signal_callback_add(plus_item, "down", "plus_item", _plus_item_down_cb, page);
- elm_object_signal_callback_add(plus_item, "up", "plus_item", _plus_item_up_cb, page);
- elm_object_signal_callback_add(plus_item, "click", "plus_item", _plus_item_clicked_cb, page_info->layout);
-
-
-
- return page;
-
-ERROR:
- evas_object_del(page);
-
- return NULL;
-}
-
-
-
-HAPI void page_destroy_plus_page(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- page_info = evas_object_data_get(scroller_info->plus_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- evas_object_data_del(page_info->item, DATA_KEY_IS_LONGPRESS);
-
- evas_object_del(page_info->item);
- page_destroy(scroller_info->plus_page);
-
- scroller_info->plus_page = NULL;
-}
-
-
-
-HAPI void page_arrange_plus_page(Evas_Object *scroller, int toast_popup)
-{
- scroller_info_s *scroller_info = NULL;
- int count = 0;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- count = scroller_count_direction(scroller, PAGE_DIRECTION_RIGHT);
- if (count > MAX_WIDGET) {
- if (scroller_info->plus_page) {
- char text[TEXT_LEN] = {0, };
-
- scroller_pop_page(scroller, scroller_info->plus_page);
- page_destroy_plus_page(scroller);
-
- if (toast_popup) {
- snprintf(text, sizeof(text), _("IDS_HS_TPOP_MAXIMUM_NUMBER_OF_WIDGETS_HPD_REACHED"), MAX_WIDGET);
- util_create_toast_popup(scroller, text);
- }
- } else {
- /* Leave me alone */
- }
- } else if (count == MAX_WIDGET) {
- /* Leave me alone */
- } else {
- if (scroller_info->plus_page) {
- /* Leave me alone */
- scroller_pop_page(scroller, scroller_info->plus_page);
- scroller_push_page(scroller, scroller_info->plus_page, SCROLLER_PUSH_TYPE_LAST);
- } else {
- page_create_plus_page(scroller);
- page_set_effect(scroller_info->plus_page, page_effect_none, page_effect_none);
- scroller_push_page(scroller, scroller_info->plus_page, SCROLLER_PUSH_TYPE_LAST);
- }
- }
-}
-
-
-
-Evas_Object *page_set_item(Evas_Object *page, Evas_Object *item)
-{
- Evas_Object *old_item = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!page, NULL);
- retv_if(!item, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- old_item = elm_object_part_content_unset(page_info->page_inner, "item");
- if (old_item) {
- _D("You need to free the old item");
- }
-
- elm_object_part_content_set(page_info->page_inner, "item", item);
- page_info->item = item;
-
- return old_item;
-}
-
-
-
-HAPI Evas_Object *page_get_item(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- return page_info->item;
-}
-
-
-
-HAPI void page_focus(Evas_Object *page)
-{
- Eina_Bool is_focused = EINA_FALSE;
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->focus);
-
- is_focused = elm_object_focus_get(page_info->focus);
- if (is_focused) return;
-
- /*
- * workaround, to avoid scroller focus become invalid
- */
- _D("focus set to %p", page_info->focus);
- elm_object_focus_set(page_info->focus, EINA_TRUE);
-}
-
-
-
-HAPI void page_unfocus(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->focus);
-
- elm_object_focus_set(page_info->focus, EINA_FALSE);
-}
-
-
-
-HAPI void page_highlight(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->focus);
-
- elm_access_object_register(page_info->focus, page);
-}
-
-
-
-HAPI void page_unhighlight(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->focus);
-
- elm_access_object_unregister(page_info->focus);
-}
-
-
-
-/* You have to free returned value */
-HAPI char *page_read_title(Evas_Object *page)
-{
- char *title = NULL;
- const char *tmp = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
- retv_if(!page_info->item, NULL);
-
- switch (page_info->direction) {
- case PAGE_DIRECTION_LEFT:
- break;
- case PAGE_DIRECTION_CENTER:
- break;
- case PAGE_DIRECTION_RIGHT:
- tmp = widget_viewer_evas_get_title_string(page_info->item);
- if (!tmp || strlen(tmp) == 0) {
- const char *widget_id;
- struct add_viewer_package *pkginfo;
-
- widget_id = widget_viewer_evas_get_widget_id(page_info->item);
- break_if(!widget_id);
-
- pkginfo = add_viewer_package_find(widget_id);
- if (pkginfo) {
- tmp = add_viewer_package_list_name(pkginfo);
- }
-
- if (!tmp) {
- //Fallback to the widget id
- tmp = widget_id;
- }
- }
- break;
- default:
- _E("Cannot reach here");
- break;
- }
- if (!tmp) return NULL;
-
- title = strdup(tmp);
- retv_if(!title, NULL);
-
- return title;
-}
-
-
-
-HAPI void page_set_effect(Evas_Object *page, void (*left_effect)(Evas_Object *), void (*right_effect)(Evas_Object *))
-{
- ret_if(!page);
-
- if (left_effect) {
- evas_object_data_set(page, PRIVATE_DATA_KEY_PAGE_LEFT_EFFECT, left_effect);
- }
-
- if (right_effect) {
- evas_object_data_set(page, PRIVATE_DATA_KEY_PAGE_RIGHT_EFFECT, right_effect);
- }
-}
-
-
-
-HAPI void page_unset_effect(Evas_Object *page)
-{
- evas_object_data_del(page, PRIVATE_DATA_KEY_PAGE_LEFT_EFFECT);
- evas_object_data_del(page, PRIVATE_DATA_KEY_PAGE_RIGHT_EFFECT);
-}
-
-
-
-HAPI void *page_get_effect(Evas_Object *page, page_effect_type_e effect_type)
-{
- void (*effect)(Evas_Object *) = NULL;
-
- retv_if(!page, NULL);
-
- switch (effect_type) {
- case PAGE_EFFECT_TYPE_LEFT:
- effect = evas_object_data_get(page, PRIVATE_DATA_KEY_PAGE_LEFT_EFFECT);
- break;
- case PAGE_EFFECT_TYPE_RIGHT:
- effect = evas_object_data_get(page, PRIVATE_DATA_KEY_PAGE_RIGHT_EFFECT);
- break;
- default:
- _E("Cannot reach here");
- break;
- }
-
- return effect;
-}
-
-
-
-HAPI void page_effect_none(Evas_Object *page)
-{
- Evas_Map *map = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int cur_x, cur_y, cur_w, cur_h;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->page_inner);
-
- scroller_info = evas_object_data_get(page_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- /**
- * Send mouse up event when we start to scroll pages.
- */
- if (page_info->item) {
- widget_viewer_evas_feed_mouse_up_event(page_info->item);
- }
-
- evas_object_geometry_get(page, &cur_x, &cur_y, &cur_w, &cur_h);
-
- map = evas_map_new(4);
- ret_if(!map);
-
- /* LEFT */
- evas_map_point_coord_set(map, 0, cur_x, cur_y, 0);
- evas_map_point_image_uv_set(map, 0, 0, 0);
- evas_map_point_color_set(map, 0, 255, 255, 255, 255);
-
- /* RIGHT */
- evas_map_point_coord_set(map, 1, cur_x + cur_w, cur_y, 0);
- evas_map_point_image_uv_set(map, 1, cur_w, 0);
- evas_map_point_color_set(map, 1, 255, 255, 255, 255);
-
- /* BOTTOM-RIGHT */
- evas_map_point_coord_set(map, 2, cur_x + cur_w, cur_y + cur_h, 0);
- evas_map_point_image_uv_set(map, 2, cur_w, cur_h);
- evas_map_point_color_set(map, 2, 255, 255, 255, 255);
-
- /* BOTTOM-LEFT */
- evas_map_point_coord_set(map, 3, cur_x, cur_y + cur_h, 0);
- evas_map_point_image_uv_set(map, 3, 0, cur_h);
- evas_map_point_color_set(map, 3, 255, 255, 255, 255);
-
- evas_object_map_set(page_info->page_inner, map);
- evas_object_map_enable_set(page_info->page_inner, EINA_TRUE);
-
- evas_map_free(map);
-
- if (!eina_list_data_find_list(scroller_info->effect_page_list, page_info->page_inner)) {
- scroller_info->effect_page_list
- = eina_list_append(scroller_info->effect_page_list, page_info->page_inner);
- }
-}
-
-
-
-
-
-
-HAPI void page_clean_effect(Evas_Object *scroller)
-{
- Evas_Object *page_inner = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- list = scroller_info->effect_page_list;
- if (!list) return;
-
- EINA_LIST_FREE(list, page_inner) {
- evas_object_map_enable_set(page_inner, EINA_FALSE);
- }
-
- scroller_info->effect_page_list = NULL;
-}
-
-
-
-HAPI void page_backup_inner_focus(Evas_Object *page, Evas_Object *prev_page, Evas_Object *next_page)
-{
- page_info_s *page_info = NULL;
- page_info_s *prev_page_info = NULL;
- page_info_s *next_page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- if (prev_page) {
- prev_page_info = evas_object_data_get(prev_page, DATA_KEY_PAGE_INFO);
- ret_if(!prev_page_info);
- }
- if (next_page) {
- next_page_info = evas_object_data_get(next_page, DATA_KEY_PAGE_INFO);
- ret_if(!next_page_info);
- }
-
- if (prev_page) {
- elm_object_focus_next_object_set(page_info->focus, prev_page_info->focus, ELM_FOCUS_PREVIOUS);
- elm_access_highlight_next_set(page_info->focus, ELM_HIGHLIGHT_DIR_PREVIOUS, prev_page_info->focus);
- }
-
- if (next_page) {
- elm_object_focus_next_object_set(page_info->focus, next_page_info->focus, ELM_FOCUS_NEXT);
- elm_access_highlight_next_set(page_info->focus, ELM_HIGHLIGHT_DIR_NEXT, next_page_info->focus);
- }
-}
-
-
-
-HAPI void page_restore_inner_focus(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- if (page_info->focus_prev) {
- elm_object_focus_next_object_set(page_info->focus, page_info->focus_prev, ELM_FOCUS_PREVIOUS);
- elm_access_highlight_next_set(page_info->focus, ELM_HIGHLIGHT_DIR_PREVIOUS, page_info->focus_prev);
- } else {
- elm_object_focus_next_object_set(page_info->focus, NULL, ELM_FOCUS_PREVIOUS);
- elm_access_highlight_next_set(page_info->focus, ELM_HIGHLIGHT_DIR_PREVIOUS, NULL);
- }
-
- if (page_info->focus_next) {
- elm_object_focus_next_object_set(page_info->focus, page_info->focus_next, ELM_FOCUS_NEXT);
- elm_access_highlight_next_set(page_info->focus, ELM_HIGHLIGHT_DIR_NEXT, page_info->focus_next);
- } else {
- elm_object_focus_next_object_set(page_info->focus, NULL, ELM_FOCUS_NEXT);
- elm_access_highlight_next_set(page_info->focus, ELM_HIGHLIGHT_DIR_NEXT, NULL);
- }
-}
-
-
-
-HAPI void page_set_title(Evas_Object *page, const char *title)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- free(page_info->title);
-
- /* Title can be NULL */
- if (title) {
- page_info->title = strdup(title);
- } else {
- page_info->title = NULL;
- }
-}
-
-
-
-HAPI const char *page_get_title(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- retv_if(!page, NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- return page_info->title;
-}
-
-
-
-HAPI int page_is_appended(Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- retv_if(!page, 0);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, 0);
-
- return page_info->appended == EINA_TRUE ? 1 : 0;
-}
-
-
-
-static void _plus_page_update_label(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- page_info = evas_object_data_get(scroller_info->plus_page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- elm_object_part_text_set(page_info->item, "plus_text", _("IDS_HS_BODY_ADD_WIDGET"));
-}
-
-
-
-HAPI void page_update_label(void)
-{
- Evas_Object *scroller = NULL;
- Evas_Object *layout = NULL;
- Evas_Object *win = main_get_info()->win;
- ret_if(!win);
-
- layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- scroller = elm_object_part_content_get(layout, "scroller");
- ret_if(!scroller);
-
- _plus_page_update_label(scroller);
-}
-
-
-
-// End of this file
diff --git a/src/page_info.c b/src/page_info.c
deleted file mode 100755
index a9fddd6..0000000
--- a/src/page_info.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <Eina.h>
-#include <Evas.h>
-#include <bundle.h>
-#include <dlog.h>
-
-#include "log.h"
-#include "page_info.h"
-#include "util.h"
-
-HAPI page_info_s *page_info_create(const char *id, const char *subid, double period)
-{
- page_info_s *page_info = NULL;
-
- page_info = calloc(1, sizeof(page_info_s));
- retv_if(!page_info, NULL);
-
- if (id) {
- page_info->id = strdup(id);
- if (!page_info->id) {
- free(page_info);
- return NULL;
- }
- }
-
- if (subid) {
- page_info->subid = strdup(subid);
- if (!page_info->subid) {
- free(page_info->id);
- free(page_info);
- return NULL;
- }
- }
-
- if (id) {
- page_info->removable = 1;
- }
-
- page_info->period = period;
-
- return page_info;
-}
-
-
-
-HAPI void page_info_destroy(page_info_s *page_info)
-{
- ret_if(!page_info);
-
- free(page_info->id);
- free(page_info->subid);
- free(page_info);
-}
-
-
-
-HAPI page_info_s *page_info_dup(page_info_s *page_info)
-{
- page_info_s *dup = NULL;
-
- retv_if(!page_info, NULL);
-
- dup = page_info_create(page_info->id, page_info->subid, page_info->period);
- retv_if(!dup, NULL);
-
- if (page_info->title) {
- dup->title = strdup(page_info->title);
- }
- dup->width = page_info->width;
- dup->height = page_info->height;
- dup->direction = page_info->direction;
- dup->category = page_info->category;
- dup->removable = page_info->removable;
-
- dup->layout = page_info->layout;
- dup->scroller = page_info->scroller;
- dup->page = page_info->page;
- dup->page_rect = page_info->page_rect;
- dup->page_inner = page_info->page_inner;
- dup->page_inner_area = page_info->page_inner_area;
- dup->page_inner_bg = page_info->page_inner_bg;
- dup->focus = page_info->focus;
- dup->remove_focus = page_info->remove_focus;
- dup->item = page_info->item;
- dup->focus_prev = page_info->focus_prev;
- dup->focus_next = page_info->focus_next;
-
- dup->ordering = page_info->ordering;
- dup->layout_longpress = page_info->layout_longpress;
- dup->highlighted = page_info->highlighted;
- dup->need_to_unhighlight = page_info->need_to_unhighlight;
- dup->highlight_changed = page_info->highlight_changed;
- dup->is_scrolled_object = page_info->is_scrolled_object;
-
- return dup;
-}
-
-
-
-HAPI void page_info_list_destroy(Eina_List *page_info_list)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!page_info_list);
-
- EINA_LIST_FREE(page_info_list, page_info) {
- continue_if(!page_info);
- page_info_destroy(page_info);
- }
-}
-
-
-
-HAPI int page_info_is_removable(const char *id)
-{
- if(!id) return 0;
- return 1;
-}
-
-
-
-// End of a file
diff --git a/src/pkgmgr.c b/src/pkgmgr.c
deleted file mode 100755
index dabca6a..0000000
--- a/src/pkgmgr.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <package-manager.h>
-#include <pkgmgr-info.h>
-#include <bundle.h>
-#include <dlog.h>
-
-#include <widget_service.h>
-
-#include "conf.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "pkgmgr.h"
-
-
-
-struct pkgmgr_handler {
- const char *key;
- int (*func)(const char *package, const char *val, void *data);
-};
-
-typedef struct {
- char* package;
- char* key;
- char* val;
-} pkgmgr_reserve_s;
-
-typedef struct {
- char* package;
- char* status;
-} pkgmgr_request_s;
-
-typedef struct {
- char* pkg_id;
- char* app_id;
- Evas_Object *item;
-} pkgmgr_install_s;
-
-static struct {
- pkgmgr_client *listen_pc;
- Eina_List *reserve_list;
- Eina_List *request_list;
- Eina_List *item_list;
- Eina_List *widget_list;
- int hold;
-} pkg_mgr_info = {
- .listen_pc = NULL,
- .reserve_list = NULL,
- .request_list = NULL,
- .item_list = NULL,
- .widget_list = NULL,
-};
-
-
-
-HAPI void pkgmgr_hold_event(void)
-{
- pkg_mgr_info.hold = 1;
-}
-
-
-
-HAPI void pkgmgr_unhold_event(void)
-{
- pkg_mgr_info.hold = 0;
-}
-
-
-
-static w_home_error_e _append_request_in_list(const char *package, const char *status)
-{
- pkgmgr_request_s *rt = NULL;
- char *tmp_pkg = NULL;
- char *tmp_st = NULL;
-
- retv_if(NULL == package, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == status, W_HOME_ERROR_INVALID_PARAMETER);
-
- rt = calloc(1, sizeof(pkgmgr_request_s));
- retv_if(NULL == rt, W_HOME_ERROR_FAIL);
-
- tmp_pkg = strdup(package);
- goto_if(NULL == tmp_pkg, ERROR);
-
- rt->package = tmp_pkg;
-
- tmp_st = strdup(status);
- goto_if(NULL == tmp_st, ERROR);
-
- rt->status = tmp_st;
-
- pkg_mgr_info.request_list = eina_list_append(pkg_mgr_info.request_list, rt);
- goto_if(NULL == pkg_mgr_info.request_list, ERROR);
-
- return W_HOME_ERROR_NONE;
-
-ERROR:
- free(rt->package);
- free(rt->status);
- free(rt);
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-static w_home_error_e _remove_request_in_list(const char *package)
-{
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- pkgmgr_request_s *rt = NULL;
-
- retv_if(NULL == package, W_HOME_ERROR_INVALID_PARAMETER);
-
- if (NULL == pkg_mgr_info.request_list) return W_HOME_ERROR_NONE;
-
- EINA_LIST_FOREACH_SAFE(pkg_mgr_info.request_list, l, ln, rt) {
- if (!rt) continue;
- if (!rt->package) continue;
- if (strcmp(rt->package, package)) continue;
-
- pkg_mgr_info.request_list = eina_list_remove(pkg_mgr_info.request_list, rt);
- free(rt->package);
- free(rt->status);
- free(rt);
- return W_HOME_ERROR_NONE;
- }
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-static int _exist_request_in_list(const char *package)
-{
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- pkgmgr_request_s *rt = NULL;
-
- retv_if(NULL == package, 0);
-
- if (NULL == pkg_mgr_info.request_list) return 0;
-
- EINA_LIST_FOREACH_SAFE(pkg_mgr_info.request_list, l, ln, rt) {
- if (!rt) continue;
- if (!rt->package) continue;
- if (strcmp(rt->package, package)) continue;
- return 1;
- }
-
- return 0;
-}
-
-
-
-static pkgmgr_request_s *_get_request_in_list(const char *package)
-{
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- pkgmgr_request_s *rt = NULL;
-
- retv_if(NULL == package, NULL);
-
- if (NULL == pkg_mgr_info.request_list) return NULL;
-
- EINA_LIST_FOREACH_SAFE(pkg_mgr_info.request_list, l, ln, rt) {
- if (!rt) continue;
- if (!rt->package) continue;
- if (strcmp(rt->package, package)) continue;
- return rt;
- }
-
- return NULL;
-}
-
-
-
-HAPI w_home_error_e pkgmgr_item_list_append_item(const char *pkg_id, const char *app_id, Evas_Object *item)
-{
- pkgmgr_install_s *pi = NULL;
- char *tmp_pkg_id = NULL;
- char *tmp_app_id = NULL;
-
- retv_if(NULL == pkg_id, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == app_id, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == item, W_HOME_ERROR_INVALID_PARAMETER);
-
- pi = calloc(1, sizeof(pkgmgr_install_s));
- goto_if(NULL == pi, ERROR);
-
- tmp_pkg_id = strdup(pkg_id);
- goto_if(NULL == tmp_pkg_id, ERROR);
-
- tmp_app_id = strdup(app_id);
- goto_if(NULL == tmp_app_id, ERROR);
-
- pi->pkg_id = tmp_pkg_id;
- pi->app_id = tmp_app_id;
- pi->item = item;
-
- pkg_mgr_info.item_list = eina_list_append(pkg_mgr_info.item_list, pi);
- goto_if(NULL == pkg_mgr_info.item_list, ERROR);
-
- return W_HOME_ERROR_NONE;
-
-ERROR:
- free(tmp_app_id);
- free(tmp_pkg_id);
- free(pi);
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-HAPI w_home_error_e pkgmgr_item_list_remove_item(const char *pkg_id, const char *app_id, Evas_Object *item)
-{
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- pkgmgr_install_s *pi = NULL;
-
- retv_if(NULL == pkg_id, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == app_id, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == item, W_HOME_ERROR_INVALID_PARAMETER);
-
- EINA_LIST_FOREACH_SAFE(pkg_mgr_info.item_list, l, ln, pi) {
- continue_if(NULL == pi);
- continue_if(NULL == pi->pkg_id);
- continue_if(NULL == pi->app_id);
- continue_if(NULL == pi->item);
-
- if (strcmp(pi->pkg_id, pkg_id)) continue;
- if (strcmp(pi->app_id, app_id)) continue;
- if (pi->item != item) continue;
-
- pkg_mgr_info.item_list = eina_list_remove(pkg_mgr_info.item_list, pi);
-
- free(pi->app_id);
- free(pi->pkg_id);
- free(pi);
-
- return W_HOME_ERROR_NONE;
- }
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-HAPI void pkgmgr_item_list_affect_pkgid(const char *pkg_id, Eina_Bool (*_affected_cb)(const char *, Evas_Object *, void *), void *data)
-{
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- pkgmgr_install_s *pi = NULL;
-
- ret_if(NULL == pkg_mgr_info.item_list);
- ret_if(NULL == pkg_id);
- ret_if(NULL == _affected_cb);
-
- EINA_LIST_FOREACH_SAFE(pkg_mgr_info.item_list, l, ln, pi) {
- continue_if(NULL == pi);
- continue_if(NULL == pi->app_id);
- continue_if(NULL == pi->item);
-
- if (strcmp(pkg_id, pi->pkg_id)) continue;
- /* It's possible that many items with the same package name are in the install list */
- continue_if(EINA_TRUE != _affected_cb(pi->app_id, pi->item, data));
- }
-}
-
-
-
-HAPI void pkgmgr_item_list_affect_appid(const char *app_id, Eina_Bool (*_affected_cb)(const char *, Evas_Object *, void *), void *data)
-{
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- pkgmgr_install_s *pi = NULL;
-
- ret_if(NULL == pkg_mgr_info.item_list);
- ret_if(NULL == app_id);
- ret_if(NULL == _affected_cb);
-
- EINA_LIST_FOREACH_SAFE(pkg_mgr_info.item_list, l, ln, pi) {
- continue_if(NULL == pi);
- continue_if(NULL == pi->app_id);
- continue_if(NULL == pi->item);
-
- if (strcmp(app_id, pi->app_id)) continue;
- /* It's possible that many items with the same package name are in the install list */
- continue_if(EINA_TRUE != _affected_cb(pi->app_id, pi->item, data));
- }
-}
-
-
-
-HAPI w_home_error_e pkgmgr_uninstall(const char *appid)
-{
- pkgmgr_client *req_pc = NULL;
- int ret = W_HOME_ERROR_NONE;
- char *pkgid = NULL;
-
- retv_if(NULL == appid, W_HOME_ERROR_FAIL);
-
- req_pc = pkgmgr_client_new(PC_REQUEST);
- retv_if(NULL == req_pc, W_HOME_ERROR_FAIL);
-
- pkgmgrinfo_appinfo_h handle = NULL;
- if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(appid, &handle)) {
- if (PKGMGR_R_OK != pkgmgr_client_free(req_pc)) {
- _E("cannot free pkgmgr_client for request.");
- }
- return W_HOME_ERROR_FAIL;
- }
-
- if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid)) {
- if (PMINFO_R_OK != pkgmgrinfo_appinfo_destroy_appinfo(handle)) {
- _E("cannot destroy the appinfo");
- }
-
- if (PKGMGR_R_OK != pkgmgr_client_free(req_pc)) {
- _E("cannot free pkgmgr_client for request.");
- }
-
- return W_HOME_ERROR_FAIL;
- }
-
- if (!pkgid) pkgid = (char *) appid;
-
- _D("Uninstall a package[%s] from an app[%s]", pkgid, appid);
- if (pkgmgr_client_uninstall(req_pc, NULL, pkgid, PM_QUIET, NULL, NULL) < 0) {
- _E("cannot uninstall %s.", appid);
- ret = W_HOME_ERROR_FAIL;
- }
-
- if (PMINFO_R_OK != pkgmgrinfo_appinfo_destroy_appinfo(handle)) {
- _E("cannot destroy the appinfo");
- ret = W_HOME_ERROR_FAIL;
- }
-
- if (PMINFO_R_OK != pkgmgr_client_free(req_pc)) {
- _E("cannot free pkgmgr_client");
- ret = W_HOME_ERROR_FAIL;
- }
-
- return ret;
-}
-
-
-
-static w_home_error_e _start_download(const char *package, void *scroller)
-{
- _D("Start downloading for the package(%s)", package);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _start_uninstall(const char *package, void *scroller)
-{
- _D("Start uninstalling for the package(%s)", package);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _start_update(const char *package, void *scroller)
-{
- _D("Start updating for the package(%s)", package);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _start_recover(const char *package, void *scroller)
-{
- _D("Start recovering for the package(%s)", package);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _start_install(const char *package, void *scroller)
-{
- _D("Start installing for the package(%s)", package);
- return W_HOME_ERROR_NONE;
-}
-
-
-static int _get_widget_list_cb(const char *widget_id, int is_prime, void *data)
-{
- char *id = NULL;
-
- retv_if(NULL == widget_id, -1);
-
- id = strdup(widget_id);
- retv_if(!id, -1);
-
- _D("widget_id(%s %d) with %s", id, is_prime, data);
-
- pkg_mgr_info.widget_list = eina_list_append(pkg_mgr_info.widget_list, id);
-
- return 0;
-}
-
-
-static w_home_error_e _start(const char *package, const char *val, void *scroller)
-{
- struct start_cb_set {
- const char *name;
- int (*handler)(const char *package, void *scroller);
- } start_cb[] = {
- {
- .name = "download",
- .handler = _start_download,
- },
- {
- .name = "uninstall",
- .handler = _start_uninstall,
- },
- {
- .name = "install",
- .handler = _start_install,
- },
- {
- .name = "update",
- .handler = _start_update,
- },
- {
- .name = "recover",
- .handler = _start_recover,
- },
- {
- .name = NULL,
- .handler = NULL,
- },
- };
-
- _D("package [%s], val [%s]", package, val);
- retv_if(_exist_request_in_list(package), W_HOME_ERROR_FAIL);
- retv_if(W_HOME_ERROR_NONE != _append_request_in_list(package, val), W_HOME_ERROR_FAIL);
-
- widget_service_get_widget_list_by_pkgid(package, _get_widget_list_cb, (void*) val);
-
- register unsigned int i;
- for (i = 0; start_cb[i].name; i ++) {
- if (strcasecmp(val, start_cb[i].name)) continue;
- break_if(NULL == start_cb[i].handler);
- return start_cb[i].handler(package, scroller);
- }
-
- _E("Unknown status for starting phase signal'd from package manager");
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _icon_path(const char *package, const char *val, void *scroller)
-{
- _D("package(%s) with %s", package, val);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _download_percent(const char *package, const char *val, void *scroller)
-{
- _D("package(%s) with %s", package, val);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _install_percent(const char *package, const char *val, void *scroller)
-{
- _D("package(%s) with %s", package, val);
- if (_exist_request_in_list(package)) return W_HOME_ERROR_NONE;
- retv_if(W_HOME_ERROR_NONE != _append_request_in_list(package, "install"), W_HOME_ERROR_FAIL);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _error(const char *package, const char *val, void *scroller)
-{
- _D("package(%s) with %s", package, val);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static int _end_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
-{
- char *appid = NULL;
- pkgmgr_request_s *rt = NULL;
-
- retv_if(NULL == handle, -1);
- retv_if(NULL == user_data, -1);
-
- pkgmgrinfo_appinfo_get_appid(handle, &appid);
-
- rt = user_data;
- if (!strcmp(rt->status, "install")) {
- /* Install an app */
- } else if (!strcmp(rt->status, "update")) {
- /* Update an app */
- } else {
- _E("No routines for this status (%s:%s)", rt->package, rt->status);
- }
-
- return 0;
-}
-
-
-
-static Eina_Bool _uninstall_cb(const char *app_id, Evas_Object *item, void *data)
-{
- /* Uninstall a widget */
-
- return EINA_TRUE;
-}
-
-
-
-static w_home_error_e _end(const char *package, const char *val, void *data)
-{
- pkgmgr_request_s *rt = NULL;
- pkgmgrinfo_pkginfo_h handle = NULL;
-
- retv_if(!_exist_request_in_list(package), W_HOME_ERROR_FAIL);
-
- rt = _get_request_in_list(package);
- retv_if(NULL == rt, W_HOME_ERROR_FAIL);
- retv_if(strcasecmp(val, "ok"), W_HOME_ERROR_FAIL);
-
- _D("Package(%s) : key(%s) - val(%s)", package, rt->status, val);
-
- /* Criteria : pkgid */
- if (!strcasecmp("uninstall", rt->status)) {
- char *widget_id = NULL;
-
- pkgmgr_item_list_affect_pkgid(package, _uninstall_cb, NULL);
-
- EINA_LIST_FREE(pkg_mgr_info.widget_list, widget_id) {
- continue_if(NULL == widget_id);
- pkgmgr_item_list_affect_pkgid(widget_id, _uninstall_cb, NULL);
- free(widget_id);
- }
- pkg_mgr_info.widget_list = NULL;
-
- goto OUT;
- }
-
- retv_if(PMINFO_R_OK != pkgmgrinfo_pkginfo_get_pkginfo(package, &handle), W_HOME_ERROR_FAIL);
-
- /* Criteria : appid */
- if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, _end_cb, rt)) {
- if (W_HOME_ERROR_NONE != _remove_request_in_list(package))
- _E("cannot remove a request(%s:%s)", rt->package, rt->status);
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return W_HOME_ERROR_FAIL;
- }
-
-OUT:
- if (W_HOME_ERROR_NONE != _remove_request_in_list(package))
- _E("cannot remove a request(%s:%s)", rt->package, rt->status);
- if (handle) pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static w_home_error_e _change_pkg_name(const char *package, const char *val, void *scroller)
-{
- _D("package(%s) with %s", package, val);
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static struct pkgmgr_handler pkgmgr_cbs[] = {
- { "start", _start },
- { "icon_path", _icon_path },
- { "download_percent", _download_percent },
- { "command", NULL },
- { "install_percent", _install_percent },
- { "error", _error },
- { "end", _end },
- { "change_pkg_name", _change_pkg_name },
-};
-
-
-
-static w_home_error_e _pkgmgr_cb(uid_t target_uid, int req_id, const char *pkg_type, const char *package, const char *key, const char *val, const void *pmsg, void *data)
-{
- register unsigned int i;
-
- _D("pkgmgr request [%s:%s] for %s", key, val, package);
-
- if (BOOTING_STATE_DONE > main_get_info()->booting_state) {
- pkgmgr_reserve_list_push_request(package, key, val);
- return W_HOME_ERROR_NONE;
- }
-
- if (pkg_mgr_info.hold) {
- pkgmgr_reserve_list_push_request(package, key, val);
- return W_HOME_ERROR_NONE;
- }
-
- for (i = 0; i < sizeof(pkgmgr_cbs) / sizeof(struct pkgmgr_handler); i++) {
- if (strcasecmp(pkgmgr_cbs[i].key, key)) continue;
- break_if(!pkgmgr_cbs[i].func);
-
- if (W_HOME_ERROR_NONE != pkgmgr_cbs[i].func(package, val, NULL)) {
- _E("pkgmgr_cbs[%u].func has errors.", i);
- }
-
- return W_HOME_ERROR_NONE;
- }
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-HAPI w_home_error_e pkgmgr_reserve_list_push_request(const char *package, const char *key, const char *val)
-{
- char *tmp_package = NULL;
- char *tmp_key = NULL;
- char *tmp_val = NULL;
-
- retv_if(NULL == package, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == key, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(NULL == val, W_HOME_ERROR_INVALID_PARAMETER);
-
- pkgmgr_reserve_s *pr = calloc(1, sizeof(pkgmgr_reserve_s));
- retv_if(NULL == pr, W_HOME_ERROR_FAIL);
-
- tmp_package = strdup(package);
- goto_if(NULL == tmp_package, ERROR);
- pr->package = tmp_package;
-
- tmp_key = strdup(key);
- goto_if(NULL == tmp_key, ERROR);
- pr->key = tmp_key;
-
- tmp_val = strdup(val);
- goto_if(NULL == tmp_val, ERROR);
- pr->val = tmp_val;
-
- pkg_mgr_info.reserve_list = eina_list_append(pkg_mgr_info.reserve_list, pr);
- goto_if(NULL == pkg_mgr_info.reserve_list, ERROR);
-
- return W_HOME_ERROR_NONE;
-
-ERROR:
- free(tmp_val);
- free(tmp_key);
- free(tmp_package);
- free(pr);
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-HAPI w_home_error_e pkgmgr_reserve_list_pop_request(void)
-{
- pkgmgr_reserve_s *pr = NULL;
-
- if (!pkg_mgr_info.reserve_list) return W_HOME_ERROR_NO_DATA;
-
- pr = eina_list_nth(pkg_mgr_info.reserve_list, 0);
- if (!pr) return W_HOME_ERROR_NO_DATA;
- pkg_mgr_info.reserve_list = eina_list_remove(pkg_mgr_info.reserve_list, pr);
-
- goto_if(W_HOME_ERROR_NONE != _pkgmgr_cb(getuid(), 0, NULL, pr->package, pr->key, pr->val, NULL, NULL), ERROR);
-
- free(pr->package);
- free(pr->key);
- free(pr->val);
- free(pr);
-
- return W_HOME_ERROR_NONE;
-
-ERROR:
- free(pr->package);
- free(pr->key);
- free(pr->val);
- free(pr);
-
- return W_HOME_ERROR_FAIL;
-}
-
-
-
-HAPI w_home_error_e pkgmgr_init(void)
-{
- if (NULL != pkg_mgr_info.listen_pc) {
- return W_HOME_ERROR_NONE;
- }
-
- pkg_mgr_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
- retv_if(NULL == pkg_mgr_info.listen_pc, W_HOME_ERROR_FAIL);
- retv_if(pkgmgr_client_listen_status(pkg_mgr_info.listen_pc,
- _pkgmgr_cb, NULL) != PKGMGR_R_OK, W_HOME_ERROR_FAIL);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void pkgmgr_fini(void)
-{
- ret_if(NULL == pkg_mgr_info.listen_pc);
- if (pkgmgr_client_free(pkg_mgr_info.listen_pc) != PKGMGR_R_OK) {
- _E("cannot free pkgmgr_client for listen.");
- }
- pkg_mgr_info.listen_pc = NULL;
-}
-
-
-
-HAPI int pkgmgr_exist(char *appid)
-{
- int ret = 0;
- pkgmgrinfo_appinfo_h handle = NULL;
-
- ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
- if (PMINFO_R_OK != ret || NULL == handle) {
- _SD("%s doesn't exist in this binary", appid);
- return 0;
- }
-
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
-
- return 1;
-}
-
-
-
-// End of a file
diff --git a/src/popup.c b/src/popup.c
deleted file mode 100755
index fd8b89f..0000000
--- a/src/popup.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <aul.h>
-#include <app.h>
-#include <appsvc.h>
-#include <bundle.h>
-#include <Elementary.h>
-#include <Evas.h>
-#include <dlog.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <vconf.h>
-
-#include "conf.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "popup.h"
-
-
-
-#define APPID_WC_POPUP "org.tizen.weconn-popup"
-#define WC_POPUP_EXTRA_DATA_KEY "http://samsung.com/appcontrol/data/connection_type"
-static void _popup_weconn_gear_to_home(void)
-{
- app_control_h service = NULL;
- ret_if(APP_CONTROL_ERROR_NONE != app_control_create(&service));
- ret_if(NULL == service);
-
- app_control_add_extra_data(service, WC_POPUP_EXTRA_DATA_KEY, "mobile_data_noti");
-
- app_control_set_app_id(service, APPID_WC_POPUP);
- int ret = app_control_send_launch_request(service, NULL, NULL);
- if (ret != APP_CONTROL_ERROR_NONE) {
- _E("Failed to launch:%d", ret);
- }
-
- app_control_destroy(service);
-}
-
-static void _popup_after_tutorial(void)
-{
- _W("popup:misc");
- _popup_weconn_gear_to_home();
-}
-
-void popup_show(int stage)
-{
- if (stage == POPUP_STAGE_AFTER_TUTORIAL) {
- _popup_after_tutorial();
- }
-}
diff --git a/src/scroller.c b/src/scroller.c
deleted file mode 100755
index f651e13..0000000
--- a/src/scroller.c
+++ /dev/null
@@ -1,3189 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <dlog.h>
-#include <bundle.h>
-#include <vconf.h>
-#include <efl_extension.h>
-#include <widget_viewer_evas.h>
-
-#include "bg.h"
-#include "util.h"
-#include "wms.h"
-#include "conf.h"
-#include "power_mode.h"
-#include "key.h"
-#include "dbus.h"
-#include "layout.h"
-#include "layout_info.h"
-#include "widget.h"
-#include "log.h"
-#include "main.h"
-#include "page_info.h"
-#include "page.h"
-#include "pkgmgr.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "index.h"
-#include "db.h"
-#include "clock_service.h"
-
-#define BOX_EDJE EDJEDIR"/box_layout.edj"
-#define BOX_GROUP_NAME "box"
-#define FRAMETIME_FOR_ANIMATION 0.011
-
-#define PRIVATE_DATA_KEY_HIDE_INDEX_TIMER "p_h_ix_tm"
-#define PRIVATE_DATA_KEY_SHOW_END "p_s_e"
-#define PRIVATE_DATA_KEY_IS_DUMMY "p_is_dum"
-#define PRIVATE_DATA_KEY_SCROLLER_FREEZED "p_sc_is_fr"
-#define PRIVATE_DATA_KEY_SCROLLER_PRESSED_PAGE "p_sc_pr_pg"
-#define PRIVATE_DATA_KEY_SCROLLER_PUSH_ALL_TIMER "p_p_tm"
-#define PRIVATE_DATA_KEY_SCROLLER_LIST "p_sc_l"
-#define PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER "p_sc_tmer"
-#define PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM "p_sc_anim"
-#define PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB "p_sc_job"
-#define PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE "p_sc_page"
-#define PRIVATE_DATA_KEY_SCROLLER_HIDE_INDEX_TIMER "p_sc_ht"
-#define PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC "pdk_sc_bf_fn"
-#define PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC_DATA "pdk_sc_bf_fn_d"
-#define PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC "pdk_sc_af_fn"
-#define PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA "pdk_sc_af_fn_d"
-
-
-
-static inline void _page_bring_in(Evas_Object *scroller, int index, scroller_freeze_e is_freezed);
-static inline int _get_index_in_list(Evas_Object *box, Evas_Object *page);
-
-
-
-static void _mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Ecore_Timer *timer = NULL;
- Evas_Object *layout = data;
- Evas_Object *scroller = obj;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!layout);
- _D("scroller mouse down");
-
- home_dbus_scroll_booster_signal_send(200);
-
- timer = evas_object_data_del(layout, PRIVATE_DATA_KEY_HIDE_INDEX_TIMER);
- if (timer) {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- scroller_info->mouse_down = 1;
-}
-
-
-
-static void _mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Object *scroller = obj;
- scroller_info_s *scroller_info = NULL;
- _D("scroller mouse up");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- scroller_info->mouse_down = 0;
-}
-
-
-
-HAPI Evas_Object *scroller_get_picked_up_page(Evas_Object *scroller)
-{
- Evas_Object *obj = NULL;
- Evas_Object *cur_page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- if (!list) return NULL;
-
- EINA_LIST_FREE(list, obj) {
- continue_if(!obj);
- if (evas_object_data_get(obj, DATA_KEY_PICKED_UP_PAGE)) {
- cur_page = obj;
- }
- }
-
- return cur_page;
-}
-
-
-
-HAPI Evas_Object *scroller_get_focused_page(Evas_Object *scroller)
-{
- Evas_Object *obj = NULL;
- Evas_Object *cur_page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int x, w;
- int half_line, whole_line, pad;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- pad = (scroller_info->root_width - scroller_info->page_width) / 2;
- half_line = scroller_info->root_width / 2;
- whole_line = scroller_info->root_width;
-
- list = elm_box_children_get(scroller_info->box);
- if (!list) return NULL;
-
- EINA_LIST_FREE(list, obj) {
- continue_if(!obj);
- if (cur_page) continue;
-
- if (scroller_info->scroller_type != WIDGETS_STATE_ADD) {
- page_info = evas_object_data_get(obj, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (!page_info->appended) {
- _D("Page(%p) is not appended yet", obj);
- continue;
- }
- }
-
- evas_object_geometry_get(obj, &x, NULL, &w, NULL);
- if (!w) continue;
- if (x + w > half_line && x <= whole_line - pad) {
- cur_page = obj;
- } else if (x <= half_line && x >= pad) {
- cur_page = obj;
- }
- }
-
- return cur_page;
-}
-
-
-
-static int _set_scroller_reverse_by_page(Evas_Object *scroller, Evas_Object *target_page)
-{
- Evas_Object *focus_page = NULL;
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l;
- scroller_info_s *scroller_info = NULL;
- int after_focus = 0;
-
- retv_if(!scroller, 0);
-
- focus_page = scroller_get_focused_page(scroller);
- if (!focus_page) return 0;
-
- /* Center */
- if (focus_page == target_page) return 0;
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, 0);
-
- list = elm_box_children_get(scroller_info->box);
- if (!list) return 0;
-
- EINA_LIST_FOREACH(list, l, tmp) {
- /* if the target is focused, then it is not after_focus */
- if (tmp == target_page) break;
- if (tmp == focus_page) after_focus = 1;
- }
- eina_list_free(list);
-
- /* Right side */
- if (after_focus) return 1;
-
- /* Left side */
- return -1;
-}
-
-
-
-static void _elm_box_pack_start(Evas_Object *scroller, Evas_Object *page)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- _D("pack_start a page(%p) into the scroller(%p), origin_reverse(1)", page, scroller);
- elm_box_pack_start(scroller_info->box, page);
- /* recalculate : child box with pages -> parent box */
- elm_box_recalculate(scroller_info->box);
- elm_box_recalculate(scroller_info->box_layout);
-}
-
-
-
-static void _elm_box_pack_end(Evas_Object *scroller, Evas_Object *page)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- _D("pack_end a page(%p) into the scroller(%p), origin_reverse(0)", page, scroller);
- elm_box_pack_end(scroller_info->box, page);
- /* recalculate : child box with pages -> parent box */
- elm_box_recalculate(scroller_info->box);
- elm_box_recalculate(scroller_info->box_layout);
-}
-
-
-
-static void _elm_box_pack_before(Evas_Object *scroller, Evas_Object *page, Evas_Object *before)
-{
- scroller_info_s *scroller_info = NULL;
- int reverse_factor;
-
- ret_if(!scroller);
- ret_if(!page);
- ret_if(!before);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- reverse_factor = _set_scroller_reverse_by_page(scroller, before);
- switch (reverse_factor) {
- case -1:
- case 0:
- _D("pack_before a page(%p) before a page(%p) into the scroller(%p), origin_reverse(1)", page, before, scroller);
- elm_scroller_gravity_set(scroller, 1.0, 0.0);
- break;
- case 1:
- _D("pack_before a page(%p) before a page(%p) into the scroller(%p), origin_reverse(0)", page, before, scroller);
- elm_scroller_gravity_set(scroller, 0.0, 0.0);
- break;
- default:
- _E("Cannot reach here : %d", reverse_factor);
- break;
- }
-
- elm_box_pack_before(scroller_info->box, page, before);
- /* recalculate : child box with pages -> parent box */
- elm_box_recalculate(scroller_info->box);
- elm_box_recalculate(scroller_info->box_layout);
- elm_scroller_gravity_set(scroller, 0.0, 0.0);
-}
-
-
-
-static void _elm_box_pack_after(Evas_Object *scroller, Evas_Object *page, Evas_Object *after)
-{
- scroller_info_s *scroller_info = NULL;
- Eina_List *list = NULL;
- Evas_Object *item = NULL;
- int reverse_factor;
- int is_exist = 0;
-
- ret_if(!scroller);
- ret_if(!page);
- ret_if(!after);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- reverse_factor = _set_scroller_reverse_by_page(scroller, after);
- switch (reverse_factor) {
- case -1:
- _D("pack_after a page(%p) after a page(%p) into the scroller(%p), origin_reverse(1)", page, after, scroller);
- elm_scroller_gravity_set(scroller, 1.0, 0.0);
- break;
- case 0:
- case 1:
- _D("pack_after a page(%p) after a page(%p) into the scroller(%p), origin_reverse(0)", page, after, scroller);
- elm_scroller_gravity_set(scroller, 0.0, 0.0);
- break;
- default:
- _E("Cannot reach here : %d", reverse_factor);
- break;
- }
-
- list = elm_box_children_get(scroller_info->box);
-
- EINA_LIST_FREE(list, item) {
- if (item == after) {
- is_exist = 1;
- }
- }
-
- if (is_exist) {
- elm_box_pack_after(scroller_info->box, page, after);
- } else {
- elm_box_pack_start(scroller_info->box, page);
- }
- /* recalculate : child box with pages -> parent box */
- elm_box_recalculate(scroller_info->box);
- elm_box_recalculate(scroller_info->box_layout);
- elm_scroller_gravity_set(scroller, 0.0, 0.0);
-}
-
-
-
-static void _elm_box_unpack(Evas_Object *scroller, Evas_Object *page)
-{
- scroller_info_s *scroller_info = NULL;
- int reverse_factor;
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->box);
-
- int is_page_exist = 0;
- Evas_Object *tmp = NULL;
- Eina_List *list = elm_box_children_get(scroller_info->box);
- EINA_LIST_FREE(list, tmp) {
- continue_if(!tmp);
-
- if (page == tmp) {
- is_page_exist = 1;
- }
- }
-
- if (is_page_exist == 0) {
- _D("No page to unpack");
- return;
- }
-
- reverse_factor = _set_scroller_reverse_by_page(scroller, page);
- switch (reverse_factor) {
- case -1:
- _D("unpack a page(%p) from the scroller(%p), origin_reverse(1)", page, scroller);
- elm_scroller_gravity_set(scroller, 1.0, 0.0);
- break;
- case 0:
- case 1:
- _D("unpack a page(%p) from the scroller(%p), origin_reverse(0)", page, scroller);
- elm_scroller_gravity_set(scroller, 0.0, 0.0);
- break;
- default:
- _E("Cannot reach here : %d", reverse_factor);
- break;
- }
-
- elm_object_focus_set(page, EINA_FALSE);
- elm_box_unpack(scroller_info->box, page);
- /* recalculate : child box with pages -> parent box */
- elm_box_recalculate(scroller_info->box);
- elm_box_recalculate(scroller_info->box_layout);
- elm_scroller_gravity_set(scroller, 0.0, 0.0);
-}
-
-
-
-static Eina_Bool _hide_index_timer_cb(void *data)
-{
- Evas_Object *scroller = data;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- layout_hide_multi_index(scroller_info->indicator_layout);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_HIDE_INDEX_TIMER);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Evas_Object *_select_singular_index(Evas_Object *scroller)
-{
- Evas_Object *cur_page;
- scroller_info_s *scroller_info = NULL;
- page_direction_e direction;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- cur_page = scroller_get_focused_page(scroller);
- retv_if(!cur_page, NULL);
-
- direction = scroller_get_current_page_direction(scroller);
- switch (direction) {
- case PAGE_DIRECTION_LEFT:
- if (scroller_info->index) {
- index_bring_in_page(scroller_info->single_index, cur_page);
- }
- return scroller_info->single_index;
- case PAGE_DIRECTION_CENTER:
- if (scroller_info->index) {
- index_bring_in_page(scroller_info->single_index, cur_page);
- }
- break;
- case PAGE_DIRECTION_RIGHT:
- if (scroller_info->index) {
- index_bring_in_page(scroller_info->single_index, cur_page);
- }
- return scroller_info->single_index;
- default:
- _E("Cannot reach here");
- break;
- }
-
- return NULL;
-}
-
-
-
-static struct index_st *_select_plural_index(Evas_Object *scroller)
-{
- Evas_Object *cur_page = NULL;
- scroller_info_s *scroller_info = NULL;
- layout_info_s *layout_info = NULL;
- int j;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- cur_page = scroller_get_focused_page(scroller);
- retv_if(!cur_page, NULL);
-
- layout_info = evas_object_data_get(scroller_info->layout, DATA_KEY_LAYOUT_INFO);
- retv_if(!layout_info, NULL);
-
- if (!layout_info->edit) {
- layout_show_multi_index(scroller_info->indicator_layout);
-
- for (j = 0; j < PAGE_DIRECTION_ANY; j++) {
- multi_index_bring_in_page(scroller_info->index[j], cur_page);
- }
-
- scroller_add_index_hide_timer(scroller);
- }
- return NULL;
-}
-
-
-
-static void _anim_start_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- _D("start the scroller(%p) animation", scroller);
-}
-
-
-
-static void _anim_stop_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- scroller_info_s *scroller_info = NULL;
- Evas_Object *page = NULL;
- Evas_Coord x, w;
- page_info_s *page_info = NULL;
- page_direction_e direction;
-
- _D("stop the scroller(%p) animation", scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- elm_scroller_region_get(scroller, &x, NULL, &w, NULL);
- if (0 == x % scroller_info->page_width) {
- /* If TTS is off, unpack or pack page_inners */
- if (main_get_info()->is_tts) {
- page = scroller_get_focused_page(scroller);
- page_focus(page);
- }
- page = scroller_get_focused_page(scroller);
- direction = scroller_get_current_page_direction(scroller);
-
- if (direction == PAGE_DIRECTION_LEFT) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- page_info->is_focused_page = EINA_TRUE;
- clock_service_set_noti_indicator_icon();
- }
-
- if (page == main_get_info()->clock_focus) {
- vconf_set_bool(VCONFKEY_HOMESCREEN_WATCH_FACE_VISIBILITY, EINA_TRUE);
- } else {
- vconf_set_bool(VCONFKEY_HOMESCREEN_WATCH_FACE_VISIBILITY, EINA_FALSE);
- }
- }
-}
-
-
-
-static void _drag_start_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- _D("start to drag the scroller(%p)", scroller);
-}
-
-
-
-static void _drag_stop_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- _D("stop to drag the scroller(%p) animation", scroller);
-}
-
-
-
-static void _scroll_cb(void *data, Evas_Object *scroller, void *event_info)
-{
- double loop_time = 0.0;
- static double last_boosted_time = 0.0;
- scroller_info_s *scroller_info = NULL;
- layout_info_s *layout_info = NULL;
- int x, w;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- loop_time = ecore_loop_time_get();
- if (last_boosted_time == 0.0) {
- last_boosted_time = loop_time;
- } else {
- if ((loop_time - last_boosted_time) >= 2.5) {
-#if 0 // TBD
- home_dbus_scroll_booster_signal_send(2000);
-#endif
- last_boosted_time = loop_time;
- }
- }
-
- /* 1. Focus */
- elm_scroller_region_get(scroller, &x, NULL, &w, NULL);
- if (0 == x % scroller_info->page_width) {
- /* Page is on the edge */
- scroller_info->scrolling = 0;
- if (main_get_info()->is_tts) {
- scroller_restore_inner_focus(scroller);
- }
- } else {
- /* Page is not on the edge */
- if (!scroller_info->scrolling) {
- scroller_info->scrolling = 1;
- if (main_get_info()->is_tts) {
- scroller_backup_inner_focus(scroller);
- }
- }
- }
-
- /* 2. Index */
- layout_info = evas_object_data_get(scroller_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- /* When an user is reordering pages now, index has not to be updated */
- if (!scroller_info->scroll_index) return;
-
- switch (scroller_info->index_number) {
- case SCROLLER_INDEX_SINGULAR:
- _select_singular_index(scroller);
- break;
- case SCROLLER_INDEX_PLURAL:
- if (!evas_object_data_get(scroller_info->layout, DATA_KEY_ADD_VIEWER)) {
- _select_plural_index(scroller);
- }
- break;
- default:
- _E("Cannot reach here");
- break;
- }
-}
-
-
-
-static w_home_error_e _resume_result_cb(void *data)
-{
- Evas_Object *scroller = data;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, W_HOME_ERROR_INVALID_PARAMETER);
-
- _D("Activate the rotary events for Home");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
- retv_if(!scroller_info->box, W_HOME_ERROR_FAIL);
-
- eext_rotary_object_event_activated_set(scroller, EINA_TRUE);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static inline void _rotary_page_bring_in(Evas_Object *scroller, int index, scroller_freeze_e is_freezed)
-{
- scroller_info_s *scroller_info = NULL;
- int cur_freezed = 0;
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- cur_freezed = elm_object_scroll_freeze_get(scroller_info->box);
-
- if (is_freezed) scroller_unfreeze(scroller);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_ADD) {
- _D("Rotary bring in Add Viewer page to %d", index - 1);
- elm_scroller_page_bring_in(scroller, index - 1, 0);
- } else {
- _D("Rotary bring in page to %d", index);
- elm_scroller_page_bring_in(scroller, index, 0);
- }
-
- if (is_freezed && cur_freezed) scroller_freeze(scroller);
-}
-
-
-
-static void _rotary_move_page_to_next(Evas_Object *scroller, Evas_Object *page, scroller_freeze_e freeze)
-{
- scroller_info_s *scroller_info = NULL;
- Ecore_Animator *anim = NULL;
- Ecore_Job *job = NULL;
- int i = 0;
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- i = _get_index_in_list(scroller_info->box, page);
-
- /* 1. Remove the old action */
- job = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
- if (job) ecore_job_del(job);
-
- anim = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- if (anim) ecore_animator_del(anim);
-
- _rotary_page_bring_in(scroller, i, freeze);
-}
-
-
-
-static Eina_Bool _rotary_cb(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *rotary_info)
-{
- Evas_Object *scroller = obj;
- Evas_Object *cur = NULL;
- Evas_Object *next = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, ECORE_CALLBACK_PASS_ON);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_PASS_ON);
-
- cur = scroller_get_focused_page(scroller);
- retv_if(!cur, ECORE_CALLBACK_PASS_ON);
-
- _D("Detent detected, obj[%p], direction[%d], timeStamp[%u]", obj, rotary_info->direction, rotary_info->time_stamp);
- if (rotary_info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
- next = scroller_get_right_page(scroller, cur);
- } else {
- next = scroller_get_left_page(scroller, cur);
- }
- if (scroller_info->scroller_type == WIDGETS_STATE_ADD) {
- if (!evas_object_data_get(next, "package")) {
- return ECORE_CALLBACK_PASS_ON;
- }
- }
- if (next) {
- _rotary_move_page_to_next(scroller, next, SCROLLER_FREEZE_OFF);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-
-
-static void _destroy_rotary(Evas_Object *scroller)
-{
- ret_if(!scroller);
-
- _D("Finish the rotary event");
-
- eext_rotary_object_event_callback_del(scroller, _rotary_cb);
- main_unregister_cb(APP_STATE_RESUME, _resume_result_cb);
- scroller_unfreeze(scroller);
-}
-
-
-
-HAPI void scroller_init_rotary(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
- _D("lnitialize the rotary event for scroller: %p", scroller);
-
- ret_if(!scroller);
-
- eext_rotary_object_event_callback_add(scroller, _rotary_cb, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- _D("This scroller is Normal scroller");
- if (W_HOME_ERROR_NONE != main_register_cb(APP_STATE_RESUME, _resume_result_cb, scroller)) {
- _E("Cannot register the pause callback");
- }
- } else {
- _D("This scroller is Remove or Add scroller");
- }
- eext_rotary_object_event_activated_set(scroller, EINA_TRUE);
- scroller_unfreeze(scroller);
-}
-
-
-
-HAPI void scroller_destroy(Evas_Object *parent)
-{
- Evas_Object *scroller = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!parent);
-
- scroller = elm_object_part_content_unset(parent, "scroller");
- ret_if(!scroller);
-
- _destroy_rotary(scroller);
-
- evas_object_data_del(parent, DATA_KEY_SCROLLER);
- scroller_info = evas_object_data_del(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- evas_object_data_del(scroller, DATA_KEY_INDEX);
-
- if (scroller_info->index_update_timer) {
- ecore_timer_del(scroller_info->index_update_timer);
- scroller_info->index_update_timer = NULL;
- }
-
- evas_object_del(scroller_info->box);
- evas_object_del(scroller_info->box_layout);
-
- free(scroller_info);
- evas_object_del(scroller);
-}
-
-
-
-HAPI void scroller_focus(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
-
- ret_if(!scroller);
-
- page = scroller_get_focused_page(scroller);
- if (!page) return;
-
- page_focus(page);
-}
-
-
-
-HAPI void scroller_highlight(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->box);
- scroller_info->enable_highlight = 1;
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- EINA_LIST_FREE(list, page) {
- page_highlight(page);
- }
-}
-
-
-
-HAPI void scroller_unhighlight(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->box);
- scroller_info->enable_highlight = 0;
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- EINA_LIST_FREE(list, page) {
- page_unhighlight(page);
- }
-}
-
-
-
-HAPI Evas_Object *scroller_create(Evas_Object *layout, Evas_Object *parent, int page_width, int page_height, scroller_index_e index_number)
-{
- Evas_Object *scroller = NULL;
- Evas_Object *box_layout = NULL;
- Evas_Object *box = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!parent, NULL);
-
- scroller = elm_scroller_add(parent);
- retv_if(!scroller, NULL);
-
- scroller_info = calloc(1, sizeof(scroller_info_s));
- if (!scroller_info) {
- _E("Cannot calloc for scroller_info");
- evas_object_del(scroller);
- return NULL;
- }
-
- evas_object_data_set(scroller, DATA_KEY_SCROLLER_INFO, scroller_info);
- evas_object_data_set(parent, DATA_KEY_SCROLLER, scroller);
- evas_object_data_set(scroller, DATA_KEY_INDEX, NULL);
-
- elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
- elm_scroller_page_scroll_limit_set(scroller, 1, 1);
- elm_scroller_content_min_limit(scroller, EINA_FALSE, EINA_TRUE);
- elm_scroller_single_direction_set(scroller, ELM_SCROLLER_SINGLE_DIRECTION_HARD);
- elm_scroller_page_size_set(scroller, page_width, page_height);
- evas_object_smart_callback_add(scroller, "scroll", _scroll_cb, NULL);
-
- elm_object_style_set(scroller, "effect");
- evas_object_show(scroller);
- elm_object_scroll_lock_y_set(scroller, EINA_TRUE);
- elm_object_part_content_set(parent, "scroller", scroller);
-
- evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, layout);
- evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, layout);
- evas_object_smart_callback_add(scroller, "scroll,anim,start", _anim_start_cb, NULL);
- evas_object_smart_callback_add(scroller, "scroll,anim,stop", _anim_stop_cb, NULL);
- evas_object_smart_callback_add(scroller, "scroll,drag,start", _drag_start_cb, NULL);
- evas_object_smart_callback_add(scroller, "scroll,drag,stop", _drag_stop_cb, NULL);
-
- /* Use the parent between box and scroller because of alignment of a page in the box. */
- box_layout = elm_box_add(scroller);
- if (!box_layout) {
- _E("Cannot create box_layout");
- evas_object_del(scroller);
- return NULL;
- }
- elm_box_horizontal_set(box_layout, EINA_TRUE);
- /* The weight of box_layout has to be set as EVAS_HINT_EXPAND on y-axis. */
- evas_object_size_hint_weight_set(box_layout, 0.0, EVAS_HINT_EXPAND);
- evas_object_show(box_layout);
-
- elm_object_content_set(scroller, box_layout);
-
- box = elm_box_add(box_layout);
- if (!box) {
- _E("Cannot create box");
- evas_object_del(box_layout);
- evas_object_del(scroller);
- return NULL;
- }
-
- elm_box_horizontal_set(box, EINA_TRUE);
- /* The alignment of box has to be set as 0.0, 0.5 for pages */
- elm_box_align_set(box, 0.0, 0.5);
- evas_object_size_hint_weight_set(box, 0.0, EVAS_HINT_EXPAND);
- evas_object_show(box);
-
- elm_box_pack_end(box_layout, box);
-
- scroller_info->root_width = main_get_info()->root_w;
- scroller_info->root_height = main_get_info()->root_h;
- scroller_info->page_width = page_width;
- scroller_info->page_height = page_height;
- scroller_info->index_number = index_number;
-
- scroller_info->layout = layout;
- scroller_info->parent = parent;
- scroller_info->box_layout = box_layout;
- scroller_info->box = box;
-
- scroller_info->scroll_focus = 1;
- scroller_info->scroll_index = 1;
-
- return scroller;
-}
-
-
-HAPI w_home_error_e scroller_push_page_before_edit(Evas_Object *real_scroller, Evas_Object *scroller, Evas_Object *page, Evas_Object *before)
-{
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- scroller_info_s *real_scroller_info = NULL;
- page_info_s *page_info = NULL;
- Evas_Object *real_page = NULL;
- int center_check = 0;
-
- real_page = evas_object_data_get(page, DATA_KEY_REAL_PAGE);
- retv_if(!real_page, W_HOME_ERROR_FAIL);
-
- retv_if(!real_scroller, W_HOME_ERROR_FAIL);
- retv_if(!scroller, W_HOME_ERROR_FAIL);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- real_scroller_info = evas_object_data_get(real_scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!real_scroller_info, W_HOME_ERROR_FAIL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, W_HOME_ERROR_FAIL);
-
- _elm_box_unpack(scroller, page);
- if (before) _elm_box_pack_before(scroller, page, before);
- else _elm_box_pack_end(scroller, page);
-
- list = elm_box_children_get(real_scroller_info->box);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp) {
- continue_if(!tmp);
-
- if (real_scroller_info->center == tmp) center_check = 1;
- if (real_page == tmp) {
- if (center_check) page_info->direction = PAGE_DIRECTION_RIGHT;
- else page_info->direction = PAGE_DIRECTION_LEFT;
- break;
- }
- }
- eina_list_free(list);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- multi_index_update(scroller);
- } else {
- index_update(scroller_info->single_index, scroller, INDEX_BRING_IN_NONE);
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-HAPI w_home_error_e scroller_push_page_before(Evas_Object *scroller, Evas_Object *page, Evas_Object *before)
-{
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int center_check = 0;
-
- retv_if(!scroller, W_HOME_ERROR_FAIL);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, W_HOME_ERROR_FAIL);
-
- _elm_box_unpack(scroller, page);
- if (before) _elm_box_pack_before(scroller, page, before);
- else _elm_box_pack_end(scroller, page);
-
- list = elm_box_children_get(scroller_info->box);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp) {
- continue_if(!tmp);
-
- if (scroller_info->center == tmp) center_check = 1;
- if (page == tmp) {
- if (center_check) page_info->direction = PAGE_DIRECTION_RIGHT;
- else page_info->direction = PAGE_DIRECTION_LEFT;
- break;
- }
- }
- eina_list_free(list);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- multi_index_update(scroller);
- } else {
- index_update(scroller_info->single_index, scroller, INDEX_BRING_IN_NONE);
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e scroller_push_page_after(Evas_Object *scroller, Evas_Object *page, Evas_Object *after)
-{
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int center_check = 0;
-
- retv_if(!scroller, W_HOME_ERROR_FAIL);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, W_HOME_ERROR_FAIL);
-
- _elm_box_unpack(scroller, page);
- if (after) _elm_box_pack_after(scroller, page, after);
- else _elm_box_pack_start(scroller, page);
-
- list = elm_box_children_get(scroller_info->box);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp) {
- continue_if(!tmp);
-
- if (scroller_info->center == tmp) center_check = 1;
- if (page == tmp) {
- if (center_check) page_info->direction = PAGE_DIRECTION_RIGHT;
- else page_info->direction = PAGE_DIRECTION_LEFT;
- break;
- }
- }
- eina_list_free(list);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- multi_index_update(scroller);
- } else {
- if (scroller_info->single_index) {
- index_update(scroller_info->single_index, scroller, INDEX_BRING_IN_NONE);
- }
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static Eina_Bool _index_update_cb(void *data)
-{
- Evas_Object *scroller = data;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- scroller_info->index_update_timer = NULL;
-
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- multi_index_update(scroller);
- } else {
- if (scroller_info->single_index) {
- index_update(scroller_info->single_index, scroller, INDEX_BRING_IN_AFTER);
- }
- }
-
- _D("Index is updated");
- scroller_info->index_update_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-HAPI w_home_error_e scroller_push_page(Evas_Object *scroller, Evas_Object *page, scroller_push_type_e scroller_type)
-{
- Evas_Object *tmp = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!scroller, W_HOME_ERROR_FAIL);
- retv_if(!page, W_HOME_ERROR_FAIL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, W_HOME_ERROR_FAIL);
-
- switch (scroller_type) {
- case SCROLLER_PUSH_TYPE_FIRST:
- case SCROLLER_PUSH_TYPE_CENTER_LEFT:
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT:
- page_info->direction = PAGE_DIRECTION_LEFT;
- break;
- case SCROLLER_PUSH_TYPE_CENTER:
- page_info->direction = PAGE_DIRECTION_CENTER;
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_RIGHT:
- case SCROLLER_PUSH_TYPE_CENTER_RIGHT:
- case SCROLLER_PUSH_TYPE_LAST:
- default:
- page_info->direction = PAGE_DIRECTION_RIGHT;
- break;
- }
-
- if (!scroller_info->center) {
- switch (scroller_type) {
- case SCROLLER_PUSH_TYPE_CENTER_LEFT:
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT:
- case SCROLLER_PUSH_TYPE_CENTER_RIGHT:
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_RIGHT:
- scroller_type = SCROLLER_PUSH_TYPE_LAST;
- break;
- case SCROLLER_PUSH_TYPE_CENTER:
- scroller_type = SCROLLER_PUSH_TYPE_LAST;
- scroller_info->center = page;
- break;
- default:
- break;
- }
- }
-
- switch (scroller_type) {
- case SCROLLER_PUSH_TYPE_FIRST:
- _elm_box_unpack(scroller, page);
- _elm_box_pack_start(scroller, page);
- break;
- case SCROLLER_PUSH_TYPE_CENTER_LEFT:
- _elm_box_unpack(scroller, page);
-
- tmp = (scroller_info->center_neighbor_left && scroller_info->center_neighbor_left != page) ?
- scroller_info->center_neighbor_left : scroller_info->center;
- _elm_box_pack_before(scroller, page, tmp);
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT:
- if (scroller_info->center_neighbor_left) {
- _elm_box_unpack(scroller, scroller_info->center_neighbor_left);
- }
- _elm_box_pack_before(scroller, page, scroller_info->center);
- scroller_info->center_neighbor_left = page;
- break;
- case SCROLLER_PUSH_TYPE_CENTER:
- _elm_box_pack_after(scroller, page, scroller_info->center);
- _elm_box_unpack(scroller, scroller_info->center);
-
- if (evas_object_data_del(scroller_info->center, PRIVATE_DATA_KEY_IS_DUMMY) != NULL) {
- page_destroy(scroller_info->center);
- }
- scroller_info->center = page;
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_RIGHT:
- if (scroller_info->center_neighbor_right) {
- _elm_box_unpack(scroller, scroller_info->center_neighbor_right);
- }
- _elm_box_pack_after(scroller, page, scroller_info->center);
- scroller_info->center_neighbor_right = page;
- break;
- case SCROLLER_PUSH_TYPE_CENTER_RIGHT:
- _elm_box_unpack(scroller, page);
- tmp = scroller_info->center_neighbor_right && scroller_info->center_neighbor_right != page ?
- scroller_info->center_neighbor_right : scroller_info->center;
- _elm_box_pack_after(scroller, page, tmp);
- break;
- case SCROLLER_PUSH_TYPE_LAST:
- default:
- _elm_box_unpack(scroller, page);
- _elm_box_pack_end(scroller, page);
- break;
- }
-
- if (scroller_info->index_update_timer) {
- ecore_timer_reset(scroller_info->index_update_timer);
- } else {
- scroller_info->index_update_timer = ecore_timer_add(INDEX_UPDATE_TIME, _index_update_cb, scroller);
- }
- if (!scroller_info->index_update_timer) {
- _E("Cannot add an index update timer");
- }
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI Evas_Object *scroller_pop_page(Evas_Object *scroller, Evas_Object *page)
-{
- _D("Unpack page(%p) from the BOX", page);
- scroller_info_s *scroller_info = NULL;
- Eina_List *list = NULL;
- const Eina_List *l = NULL;
- const Eina_List *ln = NULL;
- Evas_Object *tmp_page = NULL;
- page_info_s *page_info = NULL;
- int count = 0;
-
- retv_if(!scroller, NULL);
- retv_if(!page, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- if (scroller_info->index_update_timer) {
- ecore_timer_del(scroller_info->index_update_timer);
- scroller_info->index_update_timer = NULL;
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(NULL == list, NULL);
-
- if (scroller_info->center == page) {
- _D("The center will be removed");
- scroller_info->center = NULL;
- }
-
- if (scroller_info->center_neighbor_left == page) {
- _D("The neighbor left will be removed");
- scroller_info->center_neighbor_left = NULL;
- }
-
- if (scroller_info->center_neighbor_right == page) {
- _D("The neighbor right will be removed");
- scroller_info->center_neighbor_right = NULL;
- }
-
- count = eina_list_count(list);
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp_page) {
- if (page != tmp_page) continue;
- _elm_box_unpack(scroller, page);
-
- scroller_info->index_update_timer = ecore_timer_add(INDEX_UPDATE_TIME, _index_update_cb, scroller);
- if (!scroller_info->index_update_timer) {
- _E("Cannot add an index update timer");
- }
-
- if (1 == count) {
- _D("There is only one page");
- eina_list_free(list);
- return page;
- }
-
- eina_list_free(list);
- return page;
- }
-
- eina_list_free(list);
-
- return NULL;
-}
-
-
-
-static void _change_favorites_order_cb(keynode_t *node, void *data)
-{
- int value = -1;
-
- _D("Change favorites order");
-
- /* check Emergency Mode */
- if(emergency_mode_enabled_get()) {
- _E("emergency mode enabled");
- return;
- }
-
- // 0 : init, 1 : backup request, 2 : restore request, 3: write done
- if(vconf_get_int(VCONF_KEY_WMS_FAVORITES_ORDER, &value) < 0) {
- _E("Failed to get VCONF_KEY_WMS_FAVORITES_ORDER");
- return;
- }
-
- _D("Change favorites order vconf:[%d]", value);
-
- wms_change_favorite_order(value);
-}
-
-
-
-static Eina_Bool _push_all_page_cb(void *data)
-{
- Evas_Object *scroller = data;
- Eina_List *page_info_list = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- void (*after_func)(void *);
- void *after_func_data = NULL;
- static int i = 0;
- int count = 0;
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- page_info_list = evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_LIST);
- if (!page_info_list) {
- _W("page_info_list is NULL");
- goto END;
- }
-
- page_info = eina_list_nth(page_info_list, i);
- if (!page_info) {
- if (!i) {
- _W("page_info_list is zero");
- }
- goto END;
- }
- i++;
-
- page_info->item = widget_create(scroller, page_info->id, page_info->subid, page_info->period);
- if (!page_info->item) {
- _E("cannot create a widget");
- return ECORE_CALLBACK_RENEW;
- }
- widget_viewer_evas_disable_loading(page_info->item);
- evas_object_resize(page_info->item, scroller_info->page_width, scroller_info->page_height);
- evas_object_size_hint_min_set(page_info->item, scroller_info->page_width, scroller_info->page_height);
- evas_object_show(page_info->item);
-
- page_info->page = page_create(scroller
- , page_info->item
- , page_info->id, page_info->subid
- , scroller_info->page_width, scroller_info->page_height
- , PAGE_CHANGEABLE_BG_ON, PAGE_REMOVABLE_ON);
- if (!page_info->page) {
- evas_object_del(page_info->item);
- _E("cannot create a page");
- goto END;
- }
- widget_add_callback(page_info->item, page_info->page);
-
- page_set_effect(page_info->page, page_effect_none, page_effect_none);
- scroller_push_page(scroller, page_info->page, SCROLLER_PUSH_TYPE_LAST);
-
- return ECORE_CALLBACK_RENEW;
-
-END:
- /* If there are 15 pages, do not append the plus page */
- count = scroller_count_direction(scroller, PAGE_DIRECTION_RIGHT);
- if (count < MAX_WIDGET
- && !main_get_info()->is_tts
- && page_create_plus_page(scroller))
- {
- page_set_effect(scroller_info->plus_page, page_effect_none, page_effect_none);
- scroller_push_page(scroller, scroller_info->plus_page, SCROLLER_PUSH_TYPE_LAST);
- }
-
- after_func = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC);
- after_func_data = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA);
-
- if (after_func) {
- after_func(after_func_data);
- }
-
- _W("It's done to push all the pages(%d)", i);
- i = 0;
-
- layout_hide_multi_index(scroller_info->indicator_layout);
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_PUSH_ALL_TIMER);
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_LIST);
-
- if (!main_get_booting_state()) {
- _W("First boot");
- main_inc_booting_state();
- _change_favorites_order_cb(NULL, NULL);
-
- /* wms vconf has to be dealt after pushing pages */
- if (vconf_notify_key_changed(VCONF_KEY_WMS_FAVORITES_ORDER, _change_favorites_order_cb, NULL) < 0) {
- _E("Failed to register the changed_apps_order callback");
- }
- }
-
- /* Key register */
- key_register();
-
- if (main_get_info()->is_tts) {
- _W("TTS Mode : Do not save orders of widgets");
- return ECORE_CALLBACK_CANCEL;
- }
-
- /* Widgets can be removed before launching w-home */
- /* But, we do not need to refresh the DB */
- count = scroller_count_direction(scroller, PAGE_DIRECTION_RIGHT);
- if (count <= 1) {
- _E("Right page is only one or zero");
- }
-
- wms_change_favorite_order(W_HOME_WMS_BACKUP);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-/* This dummy will be destroyed by the clock */
-static w_home_error_e _dummy_center(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Evas_Object *center = NULL;
- scroller_info_s *scroller_info = NULL;
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- center = evas_object_rectangle_add(main_get_info()->e);
- retv_if(!center, W_HOME_ERROR_FAIL);
-
- page = page_create(scroller
- , center
- , NULL, NULL
- , scroller_info->page_width, scroller_info->page_height
- , PAGE_CHANGEABLE_BG_OFF, PAGE_REMOVABLE_OFF);
- if (!page) {
- _E("Cannot create a page");
- evas_object_del(center);
- return W_HOME_ERROR_FAIL;
- }
-
- evas_object_data_set(page, PRIVATE_DATA_KEY_IS_DUMMY, (void*)1);
- page_set_effect(scroller_info->plus_page, page_effect_none, page_effect_none);
- scroller_push_page(scroller, page, SCROLLER_PUSH_TYPE_CENTER);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI w_home_error_e scroller_push_pages(Evas_Object *scroller, Eina_List *page_info_list, void (*after_func)(void *), void *data)
-{
- Ecore_Timer *timer = NULL;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, W_HOME_ERROR_INVALID_PARAMETER);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, W_HOME_ERROR_FAIL);
-
- timer = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_PUSH_ALL_TIMER);
- if (timer) {
- _D("There is already a timer for popping all items.");
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- if (!scroller_info->center && W_HOME_ERROR_NONE != _dummy_center(scroller)) {
- _E("Cannot create a dummy clock");
- }
-
- /* We have to prevent pushing pages doubly */
- /* We don't need to care about LEFT pages according to UIG */
- scroller_pop_pages(scroller, PAGE_DIRECTION_RIGHT);
-
- timer = ecore_timer_add(0.01f, _push_all_page_cb, scroller);
- if (!timer) {
- _E("Cannot add a timer");
- return W_HOME_ERROR_FAIL;
- }
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_PUSH_ALL_TIMER, timer);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_LIST, page_info_list);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC, after_func);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA, data);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-HAPI void scroller_pop_pages(Evas_Object *scroller, page_direction_e direction)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!scroller);
-
- _W("pop all the pages");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- switch (direction) {
- case PAGE_DIRECTION_LEFT:
- scroller_info->center_neighbor_left = NULL;
- break;
- case PAGE_DIRECTION_CENTER:
- scroller_info->center = NULL;
- break;
- case PAGE_DIRECTION_RIGHT:
- scroller_info->center_neighbor_right = NULL;
- page_destroy_plus_page(scroller);
- break;
- case PAGE_DIRECTION_ANY:
- scroller_info->center_neighbor_left = NULL;
- scroller_info->center = NULL;
- scroller_info->center_neighbor_right = NULL;
- page_destroy_plus_page(scroller);
- break;
- default:
- _E("Cannot reach here");
- break;
- }
-
- list = elm_box_children_get(scroller_info->box);
- if (!list) return;
-
- EINA_LIST_FREE(list, page) {
- continue_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (PAGE_DIRECTION_ANY != direction
- && direction != page_info->direction)
- {
- continue;
- }
-
- if (PAGE_DIRECTION_RIGHT == page_info->direction) {
- elm_object_part_content_unset(page_info->page_inner, "item");
- evas_object_del(page_info->item);
- }
-
- scroller_pop_page(scroller, page);
- page_destroy(page);
- }
-}
-
-
-
-HAPI int scroller_count(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
- Eina_List *list = NULL;
- int count;
-
- retv_if(NULL == scroller, 0);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, 0);
-
- list = elm_box_children_get(scroller_info->box);
- if (NULL == list) return 0;
-
- count = eina_list_count(list);
- eina_list_free(list);
-
- return count;
-}
-
-
-
-HAPI int scroller_count_direction(Evas_Object *scroller, page_direction_e direction)
-{
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- Eina_List *list = NULL;
- int count = 0;
-
- retv_if(NULL == scroller, 0);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, 0);
-
- list = elm_box_children_get(scroller_info->box);
- if (NULL == list) return 0;
-
- EINA_LIST_FREE(list, page) {
- continue_if(!page);
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- if (page_info->direction == direction) count++;
- }
-
- return count;
-}
-
-
-
-HAPI Eina_Bool scroller_is_scrolling(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, EINA_FALSE);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, EINA_FALSE);
-
- return scroller_info->scrolling? EINA_TRUE:EINA_FALSE;
-}
-
-
-
-HAPI void scroller_freeze(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- elm_object_scroll_freeze_push(scroller_info->box);
-}
-
-
-
-HAPI void scroller_unfreeze(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(NULL == scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- while (elm_object_scroll_freeze_get(scroller_info->box)) {
- elm_object_scroll_freeze_pop(scroller_info->box);
- }
-}
-
-
-
-static inline int _get_index_in_list(Evas_Object *box, Evas_Object *page)
-{
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
-
- list = elm_box_children_get(box);
- retv_if(!list, 0);
-
- int exist = 1;
- int i = 0;
-
- EINA_LIST_FREE(list, tmp) {
- continue_if(!tmp);
- if (tmp == page)
- exist = 0;
- i += exist;
- }
-
- if (exist) {
- i = 0;
- }
- return i;
-}
-
-
-
-static inline void _page_bring_in(Evas_Object *scroller, int index, scroller_freeze_e is_freezed)
-{
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int cur_freezed = 0;
- int j;
-
- page = scroller_get_page_at(scroller, index);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- cur_freezed = elm_object_scroll_freeze_get(scroller_info->box);
-
- if (is_freezed) scroller_unfreeze(scroller);
-
- _D("Bring in now : %d(%p)", index, page);
-
- elm_scroller_page_bring_in(scroller, index, 0);
- if (is_freezed && cur_freezed) scroller_freeze(scroller);
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- for (j = 0; j < PAGE_DIRECTION_ANY; j++) {
- multi_index_bring_in_page(scroller_info->index[j], page);
- }
- scroller_add_index_hide_timer(scroller);
- } else {
- index_bring_in_page(scroller_info->single_index, page);
- }
-}
-
-
-
-static inline void _page_show(Evas_Object *scroller, int index, scroller_freeze_e is_freezed)
-{
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int cur_freezed = 0;
- int i;
-
- page = scroller_get_page_at(scroller, index);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- cur_freezed = elm_object_scroll_freeze_get(scroller_info->box);
-
- if (is_freezed) scroller_unfreeze(scroller);
-#if 0 /* EFL Private feature */
- elm_scroller_origin_reverse_set(scroller, EINA_FALSE, EINA_FALSE);
-#endif
- _D("Page show now : %d(%p), direction: %d", index, page, page_info->direction);
- elm_scroller_page_show(scroller, index, 0);
- if (is_freezed && cur_freezed) scroller_freeze(scroller);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- for (i = 0; i < PAGE_DIRECTION_ANY; i++) {
- multi_index_bring_in_page(scroller_info->index[i], page);
- }
- } else {
- index_bring_in_page(scroller_info->single_index, page);
- }
-}
-
-
-
-static Eina_Bool _bring_in_anim_cb(void *data)
-{
- Evas_Object *scroller = data;
- int i = 0;
- int is_freezed = 0;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- i = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE);
- is_freezed = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED);
-
- _page_bring_in(scroller, i, is_freezed);
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static void _bring_in_job_cb(void *data)
-{
- Evas_Object *scroller = data;
- int i = 0;
- int is_freezed = 0;
-
- ret_if(!scroller);
-
- i = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE);
- is_freezed = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED);
-
- _page_bring_in(scroller, i, is_freezed);
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
-}
-
-
-
-HAPI void scroller_bring_in_by_push_type(Evas_Object *scroller, scroller_push_type_e push_type, scroller_freeze_e freeze, scroller_bring_type_e bring_type)
-{
- Evas_Object *page = NULL;
- Ecore_Animator *anim = NULL;
- Ecore_Job *job = NULL;
- scroller_info_s *scroller_info = NULL;
- int i = 0;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- switch (push_type) {
- case SCROLLER_PUSH_TYPE_CENTER:
- page = scroller_info->center;
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT:
- page = scroller_info->center_neighbor_left;
- if (page == NULL) {
- page = scroller_get_left_page(scroller, scroller_info->center);
- }
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_RIGHT:
- page = scroller_info->center_neighbor_right;
- if (page == NULL) {
- page = scroller_get_right_page(scroller, scroller_info->center);
- }
- break;
- default:
- _E("Unsupported push-type:%d", push_type);
- break;
- }
- ret_if(!page);
- i = _get_index_in_list(scroller_info->box, page);
-
- /* 1. Remove the old action */
- job = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
- if (job) ecore_job_del(job);
-
- anim = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- if (anim) ecore_animator_del(anim);
-
- /* 2. Append the new timer */
- switch (bring_type) {
- case SCROLLER_BRING_TYPE_INSTANT_SHOW:
- _page_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_INSTANT:
- _page_bring_in(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_JOB:
- job = ecore_job_add(_bring_in_job_cb, scroller);
- if (job) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB, job);
- else _E("Cannot add a job");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- case SCROLLER_BRING_TYPE_ANIMATOR:
- anim = ecore_animator_add(_bring_in_anim_cb, scroller);
- if (anim) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM, anim);
- else _E("Cannot add an animator");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- default:
- _E("Unsupported bring_type:%d", bring_type);
- break;
- }
-}
-
-
-
-HAPI void scroller_bring_in(Evas_Object *scroller, int i, scroller_freeze_e freeze, scroller_bring_type_e bring_type)
-{
- Ecore_Animator *anim = NULL;
- Ecore_Job *job = NULL;
-
- ret_if(!scroller);
-
- /* 1. Remove the old action */
- job = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
- if (job) ecore_job_del(job);
-
- anim = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- if (anim) ecore_animator_del(anim);
-
- /* 2. Append the new timer */
- switch (bring_type) {
- case SCROLLER_BRING_TYPE_INSTANT_SHOW:
- _page_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_INSTANT:
- _page_bring_in(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_JOB:
- job = ecore_job_add(_bring_in_job_cb, scroller);
- if (job) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB, job);
- else _E("Cannot add a job");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- case SCROLLER_BRING_TYPE_ANIMATOR:
- anim = ecore_animator_add(_bring_in_anim_cb, scroller);
- if (anim) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM, anim);
- else _E("Cannot add an animator");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- default:
- _E("Unsupported bring_type:%d", bring_type);
- break;
- }
-}
-
-
-
-HAPI void scroller_bring_in_page(Evas_Object *scroller, Evas_Object *page, scroller_freeze_e freeze, scroller_bring_type_e bring_type)
-{
- scroller_info_s *scroller_info = NULL;
- Ecore_Animator *anim = NULL;
- Ecore_Job *job = NULL;
- int i = 0;
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- i = _get_index_in_list(scroller_info->box, page);
-
- /* 1. Remove the old action */
- job = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
- if (job) ecore_job_del(job);
-
- anim = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- if (anim) ecore_animator_del(anim);
-
- /* 2. Append the new timer */
- switch (bring_type) {
- case SCROLLER_BRING_TYPE_INSTANT_SHOW:
- _page_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_INSTANT:
- _page_bring_in(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_JOB:
- job = ecore_job_add(_bring_in_job_cb, scroller);
- if (job) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB, job);
- else _E("Cannot add a job");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- case SCROLLER_BRING_TYPE_ANIMATOR:
- anim = ecore_animator_add(_bring_in_anim_cb, scroller);
- if (anim) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM, anim);
- else _E("Cannot add an animator");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- default:
- _E("Unsupported bring_type:%d", bring_type);
- break;
- }
-
-}
-
-
-
-static Eina_Bool _bring_in_center_timer_cb(void *data)
-{
- Evas_Object *scroller = data;
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- void (*before_func)(void *);
- void (*after_func)(void *);
- void *func_data = NULL;
-
- int page_w = 0;
- int total_x = 0;
-
- /* 1. Before function */
- before_func = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC);
- if (before_func) {
- func_data = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC_DATA);
- before_func(func_data);
- return ECORE_CALLBACK_RENEW;
- }
-
- /* 2. Bring in */
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- page = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_PRESSED_PAGE);
- if (page) {
- Evas_Object *tmp_page = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- int is_freezed = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED);
- int sw, sh;
- int cur_freezed = 0;
- int i;
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, ECORE_CALLBACK_CANCEL);
-
- cur_freezed = elm_object_scroll_freeze_get(scroller_info->box);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp_page) {
- continue_if(!tmp_page);
- if (tmp_page == page) break;
- evas_object_geometry_get(tmp_page, NULL, NULL, &page_w, NULL);
- total_x += page_w;
- }
- eina_list_free(list);
- evas_object_geometry_get(scroller, NULL, NULL, &sw, &sh);
-
- if (is_freezed) scroller_unfreeze(scroller);
- elm_scroller_region_bring_in(scroller, total_x, 0, sw, sh);
- if (is_freezed && cur_freezed) scroller_freeze(scroller);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, ECORE_CALLBACK_RENEW);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- for (i = 0; i < PAGE_DIRECTION_ANY; i++) {
- multi_index_bring_in_page(scroller_info->index[i], page);
- }
- } else {
- index_bring_in_page(scroller_info->single_index, page);
- }
-
- return ECORE_CALLBACK_RENEW;
- }
-
- /* 3. After function */
- after_func = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC);
- if (after_func) {
- func_data = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA);
- after_func(func_data);
- }
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-HAPI void scroller_bring_in_center_of(Evas_Object *scroller
- , Evas_Object *page
- , scroller_freeze_e freeze
- , void (*before_func)(void *), void *before_data
- , void (*after_func)(void *), void *after_data)
-{
- scroller_info_s *scroller_info = NULL;
- Ecore_Timer *timer = NULL;
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_PRESSED_PAGE, page);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC, before_func);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC_DATA, before_data);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC, after_func);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA, after_data);
-
- /* 1. Remove the old timer */
- timer = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER);
- if (timer) {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- /* 2. Append the new timer */
- timer = ecore_timer_add(0.01f, _bring_in_center_timer_cb, scroller);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER, timer);
-}
-
-
-
-static Eina_Bool _region_show_center_timer_cb(void *data)
-{
- Evas_Object *scroller = data;
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- void (*before_func)(void *);
- void (*after_func)(void *);
- void *func_data = NULL;
-
- int page_w = 0;
- int total_x = 0;
-
- /* 1. Before function */
- before_func = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC);
- if (before_func) {
- func_data = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC_DATA);
- before_func(func_data);
- return ECORE_CALLBACK_RENEW;
- }
-
- /* 2. Bring in */
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, ECORE_CALLBACK_CANCEL);
-
- page = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_PRESSED_PAGE);
- if (page) {
- Evas_Object *tmp_page = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- int is_freezed = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED);
- int cur_freezed = 0;
- int sw, sh;
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, ECORE_CALLBACK_CANCEL);
-
- cur_freezed = elm_object_scroll_freeze_get(scroller_info->box);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp_page) {
- continue_if(!tmp_page);
- if (tmp_page == page) break;
- evas_object_geometry_get(tmp_page, NULL, NULL, &page_w, NULL);
- total_x += page_w;
- }
- eina_list_free(list);
- evas_object_geometry_get(scroller, NULL, NULL, &sw, &sh);
-
- if (is_freezed) scroller_unfreeze(scroller);
- _D("Region show now : %d", total_x);
- elm_scroller_region_show(scroller, total_x, 0, sw, sh);
- if (is_freezed && cur_freezed) scroller_freeze(scroller);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, ECORE_CALLBACK_RENEW);
-
- return ECORE_CALLBACK_RENEW;
- }
-
- /* 3. After function */
- after_func = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC);
- if (after_func) {
- func_data = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA);
- after_func(func_data);
- }
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-HAPI void scroller_region_show_center_of(Evas_Object *scroller
- , Evas_Object *page
- , scroller_freeze_e freeze
- , void (*before_func)(void *), void *before_data
- , void (*after_func)(void *), void *after_data)
-{
- Ecore_Timer *timer = NULL;
-
- ret_if(!scroller);
- ret_if(!page);
-
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_PRESSED_PAGE, page);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC, before_func);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BEFORE_FUNC_DATA, before_data);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC, after_func);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_AFTER_FUNC_DATA, after_data);
-
- /* 1. Remove the old timer */
- timer = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER);
- if (timer) {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- /* 2. Append the new timer */
- timer = ecore_timer_add(0.01f, _region_show_center_timer_cb, scroller);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_TIMER, timer);
-}
-
-
-
-static inline void _page_region_show(Evas_Object *scroller, int index, scroller_freeze_e is_freezed)
-{
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int cur_freezed = 0;
- int i;
-
- page = scroller_get_page_at(scroller, index);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- elm_object_tree_focus_allow_set(scroller, EINA_TRUE);
- page_focus(page);
-
- cur_freezed = elm_object_scroll_freeze_get(scroller_info->box);
-
- if (is_freezed) scroller_unfreeze(scroller);
- _D("Page show now : %d(%p)", index, page);
- elm_scroller_page_show(scroller, index, 0);
- if (is_freezed && cur_freezed) scroller_freeze(scroller);
-
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- for (i = 0; i < PAGE_DIRECTION_ANY; i++) {
- multi_index_bring_in_page(scroller_info->index[i], page);
- }
- } else {
- index_bring_in_page(scroller_info->single_index, page);
- }
-}
-
-
-
-static void _region_show_job_cb(void *data)
-{
- Evas_Object *scroller = data;
- int i = 0;
- int is_freezed = 0;
-
- ret_if(!scroller);
-
- i = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE);
- is_freezed = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED);
-
- _page_region_show(scroller, i, is_freezed);
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
-}
-
-
-
-static Eina_Bool _region_show_anim_cb(void *data)
-{
- Evas_Object *scroller = data;
- int i = 0;
- int is_freezed = 0;
-
- retv_if(!scroller, ECORE_CALLBACK_CANCEL);
-
- i = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE);
- is_freezed = (int) evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED);
-
- _page_region_show(scroller, i, is_freezed);
-
- evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-HAPI void scroller_region_show_by_push_type(Evas_Object *scroller, scroller_push_type_e push_type, scroller_freeze_e freeze, scroller_bring_type_e bring_type)
-{
- Evas_Object *page = NULL;
- Ecore_Animator *anim = NULL;
- Ecore_Job *job = NULL;
- scroller_info_s *scroller_info = NULL;
- int i = 0;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- switch (push_type) {
- case SCROLLER_PUSH_TYPE_CENTER:
- page = scroller_info->center;
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_LEFT:
- page = scroller_info->center_neighbor_left;
- break;
- case SCROLLER_PUSH_TYPE_CENTER_NEIGHBOR_RIGHT:
- page = scroller_info->center_neighbor_right;
- break;
- default:
- _E("Unsupported push-type:%d", push_type);
- break;
- }
- ret_if(!page);
-
- i = _get_index_in_list(scroller_info->box, page);
-
- /* 1. Remove the old action */
- job = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
- if (job) ecore_job_del(job);
-
- anim = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- if (anim) ecore_animator_del(anim);
-
- /* 2. Append the new timer */
- switch (bring_type) {
- case SCROLLER_BRING_TYPE_INSTANT_SHOW:
- _page_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_INSTANT:
- _page_region_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_JOB:
- job = ecore_job_add(_region_show_job_cb, scroller);
- if (job) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB, job);
- else _E("Cannot add a job");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- case SCROLLER_BRING_TYPE_ANIMATOR:
- anim = ecore_animator_add(_region_show_anim_cb, scroller);
- if (anim) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM, anim);
- else _E("Cannot add an animator");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- default:
- _E("Unsupported bring_type:%d", bring_type);
- break;
- }
-}
-
-
-
-HAPI void scroller_region_show_page(Evas_Object *scroller, Evas_Object *page, scroller_freeze_e freeze, scroller_bring_type_e bring_type)
-{
- Ecore_Animator *anim = NULL;
- Ecore_Job *job = NULL;
- scroller_info_s *scroller_info = NULL;
- int i = 0;
-
-
- ret_if(!scroller);
- ret_if(!page);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- i = _get_index_in_list(scroller_info->box, page);
-
- /* 1. Remove the old action */
- job = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB);
- if (job) ecore_job_del(job);
-
- anim = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM);
- if (anim) ecore_animator_del(anim);
-
- /* 2. Append the new timer */
- switch (bring_type) {
- case SCROLLER_BRING_TYPE_INSTANT_SHOW:
- _page_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_INSTANT:
- _page_region_show(scroller, i, freeze);
- break;
- case SCROLLER_BRING_TYPE_JOB:
- job = ecore_job_add(_region_show_job_cb, scroller);
- if (job) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_JOB, job);
- else _E("Cannot add a job");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- case SCROLLER_BRING_TYPE_ANIMATOR:
- anim = ecore_animator_add(_region_show_anim_cb, scroller);
- if (anim) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_ANIM, anim);
- else _E("Cannot add an animator");
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_BRING_IN_PAGE, (void *) i);
- evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_FREEZED, (void *) freeze);
- break;
- default:
- _E("Unsupported bring_type:%d", bring_type);
- break;
- }
-}
-
-
-
-static Evas_Object *_pop_page_in_list(Eina_List **list, const char *id, const char *subid)
-{
- Evas_Object *page = NULL;
- const Eina_List *l, *ln;
- page_info_s *page_info = NULL;
-
- retv_if(!list, NULL);
- retv_if(!id, NULL);
-
- EINA_LIST_FOREACH_SAFE(*list, l, ln, page) {
- continue_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
- if (!page_info->id) continue;
-
- if (strcmp(page_info->id, id)) continue;
-
- if (!subid && !page_info->subid) {
- *list = eina_list_remove(*list, page);
- return page;
- }
-
- if (subid
- && page_info->subid
- && !strcmp(subid, page_info->subid))
- {
- *list = eina_list_remove(*list, page);
- return page;
- }
- }
-
- return NULL;
-}
-
-
-
-static page_info_s *_get_page_info_in_list(page_info_s *scroller_page_info, Eina_List *page_info_list)
-{
- const Eina_List *l, *ln;
- page_info_s *page_info = NULL;
-
- retv_if(!scroller_page_info, NULL);
- retv_if(!scroller_page_info->id, NULL);
- retv_if(!page_info_list, NULL);
-
- EINA_LIST_FOREACH_SAFE(page_info_list, l, ln, page_info) {
- continue_if(!page_info);
- continue_if(!page_info->id);
-
- if (!strcmp(scroller_page_info->id, page_info->id)) {
- if (((scroller_page_info->subid && page_info->subid)
- && !strcmp(scroller_page_info->subid, page_info->subid))
- || (!scroller_page_info->subid && !page_info->subid))
- {
- return page_info;
- }
- }
- }
- return NULL;
-}
-
-
-
-static Evas_Object *_get_page_in_list(page_info_s *page_info, Eina_List *list)
-{
- const Eina_List *l, *ln;
- Evas_Object *page = NULL;
- page_info_s *scroller_page_info = NULL;
-
- retv_if(!page_info, NULL);
- retv_if(!page_info->id, NULL);
- retv_if(!list, NULL);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- continue_if(!page);
-
- scroller_page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!scroller_page_info);
- if (!scroller_page_info->id) continue;
-
- if (!strcmp(scroller_page_info->id, page_info->id)) {
- if (((scroller_page_info->subid && page_info->subid)
- && !strcmp(scroller_page_info->subid, page_info->subid))
- || (!scroller_page_info->subid && !page_info->subid))
- {
- return scroller_page_info->page;
- }
- }
- }
- return NULL;
-}
-
-
-
-HAPI void scroller_read_favorites_list(Evas_Object *scroller, Eina_List *page_info_list)
-{
- Evas_Object *page = NULL;
- Evas_Object *scroller_page = NULL;
- Evas_Object *before_page = NULL;
-
- Eina_List *list = NULL;
- Eina_List *cloned_page_info_list = NULL;
- const Eina_List *l, *ln;
-
- scroller_info_s *scroller_info = NULL;
- page_info_s *scroller_page_info = NULL;
- page_info_s *page_info = NULL;
- page_info_s *clone_info = NULL;
-
- ret_if(!scroller);
- ret_if(!page_info_list);
-
- cloned_page_info_list = eina_list_clone(page_info_list);
- ret_if(!cloned_page_info_list);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- before_page = scroller_info->center;
-
- /* 1. Remove widgets those are not in the page_info_list */
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- continue_if(!page);
-
- scroller_page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- continue_if(!scroller_page_info);
- if (!scroller_page_info->id) continue;
-
- if (scroller_page_info->direction != PAGE_DIRECTION_RIGHT) continue;
-
- clone_info = _get_page_info_in_list(scroller_page_info, cloned_page_info_list);
- if (clone_info) {
- _D("Keep this widget : %s(%p)", scroller_page_info->id, page);
- cloned_page_info_list = eina_list_remove(cloned_page_info_list, clone_info);
- continue;
- } else {
- _D("Do not keep this widget : %s(%p)", scroller_page_info->id, page);
- list = eina_list_remove(list, scroller_page_info->page);
- page_destroy(scroller_page_info->page);
- }
- }
-
- /* 2. Create widgets those are not in the scroller */
- EINA_LIST_FOREACH_SAFE(page_info_list, l, ln, page_info) {
- continue_if(!page_info);
- continue_if(!page_info->id);
-
- scroller_page = _get_page_in_list(page_info, list);
- if (scroller_page) {
- _D("Reorder this widget : %s(%p)", page_info->id, scroller_page);
- _elm_box_unpack(scroller, scroller_page);
- _elm_box_pack_after(scroller, scroller_page, before_page);
- before_page = scroller_page;
- continue;
- } else {
- /* Page create */
- page_info->item = widget_create(scroller, page_info->id, page_info->subid, page_info->period);
- ret_if (!page_info->item);
- widget_viewer_evas_disable_loading(page_info->item);
- evas_object_resize(page_info->item, scroller_info->page_width, scroller_info->page_height);
- evas_object_size_hint_min_set(page_info->item, scroller_info->page_width, scroller_info->page_height);
- evas_object_show(page_info->item);
-
- page_info->page = page_create(scroller
- , page_info->item
- , page_info->id, page_info->subid
- , scroller_info->page_width, scroller_info->page_height
- , PAGE_CHANGEABLE_BG_ON, PAGE_REMOVABLE_ON);
- if (!page_info->page) {
- _E("Cannot create a page");
- evas_object_del(page_info->item);
- return;
- }
- widget_add_callback(page_info->item, page_info->page);
-
- page_set_effect(page_info->page, page_effect_none, page_effect_none);
- scroller_push_page(scroller, page_info->page, SCROLLER_PUSH_TYPE_LAST);
-
- before_page = page_info->page;
-
- _D("Create this widget : %s(%p)", page_info->id, page_info->page);
- }
- }
-
- eina_list_free(list);
- eina_list_free(cloned_page_info_list);
-
- page_arrange_plus_page(scroller, 0);
-}
-
-
-
-/* Caution : Do not create & destroy an item */
-HAPI void scroller_read_list(Evas_Object *scroller, Eina_List *page_info_list)
-{
- Evas_Object *page = NULL;
- Evas_Object *before_page = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!scroller);
- ret_if(!page_info_list);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- before_page = scroller_info->center;
-
- EINA_LIST_FOREACH_SAFE(page_info_list, l, ln, page_info) {
- continue_if(!page_info);
- continue_if(!page_info->id);
-
- if (page_info->direction != PAGE_DIRECTION_RIGHT) continue;
-
- page = _pop_page_in_list(&list, page_info->id, page_info->subid);
- if (page) {
- _elm_box_unpack(scroller, page);
- _elm_box_pack_after(scroller, page, before_page);
- before_page = page;
- }
- }
-
- eina_list_free(list);
-}
-
-
-
-HAPI Eina_List *scroller_write_list(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- page_info_s *dup_page_info = NULL;
- Eina_List *list = NULL;
- Eina_List *page_info_list = NULL;
- const Eina_List *l, *ln;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, NULL);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- continue_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) continue;
- if (!page_info->id) continue;
- if (PAGE_DIRECTION_RIGHT != page_info->direction) continue;
-
- dup_page_info = page_info_dup(page_info);
- continue_if(!dup_page_info);
-
- page_info_list = eina_list_append(page_info_list, dup_page_info);
- }
- eina_list_free(list);
-
- return page_info_list;
-}
-
-
-
-HAPI Evas_Object *scroller_move_page_prev(Evas_Object *scroller, Evas_Object *from_page, Evas_Object *to_page, Evas_Object *append_page)
-{
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, NULL);
- retv_if(!from_page, NULL);
- retv_if(!to_page, NULL);
- retv_if(!append_page, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- _elm_box_unpack(scroller, from_page);
- _elm_box_pack_after(scroller, append_page, to_page);
-
- return from_page;
-}
-
-
-
-HAPI Evas_Object *scroller_move_page_next(Evas_Object *scroller, Evas_Object *from_page, Evas_Object *to_page, Evas_Object *insert_page)
-{
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, NULL);
- retv_if(!from_page, NULL);
- retv_if(!to_page, NULL);
- retv_if(!insert_page, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- _elm_box_unpack(scroller, to_page);
- _elm_box_pack_before(scroller, insert_page, from_page);
-
- return to_page;
-}
-
-
-
-HAPI int scroller_seek_page_position(Evas_Object *scroller, Evas_Object *page)
-{
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- int position = 0;
-
- retv_if(!scroller, -1);
- retv_if(!page, -1);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, -1);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, -1);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp) {
- continue_if(!tmp);
- if (page == tmp) {
- eina_list_free(list);
- return position;
- }
- position++;
- }
-
- eina_list_free(list);
- return -1;
-}
-
-
-
-HAPI Evas_Object *scroller_get_page_at(Evas_Object *scroller, int idx)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
- int position = 0;
-
- retv_if(!scroller, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(NULL == list, NULL);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, page) {
- if (idx == position) {
- eina_list_free(list);
- return page;
- }
- position ++;
- }
- eina_list_free(list);
- return NULL;
-}
-
-
-
-HAPI int scroller_get_current_page_direction(Evas_Object *scroller)
-{
- Evas_Object *cur_page = NULL;
- page_info_s *page_info = NULL;
-
- retv_if(!scroller, -1);
-
- cur_page = scroller_get_focused_page(scroller);
- retv_if(!cur_page, -1);
-
- page_info = evas_object_data_get(cur_page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, -1);
-
- return page_info->direction;
-}
-
-
-
-HAPI Evas_Object *scroller_get_left_page(Evas_Object *scroller, Evas_Object *page)
-{
- Evas_Object *before_page = NULL;
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, NULL);
- retv_if(!page, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, NULL);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp) {
- continue_if(!tmp);
-
- if (page == tmp) break;
- before_page = tmp;
- }
- eina_list_free(list);
- return before_page;
-}
-
-
-
-HAPI Evas_Object *scroller_get_right_page(Evas_Object *scroller, Evas_Object *page)
-{
- Evas_Object *after_page = NULL;
- Evas_Object *tmp = NULL;
- Eina_List *list = NULL;
- const Eina_List *l, *ln;
- scroller_info_s *scroller_info = NULL;
-
- retv_if(!scroller, NULL);
- retv_if(!page, NULL);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, NULL);
-
- list = elm_box_children_get(scroller_info->box);
- retv_if(!list, NULL);
-
- EINA_LIST_FOREACH_SAFE(list, l, ln, tmp) {
- continue_if(!tmp);
-
- if (page == tmp) {
- after_page = eina_list_data_get(ln);
- break;
- }
- }
- eina_list_free(list);
- return after_page;
-}
-
-
-
-HAPI void scroller_region_show_page_without_timer(Evas_Object *scroller, Evas_Object *page)
-{
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- int i = 0;
- int j;
- ret_if(scroller == NULL);
- ret_if(page == NULL);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- i = _get_index_in_list(scroller_info->box, page);
-
-#if 0 /* EFL Private feature */
- elm_scroller_origin_reverse_set(scroller, EINA_FALSE, EINA_FALSE);
-#endif
- _D("Page show now : %d(%p)", i, page);
- elm_scroller_page_show(scroller, i, 0);
- if (scroller_info->scroller_type == WIDGETS_STATE_NORMAL) {
- for (j = 0; j < PAGE_DIRECTION_ANY; j++) {
- multi_index_bring_in_page(scroller_info->index[j], page);
- }
- } else {
- index_bring_in_page(scroller_info->single_index, page);
- }
-}
-
-
-
-HAPI void scroller_enable_focus_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- _D("Enable the focus on scroll");
-
- elm_object_tree_focus_allow_set(scroller, EINA_TRUE);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_focus = 1;
-}
-
-
-
-HAPI void scroller_disable_focus_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- _D("Disable the focus on scroll");
-
- elm_object_tree_focus_allow_set(scroller, EINA_FALSE);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_focus = 0;
-}
-
-
-
-HAPI void scroller_enable_index_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- _D("Enable the index on scroll");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_index = 1;
-}
-
-
-
-HAPI void scroller_disable_index_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- _D("Disable the index on scroll");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_index = 0;
-}
-
-
-
-HAPI void scroller_enable_effect_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- _D("Enable the effect on scroll");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_effect = 1;
-}
-
-
-
-HAPI void scroller_disable_effect_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- _D("Disable the effect on scroll");
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_effect = 0;
-}
-
-
-
-HAPI void scroller_enable_cover_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_cover = 1;
-}
-
-
-
-HAPI void scroller_disable_cover_on_scroll(Evas_Object *scroller)
-{
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- scroller_info->scroll_cover = 0;
-}
-
-
-
-HAPI void scroller_backup_inner_focus(Evas_Object *scroller)
-{
- Evas_Object *prev_page = NULL;
- Evas_Object *cur_page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->box);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- EINA_LIST_FREE(list, cur_page) {
- continue_if(!cur_page);
-
- if (prev_page) {
- page_backup_inner_focus(cur_page, prev_page, NULL);
- page_backup_inner_focus(prev_page, NULL, cur_page);
- }
-
- prev_page = cur_page;
- }
-}
-
-
-
-HAPI void scroller_restore_inner_focus(Evas_Object *scroller)
-{
- Evas_Object *page = NULL;
- Eina_List *list = NULL;
- scroller_info_s *scroller_info = NULL;
-
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->box);
-
- list = elm_box_children_get(scroller_info->box);
- ret_if(!list);
-
- EINA_LIST_FREE(list, page) {
- continue_if(!page);
- page_restore_inner_focus(page);
- }
-}
-
-
-
-/* This function just reorders not making a notification panel or widget */
-/* CRITICAL : You have to use this function only for notification reordering */
-HAPI void scroller_reorder_with_list(Evas_Object *scroller, Eina_List *list, page_direction_e page_direction)
-{
- Evas_Object *tmp_page = NULL;
- Evas_Object *focus_page = NULL;
- Evas_Object *after = NULL;
- Eina_List *reverse_list = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!scroller);
- ret_if(!list);
-
- reverse_list = eina_list_reverse_clone(list);
- ret_if(!reverse_list);
-
- focus_page = scroller_get_focused_page(scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->box);
-
- if (scroller_info->center_neighbor_right) {
- after = scroller_info->center_neighbor_right;
- } else {
- after = scroller_info->center;
- }
- ret_if(!after);
-
- EINA_LIST_FREE(reverse_list, tmp_page) {
- page_info = evas_object_data_get(tmp_page, DATA_KEY_PAGE_INFO);
- continue_if(!page_info);
-
- switch (page_info->direction) {
- case PAGE_DIRECTION_LEFT:
- _D("Reorder a page(%p) with pack_start", tmp_page);
- elm_box_unpack(scroller_info->box, tmp_page);
- elm_box_pack_start(scroller_info->box, tmp_page);
- break;
- case PAGE_DIRECTION_RIGHT:
- _D("Reorder a page(%p) with pack_after", tmp_page);
- elm_box_unpack(scroller_info->box, tmp_page);
- elm_box_pack_after(scroller_info->box, tmp_page, after);
- break;
- default:
- _E("Cannot reach here");
- break;
- }
- }
-
- elm_box_recalculate(scroller_info->box);
- elm_box_recalculate(scroller_info->box_layout);
-
- if (focus_page) scroller_region_show_page(scroller, focus_page, SCROLLER_FREEZE_OFF, SCROLLER_BRING_TYPE_INSTANT);
- else _E("Cannot get the focused page");
-
- scroller_info->index_update_timer = ecore_timer_add(INDEX_UPDATE_TIME, _index_update_cb, scroller);
- if (!scroller_info->index_update_timer) {
- _E("Cannot add an index update timer");
- }
-}
-
-HAPI int scroller_get_page_index_in_list(Evas_Object *scroller, Evas_Object *page)
-{
- scroller_info_s *scroller_info = NULL;
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- retv_if(!scroller_info, 0);
-
- return _get_index_in_list(scroller_info->box, page);
-}
-
-
-
-#define HIDE_TIME 1.0f
-HAPI void scroller_add_index_hide_timer(Evas_Object *scroller)
-{
- Ecore_Timer *hide_timer = NULL;
-
- hide_timer = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_HIDE_INDEX_TIMER);
- if (hide_timer) {
- ecore_timer_del(hide_timer);
- hide_timer = NULL;
- }
-
- hide_timer = ecore_timer_add(HIDE_TIME, _hide_index_timer_cb, scroller);
- if (hide_timer) evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_HIDE_INDEX_TIMER, hide_timer);
- else _E("Cannot add a hide_timer");
-}
-
-
-
-
-HAPI void scroller_remove_index_hide_timer(Evas_Object *scroller)
-{
- Ecore_Timer *hide_timer = NULL;
- scroller_info_s *scroller_info = NULL;
-
- hide_timer = evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_HIDE_INDEX_TIMER);
- if (hide_timer) {
- ecore_timer_del(hide_timer);
- hide_timer = NULL;
- }
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- layout_hide_multi_index(scroller_info->indicator_layout);
-}
-// End of this file
diff --git a/src/util.c b/src/util.c
deleted file mode 100755
index e233812..0000000
--- a/src/util.c
+++ /dev/null
@@ -1,1138 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <aul.h>
-#include <app.h>
-#include <appsvc.h>
-#include <bundle.h>
-#include <Elementary.h>
-#include <Evas.h>
-#include <dlog.h>
-#include <notification_status.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <vconf.h>
-#include <efl_extension.h>
-#include <efl_util.h>
-#include <pkgmgr-info.h>
-#include <widget_service.h>
-#include <bundle_internal.h>
-
-#include <unicode/unum.h>
-#include <unicode/ustring.h>
-
-#include "conf.h"
-#include "log.h"
-#include "util.h"
-#include "main.h"
-#include "power_mode.h"
-#include "dbus.h"
-#include "layout.h"
-#include "layout_info.h"
-#include "clock_service.h"
-
-#include <widget_errno.h>
-#include <Ecore.h>
-
-#include "apps/apps.h"
-
-
-
-
-HAPI int util_launch_app(const char *appid, const char *key, const char *value)
-{
- int pid = 0;
-
- retv_if(!appid, W_HOME_ERROR_INVALID_PARAMETER);
-
- if (key && value) {
- bundle *b = bundle_create();
- retv_if(!b, 0);
-
- bundle_add(b, key, value);
- home_dbus_cpu_booster_signal_send();
- pid = aul_launch_app(appid, b);
- bundle_free(b);
- } else {
- home_dbus_cpu_booster_signal_send();
- pid = aul_launch_app(appid, NULL);
- }
-
- if (pid < 0) {
- _E("Failed to launch %s(%d)", appid, pid);
- }
-
- return pid;
-}
-
-
-
-HAPI int util_feature_enabled_get(int feature)
-{
- int is_enabled = 1;
-
- if (feature & FEATURE_CLOCK_HIDDEN_BUTTON) {
- if (main_get_info()->is_tts) {
- return 0;
- }
- if (cooldown_mode_enabled_get() == 1) {
- return 0;
- }
-
- } else if (feature & FEATURE_CLOCK_VISUAL_CUE) {
- if (main_get_info()->is_tts) {
- return 0;
- }
- if (main_get_info()->is_alpm_clock_enabled == 1) {
- return 0;
- }
- if (emergency_mode_enabled_get() == 1) {
- return 0;
- }
- if (cooldown_mode_enabled_get() == 1) {
- return 0;
- }
- } else if (feature & FEATURE_CLOCK_SELECTOR) {
-#ifndef ENABLE_INDICATOR_BRIEFING_VIEW
- if (clock_manager_view_state_get(CLOCK_VIEW_TYPE_DRAWER) == 1) {
- return 0;
- }
-#endif
- if (main_get_info()->is_tts) {
- return 0;
- }
- if (emergency_mode_enabled_get() == 1) {
- return 0;
- }
- if (cooldown_mode_enabled_get() == 1) {
- return 0;
- }
- } else if (feature & FEATURE_APPS_BY_BEZEL_UP) {
- if (main_get_info()->is_tts) {
- return 0;
- }
-#ifndef ENABLE_INDICATOR_BRIEFING_VIEW
- if (clock_manager_view_state_get(CLOCK_VIEW_TYPE_DRAWER) == 1) {
- return 0;
- }
-#endif
- if (emergency_mode_enabled_get() == 1) {
- return 0;
- }
- if (cooldown_mode_enabled_get() == 1) {
- return 0;
- }
- } else if (feature & FEATURE_APPS) {
- if (emergency_mode_enabled_get() == 1) {
- return 0;
- }
- if (cooldown_mode_enabled_get() == 1) {
- return 0;
- }
- } else if (feature & FEATURE_CLOCK_CHANGE) {
- Evas_Object *win = main_get_info()->win;
- retv_if(win == NULL, is_enabled);
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- retv_if(layout == NULL, is_enabled);
-
- // disabled in editing
- if (layout_is_edit_mode(layout) == 1) {
- return 0;
- }
- } else if (feature & FEATURE_TUTORIAL) {
- if (emergency_mode_enabled_get() == 1) {
- return 0;
- }
- if (cooldown_mode_enabled_get() == 1) {
- return 0;
- }
- }
-
- return is_enabled;
-}
-
-HAPI const char *util_get_file_path(enum app_subdir dir, const char *relative)
-{
- static char buf[PATH_MAX];
- char *prefix;
-
- switch (dir) {
- case APP_DIR_DATA:
- prefix = app_get_data_path();
- break;
- case APP_DIR_RESOURCE:
- prefix = app_get_resource_path();
- break;
- default:
- LOGE("Not handled directory type.");
- return NULL;
- }
- size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative);
- free(prefix);
- if (res > sizeof(buf)) {
- LOGE("Path exceeded PATH_MAX");
- return NULL;
- }
-
- return &buf[0];
-}
-
-
-
-/*!
- *
- * usage)
- * app_service(...)
- * {
- * if (power_key pressed) {
- * int pid;
- * pid = util_find_top_visible_window();
- * if (pid == getpid()) {
- * // if (first page) {
- * // LCD_OFF
- * // } else {
- * // SCROLL TO THE FIRST PAGE
- * // }
- * } else {
- * // elm_win_activate(my_win);
- * }
- * }
- *
- */
-
-
-
-////////////////////////////////////////////////////////////////////
-// Apps util
-
-HAPI void _evas_object_event_changed_size_hints_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Coord w, h;
-
- evas_object_size_hint_min_get(obj, &w, &h);
- _D("%s : min (%d:%d)", data, w, h);
-
- evas_object_size_hint_max_get(obj, &w, &h);
- _D("%s : max (%d:%d)", data, w, h);
-}
-
-
-
-HAPI void _evas_object_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
- _D("%s(%p) is resized to (%d, %d, %d, %d)", data, obj, x, y, w, h);
-
- evas_object_size_hint_min_get(obj, &w, &h);
- _D("%s : min (%d:%d)", data, w, h);
-
- evas_object_size_hint_max_get(obj, &w, &h);
- _D("%s : max (%d:%d)", data, w, h);
-}
-
-
-
-void _evas_object_event_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- _D("%s(%p) IS REMOVED!", (const char *) data, obj);
-}
-
-
-
-void _evas_object_event_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
- _D("%s's GEOMETRY : [%d, %d, %d, %d]", (const char *) data, x, y, w, h);
-}
-
-
-
-void _evas_object_event_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
- _D("%s(%p)'s GEOMETRY : [%d, %d, %d, %d]", (const char *) data, obj, x, y, w, h);
-}
-
-
-
-void _evas_object_event_hide_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
- _D("%s(%p)'s GEOMETRY : [%d, %d, %d, %d]", (const char *) data, obj, x, y, w, h);
-}
-
-
-
-static Eina_Bool _unblock_cb(void *data)
-{
- retv_if(NULL == data, EINA_FALSE);
-
- return EINA_FALSE;
-}
-
-
-
-HAPI void apps_util_post_message_for_launch_fail(const char *name)
-{
- ret_if(NULL == name);
-
- int len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- char *inform = calloc(len, sizeof(char));
- ret_if(NULL == inform);
-
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
- notification_status_message_post(inform);
-
- free(inform);
-
- return;
-}
-
-
-
-static void _svc_cb(bundle *b, int request_code, appsvc_result_val result, void *data)
-{
- _D("Request code : %d");
-
- if (result != APPSVC_RES_OK) {
- char* inform;
- char* inform_with_ret;
- int len;
-
- const char *name = data;
- ret_if(NULL == name);
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, result);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- }
-}
-
-
-
-#define LAUNCH_WITH_SPECIAL_ROUTINE false
-#define PACKAGE_ORANGE_WORLD "widgetMor.orangeMobile"
-static bool _launch_special_package(const char *package, const char *name)
-{
- retv_if(NULL == package, false);
- retv_if(NULL == name, false);
-
- if (!strcmp(package, PACKAGE_ORANGE_WORLD)) {
- _D("Special launch for %s", PACKAGE_ORANGE_WORLD);
- bundle *b = bundle_create();
- retv_if(NULL == b, false);
-
- appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
- appsvc_set_uri(b, "http://m.orange.fr");
- appsvc_run_service(b, 0, _svc_cb, (void *) name);
-
- bundle_free(b);
-
- return true;
- }
-
- return false;
-}
-
-
-
-#define LAYOUT_BLOCK_INTERVAL 1.0
-HAPI void apps_util_launch(Evas_Object *win, const char *package, const char *name)
-{
- ret_if(NULL == package);
-
- if (!name) name = package;
- if (LAUNCH_WITH_SPECIAL_ROUTINE && _launch_special_package(package, name)) {
- return;
- }
-
- home_dbus_cpu_booster_signal_send();
-
- int ret_aul = aul_open_app(package);
- if (ret_aul < AUL_R_OK) {
-
- if(ret_aul == AUL_R_EREJECTED && cooldown_mode_warning_get()) {
- util_create_toast_popup(win, _("IDS_SM_BODY_THE_DEVICE_TEMPERATURE_IS_TOO_HIGH"));
- }
- else {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret_aul);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- }
- } else {
- _D("Launch app's ret : [%d]", ret_aul);
- _T(package);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-}
-
-
-
-HAPI void apps_util_launch_main_operation(Evas_Object *win, const char *app_id, const char *name)
-{
- ret_if(NULL == app_id);
-
- if (!name) name = app_id;
- app_control_h service = NULL;
- ret_if(APP_CONTROL_ERROR_NONE != app_control_create(&service));
- ret_if(NULL == service);
-
- app_control_set_operation(service, APP_CONTROL_OPERATION_MAIN);
- app_control_set_app_id(service, app_id);
-
- home_dbus_cpu_booster_signal_send();
-
- int ret = app_control_send_launch_request(service, NULL, NULL);
- if (APP_CONTROL_ERROR_NONE != ret) {
-
- if(ret == APP_CONTROL_ERROR_LAUNCH_REJECTED && cooldown_mode_warning_get()) {
- util_create_toast_popup(win, _("IDS_SM_BODY_THE_DEVICE_TEMPERATURE_IS_TOO_HIGH"));
- }
- else {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- goto ERROR;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- goto ERROR;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- }
- } else {
- _SD("Launch an app(%s:%s) ret : [%d]", app_id, name, ret);
- _T(app_id);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-
-ERROR:
- app_control_destroy(service);
-}
-
-
-
-HAPI void apps_util_launch_with_arg(Evas_Object *win, const char *app_id, const char *arg, const char *name)
-{
- ret_if(NULL == app_id);
- ret_if(NULL == arg);
-
- if (!name) name = app_id;
- if (LAUNCH_WITH_SPECIAL_ROUTINE && _launch_special_package(app_id, name)) {
- return;
- }
-
- _SD("Argument:(%s)", arg);
- int len = strlen(arg);
-
- bundle *b = NULL;
- b = bundle_decode((bundle_raw *) arg, len);
-
- /* AUL requests : Reset the caller appid as App-tray */
- const char *value = (char *)bundle_get_val(b, AUL_K_CALLER_APPID);
- if (value) bundle_del(b, AUL_K_CALLER_APPID);
-
- home_dbus_cpu_booster_signal_send();
-
- int ret = aul_launch_app(app_id, b);
- bundle_free(b);
-
- if (0 > ret) {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- } else {
- _SD("Launch an app(%s:%s) ret : [%d]", app_id, name, ret);
- _T(app_id);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-}
-
-
-
-HAPI void apps_util_launch_with_bundle(Evas_Object *win, const char *app_id, bundle *b, const char *name)
-{
- ret_if(NULL == app_id);
- ret_if(NULL == b);
-
- if (!name) name = app_id;
- if (LAUNCH_WITH_SPECIAL_ROUTINE && _launch_special_package(app_id, name)) {
- return;
- }
-
- home_dbus_cpu_booster_signal_send();
-
- int ret = aul_launch_app(app_id, b);
- if (0 > ret) {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- } else {
- _SD("Launch an app(%s:%s) ret : [%d]", app_id, name, ret);
- _T(app_id);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-}
-
-
-
-HAPI void apps_util_notify_to_home(int pid)
-{
- char *pkgname;
-
- if (pid <= 0)
- return;
-
- pkgname = vconf_get_str("db/setting/menuscreen/package_name");
- if (!pkgname)
- return;
-
- if (strcmp(pkgname, "org.tizen.cluster-home")) {
- free(pkgname);
- return;
- }
-
- _D("Service: (%s)\n", pkgname);
- free(pkgname);
-}
-
-
-static void _toast_popup_from_noti_destroy_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *popup = obj;
- ret_if(!popup);
-
- evas_object_del(popup);
-
- Evas_Object *win = (Evas_Object *)data;
- ret_if(!win);
-
- evas_object_del(win);
-}
-
-static void _toast_popup_destroy_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *popup = NULL;
- Evas_Object *parent = data;
- ret_if(!parent);
-
- popup = evas_object_data_del(parent, DATA_KEY_POPUP);
- if (popup) {
- evas_object_del(popup);
- }
-}
-
-
-/* This API is not allowed to use on the others */
-extern Evas_Object *elm_object_part_access_object_get(const Evas_Object *obj, const char *part);
-#define UTIL_TOAST_POPUP_TIMER 3.0
-int util_create_toast_popup(Evas_Object *parent, const char* text)
-{
- retv_if(!parent, EINA_FALSE);
-
- Evas_Object *popup = elm_popup_add(parent);
- Evas_Object *image = NULL;
- char buf[PATH_MAX];
- retv_if(!popup, EINA_FALSE);
-
- elm_object_style_set(popup, POPUP_STYLE_TOAST);
- elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- elm_object_part_text_set(popup, "elm.text", text);
- elm_object_domain_translatable_part_text_set(popup, "elm.text", PROJECT, text);
- if(main_get_info()->is_tts == EINA_FALSE)
- elm_popup_timeout_set(popup, UTIL_TOAST_POPUP_TIMER);
-
- image = elm_image_add(popup);
- snprintf(buf, sizeof(buf), "%s/tw_toast_popup_success.png", IMAGEDIR);
- elm_image_file_set(image, buf, NULL);
- elm_object_part_content_set(popup, "toast,icon", image);
-
- evas_object_smart_callback_add(popup, "block,clicked", _toast_popup_destroy_cb, parent);
- evas_object_smart_callback_add(popup, "timeout", _toast_popup_destroy_cb, parent);
-
- evas_object_data_set(parent, DATA_KEY_POPUP, popup);
-
- evas_object_show(popup);
-
- return EINA_TRUE;
-}
-
-
-int util_create_toast_popup_from_noti(const char* text)
-{
- Evas_Object *win = NULL;
-
- win = elm_win_add(NULL, "toast_popup", ELM_WIN_NOTIFICATION);
- retv_if(!win, EINA_FALSE);
-
- elm_win_alpha_set(win, EINA_TRUE);
- elm_win_title_set(win, "toast_popup");
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_autodel_set(win, EINA_TRUE);
- efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_HIGH);
-
- Evas_Object *popup = elm_popup_add(win);
- Evas_Object *image = NULL;
- char buf[PATH_MAX];
- retv_if(!popup, EINA_FALSE);
-
- elm_object_style_set(popup, POPUP_STYLE_TOAST);
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- elm_win_resize_object_add(win, popup);
-
- elm_object_part_text_set(popup, "elm.text", text);
- elm_object_domain_translatable_part_text_set(popup, "elm.text", PROJECT, text);
- if(main_get_info()->is_tts == EINA_FALSE)
- elm_popup_timeout_set(popup, UTIL_TOAST_POPUP_TIMER);
-
- image = elm_image_add(popup);
- snprintf(buf, sizeof(buf), "%s/tw_toast_popup_success.png", IMAGEDIR);
- elm_image_file_set(image, buf, NULL);
- elm_object_part_content_set(popup, "toast,icon", image);
-
- evas_object_smart_callback_add(popup, "block,clicked", _toast_popup_from_noti_destroy_cb, win);
- evas_object_smart_callback_add(popup, "timeout", _toast_popup_from_noti_destroy_cb, win);
-
- evas_object_show(popup);
- evas_object_show(win);
- elm_win_activate(win);
-
- return EINA_TRUE;
-}
-
-
-
-#define POPUP_EDJ EDJEDIR"/popup.edj"
-int util_create_check_popup(Evas_Object *parent, const char* text, void _clicked_cb(void *, Evas_Object *, void *))
-{
- Evas_Object *popup = NULL;
- Evas_Object *popup_scroller = NULL;
- Evas_Object *popup_layout_inner = NULL;
- Evas_Object *label = NULL;
- Evas_Object *check = NULL;
- Evas_Object *button = NULL;
-
- retv_if(!parent, EINA_FALSE);
-
- if (evas_object_data_get(parent, DATA_KEY_CHECK_POPUP)) return EINA_TRUE;
-
- popup = elm_popup_add(parent);
- retv_if(!popup, EINA_FALSE);
-
- elm_object_style_set(popup, POPUP_STYLE_DEFAULT);
- elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, ELM_NOTIFY_ALIGN_FILL);
-
- popup_scroller = elm_scroller_add(popup);
- goto_if(!popup_scroller, ERROR);
- elm_object_style_set(popup_scroller, "effect");
- evas_object_size_hint_weight_set(popup_scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_scroller_content_min_limit(popup_scroller, EINA_FALSE, EINA_TRUE);
- evas_object_size_hint_max_set(popup_scroller, POPUP_TEXT_MAX_WIDTH, POPUP_TEXT_MAX_HEIGHT);
- elm_object_content_set(popup, popup_scroller);
- evas_object_show(popup_scroller);
-
- popup_layout_inner = elm_layout_add(popup_scroller);
- goto_if(!popup_layout_inner, ERROR);
- elm_layout_file_set(popup_layout_inner, POPUP_EDJ, "popup_checkview_internal");
- evas_object_size_hint_weight_set(popup_layout_inner, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_content_set(popup_scroller, popup_layout_inner);
-
- label = elm_label_add(popup_layout_inner);
- goto_if(!label, ERROR);
- elm_object_style_set(label, "popup/default");
- elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
- elm_object_text_set(label, _("IDS_HS_POP_TO_INSTALL_OR_UNINSTALL_APPLICATIONS_USE_THE_SAMSUNG_GEAR_APPLICATION_ON_YOUR_MOBILE_DEVICE"));
- elm_object_domain_translatable_text_set(label, PROJECT, "IDS_HS_POP_TO_INSTALL_OR_UNINSTALL_APPLICATIONS_USE_THE_SAMSUNG_GEAR_APPLICATION_ON_YOUR_MOBILE_DEVICE");
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- elm_object_part_content_set(popup_layout_inner, "label", label);
-
- check = elm_check_add(popup);
- goto_if(!check, ERROR);
- elm_object_style_set(check, "popup");
- elm_object_text_set(check, _("IDS_CLOCK_BODY_DONT_REPEAT_ABB"));
- elm_object_domain_translatable_text_set(check, PROJECT, "IDS_CLOCK_BODY_DONT_REPEAT_ABB");
- elm_object_part_content_set(popup_layout_inner, "elm.swallow.end", check);
- evas_object_show(check);
- evas_object_data_set(popup, DATA_KEY_CHECK, check);
-
- button = elm_button_add(popup);
- goto_if(!button, ERROR);
- elm_object_style_set(button, BUTTON_STYLE_POPUP);
- elm_object_text_set(button, _("IDS_ST_BUTTON_OK"));
- elm_object_domain_translatable_text_set(button, PROJECT, "IDS_ST_BUTTON_OK");
- elm_object_part_content_set(popup, "button1", button);
- evas_object_smart_callback_add(button, "clicked", _clicked_cb, parent);
-
- evas_object_data_set(parent, DATA_KEY_CHECK_POPUP, popup);
- evas_object_show(popup);
-
- return EINA_TRUE;
-
-ERROR:
- if (popup) evas_object_del(popup);
- return EINA_FALSE;
-}
-
-
-
-static char *_get_app_id(const char *pkgname)
-{
- int ret = 0;
- char *appid = 0;
- pkgmgrinfo_pkginfo_h handle = NULL;
- retv_if(pkgname == NULL, NULL);
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgname, &handle);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get pkg information from pkgmgr");
- goto ERR;
- }
- ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &appid);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get mainapp ID information from pkgmgr");
- goto ERR;
- }
-
- if (appid != NULL) {
- appid = strdup(appid);
- }
-ERR:
- if (handle != NULL) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- }
-
- return appid;
-}
-
-
-
-static char *_get_app_pkgname(const char *appid)
-{
- int ret = 0;
- char *pkgname = NULL;
- pkgmgrinfo_appinfo_h handle = NULL;
- retv_if(appid == NULL, NULL);
-
- ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get app information from pkgmgr");
- goto ERR;
- }
-
- ret = pkgmgrinfo_appinfo_get_pkgname(handle, &pkgname);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get pkgname from app info handler");
- goto ERR;
- }
- if (pkgname != NULL) {
- pkgname = strdup(pkgname);
- }
-
-ERR:
- if (handle != NULL) {
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- }
-
- return pkgname;
-}
-
-
-
-static int _get_app_type(char *pkgname)
-{
- int ret = 0;
- char *apptype = NULL;
- pkgmgrinfo_pkginfo_h handle = NULL;
- retv_if(pkgname == NULL, APP_TYPE_NATIVE);
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgname, &handle);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get pkg information from pkgmgr");
- return APP_TYPE_NATIVE;
- }
-
- ret = pkgmgrinfo_pkginfo_get_type(handle, &apptype);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get app type from pkginfo handler");
- goto ERR;
- }
-
- if (apptype != NULL) {
- if (strcmp(apptype, "wgt") == 0) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return APP_TYPE_WEB;
- } else {
- char *widget_id;
- widget_id = widget_service_get_widget_id(pkgname);
- if (widget_id) {
- _D("Widget: %s\n", widget_id);
- free(widget_id);
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return APP_TYPE_WIDGET;
- }
- _D("MC: %s\n", pkgname);
- }
- }
-
-ERR:
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return APP_TYPE_NATIVE;
-}
-
-
-
-HAPI int util_get_app_type(const char *appid)
-{
- int pkgtype = APP_TYPE_NATIVE;
- char *pkgname = NULL;
- retv_if(appid == NULL, APP_TYPE_NATIVE);
-
- pkgname = _get_app_pkgname(appid);
- if(pkgname == NULL) {
- _E("Failed to get pkgname");
- goto DONE;
- }
- pkgtype = _get_app_type(pkgname);
-
-DONE:
- free(pkgname);
-
- return pkgtype;
-}
-
-
-
-/*
- * This APIs should be used only for the packages which have only one app
- * returned pointer have to be free by you
- */
-HAPI char *util_get_pkgname_by_appid(const char *appid)
-{
- return _get_app_pkgname(appid);
-}
-
-
-
-HAPI char *util_get_appid_by_pkgname(const char *pkgname)
-{
- return _get_app_id(pkgname);
-}
-
-
-
-HAPI const char *util_basename(const char *name)
-{
- int length;
- length = name ? strlen(name) : 0;
- if (!length) {
- return ".";
- }
-
- while (--length > 0 && name[length] != '/');
-
- return length <= 0 ? name : (name + length + (name[length] == '/'));
-}
-
-
-
-HAPI double util_timestamp(void)
-{
-#if defined(_USE_ECORE_TIME_GET)
- return ecore_time_get();
-#else
- struct timeval tv;
- if (gettimeofday(&tv, NULL) < 0) {
- static unsigned long internal_count = 0;
- _E("failed to get time of day(%d)", errno);
- tv.tv_sec = internal_count++;
- tv.tv_usec = 0;
- }
-
- return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
-#endif
-}
-
-
-
-HAPI void util_activate_home_window(void)
-{
- apps_hide();
-}
-
-HAPI void util_raise_home_window(int force_notify)
-{
- Evas_Object *win = main_get_info()->win;
- if (win) {
- elm_win_activate(win);
- }
-}
-
-/* You have to free the returned value */
-HAPI char *util_get_count_str_from_icu(int count)
-{
- char *p = NULL;
- char *locale_tmp = NULL;
- char *ret_str = NULL;
- char locale[LOCALE_LEN] = { 0, };
- char res[LOCALE_LEN] = { 0, };
- int slen;
-
- UErrorCode status = U_ZERO_ERROR;
- UNumberFormat *num_fmt;
- UChar result[20] = { 0, };
-
- uint32_t number = count;
- int32_t len = (int32_t) (sizeof(result) / sizeof((result)[0]));
-
- locale_tmp = vconf_get_str(VCONFKEY_REGIONFORMAT);
- retv_if(!locale_tmp, NULL);
-
- slen = strlen(locale_tmp);
-
- if( slen > 0 && slen <= LOCALE_LEN)
- strncpy(locale, locale_tmp, slen);
-
- free(locale_tmp);
-
- if(locale[0] != '\0') {
- p = strstr(locale, ".UTF-8");
- if (p) *p = 0;
- }
-
- num_fmt = unum_open(UNUM_DEFAULT, NULL, -1, locale, NULL, &status);
- unum_format(num_fmt, number, result, len, NULL, &status);
- u_austrcpy(res, result);
- unum_close(num_fmt);
-
- ret_str = strdup(res);
- return ret_str;
-}
-
-HAPI int util_is_arbic()
-{
- int ret = 0;
- char *locale_tmp = vconf_get_str(VCONFKEY_LANGSET);
- retv_if(!locale_tmp, 0);
-
- if(!strncmp(locale_tmp, "ar", 2))
- {
- ret = 1;
- }
-
- return ret;
-}
-
-
-#define PRIVATE_DATE_KEY_CIRCLE_SCROLLER_OBJ "p_d_k_c_s_o_cso"
-HAPI void util_uxt_scroller_set_rotary_event_enabled(Evas_Object *scroller, Eina_Bool enabled)
-{
- ret_if(scroller == NULL);
-
- Evas_Object *circle_scroller = evas_object_data_get(scroller, PRIVATE_DATE_KEY_CIRCLE_SCROLLER_OBJ);
-
- eext_rotary_object_event_activated_set(circle_scroller, enabled);
-
-/* if (circle_scroller == NULL) {
- Eext_Circle_Surface *surf = main_get_info()->surface;
- if (surf) {
- circle_scroller = eext_circle_object_scroller_add(scroller, surf);
- if (circle_scroller) {
- eext_circle_object_scroller_policy_set(circle_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
- eext_rotary_object_event_activated_set(circle_scroller, enabled);
- evas_object_data_set(scroller, PRIVATE_DATE_KEY_CIRCLE_SCROLLER_OBJ, circle_scroller);
- } else {
- _E("Failed to create circle scroller of %p", scroller);
- }
- } else {
- _E("Failed to get surface object");
- }
- } else {
- eext_rotary_object_event_activated_set(circle_scroller, enabled);
- }*/
-}
-
-HAPI int util_host_vender_id_get(void)
-{
- return 0;
- //int ret = W_HOME_VENDOR_ID_UNKNOWN;
-
-/* char *vender = vconf_get_str(VCONFKEY_WMS_HOST_STATUS_VENDOR);
- if (vender) {
- if (strcmp(vender, HOME_HOST_VENDOR_LO) == 0) {
- ret = W_HOME_VENDOR_ID_LO;
- }
- else if (strcmp(vender, HOME_HOST_V
- ENDER_SAMSUNG) == 0) {
- ret = W_HOME_VENDOR_ID_SAMSUNG;
- }
-
- free(vender);
- }*/
-
- //return ret;
-}
-
-
-void destroy_evas_object(Evas_Object *object)
-{
- if (object) {
- evas_object_del(object);
- }
- object = NULL;
-}
-
-// End of a file
diff --git a/src/virtual_canvas.c b/src/virtual_canvas.c
deleted file mode 100755
index c2db79a..0000000
--- a/src/virtual_canvas.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <Ecore_Evas.h>
-#include <dlog.h>
-#include <stdbool.h>
-#include <bundle.h>
-
-#include "log.h"
-#include "util.h"
-#include "virtual_canvas.h"
-
-#define QUALITY_N_COMPRESS "quality=100 compress=1"
-#define PRIVATE_DATA_KEY_DATA "dt"
-
-
-
-HAPI Evas *virtual_canvas_create(int w, int h)
-{
- Ecore_Evas *internal_ee;
- Evas *internal_e;
-
- // Create virtual canvas
- internal_ee = ecore_evas_buffer_new(w, h);
- if (!internal_ee) {
- _D("Failed to create a new canvas buffer\n");
- return NULL;
- }
-
- ecore_evas_alpha_set(internal_ee, EINA_TRUE);
- ecore_evas_manual_render_set(internal_ee, EINA_TRUE);
-
- // Get the "Evas" object from a virtual canvas
- internal_e = ecore_evas_get(internal_ee);
- if (!internal_e) {
- ecore_evas_free(internal_ee);
- _D("Faield to get Evas object\n");
- return NULL;
- }
-
- return internal_e;
-}
-
-
-
-static bool _flush_data_to_file(Evas *e, char *data, const char *filename, int w, int h)
-{
- Evas_Object *output;
-
- output = evas_object_image_add(e);
- if (!output) {
- _D("Failed to create an image object\n");
- return false;
- }
-
- evas_object_image_colorspace_set(output, EVAS_COLORSPACE_ARGB8888);
- evas_object_image_alpha_set(output, EINA_TRUE);
- evas_object_image_size_set(output, w, h);
- evas_object_image_smooth_scale_set(output, EINA_TRUE);
- evas_object_image_data_set(output, data);
- evas_object_image_data_update_add(output, 0, 0, w, h);
-
- if (evas_object_image_save(output, filename, NULL, QUALITY_N_COMPRESS) == EINA_FALSE) {
- evas_object_del(output);
- _SD("Failed to save a captured image (%s)\n", filename);
- return false;
- }
-
- evas_object_del(output);
-
- if (access(filename, F_OK) != 0) {
- _SD("File %s is not found\n", filename);
- return false;
- }
-
- return true;
-}
-
-
-
-EAPI bool virtual_canvas_flush_to_file(Evas *e, const char *filename, int w, int h)
-{
- void *data;
- Ecore_Evas *internal_ee;
-
- internal_ee = ecore_evas_ecore_evas_get(e);
- if (!internal_ee) {
- _D("Failed to get ecore evas\n");
- return false;
- }
-
- ecore_evas_manual_render(internal_ee);
-
- // Get a pointer of a buffer of the virtual canvas
- data = (void *) ecore_evas_buffer_pixels_get(internal_ee);
- if (!data) {
- _D("Failed to get pixel data\n");
- return false;
- }
-
- return _flush_data_to_file(e, data, filename, w, h);
-}
-
-
-
-#define INDICATOR_HEIGHT 30.0
-static Evas_Object *_load_file(Evas *e, const char *file, int w, int h)
-{
- Evas_Object *output = evas_object_image_filled_add(e);
- retv_if(NULL == output, NULL);
-
- int file_w, file_h;
-
- evas_object_image_smooth_scale_set(output, EINA_TRUE);
- evas_object_image_load_size_set(output, w, h);
- evas_object_image_file_set(output, file, NULL);
-
- int ret = evas_object_image_load_error_get(output);
- if (EVAS_LOAD_ERROR_NONE != ret) _E("Cannot load a file (%d, %s)", ret, file);
-
- evas_object_image_size_get(output, &file_w, &file_h);
- evas_object_image_fill_set(output, 0, 0, file_w, file_h);
-
- float file_r = (float) file_w / (float) file_h;
- float canvas_r = (float) w / ((float) h + INDICATOR_HEIGHT);
-
- int new_w = file_w;
- if (file_r > canvas_r) new_w = (float) file_h * (float) canvas_r;
-
- float r = (float) w / (float) new_w;
- file_w = (float) file_w * r;
- file_h = (float) file_h * r;
-
- evas_object_resize(output, file_w, file_h);
- evas_object_move(output, 0, (-INDICATOR_HEIGHT * r));
- evas_object_show(output);
-
- return output;
-}
-
-
-
-void _del_ee_cb(Ecore_Evas *ee)
-{
- Evas_Object *eoi = ecore_evas_data_get(ee, PRIVATE_DATA_KEY_DATA);
- evas_object_del(eoi);
-}
-
-
-
-HAPI void *virtual_canvas_load_file_to_data(Evas *e, const char *file, int w, int h)
-{
- Evas_Object *eoi = _load_file(e, file, w, h);
- retv_if(NULL == eoi, NULL);
-
- Ecore_Evas *internal_ee = ecore_evas_ecore_evas_get(e);
- if (NULL == internal_ee) {
- evas_object_del(eoi);
- return NULL;
- }
-
- ecore_evas_data_set(internal_ee, PRIVATE_DATA_KEY_DATA, eoi);
- ecore_evas_manual_render(internal_ee);
- ecore_evas_callback_pre_free_set(internal_ee, _del_ee_cb);
-
- // Get a pointer of a buffer of the virtual canvas
- return (void *) ecore_evas_buffer_pixels_get(internal_ee);
-}
-
-
-
-HAPI bool virtual_canvas_destroy(Evas *e)
-{
- Ecore_Evas *ee;
-
- ee = ecore_evas_ecore_evas_get(e);
- if (!ee) {
- _D("Failed to ecore evas object\n");
- return false;
- }
-
- ecore_evas_free(ee);
- return true;
-}
-
-
-
-// End of a file
diff --git a/src/widget.c b/src/widget.c
deleted file mode 100755
index 12f656f..0000000
--- a/src/widget.c
+++ /dev/null
@@ -1,925 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_errno.h>
-#include <stdbool.h>
-#include <dlog.h>
-#include <bundle.h>
-#include <widget.h>
-#include <vconf.h>
-#include <app_preference.h>
-//#include <widget_viewer_evas_internal.h> /* feed_access_event */
-#include <widget_viewer_evas.h>
-
-/**
- * WIDGET_ACCESS_STATUS_XXX
- */
-#include <widget_service_internal.h>
-
-#include "util.h"
-#include "db.h"
-#include "index.h"
-#include "layout_info.h"
-#include "log.h"
-#include "main.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "page.h"
-#include "edit.h"
-#include "add-viewer_package.h"
-#include "add-viewer_pkgmgr.h"
-
-
-static struct info {
- Eina_Bool is_scrolling;
- Eina_List *pended_event_list;
-} s_info = {
- .is_scrolling = EINA_FALSE,
- .pended_event_list = NULL,
-};
-
-
-
-#define MAX_TTL 10
-#define TAG_SCROLL "l.s" // Scroller
-#define TAG_UPDATED "l.u" // Widget Updated
-#define TAG_FAULT_HL "f.h" // Faulted Highlight (emulate)
-#define FAULTED_HL_TIMER 0.00001f
-
-
-
-struct pended_access_event {
- Evas_Object *widget;
- Elm_Access_Action_Info info;
- void (*cb)(Evas_Object *obj, int ret, void *data);
- void *data;
- int ttl;
-};
-
-
-
-static const char *action_type_string(int type)
-{
- switch (type) {
- case ELM_ACCESS_ACTION_HIGHLIGHT:
- return "HL";
- case ELM_ACCESS_ACTION_UNHIGHLIGHT:
- return "UNHL";
- case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
- return "NEXT";
- case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
- return "PREV";
- //case ELM_ACCESS_ACTION_VALUE_CHANGE:
- // return "VALUE_CHANGE";
- //case ELM_ACCESS_ACTION_MOUSE:
- // return "MOUSE";
- case ELM_ACCESS_ACTION_BACK:
- return "BACK";
- //case ELM_ACCESS_ACTION_OVER:
- // return "OVER";
- case ELM_ACCESS_ACTION_READ:
- return "READ";
- //case ELM_ACCESS_ACTION_ENABLE:
- // return "ENABLE";
- //case ELM_ACCESS_ACTION_DISABLE:
- // return "DISABLE";
- case ELM_ACCESS_ACTION_ACTIVATE:
- return "ACTIVATE";
- case ELM_ACCESS_ACTION_SCROLL:
- return "SCROLL";
- default:
- return "Unknown";
- }
-}
-
-
-static void del_cb(void *data, Evas *e, Evas_Object *widget, void *event_info)
-{
- const char *widget_id;
- struct pended_access_event *info;
- Eina_List *l;
- Eina_List *n;
-
- EINA_LIST_FOREACH_SAFE(s_info.pended_event_list, l, n, info) {
- if (info->widget == widget) {
- s_info.pended_event_list = eina_list_remove(s_info.pended_event_list, info);
- free(info);
- }
- }
-
- widget_id = widget_viewer_evas_get_widget_id(widget);
- if (widget_id) {
- struct add_viewer_package *pkginfo;
-
- pkginfo = add_viewer_package_find(widget_id);
- if (!pkginfo) {
- _E("Add viewer has no info: %s", widget_id);
- } else {
- add_viewer_package_set_skip(pkginfo, 0);
- }
- } else {
- _E("Has no widget_id?");
- }
-}
-
-
-
-static void _widget_created_cb(void *data, Evas_Object *obj, void *event_info)
-{
-}
-
-
-
-static void _widget_updated_cb(void *data, Evas_Object *obj, void *event_info)
-{
- int (*updated)(Evas_Object *obj);
-
- updated = evas_object_data_get(obj, TAG_UPDATED);
- if (!updated) {
- return;
- }
-
- if (updated(obj) == ECORE_CALLBACK_CANCEL) {
- evas_object_data_del(obj, TAG_UPDATED);
- }
-}
-
-
-
-static void _widget_control_scroll_cb(void *data, Evas_Object *obj, void *event_info)
-{
- struct widget_evas_event_info *ev = event_info;
- int (*scroll)(Evas_Object *obj, int hold);
-
- scroll = evas_object_data_get(obj, TAG_SCROLL);
- if (!scroll) {
- return;
- }
-
- if (scroll(obj, (ev->error == WIDGET_ERROR_NONE && ev->event == WIDGET_EVENT_HOLD_SCROLL)) == ECORE_CALLBACK_CANCEL) {
- evas_object_data_del(obj, TAG_SCROLL);
- }
-}
-
-
-
-HAPI Evas_Object *widget_create(Evas_Object *parent, const char *id, const char *subid, double period)
-{
- Evas_Object *widget = NULL;
- char *pkgname = NULL;
- struct add_viewer_package *pkginfo;
-
- retv_if(!id, NULL);
-
- pkgname = widget_service_get_widget_id(id);
- if (pkgname) {
- free(pkgname);
- } else {
- _D("%s is not installed in the pkgmgr DB", id);
- return NULL;
- }
-
- widget = widget_viewer_evas_add_widget(parent, id, subid, period);
- retv_if(!widget, NULL);
-
- pkginfo = add_viewer_package_find(id);
- if (!pkginfo) {
- _E("add-viewer info none: %s", id);
- } else {
- if (add_viewer_package_is_skipped(pkginfo)) {
- _E("Package marked as skip");
- }
-
- add_viewer_package_set_skip(pkginfo, 1);
- _D("Mark added: %s", id);
- }
-
- evas_object_event_callback_add(widget, EVAS_CALLBACK_DEL, del_cb, NULL);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_WIDGET_CREATED, _widget_created_cb, NULL);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_UPDATED, _widget_updated_cb, NULL);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_CONTROL_SCROLLER, _widget_control_scroll_cb, NULL);
- return widget;
-}
-
-
-
-HAPI void widget_destroy(Evas_Object *widget)
-{
- ret_if(!widget);
-
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_WIDGET_CREATED, _widget_created_cb);
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_UPDATED, _widget_updated_cb);
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_CONTROL_SCROLLER, _widget_control_scroll_cb);
- evas_object_del(widget);
-}
-
-
-
-/* The content is updated */
-static void _widget_extra_updated_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *page = data;
- layout_info_s *layout_info = NULL;
- scroller_info_s *scroller_info = NULL;
- page_info_s *page_info = NULL;
- const char *content_info = NULL;
-
- int center_index = 0;
- int page_index = 0;
- int ordering;
-
- ret_if(!page);
-
- _D("Widget is updated");
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
- ret_if(!page_info->item);
-
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- content_info = widget_viewer_evas_get_content_info(page_info->item);
- ret_if(!content_info);
-
- free(page_info->subid);
- page_info->subid = strdup(content_info);
- ret_if(!page_info->subid);
-
- /* do not need to update DB on the edit mode */
- if (layout_info->edit) return;
-
- scroller_info = evas_object_data_get(page_info->scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
-
- center_index = scroller_seek_page_position(page_info->scroller, scroller_info->center);
- page_index = scroller_seek_page_position(page_info->scroller, page);
- ordering = page_index - center_index - 1;
-
- db_update_item_by_ordering(page_info->id, content_info, ordering);
-
- _SD("Widget is updated to [%s:%s:%d]", page_info->id, content_info, ordering);
-}
-
-
-
-static void _widget_remove(Evas_Object *page)
-{
- Evas_Object *proxy_page = NULL;
- Evas_Object *page_current = NULL;
- Evas_Object *scroller = NULL;
- page_info_s *page_info = NULL;
-
- /* We have to delete a proxy page on the edit mode */
- proxy_page = evas_object_data_get(page, DATA_KEY_PROXY_PAGE);
- if (proxy_page) {
- scroller_info_s *scroller_info = NULL;
- page_info_s *proxy_page_info = NULL;
-
- proxy_page_info = evas_object_data_get(proxy_page, DATA_KEY_PAGE_INFO);
- ret_if(!proxy_page_info);
-
- scroller = proxy_page_info->scroller;
- ret_if(!scroller);
-
- scroller_info = evas_object_data_get(scroller, DATA_KEY_SCROLLER_INFO);
- ret_if(!scroller_info);
- ret_if(!scroller_info->parent);
-
- scroller_pop_page(proxy_page_info->scroller, proxy_page);
- edit_destroy_proxy_page(proxy_page);
-
- page_current = scroller_get_focused_page(scroller);
- ret_if(!page_current);
-
- index_bring_in_page(scroller_info->single_index, page_current);
- edit_change_focus(scroller, page_current);
- edit_arrange_plus_page(scroller_info->parent);
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- _D("Widget(%s) is removed", page_info->id);
-
- scroller = page_info->scroller;
- ret_if(!scroller);
-
- scroller_pop_page(page_info->scroller, page);
- page_destroy(page);
- if (!main_get_info()->is_tts) {
- page_arrange_plus_page(scroller, 0);
- }
-}
-
-
-
-static void _widget_create_aborted_cb(void *data, Evas_Object *obj, void *event_info)
-{
- struct widget_evas_event_info *ev = event_info;
- Evas_Object *page = data;
- Eina_List *page_info_list = NULL;
- layout_info_s *layout_info = NULL;
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- _D("Widget is aborted to create");
-
- /* We have to get the page_info before removing it */
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- layout_info = evas_object_data_get(page_info->layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- if (ev->error == WIDGET_ERROR_ALREADY_EXIST) {
- _SW("Already exists %s", ev->widget_app_id);
- _widget_remove(page);
- } else if (ev->error == WIDGET_ERROR_DISABLED) {
- _SW("Disable %s", ev->widget_app_id);
- _widget_remove(page);
- page_info_list = scroller_write_list(layout_info->scroller);
- if (page_info_list) {
- db_read_list(page_info_list);
- page_info_list_destroy(page_info_list);
- } else {
- db_remove_all_item();
- }
- }
-}
-
-
-
-static void _widget_period_changed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- struct widget_evas_event_info *ev = event_info;
- _SD("Period changed: %s -> %lf", ev->widget_app_id, widget_viewer_evas_get_period(obj));
- /*
- * TODO: Update the period information - Sync with DB?
- */
-}
-
-
-
-static void _widget_faulted_cb(void *data, Evas_Object *obj, void *event_info)
-{
- struct widget_evas_event_info *ev = event_info;
-
- _SD("Widget is faulted - %s", ev->widget_app_id);
-}
-
-
-
-static void _widget_deleted_cb(void *data, Evas_Object *obj, void *event_info)
-{
- struct widget_evas_event_info *ev = event_info;
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
-
- ret_if(!page);
-
- _D("Widget is deleted");
-
- if (ev->error == WIDGET_ERROR_FAULT) {
- /* DBox is faulted. */
- _SE("Widget is faulted - %s", ev->widget_app_id);
- return;
- }
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- if (!widget_viewer_evas_is_faulted(page_info->item)) {
- _widget_remove(page);
- }
-}
-
-
-
-
-static Eina_Bool _highlight_action_cb(void *data, Evas_Object *focus, Elm_Access_Action_Info *action_info)
-{
- Evas_Object *page = data;
- page_info_s *page_info;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- _E("Page info is not valid\n");
- return EINA_FALSE;
- }
-
- if (page_info->highlighted == EINA_FALSE) {
- page_info->highlighted = EINA_TRUE;
- page_info->need_to_read = EINA_TRUE;
- _D("Turn on highlight");
- return EINA_FALSE;
- }
-
- if (page_info->need_to_unhighlight) {
- page_info->need_to_unhighlight = EINA_FALSE;
- _D("Turn off highlight");
- return EINA_TRUE;
- } else {
- _D("Turn on highlight");
- return EINA_FALSE;
- }
-}
-
-
-
-static Eina_Bool _unhighlight_action_cb(void *data, Evas_Object *focus, Elm_Access_Action_Info *action_info)
-{
- Evas_Object *page = data;
- page_info_s *page_info;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- _E("Page info is not valid\n");
- return EINA_FALSE;
- }
-
- if (page_info->highlighted == EINA_TRUE) {
- Elm_Access_Action_Info _action_info;
-
- _D("Reset highlight flags");
- page_info->highlighted = EINA_FALSE;
- page_info->highlight_changed = EINA_FALSE;
-
- memset(&_action_info, 0, sizeof(_action_info));
- if (s_info.is_scrolling) {
- if (page_info->is_scrolled_object) {
- page_info->is_scrolled_object = EINA_FALSE;
-
- if (widget_viewer_evas_is_faulted(page_info->item)) {
- _D("Faulted");
- return EINA_FALSE;
- }
-
- // We have to cancelate the scroll event.
- _action_info.mouse_type = 2; // MOUSE_UP
- _action_info.action_type = ELM_ACCESS_ACTION_SCROLL;
-
- _action_info.mouse_type = 0;
- _action_info.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
- _D("Reset scroll event");
- }
- } else {
- // Need to turn of highlight
- _action_info.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
- }
- return EINA_FALSE;
- }
-
- _D("Unhighlighted");
- return EINA_TRUE;
-}
-
-
-
-static Eina_Bool _access_action_activate_cb(void *data, Evas_Object *focus, Elm_Access_Action_Info *action_info)
-{
- Evas_Object *page = data;
- page_info_s *page_info;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- _E("Page info is not valid\n");
- /* Do not change the highlight in this case, so return EINA_TRUE */
- return EINA_FALSE;
- }
-
- if (page_info->highlighted == EINA_FALSE) {
- _D("Highlight is not exists");
- return EINA_FALSE;
- }
-
- if (widget_viewer_evas_is_faulted(page_info->item)) {
- _D("Activate Widget\n");
- widget_viewer_evas_activate_faulted_widget(page_info->item);
- } else {
- _D("Access action(%s) for focus(%p <> %p) is called", action_type_string(action_info->action_type), focus, page_info->focus);
- /* Highligh off and then reset highlight from return callback _widget_access_action_ret_cb() */
- }
-
- return EINA_TRUE;
-}
-
-
-
-static Eina_Bool _access_action_scroll_cb(void *data, Evas_Object *focus, Elm_Access_Action_Info *action_info)
-{
- Evas_Object *page = data;
- page_info_s *page_info;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- _E("Page info is not valid\n");
- /* Do not change the highlight in this case, so return EINA_TRUE */
- return EINA_FALSE;
- }
-
- if (page_info->highlighted == EINA_FALSE) {
- _D("Highlight is not exists");
- return EINA_FALSE;
- }
-
- if (action_info->mouse_type == 0) { // MOUSE_DOWN
- s_info.is_scrolling = EINA_TRUE;
- page_info->is_scrolled_object = EINA_TRUE;
- } else if (action_info->mouse_type == 2) { // MOUSE_UP
- s_info.is_scrolling = EINA_FALSE;
-
- if (!page_info->is_scrolled_object) {
- return EINA_FALSE;
- }
-
- page_info->is_scrolled_object = EINA_FALSE;
- } else if (s_info.is_scrolling != EINA_TRUE) {
- return EINA_FALSE;
- }
-
- if (widget_viewer_evas_is_faulted(page_info->item)) {
- _D("Faulted box, do not send any events");
- return EINA_FALSE;
- }
-
-
- /* Highligh off and then reset highlight from return callback _widget_access_action_ret_cb() */
- return EINA_FALSE;
-}
-
-
-
-static Eina_Bool delayed_faulted_action_cb(void *data)
-{
- Evas_Object *page = data;
- page_info_s *page_info;
- Elm_Access_Action_Info action_info;
- int ret = ECORE_CALLBACK_RENEW;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- return ECORE_CALLBACK_CANCEL;
- }
-
- memset(&action_info, 0, sizeof(action_info));
-
- if ((int)evas_object_data_get(page, TAG_FAULT_HL) == 1) {
- action_info.action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
- /**
- * Call elm_access_action with "HIGHLIGHT", will invoke the ELM_ACCESS_ACTION_READ callback.
- * It will invoke the _access_action_forward_cb,
- */
- elm_access_action(page_info->focus, action_info.action_type, &action_info);
-
- evas_object_data_del(page, TAG_FAULT_HL);
- page_info->faulted_hl_timer = NULL;
- ret = ECORE_CALLBACK_CANCEL;
- } else if ((int)evas_object_data_get(page, TAG_FAULT_HL) == 0) {
- action_info.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
- elm_access_action(page_info->focus, action_info.action_type, &action_info);
-
- evas_object_data_set(page, TAG_FAULT_HL, (void *)1);
- }
-
- return ret;
-}
-
-
-
-/**
- * ELM_ACCESS_ACTION_HIGHLIGHT_NEXT
- * ELM_ACCESS_ACTION_HIGHLIGHT_PREV
- * ELM_ACCESS_ACTION_VALUE_CHANGE
- * ELM_ACCESS_ACTION_BACK
- * ELM_ACCESS_ACTION_READ
- * ELM_ACCESS_ACTION_ENABLE
- * ELM_ACCESS_ACTION_DISABLE
- */
-static Eina_Bool _access_action_forward_cb(void *data, Evas_Object *focus, Elm_Access_Action_Info *action_info)
-{
- Evas_Object *page = data;
- page_info_s *page_info;
- Evas_Coord x, y;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- _E("Page info is not valid\n");
- /* Do not change the highlight in this case, so return EINA_TRUE */
- return EINA_FALSE;
- }
-
- if (page_info->highlighted == EINA_FALSE) {
- _D("Highlight is not exists");
- return EINA_FALSE;
- }
-
- evas_object_geometry_get(page_info->item, &x, &y, NULL, NULL);
-
- if (s_info.is_scrolling || x || y) {
- _D("I don't want to do anything! %dx%d", x, y);
- return EINA_FALSE;
- }
-
- if (widget_viewer_evas_is_faulted(page_info->item)) {
- switch (action_info->action_type) {
- case ELM_ACCESS_ACTION_READ:
- break;
- case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
- case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
- if (!page_info->faulted_hl_timer) {
- page_info->faulted_hl_timer = ecore_timer_add(FAULTED_HL_TIMER, delayed_faulted_action_cb, page);
- if (!page_info->faulted_hl_timer) {
- _E("Faulted box, faulted timer failed");
- } else {
- _D("Faulted box, Add highlight emulate timer");
- }
- } else {
- _D("Faulted box, Keep highlight emulate timer");
- }
- break;
- default:
- break;
- }
- page_info->need_to_read = EINA_TRUE;
-
- return EINA_TRUE;
- }
-
- _D("Access action(%s) for focus(%p <> %p) is called, by(%d)", action_type_string(action_info->action_type), focus, page_info->focus, action_info->action_by);
-
- /* Highligh off and then reset highlight from return callback _widget_access_action_ret_cb() */
- return EINA_TRUE;
-}
-
-
-static char *_access_widget_read_cb(void *data, Evas_Object *obj)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
- char *tmp;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- if (widget_viewer_evas_is_widget(page_get_item(page)) == 1) {
- if (page_info->need_to_read == EINA_FALSE) {
- /*
- * need_to_read will be toggled by _access_page_num_cb function
- * so this function should not touch it.
- */
- return NULL;
- }
-
- if (page_info->need_to_unhighlight == EINA_TRUE) {
- return NULL;
- }
- }
-
- tmp = strdup(_("IDS_IDLE_HEADER_WIDGET"));
- retv_if(!tmp, NULL);
- return tmp;
-}
-
-
-static char *_access_page_name_cb(void *data, Evas_Object *obj)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
- char *title;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- if (widget_viewer_evas_is_widget(page_get_item(page)) == 1) {
- if (page_info->need_to_read == EINA_FALSE) {
- /*
- * need_to_read will be toggled by _access_page_num_cb function
- * so this function should not touch it.
- */
- return NULL;
- }
-
- if (page_info->need_to_unhighlight == EINA_TRUE) {
- return NULL;
- }
- }
-
- if (page_info->title) {
- title = strdup(page_info->title);
- retv_if(!title, NULL);
- return title;
- }
-
- /* EFL will free this title. */
- title = page_read_title(page);
- retv_if(!title, NULL);
-
- return title;
-}
-
-
-
-static char *_access_context_info_cb(void *data, Evas_Object *obj)
-{
- Evas_Object *page = data;
- page_info_s *page_info = NULL;
- char *ctx = NULL;
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- retv_if(!page_info, NULL);
-
- if (widget_viewer_evas_is_faulted(page_info->item)) {
- if (page_info->need_to_read == EINA_FALSE) {
- return NULL;
- }
-
- if (page_info->need_to_unhighlight == EINA_TRUE) {
- return NULL;
- }
- page_info->need_to_read = EINA_FALSE;
- ctx = strdup(_("IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY"));
- }
-
- return ctx;
-}
-
-
-
-HAPI void widget_add_callback(Evas_Object *widget, Evas_Object *page)
-{
- page_info_s *page_info = NULL;
-
- ret_if(!widget);
- ret_if(!page);
-
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- ret_if(!page_info);
-
- /* Only handling the focus set operation to page_focus */
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_HIGHLIGHT, _highlight_action_cb, page);
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_UNHIGHLIGHT, _unhighlight_action_cb, page);
-
- /* Deliever events to the widget */
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, _access_action_forward_cb, page);
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_HIGHLIGHT_PREV, _access_action_forward_cb, page);
- //elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_VALUE_CHANGE, _access_action_forward_cb, page);
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_BACK, _access_action_forward_cb, page);
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_READ, _access_action_forward_cb, page);
- //elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_ENABLE, _access_action_forward_cb, page);
- //elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_DISABLE, _access_action_forward_cb, page);
-
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_ACTIVATE, _access_action_activate_cb, page);
-
- elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_SCROLL, _access_action_scroll_cb, page);
- //elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_MOUSE, _access_action_mouse_cb, page);
- //elm_access_action_cb_set(page_info->focus, ELM_ACCESS_ACTION_OVER, _access_action_mouse_cb, page);
-
- elm_access_info_cb_set(page_info->focus, ELM_ACCESS_INFO, _access_page_name_cb, page);
- elm_access_info_cb_set(page_info->focus, ELM_ACCESS_TYPE, _access_widget_read_cb, page);
- elm_access_info_cb_set(page_info->focus, ELM_ACCESS_CONTEXT_INFO, _access_context_info_cb, page);
-
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_EXTRA_INFO_UPDATED, _widget_extra_updated_cb, page);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_WIDGET_DELETED, _widget_deleted_cb, page);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_WIDGET_FAULTED, _widget_faulted_cb, page);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_PERIOD_CHANGED, _widget_period_changed_cb, page);
- evas_object_smart_callback_add(widget, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, _widget_create_aborted_cb, page);
-}
-
-
-
-HAPI void widget_del_callback(Evas_Object *widget)
-{
- ret_if(!widget);
-
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_EXTRA_INFO_UPDATED, _widget_extra_updated_cb);
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_WIDGET_DELETED, _widget_deleted_cb);
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_WIDGET_FAULTED, _widget_faulted_cb);
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_PERIOD_CHANGED, _widget_period_changed_cb);
- evas_object_smart_callback_del(widget, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, _widget_create_aborted_cb);
-}
-
-
-
-HAPI void widget_set_update_callback(Evas_Object *obj, int (*updated)(Evas_Object *obj))
-{
- evas_object_data_set(obj, TAG_UPDATED, updated);
-}
-
-
-
-HAPI void widget_set_scroll_callback(Evas_Object *obj, int (*scroll)(Evas_Object *obj, int hold))
-{
- evas_object_data_set(obj, TAG_SCROLL, scroll);
-}
-
-
-
-static int uninstall_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
- layout_info_s *layout_info;
- scroller_info_s *scroller_info;
- page_info_s *page_info;
- Eina_List *page_list;
- Evas_Object *page;
-
- if (status != PKGMGR_STATUS_START) {
- return 0;
- }
-
- if (!main_get_info()->layout) {
- return 0;
- }
-
- layout_info = evas_object_data_get(main_get_info()->layout, DATA_KEY_LAYOUT_INFO);
- if (!layout_info) {
- return 0;
- }
-
- scroller_info = evas_object_data_get(layout_info->scroller, DATA_KEY_SCROLLER_INFO);
- if (!scroller_info) {
- return 0;
- }
-
- if (!scroller_info->box) {
- return 0;
- }
-
- page_list = elm_box_children_get(scroller_info->box);
- EINA_LIST_FREE(page_list, page) {
- page_info = evas_object_data_get(page, DATA_KEY_PAGE_INFO);
- if (!page_info) {
- continue;
- }
-
- if (page_info->direction != PAGE_DIRECTION_RIGHT) {
- continue;
- }
-
- if (!page_info->item) {
- continue;
- }
-
- if (!widget_viewer_evas_is_faulted(page_info->item)) {
- continue;
- }
-
- _D("Faulted package: %s", widget_viewer_evas_get_widget_id(page_info->item));
- _widget_remove(page);
- }
-
- return 0;
-}
-
-
-
-HAPI void widget_init(Evas_Object *win)
-{
- int val;
-
- add_viewer_pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
-
- widget_viewer_evas_set_option(WIDGET_VIEWER_EVAS_AUTO_RENDER_SELECTION, 1);
-
- if (preference_get_int("memory/private/org.tizen.w-home/auto_feed", &val) >= 0) {
- widget_viewer_evas_set_option(WIDGET_VIEWER_EVAS_EVENT_AUTO_FEED, val);
- }
-
- if (preference_get_int("memory/private/org.tizen.w-home/sensitive_move", &val) >= 0) {
- widget_viewer_evas_set_option(WIDGET_VIEWER_EVAS_SENSITIVE_MOVE, val);
- }
-
- widget_viewer_evas_init(win);
- widget_viewer_evas_set_option(WIDGET_VIEWER_EVAS_SCROLL_X, 1);
-}
-
-
-
-HAPI void widget_fini(void)
-{
- widget_viewer_evas_fini();
- add_viewer_pkgmgr_del_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
-}
-
-
-
-// End of a file
diff --git a/src/widgets/widgets_manager.c b/src/widgets/widgets_manager.c
deleted file mode 100755
index d6f8b02..0000000
--- a/src/widgets/widgets_manager.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "widgets/widgets.h"
-
-ERROR_E widgets_init(void)
-{
- _D("%s", __func__);
-
- return ERROR_NONE;
-}
-
-void widgets_fini(void)
-{
-
-}
diff --git a/src/win.c b/src/win.c
deleted file mode 100755
index 7d43756..0000000
--- a/src/win.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <Elementary.h>
-#include <Evas.h>
-#include <dlog.h>
-
-#include "log.h"
-#include "util.h"
-#include "main.h"
-
-
-
-#ifdef BOOT_OPTIMIZATION
-static w_home_error_e _rotate_cb(main_s *info, int angle)
-{
- _D("Enter _rotate, angle is %d", angle);
- info->angle = angle;
-
- switch (angle) {
- case 0:
- _D("Portrait normal");
- info->is_rotated = 0;
- break;
- case 90:
- _D("Landscape reverse");
- info->is_rotated = 1;
- break;
- case 180:
- _D("Portrait reverse");
- info->is_rotated = 0;
- break;
- case 270:
- _D("Landscape normal");
- info->is_rotated = 1;
- break;
- default:
- _E("Cannot reach here, angle is %d", angle);
- }
-
- /* Rotate all objects */
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static void _rotation_changed_cb(void *data, Evas_Object *obj, void *event)
-{
- main_s *info = data;
- int changed_ang;
-
- ret_if(!info);
-
- changed_ang = elm_win_rotation_get(info->win);
- if (changed_ang != info->angle) {
- _rotate_cb(info, changed_ang);
- }
-}
-#endif
-
-
-
-HAPI Evas_Object *win_create(const char *name)
-{
- Evas_Object *win = NULL;
- main_s *info = NULL;
-
- info = main_get_info();
- retv_if(!info, NULL);
-
- elm_config_accel_preference_set("3d");
- //ecore_x_window_size_get(ecore_x_window_root_first_get(), &info->root_w, &info->root_h);
-
-#if 0 // Doesn't support app_get_preinitialized_window in the wearables
- win = (Evas_Object *) app_get_preinitialized_window(name);
- if (!win) win = elm_win_add(NULL, name, ELM_WIN_BASIC);
-#else
- win = elm_win_add(NULL, name, ELM_WIN_BASIC);
-#endif
- retv_if(!win, NULL);
-
- elm_win_screen_size_get(win, NULL, NULL, &info->root_w, &info->root_h);
- elm_win_title_set(win, name);
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_alpha_set(win, EINA_FALSE);
- elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_OPAQUE);
- elm_win_aux_hint_add(win, "wm.policy.win.gesture.disable", "1"); //Global gesture disable
-
-#ifdef BOOT_OPTIMIZATION
- /* Set available rotations */
- if (elm_win_wm_rotation_supported_get(win)) {
- const int rots[4] = {0, 90, 180, 270};
- elm_win_wm_rotation_available_rotations_set(win, (const int *) &rots, 4);
- _D("Set available rotations, {0, 90, 180, 270}");
- }
- evas_object_smart_callback_add(win, "wm,rotation,changed", _rotation_changed_cb, info);
-#endif
-
- evas_object_resize(win, info->root_w, info->root_h);
- evas_object_show(win);
- info->win = win;
- info->e = evas_object_evas_get(win);
-
- //xwin = elm_win_xwindow_get(win);
- //ecore_x_vsync_animator_tick_source_set(xwin);
-
- return win;
-}
-
-
-
-HAPI void win_destroy(Evas_Object *win)
-{
- main_s *info = NULL;
-
- ret_if(!win);
-
- info = main_get_info();
- ret_if(!info);
-
- evas_object_del(win);
- info->win = NULL;
-}
-
-
-
-// End of a file
diff --git a/src/wms.c b/src/wms.c
deleted file mode 100755
index 6ad23ea..0000000
--- a/src/wms.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app_control.h>
-#include <widget_service.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <Elementary.h>
-
-#include "log.h"
-#include "util.h"
-#include "db.h"
-#include "page.h"
-#include "widget.h"
-#include "wms.h"
-#include "conf.h"
-#include "layout_info.h"
-#include "xml.h"
-#include "page_info.h"
-#include "scroller_info.h"
-#include "scroller.h"
-#include "main.h"
-
-
-
-void wms_change_apps_order(int value)
-{
- switch(value)
- {
- case W_HOME_WMS_BACKUP:
- _D("Backup");
-
- //Have to set the DONE, 3, to notify that backup is completed.
- vconf_set_int(VCONF_KEY_WMS_APPS_ORDER, W_HOME_WMS_DONE);
-
- break;
- case W_HOME_WMS_RESOTRE:
- _D("Restore");
- break;
- case W_HOME_WMS_DONE:
- _D("done");
- //No need to do anything
- break;
- default:
- _E("Invalid value:[%d]", value);
- break;
- }
-}
-
-
-
-#define FAVORITES_ORDER_XML_PATH DATADIR"/favorites_order.xml"
-void wms_change_favorite_order(int value)
-{
- Evas_Object *layout = NULL;
- layout_info_s *layout_info = NULL;
- Eina_List *page_info_list = NULL;
-
- layout = evas_object_data_get(main_get_info()->win, DATA_KEY_LAYOUT);
- ret_if(!layout);
-
- layout_info = evas_object_data_get(layout, DATA_KEY_LAYOUT_INFO);
- ret_if(!layout_info);
-
- switch(value)
- {
- case W_HOME_WMS_BACKUP:
- _D("Favorite Backup");
-
- page_info_list = scroller_write_list(layout_info->scroller);
- if (page_info_list) {
- xml_read_list(FAVORITES_ORDER_XML_PATH, page_info_list);
- }
-
- //Have to set the DONE, 3, to notify that backup is completed.
- vconf_set_int(VCONF_KEY_WMS_FAVORITES_ORDER, W_HOME_WMS_DONE);
-
- break;
- case W_HOME_WMS_RESOTRE:
- _D("Favorite Restore");
- page_info_list = xml_write_list(FAVORITES_ORDER_XML_PATH);
- if (page_info_list) {
- scroller_read_favorites_list(layout_info->scroller, page_info_list);
- }
- break;
- case W_HOME_WMS_DONE:
- _D("done");
- //No need to do anything
- break;
- default:
- _E("Invalid value:[%d]", value);
- break;
- }
-}
-
-// End of a file
diff --git a/src/xml.c b/src/xml.c
deleted file mode 100755
index b220c72..0000000
--- a/src/xml.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * w-home
- * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <aul.h>
-#include <Eina.h>
-#include <Evas.h>
-
-#include <libxml/encoding.h>
-#include <libxml/xmlwriter.h>
-#include <libxml/xmlreader.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <dlog.h>
-#include <widget_viewer_evas.h> // WIDGET_EVAS_DEFAULT_PERIOD
-
-#include "log.h"
-#include "page_info.h"
-#include "util.h"
-#include "xml.h"
-
-const char *XML_ENCODING = "utf-8";
-const char *PAGE_CATEGORY_IDLE_CLOCK_STR = "idle-clock";
-const char *PAGE_CATEGORY_FAVORITE_STR = "favorite";
-const char *PAGE_CATEGORY_APP_WIDGET_STR = "appwidget";
-const char *PAGE_CATEGORY_MORE_APPS_STR = "more-apps";
-const int WIDGET_PER_PAGE = 4;
-
-static void _get_position_by_order(int ordering, int *row, int *cellx, int *celly)
-{
- ret_if(!row);
- ret_if(!cellx);
- ret_if(!celly);
-
- *row = ordering / 4;
-
- switch(ordering % 4) {
- case 0:
- *cellx = 0;
- *celly = 0;
- break;
- case 1:
- *cellx = 1;
- *celly = 0;
- break;
- case 2:
- *cellx = 0;
- *celly = 1;
- break;
- case 3:
- *cellx = 1;
- *celly = 1;
- break;
- default:
- _E("Failed to get cellx & celly");
- *cellx = -1;
- *celly = -1;
- break;
- }
-}
-
-
-
-static xmlTextWriterPtr _init_writer(const char *xml_file)
-{
- xmlTextWriterPtr writer;
- int ret = 0;
-
- writer = xmlNewTextWriterFilename(xml_file, 0);
- retv_if(!writer, NULL);
-
- ret = xmlTextWriterStartDocument(writer, NULL, XML_ENCODING, NULL);
- if (ret < 0) {
- _E("Failed to start xmlTextWriterStartDocument");
- xmlFreeTextWriter(writer);
- return NULL;
- }
-
- ret = xmlTextWriterStartElement(writer, BAD_CAST "data");
- if (ret < 0) {
- _E("Failed to start xmlTextWriterStartElement");
- xmlFreeTextWriter(writer);
- return NULL;
- }
-
- return writer;
-}
-
-
-
-static void _destroy_writer(xmlTextWriterPtr writer)
-{
- int ret = 0;
-
- ret = xmlTextWriterEndElement(writer);
- goto_if(ret < 0, END);
-
- ret = xmlTextWriterEndDocument(writer);
- if (ret < 0) {
- _E("Cannot end the document");
- }
-
-END:
- xmlFreeTextWriter(writer);
-}
-
-
-
-HAPI w_home_error_e xml_read_list(const char *xml_file, Eina_List *page_info_list)
-{
- xmlTextWriterPtr writer;
- Eina_List *l = NULL;
- page_info_s *page_info = NULL;
- char *category = NULL;
- int ret = 0;
- int row = -1;
- int cellx = -1;
- int celly = -1;
-
- retv_if(!xml_file, W_HOME_ERROR_INVALID_PARAMETER);
- retv_if(!page_info_list, W_HOME_ERROR_INVALID_PARAMETER);
-
- writer = _init_writer(xml_file);
- retv_if(!writer, W_HOME_ERROR_FAIL);
-
- EINA_LIST_FOREACH(page_info_list, l, page_info) {
- continue_if(!page_info);
-
- _get_position_by_order(page_info->ordering, &row, &cellx, &celly);
-
- switch(page_info->category) {
- case PAGE_CATEGORY_IDLE_CLOCK:
- category = (char *) PAGE_CATEGORY_IDLE_CLOCK_STR;
- break;
- case PAGE_CATEGORY_APP:
- category = (char *) PAGE_CATEGORY_FAVORITE_STR;
- break;
- case PAGE_CATEGORY_WIDGET:
- category = (char *) PAGE_CATEGORY_APP_WIDGET_STR;
- break;
- case PAGE_CATEGORY_MORE_APPS:
- category = (char *) PAGE_CATEGORY_MORE_APPS_STR;
- break;
- default:
- _E("page_info->category error");
- break;
- }
-
- ret = xmlTextWriterStartElement(writer, BAD_CAST category);
- goto_if(ret < 0, END);
-
- ret = xmlTextWriterWriteFormatElement(writer, BAD_CAST "packageName", "%s", page_info->id);
- goto_if(ret < 0, END);
-
- if (page_info->subid) {
- ret = xmlTextWriterWriteFormatElement(writer, BAD_CAST "className", "%s", page_info->subid);
- } else {
- ret = xmlTextWriterWriteFormatElement(writer, BAD_CAST "className", "%s", page_info->id);
- }
- goto_if(ret < 0, END);
-
- ret = xmlTextWriterWriteFormatElement(writer, BAD_CAST "screen", "%d", row);
- goto_if(ret < 0, END);
-
- ret = xmlTextWriterWriteFormatElement(writer, BAD_CAST "cellX", "%d", cellx);
- goto_if(ret < 0, END);
-
- ret = xmlTextWriterWriteFormatElement(writer, BAD_CAST "cellY", "%d", celly);
- goto_if(ret < 0, END);
-
- ret = xmlTextWriterEndElement(writer);
- goto_if(ret < 0, END);
- }
-
-END:
- _destroy_writer(writer);
-
- return W_HOME_ERROR_NONE;
-}
-
-
-
-static xmlTextReaderPtr _init_reader(const char *xml_file)
-{
- xmlTextReaderPtr reader = NULL;
-
- retv_if(!xml_file, NULL);
-
- reader = xmlReaderForFile(xml_file, NULL, 0);
- retv_if(!reader, NULL);
-
- return reader;
-}
-
-
-
-static void _destroy_reader(xmlTextReaderPtr reader)
-{
- ret_if(!reader);
- xmlFreeTextReader(reader);
-}
-
-
-
-HAPI Eina_List *xml_write_list(const char *xml_file)
-{
- xmlTextReaderPtr reader = NULL;
- Eina_List *page_info_list = NULL;
- page_info_s *page_info = NULL;
- const char *name, *value;
- char *element = NULL;
- int ret = -1;
-
- retv_if(!xml_file, NULL);
-
- reader = _init_reader(xml_file);
- retv_if(!reader, NULL);
-
- while ((ret = xmlTextReaderRead(reader)) == 1) {
- int dep = 0;
- int node_type = 0;
- static int cellx = 0;
- static int celly = 0;
- static int page_no = 0;
-
- dep = xmlTextReaderDepth(reader);
- node_type = xmlTextReaderNodeType(reader);
- continue_if(-1 == dep || -1 == node_type);
-
- name = (const char*) xmlTextReaderConstName(reader);
- continue_if(!name);
-
- value = (const char*) xmlTextReaderConstValue(reader);
- /* value can be NULL in case of 'category' */
-
- // Category, element is 1
- if ((1 == dep) && (1 == node_type)) {
- if (page_info) {
- page_info_destroy(page_info);
- page_info = NULL;
- }
-
- page_info = page_info_create(NULL, NULL, WIDGET_VIEWER_EVAS_DEFAULT_PERIOD);
- goto_if(!page_info, CRITICAL_ERROR);
-
- if(!strcasecmp(PAGE_CATEGORY_IDLE_CLOCK_STR, name)) {
- page_info->category = PAGE_CATEGORY_IDLE_CLOCK;
- } else if(!strcasecmp(PAGE_CATEGORY_FAVORITE_STR, name)) {
- page_info->category = PAGE_CATEGORY_APP;
- } else if(!strcasecmp(PAGE_CATEGORY_APP_WIDGET_STR, name)) {
- page_info->category = PAGE_CATEGORY_WIDGET;
- } else if(!strcasecmp(PAGE_CATEGORY_MORE_APPS_STR, name)) {
- page_info->category = PAGE_CATEGORY_MORE_APPS;
- } else {
- _E("Type is wrong.");
- page_info_destroy(page_info);
- page_info = NULL;
- }
- continue;
- }
-
- // Category has to be at first.
- if (!page_info) continue;
-
- // Element name
- if ((2 == dep) && (1 == node_type)) {
- if (element) {
- _E("The element name is NOT NULL");
- free(element);
- element = NULL;
- }
-
- element = strdup(name);
- goto_if(!element, CRITICAL_ERROR);
- continue;
- }
-
- // Element value, textfield is 3
- if ((3 == dep) && (3 == node_type)) {
- continue_if(!element);
-
- if (!strcasecmp("packageName", element)) {
- page_info->id = strdup(value);
- goto_if(!page_info->id, CRITICAL_ERROR);
- } else if (!strcasecmp("className", element)) {
- if (page_info->id && !strcmp(value, page_info->id)) {
- _D("%s subid is NULL", page_info->id);
- page_info->subid = NULL;
- } else {
- page_info->subid = strdup(value);
- goto_if(!page_info->subid, CRITICAL_ERROR);
- }
- } else if(!strcasecmp("screen", element)) {
- page_no = atoi(value);
- } else if(!strcasecmp("cellx", element)) {
- cellx = atoi(value);
- } else if(!strcasecmp("celly", element)) {
- celly = atoi(value);
- }
- continue;
- }
-
- // End of the Element
- if ((2 == dep) && (15 == node_type)) {
- if (!element) {
- if (page_info) {
- page_info_destroy(page_info);
- page_info = NULL;
- continue;
- }
- }
-
- free(element);
- element = NULL;
- continue;
- }
-
- // End of the category
- if ((1 == dep) && (15 == node_type)) { // End of the category
- page_info->direction = PAGE_DIRECTION_RIGHT;
- page_info->ordering = page_no * WIDGET_PER_PAGE + celly * 2 + cellx;
- page_info->removable = page_info_is_removable(page_info->id);
- page_info_list = eina_list_append(page_info_list, page_info);
- _D("Append a package into the page_info_list : (%s:%s:%d:%d) (%d:%d:%d)"
- , page_info->id, page_info->subid, page_info->category, page_info->ordering
- , page_no, celly, cellx);
-
- page_info = NULL;
- page_no = 0;
- cellx = 0;
- celly = 0;
- }
- }
-
- if(element) {
- _E("An element is not appended properly");
- free(element);
- element = NULL;
- }
-
- if(page_info) {
- _E("A node(%s) is not appended into the page_info_list", page_info->subid);
- page_info_destroy(page_info);
- page_info = NULL;
- }
- goto_if(ret, CRITICAL_ERROR);
-
- _destroy_reader(reader);
- return page_info_list;
-
-CRITICAL_ERROR:
- if (page_info) page_info_destroy(page_info);
- page_info_list_destroy(page_info_list);
- _destroy_reader(reader);
- free(element);
- return NULL;
-}
-
-
-
-// End of a file