using namespace common;
NotificationInstance::NotificationInstance() {
+ LoggerD("Enter");
using std::placeholders::_1;
using std::placeholders::_2;
#define REGISTER_SYNC(c, x) \
}
NotificationInstance::~NotificationInstance() {
+ LoggerD("Enter");
}
#define CHECK_EXIST(args, name, out) \
void NotificationInstance::NotificationManagerPost(const picojson::value& args,
picojson::object& out) {
+ LoggerD("Enter");
picojson::value val{picojson::object{}};
PlatformResult status =
manager_->Post(args.get<picojson::object>(), val.get<picojson::object>());
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(val, out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerUpdate(
const picojson::value& args,
picojson::object& out) {
+ LoggerD("Enter");
PlatformResult status = manager_->Update(args.get<picojson::object>());
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerRemove(
const picojson::value& args,
picojson::object& out) {
+ LoggerD("Enter");
PlatformResult status = manager_->Remove(args.get<picojson::object>());
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerRemoveAll(
const picojson::value& args,
picojson::object& out) {
+ LoggerD("Enter");
PlatformResult status = manager_->RemoveAll();
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerGet(const picojson::value& args,
picojson::object& out) {
+ LoggerD("Enter");
picojson::value val{picojson::object{}};
PlatformResult status =
manager_->Get(args.get<picojson::object>(), val.get<picojson::object>());
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(val, out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerGetAll(
const picojson::value& args,
picojson::object& out) {
+ LoggerD("Enter");
picojson::value val{picojson::array{}};
PlatformResult status = manager_->GetAll(val.get<picojson::array>());
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(val, out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerPlayLEDCustomEffect(
const picojson::value& args, picojson::object& out) {
+ LoggerD("Enter");
+
PlatformResult status = manager_->PlayLEDCustomEffect(args.get<picojson::object>());
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
void NotificationInstance::NotificationManagerStopLEDCustomEffect(
const picojson::value& /*args*/, picojson::object& out) {
+ LoggerD("Enter");
+
PlatformResult status = manager_->StopLEDCustomEffect();
- if (status.IsSuccess())
+ if (status.IsSuccess()) {
ReportSuccess(out);
- else
+ } else {
+ LoggerE("Failed");
ReportError(status, &out);
+ }
}
#undef CHECK_EXIST
using namespace common;
NotificationManager::NotificationManager() {
+ LoggerD("Enter");
}
NotificationManager::~NotificationManager() {
+ LoggerD("Enter");
}
NotificationManager* NotificationManager::GetInstance() {
+ LoggerD("Enter");
static NotificationManager instance;
return &instance;
}
PlatformResult NotificationManager::Post(const picojson::object& args,
picojson::object& out) {
+ LoggerD("Enter");
return StatusNotification::FromJson(args, false, &out);
}
PlatformResult NotificationManager::Update(const picojson::object& args) {
+ LoggerD("Enter");
return StatusNotification::FromJson(args, true, NULL);
}
PlatformResult NotificationManager::Remove(const picojson::object& args) {
+ LoggerD("Enter");
int id = std::stoi(FromJson<std::string>(args, "id"));
int ret = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NONE, id);
}
PlatformResult NotificationManager::RemoveAll() {
+ LoggerD("Enter");
int ret = notification_delete_all(NOTIFICATION_TYPE_NOTI);
if (ret != NOTIFICATION_ERROR_NONE) {
LoggerE("Notification remove all failed: %d", ret);
PlatformResult NotificationManager::Get(const picojson::object& args,
picojson::object& out) {
+ LoggerD("Enter");
int id = std::stoi(FromJson<std::string>(args, "id"));
notification_h noti_handle;
PlatformResult status = StatusNotification::GetNotiHandle(id, ¬i_handle);
if (status.IsError())
+ {
+ LoggerE("Failed: GetNotiHandle");
return status;
-
+ }
app_control_h app_control;
status = StatusNotification::GetAppControl(noti_handle, &app_control);
if (status.IsError())
+ {
+ LoggerE("Failed: GetAppControl");
return status;
-
+ }
status = StatusNotification::ToJson(id, noti_handle, app_control, &out);
if (status.IsError())
+ {
+ LoggerE("Failed: ToJson");
return status;
-
+ }
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult NotificationManager::GetAll(picojson::array& out) {
+ LoggerD("Enter");
notification_h noti = nullptr;
notification_list_h noti_list = nullptr;
notification_list_h noti_list_iter = nullptr;
PlatformResult NotificationManager::PlayLEDCustomEffect(
const picojson::object& args) {
- LOGGER(DEBUG) << "entered";
+ LoggerD("Enter");
int timeOn = FromJson<double>(args, "timeOn");
int timeOff = FromJson<double>(args, "timeOff");
}
PlatformResult NotificationManager::StopLEDCustomEffect() {
- LOGGER(DEBUG) << "entered";
+ LoggerD("Enter");
int ret = DEVICE_ERROR_NONE;
ret = device_led_stop_custom();
}
bool StatusNotification::IsColorFormatNumberic(const std::string& color) {
+ LoggerD("Enter");
std::string hexCode = "0123456789abcdef";
if (color.length() != 7 || !color.compare(0, 1, "#")) {
return false;
PlatformResult StatusNotification::SetLayout(notification_h noti_handle,
const std::string& noti_type) {
+
+ LoggerD("Enter");
notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
if (noti_type == "SIMPLE") {
PlatformResult status =
GetNumber(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &number);
if (status.IsError())
+ {
+ LoggerE("Failed: GetNumber");
return status;
-
+ }
if (number > 0)
noti_layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
else
static bool ServiceExtraDataCb(app_control_h service,
const char* key,
void* user_data) {
+ LoggerD("Enter");
if (user_data != NULL && key != NULL) {
LoggerE("User data or key not exist");
return true;
PlatformResult StatusNotification::Create(notification_type_e noti_type,
notification_h* noti_handle) {
+ LoggerD("Enter");
*noti_handle = notification_create(noti_type);
if (!noti_handle) {
LoggerE("Cannot make new notification object");
notification_type_e noti_type,
notification_ly_type_e noti_layout,
std::string* type) {
+ LoggerD("Enter");
if (noti_type == NOTIFICATION_TYPE_NOTI) {
if (noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE) {
PlatformResult StatusNotification::StatusTypeToPlatform(
const std::string& type,
notification_type_e* noti_type) {
+ LoggerD("Enter");
if (type == "SIMPLE" || type == "THUMBNAIL") {
*noti_type = NOTIFICATION_TYPE_NOTI;
} else if (type == "ONGOING" || type == "PROGRESS") {
notification_h noti_handle,
notification_image_type_e image_type,
std::string* image_path) {
+ LoggerD("Enter");
char* path = NULL;
*image_path = "";
notification_h noti_handle,
notification_image_type_e image_type,
const std::string& image_path) {
+ LoggerD("Enter");
int ret = notification_set_image(noti_handle, image_type, image_path.c_str());
if (ret != NOTIFICATION_ERROR_NONE) {
LoggerE("Set notification image error, image_type: %d, error: %d",
PlatformResult StatusNotification::GetText(notification_h noti_handle,
notification_text_type_e text_type,
std::string* noti_text) {
+ LoggerD("Enter");
char* text = NULL;
*noti_text = "";
PlatformResult StatusNotification::SetText(notification_h noti_handle,
notification_text_type_e text_type,
const std::string& noti_text) {
+ LoggerD("Enter");
int ret = notification_set_text(noti_handle,
text_type,
noti_text.c_str(),
PlatformResult StatusNotification::GetNumber(notification_h noti_handle,
notification_text_type_e text_type,
long* number) {
+ LoggerD("Enter");
std::string text;
PlatformResult status = GetText(noti_handle, text_type, &text);
if (status.IsError())
PlatformResult StatusNotification::GetDetailInfos(notification_h noti_handle,
picojson::array* out) {
+ LoggerD("Enter");
if (info_map_.size() != info_sub_map_.size()) {
LoggerE("Different notification information types element size");
return PlatformResult(
PlatformResult StatusNotification::SetDetailInfos(
notification_h noti_handle,
const picojson::array& value) {
+ LoggerD("Enter");
int idx = 0;
for (auto& item : value) {
PlatformResult StatusNotification::GetLedColor(notification_h noti_handle,
std::string* led_color) {
+ LoggerD("Enter");
unsigned int color = 0;
notification_led_op_e type = NOTIFICATION_LED_OP_ON;
PlatformResult StatusNotification::SetLedColor(notification_h noti_handle,
const std::string& led_color) {
+ LoggerD("Enter");
std::string color_str = led_color;
std::transform(
color_str.begin(), color_str.end(), color_str.begin(), ::tolower);
PlatformResult StatusNotification::GetLedPeriod(notification_h noti_handle,
unsigned long* on_period,
unsigned long* off_period) {
+ LoggerD("Enter");
int on_time = 0;
int off_time = 0;
PlatformResult StatusNotification::SetLedOnPeriod(notification_h noti_handle,
unsigned long on_period) {
+ LoggerD("Enter");
unsigned long off_period = 0;
PlatformResult status = GetLedPeriod(noti_handle, nullptr, &off_period);
if (status.IsError())
PlatformResult StatusNotification::SetLedOffPeriod(notification_h noti_handle,
unsigned long off_period) {
+ LoggerD("Enter");
unsigned long on_period = 0;
PlatformResult status = GetLedPeriod(noti_handle, &on_period, nullptr);
if (status.IsError())
PlatformResult StatusNotification::GetThumbnails(notification_h noti_handle,
picojson::array* out) {
+ LoggerD("Enter");
std::string text;
for (int idx = 0; idx < thumbnails_map_.size(); ++idx) {
PlatformResult status =
PlatformResult StatusNotification::SetThumbnails(notification_h noti_handle,
const picojson::array& value) {
+ LoggerD("Enter");
int idx = 0;
for (auto& item : value) {
PlatformResult StatusNotification::GetSoundPath(notification_h noti_handle,
std::string* sound_path) {
+ LoggerD("Enter");
*sound_path = "";
const char* path = NULL;
PlatformResult StatusNotification::SetSoundPath(notification_h noti_handle,
const std::string& sound_path) {
+ LoggerD("Enter");
int ret = notification_set_sound(
noti_handle, NOTIFICATION_SOUND_TYPE_USER_DATA, sound_path.c_str());
if (ret != NOTIFICATION_ERROR_NONE) {
PlatformResult StatusNotification::GetVibration(notification_h noti_handle,
bool* vibration) {
+ LoggerD("Enter");
notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
if (notification_get_vibration(noti_handle, &vib_type, NULL) !=
PlatformResult StatusNotification::SetVibration(notification_h noti_handle,
bool vibration) {
+ LoggerD("Enter");
bool platform_vibration;
PlatformResult status = GetVibration(noti_handle, &platform_vibration);
if (status.IsError())
PlatformResult StatusNotification::GetApplicationControl(
app_control_h app_handle,
picojson::object* out_ptr) {
+ LoggerD("Enter");
picojson::object& out = *out_ptr;
char* operation = NULL;
PlatformResult StatusNotification::SetApplicationControl(
app_control_h app_handle,
const picojson::object& app_ctrl) {
+ LoggerD("Enter");
picojson::value val(app_ctrl);
const std::string& operation =
common::FromJson<std::string>(app_ctrl, "operation");
PlatformResult StatusNotification::GetApplicationId(app_control_h app_handle,
std::string* app_id) {
+ LoggerD("Enter");
char* app_id_str = NULL;
SCOPE_EXIT { free(app_id_str); };
PlatformResult StatusNotification::SetApplicationId(app_control_h app_handle,
const std::string& app_id) {
+ LoggerD("Enter");
int ret = app_control_set_app_id(app_handle, app_id.c_str());
if (ret != APP_CONTROL_ERROR_NONE) {
LoggerE("Set applicaiton ID error: %d", ret);
notification_h noti_handle,
const std::string& progess_type,
double* progress_value) {
+ LoggerD("Enter");
*progress_value = 0.0;
if (progess_type == kProgressTypeByte) {
const std::string& progress_type,
double progress_value,
bool is_update) {
+ LoggerD("Enter");
int ret;
if (progress_type == kProgressTypeByte) {
PlatformResult StatusNotification::GetPostedTime(notification_h noti_handle,
time_t* posted_time) {
+ LoggerD("Enter");
*posted_time = 0;
if (notification_get_insert_time(noti_handle, posted_time) !=
PlatformResult StatusNotification::GetNotiHandle(int id,
notification_h* noti_handle) {
+ LoggerD("Enter");
*noti_handle = notification_load(NULL, id);
if (NULL == *noti_handle) {
LoggerE("Not found or removed notification id");
PlatformResult StatusNotification::GetAppControl(notification_h noti_handle,
app_control_h* app_control) {
+ LoggerD("Enter");
int ret =
notification_get_launch_option(noti_handle,
NOTIFICATION_LAUNCH_OPTION_APP_CONTROL,
PlatformResult StatusNotification::CreateAppControl(
app_control_h* app_control) {
+ LoggerD("Enter");
int ret = app_control_create(app_control);
if (ret != APP_CONTROL_ERROR_NONE) {
LoggerE("Application create error: %d", ret);
PlatformResult StatusNotification::SetAppControl(notification_h noti_handle,
app_control_h app_control) {
+ LoggerD("Enter");
int ret =
notification_set_launch_option(noti_handle,
NOTIFICATION_LAUNCH_OPTION_APP_CONTROL,
notification_h noti_handle,
app_control_h app_handle,
picojson::object* out_ptr) {
+ LoggerD("Enter");
picojson::object& out = *out_ptr;
out["id"] = picojson::value(std::to_string(id));
PlatformResult StatusNotification::FromJson(const picojson::object& args,
bool is_update,
picojson::object* out_ptr) {
+ LoggerD("Enter");
picojson::object noti_obj =
common::FromJson<picojson::object>(args, "notification");