INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer_surface.h DESTINATION include/${PROJECT_NAME})
-#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION include/${PROJECT_NAME}
-# FILES_MATCHING PATTERN "*.h")
-#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src DESTINATION include/${PROJECT_NAME}
-# FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
+ PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
+ PATTERN "*.hh")
\ No newline at end of file
#include <aul.h>
#include <bundle.h>
+#include <bundle_cpp.h>
#include <dlog.h>
#include <aul_app_com.h>
+#include <uuid/uuid.h>
-#include "ambient-viewer.h"
-#include "top-app-surface.h"
-#include "watch-surface.h"
+#include "ambient-viewer.hh"
+#include "top-app-surface.hh"
+#include "watch-surface.hh"
#ifdef LOG_TAG
#undef LOG_TAG
#define LOG_TAG "AMBIENT_VIEWER"
+#define NOTIFY_CHANGED_EVENT_APPID_KEY "__NOTIFY_CHANGED_EVENT_APPID_KEY__"
+#define NOTIFY_CHANGED_EVENT_RID_KEY "__NOTIFY_CHANGED_EVENT_RID_KEY__"
+
+using namespace std;
using namespace tizen_base;
namespace ambient_viewer {
-AmbientViewer::AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win)
+AmbientViewer::AmbientViewer(Evas_Object* win)
: win_(win) {
char appid_buf[512] = {0, };
if (aul_app_get_appid_bypid(
AmbientViewer::~AmbientViewer() = default;
-void AmbientViewer::Monitor() {
- char appid[512] = {0, };
- if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK)
- LOGE("Failed to get appid (%d)", getpid());
+string AmbientViewer::GetUUID(string rid) const {
+ char uuid[37];
+ uuid_t u;
- top_app_surface_ = std::make_shared<TopAppSurface>(win_, this);
- watch_surface_ = std::make_shared<WatchSurface>(appid, win_, this);
+ uuid_generate(u);
+ uuid_unparse(u, uuid);
+ return string(uuid) + rid;
+}
+
+void AmbientViewer::OnChangedSignal(keynode_t *node, void *user_data) {
+ AmbientViewer* viewer = (AmbientViewer*)user_data;
+ const char* raw = vconf_get_str(VCONFKEY_WATCH_CURRENT_WATCH_INFO);
+ if (raw == nullptr || strlen(raw) == 0)
+ return;
+ try {
+ Bundle data(raw);
+ string appid = data.GetString(NOTIFY_CHANGED_EVENT_APPID_KEY);
+ string rid = data.GetString(NOTIFY_CHANGED_EVENT_RID_KEY);
+ viewer->watch_surface_ = make_shared<WatchSurface>(
+ stoi(rid), viewer->GetUUID(rid), appid, viewer->win_, viewer);
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
+ return;
+ }
+}
+
+void AmbientViewer::Monitor() {
+ top_app_surface_ = std::make_shared<TopAppSurface>(
+ make_shared<screen_connector::EvasObject>(win_, false), this);
+ if (vconf_notify_key_changed(
+ VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) {
+ LOGE("failed to listen on changed signal");
+ return;
+ }
+ OnChangedSignal(nullptr, this);
}
void AmbientViewer::Unmonitor() {
watch_surface_.reset();
}
+void AmbientViewer::OnReceived(AmbientViewer::EventType ev, std::string sender,
+ Bundle extra) {
+}
+
int AmbientViewer::NotifyAmbientEvent(bool enter, AmbientViewer::Direction dir,
Bundle extra) {
bundle* b;
#ifndef __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
#define __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
-#include <aul.h>
#include <aul_app_com.h>
#include <bundle.h>
#include <bundle_cpp.h>
+#include <vconf.h>
#include <string>
#include <memory>
-#include "iambient-viewer.h"
-#include "isurface.h"
+#include "iambient-viewer.hh"
+#include "isurface.hh"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
};
public:
- AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win);
-
+ AmbientViewer(Evas_Object* win);
virtual ~AmbientViewer();
- virtual void OnReceived(EventType ev, std::string sender, tizen_base::Bundle extra) = 0;
-
void Monitor();
void Unmonitor();
+ virtual void OnReceived(EventType ev, std::string sender, tizen_base::Bundle extra) = 0;
int NotifyAmbientEvent(bool enter, Direction dir, tizen_base::Bundle extra);
const ISurface& GetWatchSurface() const;
const ISurface& GetTopAppSurface() const;
private:
+ std::string GetUUID(std::string rid) const;
+ static void OnChangedSignal(keynode_t *node, void *user_data);
static int OnReceiveSignal(const char *endpoint, aul_app_com_result_e e,
bundle *envelope, void *user_data);
-
- std::shared_ptr<screen_connector::EvasObject> win_;
+ Evas_Object* win_;
std::shared_ptr<ISurface> watch_surface_;
std::shared_ptr<ISurface> top_app_surface_;
- aul_app_com_connection_h receive_signal_conn_;
+ aul_app_com_connection_h receive_signal_conn_ = nullptr;
};
} // namespace ambient_viewer
#include <string>
-#include "isurface.h"
+#include "isurface.hh"
namespace ambient_viewer {
#include <system_info.h>
-#include "internal.h"
+#include "internal.hh"
#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
namespace ambient_viewer::internal {
-float _GetOpr(void* source_data, int width, int height) {
+float GetOpr(void* source_data, int width, int height) {
int *source;
int x;
int y;
namespace ambient_viewer::internal {
- float _GetOpr(void* source_data, int width, int height);
+ float GetOpr(void* source_data, int width, int height);
} // namespace ambient_viewer::internal
#define EXPORT_API __attribute__((visibility("default")))
#endif
-#include <evas_object.h>
+#include <Elementary.h>
#include <string>
class EXPORT_API ISurface {
public:
virtual ~ISurface() = default;
- virtual screen_connector::EvasObject& GetCurrentImage() const = 0;
+ virtual Evas_Object* GetCurrentImage() const = 0;
virtual bool IsWatch() const = 0;
virtual std::string GetAppId() const = 0;
virtual std::string GetInstId() const = 0;
*/
#include <dlog.h>
-#include <remote_surface_watcher.h>
+#include <bundle_cpp.h>
#include "ambient_viewer.h"
#include "ambient_viewer_surface.h"
#include "ambient_viewer_common.h"
-#include "ambient-viewer.h"
-#include "isurface.h"
+#include "ambient-viewer.hh"
+#include "isurface.hh"
using namespace std;
using namespace tizen_base;
using namespace ambient_viewer;
-using namespace screen_connector;
class MonitorCallbackInfo {
public:
class AmbientViewerStub : public AmbientViewer {
public:
- AmbientViewerStub(std::shared_ptr<EvasObject> win)
+ AmbientViewerStub(Evas_Object* win)
: AmbientViewer(win) {
}
return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
}
- AmbientViewerStub* h = new (nothrow) AmbientViewerStub(
- shared_ptr<EvasObject>(new EvasObject(win, false)));
+ AmbientViewerStub* h = new (nothrow) AmbientViewerStub(win);
if (h == nullptr) {
LOGE("out of memory");
return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
}
const ISurface* surface = static_cast<const ISurface*>(handle);
- *image = surface->GetCurrentImage().GetRaw();
+ *image = surface->GetCurrentImage();
return AMBIENT_VIEWER_ERROR_NONE;
}
* limitations under the License.
*/
+#include <dlog.h>
-#include "top-app-surface.h"
-#include "internal.h"
+#include "top-app-surface.hh"
+#include "internal.hh"
-using namespace ambient_viewer::internal;
-using namespace screen_connector;
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "AMBIENT_VIEWER"
namespace ambient_viewer {
TopAppSurface::TopAppSurface(
- std::shared_ptr<EvasObject> surface, IAmbientViewer* listener)
- : RemoteSurfaceWatcher(RemoteSurface::UI, surface), listener_(listener) {
+ std::shared_ptr<screen_connector::EvasObject> surface, IAmbientViewer* listener)
+ : screen_connector::RemoteSurfaceWatcher(
+ screen_connector::RemoteSurface::UI, surface), listener_(listener) {
}
TopAppSurface::~TopAppSurface() = default;
-EvasObject& TopAppSurface::GetCurrentImage() const {
- return *image_;
+Evas_Object* TopAppSurface::GetCurrentImage() const {
+ return image_;
}
bool TopAppSurface::IsWatch() const {
if (image_ == nullptr)
return 0;
- evas_object_geometry_get(image_->GetRaw(), nullptr, nullptr, &width, &height);
+ evas_object_geometry_get(image_, nullptr, nullptr, &width, &height);
- ns = evas_object_image_native_surface_get(image_->GetRaw());
+ ns = evas_object_image_native_surface_get(image_);
if (ns == nullptr) {
return 0;
}
return 0;
}
- opr = _GetOpr(source_data, width, height);
+ opr = ambient_viewer::internal::GetOpr(source_data, width, height);
tbm_surface_unmap(surface);
const std::string& instId, const int pid) {
app_id_ = appId;
inst_id_ = instId;
-
- listener_->OnAdded(*this);
}
void TopAppSurface::OnWatcherChanged(const std::string& appId,
const std::string& instId, const int pid,
- const EvasObject& image) {
- *image_ = image;
- listener_->OnUpdated(*this);
+ const screen_connector::EvasObject& image) {
+ bool added = (image_ == nullptr);
+ image_ = image.GetRaw();
+ if (added)
+ listener_->OnAdded(*this);
+ else
+ listener_->OnUpdated(*this);
}
void TopAppSurface::OnWatcherRemoved(const std::string& appId,
#include <string>
#include <memory>
-#include "iambient-viewer.h"
-#include "isurface.h"
-#include "ambient-viewer.h"
+#include "iambient-viewer.hh"
+#include "isurface.hh"
+#include "ambient-viewer.hh"
namespace ambient_viewer {
class TopAppSurface : public screen_connector::RemoteSurfaceWatcher,
public ISurface {
public:
- screen_connector::EvasObject& GetCurrentImage() const override;
+ Evas_Object* GetCurrentImage() const override;
bool IsWatch() const override;
std::string GetAppId() const override;
std::string GetInstId() const override;
const int pid) override;
private:
- std::shared_ptr<screen_connector::EvasObject> image_;
+ Evas_Object* image_ = nullptr;
std::string app_id_;
std::string inst_id_;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <dlog.h>
-#include "watch-surface.h"
-#include "internal.h"
+#include "watch-surface.hh"
+#include "internal.hh"
-using namespace std;
-using namespace ambient_viewer::internal;
-using namespace screen_connector;
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "AMBIENT_VIEWER"
namespace ambient_viewer {
-WatchSurface::WatchSurface(string appid,
- shared_ptr<EvasObject> surface, IAmbientViewer* listener)
- : RemoteSurfaceEvas(appid, RemoteSurface::WATCH, surface),
- listener_(listener) {
+WatchSurface::WatchSurface(
+ int rid, std::string id, std::string appid,
+ Evas_Object* viewer_win, IAmbientViewer* listener)
+ : RemoteSurfaceEvas(rid, id, RemoteSurface::WATCH,
+ std::make_shared<screen_connector::EvasObject>(viewer_win, false)),
+ appid_(appid), listener_(listener) {
+ LOGI("WatchSurface created (%s)", appid.c_str());
}
WatchSurface::~WatchSurface() = default;
-EvasObject& WatchSurface::GetCurrentImage() const {
- return *image_;
+Evas_Object* WatchSurface::GetCurrentImage() const {
+ return image_;
}
bool WatchSurface::IsWatch() const {
}
std::string WatchSurface::GetAppId() const {
- return app_id_;
+ return appid_;
}
std::string WatchSurface::GetInstId() const {
if (image_ == nullptr)
return 0;
- evas_object_geometry_get(image_->GetRaw(), nullptr, nullptr, &width, &height);
+ evas_object_geometry_get(image_, nullptr, nullptr, &width, &height);
- ns = evas_object_image_native_surface_get(image_->GetRaw());
+ ns = evas_object_image_native_surface_get(image_);
if (ns == nullptr) {
return 0;
}
return 0;
}
- opr = _GetOpr(source_data, width, height);
-
+ opr = ambient_viewer::internal::GetOpr(source_data, width, height);
tbm_surface_unmap(surface);
return opr;
void WatchSurface::OnEvasAdded(const std::string& appId,
const std::string& instId, int pid,
- const EvasObject& image) {
- app_id_ = appId;
+ const screen_connector::EvasObject& image) {
inst_id_ = instId;
- *image_ = image;
+ image_ = image.GetRaw();
listener_->OnAdded(*this);
}
void WatchSurface::OnEvasRemoved(const std::string& appId,
const std::string& instId, int pid,
- const EvasObject& image) {
+ const screen_connector::EvasObject& image) {
image_ = nullptr;
listener_->OnRemoved(*this);
}
void WatchSurface::OnEvasChanged(const std::string& appId,
const std::string& instId, int pid,
- const EvasObject& image) {
- *image_ = image;
+ const screen_connector::EvasObject& image) {
+ image_ = image.GetRaw();
listener_->OnUpdated(*this);
}
#include <string>
#include <memory>
-#include "iambient-viewer.h"
-#include "isurface.h"
-#include "ambient-viewer.h"
+#include "iambient-viewer.hh"
+#include "isurface.hh"
+#include "ambient-viewer.hh"
namespace ambient_viewer {
class WatchSurface : public screen_connector::RemoteSurfaceEvas, public ISurface {
public:
- screen_connector::EvasObject& GetCurrentImage() const override;
+ Evas_Object* GetCurrentImage() const override;
bool IsWatch() const override;
std::string GetAppId() const override;
std::string GetInstId() const override;
float GetOpr() const override;
-
- WatchSurface(std::string appid,
- std::shared_ptr<screen_connector::EvasObject> surface,
- IAmbientViewer* listener);
+ WatchSurface(int rid, std::string id, std::string appid,
+ Evas_Object* viewer_win, IAmbientViewer* listener);
virtual ~WatchSurface();
private:
int pid, const screen_connector::EvasObject& image) override;
private:
- std::shared_ptr<screen_connector::EvasObject> image_;
- std::string app_id_;
+ Evas_Object* image_ = nullptr;
+ std::string appid_;
std::string inst_id_;
IAmbientViewer* listener_;
%files -n ambient-viewer-devel
%{_includedir}/ambient-viewer/*.h
+%{_includedir}/ambient-viewer/*.hh
%{_libdir}/pkgconfig/ambient-viewer.pc
%{_libdir}/libambient-viewer.so
# End of a file
#include <gtest/gtest.h>
#include <gmock/gmock.h>
-#include <ambient-viewer.h>
+#include <ambient-viewer.hh>
using namespace std;
using namespace ambient_viewer;
-using namespace screen_connector;
using namespace tizen_base;
class AmbientViewerStub : public AmbientViewer {
public:
- AmbientViewerStub(std::shared_ptr<EvasObject> win)
+ AmbientViewerStub(Evas_Object* win)
: AmbientViewer(win) {
}
void OnAdded(const ISurface& surface) override {}
virtual void SetUp() {
Evas_Object* win = elm_win_add(NULL, "Widget Viewer", ELM_WIN_BASIC);
- stub = new AmbientViewerStub(shared_ptr<EvasObject>(new EvasObject(win, false)));
+ stub = new AmbientViewerStub(win);
}
virtual void TearDown() {
delete stub;
std::string appid_;
Evas_Object* win_;
std::list<std::shared_ptr<Watch>> stack_;
- aul_app_com_connection_h launch_signal_conn_;
- aul_app_com_connection_h dead_signal_conn_;
- aul_app_com_connection_h ambient_changed_signal_conn_;
+ aul_app_com_connection_h launch_signal_conn_ = nullptr;
+ aul_app_com_connection_h dead_signal_conn_ = nullptr;
+ aul_app_com_connection_h ambient_changed_signal_conn_ = nullptr;
};
} // namespace watch_holder
private:
std::string appid_;
Evas_Object* win_;
+ aul_app_com_connection_h watch_changed_conn_ = nullptr;
std::list<std::shared_ptr<Watch>> stack_;
};