*
*/
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
+#include "shortcut_manager.h"
-#include <aul.h>
#include <app_common.h>
+#include <aul.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
#include <system_info.h>
+#include <unistd.h>
#include "log_private.h"
#include "shortcut.h"
-#include "shortcut_manager.h"
#include "shortcut_internal.h"
#include "shortcut_proxy.h"
#define EAPI __attribute__((visibility("default")))
#endif
-#define SHORTCUT_IS_WIDGET_SIZE(size) (!!((size) & WIDGET_SIZE_DEFAULT))
+#define SHORTCUT_IS_WIDGET_SIZE(size) (!!((size)&WIDGET_SIZE_DEFAULT))
#define SHORTCUT_FEATURE "http://tizen.org/feature/shortcut"
-#define CHECK_SHORTCUT_FEATURE() \
- do { \
- bool is_supported = false; \
+#define CHECK_SHORTCUT_FEATURE() \
+ do { \
+ bool is_supported = false; \
if (!system_info_get_platform_bool(SHORTCUT_FEATURE, &is_supported)) { \
- if (is_supported == false) { \
- _E("[%s] feature is disabled", SHORTCUT_FEATURE); \
- return SHORTCUT_ERROR_NOT_SUPPORTED; \
- } \
- } \
+ if (is_supported == false) { \
+ _E("[%s] feature is disabled", SHORTCUT_FEATURE); \
+ return SHORTCUT_ERROR_NOT_SUPPORTED; \
+ } \
+ } \
} while (0)
-#define CHECK_SHORTCUT_FEATURE_RET_LAST_RESULT() \
- do { \
- bool is_supported = false; \
+#define CHECK_SHORTCUT_FEATURE_RET_LAST_RESULT() \
+ do { \
+ bool is_supported = false; \
if (!system_info_get_platform_bool(SHORTCUT_FEATURE, &is_supported)) { \
- if (is_supported == false) { \
- _E("[%s] feature is disabled", SHORTCUT_FEATURE); \
- set_last_result(SHORTCUT_ERROR_NOT_SUPPORTED); \
- return; \
- } \
- } \
+ if (is_supported == false) { \
+ _E("[%s] feature is disabled", SHORTCUT_FEATURE); \
+ set_last_result(SHORTCUT_ERROR_NOT_SUPPORTED); \
+ return; \
+ } \
+ } \
} while (0)
namespace rpc = rpc_port::shortcut_proxy;
void OnConnected() override {}
/* LCOV_EXCL_START */
- void OnDisconnected() override {
- shortcut_proxy_.reset();
- }
+ void OnDisconnected() override { shortcut_proxy_.reset(); }
- void OnRejected() override {
- shortcut_proxy_.reset();
- }
+ void OnRejected() override { shortcut_proxy_.reset(); }
/* LCOV_EXCL_STOP */
} connection_listener_;
void OnReceived(rpc::Context cxt) override {
const auto& id = cxt.GetId();
- if (!request_cb_)
- return;
+ if (!request_cb_) return;
request_cb_(id.GetAppid().c_str(), id.GetName().c_str(), cxt.GetType(),
- cxt.GetUri().c_str(), cxt.GetIcon().c_str(), id.GetPid(), 0,
- cxt.GetAllowDup() ? 1 : 0, data_);
+ cxt.GetUri().c_str(), cxt.GetIcon().c_str(), id.GetPid(), 0,
+ cxt.GetAllowDup() ? 1 : 0, data_);
}
private:
void OnReceived(rpc::WidgetContext cxt) override {
const auto& id = cxt.GetId();
- if (!request_cb_)
- return;
- request_cb_(id.GetAppid().c_str(), id.GetName().c_str(), 0,
- cxt.GetUri().c_str(), cxt.GetIcon().c_str(), id.GetPid(), cxt.GetPeriod(),
- cxt.GetAllowDup() ? 1 : 0, data_);
+ if (!request_cb_) return;
+ request_cb_(id.GetAppid().c_str(), id.GetName().c_str(), cxt.GetSize(),
+ cxt.GetUri().c_str(), cxt.GetIcon().c_str(), id.GetPid(),
+ cxt.GetPeriod(), cxt.GetAllowDup() ? 1 : 0, data_);
}
private:
: remove_cb_(remove_cb), data_(data) {}
void OnReceived(rpc::Id id) override {
- if (!remove_cb_)
- return;
- remove_cb_(id.GetAppid().c_str(), id.GetName().c_str(), id.GetPid(),
- data_);
+ if (!remove_cb_) return;
+ remove_cb_(id.GetAppid().c_str(), id.GetName().c_str(), id.GetPid(), data_);
}
private:
class ResultEvent : public rpc_proxy::Shortcut::ResultCb {
public:
- ResultEvent(result_cb res_cb, void* data)
- : res_cb_(res_cb), data_(data) {}
+ ResultEvent(result_cb res_cb, void* data) : res_cb_(res_cb), data_(data) {}
void OnReceived(int ret) override {
- if (!res_cb_)
- return;
+ if (!res_cb_) return;
res_cb_(ret, data_);
}
void Connect() {
if (!shortcut_proxy_) {
- shortcut_proxy_.reset(new rpc_proxy::Shortcut(&connection_listener_,
- "d::org.tizen.appfw.service.esd"));
+ shortcut_proxy_.reset(new rpc_proxy::Shortcut(
+ &connection_listener_, "d::org.tizen.appfw.service.esd"));
shortcut_proxy_->Connect(true);
}
} // namespace
EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void* data) {
- LOGW("DEPRECATION WARNING: shortcut_set_request_cb() is deprecated and will be removed from next release");
+ LOGW(
+ "DEPRECATION WARNING: shortcut_set_request_cb() is deprecated and will "
+ "be removed from next release");
CHECK_SHORTCUT_FEATURE();
- if (request_cb == nullptr)
- return SHORTCUT_ERROR_INVALID_PARAMETER;
+ if (request_cb == nullptr) return SHORTCUT_ERROR_INVALID_PARAMETER;
try {
::Connect();
shortcut_proxy_->ListenWidgetAddedEvents(
std::unique_ptr<rpc_proxy::Shortcut::WidgetAddedCb>(
new WidgetAddedEvent(request_cb, data)));
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
}
EAPI void shortcut_unset_request_cb() {
- LOGW("DEPRECATION WARNING: shortcut_unset_request_cb() is deprecated and will be removed from next release");
+ LOGW(
+ "DEPRECATION WARNING: shortcut_unset_request_cb() is deprecated and will "
+ "be removed from next release");
CHECK_SHORTCUT_FEATURE_RET_LAST_RESULT();
try {
::Connect();
shortcut_proxy_->UnlistenAddedEvents();
shortcut_proxy_->UnlistenWidgetAddedEvents();
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
set_last_result(SHORTCUT_ERROR_IO_ERROR);
}
EAPI int shortcut_set_remove_cb(shortcut_remove_cb remove_cb, void* data) {
- LOGW("DEPRECATION WARNING: shortcut_set_remove_cb() is deprecated and will be removed from next release");
+ LOGW(
+ "DEPRECATION WARNING: shortcut_set_remove_cb() is deprecated and will be "
+ "removed from next release");
CHECK_SHORTCUT_FEATURE();
- if (remove_cb == nullptr)
- return SHORTCUT_ERROR_INVALID_PARAMETER;
+ if (remove_cb == nullptr) return SHORTCUT_ERROR_INVALID_PARAMETER;
try {
::Connect();
shortcut_proxy_->ListenRemovedEvents(
std::unique_ptr<rpc_proxy::Shortcut::RemovedCb>(
new RemovedEvent(remove_cb, data)));
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
}
EAPI void shortcut_unset_remove_cb() {
- LOGW("DEPRECATION WARNING: shortcut_unset_remove_cb() is deprecated and will be removed from next release");
+ LOGW(
+ "DEPRECATION WARNING: shortcut_unset_remove_cb() is deprecated and will "
+ "be removed from next release");
CHECK_SHORTCUT_FEATURE_RET_LAST_RESULT();
try {
::Connect();
shortcut_proxy_->UnlistenRemovedEvents();
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
set_last_result(SHORTCUT_ERROR_IO_ERROR);
}
EAPI int shortcut_add_to_home(const char* name, shortcut_type type,
- const char* uri, const char* icon, int allow_duplicate,
- result_cb cb, void* data) {
- LOGW("DEPRECATION WARNING: shortcut_add_to_home() is deprecated and will be removed from next release");
+ const char* uri, const char* icon,
+ int allow_duplicate, result_cb cb, void* data) {
+ LOGW(
+ "DEPRECATION WARNING: shortcut_add_to_home() is deprecated and will be "
+ "removed from next release");
CHECK_SHORTCUT_FEATURE();
if (ADD_TO_HOME_IS_DYNAMICBOX(type)) {
_E("Invalid type used for adding a shortcut");
try {
::Connect();
- rpc::Context cxt {
- rpc::Id {
- getpid(),
- sAppid ? sAppid : "",
- name ? name : ""
- },
- type,
- uri ? uri : "",
- icon ? icon : "", static_cast<bool>(allow_duplicate)
- };
+ rpc::Context cxt{rpc::Id{getpid(), sAppid ? sAppid : "", name ? name : ""},
+ type, uri ? uri : "", icon ? icon : "",
+ static_cast<bool>(allow_duplicate)};
shortcut_proxy_->AddAsync(std::move(cxt),
- std::unique_ptr<rpc_proxy::Shortcut::ResultCb>(new ResultEvent(cb, data)));
- } catch(...) { /* LCOV_EXCL_LINE */
+ std::unique_ptr<rpc_proxy::Shortcut::ResultCb>(
+ new ResultEvent(cb, data)));
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
}
EAPI int shortcut_add_to_home_widget(const char* name,
- shortcut_widget_size_e size, const char* widget_id, const char* icon,
- double period, int allow_duplicate, result_cb cb, void* data) {
- LOGW("DEPRECATION WARNING: shortcut_add_to_home_widget() is deprecated and will be removed from next release");
+ shortcut_widget_size_e size,
+ const char* widget_id, const char* icon,
+ double period, int allow_duplicate,
+ result_cb cb, void* data) {
+ LOGW(
+ "DEPRECATION WARNING: shortcut_add_to_home_widget() is deprecated and "
+ "will be removed from next release");
CHECK_SHORTCUT_FEATURE();
if (name == nullptr) {
try {
::Connect();
- rpc::WidgetContext cxt {
- rpc::Id {
- getpid(),
- sAppid ? sAppid : "",
- name ? name : ""
- },
- size,
- "",
- icon ? icon : "", period, static_cast<bool>(allow_duplicate)
- };
- shortcut_proxy_->AddWidgetAsync(std::move(cxt),
- std::unique_ptr<rpc_proxy::Shortcut::ResultCb>(
- new ResultEvent(cb, data)));
- } catch(...) { /* LCOV_EXCL_LINE */
+ rpc::WidgetContext cxt{
+ rpc::Id{getpid(), widget_id ? widget_id : "", name ? name : ""},
+ size,
+ "",
+ icon ? icon : "",
+ period,
+ static_cast<bool>(allow_duplicate)};
+ shortcut_proxy_->AddWidgetAsync(
+ std::move(cxt), std::unique_ptr<rpc_proxy::Shortcut::ResultCb>(
+ new ResultEvent(cb, data)));
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
}
EAPI int shortcut_remove_from_home(const char* name, result_cb cb,
- void* user_data) {
- LOGW("DEPRECATION WARNING: shortcut_remove_from_home() is deprecated and will be removed from next release");
+ void* user_data) {
+ LOGW(
+ "DEPRECATION WARNING: shortcut_remove_from_home() is deprecated and will "
+ "be removed from next release");
CHECK_SHORTCUT_FEATURE();
if (name == nullptr) {
_E("name is NULL.");
::Connect();
shortcut_proxy_->RemoveAsync(
- rpc::Id {
- getpid(),
- sAppid ? sAppid : "",
- name ? name : ""
- },
+ rpc::Id{getpid(), sAppid ? sAppid : "", name ? name : ""},
std::unique_ptr<rpc_proxy::Shortcut::ResultCb>(
new ResultEvent(cb, user_data)));
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
}
EAPI int shortcut_get_list(const char* package_name, shortcut_list_cb list_cb,
- void* data) {
+ void* data) {
int ret = SHORTCUT_ERROR_NONE;
- LOGW("DEPRECATION WARNING: shortcut_get_list() is deprecated and will be removed from next release");
+ LOGW(
+ "DEPRECATION WARNING: shortcut_get_list() is deprecated and will be "
+ "removed from next release");
CHECK_SHORTCUT_FEATURE();
- if (list_cb == nullptr)
- return SHORTCUT_ERROR_INVALID_PARAMETER;
+ if (list_cb == nullptr) return SHORTCUT_ERROR_INVALID_PARAMETER;
try {
::Connect();
- auto info = shortcut_proxy_->GetList(package_name ? package_name : "",
- ret);
+ auto info = shortcut_proxy_->GetList(package_name ? package_name : "", ret);
for (const auto& i : info) {
list_cb(i.GetAppid().c_str(), i.GetIcon().c_str(), i.GetName().c_str(),
- i.GetExtraKey().c_str(), i.GetExtraData().c_str(), data);
+ i.GetExtraKey().c_str(), i.GetExtraData().c_str(), data);
}
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
}
EAPI int shortcut_add_to_home_sync(const char* name, shortcut_type type,
- const char* uri, const char* icon, int allow_duplicate) {
- LOGW("DEPRECATION WARNING: shortcut_add_to_home_sync() is deprecated and will be removed from next release");
+ const char* uri, const char* icon,
+ int allow_duplicate) {
+ LOGW(
+ "DEPRECATION WARNING: shortcut_add_to_home_sync() is deprecated and will "
+ "be removed from next release");
CHECK_SHORTCUT_FEATURE();
if (ADD_TO_HOME_IS_DYNAMICBOX(type)) {
try {
::Connect();
- rpc::Context cxt {
- rpc::Id {
- getpid(),
- sAppid ? sAppid : "",
- name ? name : ""
- },
- type,
- uri ? uri : "",
- icon ? icon : "", static_cast<bool>(allow_duplicate)
- };
+ rpc::Context cxt{rpc::Id{getpid(), sAppid ? sAppid : "", name ? name : ""},
+ type, uri ? uri : "", icon ? icon : "",
+ static_cast<bool>(allow_duplicate)};
ret = shortcut_proxy_->Add(std::move(cxt));
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
return ret;
}
-EAPI int shortcut_add_to_home_widget_sync(const char *name,
- shortcut_widget_size_e size, const char *widget_id,
- const char *icon, double period, int allow_duplicate) {
- LOGW("DEPRECATION WARNING: shortcut_add_to_home_widget_sync() is deprecated and will be removed from next release");
+EAPI int shortcut_add_to_home_widget_sync(const char* name,
+ shortcut_widget_size_e size,
+ const char* widget_id,
+ const char* icon, double period,
+ int allow_duplicate) {
+ LOGW(
+ "DEPRECATION WARNING: shortcut_add_to_home_widget_sync() is deprecated "
+ "and will be removed from next release");
CHECK_SHORTCUT_FEATURE();
if (name == NULL) {
try {
::Connect();
- rpc::WidgetContext cxt {
- rpc::Id {
- getpid(),
- sAppid ? sAppid : "",
- name ? name : ""
- },
- size,
- "",
- icon ? icon : "", period, static_cast<bool>(allow_duplicate)
- };
+ rpc::WidgetContext cxt{
+ rpc::Id{getpid(), widget_id ? widget_id : "", name ? name : ""},
+ size,
+ "",
+ icon ? icon : "",
+ period,
+ static_cast<bool>(allow_duplicate)};
ret = shortcut_proxy_->AddWidget(std::move(cxt));
- } catch(...) { /* LCOV_EXCL_LINE */
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;
return ret;
}
-EAPI int shortcut_remove_from_home_sync(const char *name) {
- LOGW("DEPRECATION WARNING: shortcut_remove_from_home_sync() is deprecated and will be removed from next release");
+EAPI int shortcut_remove_from_home_sync(const char* name) {
+ LOGW(
+ "DEPRECATION WARNING: shortcut_remove_from_home_sync() is deprecated and "
+ "will be removed from next release");
CHECK_SHORTCUT_FEATURE();
if (name == NULL) {
::Connect();
ret = shortcut_proxy_->Remove(
- rpc::Id {
- getpid(),
- sAppid ? sAppid : "",
- name ? name : ""
- });
- } catch(...) { /* LCOV_EXCL_LINE */
+ rpc::Id{getpid(), sAppid ? sAppid : "", name ? name : ""});
+ } catch (...) { /* LCOV_EXCL_LINE */
/* LCOV_EXCL_START */
shortcut_proxy_.reset();
return SHORTCUT_ERROR_IO_ERROR;