}, {
name: 'notification',
type: AV.Types.PLATFORM_OBJECT,
- values: tizen.StatusNotification
+ values: [tizen.StatusNotification, tizen.UserNotification]
}]);
var type = null, milliseconds = 0;
callArgs.milliseconds = Converter.toString(milliseconds);
callArgs.isPeriodSet = !T.isNullOrUndefined(args.alarm.period);
+ //add marker for UserNotification implementation
+ callArgs.newImpl = (callArgs.notification instanceof tizen.UserNotification);
+
var result = native.callSync('AlarmManager_addAlarmNotification', callArgs);
if (native.isFailure(result)) {
throw native.getErrorObject(result);
}
};
+function _prepareAppControl(noti) {
+ if (!noti || !noti.actions || !noti.actions.appControl) {
+ privUtils_.log("Do nothing - appControl is NOT present");
+ return;
+ }
+ if (!T.isNullOrUndefined(noti.actions.appControl.operation)) {
+ noti.actions.appControl = new tizen.ApplicationControl(
+ noti.actions.appControl.operation,
+ noti.actions.appControl.uri,
+ noti.actions.appControl.mime,
+ noti.actions.appControl.category,
+ noti.actions.appControl.data,
+ noti.actions.appControl.launchMode);
+ }
+}
+
+function _prepareDetailInfo(noti) {
+ if (!noti || !noti.textContents || !noti.textContents.detailInfo) {
+ console.log("Do nothing - detailInfo is NOT present");
+ return;
+ }
+ var detailInfo = noti.textContents.detailInfo;
+ if (T.isArray(detailInfo)) {
+ var _d = [];
+ for (var i = 0; i < detailInfo.length; ++i) {
+ _d.push(new tizen.NotificationDetailInfo(detailInfo[i].mainText,
+ detailInfo[i].subText || null));
+ }
+ noti.textContents.detailInfo = _d;
+ }
+}
+
AlarmManager.prototype.getAlarmNotification = function () {
var args = AV.validateMethod(arguments, [
{
throw native.getErrorObject(result);
} else {
var noti = native.getResultObject(result);
- if(!T.isNullOrUndefined(noti.appControl.operation)){
- noti.appControl = new tizen.ApplicationControl(
- noti.appControl.operation,
- noti.appControl.uri,
- noti.appControl.mime,
- noti.appControl.category,
- noti.appControl.data,
- noti.appControl.launchMode);
- }
- return new tizen.StatusNotification('SIMPLE', noti.title, noti);
+ _prepareAppControl(noti);
+ _prepareDetailInfo(noti);
+ return new tizen.UserNotification(noti.userType, noti.title, noti);
}
};
#include "alarm_instance.h"
#include "alarm_utils.h"
+#include "notification/common_notification.h"
#include "notification/status_notification.h"
+#include "notification/user_notification.h"
using namespace common;
using namespace common::tools;
app_control_destroy(app_control);
};
- PlatformResult platform_result = StatusNotification::GetNotiHandleFromJson(
- args.get<picojson::object>(),
- false,
- ¬ification_handle);
+ using namespace std::placeholders;
+ std::function <PlatformResult(const picojson::object& args,
+ bool is_update,
+ notification_h *noti_handle)> impl {};
+ if (args.contains("newImpl") && args.get("newImpl").is<bool>()
+ && args.get("newImpl").get<bool>()) {
+ LoggerD("New implementation");
+ impl = std::bind(&UserNotification::GetNotiHandleFromJson, _1, _2, _3);
+ } else {
+ LoggerW("Deprecated object used");
+ impl = std::bind(&StatusNotification::GetNotiHandleFromJson, _1, _2, _3);
+ }
+ PlatformResult platform_result = impl(args.get<picojson::object>(),
+ false, ¬ification_handle);
if (!platform_result) {
LogAndReportError(PlatformResult(ErrorCode::ABORT_ERR, platform_result.message().c_str()),
&out);
}
-
- platform_result = StatusNotification::GetAppControl(notification_handle, &app_control);
+ platform_result = CommonNotification::GetAppControl(notification_handle, &app_control);
if (!platform_result) {
LogAndReportError(
return;
}
- platform_result = StatusNotification::SetAppControl(notification_handle, app_control);
+ platform_result = CommonNotification::SetAppControl(notification_handle, app_control);
if (!platform_result) {
LogAndReportError(
int repeat_value = 0;
util::ArrayDaysToMask(days_of_the_week, &repeat_value);
- platform_result = StatusNotification::SetAppControl(notification_handle, app_control);
+ platform_result = CommonNotification::SetAppControl(notification_handle, app_control);
if (!platform_result) {
LogAndReportError(
PlatformResult(platform_result.error_code(), platform_result.message().c_str()), &out);
return;
}
- platform_result = StatusNotification::SetAppControl(notification_handle, app_control);
+ platform_result = CommonNotification::SetAppControl(notification_handle, app_control);
if (!platform_result) {
LogAndReportError(
PlatformResult(platform_result.error_code(), platform_result.message().c_str()), &out);
return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Alarm not found.",
("Alarm not found: %d (%s)", ret, get_error_message(ret)));
} else {
- PlatformResult platform_result = extension::notification::StatusNotification::GetAppControl(
+ PlatformResult platform_result = extension::notification::CommonNotification::GetAppControl(
notification_handle, &app_control);
if (!platform_result) {
return LogAndCreateResult(
}
app_control_h app_control = nullptr;
- platform_result = StatusNotification::GetAppControl(notification_handle, &app_control);
+ platform_result = CommonNotification::GetAppControl(notification_handle, &app_control);
if (!platform_result) {
LogAndReportError(platform_result, &out);
picojson::value result = picojson::value(picojson::object());
picojson::object& result_obj = result.get<picojson::object>();
- platform_result = StatusNotification::ToJson(-1, notification_handle, app_control, &result_obj);
+ platform_result = UserNotification::ToJson(-1, notification_handle, app_control, &result_obj);
if (ALARM_ERROR_NONE != ret) {
LogAndReportError(PlatformResult(ErrorCode::ABORT_ERR, "Failed ToJson()."), &out);