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