Merge branch 'tizen' into tizen_5.5
[platform/core/api/notification.git] / notification-ex / stub.cc
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <dlog.h>
18 #include <glib.h>
19 #include <unistd.h>
20
21 #include <list>
22 #include <sstream>
23 #include <iomanip>
24
25 #include "api/notification_ex.h"
26 #include "api/notification_ex_internal.h"
27 #include "notification-ex/reporter.h"
28 #include "notification-ex/app_control_action.h"
29 #include "notification-ex/button_item.h"
30 #include "notification-ex/chat_message_item.h"
31 #include "notification-ex/checkbox_item.h"
32 #include "notification-ex/entry_item.h"
33 #include "notification-ex/group_item.h"
34 #include "notification-ex/input_selector_item.h"
35 #include "notification-ex/abstract_item.h"
36 #include "notification-ex/progress_item.h"
37 #include "notification-ex/time_item.h"
38 #include "notification-ex/visibility_action.h"
39 #include "notification-ex/event_info_internal.h"
40 #include "notification-ex/manager.h"
41 #include "notification-ex/dbus_sender.h"
42 #include "notification-ex/dbus_event_listener.h"
43 #include "notification-ex/exception.h"
44 #include "notification-ex/iitem_info_internal.h"
45 #include "notification-ex/icon_item.h"
46
47 #ifdef LOG_TAG
48 #undef LOG_TAG
49 #endif
50 #define LOG_TAG "NOTIFICATION_EX"
51
52 #ifdef EXPORT_API
53 #undef EXPORT_API
54 #endif
55 #define EXPORT_API __attribute__((visibility("default")))
56
57 using namespace std;
58 using namespace tizen_base;
59 using namespace notification::item;
60 using namespace notification;
61
62 namespace {
63
64 class Handle {
65  public:
66   explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
67   explicit Handle(std::shared_ptr<item::AbstractItem> ptr)
68       : ref_(nullptr), ptr_(move(ptr)) { }
69   virtual ~Handle() = default;
70   item::AbstractItem* Get() const {
71     if (ptr_ == nullptr)
72       return ref_;
73     return ptr_.get();
74   }
75
76   bool IsValidType(int type) const {
77     return (Get()->GetType() == type
78         || Get()->GetType() >= AbstractItem::Custom);
79   }
80
81   std::shared_ptr<item::AbstractItem> GetPtr() const {
82     if (ptr_ == nullptr)
83       return std::shared_ptr<item::AbstractItem>({});
84     return ptr_;
85   }
86
87  private:
88   item::AbstractItem* ref_;
89   std::shared_ptr<item::AbstractItem> ptr_;
90 };
91
92 class ManagerCallbackInfo {
93  public:
94   ManagerCallbackInfo(noti_ex_manager_events_s cb, void* user_data)
95     : user_data_(user_data) {
96     cb_.added = cb.added;
97     cb_.updated = cb.updated;
98     cb_.deleted = cb.deleted;
99     cb_.error = cb.error;
100   }
101
102   void InvokeAdded(Manager* manager, const IEventInfo& info,
103       list<shared_ptr<AbstractItem>> addedItem) {
104     if (cb_.added == nullptr)
105       return;
106     noti_ex_item_h* added_item =
107         (noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
108     if (added_item == nullptr) {
109       LOGE("Out of memory");
110       return;
111     }
112
113     int idx = 0;
114     for (auto& i : addedItem) {
115       added_item[idx++] =
116           static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i)));
117     }
118
119     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
120     cb_.added(static_cast<noti_ex_manager_h>(manager),
121         static_cast<noti_ex_event_info_h>(c_info), added_item,
122         addedItem.size(), user_data_);
123   }
124
125   void InvokeUpdated(Manager* manager, const IEventInfo& info,
126       shared_ptr<item::AbstractItem> updatedItem) {
127     if (cb_.updated == nullptr)
128       return;
129     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
130     cb_.updated(static_cast<noti_ex_manager_h>(manager),
131         static_cast<noti_ex_event_info_h>(c_info),
132         static_cast<noti_ex_item_h>(new Handle(updatedItem)), user_data_);
133   }
134
135   void InvokeDeleted(Manager* manager, const IEventInfo& info,
136       shared_ptr<item::AbstractItem> deletedItem) {
137     if (cb_.deleted == nullptr)
138       return;
139     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
140     if (c_info->GetEventType() == static_cast<int>(IEventInfo::EventType::DeleteAll)) {
141       cb_.deleted(static_cast<noti_ex_manager_h>(manager),
142         static_cast<noti_ex_event_info_h>(c_info),
143         nullptr, user_data_);
144     } else {
145       cb_.deleted(static_cast<noti_ex_manager_h>(manager),
146         static_cast<noti_ex_event_info_h>(c_info),
147         static_cast<noti_ex_item_h>(
148             new Handle(deletedItem)), user_data_);
149     }
150   }
151
152   void InvokeError(Manager* manager, NotificationError error, int requestId) {
153     if (cb_.error == nullptr)
154       return;
155     cb_.error(static_cast<noti_ex_manager_h>(manager),
156         static_cast<noti_ex_error_e>(error), requestId, user_data_);
157   }
158
159  private:
160   noti_ex_manager_events_s cb_;
161   void* user_data_;
162 };
163
164 class ManagerStub : public Manager {
165  public:
166   ManagerStub(std::unique_ptr<IEventSender> sender,
167       std::unique_ptr<IEventListener> listener, std::string receiver_group = "")
168     : Manager(move(sender), move(listener), receiver_group) {
169   }
170
171   void OnAdd(const IEventInfo& info,
172       list<shared_ptr<AbstractItem>> addedItem) override {
173     cb_->InvokeAdded(this, info, addedItem);
174   }
175
176   void OnUpdate(const IEventInfo& info,
177       std::shared_ptr<item::AbstractItem> updatedItem) override {
178     cb_->InvokeUpdated(this, info, updatedItem);
179   }
180
181   void OnDelete(const IEventInfo& info,
182       shared_ptr<item::AbstractItem> deletedItem) override {
183     cb_->InvokeDeleted(this, info, deletedItem);
184   }
185
186   void OnError(NotificationError error, int requestId) override {
187     cb_->InvokeError(this, error, requestId);
188   }
189
190   int SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo> ci) {
191     cb_ = move(ci);
192     return NOTI_EX_ERROR_NONE;
193   }
194
195   int ClearManagerCallbackInfo() {
196     cb_.reset();
197     return NOTI_EX_ERROR_NONE;
198   }
199
200  private:
201   unique_ptr<ManagerCallbackInfo> cb_;
202 };
203
204
205 class ReporterCallbackInfo {
206  public:
207   ReporterCallbackInfo(noti_ex_reporter_events_s cb, void* user_data)
208     : user_data_(user_data) {
209     cb_.event = cb.event;
210     cb_.error = cb.error;
211   }
212
213   void InvokeEvent(Reporter* reporter, const IEventInfo& info,
214       list<shared_ptr<AbstractItem>> notiList) {
215     if (cb_.event == nullptr)
216       return;
217     noti_ex_item_h* noti_list =
218         (noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
219     if (noti_list == nullptr) {
220       LOGE("Out of memory");
221       return;
222     }
223
224     int idx = 0;
225     for (auto& i : notiList) {
226       noti_list[idx++] =
227           static_cast<noti_ex_item_h>(new Handle(i));
228     }
229
230     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
231     cb_.event(static_cast<noti_ex_reporter_h>(reporter),
232         static_cast<noti_ex_event_info_h>(c_info), noti_list,
233         notiList.size(), user_data_);
234     free(noti_list);
235   }
236
237   void InvokeError(Reporter* reporter, NotificationError error, int requestId) {
238     if (cb_.error == nullptr)
239       return;
240     cb_.error(static_cast<noti_ex_reporter_h>(reporter),
241         static_cast<noti_ex_error_e>(error), requestId, user_data_);
242   }
243
244  private:
245   noti_ex_reporter_events_s cb_;
246   void* user_data_;
247 };
248
249 class ReporterStub : public Reporter {
250  public:
251   ReporterStub(std::unique_ptr<IEventSender> sender,
252       std::unique_ptr<IEventListener> listener)
253     : Reporter(move(sender), move(listener)) {
254   }
255
256   void OnEvent(const IEventInfo& info,
257       std::list<std::shared_ptr<item::AbstractItem>> notiList) override {
258     cb_->InvokeEvent(this, info, notiList);
259   }
260
261   void OnError(NotificationError error, int requestId) override {
262     cb_->InvokeError(this, error, requestId);
263   }
264
265   int SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo> ci) {
266     cb_ = move(ci);
267     return NOTI_EX_ERROR_NONE;
268   }
269
270   int ClearReporterCallbackInfo() {
271     cb_.reset();
272     return NOTI_EX_ERROR_NONE;
273   }
274
275  private:
276   unique_ptr<ReporterCallbackInfo> cb_;
277 };
278
279 }  // namespace
280
281 void __noti_ex_free_str_array(char** val, int length) {
282   int i;
283   for (i = 0; i < length ; i++)
284     free(val[i]);
285   free(val);
286 }
287
288 extern "C" EXPORT_API int noti_ex_action_app_control_create(
289     noti_ex_action_h *handle, app_control_h app_control,
290     const char *extra) {
291   if (handle == nullptr || app_control == nullptr) {
292     LOGE("Invalid parameter");
293     return NOTI_EX_ERROR_INVALID_PARAMETER;
294   }
295
296   shared_ptr<AbstractAction>* p;
297
298   if (extra) {
299     p = new (std::nothrow) shared_ptr<AbstractAction>(
300           new (std::nothrow) AppControlAction(app_control, extra));
301   } else {
302     p = new (std::nothrow) shared_ptr<AbstractAction>(
303           new (std::nothrow) AppControlAction(app_control));
304   }
305
306   if (p == nullptr) {
307     LOGE("Out-of-memory");
308     return NOTI_EX_ERROR_OUT_OF_MEMORY;
309   }
310
311   *handle = p;
312
313   return NOTI_EX_ERROR_NONE;
314 }
315
316 extern "C" EXPORT_API int noti_ex_action_app_control_set(
317     noti_ex_action_h handle, app_control_h app_control) {
318   if (handle == nullptr || app_control == nullptr) {
319     LOGE("Invalid parameter");
320     return NOTI_EX_ERROR_INVALID_PARAMETER;
321   }
322
323   shared_ptr<AbstractAction>* ptr =
324       static_cast<shared_ptr<AbstractAction>*>(handle);
325   AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
326   action->SetAppControl(app_control);
327
328   return NOTI_EX_ERROR_NONE;
329 }
330
331 extern "C" EXPORT_API int noti_ex_action_app_control_get(
332     noti_ex_action_h handle, app_control_h *app_control) {
333   if (handle == nullptr || app_control == nullptr) {
334     LOGE("Invalid parameter");
335     return NOTI_EX_ERROR_INVALID_PARAMETER;
336   }
337
338   shared_ptr<AbstractAction>* ptr =
339       static_cast<shared_ptr<AbstractAction>*>(handle);
340   AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
341
342   app_control_h clone;
343   int r = app_control_clone(&clone, action->GetAppControl());
344   if (r != APP_CONTROL_ERROR_NONE) {
345     LOGE("failed to create a app_control handle : %d", r);
346     return NOTI_EX_ERROR_INVALID_PARAMETER;
347   }
348
349   *app_control = clone;
350
351   return NOTI_EX_ERROR_NONE;
352 }
353
354 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
355     const char *id, const char *title) {
356   ButtonItem* p;
357
358   if (handle == nullptr || title == nullptr) {
359     LOGE("Invalid parameter");
360     return NOTI_EX_ERROR_INVALID_PARAMETER;
361   }
362
363   if (id)
364     p = new (std::nothrow) ButtonItem(id, title);
365   else
366     p = new (std::nothrow) ButtonItem(title);
367
368   if (p == nullptr) {
369     LOGE("Out-of-memory");
370     return NOTI_EX_ERROR_OUT_OF_MEMORY;
371   }
372   *handle = new Handle(shared_ptr<AbstractItem>(p));
373
374   return NOTI_EX_ERROR_NONE;
375 }
376
377 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
378     char **title) {
379   if (handle == nullptr || title == nullptr) {
380     LOGE("Invalid parameter");
381     return NOTI_EX_ERROR_INVALID_PARAMETER;
382   }
383
384   Handle* sp = static_cast<Handle*>(handle);
385   if (!sp->IsValidType(AbstractItem::Button)) {
386     LOGE("Invalid handle type");
387     return NOTI_EX_ERROR_INVALID_PARAMETER;
388   }
389
390   ButtonItem* p = static_cast<ButtonItem*>(sp->Get());
391   string str;
392   if (p->GetMultiLanguage() != nullptr &&
393       !p->GetMultiLanguage()->GetTranslatedString().empty())
394     str = p->GetMultiLanguage()->GetTranslatedString();
395   else if (!p->GetTitle().empty())
396     str = p->GetTitle();
397
398   *title = strdup(str.c_str());
399   if (*title == nullptr) {
400     LOGE("Out-of-memory");
401     return NOTI_EX_ERROR_OUT_OF_MEMORY;
402   }
403
404   return NOTI_EX_ERROR_NONE;
405 }
406
407 extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title(
408     noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
409   if (handle == nullptr) {
410     LOGE("Invalid parameter");
411     return NOTI_EX_ERROR_INVALID_PARAMETER;
412   }
413
414   Handle* p = static_cast<Handle*>(handle);
415   if (!p->IsValidType(AbstractItem::Button)) {
416     LOGE("Invalid handle type");
417     return NOTI_EX_ERROR_INVALID_PARAMETER;
418   }
419
420   ButtonItem* bi = static_cast<ButtonItem*>(p->Get());
421   if (multi == nullptr) {
422     bi->SetMultiLanguage(nullptr);
423     return NOTI_EX_ERROR_NONE;
424   }
425
426   shared_ptr<MultiLanguage> mul_ptr =
427       *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
428
429   mul_ptr->UpdateString();
430   bi->SetMultiLanguage(mul_ptr);
431
432   return NOTI_EX_ERROR_NONE;
433 }
434
435 extern "C" EXPORT_API int noti_ex_item_button_set_image(
436     noti_ex_item_h handle, const char *path) {
437   if (handle == nullptr || path == nullptr) {
438     LOGE("Invalid parameter");
439     return NOTI_EX_ERROR_INVALID_PARAMETER;
440   }
441
442   Handle* h = static_cast<Handle*>(handle);
443   if (!h->IsValidType(AbstractItem::Button)) {
444     LOGE("Invalid handle type");
445     return NOTI_EX_ERROR_INVALID_PARAMETER;
446   }
447
448   ButtonItem* p = static_cast<ButtonItem*>(h->Get());
449   p->SetImgPath(path);
450
451   return NOTI_EX_ERROR_NONE;
452 }
453
454 extern "C" EXPORT_API int noti_ex_item_button_get_image(
455     noti_ex_item_h handle, char **path) {
456   if (handle == nullptr || path == nullptr) {
457     LOGE("Invalid parameter");
458     return NOTI_EX_ERROR_INVALID_PARAMETER;
459   }
460
461   Handle* h = static_cast<Handle*>(handle);
462   if (!h->IsValidType(AbstractItem::Button)) {
463     LOGE("Invalid handle type");
464     return NOTI_EX_ERROR_INVALID_PARAMETER;
465   }
466
467   ButtonItem* p = static_cast<ButtonItem*>(h->Get());
468   if (!p->GetImgPath().empty())
469     *path = strdup(p->GetImgPath().c_str());
470   else
471     *path = nullptr;
472
473   return NOTI_EX_ERROR_NONE;
474 }
475
476 extern "C" EXPORT_API int noti_ex_item_button_set_contents(
477     noti_ex_item_h handle, const char *contents) {
478   if (handle == nullptr || contents == nullptr) {
479     LOGE("Invalid parameter");
480     return NOTI_EX_ERROR_INVALID_PARAMETER;
481   }
482
483   Handle* h = static_cast<Handle*>(handle);
484   if (!h->IsValidType(AbstractItem::Button)) {
485     LOGE("Invalid handle type");
486     return NOTI_EX_ERROR_INVALID_PARAMETER;
487   }
488
489   ButtonItem* p = static_cast<ButtonItem*>(h->Get());
490   p->SetContents(std::string(contents));
491
492   return NOTI_EX_ERROR_NONE;
493 }
494
495 extern "C" EXPORT_API int noti_ex_item_button_get_contents(
496     noti_ex_item_h handle, char **contents) {
497   if (handle == nullptr || contents == nullptr) {
498     LOGE("Invalid parameter");
499     return NOTI_EX_ERROR_INVALID_PARAMETER;
500   }
501
502   Handle* h = static_cast<Handle*>(handle);
503   if (!h->IsValidType(AbstractItem::Button)) {
504     LOGE("Invalid handle type");
505     return NOTI_EX_ERROR_INVALID_PARAMETER;
506   }
507
508   ButtonItem* p = static_cast<ButtonItem*>(h->Get());
509   if (!p->GetContents().empty())
510     *contents = strdup(p->GetContents().c_str());
511   else
512     *contents = nullptr;
513
514   return NOTI_EX_ERROR_NONE;
515 }
516
517 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
518     noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
519     noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
520     noti_ex_item_chat_message_type_e message_type) {
521   if (handle == nullptr || (text == nullptr && image == nullptr)
522       || name == nullptr || time == nullptr
523       || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
524     LOGE("Invalid parameter");
525     return NOTI_EX_ERROR_INVALID_PARAMETER;
526   }
527
528   if (id == NULL)
529     id = "";
530
531   auto* p = new (std::nothrow) ChatMessageItem(id,
532           dynamic_pointer_cast<TextItem>(static_cast<Handle*>(name)->GetPtr()),
533           text == nullptr ? nullptr
534             : dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
535           image == nullptr ? nullptr
536             : dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
537           dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
538           static_cast<ChatMessageItem::Type>(message_type));
539   if (p == nullptr) {
540     LOGE("Out-of-memory");
541     return NOTI_EX_ERROR_OUT_OF_MEMORY;
542   }
543
544   *handle = new Handle(shared_ptr<AbstractItem>(p));
545
546   return NOTI_EX_ERROR_NONE;
547 }
548
549 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
550     noti_ex_item_h handle, noti_ex_item_h *name) {
551   if (handle == nullptr || name == nullptr) {
552     LOGE("Invalid parameter");
553     return NOTI_EX_ERROR_INVALID_PARAMETER;
554   }
555   Handle* h = static_cast<Handle*>(handle);
556   if (!h->IsValidType(AbstractItem::ChatMessage)) {
557     LOGE("Invalid handle type");
558     return NOTI_EX_ERROR_INVALID_PARAMETER;
559   }
560   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
561   if (p->GetNameItem().GetType() == AbstractItem::NullObject)
562     *name = nullptr;
563   else
564     *name = new Handle(&(p->GetNameItem()));
565
566   return NOTI_EX_ERROR_NONE;
567 }
568
569 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
570     noti_ex_item_h handle, noti_ex_item_h *text) {
571   if (handle == nullptr || text == nullptr) {
572     LOGE("Invalid parameter");
573     return NOTI_EX_ERROR_INVALID_PARAMETER;
574   }
575
576   Handle* h = static_cast<Handle*>(handle);
577   if (!h->IsValidType(AbstractItem::ChatMessage)) {
578     LOGE("Invalid handle type");
579     return NOTI_EX_ERROR_INVALID_PARAMETER;
580   }
581   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
582   if (p->GetTextItem().GetType() == AbstractItem::NullObject)
583     *text = nullptr;
584   else
585     *text = new Handle(&(p->GetTextItem()));
586
587   return NOTI_EX_ERROR_NONE;
588 }
589
590 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
591     noti_ex_item_h handle, noti_ex_item_h *image) {
592   if (handle == nullptr || image == nullptr) {
593     LOGE("Invalid parameter");
594     return NOTI_EX_ERROR_INVALID_PARAMETER;
595   }
596
597   Handle* h = static_cast<Handle*>(handle);
598   if (!h->IsValidType(AbstractItem::ChatMessage)) {
599     LOGE("Invalid handle type");
600     return NOTI_EX_ERROR_INVALID_PARAMETER;
601   }
602   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
603   if (p->GetImageItem().GetType() == AbstractItem::NullObject)
604     *image = nullptr;
605   else
606     *image =  new Handle(&(p->GetImageItem()));
607
608   return NOTI_EX_ERROR_NONE;
609 }
610
611 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
612     noti_ex_item_h handle, noti_ex_item_h *time) {
613   if (handle == nullptr || time == nullptr) {
614     LOGE("Invalid parameter");
615     return NOTI_EX_ERROR_INVALID_PARAMETER;
616   }
617
618   Handle* h = static_cast<Handle*>(handle);
619   if (!h->IsValidType(AbstractItem::ChatMessage)) {
620     LOGE("Invalid handle type");
621     return NOTI_EX_ERROR_INVALID_PARAMETER;
622   }
623   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
624   if (p->GetTimeItem().GetType() == AbstractItem::NullObject)
625     *time = nullptr;
626   else
627     *time = new Handle(&(p->GetTimeItem()));
628
629   return NOTI_EX_ERROR_NONE;
630 }
631
632 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
633     noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
634   if (handle == nullptr || message_type == nullptr) {
635     LOGE("Invalid parameter");
636     return NOTI_EX_ERROR_INVALID_PARAMETER;
637   }
638
639   Handle* h = static_cast<Handle*>(handle);
640   if (!h->IsValidType(AbstractItem::ChatMessage)) {
641     LOGE("Invalid handle type");
642     return NOTI_EX_ERROR_INVALID_PARAMETER;
643   }
644   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
645   *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
646
647   return NOTI_EX_ERROR_NONE;
648 }
649
650 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
651     const char *id, const char *title, bool checked) {
652   CheckBoxItem* p;
653
654   if (handle == nullptr || title == nullptr) {
655     LOGE("Invalid parameter");
656     return NOTI_EX_ERROR_INVALID_PARAMETER;
657   }
658
659   if (id == NULL)
660     id = "";
661
662   p = new (std::nothrow) CheckBoxItem(id, title, checked);
663   if (p == nullptr) {
664     LOGE("Out-of-memory");
665     return NOTI_EX_ERROR_OUT_OF_MEMORY;
666   }
667
668   *handle = new Handle(shared_ptr<AbstractItem>(p));
669
670   return NOTI_EX_ERROR_NONE;
671 }
672
673 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
674     char **title) {
675   if (handle == nullptr || title == nullptr) {
676     LOGE("Invalid parameter");
677     return NOTI_EX_ERROR_INVALID_PARAMETER;
678   }
679   Handle* h = static_cast<Handle*>(handle);
680   if (!h->IsValidType(AbstractItem::CheckBox)) {
681     LOGE("Invalid handle type");
682     return NOTI_EX_ERROR_INVALID_PARAMETER;
683   }
684
685   CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
686   string str;
687   if (p->GetMultiLanguage() != nullptr &&
688     !p->GetMultiLanguage()->GetTranslatedString().empty())
689     str = p->GetMultiLanguage()->GetTranslatedString();
690   else if (!p->GetTitle().empty())
691     str = p->GetTitle();
692
693   *title = strdup(str.c_str());
694   if (*title == nullptr) {
695     LOGE("Out-of-memory");
696     return NOTI_EX_ERROR_OUT_OF_MEMORY;
697   }
698
699   return NOTI_EX_ERROR_NONE;
700 }
701
702 extern "C" EXPORT_API int noti_ex_item_checkbox_set_multi_language_title(
703     noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
704   if (handle == nullptr) {
705     LOGE("Invalid parameter");
706     return NOTI_EX_ERROR_INVALID_PARAMETER;
707   }
708
709   Handle* p = static_cast<Handle*>(handle);
710   if (!p->IsValidType(AbstractItem::CheckBox)) {
711     LOGE("Invalid handle type");
712     return NOTI_EX_ERROR_INVALID_PARAMETER;
713   }
714
715   CheckBoxItem* ci = static_cast<CheckBoxItem*>(p->Get());
716   if (multi == nullptr) {
717     ci->SetMultiLanguage(nullptr);
718     return NOTI_EX_ERROR_NONE;
719   }
720
721   shared_ptr<MultiLanguage> mul_ptr =
722       *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
723   mul_ptr->UpdateString();
724   ci->SetMultiLanguage(mul_ptr);
725
726   return NOTI_EX_ERROR_NONE;
727 }
728
729 extern "C" EXPORT_API int noti_ex_item_checkbox_get_check_state(
730     noti_ex_item_h handle, bool *checked) {
731   if (handle == nullptr || checked == nullptr) {
732     LOGE("Invalid parameter");
733     return NOTI_EX_ERROR_INVALID_PARAMETER;
734   }
735   Handle* h = static_cast<Handle*>(handle);
736   if (!h->IsValidType(AbstractItem::CheckBox)) {
737     LOGE("Invalid handle type");
738     return NOTI_EX_ERROR_INVALID_PARAMETER;
739   }
740   CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
741   *checked = p->IsChecked();
742
743   return NOTI_EX_ERROR_NONE;
744 }
745
746 extern "C" EXPORT_API int noti_ex_item_checkbox_set_check_state(
747     noti_ex_item_h handle, bool checked) {
748   if (handle == nullptr) {
749     LOGE("Invalid parameter");
750     return NOTI_EX_ERROR_INVALID_PARAMETER;
751   }
752
753   Handle* h = static_cast<Handle*>(handle);
754   if (!h->IsValidType(AbstractItem::CheckBox)) {
755     LOGE("Invalid handle type");
756     return NOTI_EX_ERROR_INVALID_PARAMETER;
757   }
758
759   CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
760   p->SetChecked(checked);
761
762   return NOTI_EX_ERROR_NONE;
763 }
764
765 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
766     const char *id) {
767   EntryItem* p;
768
769   if (handle == nullptr) {
770     LOGE("Invalid parameter");
771     return NOTI_EX_ERROR_INVALID_PARAMETER;
772   }
773
774   if (id)
775     p = new (std::nothrow) EntryItem(id);
776   else
777     p = new (std::nothrow) EntryItem();
778
779   if (p == nullptr) {
780     LOGE("Out-of-memory");
781     return NOTI_EX_ERROR_OUT_OF_MEMORY;
782   }
783
784   *handle = new Handle(shared_ptr<AbstractItem>(p));
785
786   return NOTI_EX_ERROR_NONE;
787 }
788
789 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
790     char **text) {
791   if (handle == nullptr || text == nullptr) {
792     LOGE("Invalid parameter");
793     return NOTI_EX_ERROR_INVALID_PARAMETER;
794   }
795
796   Handle* h = static_cast<Handle*>(handle);
797   if (!h->IsValidType(AbstractItem::Entry)) {
798     LOGE("Invalid handle type");
799     return NOTI_EX_ERROR_INVALID_PARAMETER;
800   }
801
802   EntryItem* p = static_cast<EntryItem*>(h->Get());
803   string str;
804   if (p->GetMultiLanguage() != nullptr &&
805       !p->GetMultiLanguage()->GetTranslatedString().empty())
806     str = p->GetMultiLanguage()->GetTranslatedString();
807   else if (!p->GetText().empty())
808     str = p->GetText();
809
810   *text = strdup(str.c_str());
811   if (*text == nullptr) {
812     LOGE("Out-of-memory");
813     return NOTI_EX_ERROR_OUT_OF_MEMORY;
814   }
815
816   return NOTI_EX_ERROR_NONE;
817 }
818
819 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
820     const char *text) {
821   if (handle == nullptr || text == nullptr) {
822     LOGE("Invalid parameter");
823     return NOTI_EX_ERROR_INVALID_PARAMETER;
824   }
825   Handle* h = static_cast<Handle*>(handle);
826   if (!h->IsValidType(AbstractItem::Entry)) {
827     LOGE("Invalid handle type");
828     return NOTI_EX_ERROR_INVALID_PARAMETER;
829   }
830   EntryItem* p = static_cast<EntryItem*>(h->Get());
831   p->SetText(std::string(text));
832
833   return NOTI_EX_ERROR_NONE;
834 }
835
836 extern "C" EXPORT_API int noti_ex_item_entry_set_multi_language(
837     noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
838   if (handle == nullptr) {
839     LOGE("Invalid parameter");
840     return NOTI_EX_ERROR_INVALID_PARAMETER;
841   }
842
843   Handle* p = static_cast<Handle*>(handle);
844   if (!p->IsValidType(AbstractItem::Entry)) {
845     LOGE("Invalid handle type");
846     return NOTI_EX_ERROR_INVALID_PARAMETER;
847   }
848
849   EntryItem* ei = static_cast<EntryItem*>(p->Get());
850   if (multi == nullptr) {
851     ei->SetMultiLanguage(nullptr);
852     return NOTI_EX_ERROR_NONE;
853   }
854
855   shared_ptr<MultiLanguage> mul_ptr =
856       *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
857   ei->SetMultiLanguage(mul_ptr);
858   ei->GetMultiLanguage()->UpdateString();
859
860   return NOTI_EX_ERROR_NONE;
861 }
862
863 extern "C" EXPORT_API int noti_ex_event_info_clone(noti_ex_event_info_h handle,
864                 noti_ex_event_info_h* cloned_handle) {
865   if (handle == nullptr || cloned_handle == nullptr) {
866     LOGE("Invalid parameter");
867     return NOTI_EX_ERROR_INVALID_PARAMETER;
868   }
869
870   Bundle cloned = static_cast<EventInfo*>(handle)->Serialize();
871   EventInfo* info = new EventInfo(cloned);
872   *cloned_handle = info;
873   return NOTI_EX_ERROR_NONE;
874 }
875
876 extern "C" EXPORT_API int noti_ex_event_info_destroy(
877     noti_ex_event_info_h handle) {
878   if (handle == nullptr) {
879     LOGE("Invalid parameter");
880     return NOTI_EX_ERROR_INVALID_PARAMETER;
881   }
882   EventInfo* info = static_cast<EventInfo*>(handle);
883   delete info;
884   return NOTI_EX_ERROR_NONE;
885 }
886
887 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
888     noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
889   if (handle == nullptr || event_type == nullptr) {
890     LOGE("Invalid parameter");
891     return NOTI_EX_ERROR_INVALID_PARAMETER;
892   }
893   EventInfo* info = static_cast<EventInfo*>(handle);
894   *event_type = static_cast<noti_ex_event_info_type_e>(info->GetEventType());
895
896   return NOTI_EX_ERROR_NONE;
897 }
898
899 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
900     noti_ex_event_info_h handle, char **owner) {
901   if (handle == nullptr || owner == nullptr) {
902     LOGE("Invalid parameter");
903     return NOTI_EX_ERROR_INVALID_PARAMETER;
904   }
905   EventInfo* info = static_cast<EventInfo*>(handle);
906   *owner = strdup(info->GetOwner().c_str());
907   return NOTI_EX_ERROR_NONE;
908 }
909
910 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
911     noti_ex_event_info_h handle, char **channel) {
912   if (handle == nullptr || channel == nullptr) {
913     LOGE("Invalid parameter");
914     return NOTI_EX_ERROR_INVALID_PARAMETER;
915   }
916   EventInfo* info = static_cast<EventInfo*>(handle);
917   *channel = strdup(info->GetChannel().c_str());
918   return NOTI_EX_ERROR_NONE;
919 }
920
921 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
922     noti_ex_event_info_h handle, char **item_id) {
923   if (handle == nullptr || item_id == nullptr) {
924     LOGE("Invalid parameter");
925     return NOTI_EX_ERROR_INVALID_PARAMETER;
926   }
927   EventInfo* info = static_cast<EventInfo*>(handle);
928   *item_id = strdup(info->GetItemId().c_str());
929   return NOTI_EX_ERROR_NONE;
930 }
931
932 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
933     noti_ex_event_info_h handle, int *req_id) {
934   if (handle == nullptr || req_id == nullptr) {
935     LOGE("Invalid parameter");
936     return NOTI_EX_ERROR_INVALID_PARAMETER;
937   }
938   EventInfo* info = static_cast<EventInfo*>(handle);
939   *req_id = info->GetRequestId();
940   return NOTI_EX_ERROR_NONE;
941 }
942
943 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
944     const char *id) {
945   GroupItem* p;
946
947   if (handle == nullptr) {
948     LOGE("Invalid parameter");
949     return NOTI_EX_ERROR_INVALID_PARAMETER;
950   }
951
952   if (id)
953     p = new (std::nothrow) GroupItem(id);
954   else
955     p = new (std::nothrow) GroupItem();
956
957   if (p == nullptr) {
958     LOGE("Out-of-memory");
959     return NOTI_EX_ERROR_OUT_OF_MEMORY;
960   }
961
962   *handle = new Handle(shared_ptr<AbstractItem>(p));
963
964   return NOTI_EX_ERROR_NONE;
965 }
966
967 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
968     bool vertical) {
969   if (handle == nullptr) {
970     LOGE("Invalid parameter");
971     return NOTI_EX_ERROR_INVALID_PARAMETER;
972   }
973   Handle* h = static_cast<Handle*>(handle);
974   if (!h->IsValidType(AbstractItem::Group)) {
975     LOGE("Invalid handle type");
976     return NOTI_EX_ERROR_INVALID_PARAMETER;
977   }
978   GroupItem* p = static_cast<GroupItem*>(h->Get());
979   p->SetDirection(vertical);
980
981   return NOTI_EX_ERROR_NONE;
982 }
983
984 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
985     bool *vertical) {
986   if (handle == nullptr) {
987     LOGE("Invalid parameter");
988     return NOTI_EX_ERROR_INVALID_PARAMETER;
989   }
990   Handle* h = static_cast<Handle*>(handle);
991   if (!h->IsValidType(AbstractItem::Group)) {
992     LOGE("Invalid handle type");
993     return NOTI_EX_ERROR_INVALID_PARAMETER;
994   }
995   GroupItem* p = static_cast<GroupItem*>(h->Get());
996   *vertical = p->IsVertical();
997
998   return NOTI_EX_ERROR_NONE;
999 }
1000
1001 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
1002     char **label) {
1003   if (handle == nullptr) {
1004     LOGE("Invalid parameter");
1005     return NOTI_EX_ERROR_INVALID_PARAMETER;
1006   }
1007   Handle* h = static_cast<Handle*>(handle);
1008   if (!h->IsValidType(AbstractItem::Group)) {
1009     LOGE("Invalid handle type");
1010     return NOTI_EX_ERROR_INVALID_PARAMETER;
1011   }
1012   GroupItem* p = static_cast<GroupItem*>(h->Get());
1013   if (!p->GetAppLabel().empty()) {
1014     *label = strdup(p->GetAppLabel().c_str());
1015     if (*label == nullptr) {
1016       LOGE("Out-of-memory");
1017       return NOTI_EX_ERROR_OUT_OF_MEMORY;
1018     }
1019   }
1020
1021   return NOTI_EX_ERROR_NONE;
1022 }
1023
1024 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
1025     noti_ex_item_h child) {
1026   if (handle == nullptr || child == nullptr) {
1027     LOGE("Invalid parameter");
1028     return NOTI_EX_ERROR_INVALID_PARAMETER;
1029   }
1030   Handle* h = static_cast<Handle*>(handle);
1031   if (!h->IsValidType(AbstractItem::Group)) {
1032     LOGE("Invalid handle type");
1033     return NOTI_EX_ERROR_INVALID_PARAMETER;
1034   }
1035   auto p = static_cast<GroupItem*>(h->Get());
1036   p->AddChild((static_cast<Handle*>(child))->GetPtr());
1037
1038   return NOTI_EX_ERROR_NONE;
1039 }
1040
1041 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
1042     const char *item_id) {
1043   if (handle == nullptr || item_id == nullptr) {
1044     LOGE("Invalid parameter");
1045     return NOTI_EX_ERROR_INVALID_PARAMETER;
1046   }
1047   Handle* h = static_cast<Handle*>(handle);
1048   if (!h->IsValidType(AbstractItem::Group)) {
1049     LOGE("Invalid handle type");
1050     return NOTI_EX_ERROR_INVALID_PARAMETER;
1051   }
1052   GroupItem* p = static_cast<GroupItem*>(h->Get());
1053   p->RemoveChild(std::string(item_id));
1054
1055   return NOTI_EX_ERROR_NONE;
1056 }
1057
1058 extern "C" EXPORT_API int noti_ex_item_group_foreach_child(noti_ex_item_h handle,
1059     noti_ex_item_group_foreach_child_cb callback, void *data) {
1060   if (handle == nullptr || callback == nullptr) {
1061     LOGE("Invalid parameter");
1062     return NOTI_EX_ERROR_INVALID_PARAMETER;
1063   }
1064
1065   Handle* h = static_cast<Handle*>(handle);
1066   if (!h->IsValidType(AbstractItem::Group)) {
1067     LOGE("Invalid handle type");
1068     return NOTI_EX_ERROR_INVALID_PARAMETER;
1069   }
1070   GroupItem* p = static_cast<GroupItem*>(h->Get());
1071   list<shared_ptr<AbstractItem>> children = p->GetChildren();
1072   LOGI("Retrive (%zd)", children.size());
1073   for (auto i : children) {
1074     int ret = callback(
1075         static_cast<noti_ex_item_h>(new Handle(i)), data);
1076     if (ret != NOTI_EX_ERROR_NONE) {
1077       LOGW("callback return (%d) stop foreach", ret);
1078       break;
1079     }
1080   }
1081
1082   return NOTI_EX_ERROR_NONE;
1083 }
1084
1085 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
1086     const char *id, const char *image_path) {
1087   ImageItem* p;
1088
1089   if (handle == nullptr  || image_path == nullptr) {
1090     LOGE("Invalid parameter");
1091     return NOTI_EX_ERROR_INVALID_PARAMETER;
1092   }
1093
1094   if (id)
1095     p = new (std::nothrow) ImageItem(id, image_path);
1096   else
1097     p = new (std::nothrow) ImageItem(image_path);
1098
1099   if (p == nullptr) {
1100     LOGE("Out-of-memory");
1101     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1102   }
1103
1104   *handle = new Handle(shared_ptr<AbstractItem>(p));
1105
1106   return NOTI_EX_ERROR_NONE;
1107 }
1108
1109 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
1110     noti_ex_item_h handle, char **image_path) {
1111   if (handle == nullptr || image_path == nullptr) {
1112     LOGE("Invalid parameter");
1113     return NOTI_EX_ERROR_INVALID_PARAMETER;
1114   }
1115   Handle* h = static_cast<Handle*>(handle);
1116   if (!h->IsValidType(AbstractItem::Image)) {
1117     LOGE("Invalid handle type");
1118     return NOTI_EX_ERROR_INVALID_PARAMETER;
1119   }
1120   ImageItem* p = static_cast<ImageItem*>(h->Get());
1121   if (!p->GetImagePath().empty()) {
1122     *image_path = strdup(p->GetImagePath().c_str());
1123     if (*image_path == nullptr) {
1124       LOGE("Out-of-memory");
1125       return NOTI_EX_ERROR_OUT_OF_MEMORY;
1126     }
1127   } else {
1128     *image_path = nullptr;
1129   }
1130
1131   return NOTI_EX_ERROR_NONE;
1132 }
1133
1134 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
1135     noti_ex_item_h *handle, const char *id) {
1136   InputSelectorItem* p;
1137
1138   if (handle == nullptr) {
1139     LOGE("Invalid parameter");
1140     return NOTI_EX_ERROR_INVALID_PARAMETER;
1141   }
1142
1143   if (id)
1144     p = new (std::nothrow) InputSelectorItem(id);
1145   else
1146     p = new (std::nothrow) InputSelectorItem();
1147
1148   if (p == nullptr) {
1149     LOGE("Out-of-memory");
1150     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1151   }
1152
1153   *handle = new Handle(shared_ptr<AbstractItem>(p));
1154
1155   return NOTI_EX_ERROR_NONE;
1156 }
1157
1158 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
1159     noti_ex_item_h handle, char ***contents_list, int *count) {
1160   if (handle == nullptr || contents_list == nullptr || count == nullptr) {
1161     LOGE("Invalid parameter");
1162     return NOTI_EX_ERROR_INVALID_PARAMETER;
1163   }
1164
1165   Handle* h = static_cast<Handle*>(handle);
1166   if (!h->IsValidType(AbstractItem::InputSelector)) {
1167     LOGE("Invalid handle type");
1168     return NOTI_EX_ERROR_INVALID_PARAMETER;
1169   }
1170
1171   InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1172   vector<shared_ptr<MultiLanguage>> arr = p->GetMultiLanguageArr();
1173   list<string> contents;
1174   if (arr.size() == 0) {
1175     contents = p->GetContents();
1176   } else {
1177     for (auto& i : arr) {
1178       contents.push_back(i->GetTranslatedString());
1179     }
1180   }
1181
1182   char **list = (char**)calloc(contents.size(), sizeof(char*));
1183   if (list == nullptr) {
1184     LOGE("Out of memory");
1185     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1186   }
1187
1188   int idx = 0;
1189   for (auto& i : contents) {
1190     list[idx] = strdup(i.c_str());
1191     if (list[idx] == nullptr) {
1192       __noti_ex_free_str_array(list, idx);
1193       LOGE("Out of memory");
1194       return NOTI_EX_ERROR_OUT_OF_MEMORY;
1195     }
1196     idx++;
1197   }
1198
1199   *count = contents.size();
1200   *contents_list = list;
1201
1202   return NOTI_EX_ERROR_NONE;
1203 }
1204
1205 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
1206     noti_ex_item_h handle, const char **contents, int count) {
1207   if (handle == nullptr || contents == nullptr) {
1208     LOGE("Invalid parameter");
1209     return NOTI_EX_ERROR_INVALID_PARAMETER;
1210   }
1211
1212   list<string> new_contents;
1213   Handle* h = static_cast<Handle*>(handle);
1214   if (!h->IsValidType(AbstractItem::InputSelector)) {
1215     LOGE("Invalid handle type");
1216     return NOTI_EX_ERROR_INVALID_PARAMETER;
1217   }
1218   InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1219   for (int i = 0; i < count; i++) {
1220     new_contents.push_back(contents[i]);
1221   }
1222   p->SetContents(move(new_contents));
1223
1224   return NOTI_EX_ERROR_NONE;
1225 }
1226
1227 extern "C" EXPORT_API int noti_ex_item_input_selector_set_multi_language_contents(
1228     noti_ex_item_h handle, noti_ex_multi_lang_h* multi_language_list, int count) {
1229   if (handle == nullptr) {
1230     LOGE("Invalid parameter");
1231     return NOTI_EX_ERROR_INVALID_PARAMETER;
1232   }
1233
1234   Handle* p = static_cast<Handle*>(handle);
1235   if (!p->IsValidType(AbstractItem::InputSelector)) {
1236     LOGE("Invalid handle type");
1237     return NOTI_EX_ERROR_INVALID_PARAMETER;
1238   }
1239
1240   vector<shared_ptr<MultiLanguage>> m_list;
1241   for (int i = 0; i < count; i++) {
1242     shared_ptr<MultiLanguage> mul_ptr =
1243       *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi_language_list[i]);
1244     mul_ptr->UpdateString();
1245     m_list.push_back(mul_ptr);
1246   }
1247
1248   InputSelectorItem* input = static_cast<InputSelectorItem*>(p->Get());
1249   input->SetMultiLanguage(m_list);
1250
1251   return NOTI_EX_ERROR_NONE;
1252 }
1253
1254 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
1255     unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
1256   if (handle == nullptr) {
1257     LOGE("Invalid parameter");
1258     return NOTI_EX_ERROR_INVALID_PARAMETER;
1259   }
1260
1261   auto* ptr = new (std::nothrow) shared_ptr<Color>(
1262       new (std::nothrow) Color(a, r, g, b));
1263   if (ptr == nullptr || ptr->get() == nullptr) {
1264     LOGE("Out-of-memory");
1265     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1266   }
1267
1268   *handle = ptr;
1269
1270   return NOTI_EX_ERROR_NONE;
1271 }
1272
1273 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
1274   if (handle == nullptr) {
1275     LOGE("Invalid parameter");
1276     return NOTI_EX_ERROR_INVALID_PARAMETER;
1277   }
1278
1279   shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1280   delete p;
1281
1282   return NOTI_EX_ERROR_NONE;
1283 }
1284
1285 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
1286     unsigned char *val) {
1287   if (handle == nullptr || val == nullptr) {
1288     LOGE("Invalid parameter");
1289     return NOTI_EX_ERROR_INVALID_PARAMETER;
1290   }
1291
1292   shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1293   *val = (*p)->GetAVal();
1294
1295   return NOTI_EX_ERROR_NONE;
1296 }
1297
1298 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
1299     unsigned char *val) {
1300   if (handle == nullptr || val == nullptr) {
1301     LOGE("Invalid parameter");
1302     return NOTI_EX_ERROR_INVALID_PARAMETER;
1303   }
1304
1305   shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1306   *val = (*p)->GetRVal();
1307
1308   return NOTI_EX_ERROR_NONE;
1309 }
1310
1311 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
1312     unsigned char *val) {
1313   if (handle == nullptr || val == nullptr) {
1314     LOGE("Invalid parameter");
1315     return NOTI_EX_ERROR_INVALID_PARAMETER;
1316   }
1317
1318   shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1319   *val = (*p)->GetGVal();
1320
1321   return NOTI_EX_ERROR_NONE;
1322 }
1323
1324 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
1325     unsigned char *val) {
1326   if (handle == nullptr || val == nullptr) {
1327     LOGE("Invalid parameter");
1328     return NOTI_EX_ERROR_INVALID_PARAMETER;
1329   }
1330
1331   shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1332   *val = (*p)->GetBVal();
1333
1334   return NOTI_EX_ERROR_NONE;
1335 }
1336
1337 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
1338     int left, int top, int right, int bottom) {
1339   if (handle == nullptr) {
1340     LOGE("Invalid parameter");
1341     return NOTI_EX_ERROR_INVALID_PARAMETER;
1342   }
1343
1344   auto* ptr = new (std::nothrow) shared_ptr<Padding>(
1345       new (std::nothrow) Padding(left, top, right, bottom));
1346   if (ptr == nullptr || ptr->get() == nullptr) {
1347     LOGE("Out-of-memory");
1348     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1349   }
1350
1351   *handle = ptr;
1352
1353   return NOTI_EX_ERROR_NONE;
1354 }
1355
1356 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
1357   if (handle == nullptr) {
1358     LOGE("Invalid parameter");
1359     return NOTI_EX_ERROR_INVALID_PARAMETER;
1360   }
1361
1362   shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1363   delete p;
1364
1365   return NOTI_EX_ERROR_NONE;
1366 }
1367
1368 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
1369     int *val) {
1370   if (handle == nullptr || val == nullptr) {
1371     LOGE("Invalid parameter");
1372     return NOTI_EX_ERROR_INVALID_PARAMETER;
1373   }
1374
1375   shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1376   *val = (*p)->GetLeft();
1377
1378   return NOTI_EX_ERROR_NONE;
1379 }
1380
1381 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
1382     int *val) {
1383   if (handle == nullptr || val == nullptr) {
1384     LOGE("Invalid parameter");
1385     return NOTI_EX_ERROR_INVALID_PARAMETER;
1386   }
1387
1388   shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1389   *val = (*p)->GetTop();
1390
1391   return NOTI_EX_ERROR_NONE;
1392 }
1393
1394 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
1395     int *val) {
1396   if (handle == nullptr || val == nullptr) {
1397     LOGE("Invalid parameter");
1398     return NOTI_EX_ERROR_INVALID_PARAMETER;
1399   }
1400
1401   shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1402   *val = (*p)->GetRight();
1403
1404   return NOTI_EX_ERROR_NONE;
1405 }
1406
1407 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
1408     int *val) {
1409   if (handle == nullptr || val == nullptr) {
1410     LOGE("Invalid parameter");
1411     return NOTI_EX_ERROR_INVALID_PARAMETER;
1412   }
1413
1414   shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1415   *val = (*p)->GetBottom();
1416
1417   return NOTI_EX_ERROR_NONE;
1418 }
1419
1420 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
1421     int x, int y, int w, int h) {
1422   if (handle == nullptr) {
1423     LOGE("Invalid parameter");
1424     return NOTI_EX_ERROR_INVALID_PARAMETER;
1425   }
1426
1427   auto* ptr = new (std::nothrow) shared_ptr<Geometry>(
1428       new (std::nothrow) Geometry(x, y, w, h));
1429   if (ptr == nullptr || ptr->get() == nullptr) {
1430     LOGE("Out-of-memory");
1431     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1432   }
1433
1434   *handle = ptr;
1435
1436   return NOTI_EX_ERROR_NONE;
1437 }
1438
1439 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
1440   if (handle == nullptr) {
1441     LOGE("Invalid parameter");
1442     return NOTI_EX_ERROR_INVALID_PARAMETER;
1443   }
1444
1445   shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1446   delete p;
1447
1448   return NOTI_EX_ERROR_NONE;
1449 }
1450
1451 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
1452     int *val) {
1453   if (handle == nullptr || val == nullptr) {
1454     LOGE("Invalid parameter");
1455     return NOTI_EX_ERROR_INVALID_PARAMETER;
1456   }
1457
1458   shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1459   *val = (*p)->GetX();
1460
1461   return NOTI_EX_ERROR_NONE;
1462 }
1463
1464 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
1465     int *val) {
1466   if (handle == nullptr || val == nullptr) {
1467     LOGE("Invalid parameter");
1468     return NOTI_EX_ERROR_INVALID_PARAMETER;
1469   }
1470
1471   shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1472   *val = (*p)->GetY();
1473
1474   return NOTI_EX_ERROR_NONE;
1475 }
1476
1477 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
1478     int *val) {
1479   if (handle == nullptr || val == nullptr) {
1480     LOGE("Invalid parameter");
1481     return NOTI_EX_ERROR_INVALID_PARAMETER;
1482   }
1483
1484   shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1485   *val = (*p)->GetWidth();
1486
1487   return NOTI_EX_ERROR_NONE;
1488 }
1489
1490 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
1491     int *val) {
1492   if (handle == nullptr || val == nullptr) {
1493     LOGE("Invalid parameter");
1494     return NOTI_EX_ERROR_INVALID_PARAMETER;
1495   }
1496
1497   shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1498   *val = (*p)->GetHeight();
1499
1500   return NOTI_EX_ERROR_NONE;
1501 }
1502
1503 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
1504     noti_ex_color_h color,
1505     noti_ex_padding_h padding,
1506     noti_ex_geometry_h geometry) {
1507   if (handle == nullptr) {
1508     LOGE("Invalid parameter");
1509     return NOTI_EX_ERROR_INVALID_PARAMETER;
1510   }
1511
1512   shared_ptr<Color> col = (color == nullptr) ?
1513       nullptr : *(static_cast<shared_ptr<Color>*>(color));
1514   shared_ptr<Padding> padd = (padding == nullptr) ?
1515       nullptr : *(static_cast<shared_ptr<Padding>*>(padding));
1516   shared_ptr<Geometry> geo = (geometry == nullptr) ?
1517       nullptr : *(static_cast<shared_ptr<Geometry>*>(geometry));
1518
1519   auto* ptr = new (std::nothrow) shared_ptr<Style>(
1520       new (std::nothrow) Style(col, padd, geo));
1521   if (ptr == nullptr || ptr->get() == nullptr) {
1522     LOGE("Out-of-memory");
1523     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1524   }
1525
1526   *handle = ptr;
1527
1528   return NOTI_EX_ERROR_NONE;
1529 }
1530
1531 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
1532   if (handle == nullptr) {
1533     LOGE("Invalid parameter");
1534     return NOTI_EX_ERROR_INVALID_PARAMETER;
1535   }
1536
1537   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1538   delete p;
1539
1540   return NOTI_EX_ERROR_NONE;
1541 }
1542
1543 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
1544     noti_ex_padding_h *padding) {
1545   if (handle == nullptr || padding == nullptr) {
1546     LOGE("Invalid parameter");
1547     return NOTI_EX_ERROR_INVALID_PARAMETER;
1548   }
1549
1550   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1551   if ((*p)->GetPadding() == nullptr) {
1552     LOGW("Padding info is null");
1553     return NOTI_EX_ERROR_INVALID_PARAMETER;
1554   }
1555
1556   shared_ptr<Padding>* padd = new (std::nothrow) shared_ptr<Padding>(
1557       new (std::nothrow) Padding(*((*p)->GetPadding())));
1558   if (padd == nullptr || padd->get() == nullptr) {
1559     LOGE("Out-of-memory");
1560     *padding = nullptr;
1561     return NOTI_EX_ERROR_NONE;
1562   }
1563
1564   *padding = padd;
1565
1566   return NOTI_EX_ERROR_NONE;
1567 }
1568
1569
1570 extern "C" EXPORT_API int noti_ex_style_set_padding(noti_ex_style_h handle,
1571     noti_ex_padding_h padding) {
1572   if (handle == nullptr) {
1573     LOGE("Invalid parameter");
1574     return NOTI_EX_ERROR_INVALID_PARAMETER;
1575   }
1576
1577   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1578   if (padding == nullptr) {
1579     (*p)->SetPadding(nullptr);
1580     return NOTI_EX_ERROR_NONE;
1581   }
1582
1583   shared_ptr<Padding>* padd = static_cast<shared_ptr<Padding>*>(padding);
1584   (*p)->SetPadding(*padd);
1585
1586   return NOTI_EX_ERROR_NONE;
1587 }
1588
1589 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
1590     noti_ex_color_h *color) {
1591   if (handle == nullptr || color == nullptr) {
1592     LOGE("Invalid parameter");
1593     return NOTI_EX_ERROR_INVALID_PARAMETER;
1594   }
1595
1596   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1597   if ((*p)->GetColor() == nullptr) {
1598     LOGW("Color info is null");
1599     *color = nullptr;
1600     return NOTI_EX_ERROR_NONE;
1601   }
1602
1603   shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1604       new (std::nothrow) Color(*((*p)->GetColor())));
1605   if (col == nullptr || col->get() == nullptr) {
1606     LOGE("Out-of-memory");
1607     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1608   }
1609
1610   *color = col;
1611
1612   return NOTI_EX_ERROR_NONE;
1613 }
1614
1615 extern "C" EXPORT_API int noti_ex_style_set_color(
1616     noti_ex_style_h handle, noti_ex_color_h color) {
1617   if (handle == nullptr) {
1618     LOGE("Invalid parameter");
1619     return NOTI_EX_ERROR_INVALID_PARAMETER;
1620   }
1621
1622   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1623   if (color == nullptr) {
1624     (*p)->SetColor(nullptr);
1625     return NOTI_EX_ERROR_NONE;
1626   }
1627
1628   shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1629   (*p)->SetColor(*col);
1630
1631   return NOTI_EX_ERROR_NONE;
1632 }
1633
1634 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
1635     noti_ex_geometry_h *geometry) {
1636   if (handle == nullptr || geometry == nullptr) {
1637     LOGE("Invalid parameter");
1638     return NOTI_EX_ERROR_INVALID_PARAMETER;
1639   }
1640
1641   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1642   if ((*p)->GetGeometry() == nullptr) {
1643     LOGW("Geometry info is null");
1644     *geometry = nullptr;
1645     return NOTI_EX_ERROR_NONE;
1646   }
1647
1648   shared_ptr<Geometry>* geo = new (std::nothrow) shared_ptr<Geometry>(
1649       new (std::nothrow) Geometry(*((*p)->GetGeometry())));
1650   if (geo == nullptr || geo->get() == nullptr) {
1651     LOGE("Out-of-memory");
1652     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1653   }
1654
1655   *geometry = geo;
1656
1657   return NOTI_EX_ERROR_NONE;
1658 }
1659
1660 extern "C" EXPORT_API int noti_ex_style_set_geometry(
1661     noti_ex_style_h handle, noti_ex_geometry_h geometry) {
1662   if (handle == nullptr) {
1663     LOGE("Invalid parameter");
1664     return NOTI_EX_ERROR_INVALID_PARAMETER;
1665   }
1666
1667   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1668   if (geometry == nullptr) {
1669     (*p)->SetGeometry(nullptr);
1670     return NOTI_EX_ERROR_NONE;
1671   }
1672
1673   shared_ptr<Geometry>* geo = static_cast<shared_ptr<Geometry>*>(geometry);
1674   (*p)->SetGeometry(*geo);
1675
1676   return NOTI_EX_ERROR_NONE;
1677 }
1678
1679 extern "C" EXPORT_API int noti_ex_style_get_background_image(
1680     noti_ex_style_h handle, char** background_image) {
1681   if (handle == nullptr || background_image == nullptr) {
1682     LOGE("Invalid parameter");
1683     return NOTI_EX_ERROR_INVALID_PARAMETER;
1684   }
1685
1686   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1687
1688   if ((*p)->GetBackgroundImage().empty())
1689     *background_image = nullptr;
1690   else
1691     *background_image = strdup((*p)->GetBackgroundImage().c_str());
1692
1693   return NOTI_EX_ERROR_NONE;
1694 }
1695
1696 extern "C" EXPORT_API int noti_ex_style_set_background_image(
1697     noti_ex_style_h handle, char* background_image) {
1698   if (handle == nullptr) {
1699     LOGE("Invalid parameter");
1700     return NOTI_EX_ERROR_INVALID_PARAMETER;
1701   }
1702
1703   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1704   if (background_image == nullptr)
1705     (*p)->SetBackgroundImage("");
1706   else
1707     (*p)->SetBackgroundImage(background_image);
1708
1709   return NOTI_EX_ERROR_NONE;
1710 }
1711
1712 extern "C" EXPORT_API int noti_ex_style_get_background_color(
1713     noti_ex_style_h handle, noti_ex_color_h* color) {
1714   if (handle == nullptr || color == nullptr) {
1715     LOGE("Invalid parameter");
1716     return NOTI_EX_ERROR_INVALID_PARAMETER;
1717   }
1718
1719   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1720   if ((*p)->GetBackgroundColor() == nullptr) {
1721     LOGW("Color info is null");
1722     *color = nullptr;
1723     return NOTI_EX_ERROR_NONE;
1724   }
1725
1726   shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1727       new (std::nothrow) Color(*((*p)->GetBackgroundColor())));
1728   if (col == nullptr || col->get() == nullptr) {
1729     LOGE("Out-of-memory");
1730     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1731   }
1732
1733   *color = col;
1734
1735   return NOTI_EX_ERROR_NONE;
1736 }
1737
1738 extern "C" EXPORT_API int noti_ex_style_set_background_color(
1739     noti_ex_style_h handle, noti_ex_color_h color) {
1740   if (handle == nullptr) {
1741     LOGE("Invalid parameter");
1742     return NOTI_EX_ERROR_INVALID_PARAMETER;
1743   }
1744
1745   shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1746   if (color == nullptr) {
1747     (*p)->SetBackgroundColor(nullptr);
1748     return NOTI_EX_ERROR_NONE;
1749   }
1750
1751   shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1752   (*p)->SetBackgroundColor(*col);
1753
1754   return NOTI_EX_ERROR_NONE;
1755 }
1756
1757 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
1758     noti_ex_color_h color) {
1759   if (handle == nullptr || color == nullptr) {
1760     LOGE("Invalid parameter");
1761     return NOTI_EX_ERROR_INVALID_PARAMETER;
1762   }
1763
1764   shared_ptr<Color>* color_ptr = static_cast<shared_ptr<Color>*>(color);
1765   shared_ptr<LEDInfo>* p = new (std::nothrow) shared_ptr<LEDInfo>(
1766       new (std::nothrow) LEDInfo(*color_ptr));
1767   if (p == nullptr) {
1768     LOGE("Out-of-memory");
1769     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1770   }
1771
1772   *handle = p;
1773
1774   return NOTI_EX_ERROR_NONE;
1775 }
1776
1777 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
1778   if (handle == nullptr) {
1779     LOGE("Invalid parameter");
1780     return NOTI_EX_ERROR_INVALID_PARAMETER;
1781   }
1782
1783   shared_ptr<LEDInfo>* led_ptr =
1784       reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1785   delete led_ptr;
1786   return NOTI_EX_ERROR_NONE;
1787 }
1788
1789 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
1790     noti_ex_led_info_h handle, int ms) {
1791   if (handle == nullptr) {
1792     LOGE("Invalid parameter");
1793     return NOTI_EX_ERROR_INVALID_PARAMETER;
1794   }
1795
1796   shared_ptr<LEDInfo>* led_ptr =
1797       reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1798   (*led_ptr)->SetOnPeriod(ms);
1799
1800   return NOTI_EX_ERROR_NONE;
1801 }
1802
1803 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
1804     noti_ex_led_info_h handle, int *ms) {
1805   if (handle == nullptr || ms == nullptr) {
1806     LOGE("Invalid parameter");
1807     return NOTI_EX_ERROR_INVALID_PARAMETER;
1808   }
1809
1810   shared_ptr<LEDInfo>* led_ptr =
1811       reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1812   *ms = (*led_ptr)->GetOnPeriod();
1813
1814   return NOTI_EX_ERROR_NONE;
1815 }
1816
1817 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
1818     noti_ex_led_info_h handle, int ms) {
1819   if (handle == nullptr) {
1820     LOGE("Invalid parameter");
1821     return NOTI_EX_ERROR_INVALID_PARAMETER;
1822   }
1823
1824   shared_ptr<LEDInfo>* led_ptr =
1825       reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1826   (*led_ptr)->SetOffPeriod(ms);
1827
1828   return NOTI_EX_ERROR_NONE;
1829 }
1830
1831 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
1832     noti_ex_led_info_h handle, int *ms) {
1833   if (handle == nullptr) {
1834     LOGE("Invalid parameter");
1835     return NOTI_EX_ERROR_INVALID_PARAMETER;
1836   }
1837
1838   shared_ptr<LEDInfo>* led_ptr =
1839       reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1840   *ms = (*led_ptr)->GetOffPeriod();
1841
1842   return NOTI_EX_ERROR_NONE;
1843 }
1844
1845 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1846     noti_ex_led_info_h handle, noti_ex_color_h *color) {
1847   if (handle == nullptr) {
1848     LOGE("Invalid parameter");
1849     return NOTI_EX_ERROR_INVALID_PARAMETER;
1850   }
1851
1852   shared_ptr<LEDInfo>* led_ptr =
1853       reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1854   if ((*led_ptr)->GetColor() == nullptr) {
1855     LOGW("Color is null");
1856     *color = nullptr;
1857     return NOTI_EX_ERROR_NONE;
1858   }
1859
1860   shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1861       new (std::nothrow) Color(*((*led_ptr)->GetColor())));
1862   if (col == nullptr || col->get() == nullptr) {
1863     LOGE("Out-of-memory");
1864     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1865   }
1866
1867   *color = col;
1868
1869   return NOTI_EX_ERROR_NONE;
1870 }
1871
1872 extern "C" EXPORT_API int noti_ex_led_info_set_color(
1873     noti_ex_led_info_h handle, noti_ex_color_h color) {
1874   if (handle == nullptr) {
1875     LOGE("Invalid parameter");
1876     return NOTI_EX_ERROR_INVALID_PARAMETER;
1877   }
1878
1879   shared_ptr<LEDInfo>* p = static_cast<shared_ptr<LEDInfo>*>(handle);
1880   if (color == nullptr) {
1881     (*p)->SetColor(nullptr);
1882     return NOTI_EX_ERROR_NONE;
1883   }
1884
1885   shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1886   (*p)->SetColor(*col);
1887
1888   return NOTI_EX_ERROR_NONE;
1889 }
1890
1891 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1892   if (handle == nullptr) {
1893     LOGE("Invalid parameter");
1894     return NOTI_EX_ERROR_INVALID_PARAMETER;
1895   }
1896
1897   shared_ptr<AbstractAction>* ptr =
1898       static_cast<shared_ptr<AbstractAction>*>(handle);
1899   delete ptr;
1900
1901   return NOTI_EX_ERROR_NONE;
1902 }
1903
1904 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1905     int *type) {
1906   if (handle == nullptr || type == nullptr) {
1907     LOGE("Invalid parameter");
1908     return NOTI_EX_ERROR_INVALID_PARAMETER;
1909   }
1910
1911   shared_ptr<AbstractAction>* ptr =
1912       static_cast<shared_ptr<AbstractAction>*>(handle);
1913   *type = (*ptr)->GetType();
1914
1915   return NOTI_EX_ERROR_NONE;
1916 }
1917
1918 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1919     bool *local) {
1920   if (handle == nullptr || local == nullptr) {
1921     LOGE("Invalid parameter");
1922     return NOTI_EX_ERROR_INVALID_PARAMETER;
1923   }
1924
1925   shared_ptr<AbstractAction>* ptr =
1926       static_cast<shared_ptr<AbstractAction>*>(handle);
1927   *local = (*ptr)->IsLocal();
1928
1929   return NOTI_EX_ERROR_NONE;
1930 }
1931
1932 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1933     noti_ex_item_h item) {
1934   if (handle == nullptr || item == nullptr) {
1935     LOGE("Invalid parameter");
1936     return NOTI_EX_ERROR_INVALID_PARAMETER;
1937   }
1938   shared_ptr<AbstractAction>* ptr =
1939       static_cast<shared_ptr<AbstractAction>*>(handle);
1940   Handle* ih = static_cast<Handle*>(item);
1941   (*ptr)->Execute(ih->GetPtr());
1942
1943   return NOTI_EX_ERROR_NONE;
1944 }
1945
1946 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1947     char **extra) {
1948   if (handle == nullptr || extra == nullptr) {
1949     LOGE("Invalid parameter");
1950     return NOTI_EX_ERROR_INVALID_PARAMETER;
1951   }
1952
1953   shared_ptr<AbstractAction>* ptr =
1954       static_cast<shared_ptr<AbstractAction>*>(handle);
1955   if (!(*ptr)->GetExtra().empty()) {
1956     *extra = strdup((*ptr)->GetExtra().c_str());
1957     if (*extra == nullptr) {
1958       LOGE("Out-of-memory");
1959       return NOTI_EX_ERROR_OUT_OF_MEMORY;
1960     }
1961   } else {
1962     *extra = nullptr;
1963   }
1964
1965   return NOTI_EX_ERROR_NONE;
1966 }
1967
1968 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1969     noti_ex_item_info_h handle, int *hide_time) {
1970   if (handle == nullptr || hide_time == nullptr) {
1971     LOGE("Invalid parameter");
1972     return NOTI_EX_ERROR_INVALID_PARAMETER;
1973   }
1974   IItemInfo* p = static_cast<IItemInfo*>(handle);
1975   *hide_time = p->GetHideTime();
1976   return NOTI_EX_ERROR_NONE;
1977 }
1978
1979 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1980     noti_ex_item_info_h handle, int hide_time) {
1981   if (handle == nullptr) {
1982     LOGE("Invalid parameter");
1983     return NOTI_EX_ERROR_INVALID_PARAMETER;
1984   }
1985   IItemInfo* p = static_cast<IItemInfo*>(handle);
1986   p->SetHideTime(hide_time);
1987   return NOTI_EX_ERROR_NONE;
1988 }
1989
1990 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1991     noti_ex_item_info_h handle, int *delete_time) {
1992   if (handle == nullptr || delete_time == nullptr) {
1993     LOGE("Invalid parameter");
1994     return NOTI_EX_ERROR_INVALID_PARAMETER;
1995   }
1996   IItemInfo* p = static_cast<IItemInfo*>(handle);
1997   *delete_time = p->GetDeleteTime();
1998   return NOTI_EX_ERROR_NONE;
1999 }
2000
2001 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
2002     noti_ex_item_info_h handle, int delete_time) {
2003   if (handle == nullptr) {
2004     LOGE("Invalid parameter");
2005     return NOTI_EX_ERROR_INVALID_PARAMETER;
2006   }
2007   IItemInfo* p = static_cast<IItemInfo*>(handle);
2008   p->SetDeleteTime(delete_time);
2009   return NOTI_EX_ERROR_NONE;
2010 }
2011
2012 extern "C" EXPORT_API int noti_ex_item_info_get_time(
2013     noti_ex_item_info_h handle, time_t *time) {
2014   if (handle == nullptr || time == nullptr) {
2015     LOGE("Invalid parameter");
2016     return NOTI_EX_ERROR_INVALID_PARAMETER;
2017   }
2018
2019   IItemInfo* p = static_cast<IItemInfo*>(handle);
2020   *time = p->GetTime();
2021   return NOTI_EX_ERROR_NONE;
2022 }
2023
2024 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
2025   if (handle == nullptr) {
2026     LOGE("Invalid parameter");
2027     return NOTI_EX_ERROR_INVALID_PARAMETER;
2028   }
2029
2030   Handle* h = static_cast<Handle*>(handle);
2031   delete h;
2032   return NOTI_EX_ERROR_NONE;
2033 }
2034
2035 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
2036     const char *id, noti_ex_item_h *item) {
2037   if (handle == nullptr) {
2038     LOGE("Invalid parameter");
2039     return NOTI_EX_ERROR_INVALID_PARAMETER;
2040   }
2041
2042   Handle* p = static_cast<Handle*>(handle);
2043   AbstractItem& find_item = p->Get()->FindByID(string(id));
2044   if (find_item.GetType() == AbstractItem::NullObject) {
2045     LOGW("Not exist ID");
2046     *item = nullptr;
2047     return NOTI_EX_ERROR_NONE;
2048   }
2049
2050   *item = new Handle(&find_item);
2051   return NOTI_EX_ERROR_NONE;
2052 }
2053
2054 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
2055     int *type) {
2056   if (handle == nullptr || type == nullptr) {
2057     LOGE("Invalid parameter");
2058     return NOTI_EX_ERROR_INVALID_PARAMETER;
2059   }
2060
2061   Handle* h = static_cast<Handle*>(handle);
2062   AbstractItem* p = h->Get();
2063   *type = p->GetType();
2064   return NOTI_EX_ERROR_NONE;
2065 }
2066
2067 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
2068     char **id) {
2069   if (handle == nullptr || id == nullptr) {
2070     LOGE("Invalid parameter");
2071     return NOTI_EX_ERROR_INVALID_PARAMETER;
2072   }
2073   Handle* h = static_cast<Handle*>(handle);
2074   AbstractItem* p = h->Get();
2075   *id = strdup(p->GetId().c_str());
2076   return NOTI_EX_ERROR_NONE;
2077 }
2078
2079 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
2080     const char *id) {
2081   if (handle == nullptr || id == nullptr) {
2082     LOGE("Invalid parameter");
2083     return NOTI_EX_ERROR_INVALID_PARAMETER;
2084   }
2085   Handle* p = static_cast<Handle*>(handle);
2086   p->Get()->SetId(id);
2087   return NOTI_EX_ERROR_NONE;
2088 }
2089
2090 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
2091     noti_ex_action_h *action) {
2092   if (handle == nullptr || action == nullptr) {
2093     LOGE("Invalid parameter");
2094     return NOTI_EX_ERROR_INVALID_PARAMETER;
2095   }
2096   Handle* p = static_cast<Handle*>(handle);
2097   if (p->Get()->GetAction() == nullptr) {
2098     *action = nullptr;
2099     return NOTI_EX_ERROR_NONE;
2100   }
2101   *action = static_cast<noti_ex_action_h>(new shared_ptr<AbstractAction>(
2102       p->Get()->GetAction()));
2103
2104   return NOTI_EX_ERROR_NONE;
2105 }
2106
2107 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
2108     noti_ex_action_h action) {
2109   if (handle == nullptr) {
2110     LOGE("Invalid parameter");
2111     return NOTI_EX_ERROR_INVALID_PARAMETER;
2112   }
2113
2114   Handle* p = static_cast<Handle*>(handle);
2115   if (action == nullptr) {
2116     p->Get()->SetAction(nullptr);
2117     return NOTI_EX_ERROR_NONE;
2118   }
2119
2120   shared_ptr<AbstractAction>* ptr =
2121       static_cast<shared_ptr<AbstractAction>*>(action);
2122   p->Get()->SetAction(*ptr);
2123   return NOTI_EX_ERROR_NONE;
2124 }
2125
2126 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
2127     noti_ex_style_h *style) {
2128   if (handle == nullptr || style == nullptr) {
2129     LOGE("Invalid parameter");
2130     return NOTI_EX_ERROR_INVALID_PARAMETER;
2131   }
2132
2133   Handle* p = static_cast<Handle*>(handle);
2134   shared_ptr<Style> s = p->Get()->GetStyle();
2135   if (s.get() == nullptr) {
2136     LOGW("Style is null");
2137     *style = nullptr;
2138     return NOTI_EX_ERROR_NONE;
2139   }
2140
2141   auto* ptr = new (std::nothrow) shared_ptr<Style>(new (std::nothrow) Style(*s));
2142   if (ptr == nullptr || ptr->get() == nullptr) {
2143     LOGE("Out of memory");
2144     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2145   }
2146
2147   *style = ptr;
2148   return NOTI_EX_ERROR_NONE;
2149 }
2150
2151 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
2152     noti_ex_style_h style) {
2153   if (handle == nullptr) {
2154     LOGE("Invalid parameter");
2155     return NOTI_EX_ERROR_INVALID_PARAMETER;
2156   }
2157
2158   Handle* p = static_cast<Handle*>(handle);
2159   if (style == nullptr) {
2160     p->Get()->SetStyle(nullptr);
2161     return NOTI_EX_ERROR_NONE;
2162   }
2163
2164   shared_ptr<Style>* s = static_cast<shared_ptr<Style>*>(style);
2165   p->Get()->SetStyle(*s);
2166   return NOTI_EX_ERROR_NONE;
2167 }
2168
2169 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
2170     bool visible) {
2171   if (handle == nullptr) {
2172     LOGE("Invalid parameter");
2173     return NOTI_EX_ERROR_INVALID_PARAMETER;
2174   }
2175
2176   Handle* p = static_cast<Handle*>(handle);
2177   p->Get()->SetVisible(visible);
2178   return NOTI_EX_ERROR_NONE;
2179 }
2180
2181 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
2182     bool *visible) {
2183   if (handle == nullptr || visible == nullptr) {
2184     LOGE("Invalid parameter");
2185     return NOTI_EX_ERROR_INVALID_PARAMETER;
2186   }
2187
2188   Handle* p = static_cast<Handle*>(handle);
2189   *visible = p->Get()->GetVisible();
2190   return NOTI_EX_ERROR_NONE;
2191 }
2192
2193 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
2194     bool enable) {
2195   if (handle == nullptr) {
2196     LOGE("Invalid parameter");
2197     return NOTI_EX_ERROR_INVALID_PARAMETER;
2198   }
2199
2200   Handle* p = static_cast<Handle*>(handle);
2201   p->Get()->SetEnable(enable);
2202   return NOTI_EX_ERROR_NONE;
2203 }
2204
2205 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
2206     bool *enable) {
2207   if (handle == nullptr || enable == nullptr) {
2208     LOGE("Invalid parameter");
2209     return NOTI_EX_ERROR_INVALID_PARAMETER;
2210   }
2211
2212   Handle* p = static_cast<Handle*>(handle);
2213   *enable = p->Get()->GetEnable();
2214   return NOTI_EX_ERROR_NONE;
2215 }
2216
2217 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
2218     const char *receiver_group) {
2219   if (handle == nullptr || receiver_group == nullptr) {
2220     LOGE("Invalid parameter");
2221     return NOTI_EX_ERROR_INVALID_PARAMETER;
2222   }
2223
2224   Handle* p = static_cast<Handle*>(handle);
2225   p->Get()->AddReceiver(receiver_group);
2226   return NOTI_EX_ERROR_NONE;
2227 }
2228
2229 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
2230     const char *receiver_group) {
2231   if (handle == nullptr || receiver_group == nullptr) {
2232     LOGE("Invalid parameter");
2233     return NOTI_EX_ERROR_INVALID_PARAMETER;
2234   }
2235
2236   Handle* p = static_cast<Handle*>(handle);
2237   p->Get()->RemoveReceiver(receiver_group);
2238   return NOTI_EX_ERROR_NONE;
2239 }
2240
2241 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
2242     char ***receiver_list, int *count) {
2243   if (handle == nullptr || receiver_list == nullptr || count == nullptr) {
2244     LOGE("Invalid parameter");
2245     return NOTI_EX_ERROR_INVALID_PARAMETER;
2246   }
2247
2248   Handle* p = static_cast<Handle*>(handle);
2249   list<string> receivers = p->Get()->GetReceiverList();
2250   if (receivers.size() == 0) {
2251     *receiver_list = nullptr;
2252     *count = 0;
2253     return NOTI_EX_ERROR_NONE;
2254   }
2255
2256   char **tmp_list = (char**)calloc(receivers.size(), sizeof(char*));
2257   if (tmp_list == nullptr) {
2258     LOGE("Out of memory");
2259     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2260   }
2261
2262   int idx = 0;
2263   for (auto& i : receivers) {
2264     tmp_list[idx] = strdup(i.c_str());
2265     if (tmp_list[idx] == nullptr) {
2266       __noti_ex_free_str_array(tmp_list, idx);
2267       LOGE("Out of memory");
2268       return NOTI_EX_ERROR_OUT_OF_MEMORY;
2269     }
2270     idx++;
2271   }
2272
2273   *receiver_list = tmp_list;
2274   *count = receivers.size();
2275   return NOTI_EX_ERROR_NONE;
2276 }
2277
2278 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
2279     int policy) {
2280   if (handle == nullptr) {
2281     LOGE("Invalid parameter");
2282     return NOTI_EX_ERROR_INVALID_PARAMETER;
2283   }
2284
2285   Handle* p = static_cast<Handle*>(handle);
2286   p->Get()->SetPolicy(policy);
2287   return NOTI_EX_ERROR_NONE;
2288 }
2289
2290 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
2291     int *policy) {
2292   if (handle == nullptr || policy == nullptr) {
2293     LOGE("Invalid parameter");
2294     return NOTI_EX_ERROR_INVALID_PARAMETER;
2295   }
2296
2297   Handle* p = static_cast<Handle*>(handle);
2298   *policy = p->Get()->GetPolicy();
2299   return NOTI_EX_ERROR_NONE;
2300 }
2301
2302 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
2303     char **channel) {
2304   if (handle == nullptr || channel == nullptr) {
2305     LOGE("Invalid parameter");
2306     return NOTI_EX_ERROR_INVALID_PARAMETER;
2307   }
2308
2309   Handle* p = static_cast<Handle*>(handle);
2310   if (!p->Get()->GetChannel().empty())
2311     *channel = strdup(p->Get()->GetChannel().c_str());
2312   else
2313     *channel = nullptr;
2314
2315   return NOTI_EX_ERROR_NONE;
2316 }
2317
2318 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
2319     const char *channel) {
2320   if (handle == nullptr) {
2321     LOGE("Invalid parameter");
2322     return NOTI_EX_ERROR_INVALID_PARAMETER;
2323   }
2324
2325   Handle* p = static_cast<Handle*>(handle);
2326   p->Get()->SetChannel(channel);
2327   return NOTI_EX_ERROR_NONE;
2328 }
2329
2330 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
2331     noti_ex_led_info_h led) {
2332   if (handle == nullptr) {
2333     LOGE("Invalid parameter");
2334     return NOTI_EX_ERROR_INVALID_PARAMETER;
2335   }
2336
2337   Handle* p = static_cast<Handle*>(handle);
2338   if (led == nullptr) {
2339     p->Get()->SetLEDInfo(nullptr);
2340     return NOTI_EX_ERROR_NONE;
2341   }
2342   shared_ptr<LEDInfo>* led_ptr =
2343       reinterpret_cast<shared_ptr<LEDInfo>*>(led);
2344   p->Get()->SetLEDInfo(*led_ptr);
2345   return NOTI_EX_ERROR_NONE;
2346 }
2347
2348 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
2349     noti_ex_led_info_h *led) {
2350   if (handle == nullptr) {
2351     LOGE("Invalid parameter");
2352     return NOTI_EX_ERROR_INVALID_PARAMETER;
2353   }
2354
2355   Handle* p = static_cast<Handle*>(handle);
2356   if (p->Get()->GetLEDInfo() != nullptr)
2357     *led = new shared_ptr<LEDInfo>(p->Get()->GetLEDInfo());
2358   else
2359     *led = nullptr;
2360   return NOTI_EX_ERROR_NONE;
2361 }
2362
2363 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
2364     const char *path) {
2365   if (handle == nullptr) {
2366     LOGE("Invalid parameter");
2367     return NOTI_EX_ERROR_INVALID_PARAMETER;
2368   }
2369
2370   Handle* p = static_cast<Handle*>(handle);
2371   if (path == nullptr)
2372     p->Get()->SetSoundPath("");
2373   else
2374     p->Get()->SetSoundPath(path);
2375   return NOTI_EX_ERROR_NONE;
2376 }
2377
2378 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
2379     const char *path) {
2380   if (handle == nullptr) {
2381     LOGE("Invalid parameter");
2382     return NOTI_EX_ERROR_INVALID_PARAMETER;
2383   }
2384
2385   Handle* p = static_cast<Handle*>(handle);
2386   if (path == nullptr)
2387     p->Get()->SetVibrationPath("");
2388   else
2389     p->Get()->SetVibrationPath(path);
2390   return NOTI_EX_ERROR_NONE;
2391 }
2392
2393 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
2394     char **path) {
2395   if (handle == nullptr || path == nullptr) {
2396     LOGE("Invalid parameter");
2397     return NOTI_EX_ERROR_INVALID_PARAMETER;
2398   }
2399
2400   Handle* p = static_cast<Handle*>(handle);
2401   if (p->Get()->GetSoundPath().empty())
2402     *path = nullptr;
2403   else
2404     *path = strdup(p->Get()->GetSoundPath().c_str());
2405   return NOTI_EX_ERROR_NONE;
2406 }
2407
2408 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
2409     char **path) {
2410   if (handle == nullptr || path == nullptr) {
2411     LOGE("Invalid parameter");
2412     return NOTI_EX_ERROR_INVALID_PARAMETER;
2413   }
2414
2415   Handle* p = static_cast<Handle*>(handle);
2416   if (p->Get()->GetVibrationPath().empty())
2417     *path = nullptr;
2418   else
2419     *path = strdup(p->Get()->GetVibrationPath().c_str());
2420   return NOTI_EX_ERROR_NONE;
2421 }
2422
2423 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
2424     noti_ex_item_info_h *info) {
2425   if (handle == nullptr || info == nullptr) {
2426     LOGE("Invalid parameter");
2427     return NOTI_EX_ERROR_INVALID_PARAMETER;
2428   }
2429
2430   Handle* p = static_cast<Handle*>(handle);
2431   if (p->Get()->GetInfo() == nullptr)
2432     *info = nullptr;
2433   else
2434     *info = static_cast<noti_ex_item_info_h>(p->Get()->GetInfo().get());
2435   return NOTI_EX_ERROR_NONE;
2436 }
2437
2438 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
2439     char **id) {
2440   if (handle == nullptr || id == nullptr) {
2441     LOGE("Invalid parameter");
2442     return NOTI_EX_ERROR_INVALID_PARAMETER;
2443   }
2444
2445   Handle* p = static_cast<Handle*>(handle);
2446   if (p->Get()->GetSenderAppId().empty())
2447     *id = nullptr;
2448   else
2449     *id = strdup(p->Get()->GetSenderAppId().c_str());
2450   return NOTI_EX_ERROR_NONE;
2451 }
2452
2453 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
2454     char **tag) {
2455   if (handle == nullptr || tag == nullptr) {
2456     LOGE("Invalid parameter");
2457     return NOTI_EX_ERROR_INVALID_PARAMETER;
2458   }
2459
2460   Handle* p = static_cast<Handle*>(handle);
2461   if (p->Get()->GetTag().empty())
2462     *tag = nullptr;
2463   else
2464     *tag = strdup(p->Get()->GetTag().c_str());
2465   return NOTI_EX_ERROR_NONE;
2466 }
2467
2468 extern "C" EXPORT_API int noti_ex_item_set_tag(noti_ex_item_h handle,
2469     const char *tag) {
2470   if (handle == nullptr) {
2471     LOGE("Invalid parameter");
2472     return NOTI_EX_ERROR_INVALID_PARAMETER;
2473   }
2474
2475   Handle* p = static_cast<Handle*>(handle);
2476   if (tag == nullptr)
2477     p->Get()->SetTag("");
2478   else
2479     p->Get()->SetTag(tag);
2480   return NOTI_EX_ERROR_NONE;
2481 }
2482
2483 extern "C" EXPORT_API int noti_ex_item_get_ongoing_state(noti_ex_item_h handle,
2484     bool* ongoing) {
2485   if (handle == nullptr || ongoing == nullptr) {
2486     LOGE("Invalid parameter");
2487     return NOTI_EX_ERROR_INVALID_PARAMETER;
2488   }
2489
2490   Handle* p = static_cast<Handle*>(handle);
2491   *ongoing = p->Get()->GetOnGoingState();
2492
2493   return NOTI_EX_ERROR_NONE;
2494 }
2495
2496 extern "C" EXPORT_API int noti_ex_item_set_ongoing_state(noti_ex_item_h handle,
2497     bool ongoing) {
2498   if (handle == nullptr) {
2499     LOGE("Invalid parameter");
2500     return NOTI_EX_ERROR_INVALID_PARAMETER;
2501   }
2502
2503   Handle* p = static_cast<Handle*>(handle);
2504   p->Get()->SetOnGoingState(ongoing);
2505
2506   return NOTI_EX_ERROR_NONE;
2507 }
2508
2509 extern "C" EXPORT_API int noti_ex_item_check_type_exist(noti_ex_item_h handle,
2510     int type, bool* exist) {
2511   if (handle == nullptr || exist == nullptr) {
2512     LOGE("Invalid parameter");
2513     return NOTI_EX_ERROR_INVALID_PARAMETER;
2514   }
2515
2516   Handle* p = static_cast<Handle*>(handle);
2517   *exist = p->Get()->IsItemTypeExist(type);
2518
2519   return NOTI_EX_ERROR_NONE;
2520 }
2521
2522 extern "C" EXPORT_API int noti_ex_item_get_main_type(noti_ex_item_h handle,
2523     int* type) {
2524   if (handle == nullptr || type == nullptr) {
2525     LOGE("Invalid parameter");
2526     return NOTI_EX_ERROR_INVALID_PARAMETER;
2527   }
2528
2529   Handle* p = static_cast<Handle*>(handle);
2530   *type = p->Get()->GetMainType();
2531
2532   return NOTI_EX_ERROR_NONE;
2533 }
2534
2535 extern "C" EXPORT_API int noti_ex_item_set_main_type(noti_ex_item_h handle,
2536     const char* id, int type) {
2537   if (handle == nullptr || id == nullptr) {
2538     LOGE("Invalid parameter");
2539     return NOTI_EX_ERROR_INVALID_PARAMETER;
2540   }
2541
2542   Handle* p = static_cast<Handle*>(handle);
2543   if (!(p->Get()->SetMainType(string(id),
2544                     static_cast<AbstractItem::MainType>(type))))
2545     return NOTI_EX_ERROR_INVALID_PARAMETER;
2546
2547   return NOTI_EX_ERROR_NONE;
2548 }
2549
2550 extern "C" EXPORT_API int noti_ex_item_find_by_main_type(noti_ex_item_h handle,
2551     int type, noti_ex_item_h* item) {
2552   if (handle == nullptr || item == nullptr) {
2553     LOGE("Invalid parameter");
2554     return NOTI_EX_ERROR_INVALID_PARAMETER;
2555   }
2556
2557   Handle* h = static_cast<Handle*>(handle);
2558   if (!h->IsValidType(AbstractItem::Group)) {
2559     LOGE("Invalid handle type");
2560     return NOTI_EX_ERROR_INVALID_PARAMETER;
2561   }
2562
2563   GroupItem* p = static_cast<GroupItem*>(h->Get());
2564   AbstractItem& find_item = p->FindByMainType(static_cast<AbstractItem::MainType>(type));
2565   if (find_item.GetType() == AbstractItem::NullObject) {
2566     LOGW("Not exist ID");
2567     *item = nullptr;
2568     return NOTI_EX_ERROR_NONE;
2569   }
2570   *item = new Handle(&find_item);
2571
2572   return NOTI_EX_ERROR_NONE;
2573 }
2574
2575 extern "C" EXPORT_API int noti_ex_item_get_extension_data(noti_ex_item_h handle,
2576     const char *key, bundle **value) {
2577   if (handle == nullptr || key == nullptr || value == nullptr) {
2578     LOGE("Invalid handle type");
2579     return NOTI_EX_ERROR_INVALID_PARAMETER;
2580   }
2581
2582   Handle* p = static_cast<Handle*>(handle);
2583
2584   Bundle b = p->Get()->GetExtensionData(key);
2585   if (b.GetCount() == 0)
2586     *value = nullptr;
2587   else
2588     *value = bundle_dup(b.GetHandle());
2589
2590   return NOTI_EX_ERROR_NONE;
2591 }
2592
2593 extern "C" EXPORT_API int noti_ex_item_set_extension_data(noti_ex_item_h handle,
2594     const char *key, bundle *value) {
2595   if (handle == nullptr || key == nullptr || value == nullptr) {
2596     LOGE("Invalid handle type");
2597     return NOTI_EX_ERROR_INVALID_PARAMETER;
2598   }
2599
2600   Bundle b = Bundle(value);
2601
2602   Handle* p = static_cast<Handle*>(handle);
2603   p->Get()->SetExtensionData(key, b);
2604
2605   return NOTI_EX_ERROR_NONE;
2606 }
2607
2608 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
2609     const char *receiver_group, noti_ex_manager_events_s event_callbacks,
2610     void *data) {
2611   if (handle == nullptr) {
2612     LOGE("Invalid parameter");
2613     return NOTI_EX_ERROR_INVALID_PARAMETER;
2614   }
2615
2616   string receiver_group_str = "";
2617   if (receiver_group)
2618     receiver_group_str = string(receiver_group);
2619
2620   ManagerStub* stub = new (std::nothrow) ManagerStub(
2621       unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
2622       unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
2623       receiver_group_str);
2624   if (stub == nullptr) {
2625     LOGE("Fail to create manager");
2626     return NOTI_EX_ERROR_IO_ERROR;
2627   }
2628   stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
2629       new ManagerCallbackInfo(event_callbacks, data)));
2630   *handle = static_cast<noti_ex_manager_h>(stub);
2631
2632   return NOTI_EX_ERROR_NONE;
2633 }
2634
2635 extern "C" EXPORT_API int noti_ex_manager_destroy(noti_ex_manager_h handle) {
2636   if (handle == nullptr) {
2637     LOGE("Invalid parameter");
2638     return NOTI_EX_ERROR_INVALID_PARAMETER;
2639   }
2640   ManagerStub* stub = static_cast<ManagerStub*>(handle);
2641   delete stub;
2642   return NOTI_EX_ERROR_NONE;
2643 }
2644
2645 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
2646     noti_ex_item_h **items, int *count) {
2647   if (handle == nullptr || items == nullptr || count == nullptr) {
2648     LOGE("Invalid parameter");
2649     return NOTI_EX_ERROR_INVALID_PARAMETER;
2650   }
2651
2652   try {
2653     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2654     list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
2655     if (item_list.size() == 0) {
2656       *items = nullptr;
2657       *count = 0;
2658       return NOTI_EX_ERROR_NONE;
2659     }
2660     noti_ex_item_h* added_item =
2661         (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2662     if (added_item == nullptr) {
2663       LOGE("Fail to create items");
2664       return NOTI_EX_ERROR_OUT_OF_MEMORY;
2665     }
2666
2667     int idx = 0;
2668     for (auto& i : item_list) {
2669       added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2670     }
2671     *items = added_item;
2672     *count = item_list.size();
2673   } catch (Exception &ex) {
2674     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2675     return NOTI_EX_ERROR_IO_ERROR;
2676   }
2677   return NOTI_EX_ERROR_NONE;
2678 }
2679
2680 extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
2681     noti_ex_manager_h handle, char* channel, noti_ex_item_h** items, int* count) {
2682   if (handle == nullptr || channel == nullptr ||
2683       items == nullptr || count == nullptr) {
2684     LOGE("Invalid parameter");
2685     return NOTI_EX_ERROR_INVALID_PARAMETER;
2686   }
2687
2688   try {
2689     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2690     list<unique_ptr<item::AbstractItem>> item_list = stub->Get(channel);
2691     if (item_list.size() == 0) {
2692       *items = nullptr;
2693       *count = 0;
2694       return NOTI_EX_ERROR_NONE;
2695     }
2696     noti_ex_item_h* added_item =
2697         (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2698     if (added_item == nullptr) {
2699       LOGE("Fail to create items");
2700       return NOTI_EX_ERROR_OUT_OF_MEMORY;
2701     }
2702
2703     int idx = 0;
2704     for (auto& i : item_list) {
2705       added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2706     }
2707     *items = added_item;
2708     *count = item_list.size();
2709   } catch (Exception &ex) {
2710     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2711     return NOTI_EX_ERROR_IO_ERROR;
2712   }
2713
2714   return NOTI_EX_ERROR_NONE;
2715 }
2716
2717 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
2718     noti_ex_item_h noti, int *request_id) {
2719   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2720     LOGE("Invalid parameter");
2721     return NOTI_EX_ERROR_INVALID_PARAMETER;
2722   }
2723   try {
2724     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2725     Handle* sp = static_cast<Handle*>(noti);
2726     if (sp->GetPtr().get() == nullptr) {
2727       LOGE("Invalid noti reference can not be sended");
2728       return NOTI_EX_ERROR_INVALID_PARAMETER;
2729     } else {
2730       *request_id = stub->Update(sp->GetPtr());
2731     }
2732   } catch (Exception &ex) {
2733     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2734     return NOTI_EX_ERROR_IO_ERROR;
2735   }
2736   return NOTI_EX_ERROR_NONE;
2737 }
2738
2739 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
2740     noti_ex_item_h noti, int *request_id) {
2741   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2742     LOGE("Invalid parameter");
2743     return NOTI_EX_ERROR_INVALID_PARAMETER;
2744   }
2745   try {
2746     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2747     Handle* item = static_cast<Handle*>(noti);
2748     if (item->GetPtr().get() == nullptr) {
2749       LOGE("Invalid noti reference can not be sended");
2750       return NOTI_EX_ERROR_INVALID_PARAMETER;
2751     } else {
2752       *request_id = stub->Delete(item->GetPtr());
2753     }
2754   } catch (Exception &ex) {
2755     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2756     return NOTI_EX_ERROR_IO_ERROR;
2757   }
2758   return NOTI_EX_ERROR_NONE;
2759 }
2760
2761 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
2762     int *request_id) {
2763   if (handle == nullptr || request_id == nullptr) {
2764     LOGE("Invalid parameter");
2765     return NOTI_EX_ERROR_INVALID_PARAMETER;
2766   }
2767   try {
2768     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2769     *request_id = stub->DeleteAll();
2770   } catch (Exception &ex) {
2771     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2772     return NOTI_EX_ERROR_IO_ERROR;
2773   }
2774   return NOTI_EX_ERROR_NONE;
2775 }
2776
2777 extern "C" EXPORT_API int noti_ex_manager_delete_by_channel(
2778     noti_ex_manager_h handle, const char* channel, int* request_id) {
2779   if (handle == nullptr || channel == nullptr || request_id == nullptr) {
2780     LOGE("Invalid parameter");
2781     return NOTI_EX_ERROR_INVALID_PARAMETER;
2782   }
2783
2784   try {
2785     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2786     *request_id = stub->DeleteByChannel(channel);
2787   } catch (Exception &ex) {
2788     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2789     return NOTI_EX_ERROR_IO_ERROR;
2790   }
2791
2792   return NOTI_EX_ERROR_NONE;
2793 }
2794
2795 extern "C" EXPORT_API int noti_ex_manager_delete_by_appid(
2796     noti_ex_manager_h handle, const char* app_id, int* request_id) {
2797   if (handle == nullptr || app_id == nullptr || request_id == nullptr) {
2798     LOGE("Invalid parameter");
2799     return NOTI_EX_ERROR_INVALID_PARAMETER;
2800   }
2801
2802   try {
2803     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2804     *request_id = stub->DeleteByAppId(app_id);
2805   } catch (Exception &ex) {
2806     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2807     return NOTI_EX_ERROR_IO_ERROR;
2808   }
2809
2810   return NOTI_EX_ERROR_NONE;
2811 }
2812
2813 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
2814     noti_ex_item_h noti, int *request_id) {
2815   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2816     LOGE("Invalid parameter");
2817     return NOTI_EX_ERROR_INVALID_PARAMETER;
2818   }
2819   try {
2820     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2821     Handle* item = static_cast<Handle*>(noti);
2822     if (item->GetPtr().get() == nullptr) {
2823       LOGE("Invalid noti reference can not be sended");
2824       return NOTI_EX_ERROR_INVALID_PARAMETER;
2825     } else {
2826       *request_id = stub->Hide(item->GetPtr());
2827     }
2828   } catch (Exception &ex) {
2829     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2830     return NOTI_EX_ERROR_IO_ERROR;
2831   }
2832   return NOTI_EX_ERROR_NONE;
2833 }
2834
2835 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
2836     noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
2837   if (handle == nullptr || root_id == nullptr || item == nullptr) {
2838     LOGE("Invalid parameter");
2839     return NOTI_EX_ERROR_INVALID_PARAMETER;
2840   }
2841   try {
2842     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2843     shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
2844     if (ptr == nullptr) {
2845       LOGW("Not exist ID");
2846       *item = nullptr;
2847       return NOTI_EX_ERROR_NONE;
2848     }
2849     *item = new Handle(ptr);
2850   } catch (Exception &ex) {
2851     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2852     return NOTI_EX_ERROR_IO_ERROR;
2853   }
2854   return NOTI_EX_ERROR_NONE;
2855 }
2856
2857 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
2858     noti_ex_event_info_h info, noti_ex_error_e error) {
2859   if (handle == nullptr || info == nullptr) {
2860     LOGE("Invalid parameter");
2861     return NOTI_EX_ERROR_INVALID_PARAMETER;
2862   }
2863   try {
2864     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2865     IEventInfo* c_info = static_cast<IEventInfo*>(info);
2866     stub->SendError(static_cast<const IEventInfo&>(*c_info),
2867         static_cast<NotificationError>(error));
2868   } catch (Exception &ex) {
2869     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2870     return NOTI_EX_ERROR_IO_ERROR;
2871   }
2872   return NOTI_EX_ERROR_NONE;
2873 }
2874
2875 extern "C" EXPORT_API int noti_ex_manager_get_notification_count(
2876     noti_ex_manager_h handle, int *cnt) {
2877
2878   if (handle == nullptr || cnt == nullptr) {
2879     LOGE("Invalid parameter");
2880     return NOTI_EX_ERROR_INVALID_PARAMETER;
2881   }
2882   try {
2883     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2884     *cnt = stub->GetCount();
2885   } catch (Exception &ex) {
2886     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2887     return NOTI_EX_ERROR_IO_ERROR;
2888   }
2889   return NOTI_EX_ERROR_NONE;
2890 }
2891
2892 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
2893     const char *id, float min, float current, float max) {
2894   ProgressItem* p;
2895
2896   if (handle == nullptr) {
2897     LOGE("Invalid parameter");
2898     return NOTI_EX_ERROR_INVALID_PARAMETER;
2899   }
2900
2901   if (id)
2902     p = new (std::nothrow) ProgressItem(id, min, current, max);
2903   else
2904     p = new (std::nothrow) ProgressItem(min, current, max);
2905
2906   if (p == nullptr) {
2907     LOGE("Out-of-memory");
2908     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2909   }
2910
2911   *handle = new Handle(shared_ptr<AbstractItem>(p));
2912
2913   return NOTI_EX_ERROR_NONE;
2914 }
2915
2916 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
2917     noti_ex_item_h handle, float *current) {
2918   if (handle == nullptr || current == nullptr) {
2919     LOGE("Invalid parameter");
2920     return NOTI_EX_ERROR_INVALID_PARAMETER;
2921   }
2922
2923   Handle *h = static_cast<Handle*>(handle);
2924   if (!h->IsValidType(AbstractItem::Progress)) {
2925     LOGE("Invalid handle type");
2926     return NOTI_EX_ERROR_INVALID_PARAMETER;
2927   }
2928   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2929   *current = p->GetCurrent();
2930
2931   return NOTI_EX_ERROR_NONE;
2932 }
2933
2934 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
2935     noti_ex_item_h handle, float current) {
2936   if (handle == nullptr) {
2937     LOGE("Invalid parameter");
2938     return NOTI_EX_ERROR_INVALID_PARAMETER;
2939   }
2940
2941   Handle *h = static_cast<Handle*>(handle);
2942   if (!h->IsValidType(AbstractItem::Progress)) {
2943     LOGE("Invalid handle type");
2944     return NOTI_EX_ERROR_INVALID_PARAMETER;
2945   }
2946   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2947   p->SetCurrent(current);
2948
2949   return NOTI_EX_ERROR_NONE;
2950 }
2951
2952 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
2953     float *min) {
2954   if (handle == nullptr || min == nullptr) {
2955     LOGE("Invalid parameter");
2956     return NOTI_EX_ERROR_INVALID_PARAMETER;
2957   }
2958
2959   Handle *h = static_cast<Handle*>(handle);
2960   if (!h->IsValidType(AbstractItem::Progress)) {
2961     LOGE("Invalid handle type");
2962     return NOTI_EX_ERROR_INVALID_PARAMETER;
2963   }
2964   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2965   *min = p->GetMin();
2966
2967   return NOTI_EX_ERROR_NONE;
2968 }
2969
2970 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
2971     float *max) {
2972   if (handle == nullptr || max == nullptr) {
2973     LOGE("Invalid parameter");
2974     return NOTI_EX_ERROR_INVALID_PARAMETER;
2975   }
2976
2977   Handle *h = static_cast<Handle*>(handle);
2978   if (!h->IsValidType(AbstractItem::Progress)) {
2979     LOGE("Invalid handle type");
2980     return NOTI_EX_ERROR_INVALID_PARAMETER;
2981   }
2982   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2983   *max = p->GetMax();
2984
2985   return NOTI_EX_ERROR_NONE;
2986 }
2987
2988 extern "C" EXPORT_API int noti_ex_item_progress_get_type(noti_ex_item_h handle,
2989     int* type) {
2990   if (handle == nullptr || type == nullptr) {
2991     LOGE("Invalid parameter");
2992     return NOTI_EX_ERROR_INVALID_PARAMETER;
2993   }
2994
2995   Handle *h = static_cast<Handle*>(handle);
2996   if (!h->IsValidType(AbstractItem::Progress)) {
2997     LOGE("Invalid handle type");
2998     return NOTI_EX_ERROR_INVALID_PARAMETER;
2999   }
3000   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
3001   *type = static_cast<noti_ex_item_progress_type_e>(p->GetProgressType());
3002
3003   return NOTI_EX_ERROR_NONE;
3004 }
3005
3006 extern "C" EXPORT_API int noti_ex_item_progress_set_type(noti_ex_item_h handle,
3007     int type) {
3008   if (handle == nullptr) {
3009     LOGE("Invalid parameter");
3010     return NOTI_EX_ERROR_INVALID_PARAMETER;
3011   }
3012
3013   Handle *h = static_cast<Handle*>(handle);
3014   if (!h->IsValidType(AbstractItem::Progress)) {
3015     LOGE("Invalid handle type");
3016     return NOTI_EX_ERROR_INVALID_PARAMETER;
3017   }
3018   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
3019   p->SetProgressType(static_cast<ProgressItem::Type>(type));
3020
3021   return NOTI_EX_ERROR_NONE;
3022 }
3023
3024 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
3025     noti_ex_reporter_events_s event_callbacks, void *data) {
3026   if (handle == nullptr) {
3027     LOGE("Invalid parameter");
3028     return NOTI_EX_ERROR_INVALID_PARAMETER;
3029   }
3030
3031   ReporterStub* stub = new (std::nothrow) ReporterStub(
3032       unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
3033       unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())));
3034   if (stub == nullptr) {
3035     LOGE("Fail to create manager");
3036     return NOTI_EX_ERROR_IO_ERROR;
3037   }
3038   stub->SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo>(
3039       new ReporterCallbackInfo(event_callbacks, data)));
3040
3041   *handle = static_cast<noti_ex_reporter_h>(stub);
3042
3043   return NOTI_EX_ERROR_NONE;
3044 }
3045
3046 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
3047   if (handle == nullptr) {
3048     LOGE("Invalid parameter");
3049     return NOTI_EX_ERROR_INVALID_PARAMETER;
3050   }
3051   ReporterStub* stub = static_cast<ReporterStub*>(handle);
3052   delete stub;
3053   return NOTI_EX_ERROR_NONE;
3054 }
3055
3056 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
3057     noti_ex_event_info_h info, noti_ex_error_e error) {
3058   if (handle == nullptr || info == nullptr) {
3059     LOGE("Invalid parameter");
3060     return NOTI_EX_ERROR_INVALID_PARAMETER;
3061   }
3062   try {
3063     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3064     IEventInfo* c_info = static_cast<IEventInfo*>(info);
3065     stub->SendError(static_cast<const IEventInfo&>(*c_info),
3066         static_cast<NotificationError>(error));
3067   } catch (Exception &ex) {
3068     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3069     return NOTI_EX_ERROR_IO_ERROR;
3070   }
3071   return NOTI_EX_ERROR_NONE;
3072 }
3073
3074 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
3075     noti_ex_item_h noti, int *request_id) {
3076   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3077     LOGE("Invalid parameter");
3078     return NOTI_EX_ERROR_INVALID_PARAMETER;
3079   }
3080   try {
3081     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3082     Handle* h = static_cast<Handle*>(noti);
3083     if (h->GetPtr().get() == nullptr) {
3084       LOGE("Invalid noti reference can not be sended");
3085       return NOTI_EX_ERROR_INVALID_PARAMETER;
3086     } else {
3087       *request_id = stub->Post(h->GetPtr());
3088     }
3089   } catch (Exception &ex) {
3090     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3091     return NOTI_EX_ERROR_IO_ERROR;
3092   }
3093   return NOTI_EX_ERROR_NONE;
3094 }
3095
3096 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
3097     noti_ex_item_h *noti_list, int count, int *request_id) {
3098
3099   if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
3100     LOGE("Invalid parameter");
3101     return NOTI_EX_ERROR_INVALID_PARAMETER;
3102   }
3103   try {
3104     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3105     list<shared_ptr<item::AbstractItem>> notiList;
3106     for (int i = 0; i < count; i++) {
3107       Handle* item = static_cast<Handle*>(noti_list[i]);
3108       notiList.push_back(item->GetPtr());
3109     }
3110     *request_id = stub->Post(notiList);
3111   } catch (Exception &ex) {
3112     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3113     return NOTI_EX_ERROR_IO_ERROR;
3114   }
3115   return NOTI_EX_ERROR_NONE;
3116 }
3117
3118 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
3119     noti_ex_item_h noti, int *request_id) {
3120   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3121     LOGE("Invalid parameter");
3122     return NOTI_EX_ERROR_INVALID_PARAMETER;
3123   }
3124   try {
3125     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3126     Handle* item = static_cast<Handle*>(noti);
3127     if (item->GetPtr().get() == nullptr) {
3128       LOGE("Invalid noti reference can not be sended");
3129       return NOTI_EX_ERROR_INVALID_PARAMETER;
3130     } else {
3131       *request_id = stub->Update(item->GetPtr());
3132     }
3133   } catch (Exception &ex) {
3134     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3135     return NOTI_EX_ERROR_IO_ERROR;
3136   }
3137   return NOTI_EX_ERROR_NONE;
3138 }
3139
3140 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
3141     noti_ex_item_h noti, int *request_id) {
3142   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3143     LOGE("Invalid parameter");
3144     return NOTI_EX_ERROR_INVALID_PARAMETER;
3145   }
3146   try {
3147     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3148     Handle* item = static_cast<Handle*>(noti);
3149     if (item->GetPtr().get() == nullptr) {
3150       LOGE("Invalid noti reference can not be sended");
3151       return NOTI_EX_ERROR_INVALID_PARAMETER;
3152     } else {
3153       *request_id = stub->Delete(item->GetPtr());
3154     }
3155   } catch (Exception &ex) {
3156     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3157     return NOTI_EX_ERROR_IO_ERROR;
3158   }
3159   return NOTI_EX_ERROR_NONE;
3160 }
3161
3162 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
3163     noti_ex_reporter_h handle, int *request_id) {
3164   if (handle == nullptr || request_id == nullptr) {
3165     LOGE("Invalid parameter");
3166     return NOTI_EX_ERROR_INVALID_PARAMETER;
3167   }
3168   try {
3169     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3170     *request_id = stub->DeleteAll();
3171   } catch (Exception &ex) {
3172     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3173     return NOTI_EX_ERROR_IO_ERROR;
3174   }
3175   return NOTI_EX_ERROR_NONE;
3176 }
3177
3178 extern "C" EXPORT_API int noti_ex_reporter_delete_by_channel(
3179     noti_ex_reporter_h handle, const char* channel, int* request_id) {
3180   if (handle == nullptr || channel == nullptr || request_id == nullptr) {
3181     LOGE("Invalid parameter");
3182     return NOTI_EX_ERROR_INVALID_PARAMETER;
3183   }
3184
3185   try {
3186     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3187     *request_id = stub->DeleteByChannel(channel);
3188   } catch (Exception &ex) {
3189     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3190     return NOTI_EX_ERROR_IO_ERROR;
3191   }
3192
3193   return NOTI_EX_ERROR_NONE;
3194 }
3195
3196 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
3197     noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
3198   if (handle == nullptr || root_id == nullptr || item == nullptr) {
3199     LOGE("Invalid parameter");
3200     return NOTI_EX_ERROR_INVALID_PARAMETER;
3201   }
3202   try {
3203     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3204     shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
3205     if (ptr == nullptr) {
3206       LOGW("Not exist ID");
3207       *item = nullptr;
3208       return NOTI_EX_ERROR_NONE;
3209     }
3210     *item = new Handle(ptr);
3211   } catch (Exception &ex) {
3212     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3213     return NOTI_EX_ERROR_IO_ERROR;
3214   }
3215   return NOTI_EX_ERROR_NONE;
3216 }
3217
3218 extern "C" EXPORT_API int noti_ex_reporter_find_by_channel(noti_ex_reporter_h handle,
3219     const char *channel, noti_ex_item_h **noti_list, int *count) {
3220   if (handle == nullptr || channel == nullptr || noti_list == nullptr
3221       || count == nullptr) {
3222     LOGE("Invalid parameter");
3223     return NOTI_EX_ERROR_INVALID_PARAMETER;
3224   }
3225
3226   Handle** list_item = nullptr;
3227
3228   try {
3229     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3230     list<unique_ptr<AbstractItem>> list_ptr = stub->FindByChannel(channel);
3231     if (list_ptr.empty()) {
3232       LOGW("Not exist ID");
3233       *noti_list = nullptr;
3234       return NOTI_EX_ERROR_NONE;
3235     }
3236
3237     int size = list_ptr.size();
3238     int i = 0;
3239
3240     list_item = (Handle**)calloc(size, sizeof(Handle*));
3241     for (auto& ptr : list_ptr)
3242       list_item[i++] = new Handle(std::move(ptr));
3243
3244     *noti_list = reinterpret_cast<noti_ex_item_h*>(list_item);
3245     *count = size;
3246   } catch (Exception &ex) {
3247     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3248     free(list_item);
3249     return NOTI_EX_ERROR_IO_ERROR;
3250   }
3251
3252   return NOTI_EX_ERROR_NONE;
3253 }
3254
3255 extern "C" EXPORT_API int noti_ex_reporter_find_all(noti_ex_reporter_h handle,
3256     noti_ex_item_h **noti_list, int *count) {
3257   if (handle == nullptr || noti_list == nullptr || count == nullptr) {
3258     LOGE("Invalid parameter");
3259     return NOTI_EX_ERROR_INVALID_PARAMETER;
3260   }
3261
3262   Handle** list_item = nullptr;
3263
3264   try {
3265     ReporterStub* stub = static_cast<ReporterStub*>(handle);
3266     list<unique_ptr<AbstractItem>> list_ptr = stub->FindAll();
3267     if (list_ptr.empty()) {
3268       LOGW("Not exist ID");
3269       *noti_list = nullptr;
3270       return NOTI_EX_ERROR_NONE;
3271     }
3272
3273     int size = list_ptr.size();
3274     int i = 0;
3275
3276     list_item = (Handle**)calloc(size, sizeof(Handle*));
3277     for (auto& ptr : list_ptr)
3278       list_item[i++] = new Handle(std::move(ptr));
3279
3280     *noti_list = reinterpret_cast<noti_ex_item_h*>(list_item);
3281     *count = size;
3282   } catch (Exception &ex) {
3283     LOGE("%s %d", ex.what(), ex.GetErrorCode());
3284     free(list_item);
3285     return NOTI_EX_ERROR_IO_ERROR;
3286   }
3287
3288   return NOTI_EX_ERROR_NONE;
3289 }
3290
3291 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
3292     const char *id, const char *text, const char *hyperlink) {
3293   if (handle == nullptr || text == nullptr) {
3294     LOGE("Invalid parameter");
3295     return NOTI_EX_ERROR_INVALID_PARAMETER;
3296   }
3297
3298   TextItem* p;
3299
3300   if (id == NULL)
3301     id = "";
3302
3303   if (hyperlink)
3304     p = new (std::nothrow) TextItem(id, std::string(text),
3305                 std::string(hyperlink));
3306   else
3307     p = new (std::nothrow) TextItem(id, std::string(text));
3308
3309   if (p == nullptr) {
3310     LOGE("Out-of-memory");
3311     return NOTI_EX_ERROR_OUT_OF_MEMORY;
3312   }
3313
3314   *handle = new Handle(shared_ptr<AbstractItem>(p));
3315
3316   return NOTI_EX_ERROR_NONE;
3317 }
3318
3319 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
3320     const char *contents) {
3321   if (handle == nullptr || contents == nullptr) {
3322     LOGE("Invalid parameter");
3323     return NOTI_EX_ERROR_INVALID_PARAMETER;
3324   }
3325
3326   Handle* p = static_cast<Handle*>(handle);
3327   if (!p->IsValidType(AbstractItem::Text)) {
3328     LOGE("Invalid handle type");
3329     return NOTI_EX_ERROR_INVALID_PARAMETER;
3330   }
3331   TextItem* ti = static_cast<TextItem*>(p->Get());
3332   ti->SetContents(std::string(contents));
3333
3334   return NOTI_EX_ERROR_NONE;
3335 }
3336
3337 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
3338     char **contents) {
3339   if (handle == nullptr || contents == nullptr) {
3340     LOGE("Invalid parameter");
3341     return NOTI_EX_ERROR_INVALID_PARAMETER;
3342   }
3343
3344   Handle* p = static_cast<Handle*>(handle);
3345   if (!p->IsValidType(AbstractItem::Text)) {
3346     LOGE("Invalid handle type");
3347     return NOTI_EX_ERROR_INVALID_PARAMETER;
3348   }
3349
3350   TextItem* ti = static_cast<TextItem*>(p->Get());
3351   string str;
3352   if (ti->GetMultiLanguage() != nullptr &&
3353       !ti->GetMultiLanguage()->GetTranslatedString().empty())
3354     str = ti->GetMultiLanguage()->GetTranslatedString();
3355   else if (!ti->GetContents().empty())
3356     str = ti->GetContents();
3357
3358   *contents = strdup(str.c_str());
3359   if (*contents == nullptr) {
3360     LOGE("Out-of-memory");
3361     return NOTI_EX_ERROR_OUT_OF_MEMORY;
3362   }
3363
3364   return NOTI_EX_ERROR_NONE;
3365 }
3366
3367 extern "C" EXPORT_API int noti_ex_item_text_get_hyperlink(
3368     noti_ex_item_h handle, char **hyper_link) {
3369   if (handle == nullptr || hyper_link == nullptr) {
3370     LOGE("Invalid parameter");
3371     return NOTI_EX_ERROR_INVALID_PARAMETER;
3372   }
3373
3374   Handle* p = static_cast<Handle*>(handle);
3375   if (!p->IsValidType(AbstractItem::Text)) {
3376     LOGE("Invalid handle type");
3377     return NOTI_EX_ERROR_INVALID_PARAMETER;
3378   }
3379   TextItem* ti = static_cast<TextItem*>(p->Get());
3380   if (!ti->GetHyperLink().empty()) {
3381     *hyper_link = strdup(ti->GetHyperLink().c_str());
3382     if (*hyper_link == nullptr) {
3383       LOGE("Out-of-memory");
3384       return NOTI_EX_ERROR_OUT_OF_MEMORY;
3385     }
3386   } else {
3387     *hyper_link = nullptr;
3388   }
3389
3390   return NOTI_EX_ERROR_NONE;
3391 }
3392
3393 extern "C" EXPORT_API int noti_ex_item_text_set_multi_language(
3394     noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
3395   if (handle == nullptr) {
3396     LOGE("Invalid parameter");
3397     return NOTI_EX_ERROR_INVALID_PARAMETER;
3398   }
3399
3400   Handle* p = static_cast<Handle*>(handle);
3401   if (!p->IsValidType(AbstractItem::Text)) {
3402     LOGE("Invalid handle type");
3403     return NOTI_EX_ERROR_INVALID_PARAMETER;
3404   }
3405
3406   TextItem* ti = static_cast<TextItem*>(p->Get());
3407   if (multi == nullptr) {
3408     ti->SetMultiLanguage(nullptr);
3409     return NOTI_EX_ERROR_NONE;
3410   }
3411
3412   shared_ptr<MultiLanguage> mul_ptr =
3413       *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
3414   ti->SetMultiLanguage(mul_ptr);
3415   ti->GetMultiLanguage()->UpdateString();
3416
3417   return NOTI_EX_ERROR_NONE;
3418 }
3419
3420 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
3421     const char *id, time_t time) {
3422   TimeItem* p;
3423
3424   if (handle == nullptr) {
3425     LOGE("Invalid parameter");
3426     return NOTI_EX_ERROR_INVALID_PARAMETER;
3427   }
3428
3429   if (time) {
3430     if (id)
3431       p = new (std::nothrow) TimeItem(id, time);
3432     else
3433       p = new (std::nothrow) TimeItem(time);
3434   } else {
3435       p = new (std::nothrow) TimeItem();
3436   }
3437
3438   if (p == nullptr) {
3439     LOGE("Out-of-memory");
3440     return NOTI_EX_ERROR_OUT_OF_MEMORY;
3441   }
3442
3443   *handle = new Handle(shared_ptr<AbstractItem>(p));
3444
3445   return NOTI_EX_ERROR_NONE;
3446 }
3447
3448 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
3449     time_t *time) {
3450   if (handle == nullptr || time == nullptr) {
3451     LOGE("Invalid parameter");
3452     return NOTI_EX_ERROR_INVALID_PARAMETER;
3453   }
3454   Handle* h = static_cast<Handle*>(handle);
3455   if (!h->IsValidType(AbstractItem::Time)) {
3456     LOGE("Invalid handle type");
3457     return NOTI_EX_ERROR_INVALID_PARAMETER;
3458   }
3459   TimeItem* p = static_cast<TimeItem*>(h->Get());
3460   *time = p->GetTime();
3461
3462   return NOTI_EX_ERROR_NONE;
3463 }
3464
3465 extern "C" EXPORT_API int noti_ex_item_time_set_time(noti_ex_item_h handle,
3466     time_t time) {
3467   if (handle == nullptr) {
3468     LOGE("Invalid parameter");
3469     return NOTI_EX_ERROR_INVALID_PARAMETER;
3470   }
3471   Handle* h = static_cast<Handle*>(handle);
3472   if (!h->IsValidType(AbstractItem::Time)) {
3473     LOGE("Invalid handle type");
3474     return NOTI_EX_ERROR_INVALID_PARAMETER;
3475   }
3476   TimeItem* p = static_cast<TimeItem*>(h->Get());
3477   p->SetTime(time);
3478
3479   return NOTI_EX_ERROR_NONE;
3480 }
3481
3482 extern "C" EXPORT_API int noti_ex_action_visibility_create(
3483     noti_ex_action_h *handle, const char *extra) {
3484   if (handle == nullptr) {
3485     LOGE("Invalid parameter");
3486     return NOTI_EX_ERROR_INVALID_PARAMETER;
3487   }
3488
3489   string extra_str = "";
3490   if (extra != NULL)
3491     extra_str = string(extra);
3492
3493   shared_ptr<AbstractAction>* ptr = new (std::nothrow) shared_ptr<AbstractAction>(
3494       new (std::nothrow) VisibilityAction(extra_str));
3495   if (ptr == nullptr) {
3496     LOGE("Out-of-memory");
3497     return NOTI_EX_ERROR_OUT_OF_MEMORY;
3498   }
3499
3500   *handle = ptr;
3501
3502   return NOTI_EX_ERROR_NONE;
3503 }
3504
3505 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
3506     const char *id, bool visible) {
3507   if (handle == nullptr || id == nullptr) {
3508     LOGE("Invalid parameter");
3509     return NOTI_EX_ERROR_INVALID_PARAMETER;
3510   }
3511
3512   shared_ptr<AbstractAction>* ptr =
3513       static_cast<shared_ptr<AbstractAction>*>(handle);
3514   VisibilityAction* action = static_cast<VisibilityAction*>(ptr->get());
3515   action->SetVisibility(id, visible);
3516
3517   return NOTI_EX_ERROR_NONE;
3518 }
3519
3520 extern "C" EXPORT_API int noti_ex_multi_lang_create(noti_ex_multi_lang_h* handle,
3521     const char* msgid, const char* format, ...) {
3522   if (handle == nullptr || msgid == nullptr || format == nullptr) {
3523     LOGE("Invalid parameter");
3524     return NOTI_EX_ERROR_INVALID_PARAMETER;
3525   }
3526
3527   const char* format_idx = format;
3528   vector<string> arr;
3529   va_list args;
3530   va_start(args, format);
3531   while (*format_idx != '\0') {
3532     char* arg = nullptr;
3533     int arg_i;
3534     double arg_f;
3535     stringstream stream;
3536     if (*format_idx == '%') {
3537       switch (*(format_idx + 1)) {
3538         case 's':
3539           arg = va_arg(args, char *);
3540           arr.push_back(string(arg));
3541           break;
3542         case 'd':
3543           arg_i = va_arg(args, int);
3544           arr.push_back(to_string(arg_i));
3545           break;
3546         case 'f':
3547           arg_f = va_arg(args, double);
3548           stream << std::fixed << std::setprecision(2) << arg_f;
3549           arr.push_back(stream.str());
3550           break;
3551       }
3552     }
3553     format_idx++;
3554   }
3555   va_end(args);
3556
3557   MultiLanguage* p = new MultiLanguage(string(msgid), format, arr);
3558   if (p == nullptr) {
3559     LOGE("Out-of-memory");
3560     return NOTI_EX_ERROR_OUT_OF_MEMORY;
3561   }
3562   *handle = new shared_ptr<MultiLanguage>(p);
3563
3564   return NOTI_EX_ERROR_NONE;
3565 }
3566
3567 extern "C" EXPORT_API int noti_ex_multi_lang_destroy(noti_ex_multi_lang_h handle) {
3568   if (handle == nullptr) {
3569     LOGE("Invalid parameter");
3570     return NOTI_EX_ERROR_INVALID_PARAMETER;
3571   }
3572
3573   shared_ptr<MultiLanguage>* mul_ptr =
3574       reinterpret_cast<shared_ptr<MultiLanguage>*>(handle);
3575   delete mul_ptr;
3576   return NOTI_EX_ERROR_NONE;
3577 }
3578
3579 extern "C" EXPORT_API int noti_ex_item_get_private_id(
3580     noti_ex_item_h item, int64_t* private_id) {
3581   if (item == nullptr || private_id == nullptr) {
3582     LOGE("Invalid parameter");
3583     return NOTI_EX_ERROR_INVALID_PARAMETER;
3584   }
3585
3586   Handle* h = static_cast<Handle*>(item);
3587   *private_id = static_pointer_cast<IItemInfoInternal>(
3588       h->Get()->GetInfo())->GetPrivateId();
3589
3590   return NOTI_EX_ERROR_NONE;
3591 }
3592
3593 extern "C" EXPORT_API int noti_ex_item_set_private_id(
3594     noti_ex_item_h item, int64_t priv_id) {
3595   if (item == nullptr) {
3596     LOGE("Invalid parameter");
3597     return NOTI_EX_ERROR_INVALID_PARAMETER;
3598   }
3599
3600   Handle* h = static_cast<Handle*>(item);
3601   static_pointer_cast<IItemInfoInternal>(
3602       h->Get()->GetInfo())->SetPrivateId(priv_id);
3603
3604   return NOTI_EX_ERROR_NONE;
3605 }
3606
3607 extern "C" EXPORT_API int noti_ex_item_free_string_list(char** list, int count) {
3608   if (list == nullptr) {
3609     LOGE("Invalid parameter");
3610     return NOTI_EX_ERROR_INVALID_PARAMETER;
3611   }
3612
3613   LOGI("Free strings (%d)", count);
3614   for (int i = 0; i < count; i++)
3615     free(list[i]);
3616   free(list);
3617
3618   return NOTI_EX_ERROR_NONE;
3619 }
3620
3621 extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h handle) {
3622   if (handle == nullptr) {
3623     LOGE("Invalid parameter");
3624     return NOTI_EX_ERROR_INVALID_PARAMETER;
3625   }
3626   Handle* h = static_cast<Handle*>(handle);
3627   if (!h->IsValidType(AbstractItem::Group)) {
3628     LOGE("Invalid handle type");
3629     return NOTI_EX_ERROR_INVALID_PARAMETER;
3630   }
3631   GroupItem* p = static_cast<GroupItem*>(h->Get());
3632   p->RemoveChildren();
3633
3634   return NOTI_EX_ERROR_NONE;
3635 }
3636
3637 extern "C" EXPORT_API int noti_ex_item_icon_create(noti_ex_item_h *handle,
3638     const char *id, const char *icon_path) {
3639   if (handle == nullptr || icon_path == nullptr) {
3640     LOGE("Invalid parameter");
3641     return NOTI_EX_ERROR_INVALID_PARAMETER;
3642   }
3643
3644   IconItem* p;
3645   if (id)
3646     p = new (std::nothrow) IconItem(id, icon_path);
3647   else
3648     p = new (std::nothrow) IconItem(icon_path);
3649
3650   if (p == nullptr) {
3651     LOGE("Out-of-memory");
3652     return NOTI_EX_ERROR_OUT_OF_MEMORY;
3653   }
3654
3655   *handle = new Handle(shared_ptr<AbstractItem>(p));
3656
3657   return NOTI_EX_ERROR_NONE;
3658 }
3659
3660 int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle, char **icon_path) {
3661   if (handle == nullptr || icon_path == nullptr) {
3662     LOGE("Invalid parameter");
3663     return NOTI_EX_ERROR_INVALID_PARAMETER;
3664   }
3665
3666   Handle* h = static_cast<Handle*>(handle);
3667   if (!h->IsValidType(AbstractItem::Icon)) {
3668     LOGE("Invalid handle type");
3669     return NOTI_EX_ERROR_INVALID_PARAMETER;
3670   }
3671
3672   IconItem* p = static_cast<IconItem*>(h->Get());
3673   if (!p->GetImagePath().empty()) {
3674     *icon_path = strdup(p->GetImagePath().c_str());
3675     if (*icon_path == nullptr) {
3676       LOGE("Out-of-memory");
3677       return NOTI_EX_ERROR_OUT_OF_MEMORY;
3678     }
3679   } else {
3680     *icon_path = nullptr;
3681   }
3682
3683   return NOTI_EX_ERROR_NONE;
3684 }