merge with master
[platform/framework/web/wrt-plugins-tizen.git] / src / Notification / JSStatusNotification.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include <CommonsJavaScript/Converter.h>
19 #include <CommonsJavaScript/Validator.h>
20 #include <CommonsJavaScript/JSUtils.h>
21 #include <CommonsJavaScript/JSCallbackManager.h>
22 #include <CommonsJavaScript/Utils.h>
23 #include <SecurityExceptions.h>
24 #include <JSTizenExceptionFactory.h>
25 #include <JSTizenException.h>
26 #include "NotificationFactory.h"
27 #include "JSStatusNotification.h"
28 #include "NotificationConverter.h"
29
30 //#include "plugin_config.h"
31
32 using namespace DeviceAPI::Common;
33
34 namespace DeviceAPI {
35 namespace Notification {
36
37
38 JSClassDefinition JSStatusNotification::m_classInfo =
39 {
40         0,
41         kJSClassAttributeNone,
42         "StatusNotification",
43         NULL,
44         m_properties,
45         NULL,
46         initialize,
47         finalize,
48         NULL, 
49         NULL, 
50         NULL, 
51         NULL, 
52         NULL, 
53         NULL,
54         constructor,
55         hasInstance,
56         NULL
57 };
58
59 JSStaticValue JSStatusNotification::m_properties[] = 
60 {
61         {NOTIFICATION_ID,                               JSStatusNotification::getProperty, NULL,        kJSPropertyAttributeReadOnly },
62         {NOTIFICATION_TYPE,                     JSStatusNotification::getProperty, NULL,        kJSPropertyAttributeReadOnly },
63         {NOTIFICATION_POSTED_TIME,              JSStatusNotification::getProperty, NULL,        kJSPropertyAttributeReadOnly },
64         {NOTIFICATION_TITLE,                    JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },
65         {NOTIFICATION_CONTENT,                  JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },
66         
67         {NOTIFICATION_STATUS_TYPE,              JSStatusNotification::getProperty, NULL,        kJSPropertyAttributeReadOnly },
68         {NOTIFICATION_ICON_PATH,                JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },
69         {NOTIFICATION_SOUND_PATH,               JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },
70         {NOTIFICATION_VIBRATION,                JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },
71 #ifdef APPLICATION_API_BACKWARD_COMPATIBILITY
72         {NOTIFICATION_SEVICE,                   JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
73 #endif
74         {NOTIFICATION_APP_CONTROL,              JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },
75         {NOTIFICATION_APP_ID,                   JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
76         {NOTIFICATION_PROGRESS_VALUE,   JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
77         {NOTIFICATION_LINES,    JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
78         {NOTIFICATION_BACKGROUND_IMAGE_PATH,    JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
79         {NOTIFICATION_NUMBER,   JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
80         {NOTIFICATION_THUMBNAILS,       JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
81         {NOTIFICATION_SUB_ICON_PATH,    JSStatusNotification::getProperty, JSStatusNotification::setProperty,   kJSPropertyAttributeNone },     
82         {0, 0, 0, 0}
83 };
84
85 const JSClassRef JSStatusNotification::getClassRef() 
86 {
87         if (!m_jsClassRef) {
88                 m_jsClassRef = JSClassCreate(&m_classInfo);
89         }
90         return m_jsClassRef;
91 }
92
93 const JSClassDefinition* JSStatusNotification::getClassInfo() 
94 {
95         return &m_classInfo;
96 }
97
98 JSClassRef JSStatusNotification::m_jsClassRef = JSClassCreate(JSStatusNotification::getClassInfo());
99
100 void JSStatusNotification::initialize(JSContextRef context, JSObjectRef object) 
101 {
102         LogDebug("JSStatusNotification::initialize, nothing ");
103 }
104
105 void JSStatusNotification::finalize(JSObjectRef object) 
106 {
107         JSStatusNotificationPriv* priv = static_cast<JSStatusNotificationPriv*>(JSObjectGetPrivate(object));
108
109         LogDebug("JSStatusNotification::Finalize");
110
111         if (priv != NULL) 
112         {
113                 JSObjectSetPrivate(object, NULL);
114                 delete priv;
115         }
116 }
117
118 bool JSStatusNotification::hasInstance(JSContextRef context, JSObjectRef constructor,
119                 JSValueRef possibleInstance, JSValueRef* exception) 
120 {
121         return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
122 }
123
124 bool JSStatusNotification::setProperty(JSContextRef context,
125         JSObjectRef object,
126         JSStringRef propertyName,
127         JSValueRef value,
128         JSValueRef* exception)
129 {
130         LogDebug("OK"); 
131
132         JSStatusNotificationPriv* priv = static_cast<JSStatusNotificationPriv*>(JSObjectGetPrivate(object));
133         //NotificationConverter converter(context);
134         NotificationConverterFactory::ConverterType converter =
135                  NotificationConverterFactory::getConverter(context);
136         std::string property = converter->toString(propertyName);
137         LogDebug("Property = " << property);
138         try {
139                 
140                 if (priv == NULL)
141                 {
142                         ThrowMsg(WrtDeviceApis::Commons::ConversionException,"Private Object is null");
143                 }
144
145
146                 INotificationPtr notification(priv->getObject());
147
148                 if (notification == NULL)
149                 {
150                         ThrowMsg(WrtDeviceApis::Commons::ConversionException,"Private Object is null");
151                 }
152
153                 if (property == NOTIFICATION_TITLE)
154                 {
155                         std::string title = converter->toString(value);
156                         notification->setTitle(title);
157                         return true;
158                 }
159                 else if (property == NOTIFICATION_CONTENT)
160                 {
161                         std::string content = converter->toString(value);
162                         notification->setContent(content);
163                         return true;
164                 }
165
166                 else if (property == NOTIFICATION_ICON_PATH)
167                 {
168                         if (JSValueIsUndefined(context, value) || JSValueIsNull(context, value)) 
169                         {
170                                 return true;
171                         }
172                         
173                         std::string iconPath = converter->toString(value);
174                         DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, iconPath);
175                         iconPath = path->getFullPath();
176                 
177                         notification->setIconPath(iconPath);
178                         return true;
179
180                 }
181                 else if (property == NOTIFICATION_SOUND_PATH)
182                 {
183                         if (JSValueIsUndefined(context, value) || JSValueIsNull(context, value)) 
184                         {
185                                 return true;
186                         }
187                         
188                         std::string soundPath = converter->toString(value);
189                         DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, soundPath);
190                         soundPath = path->getFullPath();
191                         
192                         notification->setSoundPath(soundPath);
193                         return true;
194                 }
195                 else if (property == NOTIFICATION_VIBRATION)
196                 {
197                         bool virbration = converter->toBool(value);
198                         notification->setDefaultVibration(virbration);
199                         return true;
200                 }
201                 else if (property == NOTIFICATION_APP_CONTROL
202 #ifdef APPLICATION_API_BACKWARD_COMPATIBILITY
203                                 || property == NOTIFICATION_SEVICE
204 #endif
205                                 )
206                 {
207                         DeviceAPI::Application::ApplicationControlPtr appControl = converter->toIApplicationPtr(value);
208                         notification->setApplicationControl(appControl);
209                         return true;
210                 }
211                 else if (property == NOTIFICATION_APP_ID)
212                 {
213                         std::string appId = converter->toString(value);
214                         notification->setApplicationId(appId);
215                 }
216                 else if (property == NOTIFICATION_PROGRESS_VALUE)
217                 {
218                         unsigned short progressValue = (unsigned short)converter->toULong(value);
219                         NotificationProgressType progressType = notification->getProgressType();
220                         
221                         LogDebug(" progress type = " << progressType << "progressValue = " << progressValue);
222                                                         
223                         if ( NOTI_PROGRESS_TYPE_SIZE == progressType)
224                         {
225                                 notification->setProgressValue(progressValue);
226                         }
227                         else if ( NOTI_PROGRESS_TYPE_PERCENTAGE == progressType)
228                         {
229                                 //check arrang.
230                                 if (  progressValue > 100 )
231                                 {
232                                         ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "progress value error");
233                                 }                                                       
234                                 
235                                 double percentage = (double)progressValue/(double)100;
236                                 LogDebug(" Percentage Value = " << percentage);
237                                 notification->setProgressValue(percentage);
238                         }
239                                                 
240                         return true;
241                 }
242                 
243                 else if (property == NOTIFICATION_LINES)
244                 {
245                         NotificationLineArrayPtr lines = converter->toNotificationLineArray(value);
246                         notification->setLines(lines);
247                 }
248                 else if (property == NOTIFICATION_BACKGROUND_IMAGE_PATH )
249                 {
250                         if (JSValueIsUndefined(context, value) || JSValueIsNull(context, value)) 
251                         {
252                                 return true;
253                         }
254                         
255                         std::string backgroundImagePath = converter->toString(value);
256                         DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, backgroundImagePath); 
257                         backgroundImagePath = path->getFullPath();
258                         notification->setBackground(backgroundImagePath);
259                         return true;
260                 }
261                 else if (property == NOTIFICATION_NUMBER)
262                 {
263                         unsigned int number = converter->toULong(value);
264                         LogDebug("Number is = " << number);
265                         notification->setNumber(number);
266                 }
267                 else if (property == NOTIFICATION_THUMBNAILS)
268                 {
269
270                         StringArrayPtr thumbnailsPtr = converter->toStringArray(value);
271                         notification->setThumbnails(thumbnailsPtr);
272
273                         std::vector<std::string>::iterator it;
274
275                         int idx = 0;
276                         for (it = thumbnailsPtr->begin(); it < thumbnailsPtr->end(); ++it)
277                         {
278                                 std::string str = *it;
279                                 LogDebug(" thumbs : " << str);
280                                 DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, str);
281                                 str = path->getFullPath();
282
283                                 LogDebug(" thumbs : " << str);
284                                 notification->setThumbnail(str, idx);
285                                 idx ++;
286                         }
287                         
288                 }
289                 else if (property == NOTIFICATION_SUB_ICON_PATH )
290                 {
291                         if (JSValueIsUndefined(context, value) || JSValueIsNull(context, value)) 
292                         {
293                                 return true;
294                         }
295                         
296                         std::string subIconPath = converter->toString(value);
297                         DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, subIconPath); 
298                         subIconPath = path->getFullPath();
299                         notification->setSubIconPath(subIconPath);
300                         return true;
301                 }
302                 else 
303                 {
304                         ThrowMsg(WrtDeviceApis::Commons::ConversionException,"No attribute");
305                 }
306                 
307         }
308         Catch (WrtDeviceApis::Commons::ConversionException)
309         {
310                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
311                 return JSTizenExceptionFactory::postException(context, exception, 
312                                         JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
313
314         }
315         Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
316         {
317                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
318                 return JSTizenExceptionFactory::postException(context, exception,
319                         JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());      
320         }
321         Catch(WrtDeviceApis::Commons::UnsupportedException)
322         {
323                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
324                 return JSTizenExceptionFactory::postException(context, exception,
325                                 JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
326         }
327         Catch (WrtDeviceApis::Commons::Exception) 
328         {
329                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
330                 return JSTizenExceptionFactory::postException(context, exception, 
331                         JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
332         }
333
334         return false;
335 }
336
337 JSValueRef JSStatusNotification::getProperty(JSContextRef context,
338                                                                                 JSObjectRef object,
339                                                                                 JSStringRef propertyName,
340                                                                                 JSValueRef* exception)
341 {
342         LogDebug("OK"); 
343
344         JSStatusNotificationPriv* priv = static_cast<JSStatusNotificationPriv*>(JSObjectGetPrivate(object));
345         //NotificationConverter converter(context);
346         NotificationConverterFactory::ConverterType converter =
347                NotificationConverterFactory::getConverter(context);
348         std::string property = converter->toString(propertyName);
349
350         LogDebug("property = " << property);
351
352         try {
353                 
354                 if (priv == NULL)
355                 {
356                         ThrowMsg(WrtDeviceApis::Commons::ConversionException,"Private Object is null");
357                 }
358                 
359                 INotificationPtr notification(priv->getObject());
360
361                 if (notification == NULL)
362                 {
363                         ThrowMsg(WrtDeviceApis::Commons::ConversionException,"Private Object is null");
364                 }
365
366                 if (property == NOTIFICATION_ID)
367                 {
368                         LogDebug(" ID : " << notification->getID());
369                         int id = notification->getID();
370                         if (id >= 0)
371                         {
372                                 std::stringstream stream;
373                                 stream << id;
374                                 
375                                 return converter->toJSValueRef(stream.str());
376                         }
377                         else
378                         {
379                                 return JSValueMakeNull(context);
380                         }
381                         
382                         return converter->toJSValueRef(notification->getID());
383                 }
384                 else if (property == NOTIFICATION_TYPE)
385                 {
386                         LogDebug(" TYPE : " << notification->getNotiType());
387                         return converter->toJSValueRef(notification->getNotiType());
388                 }
389                 else if (property == NOTIFICATION_POSTED_TIME)
390                 {       
391                         LogDebug("notification =" << notification) ;
392                         time_t postedTime = notification->getPostedTime();
393                         
394                         LogDebug("postedtime = " << postedTime);
395                         
396                         if (postedTime)
397                                 return converter->toJSValueRef(postedTime);
398                         else
399                                 return JSValueMakeNull(context);
400                 }
401                 else if (property == NOTIFICATION_TITLE)
402                 {
403                         std::string title = notification->getTitle();
404                         LogDebug(" Title : " << title);
405                         return converter->toJSValueRef(title);
406                 }
407                 else if (property == NOTIFICATION_CONTENT)
408                 {
409                         std::string content = notification->getContent();
410
411                         if (content.size() == 0)
412                                 return JSValueMakeNull(context);
413                                 
414                         LogDebug(" Content : " << content);
415                         
416                         return converter->toJSValueRef(content);
417                 }
418                 else if (property == NOTIFICATION_STATUS_TYPE)
419                 {
420                         //std::string statusType = notification->getStatusType();
421                         LogDebug(" NOTIFICATION_STATUS_TYPE : " << notification->getNotiType());
422                         return converter->toJSValueRef(notification->getNotiType());
423                 }
424                 else if (property == NOTIFICATION_ICON_PATH)
425                 {
426                         std::string iconPath = notification->getIconPath();
427                         LogDebug(" IconPath : " << iconPath);
428                         if (iconPath.empty())
429                                 return JSValueMakeNull(context);
430                         
431                         iconPath = DeviceAPI::Filesystem::Utils::toVirtualPath(context, iconPath);
432                         
433                         return converter->toJSValueRef(iconPath);
434                 }
435                 else if (property == NOTIFICATION_SOUND_PATH)
436                 {
437                         std::string soundPath = notification->getSoundPath();
438                         LogDebug(" NOTIFICATION_SOUND_PATH : " << soundPath);
439                         if (soundPath.empty())
440                                 return JSValueMakeNull(context);
441                                                 
442                         soundPath = DeviceAPI::Filesystem::Utils::toVirtualPath(context, soundPath);
443                                                 
444                         return converter->toJSValueRef(soundPath);
445                 }
446                 else if (property == NOTIFICATION_VIBRATION)
447                 {
448                         bool virbration = notification->getDefaultVibration();
449                         LogDebug(" NOTIFICATION_VIBRATION : " << virbration);
450                         return converter->toJSValueRef(virbration);
451                 }
452                 else if (property == NOTIFICATION_APP_ID)
453                 {
454                         std::string appid = notification->getApplicationId();
455                         LogDebug(" NOTIFICATION_APP_ID : " << appid);
456                         return converter->toJSValueRef(appid);
457                 }
458                 else if (property == NOTIFICATION_APP_CONTROL
459 #ifdef APPLICATION_API_BACKWARD_COMPATIBILITY
460                                 || property == NOTIFICATION_SEVICE
461 #endif
462                                 )
463                 {
464                         DeviceAPI::Application::ApplicationControlPtr appControl = notification->getApplicationControl();
465                         return converter->toJSValueRef(appControl);
466                 }
467                 else if (property == NOTIFICATION_PROGRESS_VALUE)
468                 {
469                         double progress = notification->getProgressValue();
470                         NotificationProgressType progressType = notification->getProgressType();
471                         LogDebug(" progress type = " << progressType << " progress = " << progress);
472
473                         int progressValue = 0;
474                                 
475                         if ( NOTI_PROGRESS_TYPE_SIZE == progressType)
476                         {
477                                 progressValue = int(progress);
478                         }
479                         else if ( NOTI_PROGRESS_TYPE_PERCENTAGE == progressType)
480                         {
481                                 progressValue = int(progress*100 + 0.01);
482                         }
483                         LogDebug("ProgressValue = " << progressValue);
484                         
485                         //int progressValue = int (progress);
486                         //LogDebug("progress = " << progress << " value = " << progressValue);
487                         
488                         return converter->toJSValueRef(progressValue);
489                 }
490                 else if (property == NOTIFICATION_LINES)
491                 {
492                         if (notification->getLines())
493                                 return converter->toJSValueRef(notification->getLines());
494                         else
495                                 return JSValueMakeNull(context);
496                 }
497                 else if (property == NOTIFICATION_BACKGROUND_IMAGE_PATH )
498                 {
499                         std::string strBackground = notification->getBackground();
500                         LogDebug(" NOTIFICATION_BACKGROUND_PATH : " << strBackground);
501                         if (strBackground.empty())
502                                 return JSValueMakeNull(context);
503                                                 
504                         strBackground = DeviceAPI::Filesystem::Utils::toVirtualPath(context, strBackground);
505                         return converter->toJSValueRef(strBackground);
506                 }
507                 else if (property == NOTIFICATION_NUMBER)
508                 {
509                         unsigned int number = notification->getNumber();
510                         LogDebug(" NUMBER : " << notification->getNumber());
511                         return converter->toJSValueRef(number);
512                 }
513                 else if (property == NOTIFICATION_THUMBNAILS)
514                 {
515                         return converter->toJSValueRef(notification->getThumbnails());
516                 }
517                 else if (property == NOTIFICATION_SUB_ICON_PATH )
518                 {
519                         std::string strSubIcon = notification->getSubIconPath();
520                         LogDebug(" NOTIFICATION_SUB_ICON_PATH : " << strSubIcon);
521                         if (strSubIcon.empty())
522                                 return JSValueMakeNull(context);
523                                                 
524                         strSubIcon = DeviceAPI::Filesystem::Utils::toVirtualPath(context, strSubIcon);
525                         return converter->toJSValueRef(strSubIcon);
526                 }
527                 else 
528                 {
529                         ThrowMsg(WrtDeviceApis::Commons::ConversionException,"No attribute");
530                 }
531                 
532         }
533         Catch (WrtDeviceApis::Commons::NullPointerException)
534         {
535                 if (property == NOTIFICATION_POSTED_TIME || property == NOTIFICATION_APP_CONTROL
536         #ifdef APPLICATION_API_BACKWARD_COMPATIBILITY
537                                         || property == NOTIFICATION_SEVICE
538         #endif
539                         )
540                 {
541                         return JSValueMakeNull(context);
542                 }
543                 else 
544                 {
545                         LogWarning("Exception: "<<_rethrown_exception.GetMessage());
546                         return JSTizenExceptionFactory::postException(context, exception, 
547                                                 JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
548                 }
549         }
550         Catch (WrtDeviceApis::Commons::ConversionException)
551         {
552                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
553                 return JSTizenExceptionFactory::postException(context, exception, 
554                                         JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
555
556         }
557         Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
558         {
559                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
560                 return JSTizenExceptionFactory::postException(context, exception,
561                         JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());      
562         }
563         Catch(WrtDeviceApis::Commons::UnsupportedException)
564         {
565                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
566                 return JSTizenExceptionFactory::postException(context, exception,
567                                 JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
568         }
569         Catch (WrtDeviceApis::Commons::Exception) 
570         {
571                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
572                 return JSTizenExceptionFactory::postException(context, exception, 
573                         JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
574         }       
575
576 }
577
578
579 JSObjectRef JSStatusNotification::createJSObject(JSContextRef context, INotificationPtr notification)
580 {
581         JSStatusNotificationPriv* priv = new JSStatusNotificationPriv( context, notification);
582         return JSObjectMake(context, getClassRef(), priv);
583 }
584
585
586 JSObjectRef JSStatusNotification::constructor(JSContextRef context,
587     JSObjectRef constructor,
588     size_t argumentCount,
589     const JSValueRef arguments[],
590     JSValueRef* exception)
591 {
592         LogDebug("OK"); 
593         //NotificationConverter converter(context);
594         NotificationConverterFactory::ConverterType converter =
595                 NotificationConverterFactory::getConverter(context);
596         JSValueRef reserveArguments[3];
597         size_t index = 0;
598         JSStatusNotificationPriv* priv = NULL;
599
600         Try     
601         {
602                 for (index = 0; index < 3; index++)
603                 {
604                         if (index < argumentCount)
605                                 reserveArguments[index] = arguments[index];
606                         else 
607                                 reserveArguments[index] = JSValueMakeUndefined(context);                                
608                 }
609
610                 std::string statusType = converter->toString(reserveArguments[0]);
611         
612                 //create notification private object.
613                 INotificationPtr notification = NotificationFactory::getInstance().getNotification(converter->toNotificationType(reserveArguments[0]));                 
614                 priv = new JSStatusNotificationPriv(context, notification);
615
616                 LogDebug("notification=" << notification);
617                 
618 #if 0
619                 if (statusType == "ONGOING" || statusType == "PROGRESS") 
620                 {
621                         notification.Reset();
622                         INotificationPtr newNotification(
623                         NotificationFactory::getInstance().getNotification(TRUE));
624                         notification = newNotification;
625
626                         if (priv)
627                         {
628                                 delete priv;
629                                 priv = new JSStatusNotificationPriv(context, notification);
630                         }
631                 }
632 #endif          
633                 //notification->setStatusType(converter.toString(reserveArguments[0]));
634                 //notification->setNotiType(converter.toNotificationType(reserveArguments[0]));         
635                 
636                 notification->setTitle(converter->toString(reserveArguments[1]));
637
638                 if (!JSValueIsUndefined(context, reserveArguments[2]))
639                 {       
640                         converter->toNotificationFromDict(notification, reserveArguments[2]);
641                 }
642                 
643                 return JSObjectMake(context, getClassRef(), priv);
644         }
645         Catch (WrtDeviceApis::Commons::Exception) 
646         {
647                 if (priv != NULL) 
648                 {                       
649                         delete priv;
650                 }
651                 LogWarning("Exception: "<<_rethrown_exception.GetMessage());
652                 *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
653         }
654         
655         return NULL;
656 }
657
658 INotificationPtr JSStatusNotification::getNotification(JSContextRef context, JSValueRef value)
659 {
660         JSObjectRef object = JSValueToObject(context, value, NULL);
661         if (!object) 
662         {
663                 Throw(WrtDeviceApis::Commons::InvalidArgumentException);
664         }
665         JSStatusNotificationPriv *priv = static_cast<JSStatusNotificationPriv*>(JSObjectGetPrivate(object));
666         
667         if (!priv) 
668         {
669                 Throw(WrtDeviceApis::Commons::NullPointerException);
670         }
671         return priv->getObject();
672 }
673
674
675 }
676 }
677