Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Notification / StatusNotification.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 <cassert>
19 #include <Commons/Exception.h>
20 #include <sstream>
21 #include <notification.h>
22 #include <appsvc/appsvc.h>
23 #include "StatusNotification.h"
24 #include <FilesystemUtils.h>
25
26
27 namespace DeviceAPI {
28 namespace Notification{
29
30 #define DEFAULT_ICON_PATH "/opt/share/icons/default/"
31 #define MAX_NOTIFICATION_LINE_LENGTH 2
32 #define MAX_THUMBNAIL_LENGTH 4
33
34 extern "C" int service_create_event(bundle *data, struct service_s **service);
35 extern "C" int service_to_bundle(service_h service, bundle **data);
36
37 #if 0
38 static void service_bundle_iterator(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
39 {
40         service_h service = (service_h)user_data;
41         LogDebug("key = " << key);
42         LogDebug(" type = " << type);
43         void *basic_val = NULL;
44         size_t basic_size = 0;
45         
46         if (bundle_keyval_type_is_array((bundle_keyval_t*)kv))
47         {
48                 LogDebug("Array");
49         }
50         else
51         {
52                 bundle_keyval_get_basic_val((bundle_keyval_t*)kv, &basic_val, &basic_size);
53                 
54                 service_add_extra_data(service, key, );
55         }
56 }
57 #endif
58
59 StatusNotification::StatusNotification(NotificationType statusType) :
60         m_notiHandle(NULL),
61         m_service(NULL),
62         m_lines(NULL)
63 {       
64         notification_type_e type = NOTIFICATION_TYPE_NONE;
65
66         LogDebug("statusType =" << statusType);
67         setNotiType(statusType);
68         
69         if (statusType == NOTI_TYPE_SIMPLE || statusType == NOTI_TYPE_MUTIPLE || statusType == NOTI_TYPE_THUMBNAIL)
70         {
71                 type = NOTIFICATION_TYPE_NOTI;
72         }
73         else if ( statusType == NOTI_TYPE_ONGOING || statusType == NOTI_TYPE_PROGRESS)
74         {
75                 type = NOTIFICATION_TYPE_ONGOING;
76         }
77         else
78         {
79                 LogDebug(" invalide noti type");
80                 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Error : noti type");
81         }
82
83         setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
84         
85         LogDebug("Notification Type : " << type);
86         
87         notification_h noti = NULL;
88         noti = notification_create(type);       //create notificatin.
89         if ( noti )
90         {
91                 LogDebug("noti =" << noti);
92                 setNotificationHandle((void*)noti);
93                 setNotificationState(NOTI_STATE_CREATED);
94         }
95         m_lines = NotificationLineArrayPtr(new NotificationLineArray());
96         m_thumbs = StringArrayPtr(new StringArray());
97                 
98 }
99
100 StatusNotification::StatusNotification(void* noti) :
101         m_notiHandle(NULL),
102         m_service(NULL),
103         m_lines(NULL)
104 {
105         LogDebug("noti : " << noti);
106         notification_h notification = (notification_h)noti;
107         
108         if ( notification )
109         {
110                 NotificationType type = NOTI_TYPE_NONE; 
111                 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
112                 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
113                 
114                 notification_get_type(notification, &noti_type);
115                 notification_get_layout(notification, &noti_layout);
116                 
117                 if ( noti_type == NOTIFICATION_TYPE_NOTI )
118                 {
119                         if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE || 
120                                 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
121                         {
122                                 type = NOTI_TYPE_SIMPLE;
123                         }
124                         else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
125                         {
126                                 type = NOTI_TYPE_THUMBNAIL;
127                         }
128                 }
129                 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
130                 {
131                         if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
132                         {
133                                 type = NOTI_TYPE_ONGOING;
134                         }
135                         else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
136                         {
137                                 type = NOTI_TYPE_PROGRESS;
138                         }
139                 }
140
141                 LogDebug(" notification type  =" << type);
142                 setNotiType(type);
143                 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.      
144                 setNotificationHandle((void*)notification);
145
146                 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
147                 m_thumbs = StringArrayPtr(new StringArray());
148
149                 setNotificationLines();
150                 setNotificationState(NOTI_STATE_CREATED);
151
152                 //service
153                 bundle *bSvc = NULL;
154
155                 int ret =  notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
156                 LogDebug("ret = " << ret); 
157                 if (ret == NOTIFICATION_ERROR_NONE)
158                 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
159                 {
160                         LogDebug(" bundle = " << bSvc);
161                         if (bSvc)
162                         {
163                                 LogDebug("bundle is valid");    
164                                 int ret = service_create_event(bSvc, &m_service);
165                                 if (ret != SERVICE_ERROR_NONE)
166                                 {
167                                         LogDebug("Service Create Event Error");
168                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
169                                 }
170
171 #if 0
172                                 const char *tmpStr = NULL;
173                                 if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
174                                 {
175                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
176                                 }
177                                 
178                                 tmpStr = appsvc_get_operation(bSvc);
179                                 if (tmpStr)
180                                 {
181                                         LogDebug("operation = " << tmpStr);
182                                         if (tmpStr)
183                                         {
184                                                 if (service_set_operation(m_service, tmpStr) != SERVICE_ERROR_NONE)
185                                                 {
186                                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
187                                                 }
188                                         }
189                                         else if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
190                                         {
191                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
192                                         }
193                                         tmpStr = NULL;  
194                                 }
195
196                                 else 
197                                 {
198                                         if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
199                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
200                                 }
201                                 
202                                 tmpStr = appsvc_get_uri(bSvc);
203                                 if (tmpStr)
204                                 {
205                                         LogDebug("uri = " << tmpStr);
206                                         if (service_set_uri(m_service, tmpStr) != SERVICE_ERROR_NONE)
207                                         {
208                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
209                                         }
210                                         tmpStr = NULL;
211                                 }
212                                 
213                                 tmpStr = appsvc_get_mime(bSvc);
214                                 if(tmpStr)
215                                 {
216                                         LogDebug("mime = " << tmpStr);
217                                         if (service_set_mime(m_service, tmpStr) != SERVICE_ERROR_NONE)
218                                         {
219                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
220                                         }
221                                         tmpStr = NULL;
222                                 }
223                 
224                                 tmpStr = appsvc_get_category(bSvc);
225                                 if(tmpStr)
226                                 {
227                                         LogDebug("category = " << tmpStr);
228                                         if (service_set_category(m_service, tmpStr) != SERVICE_ERROR_NONE)
229                                         {
230                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set category error");
231                                         }
232                                         tmpStr = NULL;
233                                 }
234                                 
235                                 //extra option
236                                 bundle_foreach(bSvc, service_bundle_iterator, m_service); 
237 #endif
238                                 bundle_free(bSvc); //bundle free
239                         }
240                 }
241         }
242 }
243
244 StatusNotification::StatusNotification(int privID) :
245                 m_notiHandle(NULL),
246                 m_service(NULL),
247                 m_lines(NULL)
248 {
249         LogDebug("priv ID : " << privID);
250         
251         notification_h notification = notification_load( NULL, privID);
252         LogDebug(" notification " << notification);
253         
254         if ( notification )
255         {
256                 NotificationType type = NOTI_TYPE_NONE; 
257                 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
258                 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
259                 
260                 notification_get_type(notification, &noti_type);
261                 notification_get_layout(notification, &noti_layout);
262                 
263                 if ( noti_type == NOTIFICATION_TYPE_NOTI )
264                 {
265                         if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE || 
266                                 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
267                         {
268                                 type = NOTI_TYPE_SIMPLE;
269                         }
270                         else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
271                         {
272                                 type = NOTI_TYPE_THUMBNAIL;
273                         }
274                 }
275                 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
276                 {
277                         if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
278                         {
279                                 type = NOTI_TYPE_ONGOING;
280                         }
281                         else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
282                         {
283                                 type = NOTI_TYPE_PROGRESS;
284                         }
285                 }
286
287                 LogDebug(" notification type  =" << type);
288                 setNotiType(type);
289                 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.      
290                 setNotificationHandle((void*)notification);
291
292                 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
293                 m_thumbs = StringArrayPtr(new StringArray());
294
295                 setNotificationLines();
296                 setNotificationState(NOTI_STATE_CREATED);
297
298                 //service
299                 bundle *bSvc = NULL;
300
301                 int ret =  notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
302                 LogDebug("ret = " << ret); 
303                 if (ret == NOTIFICATION_ERROR_NONE)
304                 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
305                 {
306                         LogDebug(" bundle = " << bSvc);
307                         if (bSvc)
308                         {
309                                 LogDebug("bundle is valid");    
310                                 int ret = service_create_event(bSvc, &m_service);
311                                 if (ret != SERVICE_ERROR_NONE)
312                                 {
313                                         LogDebug("Service Create Event Error");
314                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
315                                 }
316                                 
317                                 //bundle_free(bSvc); //bundle free
318                         }
319                 }
320         }
321         else
322         {
323                 LogDebug(" can't find notification");
324                 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Can't find noti");
325         }
326         
327 }
328
329
330 StatusNotification::~StatusNotification() 
331 {
332         LogDebug(" notification = " << m_notiHandle);
333
334         if (m_notiHandle)
335         {
336                 if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
337                 {
338                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
339                 }
340
341 #if 0
342                 LogDebug(" service = " << m_service);
343                 if (m_service != NULL)
344                 {
345                         service_destroy(m_service);
346                         m_service = NULL;
347                 }
348 #endif
349                 m_notiHandle = NULL;
350         }
351 }
352
353 namespace {
354         
355 static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
356 {
357         LogDebug("OK");
358         char **value = NULL;
359         int length = 0;
360
361         if (user_data != NULL && key != NULL)
362         {       
363                 LogDebug("user data & key is existed");
364
365                 DeviceAPI::Application::ApplicationControlPtr* appControl = 
366                         (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
367
368                 DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
369                 LogDebug("key = " << key);
370                 std::string keyStr = key;
371                 std::vector<std::string> keyValue;
372                 int index = 0;
373
374                 if (service_get_extra_data_array((*appControl)->getService_h(), key, &value, &length) == SERVICE_ERROR_NONE)
375                 {
376                         LogDebug("extra_data_array length = " << length);
377                         
378                         if (value != NULL && length != 0)
379                         {
380                                 LogDebug("extra_data_length = " << length);
381                                 data->setKey(key);
382                                 for (index = 0; index < length; index++)
383                                 {
384                                         LogDebug("Value=" << value[index]);
385                                         keyValue.push_back(value[index]);
386                                 }
387                                 
388                                 data->setValue(keyValue);
389                                 (*appControl)->addAppControlData(data);
390                         }
391                         
392                         if(value)
393                                 free(value);
394                 }
395         }
396         return true;
397 }
398
399 static bool service_extra_data_delete_cb(service_h service, const char *key, void *user_data)
400 {
401         LogDebug("OK");
402         if (key != NULL)
403         {       
404                 LogDebug("del key = " << key);
405                 
406                 if (service_remove_extra_data(service, key) != SERVICE_ERROR_NONE)
407                 {
408                         LogDebug("remove extra data failed");
409                         return false;
410                 }
411         }
412         return true;
413 }
414
415
416
417 }//namespace
418
419 int StatusNotification::getID()
420 {
421         if (m_notiHandle)
422         {
423                 int id = 0;
424                 notification_get_id(m_notiHandle, NULL, &id);
425                 return id;
426         }
427         else
428         {
429                 return -1;      // notification not inserted yet.
430         }
431 }
432
433 time_t StatusNotification::getPostedTime()
434 {
435         LogDebug("get m_notiHandle = " << m_notiHandle);
436         
437         time_t postedTime = 0;
438         
439         if (m_notiHandle)
440         {                       
441                 if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
442                 {
443                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification posted time error");
444                 }
445         }
446         
447         LogDebug("posted Time =" << ctime(&postedTime));
448         return postedTime;
449 }
450
451 std::string StatusNotification::getTitle()
452 {
453         if (m_notiHandle)
454         {
455                 char *title = NULL;
456         
457                 if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
458                 {
459                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
460                 }
461
462                 std::string notiTitle(title);
463                 return notiTitle;               
464         }
465         else
466         {
467                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
468         }
469 }
470
471 void StatusNotification::setTitle(std::string title)
472 {
473         LogDebug("Title : " << title);
474         if (m_notiHandle)
475         {
476                 LogDebug("get Title : " << getTitle());
477                 if((getTitle()).compare(title)) //different value.
478                 {
479                         if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(), 
480                                 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
481                         {
482                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification title error");
483                         }
484                         
485                         setUpdatedFlag(true);
486                 }
487                 else
488                 {
489                         LogDebug(" title = " << title << " getTitle = " << getTitle());
490                 }
491         }
492         else
493         {       
494                 LogDebug("noti Handle is NULL");
495                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
496         }
497 }
498
499 std::string StatusNotification::getContent()
500 {
501         LogDebug("get Content : " << m_notiHandle);
502         if (m_notiHandle)
503         {
504                 char *content = NULL;
505
506                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
507                 {
508                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification Content error");
509                 }
510                 
511                 LogDebug(" get Content : " << content);
512                 
513                 if(content)
514                 {
515                         std::string notiContent(content);
516                         return notiContent;             
517                 }
518                 else
519                 {
520                         return std::string("");
521                 }
522         }
523         else
524         {
525                 LogDebug("noti Handle is NULL");
526                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
527         }
528         
529 }
530
531 void StatusNotification::setContent(std::string content)
532 {
533         LogDebug("Content : " << content);
534         if (m_notiHandle)
535         {
536                 if((getContent()).compare(content))     //different value.
537                 {
538                         if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
539                                 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
540                         {
541                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification content error");
542                         }
543                         setUpdatedFlag(true);
544                 }
545         }
546         else
547         {       
548                 LogDebug("noti Handle is NULL");
549                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
550         }
551 }
552         
553 std::string StatusNotification::getIconPath()
554 {
555         if (m_notiHandle)
556         {
557                 char *iconPath = NULL;
558         
559                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON,  &iconPath) != NOTIFICATION_ERROR_NONE)
560                 {
561                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification icon path error");
562                 }
563
564                 std::string notiIconPath(iconPath);
565                 LogDebug("icon Path = " << iconPath);
566                 
567                 //if icon path invalid, return empty string.
568                 if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
569                         return notiIconPath;    
570                 else
571                 {
572                         return std::string("");         
573                 }
574         }
575         else
576         {
577                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
578         }
579 }
580
581 void StatusNotification::setIconPath(const std::string& iconPath)
582 {
583         if (m_notiHandle)
584         {
585                 LogDebug("icon path = " << iconPath << " origin icon path = " << getIconPath());
586                 if( getIconPath().compare(iconPath))
587                 {
588                         if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
589                         {
590                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
591                         }
592                         setUpdatedFlag(true);
593                 }
594         }
595         else
596         {       
597                 LogDebug("noti Handle is NULL");
598                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
599         }
600 }
601
602 std::string StatusNotification::getSoundPath()
603 {
604         if (m_notiHandle)
605         {
606                 const char *soundPath = NULL;
607                 notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
608                 
609                 if (notification_get_sound(m_notiHandle, &type,  &soundPath) != NOTIFICATION_ERROR_NONE)
610                 {
611                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sound error");
612                 }
613
614                 LogDebug(" sound type = " << type << " path = " << soundPath);
615                 
616                 if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
617                 {
618                         LogDebug("soundPath = " << soundPath);
619                         return std::string(soundPath); 
620                 }
621                 else
622                 {
623                         return std::string("");
624                 }
625         }
626         else
627         {
628                 LogDebug("noti Handle is NULL");
629                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
630         }
631 }
632
633 void StatusNotification::setSoundPath(const std::string& sound)
634 {
635         if (m_notiHandle)
636         {
637                 LogDebug("sound path = " << sound << " origin sound path = " << getSoundPath());
638                 
639                 if( getSoundPath().compare(sound))
640                 {
641                         if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
642                         {
643                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
644                         }
645                         setUpdatedFlag(true);
646                 }
647         }
648         else
649         {       
650                 LogDebug("noti Handle is NULL");
651                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
652         }
653 }
654
655 bool StatusNotification::getDefaultVibration()
656 {
657         if (m_notiHandle)
658         {
659                 notification_vibration_type_e vib_type;
660                 if (notification_get_vibration(m_notiHandle, &vib_type,  NULL) != NOTIFICATION_ERROR_NONE)
661                 {
662                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
663                 }
664
665                 if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT)
666                 {
667                         return true;
668                 }
669                 else
670                 {
671                         return false;
672                 }
673         }
674         else
675         {
676                 LogDebug("noti Handle is NULL");
677         }
678
679         return false;
680 }
681
682 void StatusNotification::setDefaultVibration(const bool& vibration) 
683 {
684         if (m_notiHandle)
685         {
686                 notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
687                 
688                 if (getDefaultVibration() != vibration)
689                 {
690                         if (vibration)
691                         {
692                                 vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
693                         }
694                         
695                         if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
696                         {
697                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
698                         }
699                         setUpdatedFlag(true);
700                 }
701         }
702         else
703         {
704                 LogDebug("noti Handle is NULL");
705                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
706         }
707
708 }
709
710 double StatusNotification::getProgressValue() 
711 {
712         double value = 0.0;
713         
714         if (m_notiHandle)
715         {
716                 NotificationProgressType progressType = getProgressType();
717         
718                 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
719                 {
720                         if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
721                         {
722                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification size error");
723                         }
724                 }
725                 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
726                 {
727                         if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
728                         {
729                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
730                         }
731                 }
732                 else
733                 {
734                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
735                 }
736         }
737         else
738         {
739                 LogDebug("noti Handle is NULL");
740         }
741
742         return value;
743         
744 }
745
746 void StatusNotification::setProgressValue(const double &progressValue)
747 {
748         LogDebug(" ");
749         if (m_notiHandle)
750         {       
751                 NotificationProgressType progressType = getProgressType();
752                 LogDebug("Progress Type : " << progressType);
753
754                 double val = getProgressValue();
755                 LogDebug("Progress value = " << progressValue << " origin Progress Value =" << val);
756                 
757                 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
758                 {
759                         if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
760                         {
761                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification size error");
762                         }
763                 }
764                 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
765                 {       
766                 
767                         if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
768                         {
769                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification progress error");
770                         }
771                 }
772                 else
773                 {
774                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
775                 }
776         }
777         else
778         {
779                 LogDebug("noti Handle is NULL");
780                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
781         }
782 }
783         
784 std::string StatusNotification::getSubIconPath()
785 {
786         if (m_notiHandle)
787         {
788                 char *subIconPath = NULL;
789         
790                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB,  &subIconPath) != NOTIFICATION_ERROR_NONE)
791                 {
792                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub icon error");
793                 }
794
795                 std::string notiSubIconPath;
796                 if(subIconPath)
797                         notiSubIconPath = subIconPath;
798                 return notiSubIconPath; 
799         }
800         else
801         {
802                 return std::string("");
803         }
804
805 }
806
807 void StatusNotification::setSubIconPath(const std::string& subIconPath)
808 {
809         if (m_notiHandle)
810         {
811                 LogDebug(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());     
812
813                 if( getSubIconPath().compare(subIconPath))
814                 {
815                         if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
816                         {
817                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
818                         }
819                         setUpdatedFlag(true);
820                 }
821         }
822         else
823         {       
824                 LogDebug("noti Handle is NULL");
825                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
826         }
827 }
828
829 std::vector<std::string> StatusNotification::getInformations()
830 {
831
832         std::vector<std::string> infos;
833
834         if (m_notiHandle)
835         {
836                 
837                 char *info = NULL;
838                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, &info) != NOTIFICATION_ERROR_NONE)
839                 {
840                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
841                 }
842                 
843                 if (info)
844                         infos.push_back(info);                  //info 1 
845                 else
846                         infos.push_back(std::string(""));               // insert empty String
847                 info = NULL;
848                 
849                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, &info) != NOTIFICATION_ERROR_NONE)
850                 {
851                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
852                 }       
853         
854                 if (info)
855                         infos.push_back(info);                  //info 2 
856                 else
857                         infos.push_back(std::string(""));               // insert empty String
858                 info = NULL;
859 #if 0
860                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_3, &info) != NOTIFICATION_ERROR_NONE)
861                 {
862                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
863                 }       
864
865                 if (info)
866                         infos.push_back(info);                  //info 3 
867                 else
868                         infos.push_back(std::string(""));               // insert empty String
869 #endif
870                 info = NULL;
871
872         }
873         else
874         {       
875                 LogDebug("noti Handle is NULL");
876                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
877         }
878
879         return infos;
880 }
881
882 std::string StatusNotification::getInformation(int index)
883 {
884         if (m_notiHandle)
885         {
886                 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
887                 switch (index)
888                 {
889                         case 0:
890                                 type = NOTIFICATION_TEXT_TYPE_INFO_1;
891                                 break;
892                         case 1:
893                                 type = NOTIFICATION_TEXT_TYPE_INFO_2;
894                                 break;
895                         case 2:
896                                 type = NOTIFICATION_TEXT_TYPE_INFO_3;
897                                 break;
898                         default :
899                                 type = NOTIFICATION_TEXT_TYPE_NONE;
900                 }
901                 char *info = NULL;
902                 
903                 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
904                 {
905                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
906                 }
907
908                 std::string strInfo;
909                 if (info)
910                         strInfo = info;
911                 LogDebug(" info " << strInfo);
912                 return strInfo;
913
914         }
915         else
916         {       
917                 LogDebug("noti Handle is NULL");
918                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
919         }
920         
921 }
922
923 void StatusNotification::setInformations( std::vector<std::string>& infos)
924 {
925         
926         if (m_notiHandle)
927         {
928                 std::vector<std::string>::iterator it;
929
930                 int idx = 0;
931                 for (it = infos.begin(); it != infos.end(); ++it) 
932                 {
933                         std::string str = *it;
934                         LogDebug(" Info : " << str);
935
936                         notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
937                         switch (idx)
938                         {
939                                 case 0:
940                                         type = NOTIFICATION_TEXT_TYPE_INFO_1;
941                                         break;
942                                 case 1:
943                                         type = NOTIFICATION_TEXT_TYPE_INFO_2;
944                                         break;
945                                 case 2:
946                                         type = NOTIFICATION_TEXT_TYPE_INFO_3;
947                                         break;
948                                 default :
949                                         type = NOTIFICATION_TEXT_TYPE_NONE;
950                         }
951
952                         if ( type != NOTIFICATION_TEXT_TYPE_NONE)
953                         {
954                                 if (getInformation(idx).compare(str))
955                                 {
956                                         if (notification_set_text(m_notiHandle, type, str.c_str(),
957                                                 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
958                                         {
959                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification information error");
960                                         }
961                                         setUpdatedFlag(true);
962                                 }
963                         }
964                         idx ++;
965                 }
966                 
967
968         }
969         else
970         {       
971                 LogDebug("noti Handle is NULL");
972                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
973         }
974         
975 }
976
977 void StatusNotification::setInformation( const std::string& info, int index)
978 {
979
980         if (m_notiHandle)
981         {
982                 int idx = index;
983                 LogDebug(" index : " << idx);
984                 LogDebug(" log : " << info);
985                 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
986                 
987                 switch (idx)
988                 {
989                         case 0:
990                                 type = NOTIFICATION_TEXT_TYPE_INFO_1;
991                                 break;
992                         case 1:
993                                 type = NOTIFICATION_TEXT_TYPE_INFO_2;
994                                 break;
995                         case 2:
996                                 type = NOTIFICATION_TEXT_TYPE_INFO_3;
997                                 break;
998                         default :
999                                 type = NOTIFICATION_TEXT_TYPE_NONE;
1000                 }
1001
1002                 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1003                 {
1004                         if (getInformation(idx).compare(info))
1005                         {
1006                                 if (notification_set_text(m_notiHandle, type, info.c_str(),
1007                                         NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1008                                 {
1009                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1010                                 }
1011                                 setUpdatedFlag(true);
1012                         }
1013                 }
1014         }
1015 }
1016
1017 std::vector<std::string> StatusNotification::getSubInformations()
1018 {
1019         std::vector<std::string> subInfos;
1020
1021         if (m_notiHandle)
1022         {
1023                 char *subInfo = NULL;
1024                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, &subInfo) != NOTIFICATION_ERROR_NONE)
1025                 {
1026                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub background error");
1027                 }
1028
1029                 if (subInfo)
1030                         subInfos.push_back(subInfo);    
1031                 else 
1032                         subInfos.push_back(std::string());
1033                 subInfo = NULL;
1034                 
1035                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, &subInfo) != NOTIFICATION_ERROR_NONE)
1036                 {
1037                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1038                 }
1039                 
1040                 if (subInfo)
1041                         subInfos.push_back(subInfo);    
1042                 else 
1043                         subInfos.push_back(std::string());
1044
1045                 subInfo = NULL;
1046 #if 0
1047                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, &subInfo) != NOTIFICATION_ERROR_NONE)
1048                 {
1049                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1050                 }
1051                 
1052                 if (subInfo)
1053                         subInfos.push_back(subInfo);    
1054                 else 
1055                         subInfos.push_back(std::string());
1056
1057                 subInfo = NULL;
1058 #endif          
1059         }
1060         else
1061         {       
1062                 LogDebug("noti Handle is NULL");
1063                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1064         }
1065
1066         return subInfos;
1067 }
1068
1069 std::string StatusNotification::getSubInformation(int index)
1070 {
1071
1072         if (m_notiHandle)
1073         {
1074                 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
1075                 switch (index)
1076                 {
1077                         case 0:
1078                                 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1079                                 break;
1080                         case 1:
1081                                 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1082                                 break;
1083                         case 2:
1084                                 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1085                                 break;
1086                         default :
1087                                 type = NOTIFICATION_TEXT_TYPE_NONE;
1088                 }
1089                                 
1090                 char *subInfo = NULL;
1091                 
1092                 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1093                 {
1094                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1095                 }
1096
1097                 std::string strSubInfo;
1098                 if (subInfo)
1099                         strSubInfo = subInfo;
1100                 LogDebug(" subInfo " << strSubInfo);
1101                 return strSubInfo;
1102                                 
1103         }
1104         else
1105         {       
1106                 LogDebug("noti Handle is NULL");
1107                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1108         }
1109         
1110 }
1111
1112 void StatusNotification::setSubInformations(std::vector<std::string>& subInfos)
1113 {
1114         if (m_notiHandle)
1115         {
1116                 std::vector<std::string>::iterator it;
1117
1118                 int idx = 0;
1119                 for (it = subInfos.begin(); it < subInfos.end(); ++it) 
1120                 {
1121                         std::string str = *it;
1122                         LogDebug(" sub Info : " << str);
1123
1124                         notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
1125                         switch (idx)
1126                         {
1127                                 case 0:
1128                                         type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1129                                         break;
1130                                 case 1:
1131                                         type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1132                                         break;
1133                                 case 2:
1134                                         type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1135                                         break;
1136                                 default :
1137                                         type = NOTIFICATION_TEXT_TYPE_NONE;
1138                         }
1139
1140                         if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1141                         {
1142                                 if (getSubInformation(idx).compare(str))
1143                                 {
1144                                         if (notification_set_text(m_notiHandle, type, str.c_str(),
1145                                                 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1146                                         {
1147                                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification text error");
1148                                         }
1149                                         setUpdatedFlag(true);
1150                                 }
1151                         }
1152                         idx ++;
1153                 }
1154
1155         }
1156         else
1157         {       
1158                 LogDebug("noti Handle is NULL");
1159                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1160         }
1161         
1162 }
1163
1164 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1165 {
1166
1167         if (m_notiHandle)
1168         {
1169                 int idx = index;
1170                 LogDebug(" index : " << idx);
1171                 LogDebug(" log : " << subInfo);
1172                 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
1173                 
1174                 switch (idx)
1175                 {
1176                         case 0:
1177                                 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1178                                 break;
1179                         case 1:
1180                                 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1181                                 break;
1182                         case 2:
1183                                 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1184                                 break;
1185                         default :
1186                                 type = NOTIFICATION_TEXT_TYPE_NONE;
1187                 }
1188
1189                 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1190                 {
1191                         if (getSubInformation(idx).compare(subInfo))
1192                         {
1193                                 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1194                                         NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1195                                 {
1196                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1197                                 }
1198                                 setUpdatedFlag(true);
1199                         }
1200                 }
1201         }
1202 }
1203
1204 #if 0
1205 std::vector<std::string> StatusNotification::getThumbnails()
1206 {
1207         std::vector<std::string> thumbs;
1208         if (m_notiHandle)
1209         {
1210                 //clean
1211                 if ( !thumbs.empty() )
1212                         thumbs.clear();
1213                 
1214                 char *thumb = NULL;
1215                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1216                 {
1217                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1218                 }
1219                 if (thumb)
1220                         thumbs.push_back(thumb);
1221                 else
1222                         thumbs.push_back(std::string("")); //set empty
1223                 thumb = NULL;
1224                 
1225                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1226                 {
1227                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1228                 }       
1229                 if (thumb)
1230                         thumbs.push_back(thumb);
1231                 else
1232                         thumbs.push_back(std::string("")); //set empty
1233                 thumb = NULL;
1234                 
1235                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1236                 {
1237                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1238                 }
1239                 
1240                 if (thumb)
1241                         thumbs.push_back(thumb);
1242                 else
1243                         thumbs.push_back(std::string("")); //set empty
1244                 thumb = NULL;
1245
1246                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1247                 {
1248                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1249                 }
1250                 
1251                 if (thumb)
1252                         thumbs.push_back(thumb);
1253                 else
1254                         thumbs.push_back(std::string("")); //set empty
1255                 thumb = NULL;
1256         
1257                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1258                 {
1259                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1260                 }
1261                 
1262                 if (thumb)
1263                         thumbs.push_back(thumb);
1264                 else
1265                         thumbs.push_back(std::string("")); //set empty
1266                 thumb = NULL;
1267                 
1268         }
1269         else
1270         {       
1271                 LogDebug("noti Handle is NULL");
1272                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1273         }
1274
1275         return thumbs;
1276 }
1277 #endif
1278
1279 std::string StatusNotification::getThumbnail(int index)
1280 {
1281         
1282         if (m_notiHandle)
1283         {
1284                 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1285                 
1286                 switch (index)
1287                 {
1288                         case 0:
1289                                 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1290                                 break;
1291                         case 1:
1292                                 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1293                                 break;
1294                         case 2:
1295                                 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1296                                 break;
1297                         case 3:
1298                                 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1299                                 break;
1300                         case 4:
1301                                 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1302                                 break;
1303                                 
1304                         default :
1305                                 type = NOTIFICATION_IMAGE_TYPE_NONE;
1306                 }
1307                 
1308                 char* thumb=NULL;
1309                 
1310                 if (NOTIFICATION_IMAGE_TYPE_NONE != type && notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
1311                 {
1312                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1313                 }
1314
1315                 std::string strThumb;
1316                 
1317                 if (thumb)
1318                         strThumb = thumb;
1319                 
1320                 LogDebug(" info " << strThumb);
1321                 return strThumb;
1322
1323         }
1324         else
1325         {       
1326                 LogDebug("noti Handle is NULL");
1327                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1328         }
1329
1330 }
1331
1332 void StatusNotification::setThumbnails(std::vector<std::string>& thumbs)
1333 {
1334         if (m_notiHandle)
1335         {
1336                 std::vector<std::string>::iterator it;
1337
1338                 int idx = 0;
1339                 for (it = thumbs.begin(); it < thumbs.end(); ++it)
1340                 {
1341                         std::string str = *it;
1342                         LogDebug(" thumbs : " << str);
1343
1344                         if ( idx < MAX_THUMBNAIL_LENGTH )
1345                                 setThumbnail(str, idx);
1346 #if 0
1347                         notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE; 
1348                         switch (idx)
1349                         {
1350                                 case 0:
1351                                         type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1352                                         break;
1353                                 case 1:
1354                                         type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1355                                         break;
1356                                 case 2:
1357                                         type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1358                                         break;
1359                                 case 3:
1360                                         type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1361                                         break;
1362                                 case 4:
1363                                         type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1364                                         break;                                  
1365                                 default :
1366                                         type = NOTIFICATION_IMAGE_TYPE_NONE;
1367                         }
1368                         
1369                         if ( idx < MAX_THUMBNAIL_LENGTH )
1370                         { 
1371
1372                                 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1373                                 {
1374                                         if (getThumbnail(idx).compare(str))
1375                                         {       
1376                                                 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1377                                                 {
1378                                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1379                                                 }
1380                                                 setUpdatedFlag(true);
1381                                         }
1382                                 }
1383                         }
1384
1385 #endif
1386                         idx ++;
1387                 }
1388
1389                 if ( idx < MAX_THUMBNAIL_LENGTH)
1390                 {
1391                         setThumbnail("", idx);  //set empty value
1392                 }       
1393                 
1394
1395         }
1396         else
1397         {       
1398                 LogDebug("noti Handle is NULL");
1399                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1400         }
1401
1402 }
1403
1404 void StatusNotification::setThumbnail( const std::string& thumb, int index)
1405 {
1406         if (m_notiHandle)
1407         {
1408                 LogDebug(" index : " << index);
1409                 LogDebug(" thumb : " << thumb);
1410                 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE; 
1411                 
1412                 switch (index)
1413                 {
1414                         case 0:
1415                                 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1416                                 break;
1417                         case 1:
1418                                 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1419                                 break;
1420                         case 2:
1421                                 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1422                                 break;
1423                         case 3:
1424                                 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1425                                 break;
1426                         case 4:
1427                                 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1428                                 break;                                  
1429                         default :
1430                                 type = NOTIFICATION_IMAGE_TYPE_NONE;
1431                 }
1432
1433                 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1434                 {
1435                         
1436                         if (getThumbnail(index).compare(thumb))
1437                         {
1438                                 if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
1439                                 {
1440                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1441                                 }
1442                                 setUpdatedFlag(true);
1443                         }
1444                 }
1445         }
1446
1447 }
1448
1449 void StatusNotification::setThumbnails(const StringArrayPtr &value)
1450 {
1451         if(value == NULL)
1452                 m_thumbs = StringArrayPtr(new StringArray());
1453         else
1454                 m_thumbs = value;
1455 #if 0
1456         if (m_notiHandle)
1457         {
1458                 //set notification.
1459                 if (value)
1460                 {
1461                         //setThumbnails
1462                         std::vector<std::string>::iterator it;
1463
1464                         int idx = 0;
1465                         for (it = m_thumbs->begin(); it < m_thumbs->end(); ++it)
1466                         {
1467                                 std::string str = *it;
1468                                 LogDebug(" thumbs : " << str);
1469                                 DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, soundPath);
1470                                 str = path->getFullPath();
1471                         
1472                                 LogDebug(" thumbs : " << str);
1473                                 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE; 
1474                                 switch (idx)
1475                                 {
1476                                         case 0:
1477                                                 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1478                                                 break;
1479                                         case 1:
1480                                                 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1481                                                 break;
1482                                         case 2:
1483                                                 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1484                                                 break;
1485                                         case 3:
1486                                                 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1487                                                 break;
1488                                         case 4:
1489                                                 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1490                                                 break;                                  
1491                                         default :
1492                                                 type = NOTIFICATION_IMAGE_TYPE_NONE;
1493                                 }
1494
1495                                 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1496                                 {
1497                                         if (getThumbnail(idx).compare(str))
1498                                         {       
1499                                                 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1500                                                 {
1501                                                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1502                                                 }
1503                                                 setUpdatedFlag(true);
1504                                         }
1505                                 }
1506                                 idx ++;
1507                         }
1508                 
1509
1510         
1511                 }       
1512         }
1513 #endif  
1514
1515 }
1516
1517 StringArrayPtr StatusNotification::getThumbnails()
1518 {       
1519
1520         if (m_notiHandle)
1521         {
1522                 if ( !m_thumbs->empty() )
1523                                 m_thumbs->clear();
1524
1525                 char *thumb = NULL;
1526                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1527                 {
1528                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1529                 }
1530                 if (thumb)
1531                         m_thumbs->push_back(thumb);
1532                 else
1533                         m_thumbs->push_back(std::string("")); //set empty
1534                 thumb = NULL;
1535                 
1536                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1537                 {
1538                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1539                 }       
1540                 if (thumb)
1541                         m_thumbs->push_back(thumb);
1542                 else
1543                         m_thumbs->push_back(std::string("")); //set empty
1544                 thumb = NULL;
1545                 
1546                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1547                 {
1548                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1549                 }
1550                 
1551                 if (thumb)
1552                         m_thumbs->push_back(thumb);
1553                 else
1554                         m_thumbs->push_back(std::string("")); //set empty
1555                 thumb = NULL;
1556
1557                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1558                 {
1559                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1560                 }
1561                 
1562                 if (thumb)
1563                         m_thumbs->push_back(thumb);
1564                 else
1565                         m_thumbs->push_back(std::string("")); //set empty
1566                 thumb = NULL;
1567 #if 0   
1568                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1569                 {
1570                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1571                 }
1572                 
1573                 if (thumb)
1574                         m_thumbs->push_back(thumb);
1575                 else
1576                         m_thumbs->push_back(std::string("")); //set empty
1577                 thumb = NULL;
1578 #endif          
1579         }       
1580         return m_thumbs;
1581 }
1582
1583
1584
1585 std::string StatusNotification::getBackground()
1586 {
1587         if (m_notiHandle)
1588         {
1589                 char *background = NULL;
1590         
1591                 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
1592                 {
1593                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1594                 }
1595                 
1596                 std::string notiBackground;
1597                 if (background)
1598                         notiBackground = background;
1599                 return notiBackground;
1600         }
1601         else
1602         {
1603                 LogDebug("noti Handle is NULL");
1604                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1605         }
1606
1607 }
1608
1609 void StatusNotification::setBackground(const std::string imagePath)
1610 {
1611         if (m_notiHandle)
1612         {
1613                 if (getBackground().compare(imagePath))
1614                 {
1615                         if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
1616                         {
1617                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1618                         }
1619                         setUpdatedFlag(true);
1620                 }
1621         }
1622         else
1623         {       
1624                 LogDebug("noti Handle is NULL");
1625                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1626         }
1627 }
1628
1629 unsigned int StatusNotification::getNumber()
1630 {
1631         if (m_notiHandle)
1632         {
1633                 int number = 0;
1634                 char *strNumber = NULL;
1635
1636                 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
1637                 {
1638                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1639                 }
1640
1641                 if (strNumber)
1642                         std::istringstream(strNumber) >> number;
1643
1644                 LogDebug("number = " << number);
1645
1646                 if (number < 0 )
1647                         number = 0;
1648                 return number;
1649         }
1650         else
1651         {
1652                 LogDebug("noti Handle is NULL");
1653                 return 0;
1654         }
1655 }
1656
1657 void StatusNotification::setNumber(const unsigned int number)
1658 {
1659         if (m_notiHandle)
1660         {
1661                 if(number!=getNumber())
1662                 {
1663                         std::stringstream stream;
1664                         stream << number;
1665                         if (stream.fail()) {
1666                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException,
1667                                                  "Couldn't convert e-mail account id");
1668                         }
1669                         
1670                         std::string strNumber = stream.str();           
1671                         if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
1672                                 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1673                         {
1674                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1675                         }
1676                         setUpdatedFlag(true);
1677                 }
1678         }
1679         else
1680         {               
1681                 LogDebug("noti Handle is NULL");
1682                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1683         }
1684 }
1685
1686
1687
1688 void* StatusNotification::getNotificationHandle()
1689 {
1690         return m_notiHandle;
1691 }
1692
1693 void StatusNotification::setNotificationHandle(void *handle)
1694 {
1695         if (handle == NULL)
1696         {
1697                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1698         }
1699         LogDebug("handle = " << handle << " m_notiHandle = " << m_notiHandle);
1700         
1701         if (m_notiHandle != NULL)
1702         {       
1703                 //delete old noti.
1704                 if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
1705                 {
1706                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification delete error");
1707                 }
1708                 m_notiHandle = NULL;
1709         }
1710         
1711         m_notiHandle = (notification_h)handle;
1712 }
1713
1714 void StatusNotification::setNotificationLines()
1715 {
1716         if (m_notiHandle == NULL)
1717         {
1718                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1719         }
1720         LogDebug("handle = " << m_notiHandle);
1721
1722         if (getLinesNum() > 0)
1723                 clearLines();
1724
1725         //getLine
1726         std::vector<std::string> infos = getInformations();
1727         std::vector<std::string> subInfos = getSubInformations();
1728
1729         LogDebug("info size = " << infos.size());
1730         LogDebug("subInfo size = " << subInfos.size());
1731
1732         std::vector<std::string>::iterator it;
1733
1734         int idx = 0;
1735
1736         NotificationLineArrayPtr lines = getLines();
1737
1738         for (it = infos.begin(); it < infos.end(); ++it) 
1739         {
1740                 std::string info = *it;
1741                 LogDebug(" Info : " << info);
1742                 LogDebug("subInfo=" << subInfos[idx]);
1743         
1744                 if (!(info.empty() && subInfos[idx].empty()))
1745                 {
1746                         NotificationLinePtr line(new NotificationLine(m_notiHandle,idx,info,subInfos[idx]));
1747                         lines->push_back(line);
1748                 }
1749                 idx++;
1750         }
1751         
1752 }
1753
1754 DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
1755 {       
1756         service_h service = NULL;
1757         int retcode = 0;
1758         char *tempStr = NULL;
1759         
1760         DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
1761
1762         try {
1763                 if (m_service)
1764                 {
1765                         appControl->setService_h(m_service);
1766                         // mandatory
1767                         if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
1768                         {
1769                                 LogDebug("Operation Str = " << tempStr);
1770                                 if (tempStr) 
1771                                 {
1772                                         appControl->setOperation(tempStr);
1773                                         free(tempStr);
1774                                         tempStr = NULL;
1775                                 }
1776                         }
1777
1778                         // optional
1779                         if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
1780                         {
1781                                 LogDebug("Mime Str = " << tempStr);
1782                                 if (tempStr) 
1783                                 {
1784                                         appControl->setMime(tempStr);
1785                                         free(tempStr);
1786                                         tempStr = NULL;
1787                                 }
1788                         }
1789
1790                         // optional
1791                         if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
1792                         {
1793                                 LogDebug("Uri Str = " << tempStr);
1794                                 if (tempStr)
1795                                 {
1796                                         appControl->setUri(tempStr);
1797                                         free(tempStr);
1798                                         tempStr = NULL;
1799                                 }
1800                         }
1801
1802                         if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
1803                         {
1804                                 LogDebug("Category Str = " << tempStr);
1805                                 if (tempStr)
1806                                 {
1807                                         appControl->setCategory(tempStr);
1808                                         free(tempStr);
1809                                         tempStr = NULL;
1810                                 }
1811                         }
1812                         
1813                         // optional
1814                         if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1815                         {
1816                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1817                         }
1818
1819                         return appControl;
1820                 }
1821
1822         }
1823         Catch (WrtDeviceApis::Commons::Exception) 
1824         {
1825                 if (tempStr) 
1826                 {
1827                         free(tempStr);
1828                         tempStr = NULL;
1829                 }
1830
1831                 if (service)
1832                 {
1833                         free(service);
1834                         service = NULL;
1835                 }       
1836
1837                 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1838                 {
1839                         ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1840
1841                 }
1842                 else
1843                 {
1844                         ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1845                 }
1846         }
1847
1848 #if 0
1849         try {
1850                 
1851                 if (m_service != NULL)
1852                 {
1853                         retcode = service_clone(&service, m_service);
1854                         
1855                         if (retcode != SERVICE_ERROR_NONE)
1856                         {       
1857                                 
1858                                 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
1859                                 {
1860                                         LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
1861                                 }
1862                                 else
1863                                 {
1864                                         LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
1865                                 }
1866                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
1867                         }
1868                         else
1869                         {
1870                                 if (service == NULL)
1871                                 {
1872                                         ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");                        
1873                                 }
1874                         }
1875                 }
1876
1877                 appControl->setService_h(service);
1878
1879                 // mandatory
1880                 int ret = service_get_operation(service, &tempStr);
1881                 LogDebug("ret = " << ret);
1882                 //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
1883                 if(ret != SERVICE_ERROR_NONE)
1884                 {
1885                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service operation error");                 
1886                 }
1887                 
1888                 LogDebug("temp Str = " << tempStr);
1889
1890                 if (tempStr) 
1891                 {
1892                         appControl->setOperation(tempStr);
1893                         free(tempStr);
1894                         tempStr = NULL;
1895                 }
1896                 else 
1897                 {
1898                         ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service operation ok, but null");                      
1899                 }
1900
1901                 // optional
1902                 if (service_get_mime(service, &tempStr) == SERVICE_ERROR_NONE)
1903                 {
1904                         if (tempStr) 
1905                         {
1906                                 appControl->setMime(tempStr);
1907                                 free(tempStr);
1908                                 tempStr = NULL;
1909                         }
1910                 }
1911
1912                 // optional
1913                 if (service_get_uri(service, &tempStr) == SERVICE_ERROR_NONE)
1914                 {
1915                         if (tempStr)
1916                         {
1917                                 appControl->setUri(tempStr);
1918                                 free(tempStr);
1919                                 tempStr = NULL;
1920                         }
1921                 }
1922
1923                 // optional
1924                 if ( service_foreach_extra_data(service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1925                 {
1926                         LogDebug(error);
1927                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1928                 }
1929
1930                 return appControl;
1931                 
1932         }       
1933         Catch (WrtDeviceApis::Commons::Exception) 
1934         {
1935                 if (tempStr) 
1936                 {
1937                         free(tempStr);
1938                         tempStr = NULL;
1939                 }
1940
1941                 if (service)
1942                 {
1943                         free(service);
1944                         service = NULL;
1945                 }       
1946
1947                 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1948                 {
1949                         ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1950
1951                 }
1952                 else
1953                 {
1954                         ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1955                 }
1956
1957         }
1958 #endif
1959
1960         return appControl;
1961 }
1962
1963 void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr appControl)
1964 {
1965
1966         LogDebug("Entered m_service : " << m_service);
1967         
1968         if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
1969         {
1970                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
1971         }
1972         else
1973         {
1974                 LogDebug("getOperation : " << appControl->getOperation().c_str());
1975                 if (appControl->getOperation().size() != 0)
1976                 {
1977                         if (service_set_operation(m_service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
1978                         {
1979                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
1980                         }
1981                 }
1982                         
1983                 // optional
1984                 LogDebug("getUri : " << appControl->getUri().c_str());
1985                 if (appControl->getUri().size() != 0)
1986                 {
1987                         if (service_set_uri(m_service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
1988                         {
1989                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
1990                         }
1991                 }
1992
1993                 // optional
1994                 LogDebug("getMime : " << appControl->getMime().c_str());
1995                 if (appControl->getMime().size() != 0)
1996                 {
1997                         if (service_set_mime(m_service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
1998                         {
1999                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
2000                         }
2001                 }
2002
2003                 LogDebug("Category : " << appControl->getCategory().c_str());
2004                 if (appControl->getCategory().size() != 0)
2005                 {
2006                         if (service_set_category(m_service, appControl->getCategory().c_str() ) != SERVICE_ERROR_NONE)
2007                         {
2008                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
2009                         }
2010                 }
2011
2012                 //remove key
2013                 if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
2014                 {
2015                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
2016                 }
2017                                 
2018                 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
2019                 size_t index = 0, indexArray = 0;
2020
2021                 LogDebug (" App Control Datas Count : " << appControlDataArray.size());
2022
2023                 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
2024
2025                 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
2026                 {
2027                         DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
2028                         std::string key = appControlData->getKey();
2029                         LogDebug(" key : " << key);
2030                 
2031                         if (key.empty())
2032                                 continue;
2033                 
2034                         std::vector<std::string> value = appControlDataArray[index]->getValue();
2035                         const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
2036    
2037                         for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
2038                         {
2039                                 arrayValue[indexArray] = (char*)value[indexArray].c_str();
2040                                 LogDebug( " value : " << arrayValue[indexArray]);
2041                         }
2042
2043                         const char* strKey = key.c_str();
2044                         LogDebug( " value size: " << value.size());
2045                         if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
2046                         {
2047                                 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");                     
2048                         }
2049                          
2050                         if (arrayValue)
2051                                 free(arrayValue);
2052                 }                                       
2053
2054                 bundle *bundle_data=NULL;
2055                 
2056                 if(service_to_bundle(m_service, &bundle_data) != SERVICE_ERROR_NONE)
2057                 {
2058                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get bundle");                       
2059                 }
2060                 
2061                 if (bundle_data)
2062                 {
2063                         notification_set_execute_option(m_notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
2064                                 NULL,NULL, bundle_data);
2065                         //bundle_free(bundle_data);     
2066                 }
2067                                 
2068         }       
2069
2070 }
2071
2072 void StatusNotification::setApplicationId(const std::string& appId)
2073 {
2074         int retcode = 0;
2075         LogDebug("m_service = " << m_service << " appId = " << appId);
2076         if (!m_service)
2077         {       
2078                 LogDebug("m_service = " << m_service);
2079                 if (service_create(&m_service) != SERVICE_ERROR_NONE)
2080                 {
2081                         LogDebug("Create Service Failed..");
2082                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2083                 }
2084         }
2085
2086         if (m_service)
2087         {
2088                 if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
2089                 {
2090                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");  
2091                 }
2092         }
2093
2094 #if 0
2095         int retcode = 0;
2096         service_h service = NULL;
2097         char* operation = NULL;
2098         LogDebug("Entered : " << appId);
2099         
2100         LogDebug("m_service = " << m_service);
2101         if (m_service != NULL)
2102         {
2103                 retcode = service_clone(&service, m_service);   
2104                 if (retcode != SERVICE_ERROR_NONE)
2105                 {                       
2106                         if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2107                         {
2108                                 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2109                         }
2110                         else
2111                         {
2112                                 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2113                         }
2114
2115                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2116                 }
2117         }
2118
2119         if(service == NULL)
2120         {
2121                 if (service_create(&service) != SERVICE_ERROR_NONE)
2122                 {
2123                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2124                 }
2125         }
2126
2127         if(service)
2128         {       
2129                 if (service_get_operation(service,      &operation) != SERVICE_ERROR_NONE)
2130                 {
2131                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get operation error");
2132                 }
2133
2134                 if (operation) 
2135                 {
2136                         free(operation);
2137                         operation = NULL;
2138                 }
2139                 else if (service_set_operation(service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
2140                 {
2141                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
2142                 }
2143                 
2144                 if (service_set_app_id(service, appId.c_str())!= SERVICE_ERROR_NONE)
2145                 {
2146                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");  
2147                 }
2148
2149                 if (m_service != NULL)
2150                 {
2151                         service_destroy(m_service);
2152                         m_service = NULL;
2153                 }
2154                 
2155                 m_service = service;    //set service.  
2156         }
2157 #endif
2158 }
2159
2160 std::string StatusNotification::getApplicationId()
2161 {
2162         std::string retString;
2163         service_h service = NULL;
2164         char* appIdStr = NULL;
2165         
2166         if (m_service != NULL)
2167         {
2168                 int retcode;
2169                 retcode = service_clone(&service, m_service);   
2170                 
2171                 if (retcode != SERVICE_ERROR_NONE)
2172                 {
2173                         if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2174                         {
2175                                 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2176                         }
2177                         else
2178                         {
2179                                 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2180                         }
2181                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2182                 }
2183                 else
2184                 {
2185                         if (service == NULL)
2186                         {
2187                                 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");                        
2188                         }
2189                 }
2190         }
2191
2192         if (service != NULL) 
2193         {
2194                 if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
2195                 {
2196                         ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get a appId error");
2197                 }
2198
2199                 if (appIdStr != NULL)
2200                 {
2201                         retString = appIdStr;
2202                         free(appIdStr);
2203                 }
2204         }
2205         LogDebug(retString);
2206         
2207         return retString;
2208 }
2209
2210 service_h StatusNotification::getService()
2211 {
2212         return m_service;
2213 }
2214
2215
2216 NotificationLineArrayPtr StatusNotification::getLines() const
2217 {
2218         return m_lines;
2219 }
2220
2221 int StatusNotification::getLinesNum() const
2222 {
2223         return m_lines->size();
2224 }
2225
2226 void StatusNotification::setLines(const NotificationLineArrayPtr &value)
2227 {
2228         LogDebug("setlines");
2229         if (value == NULL)
2230         {
2231                 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
2232         }
2233         else
2234         {
2235                 m_lines = value;
2236
2237                 NotificationLineArray::iterator iter;
2238                 int index = 0;
2239                 for(iter = m_lines->begin(); iter != m_lines->end(); iter++) 
2240                 { 
2241                         NotificationLinePtr line = *iter;
2242                         LogDebug("info = " << line->getInformation());
2243                         LogDebug("sub info = " << line->getSubInformation());
2244                         
2245                         if ( index < MAX_NOTIFICATION_LINE_LENGTH)
2246                         {       
2247                                 setInformation(line->getInformation(),index);
2248                                 setSubInformation(line->getSubInformation(),index);
2249                         }
2250                         index ++;
2251                 }
2252                 
2253                 //clean empty solt.`
2254                 for ( ;index < MAX_NOTIFICATION_LINE_LENGTH; index++)
2255                 {
2256                         setInformation("", index);
2257                         setSubInformation("", index);
2258                 }
2259         }
2260 }
2261
2262 void StatusNotification::addLine(const NotificationLinePtr &value)
2263 {
2264         m_lines->push_back(value);
2265 }
2266         
2267 void StatusNotification::clearLines()
2268 {
2269         m_lines->clear();
2270 }
2271
2272 }
2273 }
2274