var isAlarmAbsolutePeriodDeprecated = true;
-var AlarmManager = function () {
+var AlarmManager = function() {
Object.defineProperties(this, {
- PERIOD_MINUTE: { value: 60, writable: false, enumerable: true},
- PERIOD_HOUR: { value: 3600, writable: false, enumerable: true},
- PERIOD_DAY: { value: 86400, writable: false, enumerable: true},
- PERIOD_WEEK: { value: 604800, writable: false, enumerable: true},
+ PERIOD_MINUTE: { value: 60, writable: false, enumerable: true },
+ PERIOD_HOUR: { value: 3600, writable: false, enumerable: true },
+ PERIOD_DAY: { value: 86400, writable: false, enumerable: true },
+ PERIOD_WEEK: { value: 604800, writable: false, enumerable: true }
});
};
return new InternalData_(data);
}
- for(var key in data) {
+ for (var key in data) {
if (data.hasOwnProperty(key)) {
this[key] = data[key];
}
function UpdateInternalData_(internal, data) {
var values = InternalData_(data);
- for(var key in data) {
+ for (var key in data) {
if (values.hasOwnProperty(key) && internal.hasOwnProperty(key)) {
internal[key] = values;
}
var _warningLogs = new LogManager();
//class AlarmManager ////////////////////////////////////////////////////
-AlarmManager.prototype.add = function () {
- var args = AV.validateMethod(arguments, [
+AlarmManager.prototype.add = function() {
+ var args = AV.validateArgs(arguments, [
{
- name : 'alarm',
- type : AV.Types.PLATFORM_OBJECT,
- values : [tizen.AlarmRelative, tizen.AlarmAbsolute]
+ name: 'alarm',
+ type: AV.Types.PLATFORM_OBJECT,
+ values: [tizen.AlarmRelative, tizen.AlarmAbsolute]
},
{
- name : 'applicationId',
- type : AV.Types.STRING,
+ name: 'applicationId',
+ type: AV.Types.STRING
},
{
- name : 'appControl',
- type : AV.Types.PLATFORM_OBJECT,
- values : tizen.ApplicationControl,
- optional : true,
- nullable : true
- },
+ name: 'appControl',
+ type: AV.Types.PLATFORM_OBJECT,
+ values: tizen.ApplicationControl,
+ optional: true,
+ nullable: true
+ }
]);
- var type = null, seconds = 0;
+ var type = null,
+ seconds = 0;
if (args.alarm instanceof tizen.AlarmRelative) {
type = 'AlarmRelative';
} else if (args.alarm instanceof tizen.AlarmAbsolute) {
callArgs.seconds = Converter.toString(seconds);
callArgs.isPeriodSet = !T.isNullOrUndefined(args.alarm.period);
- var result = native.callSync('AlarmManager_add', callArgs);
+ var result = native.callSync('AlarmManagerAdd', callArgs);
if (native.isFailure(result)) {
throw native.getErrorObject(result);
} else {
};
AlarmManager.prototype.addAlarmNotification = function() {
- var args = AV.validateMethod(arguments, [
- {
- name: 'alarm',
- type: AV.Types.PLATFORM_OBJECT,
- values: [tizen.AlarmRelative, tizen.AlarmAbsolute]
- }, {
- name: 'notification',
- type: AV.Types.PLATFORM_OBJECT,
- values: [tizen.StatusNotification, tizen.UserNotification]
- }]);
-
- var type = null, milliseconds = 0;
+ var args = AV.validateArgs(arguments, [
+ {
+ name: 'alarm',
+ type: AV.Types.PLATFORM_OBJECT,
+ values: [tizen.AlarmRelative, tizen.AlarmAbsolute]
+ },
+ {
+ name: 'notification',
+ type: AV.Types.PLATFORM_OBJECT,
+ values: [tizen.StatusNotification, tizen.UserNotification]
+ }
+ ]);
+
+ var type = null,
+ milliseconds = 0;
if (args.alarm instanceof tizen.AlarmRelative) {
type = 'AlarmRelative';
} else if (args.alarm instanceof tizen.AlarmAbsolute) {
callArgs.isPeriodSet = !T.isNullOrUndefined(args.alarm.period);
//add marker for UserNotification implementation
- callArgs.newImpl = (callArgs.notification instanceof tizen.UserNotification);
+ callArgs.newImpl = callArgs.notification instanceof tizen.UserNotification;
- var result = native.callSync('AlarmManager_addAlarmNotification', callArgs);
+ var result = native.callSync('AlarmManagerAddAlarmNotification', callArgs);
if (native.isFailure(result)) {
throw native.getErrorObject(result);
- }
- else {
+ } else {
_edit.allow();
UpdateInternalData_(args.alarm, native.getResultObject(result));
_edit.disallow();
}
};
-AlarmManager.prototype.remove = function () {
- var args = AV.validateMethod(arguments, [
+AlarmManager.prototype.remove = function() {
+ var args = AV.validateArgs(arguments, [
{
- name : 'id',
- type : AV.Types.STRING,
+ name: 'id',
+ type: AV.Types.STRING
}
]);
- var result = native.callSync('AlarmManager_remove', {id: Number(args.id)});
+ var result = native.callSync('AlarmManagerRemove', { id: Number(args.id) });
if (native.isFailure(result)) {
throw native.getErrorObject(result);
}
};
-AlarmManager.prototype.removeAll = function () {
- var result = native.callSync('AlarmManager_removeAll', {});
+AlarmManager.prototype.removeAll = function() {
+ var result = native.callSync('AlarmManagerRemoveAll', {});
if (native.isFailure(result)) {
throw native.getErrorObject(result);
}
};
-AlarmManager.prototype.get = function () {
- var args = AV.validateMethod(arguments, [
+AlarmManager.prototype.get = function() {
+ var args = AV.validateArgs(arguments, [
{
- name : 'id',
- type : AV.Types.STRING,
+ name: 'id',
+ type: AV.Types.STRING
}
]);
- var result = native.callSync('AlarmManager_get', {id: Number(args.id)});
+ var result = native.callSync('AlarmManagerGet', { id: Number(args.id) });
if (native.isFailure(result)) {
throw native.getErrorObject(result);
var alarm;
_warningLogs.disallow();
if ('AlarmRelative' === result.type) {
- alarm = new tizen.AlarmRelative(result.delay, result.period, InternalData_(result));
- } else {
- var date = new Date(result.year, result.month, result.day,
- result.hour, result.min, result.sec);
+ alarm = new tizen.AlarmRelative(
+ result.delay,
+ result.period,
+ InternalData_(result)
+ );
+ } else if ('AlarmAbsolute' === result.type) {
+ var date = new Date(
+ result.year,
+ result.month,
+ result.day,
+ result.hour,
+ result.min,
+ result.sec
+ );
alarm = new tizen.AlarmAbsolute(date, result.second, InternalData_(result));
+ } else {
+ alarm = new Alarm(InternalData_(result));
}
_warningLogs.allow();
return alarm;
};
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);
- }
+ 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) {
- privUtils_.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));
+ if (!noti || !noti.textContents || !noti.textContents.detailInfo) {
+ privUtils_.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;
}
- noti.textContents.detailInfo = _d;
- }
}
-AlarmManager.prototype.getAlarmNotification = function () {
- var args = AV.validateMethod(arguments, [
+AlarmManager.prototype.getAlarmNotification = function() {
+ var args = AV.validateArgs(arguments, [
{
- name : 'id',
- type : AV.Types.STRING,
+ name: 'id',
+ type: AV.Types.STRING
}
]);
- var result = native.callSync('AlarmManager_getAlarmNotification', {id: Number(args.id)});
+ var result = native.callSync('AlarmManagerGetAlarmNotification', {
+ id: Number(args.id)
+ });
if (native.isFailure(result)) {
throw native.getErrorObject(result);
}
};
-AlarmManager.prototype.getAll = function () {
- var result = native.callSync('AlarmManager_getAll', {});
+AlarmManager.prototype.getAll = function() {
+ var result = native.callSync('AlarmManagerGetAll', {});
if (native.isFailure(result)) {
throw native.getErrorObject(result);
var data = native.getResultObject(result);
var md = [];
_warningLogs.disallow();
- data.forEach(function (i) {
- if ('AlarmRelative'=== i.type) {
+ data.forEach(function(i) {
+ if ('AlarmRelative' === i.type) {
md.push(new tizen.AlarmRelative(i.delay, i.period, InternalData_(i)));
- } else {
- var date = new Date(i.year, i.month, i.day,
- i.hour, i.min, i.sec);
+ } else if ('AlarmAbsolute' === i.type) {
+ var date = new Date(i.year, i.month, i.day, i.hour, i.min, i.sec);
md.push(new tizen.AlarmAbsolute(date, i.second, InternalData_(i)));
+ } else {
+ md.push(new Alarm(InternalData_(i)));
}
});
_warningLogs.allow();
}
var _internal = {
- 'id' : m_id
+ id: m_id
};
Object.defineProperties(this, {
id: {
- get: function () {return _internal.id;},
- set: function (value) {
+ get: function() {
+ return _internal.id;
+ },
+ set: function(value) {
if (value instanceof InternalData_) {
_internal.id = value.id;
}
var m_delay = Converter.toLong(delay);
if (arguments.length >= 2) {
- if(!T.isNullOrUndefined(period)){
+ if (!T.isNullOrUndefined(period)) {
m_period = Converter.toLong(period, true);
}
}
tizen.AlarmRelative.prototype.constructor = tizen.AlarmRelative;
-tizen.AlarmRelative.prototype.getRemainingSeconds = function () {
- var result = native.callSync('AlarmRelative_getRemainingSeconds', {id: Number(this.id)});
+tizen.AlarmRelative.prototype.getRemainingSeconds = function() {
+ var result = native.callSync('AlarmManagerGetRemainingSeconds', {
+ id: Number(this.id)
+ });
if (native.isFailure(result)) {
throw native.getErrorObject(result);
tizen.AlarmAbsolute = function(date, second, internal) {
AV.validateConstructorCall(this, tizen.AlarmAbsolute);
- var m_period = null, m_daysOfWeek = [], m_date;
+ var m_period = null,
+ m_daysOfWeek = [],
+ m_date;
if (T.isDate(date)) {
m_date = date;
if (arguments.length >= 2) {
- if(T.isArray(second)){
+ if (T.isArray(second)) {
m_daysOfWeek = second;
} else {
- if(!T.isNullOrUndefined(second)){
+ if (!T.isNullOrUndefined(second)) {
m_period = Converter.toLong(second);
- if(_warningLogs.enableLog && isAlarmAbsolutePeriodDeprecated){
- privUtils_.warn("This Constructor is deprecated since Tizen 4.0." +
- " Please consider using other constructors or other type of an alarm.");
+ if (_warningLogs.enableLog && isAlarmAbsolutePeriodDeprecated) {
+ privUtils_.warn(
+ 'This Constructor is deprecated since Tizen 4.0.' +
+ ' Please consider using other constructors or other ' +
+ 'type of an alarm.'
+ );
}
}
}
},
period: {
get: function() {
- if(_warningLogs.enableLog && isAlarmAbsolutePeriodDeprecated){
- privUtils_.warn('Since Tizen 4.0 constructor AlarmAbsolute(Date date, long period) ' +
- 'is deprecated, thus period attribute should not be used.');
+ if (_warningLogs.enableLog && isAlarmAbsolutePeriodDeprecated) {
+ privUtils_.warn(
+ 'Since Tizen 4.0 constructor AlarmAbsolute(Date date, ' +
+ 'long period) is deprecated, thus period attribute should ' +
+ 'not be used.'
+ );
}
return m_period;
},
set: function(v) {
- if(_warningLogs.enableLog && isAlarmAbsolutePeriodDeprecated){
- privUtils_.warn('Since Tizen 4.0 constructor AlarmAbsolute(Date date, long period) ' +
- 'is deprecated, thus period attribute should not be used.');
+ if (_warningLogs.enableLog && isAlarmAbsolutePeriodDeprecated) {
+ privUtils_.warn(
+ 'Since Tizen 4.0 constructor AlarmAbsolute(Date date, ' +
+ 'long period) is deprecated, thus period attribute should ' +
+ 'not be used.'
+ );
}
if (_edit.canEdit && v) {
tizen.AlarmAbsolute.prototype.constructor = tizen.AlarmAbsolute;
-tizen.AlarmAbsolute.prototype.getNextScheduledDate = function () {
- var result = native.callSync('AlarmAbsolute_getNextScheduledDate', {id: Number(this.id)});
+tizen.AlarmAbsolute.prototype.getNextScheduledDate = function() {
+ var result = native.callSync('AlarmManagerGetNextScheduledDate', {
+ id: Number(this.id)
+ });
if (native.isFailure(result)) {
throw native.getErrorObject(result);
var ProfileAlarm = (function() {
var m_profile = null;
function ProfileAlarm() {
- if (m_profile == null) {
- m_profile = privUtils_.checkProfile();
- }
- Object.defineProperties(this, {
- profile: {
- get: function() {
- return m_profile;
- },
- set: function() {},
- enumerable: true
- }
- })
- };
+ if (m_profile == null) {
+ m_profile = privUtils_.checkProfile();
+ }
+ Object.defineProperties(this, {
+ profile: {
+ get: function() {
+ return m_profile;
+ },
+ set: function() {},
+ enumerable: true
+ }
+ });
+ }
var instance;
return {
}
return instance;
}
- };
+ };
})();
var _profile = ProfileAlarm.getInstance().profile;
// Notifications feature are available on mobile and wearable profile
-if (_profile != 'mobile' && _profile != 'wearable') {
+if (_profile != 'mobile' && _profile != 'wearable' && _profile != 'common') {
delete AlarmManager.prototype.addAlarmNotification;
delete AlarmManager.prototype.getAlarmNotification;
isAlarmAbsolutePeriodDeprecated = false;