--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "../src/watch.hh"
+
+#include "watch.h"
+#include "sharable_watch.h"
+
+#ifndef C_EXPORT
+#define C_EXPORT extern "C" __attribute__((visibility("default")))
+#endif
+
+using namespace watch_holder;
+
+struct sharable_watch_s : public Watch {};
+
+C_EXPORT int sharable_watch_resume(sharable_watch_h watch) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_resume(w);
+}
+
+C_EXPORT int sharable_watch_pause(sharable_watch_h watch) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_pause(w);
+}
+
+C_EXPORT int sharable_watch_get_appid(sharable_watch_h watch, char **appid) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_get_appid(w, appid);
+}
+
+C_EXPORT int sharable_watch_get_pid(sharable_watch_h watch, int *pid) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_get_pid(w, pid);
+}
+
+C_EXPORT int sharable_watch_get_extra(sharable_watch_h watch, bundle **extra) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_get_extra(w, extra);
+}
+
+C_EXPORT int sharable_watch_get_current_image(sharable_watch_h watch, Evas_Object **image) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_get_current_image(w, image);
+}
+
+C_EXPORT int sharable_watch_is_bound(sharable_watch_h watch, bool *bound) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_is_bound(w, bound);
+}
+
+C_EXPORT int sharable_watch_is_faulted(sharable_watch_h watch, bool *faulted) {
+ watch_h w = reinterpret_cast<watch_h>(watch);
+ return watch_is_faulted(w, faulted);
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+#ifndef __SHARABLE_WATCH_H__
+#define __SHARABLE_WATCH_H__
+
+#include <Evas.h>
+#include <bundle.h>
+
+#include "watch_holder_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct sharable_watch_s *sharable_watch_h;
+
+int sharable_watch_resume(sharable_watch_h watch);
+
+int sharable_watch_pause(sharable_watch_h watch);
+
+int sharable_watch_get_appid(sharable_watch_h watch, char **appid);
+
+int sharable_watch_get_pid(sharable_watch_h watch, int *pid);
+
+int sharable_watch_get_extra(sharable_watch_h watch, bundle **extra);
+
+int sharable_watch_get_current_image(sharable_watch_h watch, Evas_Object **image);
+
+int sharable_watch_is_bound(sharable_watch_h watch, bool *bound);
+
+int sharable_watch_is_faulted(sharable_watch_h watch, bool *faulted);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
return WATCH_HOLDER_ERROR_NONE;
}
-C_EXPORT int watch_get_appid(watch_h watch, const char **appid) {
+C_EXPORT int watch_get_appid(watch_h watch, char **appid) {
Watch* w = reinterpret_cast<Watch*>(watch);
char* id = strdup(w->GetAppId().c_str());
if (id == nullptr)
return WATCH_HOLDER_ERROR_NONE;
}
+
+C_EXPORT int watch_notify_changed_event(watch_h watch) {
+ Watch* w = reinterpret_cast<Watch*>(watch);
+ if (w == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ if (w->NotifyChangedEvent() < 0) {
+ return WATCH_HOLDER_ERROR_IO_ERROR;
+ }
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_get_rid(watch_h watch, int *rid) {
+ Watch* w = reinterpret_cast<Watch*>(watch);
+ if (w == nullptr || rid == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ *rid = w->GetRid();
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_is_faulted(watch_h watch, bool *faulted) {
+ Watch* w = reinterpret_cast<Watch*>(watch);
+ if (w == nullptr || faulted == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ *faulted = w->IsFaulted();
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_is_bound(watch_h watch, bool *bound) {
+ Watch* w = reinterpret_cast<Watch*>(watch);
+ if (w == nullptr || bound == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ *bound = w->IsBound();
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_cancel_touch(watch_h watch) {
+ Watch* w = reinterpret_cast<Watch*>(watch);
+ if (w == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ w->CancelTouch();
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_get_extra(watch_h watch, bundle **extra) {
+ Watch* w = reinterpret_cast<Watch*>(watch);
+ if (w == nullptr || extra == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ *extra = w->GetExtra().GetHandle(); // should copy? or reference?
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
#include "watch_holder_error.h"
#include <Evas.h>
+#include <bundle.h>
#ifdef __cplusplus
extern "C" {
int watch_unbind(watch_h watch);
-int watch_get_appid(watch_h watch, const char **appid);
+int watch_notify_changed_event(watch_h watch);
+
+int watch_get_appid(watch_h watch, char **appid);
int watch_get_pid(watch_h watch, int *pid);
+int watch_get_rid(watch_h watch, int *rid);
+
int watch_get_opr(watch_h watch, float *opr);
int watch_get_current_image(watch_h watch, Evas_Object **image);
+int watch_get_extra(watch_h watch, bundle **extra);
+
+int watch_is_faulted(watch_h watch, bool *faulted);
+
+int watch_is_bound(watch_h watch, bool *bound);
+
+int watch_cancel_touch(watch_h watch);
+
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <cstring>
+#include <list>
+
+#include "watch_mirror.h"
+#include "../src/watch_mirror.hh"
+
+#ifndef C_EXPORT
+#define C_EXPORT extern "C" __attribute__((visibility("default")))
+#endif
+
+using namespace watch_holder;
+
+struct watch_mirror_s : public WatchMirror {
+ public:
+ watch_mirror_s(Evas_Object* win, watch_mirror_lifecycle_st cb, void* cb_data)
+ : WatchMirror(win), cb_(cb), cb_data_(cb_data) {}
+ void OnAdded(const ISharableWatch& watch) override {
+ ISharableWatch& w = const_cast<ISharableWatch&>(watch);
+ cb_.watch_mirror_lifecycle_added_cb(reinterpret_cast<sharable_watch_h>(&w), cb_data_);
+ }
+
+ void OnUpdated(const ISharableWatch& watch) override {
+ ISharableWatch& w = const_cast<ISharableWatch&>(watch);
+ cb_.watch_mirror_lifecycle_updated_cb(reinterpret_cast<sharable_watch_h>(&w), watch.GetCurrentImage(), cb_data_);
+ }
+
+ void OnRemoved(const ISharableWatch& watch) override {
+ ISharableWatch& w = const_cast<ISharableWatch&>(watch);
+ cb_.watch_mirror_lifecycle_removed_cb(reinterpret_cast<sharable_watch_h>(&w), cb_data_);
+ }
+
+ void OnChanged(const ISharableWatch& watch) override {
+ ISharableWatch& w = const_cast<ISharableWatch&>(watch);
+ cb_.watch_mirror_lifecycle_removed_cb(reinterpret_cast<sharable_watch_h>(&w), cb_data_);
+ }
+
+ watch_mirror_lifecycle_st cb_;
+ void* cb_data_;
+};
+
+C_EXPORT int watch_mirror_create(Evas_Object *viewer_win,
+ watch_mirror_lifecycle_st lifecycle, void *user_data, watch_mirror_h *handle) {
+
+ if (viewer_win == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ struct watch_mirror_s *h = new (std::nothrow) struct watch_mirror_s(
+ viewer_win, lifecycle, user_data);
+
+ if (h == nullptr)
+ return WATCH_HOLDER_ERROR_OUT_OF_MEMORY;
+
+ *handle = h;
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_mirror_destroy(watch_mirror_h handle) {
+ if (handle == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ delete handle;
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_mirror_listen(watch_mirror_h handle) {
+ if (handle == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ if (handle->Listen() < 0)
+ return WATCH_HOLDER_ERROR_INVALID_OPERATION;
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
+C_EXPORT int watch_mirror_get_current(watch_mirror_h handle, sharable_watch_h *watch) {
+ if (handle == nullptr)
+ return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
+
+ *watch = reinterpret_cast<sharable_watch_h>(handle->GetCurrent().get());
+
+ return WATCH_HOLDER_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+#ifndef __WATCH_HOLDER_H__
+#define __WATCH_HOLDER_H__
+
+#include <Evas.h>
+#include <bundle.h>
+
+#include "sharable_watch.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct watch_mirror_s *watch_mirror_h;
+
+typedef struct {
+ void (*watch_mirror_lifecycle_added_cb)(sharable_watch_h watch, void *data);
+ void (*watch_mirror_lifecycle_removed_cb)(sharable_watch_h watch, void *data);
+ void (*watch_mirror_lifecycle_updated_cb)(sharable_watch_h watch, Evas_Object *image, void *data);
+ void (*watch_mirror_lifecycle_changed_cb)(sharable_watch_h watch, void *data);
+ void (*watch_mirror_lifecycle_ambient_changed_cb)(bool enter, bundle *extra, void *data);
+} watch_mirror_lifecycle_st;
+
+/**
+ * @brief
+ * @details
+ * @since_tizen 5.5
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int watch_mirror_create(Evas_Object *viewer_win, watch_mirror_lifecycle_st lifecycle, void *user_data, watch_mirror_h *handle);
+
+int watch_mirror_destroy(watch_mirror_h handle);
+
+int watch_mirror_listen(watch_mirror_h handle);
+
+int watch_mirror_get_current(watch_mirror_h handle, sharable_watch_h *watch);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
using namespace std;
namespace watch_holder {
+WatchMirror::~WatchMirror() = default;
WatchMirror::WatchMirror(Evas_Object* win) : win_(win) {
}
class EXPORT_API WatchMirror : public Watch::IEvent {
public:
WatchMirror(Evas_Object* win);
+ virtual ~WatchMirror() = 0;
int Listen();
std::shared_ptr<ISharableWatch> GetCurrent() const;
virtual void OnChanged(const ISharableWatch& watch);
private:
std::string appid_;
Evas_Object* win_;
- aul_app_com_connection_h watch_changed_conn_;
std::list<std::shared_ptr<Watch>> stack_;
};
return;
}
- const char* appid = NULL;
+ char* appid = NULL;
watch_get_appid(watch, &appid);
DbgPrint("watch added : %s", appid);
if (appid)