Merge remote-tracking branch 'origin/tizen_3.0' into tizen_4.0
[platform/core/api/webapi-plugins.git] / src / notification / notification_api.js
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 var _global = window || global || {};
18
19 var utils_ = xwalk.utils;
20 var type_ = utils_.type;
21 var converter_ = utils_.converter;
22 var validator_ = utils_.validator;
23 var types_ = validator_.Types;
24 var native_ = new xwalk.utils.NativeManager(extension);
25
26 function convertColorToInt(rgbaColor) {
27     var color = rgbaColor.length === 7 ? rgbaColor + 'ff' : rgbaColor;
28     var isLengthOk = color.length === 9;
29     var isHash = color.substr(0, 1) === '#';
30     var hex = '0123456789abcdefABCDEF';
31     var isHex = true;
32     var c = color.replace('#', '');
33
34     for (var i = 0; i < c.length; i++) {
35         if (hex.indexOf(c[i]) < 0) {
36             isHex = false;
37         }
38     }
39
40     if (!isLengthOk || !isHash || !isHex) {
41         throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'invalid value');
42     }
43
44     return parseInt('0x' + c);
45 }
46
47 var EditManager = function() {
48     this.canEdit = false;
49 };
50
51 EditManager.prototype.allow = function() {
52     this.canEdit = true;
53 };
54
55 EditManager.prototype.disallow = function() {
56     this.canEdit = false;
57 };
58
59 var _edit = new EditManager();
60
61 var NotificationType = {
62     STATUS: 'STATUS'
63 };
64
65 var StatusNotificationType = {
66     SIMPLE: 'SIMPLE',
67     THUMBNAIL: 'THUMBNAIL',
68     ONGOING: 'ONGOING',
69     PROGRESS: 'PROGRESS'
70 };
71
72 var UserNotificationType = {
73     SIMPLE: 'SIMPLE',
74     THUMBNAIL: 'THUMBNAIL',
75     ONGOING: 'ONGOING',
76     PROGRESS: 'PROGRESS'
77 };
78
79 var NotificationProgressType = {
80     PERCENTAGE: 'PERCENTAGE',
81     BYTE: 'BYTE'
82 };
83
84 var LEDCustomFlags = {
85     LED_CUSTOM_DUTY_ON: 'LED_CUSTOM_DUTY_ON',
86     LED_CUSTOM_DEFAULT: 'LED_CUSTOM_DEFAULT'
87 };
88
89 function NotificationManager() {}
90
91 NotificationManager.prototype.post = function(notification) {
92     var args = validator_.validateArgs(arguments, [
93         { name: 'notification', type: types_.PLATFORM_OBJECT, values: Notification }
94     ]);
95
96     if (args.notification instanceof tizen.StatusNotification) {
97         utils_.warn(
98             'DEPRECATION WARNING: StatusNotification is deprecated since Tizen 4.0. ' +
99                 'Use UserNotification instead.'
100         );
101     }
102
103     var data = {
104         //add marker for UserNotification implementation
105         newImpl: args.notification instanceof tizen.UserNotification,
106         notification: args.notification
107     };
108
109     var result = native_.callSync('NotificationManager_post', data);
110
111     if (native_.isFailure(result)) {
112         throw native_.getErrorObject(result);
113     }
114
115     _edit.allow();
116     var d = native_.getResultObject(result);
117     notification.id = d.id;
118     notification.postedTime = new Date(d.postedTime) || new Date();
119     notification.type = d.type || NotificationType.STATUS;
120     _edit.disallow();
121 };
122
123 NotificationManager.prototype.update = function(notification) {
124     var args = validator_.validateArgs(arguments, [
125         { name: 'notification', type: types_.PLATFORM_OBJECT, values: Notification }
126     ]);
127
128     if (!arguments.length) {
129         throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
130     }
131     if (!args.notification.id) {
132         throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
133     }
134
135     if (args.notification instanceof tizen.StatusNotification) {
136         utils_.warn(
137             'DEPRECATION WARNING: StatusNotification is deprecated since Tizen 4.0. ' +
138                 'Use UserNotification instead.'
139         );
140     }
141
142     var data = {
143         //add marker for UserNotification implementation
144         newImpl: args.notification instanceof tizen.UserNotification,
145         notification: args.notification
146     };
147
148     var result = native_.callSync('NotificationManager_update', data);
149
150     if (native_.isFailure(result)) {
151         throw native_.getErrorObject(result);
152     }
153 };
154
155 NotificationManager.prototype.remove = function(id) {
156     var args = validator_.validateArgs(arguments, [{ name: 'id', type: types_.STRING }]);
157
158     if (!arguments.length || !(parseInt(arguments[0]) > 0)) {
159         throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
160     }
161
162     var data = {
163         id: args.id
164     };
165
166     var result = native_.callSync('NotificationManager_remove', data);
167
168     if (native_.isFailure(result)) {
169         throw native_.getErrorObject(result);
170     }
171 };
172
173 NotificationManager.prototype.removeAll = function() {
174     var result = native_.callSync('NotificationManager_removeAll', {});
175
176     if (native_.isFailure(result)) {
177         throw native_.getErrorObject(result);
178     }
179 };
180
181 NotificationManager.prototype.get = function(id) {
182     var args = validator_.validateArgs(arguments, [{ name: 'id', type: types_.STRING }]);
183
184     utils_.warn(
185         'DEPRECATION WARNING: get() is deprecated since Tizen 4.0. ' +
186             'Use getNotification() instead.'
187     );
188
189     if (!arguments.length) {
190         throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
191     }
192
193     var data = {
194         id: args.id
195     };
196
197     var result = native_.callSync('NotificationManager_get', data);
198
199     if (native_.isFailure(result)) {
200         throw native_.getErrorObject(result);
201     }
202
203     var n = native_.getResultObject(result);
204
205     _edit.allow();
206     var returnObject = new StatusNotification(n.statusType, n.title, n);
207     _edit.disallow();
208
209     return returnObject;
210 };
211
212 NotificationManager.prototype.getNotification = function(id) {
213     var args = validator_.validateArgs(arguments, [{ name: 'id', type: types_.STRING }]);
214
215     if (!arguments.length) {
216         throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
217     }
218
219     var data = {
220         //add marker for UserNotification implementation
221         newImpl: true,
222         id: args.id
223     };
224
225     var result = native_.callSync('NotificationManager_get', data);
226
227     if (native_.isFailure(result)) {
228         throw native_.getErrorObject(result);
229     }
230
231     var n = native_.getResultObject(result);
232
233     _edit.allow();
234     var returnObject = new UserNotification(n.userType, n.title, n);
235     _edit.disallow();
236
237     return returnObject;
238 };
239
240 NotificationManager.prototype.getAll = function() {
241     utils_.warn(
242         'DEPRECATION WARNING: getAll() is deprecated since Tizen 4.0. ' +
243             'Use getAllNotifications() instead.'
244     );
245
246     var result = native_.callSync('NotificationManager_getAll', {});
247
248     if (native_.isFailure(result)) {
249         throw native_.getErrorObject(result);
250     }
251
252     var n = native_.getResultObject(result);
253     var notifications = [];
254
255     _edit.allow();
256     for (var i = 0; i < n.length; i++) {
257         notifications.push(new StatusNotification(n[i].statusType, n[i].title, n[i]));
258     }
259     _edit.disallow();
260
261     return notifications;
262 };
263
264 NotificationManager.prototype.getAllNotifications = function() {
265     var result = native_.callSync('NotificationManager_getAll', {
266         //add marker for UserNotification implementation
267         newImpl: true
268     });
269
270     if (native_.isFailure(result)) {
271         throw native_.getErrorObject(result);
272     }
273
274     var n = native_.getResultObject(result);
275     var notifications = [];
276
277     _edit.allow();
278     for (var i = 0; i < n.length; i++) {
279         notifications.push(new UserNotification(n[i].userType, n[i].title, n[i]));
280     }
281     _edit.disallow();
282
283     return notifications;
284 };
285
286 /**
287  * Plays the custom effect of the service LED that is located to the front of a device.
288  *
289  * @param timeOn Number
290  * @param timeOff Number
291  * @param color String
292  * @param flags Array
293  */
294 NotificationManager.prototype.playLEDCustomEffect = function(
295     timeOn,
296     timeOff,
297     color,
298     flags
299 ) {
300     var args = validator_.validateArgs(arguments, [
301         { name: 'timeOn', type: types_.LONG },
302         { name: 'timeOff', type: types_.LONG },
303         { name: 'color', type: types_.STRING },
304         { name: 'flags', type: types_.ARRAY, values: types_.STRING }
305     ]);
306
307     for (var i = 0; i < args.flags.length; ++i) {
308         if (Object.keys(LEDCustomFlags).indexOf(args.flags[i]) < 0) {
309             throw new WebAPIException(
310                 WebAPIException.INVALID_VALUES_ERR,
311                 'invalid value'
312             );
313         }
314     }
315
316     args.color = convertColorToInt(args.color);
317     var result = native_.callSync('NotificationManager_playLEDCustomEffect', args);
318     if (native_.isFailure(result)) {
319         throw native_.getErrorObject(result);
320     }
321 };
322
323 /**
324  * Stops the custom effect of the service LED that is located to the front of a device.
325  */
326 NotificationManager.prototype.stopLEDCustomEffect = function() {
327     var result = native_.callSync('NotificationManager_stopLEDCustomEffect');
328     if (native_.isFailure(result)) {
329         throw native_.getErrorObject(result);
330     }
331 };
332
333 NotificationManager.prototype.saveNotificationAsTemplate = function(name, notification) {
334     var args = validator_.validateArgs(arguments, [
335         { name: 'name', type: types_.STRING },
336         { name: 'notification', type: types_.PLATFORM_OBJECT, values: Notification }
337     ]);
338
339     //add marker for UserNotification implementation
340     args.newImpl = args.notification instanceof tizen.UserNotification;
341
342     var result = native_.callSync('NotificationManager_saveNotificationAsTemplate', args);
343
344     if (native_.isFailure(result)) {
345         throw native_.getErrorObject(result);
346     }
347 };
348
349 NotificationManager.prototype.createNotificationFromTemplate = function(name) {
350     var args = validator_.validateArgs(arguments, [
351         { name: 'name', type: types_.STRING }
352     ]);
353
354     if (!arguments.length) {
355         throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
356     }
357
358     var result = native_.callSync(
359         'NotificationManager_createNotificationFromTemplate',
360         args
361     );
362
363     if (native_.isFailure(result)) {
364         throw native_.getErrorObject(result);
365     }
366     var n = native_.getResultObject(result);
367
368     _edit.allow();
369     var returnObject = new UserNotification(n.userType, n.title, n);
370     _edit.disallow();
371
372     return returnObject;
373 };
374
375 var _checkProgressValue = function(v, _progressType) {
376     if (
377         (_progressType === NotificationProgressType.PERCENTAGE && (v >= 0 && v <= 100)) ||
378         (_progressType === NotificationProgressType.BYTE &&
379             converter_.toUnsignedLong(v) >= 0)
380     ) {
381         return true;
382     }
383     return false;
384 };
385
386 var _checkDetailInfo = function(v) {
387     if (type_.isNull(v)) {
388         return true;
389     }
390     if (!type_.isArray(v)) {
391         return false;
392     }
393     for (var i = 0; i < v.length; ++i) {
394         if (!(v[i] instanceof tizen.NotificationDetailInfo)) {
395             return false;
396         }
397     }
398     return true;
399 };
400
401 var _setDetailInfo = function(v) {
402     var _d = [];
403     for (var i = 0; i < v.length; ++i) {
404         _d.push(new tizen.NotificationDetailInfo(v[i].mainText, v[i].subText || null));
405     }
406     return _d;
407 };
408
409 var _checkStringArray = function(v) {
410     if (type_.isNull(v)) {
411         return true;
412     }
413     if (!type_.isArray(v)) {
414         return false;
415     }
416     for (var i = 0; i < v.length; ++i) {
417         if (!type_.isString(v[i])) {
418             return false;
419         }
420     }
421     return true;
422 };
423
424 var _isHex = function(v) {
425     return (
426         v.length === 7 &&
427         v.substr(0, 1) === '#' &&
428         /^([0-9A-Fa-f]{2})+$/.test(v.substr(1, 7))
429     );
430 };
431
432 function NotificationInitDict(data) {
433     var _iconPath = null;
434     var _soundPath = null;
435     var _vibration = false;
436     var _appControl = null;
437     var _appId = null;
438     var _progressType = NotificationProgressType.PERCENTAGE;
439     var _progressValue = null;
440     var _number = null;
441     var _subIconPath = null;
442     var _detailInfo = [];
443     var _ledColor = null;
444     var _ledOnPeriod = 0;
445     var _ledOffPeriod = 0;
446     var _backgroundImagePath = null;
447     var _thumbnails = [];
448
449     Object.defineProperties(this, {
450         iconPath: {
451             get: function() {
452                 return _iconPath;
453             },
454             set: function(v) {
455                 _iconPath = type_.isString(v) || type_.isNull(v) ? v : _iconPath;
456             },
457             enumerable: true
458         },
459         soundPath: {
460             get: function() {
461                 return _soundPath;
462             },
463             set: function(v) {
464                 _soundPath = type_.isString(v) || type_.isNull(v) ? v : _soundPath;
465             },
466             enumerable: true
467         },
468         vibration: {
469             get: function() {
470                 return _vibration;
471             },
472             set: function(v) {
473                 _vibration = type_.isBoolean(v) ? v : _vibration;
474             },
475             enumerable: true
476         },
477         appControl: {
478             get: function() {
479                 return _appControl;
480             },
481             set: function(v) {
482                 _appControl =
483                     _edit.canEdit && v
484                         ? new tizen.ApplicationControl(
485                             v.operation,
486                             v.uri || null,
487                             v.mime || null,
488                             v.category || null,
489                             v.data || []
490                         )
491                         : v instanceof tizen.ApplicationControl || type_.isNull(v)
492                             ? v
493                             : _appControl;
494             },
495             enumerable: true
496         },
497         appId: {
498             get: function() {
499                 return _appId;
500             },
501             set: function(v) {
502                 _appId =
503                     (type_.isString(v) && !/\s/.test(v)) || type_.isNull(v) ? v : _appId;
504             },
505             enumerable: true
506         },
507         progressType: {
508             get: function() {
509                 return _progressType;
510             },
511             set: function(v) {
512                 _progressType =
513                     Object.keys(NotificationProgressType).indexOf(v) >= 0
514                         ? v
515                         : _progressType;
516             },
517             enumerable: true
518         },
519         progressValue: {
520             get: function() {
521                 if (null === _progressValue) {
522                     return _progressValue;
523                 }
524
525                 return _progressType === NotificationProgressType.PERCENTAGE
526                     ? _progressValue * 100
527                     : _progressValue;
528             },
529             set: function(v) {
530                 if (type_.isNull(v)) {
531                     _progressValue = v;
532                     return;
533                 }
534                 if (_checkProgressValue(v, _progressType)) {
535                     _progressValue =
536                         _progressType === NotificationProgressType.PERCENTAGE
537                             ? v / 100
538                             : converter_.toUnsignedLong(v);
539                 }
540             },
541             enumerable: true
542         },
543         number: {
544             get: function() {
545                 return _number;
546             },
547             set: function(v) {
548                 _number = type_.isNumber(v) || type_.isNull(v) ? v : _number;
549             },
550             enumerable: true
551         },
552         subIconPath: {
553             get: function() {
554                 return _subIconPath;
555             },
556             set: function(v) {
557                 _subIconPath = type_.isString(v) || type_.isNull(v) ? v : _subIconPath;
558             },
559             enumerable: true
560         },
561         detailInfo: {
562             get: function() {
563                 return _detailInfo;
564             },
565             set: function(v) {
566                 _detailInfo =
567                     _edit.canEdit && v
568                         ? _setDetailInfo(v)
569                         : _checkDetailInfo(v)
570                             ? v
571                             : _detailInfo;
572             },
573             enumerable: true
574         },
575         ledColor: {
576             get: function() {
577                 return _ledColor;
578             },
579             set: function(v) {
580                 _ledColor =
581                     (type_.isString(v) && _isHex(v)) || type_.isNull(v) ? v : _ledColor;
582             },
583             enumerable: true
584         },
585         ledOnPeriod: {
586             get: function() {
587                 return _ledOnPeriod;
588             },
589             set: function(v) {
590                 _ledOnPeriod = type_.isNumber(v) ? v : _ledOnPeriod;
591             },
592             enumerable: true
593         },
594         ledOffPeriod: {
595             get: function() {
596                 return _ledOffPeriod;
597             },
598             set: function(v) {
599                 _ledOffPeriod = type_.isNumber(v) ? v : _ledOffPeriod;
600             },
601             enumerable: true
602         },
603         backgroundImagePath: {
604             get: function() {
605                 return _backgroundImagePath;
606             },
607             set: function(v) {
608                 _backgroundImagePath =
609                     type_.isString(v) || type_.isNull(v) ? v : _backgroundImagePath;
610             },
611             enumerable: true
612         },
613         thumbnails: {
614             get: function() {
615                 return _thumbnails;
616             },
617             set: function(v) {
618                 _thumbnails = _checkStringArray(v) ? v : _thumbnails;
619             },
620             enumerable: true
621         }
622     });
623
624     if (data instanceof _global.Object) {
625         for (var prop in data) {
626             if (this.hasOwnProperty(prop)) {
627                 this[prop] = data[prop];
628             }
629         }
630     }
631 }
632
633 function Notification(data) {
634     var _id;
635     var _type = NotificationType.STATUS;
636     var _postedTime;
637     var _title;
638     var _content = null;
639
640     Object.defineProperties(this, {
641         id: {
642             get: function() {
643                 return _id;
644             },
645             set: function(v) {
646                 _id = _edit.canEdit && v ? v : _id;
647             },
648             enumerable: true
649         },
650         type: {
651             get: function() {
652                 return _type;
653             },
654             set: function(v) {
655                 _type = _edit.canEdit
656                     ? converter_.toEnum(v, Object.keys(NotificationType), false)
657                     : _type;
658             },
659             enumerable: true
660         },
661         postedTime: {
662             get: function() {
663                 return _postedTime;
664             },
665             set: function(v) {
666                 _postedTime = _edit.canEdit && v ? new Date(v) : _postedTime;
667             },
668             enumerable: true
669         },
670         title: {
671             get: function() {
672                 return _title;
673             },
674             set: function(v) {
675                 _title = converter_.toString(v);
676             },
677             enumerable: true
678         },
679         content: {
680             get: function() {
681                 return _content;
682             },
683             set: function(v) {
684                 _content = type_.isString(v) || type_.isNull(v) ? v : _content;
685             },
686             enumerable: true
687         }
688     });
689
690     if (data instanceof _global.Object) {
691         for (var prop in data) {
692             if (data.hasOwnProperty(prop) && this.hasOwnProperty(prop)) {
693                 this[prop] = data[prop];
694             }
695         }
696     }
697 }
698
699 function StatusNotification(statusType, title, notificationInitDict) {
700     validator_.isConstructorCall(this, StatusNotification);
701     type_.isObject(notificationInitDict)
702         ? (notificationInitDict.title = title)
703         : (notificationInitDict = { title: title });
704     NotificationInitDict.call(this, notificationInitDict);
705     Notification.call(this, notificationInitDict);
706
707     utils_.warn(
708         'DEPRECATION WARNING: StatusNotification is deprecated since Tizen 4.0. ' +
709             'Use UserNotification instead.'
710     );
711
712     var _statusType =
713         Object.keys(StatusNotificationType).indexOf(statusType) >= 0
714             ? statusType
715             : StatusNotificationType.SIMPLE;
716
717     Object.defineProperties(this, {
718         statusType: {
719             get: function() {
720                 return _statusType;
721             },
722             set: function(v) {
723                 _statusType =
724                     Object.keys(StatusNotificationType).indexOf(v) >= 0 && _edit.canEdit
725                         ? v
726                         : _statusType;
727             },
728             enumerable: true
729         }
730     });
731 }
732
733 StatusNotification.prototype = new Notification();
734 StatusNotification.prototype.constructor = StatusNotification;
735
736 function NotificationDetailInfo(mainText, subText) {
737     validator_.isConstructorCall(this, NotificationDetailInfo);
738
739     var _mainText = type_.isString(mainText) ? mainText : '';
740     var _subText = type_.isString(subText) ? subText : null;
741
742     Object.defineProperties(this, {
743         mainText: {
744             get: function() {
745                 return _mainText;
746             },
747             set: function(v) {
748                 _mainText = type_.isString(v) ? v : _mainText;
749             },
750             enumerable: true
751         },
752         subText: {
753             get: function() {
754                 return _subText;
755             },
756             set: function(v) {
757                 _subText = type_.isString(v) ? v : _subText;
758             },
759             enumerable: true
760         }
761     });
762 }
763
764 function TextContentsInitDict(data) {
765     if (!this) return;
766     var _progressType = NotificationProgressType.PERCENTAGE;
767     var _progressValue = null;
768     var _number = null;
769     var _detailInfo = [];
770     var _buttonsTexts = [];
771     var _contentForOff = null;
772
773     Object.defineProperties(this, {
774         progressType: {
775             get: function() {
776                 return _progressType;
777             },
778             set: function(v) {
779                 _progressType =
780                     Object.keys(NotificationProgressType).indexOf(v) >= 0
781                         ? v
782                         : _progressType;
783             },
784             enumerable: true
785         },
786         progressValue: {
787             get: function() {
788                 if (null === _progressValue) {
789                     return _progressValue;
790                 }
791
792                 return _progressType === NotificationProgressType.PERCENTAGE
793                     ? _progressValue * 100
794                     : _progressValue;
795             },
796             set: function(v) {
797                 if (type_.isNull(v)) {
798                     _progressValue = v;
799                     return;
800                 }
801                 if (_checkProgressValue(v, _progressType)) {
802                     _progressValue =
803                         _progressType === NotificationProgressType.PERCENTAGE
804                             ? v / 100
805                             : converter_.toUnsignedLong(v);
806                 }
807             },
808             enumerable: true
809         },
810         eventsNumber: {
811             get: function() {
812                 return _number;
813             },
814             set: function(v) {
815                 _number = type_.isNumber(v) || type_.isNull(v) ? v : _number;
816             },
817             enumerable: true
818         },
819         detailInfo: {
820             get: function() {
821                 return _detailInfo;
822             },
823             set: function(v) {
824                 _detailInfo =
825                     _edit.canEdit && v
826                         ? _setDetailInfo(v)
827                         : _checkDetailInfo(v)
828                             ? v
829                             : _detailInfo;
830             },
831             enumerable: true
832         },
833         buttonsTexts: {
834             get: function() {
835                 return _buttonsTexts;
836             },
837             set: function(v) {
838                 _buttonsTexts = _checkStringArray(v) ? v : _buttonsTexts;
839             },
840             enumerable: true
841         },
842         contentForOff: {
843             get: function() {
844                 return _contentForOff;
845             },
846             set: function(v) {
847                 _contentForOff =
848                     type_.isString(v) || type_.isNull(v) ? v : _contentForOff;
849             },
850             enumerable: true
851         }
852     });
853
854     if (data instanceof _global.Object) {
855         this['progressType'] = data['progressType'];
856         for (var prop in data) {
857             if (this.hasOwnProperty(prop)) {
858                 this[prop] = data[prop];
859             }
860         }
861     }
862 }
863
864 function ImagesInitDict(data) {
865     if (!this) return;
866     var _iconPath = null;
867     var _subIconPath = null;
868     var _indicatorIconPath = null;
869     var _lockScreenIconPath = null;
870     var _buttonIconPaths = [];
871     var _backgroundImagePath = null;
872
873     Object.defineProperties(this, {
874         iconPath: {
875             get: function() {
876                 return _iconPath;
877             },
878             set: function(v) {
879                 _iconPath = type_.isString(v) || type_.isNull(v) ? v : _iconPath;
880             },
881             enumerable: true
882         },
883         subIconPath: {
884             get: function() {
885                 return _subIconPath;
886             },
887             set: function(v) {
888                 _subIconPath = type_.isString(v) || type_.isNull(v) ? v : _subIconPath;
889             },
890             enumerable: true
891         },
892         indicatorIconPath: {
893             get: function() {
894                 return _indicatorIconPath;
895             },
896             set: function(v) {
897                 _indicatorIconPath =
898                     type_.isString(v) || type_.isNull(v) ? v : _indicatorIconPath;
899             },
900             enumerable: true
901         },
902         lockScreenIconPath: {
903             get: function() {
904                 return _lockScreenIconPath;
905             },
906             set: function(v) {
907                 _lockScreenIconPath =
908                     type_.isString(v) || type_.isNull(v) ? v : _lockScreenIconPath;
909             },
910             enumerable: true
911         },
912         buttonIconPaths: {
913             get: function() {
914                 return _buttonIconPaths;
915             },
916             set: function(v) {
917                 _buttonIconPaths = _checkStringArray(v) ? v : _buttonIconPaths;
918             },
919             enumerable: true
920         },
921         backgroundImagePath: {
922             get: function() {
923                 return _backgroundImagePath;
924             },
925             set: function(v) {
926                 _backgroundImagePath =
927                     type_.isString(v) || type_.isNull(v) ? v : _backgroundImagePath;
928             },
929             enumerable: true
930         }
931     });
932
933     if (data instanceof _global.Object) {
934         for (var prop in data) {
935             if (this.hasOwnProperty(prop)) {
936                 this[prop] = data[prop];
937             }
938         }
939     }
940 }
941
942 function ThumbnailsInitDict(data) {
943     if (!this) return;
944     var _lockScreenThumbnailIconPath = null;
945     var _thumbnailIconPath = null;
946     var _thumbnails = [];
947
948     Object.defineProperties(this, {
949         lockScreenThumbnailIconPath: {
950             get: function() {
951                 return _lockScreenThumbnailIconPath;
952             },
953             set: function(v) {
954                 _lockScreenThumbnailIconPath =
955                     type_.isString(v) || type_.isNull(v)
956                         ? v
957                         : _lockScreenThumbnailIconPath;
958             },
959             enumerable: true
960         },
961         thumbnailIconPath: {
962             get: function() {
963                 return _thumbnailIconPath;
964             },
965             set: function(v) {
966                 _thumbnailIconPath =
967                     type_.isString(v) || type_.isNull(v) ? v : _thumbnailIconPath;
968             },
969             enumerable: true
970         },
971         thumbnails: {
972             get: function() {
973                 return _thumbnails;
974             },
975             set: function(v) {
976                 _thumbnails = _checkStringArray(v) ? v : _thumbnails;
977             },
978             enumerable: true
979         }
980     });
981
982     if (data instanceof _global.Object) {
983         for (var prop in data) {
984             if (this.hasOwnProperty(prop)) {
985                 this[prop] = data[prop];
986             }
987         }
988     }
989 }
990
991 function ActionsInitDict(data) {
992     if (!this) return;
993     var _soundPath = null;
994     var _vibration = false;
995     var _appControl = null;
996     var _appId = null;
997
998     Object.defineProperties(this, {
999         soundPath: {
1000             get: function() {
1001                 return _soundPath;
1002             },
1003             set: function(v) {
1004                 _soundPath = type_.isString(v) || type_.isNull(v) ? v : _soundPath;
1005             },
1006             enumerable: true
1007         },
1008         vibration: {
1009             get: function() {
1010                 return _vibration;
1011             },
1012             set: function(v) {
1013                 _vibration = type_.isBoolean(v) ? v : _vibration;
1014             },
1015             enumerable: true
1016         },
1017         appControl: {
1018             get: function() {
1019                 return _appControl;
1020             },
1021             set: function(v) {
1022                 _appControl =
1023                     _edit.canEdit && v
1024                         ? new tizen.ApplicationControl(
1025                             v.operation,
1026                             v.uri || null,
1027                             v.mime || null,
1028                             v.category || null,
1029                             v.data || []
1030                         )
1031                         : v instanceof tizen.ApplicationControl || type_.isNull(v)
1032                             ? v
1033                             : _appControl;
1034             },
1035             enumerable: true
1036         },
1037         appId: {
1038             get: function() {
1039                 return _appId;
1040             },
1041             set: function(v) {
1042                 _appId =
1043                     (type_.isString(v) && !/\s/.test(v)) || type_.isNull(v) ? v : _appId;
1044             },
1045             enumerable: true
1046         }
1047     });
1048
1049     if (data instanceof _global.Object) {
1050         for (var prop in data) {
1051             if (this.hasOwnProperty(prop)) {
1052                 this[prop] = data[prop];
1053             }
1054         }
1055     }
1056 }
1057
1058 function GroupContentsInitDict(data) {
1059     if (!this) return;
1060     var _groupTitle = null;
1061     var _groupContent = null;
1062     var _groupContentForOff = null;
1063
1064     Object.defineProperties(this, {
1065         groupTitle: {
1066             get: function() {
1067                 return _groupTitle;
1068             },
1069             set: function(v) {
1070                 _groupTitle = type_.isString(v) || type_.isNull(v) ? v : _groupTitle;
1071             },
1072             enumerable: true
1073         },
1074         groupContent: {
1075             get: function() {
1076                 return _groupContent;
1077             },
1078             set: function(v) {
1079                 _groupContent = type_.isString(v) || type_.isNull(v) ? v : _groupContent;
1080             },
1081             enumerable: true
1082         },
1083         groupContentForOff: {
1084             get: function() {
1085                 return _groupContentForOff;
1086             },
1087             set: function(v) {
1088                 _groupContentForOff =
1089                     type_.isString(v) || type_.isNull(v) ? v : _groupContentForOff;
1090             },
1091             enumerable: true
1092         }
1093     });
1094
1095     if (data instanceof _global.Object) {
1096         for (var prop in data) {
1097             if (this.hasOwnProperty(prop)) {
1098                 this[prop] = data[prop];
1099             }
1100         }
1101     }
1102 }
1103
1104 function LedsInitDict(data) {
1105     if (!this) return;
1106     var _ledColor = null;
1107     var _ledOnPeriod = 0;
1108     var _ledOffPeriod = 0;
1109
1110     Object.defineProperties(this, {
1111         ledColor: {
1112             get: function() {
1113                 return _ledColor;
1114             },
1115             set: function(v) {
1116                 _ledColor =
1117                     (type_.isString(v) && _isHex(v)) || type_.isNull(v) ? v : _ledColor;
1118             },
1119             enumerable: true
1120         },
1121         ledOnPeriod: {
1122             get: function() {
1123                 return _ledOnPeriod;
1124             },
1125             set: function(v) {
1126                 _ledOnPeriod = type_.isNumber(v) ? v : _ledOnPeriod;
1127             },
1128             enumerable: true
1129         },
1130         ledOffPeriod: {
1131             get: function() {
1132                 return _ledOffPeriod;
1133             },
1134             set: function(v) {
1135                 _ledOffPeriod = type_.isNumber(v) ? v : _ledOffPeriod;
1136             },
1137             enumerable: true
1138         }
1139     });
1140
1141     if (data instanceof _global.Object) {
1142         for (var prop in data) {
1143             if (this.hasOwnProperty(prop)) {
1144                 this[prop] = data[prop];
1145             }
1146         }
1147     }
1148 }
1149
1150 function UserNotification(userType, title, notificationGroupedInitDict) {
1151     validator_.isConstructorCall(this, UserNotification);
1152     type_.isObject(notificationGroupedInitDict)
1153         ? (notificationGroupedInitDict.title = title)
1154         : (notificationGroupedInitDict = { title: title });
1155     UserNotificationInitDict.call(this, notificationGroupedInitDict);
1156     Notification.call(this, notificationGroupedInitDict);
1157
1158     this.textContents = new TextContentsInitDict(
1159         notificationGroupedInitDict.textContents
1160     );
1161     this.images = new ImagesInitDict(notificationGroupedInitDict.images);
1162     this.thumbnails = new ThumbnailsInitDict(notificationGroupedInitDict.thumbnails);
1163     this.actions = new ActionsInitDict(notificationGroupedInitDict.actions);
1164     this.leds = new LedsInitDict(notificationGroupedInitDict.leds);
1165     this.groupContents = new GroupContentsInitDict(
1166         notificationGroupedInitDict.groupContents
1167     );
1168
1169     var _userType =
1170         Object.keys(UserNotificationType).indexOf(userType) >= 0
1171             ? userType
1172             : StatusNotificationType.SIMPLE;
1173
1174     Object.defineProperties(this, {
1175         userType: {
1176             get: function() {
1177                 return _userType;
1178             },
1179             set: function(v) {
1180                 _userType =
1181                     Object.keys(StatusNotificationType).indexOf(v) >= 0 && _edit.canEdit
1182                         ? v
1183                         : _userType;
1184             },
1185             enumerable: true
1186         }
1187     });
1188 }
1189
1190 UserNotification.prototype = new Notification();
1191 UserNotification.prototype.constructor = UserNotification;
1192
1193 function UserNotificationInitDict(data) {
1194     var _textContents = null;
1195     var _images = null;
1196     var _thumbnails = null;
1197     var _actions = null;
1198     var _groupContents = null;
1199     var _leds = null;
1200
1201     Object.defineProperties(this, {
1202         textContents: {
1203             get: function() {
1204                 return _textContents;
1205             },
1206             set: function(v) {
1207                 _textContents = type_.isObject(v) || type_.isNull(v) ? v : _textContents;
1208             },
1209             enumerable: true
1210         },
1211         images: {
1212             get: function() {
1213                 return _images;
1214             },
1215             set: function(v) {
1216                 _images = type_.isObject(v) || type_.isNull(v) ? v : _images;
1217             },
1218             enumerable: true
1219         },
1220         thumbnails: {
1221             get: function() {
1222                 return _thumbnails;
1223             },
1224             set: function(v) {
1225                 _thumbnails = type_.isObject(v) || type_.isNull(v) ? v : _thumbnails;
1226             },
1227             enumerable: true
1228         },
1229         actions: {
1230             get: function() {
1231                 return _actions;
1232             },
1233             set: function(v) {
1234                 _actions = type_.isObject(v) || type_.isNull(v) ? v : _actions;
1235             },
1236             enumerable: true
1237         },
1238         groupContents: {
1239             get: function() {
1240                 return _groupContents;
1241             },
1242             set: function(v) {
1243                 _groupContents =
1244                     type_.isObject(v) || type_.isNull(v) ? v : _groupContents;
1245             },
1246             enumerable: true
1247         },
1248         leds: {
1249             get: function() {
1250                 return _leds;
1251             },
1252             set: function(v) {
1253                 _leds = type_.isObject(v) || type_.isNull(v) ? v : _leds;
1254             },
1255             enumerable: true
1256         }
1257     });
1258
1259     if (data instanceof _global.Object) {
1260         for (var prop in data) {
1261             if (this.hasOwnProperty(prop)) {
1262                 this[prop] = data[prop];
1263             }
1264         }
1265     }
1266 }
1267
1268 exports = new NotificationManager();
1269 tizen.StatusNotification = StatusNotification;
1270 tizen.UserNotification = UserNotification;
1271 tizen.NotificationDetailInfo = NotificationDetailInfo;