var converter_ = utils_.converter;
var validator_ = utils_.validator;
var types_ = validator_.Types;
-var privilege_ = xwalk.utils.privilege;
var native_ = new xwalk.utils.NativeManager(extension);
function convertColorToInt(rgbaColor) {
NotificationManager.prototype.post = function(notification) {
- xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
-
var args = validator_.validateArgs(arguments, [
{name: 'notification', type: types_.PLATFORM_OBJECT, values: StatusNotification}
]);
var result = native_.callSync('NotificationManager_post', data);
if (native_.isFailure(result)) {
- throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
+ throw native_.getErrorObject(result);
}
_edit.allow();
};
NotificationManager.prototype.update = function(notification) {
- xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
-
var args = validator_.validateArgs(arguments, [
{name: 'notification', type: types_.PLATFORM_OBJECT, values: StatusNotification}
]);
var result = native_.callSync('NotificationManager_update', data);
if (native_.isFailure(result)) {
- throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
- native_.getErrorObject(result));
+ throw native_.getErrorObject(result);
}
};
NotificationManager.prototype.remove = function(id) {
- xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
-
var args = validator_.validateArgs(arguments, [
{name: 'id', type: types_.STRING}
]);
var result = native_.callSync('NotificationManager_remove', data);
if (native_.isFailure(result)) {
- throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
- native_.getErrorObject(result));
+ throw native_.getErrorObject(result);
}
};
NotificationManager.prototype.removeAll = function() {
- xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
-
var result = native_.callSync('NotificationManager_removeAll', {});
if (native_.isFailure(result)) {
- throw new WebAPIException(WebAPIException.UNKNOWN_ERR,
- native_.getErrorObject(result));
+ throw native_.getErrorObject(result);
}
};
var result = native_.callSync('NotificationManager_get', data);
if (native_.isFailure(result)) {
- throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
- native_.getErrorObject(result));
+ throw native_.getErrorObject(result);
}
var n = native_.getResultObject(result);
var result = native_.callSync('NotificationManager_getAll', {});
if (native_.isFailure(result)) {
- throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
- native_.getErrorObject(result));
+ throw native_.getErrorObject(result);
}
var n = native_.getResultObject(result);
* @param flags Array
*/
NotificationManager.prototype.playLEDCustomEffect = function(timeOn, timeOff, color, flags) {
- xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.LED);
-
var args = validator_.validateArgs(arguments, [
{name: 'timeOn', type: types_.LONG},
{name: 'timeOff', type: types_.LONG},
* Stops the custom effect of the service LED that is located to the front of a device.
*/
NotificationManager.prototype.stopLEDCustomEffect = function() {
- xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.LED);
-
var result = native_.callSync('NotificationManager_stopLEDCustomEffect');
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
#include "common/logger.h"
#include "common/picojson.h"
#include "common/platform_result.h"
+#include "common/tools.h"
#include "notification/notification_manager.h"
namespace extension {
namespace notification {
+namespace {
+// The privileges that required in Notification API
+const std::string kPrivilegeNotification = "http://tizen.org/privilege/notification";
+const std::string kPrivilegeLED = "http://tizen.org/privilege/led";
+} // namespace
+
using namespace common;
NotificationInstance::NotificationInstance() {
void NotificationInstance::NotificationManagerPost(const picojson::value& args,
picojson::object& out) {
+ CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
LoggerD("Enter");
picojson::value val{picojson::object{}};
void NotificationInstance::NotificationManagerUpdate(
const picojson::value& args,
picojson::object& out) {
+ CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
LoggerD("Enter");
PlatformResult status = manager_->Update(args.get<picojson::object>());
void NotificationInstance::NotificationManagerRemove(
const picojson::value& args,
picojson::object& out) {
+ CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
LoggerD("Enter");
PlatformResult status = manager_->Remove(args.get<picojson::object>());
void NotificationInstance::NotificationManagerRemoveAll(
const picojson::value& args,
picojson::object& out) {
+ CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
LoggerD("Enter");
PlatformResult status = manager_->RemoveAll();
const picojson::value& args, picojson::object& out) {
LoggerD("Enter");
+ CHECK_PRIVILEGE_ACCESS(kPrivilegeLED, &out);
PlatformResult status = manager_->PlayLEDCustomEffect(args.get<picojson::object>());
const picojson::value& /*args*/, picojson::object& out) {
LoggerD("Enter");
+ CHECK_PRIVILEGE_ACCESS(kPrivilegeLED, &out);
PlatformResult status = manager_->StopLEDCustomEffect();