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