static int __change_visibility(int visibility);
static GDBusConnection *__gdbus_conn;
static guint __lcd_subscribe_id;
+static aul_app_com_connection_h __conn_launch_signal;
+
+static int __listen_launch_signal(void);
+static void __ignore_launch_signal(void);
static void __process_pending_status(int status, unsigned int surf)
{
API int watch_manager_init(Evas_Object *win)
{
__watch_viewer_init(win);
+ __listen_launch_signal();
return 0;
}
{
char buf[10];
bundle *b = NULL;
- screen_connector_toolkit_evas_ops ops;
if (app_id == NULL) {
_E("Invalid param");
app_control_set_operation(*app_control, APP_CONTROL_OPERATION_MAIN);
- _D("cur %s, new %s", __watch_appid, app_id);
- if (screen_connector_toolkit_is_exist((char *)__watch_appid,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH))
- screen_connector_toolkit_evas_remove(__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,
- (char *)app_id,
- SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH, NULL);
-
app_control_to_bundle(*app_control, &b);
if (b) {
if (!viewer_appid)
bundle_add_str(b, AUL_K_WIDGET_VIEWER, viewer_appid);
}
- if (__watch_appid)
- free(__watch_appid);
-
- __watch_appid = strdup(app_id);
- if (__watch_appid == NULL)
- _E("Out of memory");
-
return 0;
}
__conn_dead_signal = NULL;
}
+ __ignore_launch_signal();
+
return 0;
}
_E("wrong argument");
return -1;
}
+
+static int __launch_signal_handler(const char *endpoint,
+ aul_app_com_result_e res, bundle *envelope, void *user_data)
+{
+ 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;
+
+ 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);
+ if (exist)
+ screen_connector_toolkit_evas_remove(__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);
+
+ if (__watch_appid)
+ free(__watch_appid);
+
+ __watch_appid = strdup(appid);
+ if (__watch_appid == NULL)
+ _E("Out of memory");
+
+ return 0;
+}
+
+static int __listen_launch_signal(void)
+{
+ 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 0;
+}
+
+static void __ignore_launch_signal(void)
+{
+ if (!__conn_launch_signal)
+ return;
+
+ aul_app_com_leave(__conn_launch_signal);
+ __conn_launch_signal = NULL;
+}