[Common] Changed configuration for common profile build
[platform/core/api/webapi-plugins.git] / src / alarm / alarm_api.js
index 98b4c7b..8b386bb 100755 (executable)
@@ -84,7 +84,7 @@ var _warningLogs = new LogManager();
 
 //class AlarmManager ////////////////////////////////////////////////////
 AlarmManager.prototype.add = function() {
-    var args = AV.validateMethod(arguments, [
+    var args = AV.validateArgs(arguments, [
         {
             name: 'alarm',
             type: AV.Types.PLATFORM_OBJECT,
@@ -123,7 +123,7 @@ AlarmManager.prototype.add = function() {
     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 {
@@ -134,7 +134,7 @@ AlarmManager.prototype.add = function() {
 };
 
 AlarmManager.prototype.addAlarmNotification = function() {
-    var args = AV.validateMethod(arguments, [
+    var args = AV.validateArgs(arguments, [
         {
             name: 'alarm',
             type: AV.Types.PLATFORM_OBJECT,
@@ -166,7 +166,7 @@ AlarmManager.prototype.addAlarmNotification = function() {
     //add marker for UserNotification implementation
     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 {
@@ -177,14 +177,14 @@ AlarmManager.prototype.addAlarmNotification = function() {
 };
 
 AlarmManager.prototype.remove = function() {
-    var args = AV.validateMethod(arguments, [
+    var args = AV.validateArgs(arguments, [
         {
             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);
@@ -192,7 +192,7 @@ AlarmManager.prototype.remove = function() {
 };
 
 AlarmManager.prototype.removeAll = function() {
-    var result = native.callSync('AlarmManager_removeAll', {});
+    var result = native.callSync('AlarmManagerRemoveAll', {});
 
     if (native.isFailure(result)) {
         throw native.getErrorObject(result);
@@ -200,14 +200,14 @@ AlarmManager.prototype.removeAll = function() {
 };
 
 AlarmManager.prototype.get = function() {
-    var args = AV.validateMethod(arguments, [
+    var args = AV.validateArgs(arguments, [
         {
             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);
@@ -222,7 +222,7 @@ AlarmManager.prototype.get = function() {
                 result.period,
                 InternalData_(result)
             );
-        } else {
+        } else if ('AlarmAbsolute' === result.type) {
             var date = new Date(
                 result.year,
                 result.month,
@@ -233,6 +233,8 @@ AlarmManager.prototype.get = function() {
             );
 
             alarm = new tizen.AlarmAbsolute(date, result.second, InternalData_(result));
+        } else {
+            alarm = new Alarm(InternalData_(result));
         }
         _warningLogs.allow();
         return alarm;
@@ -258,7 +260,7 @@ function _prepareAppControl(noti) {
 
 function _prepareDetailInfo(noti) {
     if (!noti || !noti.textContents || !noti.textContents.detailInfo) {
-        console.log('Do nothing - detailInfo is NOT present');
+        privUtils_.log('Do nothing - detailInfo is NOT present');
         return;
     }
     var detailInfo = noti.textContents.detailInfo;
@@ -277,14 +279,14 @@ function _prepareDetailInfo(noti) {
 }
 
 AlarmManager.prototype.getAlarmNotification = function() {
-    var args = AV.validateMethod(arguments, [
+    var args = AV.validateArgs(arguments, [
         {
             name: 'id',
             type: AV.Types.STRING
         }
     ]);
 
-    var result = native.callSync('AlarmManager_getAlarmNotification', {
+    var result = native.callSync('AlarmManagerGetAlarmNotification', {
         id: Number(args.id)
     });
 
@@ -299,7 +301,7 @@ AlarmManager.prototype.getAlarmNotification = function() {
 };
 
 AlarmManager.prototype.getAll = function() {
-    var result = native.callSync('AlarmManager_getAll', {});
+    var result = native.callSync('AlarmManagerGetAll', {});
 
     if (native.isFailure(result)) {
         throw native.getErrorObject(result);
@@ -310,9 +312,11 @@ AlarmManager.prototype.getAll = function() {
         data.forEach(function(i) {
             if ('AlarmRelative' === i.type) {
                 md.push(new tizen.AlarmRelative(i.delay, i.period, InternalData_(i)));
-            } else {
+            } 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();
@@ -394,7 +398,7 @@ tizen.AlarmRelative.prototype = new Alarm();
 tizen.AlarmRelative.prototype.constructor = tizen.AlarmRelative;
 
 tizen.AlarmRelative.prototype.getRemainingSeconds = function() {
-    var result = native.callSync('AlarmRelative_getRemainingSeconds', {
+    var result = native.callSync('AlarmManagerGetRemainingSeconds', {
         id: Number(this.id)
     });
 
@@ -476,8 +480,8 @@ tizen.AlarmAbsolute = function(date, second, internal) {
                 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.'
+                            'long period) is deprecated, thus period attribute should ' +
+                            'not be used.'
                     );
                 }
                 return m_period;
@@ -486,8 +490,8 @@ tizen.AlarmAbsolute = function(date, second, internal) {
                 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.'
+                            'long period) is deprecated, thus period attribute should ' +
+                            'not be used.'
                     );
                 }
 
@@ -516,7 +520,7 @@ tizen.AlarmAbsolute.prototype = new Alarm();
 tizen.AlarmAbsolute.prototype.constructor = tizen.AlarmAbsolute;
 
 tizen.AlarmAbsolute.prototype.getNextScheduledDate = function() {
-    var result = native.callSync('AlarmAbsolute_getNextScheduledDate', {
+    var result = native.callSync('AlarmManagerGetNextScheduledDate', {
         id: Number(this.id)
     });
 
@@ -567,7 +571,7 @@ var ProfileAlarm = (function() {
 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;