struct watch_holder_s : public WatchHolder {
public:
- watch_holder_s(Evas_Object* win) : WatchHolder(win), cb_init_(false) {}
+ watch_holder_s(Evas_Object* win, watch_lifecycle_st cb, void* cb_data)
+ : WatchHolder(win), cb_(cb), cb_data_(cb_data) {}
void OnLaunched(const Watch& watch) override {
- if (cb_init_) {
- Watch& w = const_cast<Watch&>(watch);
- cb_.watch_holder_lifecycle_added_cb(reinterpret_cast<watch_h>(&w), cb_data_);
- }
+ Watch& w = const_cast<Watch&>(watch);
+ cb_.watch_holder_lifecycle_added_cb(reinterpret_cast<watch_h>(&w), cb_data_);
}
void OnDead(const Watch& watch) override {
- if (cb_init_) {
- Watch& w = const_cast<Watch&>(watch);
- cb_.watch_holder_lifecycle_dead_cb(reinterpret_cast<watch_h>(&w), false, cb_data_);
- }
+ Watch& w = const_cast<Watch&>(watch);
+ cb_.watch_holder_lifecycle_dead_cb(reinterpret_cast<watch_h>(&w), false, cb_data_);
}
void OnBound(const Watch& watch) override {
- if (cb_init_) {
- Watch& w = const_cast<Watch&>(watch);
- cb_.watch_holder_lifecycle_bound_cb(reinterpret_cast<watch_h>(&w), cb_data_);
- }
+ Watch& w = const_cast<Watch&>(watch);
+ cb_.watch_holder_lifecycle_bound_cb(reinterpret_cast<watch_h>(&w), cb_data_);
}
void OnAdded(const Watch& watch) override {
- if (cb_init_) {
- Watch& w = const_cast<Watch&>(watch);
- cb_.watch_holder_lifecycle_added_cb(reinterpret_cast<watch_h>(&w), cb_data_);
- }
+ Watch& w = const_cast<Watch&>(watch);
+ cb_.watch_holder_lifecycle_added_cb(reinterpret_cast<watch_h>(&w), cb_data_);
}
void OnUpdated(const Watch& watch) override {
- if (cb_init_) {
- Watch& w = const_cast<Watch&>(watch);
- cb_.watch_holder_lifecycle_updated_cb(reinterpret_cast<watch_h>(&w), watch.GetCurrentImage(), cb_data_);
- }
+ Watch& w = const_cast<Watch&>(watch);
+ cb_.watch_holder_lifecycle_updated_cb(reinterpret_cast<watch_h>(&w), watch.GetCurrentImage(), cb_data_);
}
void OnRemoved(const Watch& watch) override {
- if (cb_init_) {
- Watch& w = const_cast<Watch&>(watch);
- cb_.watch_holder_lifecycle_removed_cb(reinterpret_cast<watch_h>(&w), cb_data_);
- }
+ Watch& w = const_cast<Watch&>(watch);
+ cb_.watch_holder_lifecycle_removed_cb(reinterpret_cast<watch_h>(&w), cb_data_);
}
- bool cb_init_;
watch_lifecycle_st cb_;
void* cb_data_;
};
C_EXPORT int watch_holder_create(Evas_Object *viewer_win,
- watch_holder_h *handle) {
+ watch_lifecycle_st lifecycle, void *user_data, watch_holder_h *handle) {
+
if (viewer_win == nullptr)
return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
- struct watch_holder_s *h = new struct watch_holder_s(viewer_win);
+ struct watch_holder_s *h = new struct watch_holder_s(viewer_win, lifecycle,
+ user_data);
if (h == nullptr)
return WATCH_HOLDER_ERROR_OUT_OF_MEMORY;
return WATCH_HOLDER_ERROR_NONE;
}
-C_EXPORT int watch_holder_monitor(watch_holder_h handle, watch_lifecycle_st lifecycle, void *user_data) {
- if (handle == nullptr)
- return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
-
- handle->cb_init_ = true;
- handle->cb_ = lifecycle;
- handle->cb_data_ = user_data;
-
- return WATCH_HOLDER_ERROR_NONE;
-}
-
-C_EXPORT int watch_holder_unmonitor(watch_holder_h handle) {
-
- handle->cb_init_ = false;
- handle->cb_data_ = nullptr;
-
- return WATCH_HOLDER_ERROR_NONE;
-}
#include <app.h>
#include <unistd.h>
#include <errno.h>
+#include <watch_holder.h>
#include <widget_errno.h>
#include <widget_service.h>
#include <widget_service_internal.h>
#include <aul.h>
#include <aul_debug_info.h>
#include <appsvc.h>
-#include <watch_control.h>
#include <pkgmgr-info.h>
static char *__watch_pkgid;
static Evas_Object *__clock;
static bool __debug_info_initialized;
+static watch_holder_h __watch_holder;
static void back_key_cb(void *data, Evas_Object *obj, void *event_info)
{
}
}
-static void __watch_added(void *data, Evas_Object *obj, void *event_info)
-{
- LOGD("watch added");
- __clock = (Evas_Object *)event_info;
-
- evas_object_resize(s_info.win, s_info.w, s_info.h);
- evas_object_resize(__clock, s_info.w, s_info.h);
-
- evas_object_show(__clock);
- evas_object_show(s_info.win);
-}
-
-static void __watch_removed(void *data, Evas_Object *obj, void *event_info)
-{
- LOGD("watch removed");
-}
-
void __clock_vconf_cb(keynode_t *node, void *data)
{
char *cur_watch = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE);
{
/* WIDGET pause */
widget_viewer_evas_notify_paused_status_of_viewer();
- watch_manager_notify_paused_status_of_viewer();
+ watch_h watch;
+ int ret = watch_holder_get_current(__watch_holder, &watch);
+ if (ret == WATCH_HOLDER_ERROR_NONE) {
+ ret = watch_pause(watch);
+ if (ret != WATCH_HOLDER_ERROR_NONE) {
+ ErrPrint("watch_pause() failed: %d", ret);
+ }
+ }
}
static void __resume_process()
{
widget_viewer_evas_notify_resumed_status_of_viewer();
- watch_manager_notify_resumed_status_of_viewer();
+ watch_h watch;
+ int ret = watch_holder_get_current(__watch_holder, &watch);
+ if (ret == WATCH_HOLDER_ERROR_NONE) {
+ ret = watch_resume(watch);
+ if (ret != WATCH_HOLDER_ERROR_NONE) {
+ ErrPrint("watch_resume() failed: %d", ret);
+ }
+ }
}
static void app_resume(void *data)
bundle_get_str(app_control_b, AUL_K_SDK, &sdk_util);
if (sdk_util != NULL) {
aul_debug_info_init();
- aul_debug_info_set(app_control_b, b);
+ aul_debug_info_set(app_control_b, b); // copies all the keys and values
__debug_info_initialized = true;
DbgPrint("util %s", sdk_util);
}
return ret_pkgid;
}
+static void __watch_launched_cb(watch_h watch, void *data) {
+ DbgPrint("watch launched");
+}
+
+static void __watch_dead_cb(watch_h watch, bool is_faulted, void *data) {
+ DbgPrint("watch dead");
+}
+
+static void __watch_added_cb(watch_h watch, void *data) {
+ if (watch == NULL) {
+ ErrPrint("Wrong operation");
+ return;
+ }
+
+ const char* appid = NULL;
+ watch_get_appid(watch, &appid);
+ DbgPrint("watch added : %s", appid);
+ if (appid)
+ free(appid);
+
+ int ret = watch_get_current_image(watch, &__clock);
+ if (ret == WATCH_HOLDER_ERROR_NONE) {
+ evas_object_resize(s_info.win, s_info.w, s_info.h);
+ evas_object_resize(__clock, s_info.w, s_info.h);
+ evas_object_show(__clock);
+ evas_object_show(s_info.win);
+ } else {
+ ErrPrint("watch_get_current_image error:%d", ret);
+ }
+}
+
+static void __watch_removed_cb(watch_h watch, void *data) {
+ DbgPrint("watch removed");
+}
+
+static void __watch_updated_cb(watch_h watch, Evas_Object *image, void *data) {
+ DbgPrint("watch updated");
+}
+
+static void __watch_bound_cb(watch_h watch, void *data) {
+ DbgPrint("watch bound");
+}
+
static void _app_control(app_control_h service, void *data)
{
char *widget_id = NULL;
int ret;
char *app_type = NULL;
pkgmgrinfo_appinfo_h app_info;
- app_control_h watch_control = NULL;
bundle *b;
bundle *app_control_b;
char *lazy_loader = NULL;
bool is_array;
int array_len;
char **widget_id_arr;
- char *operation = NULL;
int i;
char *cur_watch = NULL;
}
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);
- evas_object_smart_callback_add(s_info.win, WATCH_SMART_SIGNAL_REMOVED, __watch_removed, NULL);
- watch_manager_get_app_control(widget_id, &watch_control);
+ watch_lifecycle_st lifecycle;
+ lifecycle.watch_holder_lifecycle_launched_cb = __watch_launched_cb;
+ lifecycle.watch_holder_lifecycle_dead_cb = __watch_dead_cb;
+ lifecycle.watch_holder_lifecycle_added_cb = __watch_added_cb;
+ lifecycle.watch_holder_lifecycle_removed_cb = __watch_removed_cb;
+ lifecycle.watch_holder_lifecycle_updated_cb = __watch_updated_cb;
+ lifecycle.watch_holder_lifecycle_bound_cb = __watch_bound_cb;
+
+ ret = watch_holder_create(s_info.win, lifecycle, &s_info, &__watch_holder);
+ if (ret != WATCH_HOLDER_ERROR_NONE) {
+ ErrPrint("Watch Holder Error:%d", ret);
+ return;
+ }
- app_control_get_operation(service, &operation);
- if (operation) {
- app_control_set_operation(watch_control, operation);
- free(operation);
+ b = bundle_create();
+ if (b == NULL) {
+ ErrPrint("Out of memory");
+ return;
}
- app_control_to_bundle(watch_control, &b);
app_control_to_bundle(service, &app_control_b);
-
__set_bundle_for_watchapp(app_control_b, b);
+ ret = watch_holder_launch(__watch_holder, false, widget_id, b);
+ if (ret < 0)
+ ErrPrint("Watch Holder Launch Error:%d", ret);
+ else
+ DbgPrint("Watch Holder Launch pid(%d)", ret);
- ret = aul_forward_app(widget_id, b);
- DbgPrint("aul_forward_app returns [%d]", ret);
- app_control_destroy(watch_control);
+ bundle_free(b);
} else {
ret = app_control_get_extra_data(service, LAZY_LOADER, &lazy_loader);
app_control_to_bundle(service, &b);