--- /dev/null
- if (instance_id);
+ /*
+ * Copyright (c) 2017 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 <string.h>
+ #include <unistd.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <glib.h>
+ #include <aul.h>
+ #include <aul_widget.h>
+ #include <wayland-extension/tizen-remote-surface-client-protocol.h>
+ #include <tbm_surface.h>
+ #include <screen_connector_toolkit_evas.h>
+ #include <Elementary.h>
+
+ #define MAX_BUFSZ 100
+ #define REGULAR_UID_MIN 5000
+
+ enum command_e {
+ CMD_LIST,
+ CMD_DUMP,
+ CMD_MAX,
+ };
+
+ enum option_e {
+ OPT_USER,
+ OPT_PATH,
+ OPT_MAX,
+ };
+
+ struct command_arg {
+ int argc;
+ char **argv;
+ uid_t uid;
+ char *path;
+ };
+
+ struct command {
+ const char *name;
+ int (*init)(struct command_arg *);
+ int (*run)(struct command_arg *);
+ void (*finish)(struct command_arg *);
+ };
+
+ struct widget_info {
+ char *widget_id;
+ char *instance_id;
+ pid_t pid;
+ unsigned int surf;
+ };
+
+ static gchar *help;
+ static gpointer cmd_opt[CMD_MAX];
+ static GOptionEntry cmd_entries[] = {
+ { "list", 'l', 0, G_OPTION_ARG_NONE, &cmd_opt[CMD_LIST],
+ "Show running widget list", NULL },
+ { "dump", 'd', 0, G_OPTION_ARG_NONE, &cmd_opt[CMD_DUMP],
+ "Dump running widget windows", NULL },
+ { NULL }
+ };
+ static gpointer opt[OPT_MAX];
+ static GOptionEntry opt_entries[] = {
+ { "user", 'u', 0, G_OPTION_ARG_INT, &opt[OPT_USER],
+ "Specify the user ID", "USER ID" },
+ { "path", 'p', 0, G_OPTION_ARG_STRING, &opt[OPT_PATH],
+ "Specify the path", "PATH" },
+ { NULL }
+ };
+ static GList *widget_info_list;
+ static Evas_Object *win;
+
+ static GOptionGroup *__get_opt_group(void)
+ {
+ GOptionGroup *group;
+
+ group = g_option_group_new("option", "Additional Options:",
+ "Additional options", NULL, NULL);
+ if (!group)
+ return NULL;
+
+ g_option_group_add_entries(group, opt_entries);
+
+ return group;
+ }
+
+ static struct command_arg __get_command_arg(int argc, char **argv)
+ {
+ struct command_arg cmd_arg = { 0, };
+
+ cmd_arg.argc = argc;
+ cmd_arg.argv = argv;
+
+ if (opt[OPT_USER])
+ cmd_arg.uid = GPOINTER_TO_INT(opt[OPT_USER]);
+
+ cmd_arg.path = opt[OPT_PATH];
+
+ return cmd_arg;
+ }
+
+ static void __print_delim(char c)
+ {
+ char buf[MAX_BUFSZ];
+
+ memset(buf, c, sizeof(buf));
+ printf("%s\n", buf);
+ }
+
+ static void __foreach_widget_info(aul_widget_info_h info,
+ void *user_data)
+ {
+ char *widget_id = NULL;
+ char *instance_id = NULL;
+ char *app_id = NULL;
+ char *package_id = NULL;
+ char *app_path = NULL;
+ pid_t pid = -1;
+ unsigned int surf = 0;
+ int *count = (int *)user_data;
+
+ if (info == NULL)
+ return;
+
+ aul_widget_info_get_widget_id(info, &widget_id);
+ aul_widget_info_get_instance_id(info, &instance_id);
+ aul_widget_info_get_app_id(info, &app_id);
+ aul_widget_info_get_package_id(info, &package_id);
+ aul_widget_info_get_app_path(info, &app_path);
+ aul_widget_info_get_pid(info, &pid);
+ aul_widget_info_get_surface_id(info, &surf);
+
+ if (*count != 0)
+ __print_delim('-');
+
+ printf(" - [Widget ID] \t\t%s\n", widget_id);
+ printf(" - [Instance ID] \t%s\n", instance_id);
+ printf(" - [App ID] \t\t%s\n", app_id);
+ printf(" - [Package ID] \t%s\n", package_id);
+ printf(" - [App Path] \t\t%s\n", app_path);
+ printf(" - [PID] \t\t%d\n", pid);
+ printf(" - [Surface ID] \t%#x\n", surf);
+
+ free(app_path);
+ free(package_id);
+ free(app_id);
+ free(instance_id);
+ free(widget_id);
+ (*count)++;
+ }
+
+ static int __cmd_list_run(struct command_arg *arg)
+ {
+ int r;
+ int count = 0;
+
+ __print_delim('=');
+ printf(" Running Widget List\n");
+ __print_delim('=');
+
+ r = aul_widget_info_foreach_for_uid(__foreach_widget_info,
+ &count, arg->uid);
+ __print_delim('=');
+
+ return r;
+ }
+
+ static int __save_image(Evas_Object *image, const char *filename,
+ int quality, int compress)
+ {
+ Ecore_Evas *ee;
+ Evas_Object *obj;
+ tbm_surface_h surface;
+ tbm_surface_info_s info;
+ Evas_Native_Surface *ns;
+ void *data;
+ int w;
+ int h;
+ char buf[128];
+
+ if (image == NULL || filename == NULL)
+ return -1;
+
+ snprintf(buf, sizeof(buf), "quality=%d compress=%d", quality, compress);
+ ns = evas_object_image_native_surface_get(image);
+ if (ns == NULL) {
+ evas_object_image_save(image, filename, NULL, buf);
+ return 0;
+ }
+
+ surface = (tbm_surface_h)ns->data.tbm.buffer;
+ if (surface == NULL)
+ return -1;
+
+ memset(&info, 0, sizeof(tbm_surface_info_s));
+ tbm_surface_map(surface, TBM_SURF_OPTION_READ, &info);
+ data = info.planes[0].ptr;
+ w = info.planes[0].stride / 4;
+ h = info.height;
+
+ ee = ecore_evas_buffer_new(1, 1);
+ if (ee == NULL) {
+ tbm_surface_unmap(surface);
+ return -1;
+ }
+
+ obj = evas_object_image_add(ecore_evas_get(ee));
+ if (obj == NULL) {
+ ecore_evas_free(ee);
+ tbm_surface_unmap(surface);
+ return -1;
+ }
+
+ evas_object_image_alpha_set(obj, EINA_TRUE);
+ evas_object_image_size_set(obj, w, h);
+ evas_object_image_data_set(obj, data);
+
+ evas_object_image_save(obj, filename, NULL, buf);
+ tbm_surface_unmap(surface);
+ evas_object_del(obj);
+ ecore_evas_free(ee);
+
+ return 0;
+ }
+
+ static void __destroy_widget_info(struct widget_info *info)
+ {
+ if (info == NULL)
+ return;
+
+ if (info->instance_id)
+ free(info->instance_id);
+ if (info->widget_id)
+ free(info->widget_id);
+ free(info);
+ }
+
+ static gint __compare_surf(gconstpointer a, gconstpointer b)
+ {
+ struct widget_info *info = (struct widget_info *)a;
+ unsigned int surf = GPOINTER_TO_UINT(b);
+
+ if (info->surf == surf)
+ return 0;
+
+ return -1;
+ }
+
+ static void __screen_connector_toolkit_evas_added_cb(const char *appid,
+ const char *instance_id, int pid,
+ Evas_Object *image, void *data)
+ {
+ const char *path = (const char *)data;
+ char cwd[PATH_MAX];
+ char buf[PATH_MAX];
+ unsigned int surf;
+ struct widget_info *info = NULL;
+ GList *found;
+
+ if (image == NULL)
+ return;
+
+ if (path == NULL)
+ path = getcwd(cwd, sizeof(cwd));
+ if (access(path, F_OK) != 0)
+ mkdir(path, 0755);
+
+ screen_connector_toolkit_evas_get_rid(image, (int *)&surf);
+ found = g_list_find_custom(widget_info_list, GUINT_TO_POINTER(surf),
+ __compare_surf);
+ if (found)
+ info = (struct widget_info *)found->data;
+
+ if (info == NULL) {
+ printf("Unknown surface(%u)", surf);
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%d_%s.jpg",
+ path, info->pid, info->instance_id);
+ __save_image(image, buf, 100, 100);
+
+ widget_info_list = g_list_remove(widget_info_list, info);
+ __destroy_widget_info(info);
+
+ if (widget_info_list == NULL)
+ elm_exit();
+ }
+
+ static void __screen_connector_toolkit_evas_removed_cb(const char *appid,
+ const char *instance_id, int pid,
+ Evas_Object *image, void *data)
+ {
+ /* Nothing */
+ }
+
+ static void __screen_connector_toolkit_evas_updated_cb(const char *appid,
+ const char *instance_id, int pid,
+ Evas_Object *image, void *data)
+ {
+ /* Nothing */
+ }
+
+ static void __get_widget_list(aul_widget_info_h info,
+ void *user_data)
+ {
+ struct widget_info *w_info;
+ char *widget_id = NULL;
+ char *instance_id = NULL;
+ pid_t pid = -1;
+ unsigned int surf = 0;
+ int r;
+
+ if (info == NULL)
+ return;
+
+ r = aul_widget_info_get_widget_id(info, &widget_id);
+ if (r != AUL_R_OK)
+ return;
+
+ r = aul_widget_info_get_instance_id(info, &instance_id);
+ if (r != AUL_R_OK)
+ goto err;
+
+ r = aul_widget_info_get_pid(info, &pid);
+ if (r != AUL_R_OK)
+ goto err;
+
+ r = aul_widget_info_get_surface_id(info, &surf);
+ if (r != AUL_R_OK)
+ goto err;
+
+ w_info = calloc(1, sizeof(struct widget_info));
+ if (!w_info) {
+ printf("Failed to create widget info\n");
+ goto err;
+ }
+
+ w_info->widget_id = widget_id;
+ w_info->instance_id = instance_id;
+ w_info->pid = pid;
+ w_info->surf = surf;
+
+ widget_info_list = g_list_append(widget_info_list, w_info);
+
+ return;
+ err:
- SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET);
++ if (instance_id)
+ free(instance_id);
+ if (widget_id)
+ free(widget_id);
+ }
+
+ static int __cmd_dump_init(struct command_arg *arg)
+ {
+ int r;
+
+ r = aul_widget_info_foreach_for_uid(__get_widget_list,
+ NULL, arg->uid);
+ if (r < 0)
+ return -1;
+
+ if (widget_info_list == NULL) {
+ printf("Widget info is empty\n");
+ return -1;
+ }
+
+ elm_init(arg->argc, arg->argv);
+
+ win = elm_win_util_standard_add("widget-mgr", "widget-mgr");
+ if (!win) {
+ printf("Failed to add window\n");
+ elm_shutdown();
+ return -1;
+ }
+
+ elm_win_alpha_set(win, EINA_FALSE);
+ evas_object_show(win);
+
+ screen_connector_toolkit_evas_init(win,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET, user_data);
++ SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET);
+
+ return 0;
+ }
+
+ static void __foreach_widget_info_list(gpointer data, gpointer user_data)
+ {
+ struct widget_info *info = (struct widget_info *)data;
+ screen_connector_toolkit_evas_ops ops;
+ screen_connector_toolkit_evas_h handle;
+
+ if (info == NULL)
+ return;
+
+ ops.added_cb = __screen_connector_toolkit_evas_added_cb;
+ ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
+ ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
+
+ handle = screen_connector_toolkit_evas_add_by_rid(&ops, info->surf,
- screen_connector_toolkit_evas_fini(SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET);
++ SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, user_data);
+ if (handle == NULL) {
+ printf("Failed to add toolkit by rid(%u)", info->surf);
+ return;
+ }
+ }
+
+ static gboolean __dump_widgets(gpointer data)
+ {
+ g_list_foreach(widget_info_list, __foreach_widget_info_list, data);
+
+ return G_SOURCE_REMOVE;
+ }
+
+ static int __cmd_dump_run(struct command_arg *arg)
+ {
+ g_idle_add(__dump_widgets, arg->path);
+ elm_run();
+
+ return 0;
+ }
+
+ static void __cmd_dump_finish(struct command_arg *arg)
+ {
++ screen_connector_toolkit_evas_fini(SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET);
+ evas_object_del(win);
+ elm_shutdown();
+ }
+
+ static struct command cmd_table[] = {
+ [CMD_LIST] = {
+ .name = "list",
+ .init = NULL,
+ .run = __cmd_list_run,
+ .finish = NULL
+ },
+ [CMD_DUMP] = {
+ .name = "dump",
+ .init = __cmd_dump_init,
+ .run = __cmd_dump_run,
+ .finish = __cmd_dump_finish
+ },
+ };
+
+ static struct command *__find_command(void)
+ {
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS(cmd_table); ++i) {
+ if (cmd_opt[i])
+ return &cmd_table[i];
+ }
+
+ return NULL;
+ }
+
+ static int __run_command(struct command_arg *cmd_arg)
+ {
+ struct command *cmd;
+
+ cmd = __find_command();
+ if (cmd == NULL) {
+ printf("%s", help);
+ return -1;
+ }
+
+ if (cmd->init) {
+ if (cmd->init(cmd_arg) < 0)
+ return -1;
+ }
+
+ if (cmd->run) {
+ if (cmd->run(cmd_arg) < 0)
+ return -1;
+ }
+
+ if (cmd->finish)
+ cmd->finish(cmd_arg);
+
+ return 0;
+ }
+
+ static int __parse_args(int argc, char **argv)
+ {
+ GOptionContext *context;
+ GOptionGroup *opt_group;
+ GError *error = NULL;
+
+ context = g_option_context_new(NULL);
+ if (!context) {
+ printf("Failed to create GOptionContext\n");
+ return -1;
+ }
+
+ g_option_context_add_main_entries(context, cmd_entries, NULL);
+
+ opt_group = __get_opt_group();
+ if (!opt_group) {
+ printf("Failed to get opt group\n");
+ g_option_context_free(context);
+ return -1;
+ }
+ g_option_context_add_group(context, opt_group);
+
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
+ printf("%s: %s\n", argv[0], error->message);
+ g_option_context_free(context);
+ g_clear_error(&error);
+ return -1;
+ }
+
+ help = g_option_context_get_help(context, TRUE, NULL);
+ g_option_context_free(context);
+
+ return 0;
+ }
+
+ int main(int argc, char **argv)
+ {
+ struct command_arg cmd_arg;
+ int r;
+
+ if (getuid() >= REGULAR_UID_MIN) {
+ printf("Regular users cannot run this tool.\n");
+ return -1;
+ }
+
+ r = __parse_args(argc, argv);
+ if (r < 0)
+ return -1;
+
+ cmd_arg = __get_command_arg(argc, argv);
+ r = __run_command(&cmd_arg);
+ if (r < 0) {
+ free(help);
+ return -1;
+ }
+
+ free(help);
+
+ return 0;
+ }
extern int watch_manager_get_app_control(const char *app_id, app_control_h *app_control);
extern int watch_manager_send_terminate(Evas_Object *watch);
extern int watch_policy_set_size_hint(watch_policy_size_hint hint);
+ extern int watch_manager_enable_buffer_update(void);
+ extern int watch_manager_disable_buffer_update(void);
extern int watch_manager_set_resource_id(int resource_id);
extern int watch_manager_get_resource_id(Evas_Object *watch, int *resource_id);
+ extern int watch_manager_add_dead_signal_listener(watch_dead_signal_cb cb, void *data);
+ extern int watch_manager_remove_dead_signal_listener(watch_dead_signal_cb cb);
+
+ /**
+ * @brief Gets the opr of the Evas Object
+ * @since_tizen 3.0
+ * @param[out] opr The OPR(On Pixel Ratio)
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_get_opr(float *opr);
+
+ /**
+ * @brief Cancels watch's click event.
+ * @details If you call this function after feeding the mouse down event, the watch will get ON_HOLD events.
+ * @since_tizen 4.0
+ * @param[in] watch A watch object
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_cancel_click_event(Evas_Object *watch);
+
+ /**
+ * @brief Changes the policy for sending visibilities
+ * @details If you turn off, the framework will not send visibility events automatically.
+ * @since_tizen 4.0
+ * @remarks By default, it is enabled
+ * @param[in] enable Whether it should be enabled or not
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_change_auto_visibility(bool enable);
+
+ /**
+ * @brief Sends a paused event to the display server.
+ * @details It sends a paused event to the display server so that it can pass on the watch application.
+ * @since_tizen 4.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_pause(void);
+
+ /**
+ * @brief Sends a resumed event to the display server.
+ * @details It sends a resumed event to the display server so that it can pass on the watch application.
+ * @since_tizen 4.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_resume(void);
+
+ /**
+ * @brief Binds watch's window with the window.
+ * @details Watch's window will be shown with the viewer window automatically.
+ * @since_tizen 4.0
+ * @param[in] win Window for the viewer app
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_window_bind(Evas_Object *win);
+
+ /**
+ * @brief Unbinds watch's window
+ * @details Watch's window will be updated as an image object.
+ * @since_tizen 4.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_window_unbind(void);
+
+ /**
+ * @brief Gets watch's setup appid.
+ * @since_tizen 3.0
+ * @remarks setup_appid should be freed.
+ * @param[in] app_id A watch app id
+ * @param[out] setup_appid A watch app id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_get_setup_appid(const char *app_id, char **setup_appid);
+
+ /**
+ * @brief Notify watch application that viewer application is paused.
+ * @remarks Watch application can not resume until it gets viewer resumed event.
+ * @since_tizen 3.0
+ * @return @c 0 on success, otherwise a negative error value
+ * @see #watch_manager_notify_resumed_status_of_viewer
+ */
+ extern int watch_manager_notify_paused_status_of_viewer(void);
+
+ /**
+ * @brief Notify watch application that viewer application is resumed.
+ * @remarks Watch application can not resume until it gets viewer resumed event.
+ * @since_tizen 3.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+ extern int watch_manager_notify_resumed_status_of_viewer(void);
+/**
+ * @brief Gets watch's setup appid.
+ * @since_tizen 4.0
+ * @remarks setup_appid should be freed.
+ * @param[in] app_id A watch app id
+ * @param[out] setup_appid A watch app id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_get_setup_appid(const char *app_id, char **setup_appid);
+
+/**
+ * @brief Gets the opr of the Evas Object
+ * @since_tizen 3.0
+ * @param[out] opr The OPR(On Pixel Ratio)
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_get_opr(float *opr);
+
+/**
+ * @brief Cancels watch's click event.
+ * @details If you call this function after feeding the mouse down event, the watch will get ON_HOLD events.
+ * @since_tizen 4.0
+ * @param[in] watch A watch object
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_cancel_click_event(Evas_Object *watch);
+
+/**
+ * @brief Changes the policy for sending visibilities
+ * @details If you turn off, the framework will not send visibility events automatically.
+ * @since_tizen 4.0
+ * @remarks By default, it is enabled
+ * @param[in] enable Whether it should be enabled or not
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_change_auto_visibility(bool enable);
+
+/**
+ * @brief Sends a paused event to the display server.
+ * @details It sends a paused event to the display server so that it can pass on the watch application.
+ * @since_tizen 4.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_pause(void);
+
+/**
+ * @brief Sends a resumed event to the display server.
+ * @details It sends a resumed event to the display server so that it can pass on the watch application.
+ * @since_tizen 4.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_resume(void);
+
+/**
+ * @brief Binds watch's window with the window.
+ * @details Watch's window will be shown with the viewer window automatically.
+ * @since_tizen 4.0
+ * @param[in] win Window for the viewer app
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_window_bind(Evas_Object *win);
+
+/**
+ * @brief Unbinds watch's window
+ * @details Watch's window will be updated as an image object.
+ * @since_tizen 4.0
+ * @return @c 0 on success, otherwise a negative error value
+ */
+extern int watch_manager_window_unbind(void);
+
#ifdef __cplusplus
}
#endif
}
screen_connector_toolkit_evas_stop_visibility_notify();
- screen_connector_toolkit_evas_fini(SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH);
+ screen_connector_toolkit_evas_fini(SCREEN_CONNECTOR_SCREEN_TYPE_WATCH);
+
+ if (__lcd_subscribe_id != 0) {
+ g_dbus_connection_signal_unsubscribe(
+ __gdbus_conn, __lcd_subscribe_id);
+ __lcd_subscribe_id = 0;
+ }
+
+ if (__gdbus_conn) {
+ g_object_unref(__gdbus_conn);
+ __gdbus_conn = NULL;
+ }
}
API int watch_manager_init(Evas_Object *win)
ops.added_cb = __screen_connector_toolkit_evas_added_cb;
ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
- handle = screen_connector_toolkit_evas_add_by_rid(&ops, resource_id, SCREEN_CONNECTOR_SCREEN_TYPE_WATCH, NULL);
+ handle = screen_connector_toolkit_evas_add_by_rid(&ops, resource_id,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH, NULL);
++ SCREEN_CONNECTOR_SCREEN_TYPE_WATCH, NULL);
if (handle == NULL) {
_E("Fail screen_connector_toolkit_evas_add_by_rid");
return -1;
if (ret != PMINFO_R_OK)
return -1;
- ret = pkgmgrinfo_appinfo_get_setup_appid(handle, &tmp_appid);
- ret = pkgmgrinfo_appinfo_get_metadata_value(handle, METADATA_SETUP_APPID, &tmp_appid);
++ ret = pkgmgrinfo_appinfo_get_metadata_value(handle,
++ METADATA_SETUP_APPID, &tmp_appid);
if (ret != PMINFO_R_OK) {
pkgmgrinfo_appinfo_destroy_appinfo(handle);
return -1;
return ret;
}
- API int watch_manager_cancel_click_event(Evas_Object *watch)
-static int __dead_signal_handler(const char *endpoint, aul_app_com_result_e e, bundle *envelope, void *user_data)
++static int __dead_signal_handler(const char *endpoint, aul_app_com_result_e e,
++ bundle *envelope, void *user_data)
{
- return screen_connector_toolkit_evas_send_touch_cancel(watch);
+ char *appid = NULL;
+ char *is_faulted = NULL;
+ char *pid_str = NULL;
+ int pid = 0;
+ struct dead_cb_s *cb_info;
+ GList *iter = __dead_cbs;
+ bool faulted = false;
+
+ bundle_get_str(envelope, AUL_K_APPID, &appid);
+ bundle_get_str(envelope, AUL_K_PID, &pid_str);
+ bundle_get_str(envelope, AUL_K_IS_FAULT, &is_faulted);
+
+ _D("appid %s pid %s is_faulted %s", appid, pid_str, is_faulted);
+ if (pid_str)
+ pid = atoi(pid_str);
+ if (is_faulted && (strcmp(is_faulted, "true") == 0))
+ faulted = true;
+
+ while (iter) {
+ cb_info = (struct dead_cb_s *)iter->data;
+ if (cb_info && cb_info->cb)
+ cb_info->cb(appid, pid, faulted, cb_info->data);
+
+ iter = iter->next;
+ }
+
+ return 0;
}
- API int watch_manager_change_auto_visibility(bool enable)
+ static int __connect_dead_signal()
{
- if (!enable)
- screen_connector_toolkit_evas_stop_visibility_notify();
- else
- screen_connector_toolkit_evas_start_visibility_notify();
+ if (__is_dead_signal_connected)
+ return 0;
+
+ if (aul_app_com_create("watch.dead", NULL,
+ __dead_signal_handler, NULL, &__conn_dead_signal) < 0) {
+ _E("failed to create status");
+ return -1;
+ }
+
+ __is_dead_signal_connected = 1;
return 0;
}
return -1;
}
- if (visible) {
- return screen_connector_toolkit_evas_send_visibility(image,
- VISIBILITY_TYPE_UNOBSCURED);
- } else {
- return screen_connector_toolkit_evas_send_visibility(image,
- VISIBILITY_TYPE_FULLY_OBSCURED);
+ cb_info->cb = cb;
+ cb_info->data = data;
+
+ __dead_cbs = g_list_append(__dead_cbs, cb_info);
+ if (!__dead_cbs) {
+ _E("out of memory");
+ free(cb_info);
+ return -1;
}
- }
- API int watch_manager_pause(void)
- {
- return __change_visibility(false);
+ __connect_dead_signal();
+
+ return ret;
}
- API int watch_manager_resume(void)
+ API int watch_manager_remove_dead_signal_listener(watch_dead_signal_cb cb)
{
- return __change_visibility(true);
+ struct dead_cb_s *cb_info;
+ GList *iter = __dead_cbs;
+
+ if (!cb) {
+ _E("invalid parameter");
+ return -1;
+ }
+
+ while (iter) {
+ cb_info = (struct dead_cb_s *)iter->data;
+ if (cb_info && cb_info->cb == cb) {
+ __dead_cbs = g_list_remove_link(__dead_cbs, iter);
+ free(cb_info);
+ g_list_free(iter);
+ return 0;
+ }
+ iter = iter->next;
+ }
+
+ _E("wrong argument");
+ return -1;
}
- API int watch_manager_window_bind(Evas_Object *win)
+ static int __launch_signal_handler(const char *endpoint,
+ aul_app_com_result_e res, bundle *envelope, void *user_data)
{
- if (!__toolkit || !win)
+ char *appid = NULL;
+ char *viewer = NULL;
+ char *pid_str = NULL;
+ screen_connector_toolkit_evas_ops ops;
+ bool exist;
+
+ bundle_get_str(envelope, AUL_K_WIDGET_VIEWER, &viewer);
+ if (viewer == NULL)
return -1;
- return screen_connector_toolkit_evas_bind(__toolkit, win);
+ if (strcmp(viewer, viewer_appid) != 0)
+ return 0;
+
+ bundle_get_str(envelope, AUL_K_APPID, &appid);
+ if (appid == NULL)
+ return -1;
+
+ bundle_get_str(envelope, AUL_K_PID, &pid_str);
+
+ _D("cur appid(%s), new appid(%s), pid(%s)",
+ __watch_appid, appid, pid_str);
+
+ exist = screen_connector_toolkit_is_exist(appid,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH);
++ SCREEN_CONNECTOR_SCREEN_TYPE_WATCH);
+
+ if (exist) {
+ screen_connector_toolkit_evas_remove(__toolkit);
+ } else {
+ __tmp_toolkit = __toolkit;
+ _D("Old toolkit %p", __tmp_toolkit);
+ }
+
+ ops.added_cb = __screen_connector_toolkit_evas_added_cb;
+ ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
+ ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
+ __toolkit = screen_connector_toolkit_evas_add(&ops, appid,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH, NULL);
++ SCREEN_CONNECTOR_SCREEN_TYPE_WATCH, NULL);
+
+ if (__watch_appid)
+ free(__watch_appid);
+
+ __watch_appid = strdup(appid);
+ if (__watch_appid == NULL)
+ _E("Out of memory");
+
+ return 0;
}
- API int watch_manager_window_unbind(void)
+ static int __listen_launch_signal(void)
{
- if (!__toolkit)
+ int r;
+
+ if (__conn_launch_signal)
+ return 0;
+
+ r = aul_app_com_create("watch.launch", NULL, __launch_signal_handler,
+ NULL, &__conn_launch_signal);
+ if (r < 0) {
+ _E("Failed to listen watch.launch signal");
return -1;
+ }
- return screen_connector_toolkit_evas_unbind(__toolkit);
+ return 0;
}
+ static void __ignore_launch_signal(void)
+ {
+ if (!__conn_launch_signal)
+ return;
+
+ aul_app_com_leave(__conn_launch_signal);
+ __conn_launch_signal = NULL;
+ }
ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
- screen_connector_toolkit_evas_add(&ops, widget_instance_info->instance_id,
- SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, widget_instance_info);
+ if (widget_instance_info->toolkit_h) {
+ screen_connector_toolkit_evas_remove(widget_instance_info->toolkit_h);
+ widget_instance_info->toolkit_h = NULL;
+ }
+
+ widget_instance_info->toolkit_h = screen_connector_toolkit_evas_add(&ops,
+ widget_instance_info->instance_id,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET,
++ SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET,
+ widget_instance_info);
+
widget_instance_info->pid = widget_instance_launch(widget_instance_info->instance_id, widget_instance_info->content_info, w, h);
widget_instance_info->restart = false;
}
return WIDGET_ERROR_INVALID_PARAMETER;
}
- if (!bindtextdomain(PKGNAME, WIDGET_VIEWER_EVAS_RESOURCE_PO)) {
+ if (s_info.initialized) {
+ ErrPrint("Already initialized");
+ return WIDGET_ERROR_ALREADY_EXIST;
+ }
+
+ if (!bindtextdomain(PKGNAME, WIDGET_VIEWER_EVAS_RESOURCE_PO))
ErrPrint("bindtextdomain: %d", errno);
- } else {
+ else
DbgPrint("%s - %s", PKGNAME, WIDGET_VIEWER_EVAS_RESOURCE_PO);
- }
s_info.win = win;
- screen_connector_toolkit_evas_init(win, SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET);
++
+ screen_connector_toolkit_evas_init(win, SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET);
screen_connector_toolkit_evas_start_visibility_notify();
if (aul_app_get_appid_bypid(getpid(), app_id, sizeof(app_id)) != AUL_R_OK) {
ops.added_cb = __screen_connector_toolkit_evas_added_cb;
ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
- screen_connector_toolkit_evas_add(&ops, info->instance_id, SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, info);
- info->toolkit_h = screen_connector_toolkit_evas_add(&ops, info->instance_id, SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET, info);
+ if (info->toolkit_h) {
+ screen_connector_toolkit_evas_remove(info->toolkit_h);
+ info->toolkit_h = NULL;
+ }
+
++ info->toolkit_h = screen_connector_toolkit_evas_add(&ops, info->instance_id, SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, info);
+
+ LOGW("launch a widget instance: %s", info->instance_id);
info->pid = widget_instance_launch(info->instance_id, info->content_info, w, h);
if (info->pid < 0) {
struct widget_evas_event_info event_info;
g_queue_free_full(info->pending_queue, __destroy_pending_item);
if (info->layout) {
- evas_object_event_callback_del(info->layout, EVAS_CALLBACK_DEL, del_cb);
- evas_object_event_callback_del(info->layout, EVAS_CALLBACK_RESIZE, resize_cb);
+ evas_object_event_callback_del(info->layout, EVAS_CALLBACK_DEL, __del_cb);
+ evas_object_event_callback_del(info->layout, EVAS_CALLBACK_RESIZE, __resize_cb);
- elm_object_signal_callback_del(info->layout, "clicked", "reload", __clicked_cb);
+ evas_object_event_callback_del(info->layout, EVAS_CALLBACK_MOVE, __move_cb);
+ elm_object_signal_callback_del(info->layout, "clicked", "reload", _clicked_cb);
}
if (info->widget_id)
}
evas_object_data_set(info->layout, WIDGET_INFO_TAG, info);
--
- evas_object_event_callback_add(info->layout, EVAS_CALLBACK_RESIZE, resize_cb, info);
+ evas_object_event_callback_add(info->layout, EVAS_CALLBACK_RESIZE, __resize_cb, info);
+ evas_object_event_callback_add(info->layout, EVAS_CALLBACK_MOVE, __move_cb, info);
- evas_object_event_callback_add(info->layout, EVAS_CALLBACK_DEL, del_cb, info);
+ evas_object_event_callback_add(info->layout, EVAS_CALLBACK_DEL, __del_cb, info);
- elm_object_signal_callback_add(info->layout, "clicked", "reload", __clicked_cb, info);
+ elm_object_signal_callback_add(info->layout, "clicked", "reload", _clicked_cb, info);
info->permanent_delete = 0;
info->disable_preview = 0;
ops.added_cb = __screen_connector_toolkit_evas_added_cb;
ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
- screen_connector_toolkit_evas_add(&ops, info->instance_id, SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, info);
+
+ if (info->toolkit_h) {
+ screen_connector_toolkit_evas_remove(info->toolkit_h);
+ info->toolkit_h = NULL;
+ }
+
- info->toolkit_h = screen_connector_toolkit_evas_add(&ops, info->instance_id, SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET, info);
++ info->toolkit_h = screen_connector_toolkit_evas_add(&ops, info->instance_id, SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, info);
info->is_faulted = false;
info->pid = widget_instance_launch(info->instance_id, info->content_info, w, h);
if (info->pid < 0) {
event_info.widget_app_id = info->widget_id;
event_info.event = WIDGET_EVENT_CREATED;
- smart_callback_call(info->layout, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, &event_info);
+ __smart_callback_call(info->layout, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, &event_info);
+ __display_overlay_text(info);
return;
}
return WIDGET_ERROR_NONE;
}
-
+ EAPI int widget_viewer_evas_launch_setup_app(Evas_Object *widget)
+ {
+ char *setup_appid;
+ const char *widget_id;
+ const char *instance_id;
+ const char *content_info;
+ app_control_h service;
+
+ widget_id = widget_viewer_evas_get_widget_id(widget);
+ if (!widget_id) {
+ ErrPrint("cannot get widget id from object");
+ return WIDGET_ERROR_INVALID_PARAMETER;
+ }
+
+ setup_appid = widget_service_get_app_id_of_setup_app(widget_id);
+ if (!setup_appid) {
+ ErrPrint("widget[%s] does not have setup appid", widget_id);
+ return WIDGET_ERROR_NOT_EXIST;
+ }
+
+ content_info = widget_viewer_evas_get_content_info(widget);
+ instance_id = widget_viewer_evas_get_widget_instance_id(widget);
+ app_control_create(&service);
+ app_control_set_operation(service, APP_CONTROL_OPERATION_EDIT);
+ app_control_set_app_id(service, setup_appid);
+ app_control_add_extra_data(service, APP_CONTROL_DATA_WIDGET_APP_ID, widget_id);
+ app_control_add_extra_data(service, APP_CONTROL_DATA_WIDGET_INSTANCE_ID, instance_id);
+ app_control_add_extra_data(service, APP_CONTROL_DATA_WIDGET_CONTENT, content_info);
+
+ if (app_control_send_launch_request(service, NULL, NULL) != APP_CONTROL_ERROR_NONE)
+ ErrPrint("Failed to launch setup app[%s]", setup_appid);
+
+ app_control_destroy(service);
+ free(setup_appid);
+
+ return WIDGET_ERROR_NONE;
+ }
+
/* End of a file */
DbgPrint("Size[%X]\n", info->size_types[i]);
item = (widget_size_list_item *)calloc(1, sizeof(widget_size_list_item));
+ if (item == NULL) {
+ ErrPrint("Fail to calloc");
+ continue;
+ }
++
item->info = info;
item->idx = i;
elm_item = elm_genlist_item_append(size_list, &class, (void *)item, NULL, ELM_GENLIST_ITEM_NONE, list_item_clicked_cb, (void *)item);
{
widget_info *info = (widget_info *)calloc(1, sizeof(widget_info));
+ if (info == NULL) {
+ ErrPrint("Fail to create info");
+ return;
+ }
info->widget_id = strdup(widget_id);
+ if (info->widget_id == NULL) {
+ ErrPrint("Fail to strdup widget_id");
+ free(info);
+ return;
+ }
++
info->period = WIDGET_VIEWER_EVAS_DEFAULT_PERIOD;
info->count_of_size_type = 20;
}
if (app_type != NULL && strcmp(app_type, "watchapp") == 0) {
-
+ cur_watch = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE);
+ if (widget_id != NULL) {
+ if (__watch_pkgid) {
+ free(__watch_pkgid);
+ __watch_pkgid = NULL;
+ }
+ __watch_pkgid = __get_pkgid_by_appid(widget_id);
+
+ if (cur_watch != NULL && __watch_pkgid != NULL &&
+ strcmp(cur_watch, __watch_pkgid) == 0) {
+ vconf_set_str(VCONFKEY_WMS_CLOCKS_SET_IDLE,
+ DEFAULT_WATCH);
+ }
+ }
+
evas_object_resize(s_info.win, s_info.w, s_info.h);
watch_manager_init(s_info.win);
evas_object_smart_callback_add(s_info.win, WATCH_SMART_SIGNAL_ADDED, __watch_added, NULL);