Remove requested callback
[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
23 #include "api/notification_ex_app_control_action.h"
24 #include "api/notification_ex_button.h"
25 #include "api/notification_ex_chat_message.h"
26 #include "api/notification_ex_checkbox.h"
27 #include "api/notification_ex_entry.h"
28 #include "api/notification_ex_event_info.h"
29 #include "api/notification_ex_group.h"
30 #include "api/notification_ex_image.h"
31 #include "api/notification_ex_input_selector.h"
32 #include "api/notification_ex_item.h"
33 #include "api/notification_ex_manager.h"
34 #include "api/notification_ex_progress.h"
35 #include "api/notification_ex_reporter.h"
36 #include "api/notification_ex_text.h"
37 #include "api/notification_ex_time.h"
38 #include "api/notification_ex_visibility_action.h"
39 #include "notification-ex/reporter.h"
40 #include "notification-ex/app_control_action.h"
41 #include "notification-ex/button_item.h"
42 #include "notification-ex/chat_message_item.h"
43 #include "notification-ex/checkbox_item.h"
44 #include "notification-ex/entry_item.h"
45 #include "notification-ex/group_item.h"
46 #include "notification-ex/input_selector_item.h"
47 #include "notification-ex/abstract_item.h"
48 #include "notification-ex/progress_item.h"
49 #include "notification-ex/time_item.h"
50 #include "notification-ex/visibility_action.h"
51 #include "notification-ex/ex_bundle.h"
52 #include "notification-ex/event_info_internal.h"
53 #include "notification-ex/manager.h"
54 #include "notification-ex/dbus_sender.h"
55 #include "notification-ex/dbus_event_listener.h"
56 #include "notification-ex/exception.h"
57
58 #ifdef LOG_TAG
59 #undef LOG_TAG
60 #endif
61 #define LOG_TAG "NOTIFICATION_EX"
62
63 #ifdef EXPORT_API
64 #undef EXPORT_API
65 #endif
66 #define EXPORT_API __attribute__((visibility("default")))
67
68 using namespace std;
69 using namespace notification::item;
70 using namespace notification;
71
72 namespace {
73 class Handle {
74  public:
75   Handle(item::AbstractItem* ref) : ref_(ref) { }
76   Handle(std::shared_ptr<item::AbstractItem> ptr)
77       : ref_(nullptr), ptr_(move(ptr)) { }
78   virtual ~Handle() = default;
79   item::AbstractItem* Get() const {
80     if (ptr_ == nullptr)
81       return ref_;
82     return ptr_.get();
83   }
84
85   bool IsValidType(int type) const {
86     return (Get()->GetType() == type
87         || Get()->GetType() >= AbstractItem::Custom);
88   }
89
90   std::shared_ptr<item::AbstractItem> GetPtr() const {
91     if (ptr_ == nullptr)
92       return std::shared_ptr<item::AbstractItem>({});
93     return ptr_;
94   }
95
96  private:
97   item::AbstractItem* ref_;
98   std::shared_ptr<item::AbstractItem> ptr_;
99
100 };
101
102 class ManagerCallbackInfo {
103  public:
104   ManagerCallbackInfo(noti_ex_manager_events_s cb, void* user_data)
105     : user_data_(user_data) {
106     cb_.added = cb.added;
107     cb_.updated = cb.updated;
108     cb_.deleted = cb.deleted;
109     cb_.error = cb.error;
110   }
111
112   void InvokeAdded(Manager* manager, const IEventInfo& info,
113       list<shared_ptr<AbstractItem>> addedItem) {
114
115     noti_ex_item_h* added_item =
116         (noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
117     if (added_item == nullptr) {
118       LOGE("Out of memory");
119       return;
120     }
121
122     int idx = 0;
123     for (auto& i : addedItem) {
124       added_item[idx++] =
125           static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i)));
126     }
127
128     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
129     cb_.added(static_cast<noti_ex_manager_h>(manager),
130         static_cast<noti_ex_event_info_h>(c_info), added_item,
131         addedItem.size(), user_data_);
132     free(added_item);
133   }
134
135   void InvokeUpdated(Manager* manager, const IEventInfo& info,
136       shared_ptr<item::AbstractItem> updatedItem) {
137     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
138     cb_.updated(static_cast<noti_ex_manager_h>(manager),
139         static_cast<noti_ex_event_info_h>(c_info),
140         static_cast<noti_ex_item_h>(new Handle(updatedItem)), user_data_);
141   }
142
143   void InvokeDeleted(Manager* manager, const IEventInfo& info,
144       shared_ptr<item::AbstractItem> deletedItem) {
145     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
146     cb_.deleted(static_cast<noti_ex_manager_h>(manager),
147         static_cast<noti_ex_event_info_h>(c_info),
148         static_cast<noti_ex_item_h>(
149             new Handle(deletedItem)), user_data_);
150   }
151
152   void InvokeError(Manager* manager, NotificationError error, int requestId) {
153     cb_.error(static_cast<noti_ex_manager_h>(manager),
154         static_cast<noti_ex_error_e>(error), requestId, user_data_);
155   }
156
157  private:
158   noti_ex_manager_events_s cb_;
159   void* user_data_;
160 };
161
162 class ManagerStub : public Manager {
163  public:
164   ManagerStub(std::unique_ptr<IEventSender> sender,
165       std::unique_ptr<IEventListener> listener, std::string receiver_group = "")
166     : Manager(move(sender), move(listener), receiver_group) {
167   }
168
169   void OnAdd(const IEventInfo& info,
170       list<shared_ptr<AbstractItem>> addedItem) override {
171     cb_->InvokeAdded(this, info, addedItem);
172
173   }
174
175   void OnUpdate(const IEventInfo& info,
176       std::shared_ptr<item::AbstractItem> updatedItem) override {
177     cb_->InvokeUpdated(this, info, updatedItem);
178   }
179
180   void OnDelete(const IEventInfo& info,
181       shared_ptr<item::AbstractItem> deletedItem) override {
182     cb_->InvokeDeleted(this, info, deletedItem);
183   }
184
185   void OnError(NotificationError error, int requestId) override {
186     cb_->InvokeError(this, error, requestId);
187   }
188
189   int SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo> ci) {
190     cb_ = move(ci);
191     return NOTI_EX_ERROR_NONE;
192   }
193
194   int ClearManagerCallbackInfo() {
195     cb_.reset();
196     return NOTI_EX_ERROR_NONE;
197   }
198
199  private:
200   unique_ptr<ManagerCallbackInfo> cb_;
201 };
202
203
204 class ReporterCallbackInfo {
205  public:
206   ReporterCallbackInfo(noti_ex_reporter_events_s cb, void* user_data)
207     : user_data_(user_data) {
208     cb_.event = cb.event;
209     cb_.error = cb.error;
210   }
211
212   void InvokeEvent(Reporter* reporter, const IEventInfo& info,
213       list<shared_ptr<AbstractItem>> notiList) {
214
215     noti_ex_item_h* noti_list =
216         (noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
217     if (noti_list == nullptr) {
218       LOGE("Out of memory");
219       return;
220     }
221
222     int idx = 0;
223     for (auto& i : notiList) {
224       noti_list[idx++] =
225           static_cast<noti_ex_item_h>(new Handle(i));
226     }
227
228     IEventInfo* c_info = const_cast<IEventInfo*>(&info);
229     cb_.event(static_cast<noti_ex_reporter_h>(reporter),
230         static_cast<noti_ex_event_info_h>(c_info), noti_list,
231         notiList.size(), user_data_);
232     free(noti_list);
233   }
234
235   void InvokeError(Reporter* reporter, NotificationError error, int requestId) {
236     cb_.error(static_cast<noti_ex_reporter_h>(reporter),
237         static_cast<noti_ex_error_e>(error), requestId, user_data_);
238   }
239
240  private:
241   noti_ex_reporter_events_s cb_;
242   void* user_data_;
243 };
244
245 class ReporterStub : public Reporter {
246  public:
247   ReporterStub(std::unique_ptr<IEventSender> sender,
248       std::unique_ptr<IEventListener> listener)
249     : Reporter(move(sender), move(listener)) {
250   }
251
252   void OnEvent(const IEventInfo& info,
253       std::list<std::shared_ptr<item::AbstractItem>> notiList) override {
254     cb_->InvokeEvent(this, info, notiList);
255   }
256
257   void OnError(NotificationError error, int requestId) override {
258     cb_->InvokeError(this, error, requestId);
259   }
260
261   int SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo> ci) {
262     cb_ = move(ci);
263     return NOTI_EX_ERROR_NONE;
264   }
265
266   int ClearReporterCallbackInfo() {
267     cb_.reset();
268     return NOTI_EX_ERROR_NONE;
269   }
270
271  private:
272   unique_ptr<ReporterCallbackInfo> cb_;
273 };
274 }
275
276 extern "C" EXPORT_API int noti_ex_action_app_control_create(
277     noti_ex_action_h *handle, app_control_h app_control,
278     const char *extra) {
279   if (handle == nullptr || app_control == nullptr) {
280     LOGE("Invalid parameter");
281     return NOTI_EX_ERROR_INVALID_PARAMETER;
282   }
283
284   auto* p = new (std::nothrow) AppControlAction(app_control, extra);
285   if (p == nullptr) {
286     LOGE("Out-of-memory");
287     return NOTI_EX_ERROR_OUT_OF_MEMORY;
288   }
289
290   *handle = p;
291
292   return NOTI_EX_ERROR_NONE;
293 }
294
295 extern "C" EXPORT_API int noti_ex_action_app_control_set(
296     noti_ex_action_h handle, app_control_h app_control) {
297   if (handle == nullptr || app_control == nullptr) {
298     LOGE("Invalid parameter");
299     return NOTI_EX_ERROR_INVALID_PARAMETER;
300   }
301
302   AppControlAction* p = static_cast<AppControlAction*>(handle);
303   p->SetAppControl(app_control);
304
305   return NOTI_EX_ERROR_NONE;
306 }
307
308 extern "C" EXPORT_API int noti_ex_action_app_control_get(
309     noti_ex_action_h handle, app_control_h *app_control) {
310   if (handle == nullptr || app_control == nullptr) {
311     LOGE("Invalid parameter");
312     return NOTI_EX_ERROR_INVALID_PARAMETER;
313   }
314
315   AppControlAction* p = static_cast<AppControlAction*>(handle);
316   *app_control = p->GetAppControl();
317
318   return NOTI_EX_ERROR_NONE;
319 }
320
321 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
322     const char *id, const char *title) {
323   ButtonItem* p;
324
325   if (handle == nullptr || title == nullptr) {
326     LOGE("Invalid parameter");
327     return NOTI_EX_ERROR_INVALID_PARAMETER;
328   }
329
330   if (id)
331     p = new (std::nothrow) ButtonItem(id, title);
332   else
333     p = new (std::nothrow) ButtonItem(title);
334
335   if (p == nullptr) {
336     LOGE("Out-of-memory");
337     return NOTI_EX_ERROR_OUT_OF_MEMORY;
338   }
339   *handle = new Handle(shared_ptr<AbstractItem>(p));
340
341   return NOTI_EX_ERROR_NONE;
342 }
343
344 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
345     char **title) {
346   if (handle == nullptr || title == nullptr) {
347     LOGE("Invalid parameter");
348     return NOTI_EX_ERROR_INVALID_PARAMETER;
349   }
350
351   Handle* sp = static_cast<Handle*>(handle);
352   if (!sp->IsValidType(AbstractItem::Button)) {
353     LOGE("Invalid handle type");
354     return NOTI_EX_ERROR_INVALID_PARAMETER;
355   }
356   ButtonItem* p = static_cast<ButtonItem*>(sp->Get());
357   if (!p->GetTitle().empty()) {
358     *title = strdup(p->GetTitle().c_str());
359     if (*title == nullptr) {
360       LOGE("Out-of-memory");
361       return NOTI_EX_ERROR_OUT_OF_MEMORY;
362     }
363   }
364
365   return NOTI_EX_ERROR_NONE;
366 }
367
368 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
369     noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
370     noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
371     noti_ex_item_chat_message_type_e message_type) {
372   if (handle == nullptr || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
373     LOGE("Invalid parameter");
374     return NOTI_EX_ERROR_INVALID_PARAMETER;
375   }
376
377   auto* p = new (std::nothrow) ChatMessageItem(id,
378           dynamic_pointer_cast<TextItem>(static_cast<Handle*>(name)->GetPtr()),
379           dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
380           dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
381           dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
382           static_cast<ChatMessageItem::Type>((int)message_type));
383   if (p == nullptr) {
384     LOGE("Out-of-memory");
385     return NOTI_EX_ERROR_OUT_OF_MEMORY;
386   }
387
388   *handle = new Handle(shared_ptr<AbstractItem>(p));
389
390   return NOTI_EX_ERROR_NONE;
391 }
392
393 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
394     noti_ex_item_h handle, noti_ex_item_h *name) {
395   if (handle == nullptr || name == nullptr) {
396     LOGE("Invalid parameter");
397     return NOTI_EX_ERROR_INVALID_PARAMETER;
398   }
399   Handle* h = static_cast<Handle*>(handle);
400   if (!h->IsValidType(AbstractItem::ChatMessage)) {
401     LOGE("Invalid handle type");
402     return NOTI_EX_ERROR_INVALID_PARAMETER;
403   }
404   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
405   *name = new Handle(&(p->GetNameItem()));
406
407   return NOTI_EX_ERROR_NONE;
408 }
409
410 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
411     noti_ex_item_h handle, noti_ex_item_h *text) {
412   if (handle == nullptr || text == nullptr) {
413     LOGE("Invalid parameter");
414     return NOTI_EX_ERROR_INVALID_PARAMETER;
415   }
416
417   Handle* h = static_cast<Handle*>(handle);
418   if (!h->IsValidType(AbstractItem::ChatMessage)) {
419     LOGE("Invalid handle type");
420     return NOTI_EX_ERROR_INVALID_PARAMETER;
421   }
422   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
423   *text = new Handle(&(p->GetTextItem()));
424
425   return NOTI_EX_ERROR_NONE;
426 }
427
428 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
429     noti_ex_item_h handle, noti_ex_item_h *image) {
430   if (handle == nullptr || image == nullptr) {
431     LOGE("Invalid parameter");
432     return NOTI_EX_ERROR_INVALID_PARAMETER;
433   }
434
435   Handle* h = static_cast<Handle*>(handle);
436   if (!h->IsValidType(AbstractItem::ChatMessage)) {
437     LOGE("Invalid handle type");
438     return NOTI_EX_ERROR_INVALID_PARAMETER;
439   }
440   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
441   *image =  new Handle(&(p->GetImageItem()));
442
443   return NOTI_EX_ERROR_NONE;
444 }
445
446 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
447     noti_ex_item_h handle, noti_ex_item_h *time) {
448   if (handle == nullptr || time == nullptr) {
449     LOGE("Invalid parameter");
450     return NOTI_EX_ERROR_INVALID_PARAMETER;
451   }
452
453   Handle* h = static_cast<Handle*>(handle);
454   if (!h->IsValidType(AbstractItem::ChatMessage)) {
455     LOGE("Invalid handle type");
456     return NOTI_EX_ERROR_INVALID_PARAMETER;
457   }
458   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
459   *time = new Handle(&(p->GetTimeItem()));
460
461   return NOTI_EX_ERROR_NONE;
462 }
463
464 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
465     noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
466   if (handle == nullptr || message_type == nullptr) {
467     LOGE("Invalid parameter");
468     return NOTI_EX_ERROR_INVALID_PARAMETER;
469   }
470
471   Handle* h = static_cast<Handle*>(handle);
472   if (!h->IsValidType(AbstractItem::ChatMessage)) {
473     LOGE("Invalid handle type");
474     return NOTI_EX_ERROR_INVALID_PARAMETER;
475   }
476   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
477   *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
478
479   return NOTI_EX_ERROR_NONE;
480 }
481
482 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
483     const char *id, const char *title, bool checked) {
484   CheckBoxItem* p;
485
486   if (handle == nullptr || title == nullptr) {
487     LOGE("Invalid parameter");
488     return NOTI_EX_ERROR_INVALID_PARAMETER;
489   }
490
491   p = new (std::nothrow) CheckBoxItem(id, title, checked);
492   if (p == nullptr) {
493     LOGE("Out-of-memory");
494     return NOTI_EX_ERROR_OUT_OF_MEMORY;
495   }
496
497   *handle = new Handle(p);
498
499   return NOTI_EX_ERROR_NONE;
500 }
501
502 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
503     char **title) {
504   if (handle == nullptr || title == nullptr) {
505     LOGE("Invalid parameter");
506     return NOTI_EX_ERROR_INVALID_PARAMETER;
507   }
508   Handle* h = static_cast<Handle*>(handle);
509   if (!h->IsValidType(AbstractItem::CheckBox)) {
510     LOGE("Invalid handle type");
511     return NOTI_EX_ERROR_INVALID_PARAMETER;
512   }
513   CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
514   if (!p->GetTitle().empty()) {
515     *title = strdup(p->GetTitle().c_str());
516     if (*title == nullptr) {
517         LOGE("Out-of-memory");
518         return NOTI_EX_ERROR_OUT_OF_MEMORY;
519     }
520   }
521
522   return NOTI_EX_ERROR_NONE;
523 }
524
525 extern "C" EXPORT_API int noti_ex_item_checkbox_is_checked(noti_ex_item_h handle,
526     bool *checked) {
527   if (handle == nullptr || checked == nullptr) {
528     LOGE("Invalid parameter");
529     return NOTI_EX_ERROR_INVALID_PARAMETER;
530   }
531   Handle* h = static_cast<Handle*>(handle);
532   if (!h->IsValidType(AbstractItem::CheckBox)) {
533     LOGE("Invalid handle type");
534     return NOTI_EX_ERROR_INVALID_PARAMETER;
535   }
536   CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
537   *checked = p->IsChecked();
538
539   return NOTI_EX_ERROR_NONE;
540 }
541
542 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
543     const char *id) {
544   EntryItem* p;
545
546   if (handle == nullptr) {
547     LOGE("Invalid parameter");
548     return NOTI_EX_ERROR_INVALID_PARAMETER;
549   }
550
551   p = new (std::nothrow) EntryItem(id);
552   if (p == nullptr) {
553     LOGE("Out-of-memory");
554     return NOTI_EX_ERROR_OUT_OF_MEMORY;
555   }
556
557   *handle = new Handle(p);
558
559   return NOTI_EX_ERROR_NONE;
560 }
561
562 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
563     char **text) {
564   if (handle == nullptr || text == nullptr) {
565     LOGE("Invalid parameter");
566     return NOTI_EX_ERROR_INVALID_PARAMETER;
567   }
568
569   Handle* h = static_cast<Handle*>(handle);
570   if (!h->IsValidType(AbstractItem::Entry)) {
571     LOGE("Invalid handle type");
572     return NOTI_EX_ERROR_INVALID_PARAMETER;
573   }
574   EntryItem* p = static_cast<EntryItem*>(h->Get());
575   if (!p->GetText().empty()) {
576     *text = strdup(p->GetText().c_str());
577     if (*text == nullptr) {
578         LOGE("Out-of-memory");
579         return NOTI_EX_ERROR_OUT_OF_MEMORY;
580     }
581   }
582
583   return NOTI_EX_ERROR_NONE;
584 }
585
586 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
587     const char *text) {
588   if (handle == nullptr || text == nullptr) {
589     LOGE("Invalid parameter");
590     return NOTI_EX_ERROR_INVALID_PARAMETER;
591   }
592   Handle* h = static_cast<Handle*>(handle);
593   if (!h->IsValidType(AbstractItem::Entry)) {
594     LOGE("Invalid handle type");
595     return NOTI_EX_ERROR_INVALID_PARAMETER;
596   }
597   EntryItem* p = static_cast<EntryItem*>(h->Get());
598   p->SetText(std::string(text));
599
600   return NOTI_EX_ERROR_NONE;
601 }
602
603 extern "C" EXPORT_API int noti_ex_event_info_clone(noti_ex_event_info_h handle,
604                 noti_ex_event_info_h* cloned_handle) {
605   if (handle == nullptr || cloned_handle == nullptr) {
606     LOGE("Invalid parameter");
607     return NOTI_EX_ERROR_INVALID_PARAMETER;
608   }
609
610   Bundle cloned = static_cast<EventInfo*>(handle)->Serialize();
611   EventInfo* info = new EventInfo(cloned);
612   *cloned_handle = info;
613   return NOTI_EX_ERROR_NONE;
614 }
615
616 extern "C" EXPORT_API int noti_ex_event_info_destroy(
617     noti_ex_event_info_h handle) {
618   if (handle == nullptr) {
619     LOGE("Invalid parameter");
620     return NOTI_EX_ERROR_INVALID_PARAMETER;
621   }
622   EventInfo* info = static_cast<EventInfo*>(handle);
623   delete info;
624   return NOTI_EX_ERROR_NONE;
625 }
626
627 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
628     noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
629   if (handle == nullptr || event_type == nullptr) {
630     LOGE("Invalid parameter");
631     return NOTI_EX_ERROR_INVALID_PARAMETER;
632   }
633   EventInfo* info = static_cast<EventInfo*>(handle);
634   *event_type = static_cast<noti_ex_event_info_type_e>(info->GetEventType());
635
636   return NOTI_EX_ERROR_NONE;
637 }
638
639 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
640     noti_ex_event_info_h handle, char **owner) {
641   if (handle == nullptr || owner == nullptr) {
642     LOGE("Invalid parameter");
643     return NOTI_EX_ERROR_INVALID_PARAMETER;
644   }
645   EventInfo* info = static_cast<EventInfo*>(handle);
646   *owner = strdup(info->GetOwner().c_str());
647   return NOTI_EX_ERROR_NONE;
648 }
649
650 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
651     noti_ex_event_info_h handle, char **channel) {
652   if (handle == nullptr || channel == nullptr) {
653     LOGE("Invalid parameter");
654     return NOTI_EX_ERROR_INVALID_PARAMETER;
655   }
656   EventInfo* info = static_cast<EventInfo*>(handle);
657   *channel = strdup(info->GetChannel().c_str());
658   return NOTI_EX_ERROR_NONE;
659 }
660
661 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
662     noti_ex_event_info_h handle, char **item_id) {
663   if (handle == nullptr || item_id == nullptr) {
664     LOGE("Invalid parameter");
665     return NOTI_EX_ERROR_INVALID_PARAMETER;
666   }
667   EventInfo* info = static_cast<EventInfo*>(handle);
668   *item_id = strdup(info->GetItemId().c_str());
669   return NOTI_EX_ERROR_NONE;
670 }
671
672 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
673     noti_ex_event_info_h handle, int *req_id) {
674   if (handle == nullptr || req_id == nullptr) {
675     LOGE("Invalid parameter");
676     return NOTI_EX_ERROR_INVALID_PARAMETER;
677   }
678   EventInfo* info = static_cast<EventInfo*>(handle);
679   *req_id = info->GetRequestId();
680   return NOTI_EX_ERROR_NONE;
681 }
682
683 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
684     const char *id) {
685   GroupItem* p;
686
687   if (handle == nullptr) {
688     LOGE("Invalid parameter");
689     return NOTI_EX_ERROR_INVALID_PARAMETER;
690   }
691
692   if (id)
693     p = new (std::nothrow) GroupItem(id);
694   else
695     p = new (std::nothrow) GroupItem();
696
697   if (p == nullptr) {
698     LOGE("Out-of-memory");
699     return NOTI_EX_ERROR_OUT_OF_MEMORY;
700   }
701
702   *handle = new Handle(shared_ptr<AbstractItem>(p));
703
704   return NOTI_EX_ERROR_NONE;
705 }
706
707 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
708     bool vertical) {
709   if (handle == nullptr) {
710     LOGE("Invalid parameter");
711     return NOTI_EX_ERROR_INVALID_PARAMETER;
712   }
713   Handle* h = static_cast<Handle*>(handle);
714   if (!h->IsValidType(AbstractItem::Group)) {
715     LOGE("Invalid handle type");
716     return NOTI_EX_ERROR_INVALID_PARAMETER;
717   }
718   GroupItem* p = static_cast<GroupItem*>(h->Get());
719   p->SetDirection(vertical);
720
721   return NOTI_EX_ERROR_NONE;
722 }
723
724 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
725     bool *vertical) {
726   if (handle == nullptr) {
727     LOGE("Invalid parameter");
728     return NOTI_EX_ERROR_INVALID_PARAMETER;
729   }
730   Handle* h = static_cast<Handle*>(handle);
731   if (!h->IsValidType(AbstractItem::Group)) {
732     LOGE("Invalid handle type");
733     return NOTI_EX_ERROR_INVALID_PARAMETER;
734   }
735   GroupItem* p = static_cast<GroupItem*>(h->Get());
736   *vertical = p->IsVertical();
737
738   return NOTI_EX_ERROR_NONE;
739 }
740
741 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
742     char **label) {
743   if (handle == nullptr) {
744     LOGE("Invalid parameter");
745     return NOTI_EX_ERROR_INVALID_PARAMETER;
746   }
747   Handle* h = static_cast<Handle*>(handle);
748   if (!h->IsValidType(AbstractItem::Group)) {
749     LOGE("Invalid handle type");
750     return NOTI_EX_ERROR_INVALID_PARAMETER;
751   }
752   GroupItem* p = static_cast<GroupItem*>(h->Get());
753   if (!p->GetAppLabel().empty()) {
754     *label = strdup(p->GetAppLabel().c_str());
755     if (*label == nullptr) {
756       LOGE("Out-of-memory");
757       return NOTI_EX_ERROR_OUT_OF_MEMORY;
758     }
759   }
760
761   return NOTI_EX_ERROR_NONE;
762 }
763
764 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
765     noti_ex_item_h child) {
766   if (handle == nullptr || child == nullptr) {
767     LOGE("Invalid parameter");
768     return NOTI_EX_ERROR_INVALID_PARAMETER;
769   }
770   Handle* h = static_cast<Handle*>(handle);
771   if (!h->IsValidType(AbstractItem::Group)) {
772     LOGE("Invalid handle type");
773     return NOTI_EX_ERROR_INVALID_PARAMETER;
774   }
775   auto p = static_cast<GroupItem*>(h->Get());
776   p->AddChild((static_cast<Handle*>(child))->GetPtr());
777
778   return NOTI_EX_ERROR_NONE;
779 }
780
781 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
782     const char *item_id) {
783   if (handle == nullptr || item_id == nullptr) {
784     LOGE("Invalid parameter");
785     return NOTI_EX_ERROR_INVALID_PARAMETER;
786   }
787   Handle* h = static_cast<Handle*>(handle);
788   if (!h->IsValidType(AbstractItem::Group)) {
789     LOGE("Invalid handle type");
790     return NOTI_EX_ERROR_INVALID_PARAMETER;
791   }
792   GroupItem* p = static_cast<GroupItem*>(h->Get());
793   p->RemoveChild(std::string(item_id));
794
795   return NOTI_EX_ERROR_NONE;
796 }
797
798 extern "C" EXPORT_API int noti_ex_item_group_foreach(noti_ex_item_h handle,
799     noti_ex_item_group_foreach_cb callback, void *data) {
800   if (handle == nullptr || callback == nullptr) {
801     LOGE("Invalid parameter");
802     return NOTI_EX_ERROR_INVALID_PARAMETER;
803   }
804
805   Handle* h = static_cast<Handle*>(handle);
806   if (!h->IsValidType(AbstractItem::Group)) {
807     LOGE("Invalid handle type");
808     return NOTI_EX_ERROR_INVALID_PARAMETER;
809   }
810   GroupItem* p = static_cast<GroupItem*>(h->Get());
811   list<shared_ptr<AbstractItem>> children = p->GetChildren();
812   LOGI("Retrive (%zd)", children.size());
813   for (auto i : children) {
814     int ret = callback(
815         static_cast<noti_ex_item_h>(new Handle(i)), data);
816     if (ret != NOTI_EX_ERROR_NONE) {
817       LOGW("callback return (%d) stop foreach", ret);
818       break;
819     }
820   }
821
822   return NOTI_EX_ERROR_NONE;
823 }
824
825 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
826     const char *id, const char *image_path) {
827   ImageItem* p;
828
829   if (handle == nullptr  || image_path == nullptr) {
830     LOGE("Invalid parameter");
831     return NOTI_EX_ERROR_INVALID_PARAMETER;
832   }
833
834   if (id)
835     p = new (std::nothrow) ImageItem(id, image_path);
836   else
837     p = new (std::nothrow) ImageItem(image_path);
838
839   if (p == nullptr) {
840     LOGE("Out-of-memory");
841     return NOTI_EX_ERROR_OUT_OF_MEMORY;
842   }
843
844   *handle = new Handle(p);
845
846   return NOTI_EX_ERROR_NONE;
847 }
848
849 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
850     noti_ex_item_h handle, char **image_path) {
851   if (handle == nullptr || image_path == nullptr) {
852     LOGE("Invalid parameter");
853     return NOTI_EX_ERROR_INVALID_PARAMETER;
854   }
855   Handle* h = static_cast<Handle*>(handle);
856   if (!h->IsValidType(AbstractItem::Image)) {
857     LOGE("Invalid handle type");
858     return NOTI_EX_ERROR_INVALID_PARAMETER;
859   }
860   ImageItem* p = static_cast<ImageItem*>(h->Get());
861   if (!p->GetImagePath().empty()) {
862     *image_path = strdup(p->GetImagePath().c_str());
863     if (*image_path == nullptr) {
864       LOGE("Out-of-memory");
865       return NOTI_EX_ERROR_OUT_OF_MEMORY;
866     }
867   }
868
869   return NOTI_EX_ERROR_NONE;
870 }
871
872 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
873     noti_ex_item_h *handle, const char *id) {
874   InputSelectorItem* p;
875
876   if (handle == nullptr) {
877     LOGE("Invalid parameter");
878     return NOTI_EX_ERROR_INVALID_PARAMETER;
879   }
880
881   if (id)
882     p = new (std::nothrow) InputSelectorItem(id);
883   else
884     p = new (std::nothrow) InputSelectorItem();
885
886   if (p == nullptr) {
887     LOGE("Out-of-memory");
888     return NOTI_EX_ERROR_OUT_OF_MEMORY;
889   }
890
891   *handle = new Handle(p);
892
893   return NOTI_EX_ERROR_NONE;
894 }
895
896 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
897     noti_ex_item_h handle, char ***contents_list, int *count) {
898   if (handle == nullptr || contents_list == nullptr || count == nullptr) {
899     LOGE("Invalid parameter");
900     return NOTI_EX_ERROR_INVALID_PARAMETER;
901   }
902
903   Handle* h = static_cast<Handle*>(handle);
904   if (!h->IsValidType(AbstractItem::InputSelector)) {
905     LOGE("Invalid handle type");
906     return NOTI_EX_ERROR_INVALID_PARAMETER;
907   }
908   InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
909   list<string> contents = p->GetContents();
910   *contents_list = (char**)calloc(contents.size(), sizeof(char*));
911   int idx = 0;
912   for (auto& i : contents) {
913     *contents_list[idx++] = strdup(i.c_str());
914   }
915   *count = contents.size();
916
917   return NOTI_EX_ERROR_NONE;
918 }
919
920 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
921     noti_ex_item_h handle, const char **contents, int count) {
922   if (handle == nullptr || contents == nullptr) {
923     LOGE("Invalid parameter");
924     return NOTI_EX_ERROR_INVALID_PARAMETER;
925   }
926
927   list<string> new_contents;
928   Handle* h = static_cast<Handle*>(handle);
929   if (!h->IsValidType(AbstractItem::InputSelector)) {
930     LOGE("Invalid handle type");
931     return NOTI_EX_ERROR_INVALID_PARAMETER;
932   }
933   InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
934   for (int i = 0; i < count; i++) {
935     new_contents.push_back(contents[i]);
936   }
937   p->SetContents(move(new_contents));
938
939   return NOTI_EX_ERROR_NONE;
940 }
941
942 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
943     unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
944   if (handle == nullptr) {
945     LOGE("Invalid parameter");
946     return NOTI_EX_ERROR_INVALID_PARAMETER;
947   }
948
949   auto* p = new (std::nothrow) Color(a, r, g, b);
950   if (p == nullptr) {
951     LOGE("Out-of-memory");
952     return NOTI_EX_ERROR_OUT_OF_MEMORY;
953   }
954
955   *handle = p;
956
957   return NOTI_EX_ERROR_NONE;
958 }
959
960 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
961   if (handle == nullptr) {
962     LOGE("Invalid parameter");
963     return NOTI_EX_ERROR_INVALID_PARAMETER;
964   }
965
966   Color* p = static_cast<Color*>(handle);
967   p->~Color();
968
969   return NOTI_EX_ERROR_NONE;
970 }
971
972 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
973     unsigned char *val) {
974   if (handle == nullptr || val == nullptr) {
975     LOGE("Invalid parameter");
976     return NOTI_EX_ERROR_INVALID_PARAMETER;
977   }
978
979   Color* p = static_cast<Color*>(handle);
980   *val = p->GetAVal();
981
982   return NOTI_EX_ERROR_NONE;
983 }
984
985 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
986     unsigned char *val) {
987   if (handle == nullptr || val == nullptr) {
988     LOGE("Invalid parameter");
989     return NOTI_EX_ERROR_INVALID_PARAMETER;
990   }
991
992   Color* p = static_cast<Color*>(handle);
993   *val = p->GetRVal();
994
995   return NOTI_EX_ERROR_NONE;
996 }
997
998 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
999     unsigned char *val) {
1000   if (handle == nullptr || val == nullptr) {
1001     LOGE("Invalid parameter");
1002     return NOTI_EX_ERROR_INVALID_PARAMETER;
1003   }
1004
1005   Color* p = static_cast<Color*>(handle);
1006   *val = p->GetGVal();
1007
1008   return NOTI_EX_ERROR_NONE;
1009 }
1010
1011 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
1012     unsigned char *val) {
1013   if (handle == nullptr || val == nullptr) {
1014     LOGE("Invalid parameter");
1015     return NOTI_EX_ERROR_INVALID_PARAMETER;
1016   }
1017
1018   Color* p = static_cast<Color*>(handle);
1019   *val = p->GetBVal();
1020
1021   return NOTI_EX_ERROR_NONE;
1022 }
1023
1024 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
1025     int left, int top, int right, int bottom) {
1026   if (handle == nullptr) {
1027     LOGE("Invalid parameter");
1028     return NOTI_EX_ERROR_INVALID_PARAMETER;
1029   }
1030
1031   auto* p = new (std::nothrow) Padding(left, top, right, bottom);
1032   if (p == nullptr) {
1033     LOGE("Out-of-memory");
1034     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1035   }
1036
1037   *handle = p;
1038
1039   return NOTI_EX_ERROR_NONE;
1040 }
1041
1042 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
1043   if (handle == nullptr) {
1044     LOGE("Invalid parameter");
1045     return NOTI_EX_ERROR_INVALID_PARAMETER;
1046   }
1047
1048   Padding* p = static_cast<Padding*>(handle);
1049   p->~Padding();
1050
1051   return NOTI_EX_ERROR_NONE;
1052 }
1053
1054 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
1055     int *val) {
1056   if (handle == nullptr || val == nullptr) {
1057     LOGE("Invalid parameter");
1058     return NOTI_EX_ERROR_INVALID_PARAMETER;
1059   }
1060
1061   Padding* p = static_cast<Padding*>(handle);
1062   *val = p->GetLeft();
1063
1064   return NOTI_EX_ERROR_NONE;
1065 }
1066
1067 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
1068     int *val) {
1069   if (handle == nullptr || val == nullptr) {
1070     LOGE("Invalid parameter");
1071     return NOTI_EX_ERROR_INVALID_PARAMETER;
1072   }
1073
1074   Padding* p = static_cast<Padding*>(handle);
1075   *val = p->GetTop();
1076
1077   return NOTI_EX_ERROR_NONE;
1078 }
1079
1080 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
1081     int *val) {
1082   if (handle == nullptr || val == nullptr) {
1083     LOGE("Invalid parameter");
1084     return NOTI_EX_ERROR_INVALID_PARAMETER;
1085   }
1086
1087   Padding* p = static_cast<Padding*>(handle);
1088   *val = p->GetRight();
1089
1090   return NOTI_EX_ERROR_NONE;
1091 }
1092
1093 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
1094     int *val) {
1095   if (handle == nullptr || val == nullptr) {
1096     LOGE("Invalid parameter");
1097     return NOTI_EX_ERROR_INVALID_PARAMETER;
1098   }
1099
1100   Padding* p = static_cast<Padding*>(handle);
1101   *val = p->GetBottom();
1102
1103   return NOTI_EX_ERROR_NONE;
1104 }
1105
1106 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
1107     int x, int y, int w, int h) {
1108   if (handle == nullptr) {
1109     LOGE("Invalid parameter");
1110     return NOTI_EX_ERROR_INVALID_PARAMETER;
1111   }
1112
1113   auto* p = new (std::nothrow) Geometry(x, y, w, h);
1114   if (p == nullptr) {
1115     LOGE("Out-of-memory");
1116     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1117   }
1118
1119   *handle = p;
1120
1121   return NOTI_EX_ERROR_NONE;
1122 }
1123
1124 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
1125   if (handle == nullptr) {
1126     LOGE("Invalid parameter");
1127     return NOTI_EX_ERROR_INVALID_PARAMETER;
1128   }
1129
1130   Geometry* p = static_cast<Geometry*>(handle);
1131   p->~Geometry();
1132
1133   return NOTI_EX_ERROR_NONE;
1134 }
1135
1136 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
1137     int *val) {
1138   if (handle == nullptr || val == nullptr) {
1139     LOGE("Invalid parameter");
1140     return NOTI_EX_ERROR_INVALID_PARAMETER;
1141   }
1142
1143   Geometry* p = static_cast<Geometry*>(handle);
1144   *val = p->GetX();
1145
1146   return NOTI_EX_ERROR_NONE;
1147 }
1148
1149 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
1150     int *val) {
1151   if (handle == nullptr || val == nullptr) {
1152     LOGE("Invalid parameter");
1153     return NOTI_EX_ERROR_INVALID_PARAMETER;
1154   }
1155
1156   Geometry* p = static_cast<Geometry*>(handle);
1157   *val = p->GetY();
1158
1159   return NOTI_EX_ERROR_NONE;
1160 }
1161
1162 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
1163     int *val) {
1164   if (handle == nullptr || val == nullptr) {
1165     LOGE("Invalid parameter");
1166     return NOTI_EX_ERROR_INVALID_PARAMETER;
1167   }
1168
1169   Geometry* p = static_cast<Geometry*>(handle);
1170   *val = p->GetWidth();
1171
1172   return NOTI_EX_ERROR_NONE;
1173 }
1174
1175 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
1176     int *val) {
1177   if (handle == nullptr || val == nullptr) {
1178     LOGE("Invalid parameter");
1179     return NOTI_EX_ERROR_INVALID_PARAMETER;
1180   }
1181
1182   Geometry* p = static_cast<Geometry*>(handle);
1183   *val = p->GetHeight();
1184
1185   return NOTI_EX_ERROR_NONE;
1186 }
1187
1188 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
1189     noti_ex_color_h color,
1190     noti_ex_padding_h padding,
1191     noti_ex_geometry_h geometry) {
1192   if (handle == nullptr) {
1193     LOGE("Invalid parameter");
1194     return NOTI_EX_ERROR_INVALID_PARAMETER;
1195   }
1196
1197   Color* color_ = static_cast<Color*>(color);
1198   Padding* padding_ = static_cast<Padding*>(padding);
1199   Geometry* geo_ = static_cast<Geometry*>(geometry);
1200
1201   auto* p = new (std::nothrow) Style(*color_, *padding_, *geo_);
1202   if (p == nullptr) {
1203     LOGE("Out-of-memory");
1204     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1205   }
1206
1207   *handle = p;
1208
1209   return NOTI_EX_ERROR_NONE;
1210 }
1211
1212 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
1213   if (handle == nullptr) {
1214     LOGE("Invalid parameter");
1215     return NOTI_EX_ERROR_INVALID_PARAMETER;
1216   }
1217
1218   Style* p = static_cast<Style*>(handle);
1219   p->~Style();
1220
1221   return NOTI_EX_ERROR_NONE;
1222 }
1223
1224 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
1225     noti_ex_padding_h *padding) {
1226   if (handle == nullptr || padding == nullptr) {
1227     LOGE("Invalid parameter");
1228     return NOTI_EX_ERROR_INVALID_PARAMETER;
1229   }
1230
1231   Style* p = static_cast<Style*>(handle);
1232   Padding* padding_ = new (std::nothrow) Padding(p->GetPadding());
1233   if (padding_ == nullptr) {
1234     LOGE("Out-of-memory");
1235     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1236   }
1237
1238   *padding = padding_;
1239
1240   return NOTI_EX_ERROR_NONE;
1241 }
1242
1243 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
1244     noti_ex_color_h *color) {
1245   if (handle == nullptr || color == nullptr) {
1246     LOGE("Invalid parameter");
1247     return NOTI_EX_ERROR_INVALID_PARAMETER;
1248   }
1249
1250   Style* p = static_cast<Style*>(handle);
1251   Color* color_ = new (std::nothrow) Color(p->GetColor());
1252   if (color_ == nullptr) {
1253     LOGE("Out-of-memory");
1254     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1255   }
1256
1257   *color = color_;
1258
1259   return NOTI_EX_ERROR_NONE;
1260 }
1261
1262 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
1263     noti_ex_geometry_h *geometry) {
1264   if (handle == nullptr || geometry == nullptr) {
1265     LOGE("Invalid parameter");
1266     return NOTI_EX_ERROR_INVALID_PARAMETER;
1267   }
1268
1269   Style* p = static_cast<Style*>(handle);
1270   Geometry* geo_ = new (std::nothrow) Geometry(p->GetGeometry());
1271   if (geo_ == nullptr) {
1272     LOGE("Out-of-memory");
1273     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1274   }
1275
1276   *geometry = geo_;
1277
1278   return NOTI_EX_ERROR_NONE;
1279 }
1280
1281 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
1282     noti_ex_color_h color) {
1283   if (handle == nullptr) {
1284     LOGE("Invalid parameter");
1285     return NOTI_EX_ERROR_INVALID_PARAMETER;
1286   }
1287
1288   Color* color_ = static_cast<Color*>(color);
1289   auto* p = new (std::nothrow) LEDInfo(*color_);
1290   if (p == nullptr) {
1291     LOGE("Out-of-memory");
1292     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1293   }
1294
1295   *handle = p;
1296
1297   return NOTI_EX_ERROR_NONE;
1298 }
1299
1300 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
1301   if (handle == nullptr) {
1302     LOGE("Invalid parameter");
1303     return NOTI_EX_ERROR_INVALID_PARAMETER;
1304   }
1305
1306   LEDInfo* p = static_cast<LEDInfo*>(handle);
1307   p->~LEDInfo();
1308
1309   return NOTI_EX_ERROR_NONE;
1310 }
1311
1312 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
1313     noti_ex_led_info_h handle, int ms) {
1314   if (handle == nullptr) {
1315     LOGE("Invalid parameter");
1316     return NOTI_EX_ERROR_INVALID_PARAMETER;
1317   }
1318
1319   LEDInfo* p = static_cast<LEDInfo*>(handle);
1320   p->SetOnPeriod(ms);
1321
1322   return NOTI_EX_ERROR_NONE;
1323 }
1324
1325 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
1326     noti_ex_led_info_h handle, int *ms) {
1327   if (handle == nullptr || ms == nullptr) {
1328     LOGE("Invalid parameter");
1329     return NOTI_EX_ERROR_INVALID_PARAMETER;
1330   }
1331
1332   LEDInfo* p = static_cast<LEDInfo*>(handle);
1333   *ms = p->GetOnPeriod();
1334
1335   return NOTI_EX_ERROR_NONE;
1336 }
1337
1338 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
1339     noti_ex_led_info_h handle, int ms) {
1340   if (handle == nullptr) {
1341     LOGE("Invalid parameter");
1342     return NOTI_EX_ERROR_INVALID_PARAMETER;
1343   }
1344
1345   LEDInfo* p = static_cast<LEDInfo*>(handle);
1346   p->SetOffPeriod(ms);
1347
1348   return NOTI_EX_ERROR_NONE;
1349 }
1350
1351 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
1352     noti_ex_led_info_h handle, int *ms) {
1353   if (handle == nullptr) {
1354     LOGE("Invalid parameter");
1355     return NOTI_EX_ERROR_INVALID_PARAMETER;
1356   }
1357
1358   LEDInfo* p = static_cast<LEDInfo*>(handle);
1359   *ms = p->GetOffPeriod();
1360
1361   return NOTI_EX_ERROR_NONE;
1362 }
1363
1364 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1365     noti_ex_led_info_h handle, noti_ex_color_h *color) {
1366   if (handle == nullptr) {
1367     LOGE("Invalid parameter");
1368     return NOTI_EX_ERROR_INVALID_PARAMETER;
1369   }
1370
1371   LEDInfo* p = static_cast<LEDInfo*>(handle);
1372   Color* color_ = new (std::nothrow) Color(p->GetColor());
1373   if (color_ == nullptr) {
1374     LOGE("Out-of-memory");
1375     return NOTI_EX_ERROR_OUT_OF_MEMORY;
1376   }
1377
1378   *color = color_;
1379
1380   return NOTI_EX_ERROR_NONE;
1381 }
1382
1383 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1384   if (handle == nullptr) {
1385     LOGE("Invalid parameter");
1386     return NOTI_EX_ERROR_INVALID_PARAMETER;
1387   }
1388
1389   AbstractAction* p = static_cast<AbstractAction*>(handle);
1390   p->~AbstractAction();
1391
1392   return NOTI_EX_ERROR_NONE;
1393 }
1394
1395 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1396     int *type) {
1397   if (handle == nullptr || type == nullptr) {
1398     LOGE("Invalid parameter");
1399     return NOTI_EX_ERROR_INVALID_PARAMETER;
1400   }
1401
1402   AbstractAction* p = static_cast<AbstractAction*>(handle);
1403   *type = p->GetType();
1404
1405   return NOTI_EX_ERROR_NONE;
1406 }
1407
1408 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1409     bool *local) {
1410   if (handle == nullptr || local == nullptr) {
1411     LOGE("Invalid parameter");
1412     return NOTI_EX_ERROR_INVALID_PARAMETER;
1413   }
1414
1415   AbstractAction* p = static_cast<AbstractAction*>(handle);
1416   *local = p->IsLocal();
1417
1418   return NOTI_EX_ERROR_NONE;
1419 }
1420
1421 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1422     noti_ex_item_h item) {
1423   if (handle == nullptr || item==nullptr) {
1424     LOGE("Invalid parameter");
1425     return NOTI_EX_ERROR_INVALID_PARAMETER;
1426   }
1427   AbstractAction* p = static_cast<AbstractAction*>(handle);
1428   Handle* ih = static_cast<Handle*>(item);
1429   p->Execute(ih->GetPtr());
1430
1431   return NOTI_EX_ERROR_NONE;
1432 }
1433
1434 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1435     char **extra) {
1436   if (handle == nullptr || extra == nullptr) {
1437     LOGE("Invalid parameter");
1438     return NOTI_EX_ERROR_INVALID_PARAMETER;
1439   }
1440
1441   AbstractAction* p = static_cast<AbstractAction*>(handle);
1442   if (!p->GetExtra().empty()) {
1443     *extra = strdup(p->GetExtra().c_str());
1444     if (*extra == nullptr) {
1445       LOGE("Out-of-memory");
1446       return NOTI_EX_ERROR_OUT_OF_MEMORY;
1447     }
1448   }
1449
1450   return NOTI_EX_ERROR_NONE;
1451 }
1452
1453 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1454     noti_ex_item_info_h handle, int *hide_time) {
1455   if (handle == nullptr || hide_time == nullptr) {
1456     LOGE("Invalid parameter");
1457     return NOTI_EX_ERROR_INVALID_PARAMETER;
1458   }
1459   IItemInfo* p = static_cast<IItemInfo*>(handle);
1460   *hide_time = p->GetHideTime();
1461   return NOTI_EX_ERROR_NONE;
1462 }
1463
1464 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1465     noti_ex_item_info_h handle, int hide_time) {
1466   if (handle == nullptr) {
1467     LOGE("Invalid parameter");
1468     return NOTI_EX_ERROR_INVALID_PARAMETER;
1469   }
1470   IItemInfo* p = static_cast<IItemInfo*>(handle);
1471   p->SetHideTime(hide_time);
1472   return NOTI_EX_ERROR_NONE;
1473 }
1474
1475 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1476     noti_ex_item_info_h handle, int *delete_time) {
1477   if (handle == nullptr || delete_time == nullptr) {
1478     LOGE("Invalid parameter");
1479     return NOTI_EX_ERROR_INVALID_PARAMETER;
1480   }
1481   IItemInfo* p = static_cast<IItemInfo*>(handle);
1482   *delete_time = p->GetDeleteTime();
1483   return NOTI_EX_ERROR_NONE;
1484 }
1485
1486 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
1487     noti_ex_item_info_h handle, int delete_time) {
1488   if (handle == nullptr) {
1489     LOGE("Invalid parameter");
1490     return NOTI_EX_ERROR_INVALID_PARAMETER;
1491   }
1492   IItemInfo* p = static_cast<IItemInfo*>(handle);
1493   p->SetDeleteTime(delete_time);
1494   return NOTI_EX_ERROR_NONE;
1495 }
1496
1497 extern "C" EXPORT_API int noti_ex_item_info_get_time(
1498     noti_ex_item_info_h handle, time_t *time) {
1499   if (handle == nullptr || time == nullptr) {
1500     LOGE("Invalid parameter");
1501     return NOTI_EX_ERROR_INVALID_PARAMETER;
1502   }
1503
1504   IItemInfo* p = static_cast<IItemInfo*>(handle);
1505   *time = p->GetTime();
1506   return NOTI_EX_ERROR_NONE;
1507 }
1508
1509 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
1510   if (handle == nullptr) {
1511     LOGE("Invalid parameter");
1512     return NOTI_EX_ERROR_INVALID_PARAMETER;
1513   }
1514
1515   Handle* h = static_cast<Handle*>(handle);
1516   delete h;
1517   return NOTI_EX_ERROR_NONE;
1518 }
1519
1520 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
1521     const char *id, noti_ex_item_h *item) {
1522   if (handle == nullptr) {
1523     LOGE("Invalid parameter");
1524     return NOTI_EX_ERROR_INVALID_PARAMETER;
1525   }
1526
1527   Handle* p = static_cast<Handle*>(handle);
1528   AbstractItem& find_item = p->Get()->FindByID(string(id));
1529   *item = new Handle(&find_item);
1530   return NOTI_EX_ERROR_NONE;
1531 }
1532
1533 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
1534     int *type) {
1535   if (handle == nullptr || type == nullptr) {
1536     LOGE("Invalid parameter");
1537     return NOTI_EX_ERROR_INVALID_PARAMETER;
1538   }
1539
1540   Handle* h = static_cast<Handle*>(handle);
1541   AbstractItem* p = h->Get();
1542   *type = p->GetType();
1543   return NOTI_EX_ERROR_NONE;
1544 }
1545
1546 extern "C" EXPORT_API int noti_ex_item_get_shared_path(noti_ex_item_h handle,
1547     char ***path, int *count) {
1548   if (handle == nullptr || path == nullptr || count == nullptr) {
1549     LOGE("Invalid parameter");
1550     return NOTI_EX_ERROR_INVALID_PARAMETER;
1551   }
1552   Handle* p = static_cast<Handle*>(handle);
1553   list<string> shared_path = p->Get()->GetSharedPath();
1554   *path = (char**)calloc(shared_path.size(), sizeof(char*));
1555   int idx = 0;
1556   for (auto& i : shared_path) {
1557     *path[idx++] = strdup(i.c_str());
1558   }
1559   *count = shared_path.size();
1560   return NOTI_EX_ERROR_NONE;
1561 }
1562
1563 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
1564     char **id) {
1565   if (handle == nullptr || id == nullptr) {
1566     LOGE("Invalid parameter");
1567     return NOTI_EX_ERROR_INVALID_PARAMETER;
1568   }
1569   Handle* h = static_cast<Handle*>(handle);
1570   AbstractItem* p = h->Get();
1571   *id = strdup(p->GetId().c_str());
1572   return NOTI_EX_ERROR_NONE;
1573 }
1574
1575 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
1576     const char *id) {
1577   if (handle == nullptr || id == nullptr) {
1578     LOGE("Invalid parameter");
1579     return NOTI_EX_ERROR_INVALID_PARAMETER;
1580   }
1581   Handle* p = static_cast<Handle*>(handle);
1582   p->Get()->SetId(id);
1583   return NOTI_EX_ERROR_NONE;
1584 }
1585
1586 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
1587     noti_ex_action_h *action) {
1588   if (handle == nullptr || action == nullptr) {
1589     LOGE("Invalid parameter");
1590     return NOTI_EX_ERROR_INVALID_PARAMETER;
1591   }
1592   Handle* p = static_cast<Handle*>(handle);
1593   if (p->Get()->GetAction() == nullptr) {
1594     *action = nullptr;
1595     return NOTI_EX_ERROR_NONE;
1596   }
1597   *action = static_cast<noti_ex_action_h>(p->Get()->GetAction().get());
1598
1599   return NOTI_EX_ERROR_NONE;
1600 }
1601
1602 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
1603     noti_ex_action_h action) {
1604   if (handle == nullptr || action == nullptr) {
1605     LOGE("Invalid parameter");
1606     return NOTI_EX_ERROR_INVALID_PARAMETER;
1607   }
1608
1609   Handle* p = static_cast<Handle*>(handle);
1610   AbstractAction* a = static_cast<AbstractAction*>(action);
1611   p->Get()->SetAction(shared_ptr<AbstractAction>(a));
1612   return NOTI_EX_ERROR_NONE;
1613 }
1614
1615 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
1616     noti_ex_style_h *style) {
1617   if (handle == nullptr || style == nullptr) {
1618     LOGE("Invalid parameter");
1619     return NOTI_EX_ERROR_INVALID_PARAMETER;
1620   }
1621
1622   Handle* p = static_cast<Handle*>(handle);
1623   shared_ptr<Style> s = p->Get()->GetStyle();
1624   *style = static_cast<noti_ex_style_h>(s.get());
1625   return NOTI_EX_ERROR_NONE;
1626 }
1627
1628 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
1629     noti_ex_style_h style) {
1630   if (handle == nullptr || style == nullptr) {
1631     LOGE("Invalid parameter");
1632     return NOTI_EX_ERROR_INVALID_PARAMETER;
1633   }
1634
1635   Handle* p = static_cast<Handle*>(handle);
1636   Style* s = static_cast<Style*>(style);
1637   p->Get()->SetStyle(shared_ptr<Style>(s));
1638   return NOTI_EX_ERROR_NONE;
1639 }
1640
1641 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
1642     bool visible) {
1643   if (handle == nullptr) {
1644     LOGE("Invalid parameter");
1645     return NOTI_EX_ERROR_INVALID_PARAMETER;
1646   }
1647
1648   Handle* p = static_cast<Handle*>(handle);
1649   p->Get()->SetVisible(visible);
1650   return NOTI_EX_ERROR_NONE;
1651 }
1652
1653 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
1654     bool *visible) {
1655   if (handle == nullptr || visible == nullptr) {
1656     LOGE("Invalid parameter");
1657     return NOTI_EX_ERROR_INVALID_PARAMETER;
1658   }
1659
1660   Handle* p = static_cast<Handle*>(handle);
1661   *visible = p->Get()->GetVisible();
1662   return NOTI_EX_ERROR_NONE;
1663 }
1664
1665 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
1666     bool enable) {
1667   if (handle == nullptr) {
1668     LOGE("Invalid parameter");
1669     return NOTI_EX_ERROR_INVALID_PARAMETER;
1670   }
1671
1672   Handle* p = static_cast<Handle*>(handle);
1673   p->Get()->SetEnable(enable);
1674   return NOTI_EX_ERROR_NONE;
1675 }
1676
1677 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
1678     bool *enable) {
1679   if (handle == nullptr || enable == nullptr) {
1680     LOGE("Invalid parameter");
1681     return NOTI_EX_ERROR_INVALID_PARAMETER;
1682   }
1683
1684   Handle* p = static_cast<Handle*>(handle);
1685   *enable = p->Get()->GetEnable();
1686   return NOTI_EX_ERROR_NONE;
1687 }
1688
1689 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
1690     const char *receiver_group) {
1691   if (handle == nullptr || receiver_group == nullptr) {
1692     LOGE("Invalid parameter");
1693     return NOTI_EX_ERROR_INVALID_PARAMETER;
1694   }
1695
1696   Handle* p = static_cast<Handle*>(handle);
1697   p->Get()->AddReceiver(receiver_group);
1698   return NOTI_EX_ERROR_NONE;
1699 }
1700
1701 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
1702     const char *receiver_group) {
1703   if (handle == nullptr || receiver_group == nullptr) {
1704     LOGE("Invalid parameter");
1705     return NOTI_EX_ERROR_INVALID_PARAMETER;
1706   }
1707
1708   Handle* p = static_cast<Handle*>(handle);
1709   p->Get()->RemoveReceiver(receiver_group);
1710   return NOTI_EX_ERROR_NONE;
1711 }
1712
1713 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
1714     char ***receiver_list, int *count) {
1715   if (handle == nullptr || receiver_list == nullptr || count == nullptr) {
1716     LOGE("Invalid parameter");
1717     return NOTI_EX_ERROR_INVALID_PARAMETER;
1718   }
1719
1720   Handle* p = static_cast<Handle*>(handle);
1721   list<string> receivers = p->Get()->GetReceiverList();
1722   *receiver_list = (char**)calloc(receivers.size(), sizeof(char*));
1723   int idx = 0;
1724   for (auto& i : receivers) {
1725     *receiver_list[idx++] = strdup(i.c_str());
1726   }
1727   *count = receivers.size();
1728   return NOTI_EX_ERROR_NONE;
1729 }
1730
1731 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
1732     int policy) {
1733   if (handle == nullptr) {
1734     LOGE("Invalid parameter");
1735     return NOTI_EX_ERROR_INVALID_PARAMETER;
1736   }
1737
1738   Handle* p = static_cast<Handle*>(handle);
1739   p->Get()->SetPolicy(policy);
1740   return NOTI_EX_ERROR_NONE;
1741 }
1742
1743 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
1744     int *policy) {
1745   if (handle == nullptr || policy == nullptr) {
1746     LOGE("Invalid parameter");
1747     return NOTI_EX_ERROR_INVALID_PARAMETER;
1748   }
1749
1750   Handle* p = static_cast<Handle*>(handle);
1751   *policy = p->Get()->GetPolicy();
1752   return NOTI_EX_ERROR_NONE;
1753 }
1754
1755 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
1756     char **channel) {
1757   if (handle == nullptr || channel == nullptr) {
1758     LOGE("Invalid parameter");
1759     return NOTI_EX_ERROR_INVALID_PARAMETER;
1760   }
1761
1762   Handle* p = static_cast<Handle*>(handle);
1763   if (!p->Get()->GetChannel().empty())
1764     *channel = strdup(p->Get()->GetChannel().c_str());
1765   else
1766     *channel = nullptr;
1767
1768   return NOTI_EX_ERROR_NONE;
1769 }
1770
1771 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
1772     const char *channel) {
1773   if (handle == nullptr) {
1774     LOGE("Invalid parameter");
1775     return NOTI_EX_ERROR_INVALID_PARAMETER;
1776   }
1777
1778   Handle* p = static_cast<Handle*>(handle);
1779   p->Get()->SetChannel(channel);
1780   return NOTI_EX_ERROR_NONE;
1781 }
1782
1783 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
1784     noti_ex_led_info_h led) {
1785   if (handle == nullptr) {
1786     LOGE("Invalid parameter");
1787     return NOTI_EX_ERROR_INVALID_PARAMETER;
1788   }
1789
1790   Handle* p = static_cast<Handle*>(handle);
1791   LEDInfo* led_info = static_cast<LEDInfo*>(led);
1792   p->Get()->SetLEDInfo(shared_ptr<LEDInfo>(led_info));
1793   return NOTI_EX_ERROR_NONE;
1794 }
1795
1796 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
1797     noti_ex_led_info_h *led) {
1798   if (handle == nullptr) {
1799     LOGE("Invalid parameter");
1800     return NOTI_EX_ERROR_INVALID_PARAMETER;
1801   }
1802
1803   Handle* p = static_cast<Handle*>(handle);
1804   if (p->Get()->GetLEDInfo() != nullptr)
1805     *led = static_cast<noti_ex_led_info_h>(p->Get()->GetLEDInfo().get());
1806   else
1807     *led = nullptr;
1808   return NOTI_EX_ERROR_NONE;
1809 }
1810
1811 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
1812     const char *path) {
1813   if (handle == nullptr) {
1814     LOGE("Invalid parameter");
1815     return NOTI_EX_ERROR_INVALID_PARAMETER;
1816   }
1817
1818   Handle* p = static_cast<Handle*>(handle);
1819   if (path == nullptr)
1820     p->Get()->SetSoundPath("");
1821   else
1822     p->Get()->SetSoundPath(path);
1823   return NOTI_EX_ERROR_NONE;
1824 }
1825
1826 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
1827     const char *path) {
1828   if (handle == nullptr) {
1829     LOGE("Invalid parameter");
1830     return NOTI_EX_ERROR_INVALID_PARAMETER;
1831   }
1832
1833   Handle* p = static_cast<Handle*>(handle);
1834   if (path == nullptr)
1835     p->Get()->SetVibrationPath("");
1836   else
1837     p->Get()->SetVibrationPath(path);
1838   return NOTI_EX_ERROR_NONE;
1839 }
1840
1841 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
1842     char **path) {
1843   if (handle == nullptr || path == nullptr) {
1844     LOGE("Invalid parameter");
1845     return NOTI_EX_ERROR_INVALID_PARAMETER;
1846   }
1847
1848   Handle* p = static_cast<Handle*>(handle);
1849   if (p->Get()->GetSoundPath().empty())
1850     *path = nullptr;
1851   else
1852     *path = strdup(p->Get()->GetSoundPath().c_str());
1853   return NOTI_EX_ERROR_NONE;
1854 }
1855
1856 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
1857     char **path) {
1858   if (handle == nullptr || path == nullptr) {
1859     LOGE("Invalid parameter");
1860     return NOTI_EX_ERROR_INVALID_PARAMETER;
1861   }
1862
1863   Handle* p = static_cast<Handle*>(handle);
1864   if (p->Get()->GetVibrationPath().empty())
1865     *path = nullptr;
1866   else
1867     *path = strdup(p->Get()->GetVibrationPath().c_str());
1868   return NOTI_EX_ERROR_NONE;
1869 }
1870
1871 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
1872     noti_ex_item_info_h *info) {
1873   if (handle == nullptr || info == nullptr) {
1874     LOGE("Invalid parameter");
1875     return NOTI_EX_ERROR_INVALID_PARAMETER;
1876   }
1877
1878   Handle* p = static_cast<Handle*>(handle);
1879   if (p->Get()->GetInfo() == nullptr)
1880     *info = nullptr;
1881   else
1882     *info = static_cast<noti_ex_item_info_h>(p->Get()->GetInfo().get());
1883   return NOTI_EX_ERROR_NONE;
1884 }
1885
1886 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
1887     char **id) {
1888   if (handle == nullptr || id == nullptr) {
1889     LOGE("Invalid parameter");
1890     return NOTI_EX_ERROR_INVALID_PARAMETER;
1891   }
1892
1893   Handle* p = static_cast<Handle*>(handle);
1894   if (p->Get()->GetSenderAppId().empty())
1895     *id = nullptr;
1896   else
1897     *id = strdup(p->Get()->GetSenderAppId().c_str());
1898   return NOTI_EX_ERROR_NONE;
1899 }
1900
1901 extern "C" EXPORT_API int noti_ex_item_set_sender_app_id(noti_ex_item_h handle,
1902     const char *id) {
1903   if (handle == nullptr) {
1904     LOGE("Invalid parameter");
1905     return NOTI_EX_ERROR_INVALID_PARAMETER;
1906   }
1907
1908   Handle* p = static_cast<Handle*>(handle);
1909   if (id == nullptr)
1910     p->Get()->SetSenderAppId("");
1911   else
1912     p->Get()->SetSenderAppId(id);
1913   return NOTI_EX_ERROR_NONE;
1914 }
1915
1916 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
1917     char **tag) {
1918   if (handle == nullptr || tag == nullptr) {
1919     LOGE("Invalid parameter");
1920     return NOTI_EX_ERROR_INVALID_PARAMETER;
1921   }
1922
1923   Handle* p = static_cast<Handle*>(handle);
1924   if (p->Get()->GetTag().empty())
1925     *tag = nullptr;
1926   else
1927     *tag = strdup(p->Get()->GetTag().c_str());
1928   return NOTI_EX_ERROR_NONE;
1929 }
1930
1931 extern "C" EXPORT_API int noti_ex_item_set_tag(noti_ex_item_h handle,
1932     const char *tag) {
1933   if (handle == nullptr) {
1934     LOGE("Invalid parameter");
1935     return NOTI_EX_ERROR_INVALID_PARAMETER;
1936   }
1937
1938   Handle* p = static_cast<Handle*>(handle);
1939   if (tag == nullptr)
1940     p->Get()->SetTag("");
1941   else
1942     p->Get()->SetTag(tag);
1943   return NOTI_EX_ERROR_NONE;
1944 }
1945
1946 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
1947     const char *receiver_group, noti_ex_manager_events_s event_callbacks,
1948     void *data) {
1949   if (handle == nullptr) {
1950     LOGE("Invalid parameter");
1951     return NOTI_EX_ERROR_INVALID_PARAMETER;
1952   }
1953
1954   ManagerStub* stub = new (std::nothrow) ManagerStub(
1955       unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
1956       unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
1957       receiver_group);
1958   if (stub == nullptr) {
1959     LOGE("Fail to create manager");
1960     return NOTI_EX_ERROR_IO_ERROR;
1961   }
1962   stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
1963       new ManagerCallbackInfo(event_callbacks, data)));
1964   *handle = static_cast<noti_ex_manager_h>(stub);
1965
1966   return NOTI_EX_ERROR_NONE;
1967 }
1968
1969 extern "C" EXPORT_API int noti_ex_manager_destroy(noti_ex_manager_h handle) {
1970   if (handle == nullptr) {
1971     LOGE("Invalid parameter");
1972     return NOTI_EX_ERROR_INVALID_PARAMETER;
1973   }
1974   ManagerStub* stub = static_cast<ManagerStub*>(handle);
1975   delete stub;
1976   return NOTI_EX_ERROR_NONE;
1977 }
1978
1979 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
1980     noti_ex_item_h **items, int *count) {
1981   if (handle == nullptr || items == nullptr || count == nullptr) {
1982     LOGE("Invalid parameter");
1983     return NOTI_EX_ERROR_INVALID_PARAMETER;
1984   }
1985
1986   try {
1987     ManagerStub* stub = static_cast<ManagerStub*>(handle);
1988     list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
1989     if (item_list.size() == 0) {
1990       *items = nullptr;
1991       *count = 0;
1992       return NOTI_EX_ERROR_NONE;
1993     }
1994     *items = (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
1995     if (*items == nullptr) {
1996       LOGE("Fail to create items");
1997       return NOTI_EX_ERROR_OUT_OF_MEMORY;
1998     }
1999
2000     int idx = 0;
2001     for (auto& i : item_list) {
2002       *items[idx++] = new Handle(move(i));
2003     }
2004     *count = item_list.size();
2005   } catch (Exception &ex) {
2006     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2007     return NOTI_EX_ERROR_IO_ERROR;
2008   }
2009   return NOTI_EX_ERROR_NONE;
2010 }
2011
2012 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
2013     noti_ex_item_h noti, int *request_id) {
2014   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2015     LOGE("Invalid parameter");
2016     return NOTI_EX_ERROR_INVALID_PARAMETER;
2017   }
2018   try {
2019     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2020     Handle* sp = static_cast<Handle*>(noti);
2021     if (sp->GetPtr().get() == nullptr) {
2022       LOGE("Invalid noti reference can not be sended");
2023       return NOTI_EX_ERROR_INVALID_PARAMETER;
2024     } else {
2025       *request_id = stub->Update(sp->GetPtr());
2026     }
2027   } catch (Exception &ex) {
2028     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2029     return NOTI_EX_ERROR_IO_ERROR;
2030   }
2031   return NOTI_EX_ERROR_NONE;
2032 }
2033
2034 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
2035     noti_ex_item_h noti, int *request_id) {
2036   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2037     LOGE("Invalid parameter");
2038     return NOTI_EX_ERROR_INVALID_PARAMETER;
2039   }
2040   try {
2041     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2042     Handle* item = static_cast<Handle*>(noti);
2043     if (item->GetPtr().get() == nullptr) {
2044       LOGE("Invalid noti reference can not be sended");
2045       return NOTI_EX_ERROR_INVALID_PARAMETER;
2046     } else {
2047       *request_id = stub->Delete(item->GetPtr());
2048     }
2049   } catch (Exception &ex) {
2050     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2051     return NOTI_EX_ERROR_IO_ERROR;
2052   }
2053   return NOTI_EX_ERROR_NONE;
2054 }
2055
2056 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
2057     int *request_id) {
2058   if (handle == nullptr || request_id == nullptr) {
2059     LOGE("Invalid parameter");
2060     return NOTI_EX_ERROR_INVALID_PARAMETER;
2061   }
2062   try {
2063     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2064     *request_id = stub->DeleteAll();
2065   } catch (Exception &ex) {
2066     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2067     return NOTI_EX_ERROR_IO_ERROR;
2068   }
2069   return NOTI_EX_ERROR_NONE;
2070 }
2071
2072 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
2073     noti_ex_item_h noti, int *request_id) {
2074   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2075     LOGE("Invalid parameter");
2076     return NOTI_EX_ERROR_INVALID_PARAMETER;
2077   }
2078   try {
2079     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2080     Handle* item = static_cast<Handle*>(noti);
2081     if (item->GetPtr().get() == nullptr) {
2082       LOGE("Invalid noti reference can not be sended");
2083       return NOTI_EX_ERROR_INVALID_PARAMETER;
2084     } else {
2085       *request_id = stub->Hide(item->GetPtr());
2086     }
2087   } catch (Exception &ex) {
2088     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2089     return NOTI_EX_ERROR_IO_ERROR;
2090   }
2091   return NOTI_EX_ERROR_NONE;
2092 }
2093
2094 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
2095     noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
2096   if (handle == nullptr || root_id == nullptr || item == nullptr) {
2097     LOGE("Invalid parameter");
2098     return NOTI_EX_ERROR_INVALID_PARAMETER;
2099   }
2100   try {
2101     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2102     *item = new Handle(stub->FindByRootID(root_id));
2103   } catch (Exception &ex) {
2104     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2105     return NOTI_EX_ERROR_IO_ERROR;
2106   }
2107   return NOTI_EX_ERROR_NONE;
2108 }
2109
2110 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
2111     noti_ex_event_info_h info, noti_ex_error_e error) {
2112   if (handle == nullptr || info == nullptr) {
2113     LOGE("Invalid parameter");
2114     return NOTI_EX_ERROR_INVALID_PARAMETER;
2115   }
2116   try {
2117     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2118     IEventInfo* c_info = static_cast<IEventInfo*>(info);
2119     stub->SendError(static_cast<const IEventInfo&>(*c_info),
2120         static_cast<NotificationError>(error));
2121   } catch (Exception &ex) {
2122     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2123     return NOTI_EX_ERROR_IO_ERROR;
2124   }
2125   return NOTI_EX_ERROR_NONE;
2126 }
2127
2128 extern "C" EXPORT_API int noti_ex_manager_get_count(noti_ex_manager_h handle,
2129     int *cnt) {
2130
2131   if (handle == nullptr || cnt == nullptr) {
2132     LOGE("Invalid parameter");
2133     return NOTI_EX_ERROR_INVALID_PARAMETER;
2134   }
2135   try {
2136     ManagerStub* stub = static_cast<ManagerStub*>(handle);
2137     *cnt = stub->GetCount();
2138   } catch (Exception &ex) {
2139     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2140     return NOTI_EX_ERROR_IO_ERROR;
2141   }
2142   return NOTI_EX_ERROR_NONE;
2143 }
2144
2145 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
2146     const char *id, float min, float current, float max) {
2147   ProgressItem* p;
2148
2149   if (handle == nullptr) {
2150     LOGE("Invalid parameter");
2151     return NOTI_EX_ERROR_INVALID_PARAMETER;
2152   }
2153
2154   if (id)
2155     p = new (std::nothrow) ProgressItem(id, min, current, max);
2156   else
2157     p = new (std::nothrow) ProgressItem(min, current, max);
2158
2159   if (p == nullptr) {
2160     LOGE("Out-of-memory");
2161     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2162   }
2163
2164   *handle = new Handle(p);
2165
2166   return NOTI_EX_ERROR_NONE;
2167 }
2168
2169 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
2170     noti_ex_item_h handle, float *current) {
2171   if (handle == nullptr || current == nullptr) {
2172     LOGE("Invalid parameter");
2173     return NOTI_EX_ERROR_INVALID_PARAMETER;
2174   }
2175
2176   Handle *h = static_cast<Handle*>(handle);
2177   if (!h->IsValidType(AbstractItem::Progress)) {
2178     LOGE("Invalid handle type");
2179     return NOTI_EX_ERROR_INVALID_PARAMETER;
2180   }
2181   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2182   *current = p->GetCurrent();
2183
2184   return NOTI_EX_ERROR_NONE;
2185 }
2186
2187 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
2188     noti_ex_item_h handle, float current) {
2189   if (handle == nullptr) {
2190     LOGE("Invalid parameter");
2191     return NOTI_EX_ERROR_INVALID_PARAMETER;
2192   }
2193
2194   Handle *h = static_cast<Handle*>(handle);
2195   if (!h->IsValidType(AbstractItem::Progress)) {
2196     LOGE("Invalid handle type");
2197     return NOTI_EX_ERROR_INVALID_PARAMETER;
2198   }
2199   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2200   p->SetCurrent(current);
2201
2202   return NOTI_EX_ERROR_NONE;
2203 }
2204
2205 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
2206     float *min) {
2207   if (handle == nullptr || min == nullptr) {
2208     LOGE("Invalid parameter");
2209     return NOTI_EX_ERROR_INVALID_PARAMETER;
2210   }
2211
2212   Handle *h = static_cast<Handle*>(handle);
2213   if (!h->IsValidType(AbstractItem::Progress)) {
2214     LOGE("Invalid handle type");
2215     return NOTI_EX_ERROR_INVALID_PARAMETER;
2216   }
2217   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2218   *min = p->GetMin();
2219
2220   return NOTI_EX_ERROR_NONE;
2221 }
2222
2223 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
2224     float *max) {
2225   if (handle == nullptr || max == nullptr) {
2226     LOGE("Invalid parameter");
2227     return NOTI_EX_ERROR_INVALID_PARAMETER;
2228   }
2229
2230   Handle *h = static_cast<Handle*>(handle);
2231   if (!h->IsValidType(AbstractItem::Progress)) {
2232     LOGE("Invalid handle type");
2233     return NOTI_EX_ERROR_INVALID_PARAMETER;
2234   }
2235   ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2236   *max = p->GetMax();
2237
2238   return NOTI_EX_ERROR_NONE;
2239 }
2240
2241 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
2242     noti_ex_reporter_events_s event_callbacks, void *data) {
2243   if (handle == nullptr) {
2244     LOGE("Invalid parameter");
2245     return NOTI_EX_ERROR_INVALID_PARAMETER;
2246   }
2247
2248   ReporterStub* stub = new (std::nothrow) ReporterStub(
2249       unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
2250       unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())));
2251   if (stub == nullptr) {
2252     LOGE("Fail to create manager");
2253     return NOTI_EX_ERROR_IO_ERROR;
2254   }
2255   stub->SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo>(
2256       new ReporterCallbackInfo(event_callbacks, data)));
2257
2258   *handle = static_cast<noti_ex_reporter_h>(stub);
2259
2260   return NOTI_EX_ERROR_NONE;
2261 }
2262
2263 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
2264   if (handle == nullptr) {
2265     LOGE("Invalid parameter");
2266     return NOTI_EX_ERROR_INVALID_PARAMETER;
2267   }
2268   ReporterStub* stub = static_cast<ReporterStub*>(handle);
2269   delete stub;
2270   return NOTI_EX_ERROR_NONE;
2271 }
2272
2273 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
2274     noti_ex_event_info_h info, noti_ex_error_e error) {
2275   if (handle == nullptr || info == nullptr) {
2276     LOGE("Invalid parameter");
2277     return NOTI_EX_ERROR_INVALID_PARAMETER;
2278   }
2279   try {
2280     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2281     IEventInfo* c_info = static_cast<IEventInfo*>(info);
2282     stub->SendError(static_cast<const IEventInfo&>(*c_info),
2283         static_cast<NotificationError>(error));
2284   } catch (Exception &ex) {
2285     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2286     return NOTI_EX_ERROR_IO_ERROR;
2287   }
2288   return NOTI_EX_ERROR_NONE;
2289 }
2290
2291 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
2292     noti_ex_item_h noti, int *request_id) {
2293   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2294     LOGE("Invalid parameter");
2295     return NOTI_EX_ERROR_INVALID_PARAMETER;
2296   }
2297   try {
2298     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2299     Handle* h = static_cast<Handle*>(noti);
2300     if (h->GetPtr().get() == nullptr) {
2301       LOGE("Invalid noti reference can not be sended");
2302       return NOTI_EX_ERROR_INVALID_PARAMETER;
2303     } else {
2304       *request_id = stub->Post(h->GetPtr());
2305     }
2306   } catch (Exception &ex) {
2307     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2308     return NOTI_EX_ERROR_IO_ERROR;
2309   }
2310   return NOTI_EX_ERROR_NONE;
2311 }
2312
2313 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
2314     noti_ex_item_h *noti_list, int count, int *request_id) {
2315
2316   if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
2317     LOGE("Invalid parameter");
2318     return NOTI_EX_ERROR_INVALID_PARAMETER;
2319   }
2320   try {
2321     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2322     list<shared_ptr<item::AbstractItem>> notiList;
2323     for (int i = 0; i < count; i++) {
2324       Handle* item = static_cast<Handle*>(noti_list[i]);
2325       notiList.emplace_back(item->GetPtr());
2326     }
2327     *request_id = stub->Post(notiList);
2328   } catch (Exception &ex) {
2329     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2330     return NOTI_EX_ERROR_IO_ERROR;
2331   }
2332   return NOTI_EX_ERROR_NONE;
2333 }
2334
2335 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
2336     noti_ex_item_h noti, int *request_id) {
2337   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2338     LOGE("Invalid parameter");
2339     return NOTI_EX_ERROR_INVALID_PARAMETER;
2340   }
2341   try {
2342     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2343     Handle* item = static_cast<Handle*>(noti);
2344     if (item->GetPtr().get() == nullptr) {
2345       LOGE("Invalid noti reference can not be sended");
2346       return NOTI_EX_ERROR_INVALID_PARAMETER;
2347     } else {
2348       *request_id = stub->Update(item->GetPtr());
2349     }
2350   } catch (Exception &ex) {
2351     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2352     return NOTI_EX_ERROR_IO_ERROR;
2353   }
2354   return NOTI_EX_ERROR_NONE;
2355 }
2356
2357 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
2358     noti_ex_item_h noti, int *request_id) {
2359   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2360     LOGE("Invalid parameter");
2361     return NOTI_EX_ERROR_INVALID_PARAMETER;
2362   }
2363   try {
2364     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2365     Handle* item = static_cast<Handle*>(noti);
2366     if (item->GetPtr().get() == nullptr) {
2367       LOGE("Invalid noti reference can not be sended");
2368       return NOTI_EX_ERROR_INVALID_PARAMETER;
2369     } else {
2370       *request_id = stub->Delete(item->GetPtr());
2371     }
2372   } catch (Exception &ex) {
2373     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2374     return NOTI_EX_ERROR_IO_ERROR;
2375   }
2376   return NOTI_EX_ERROR_NONE;
2377 }
2378
2379 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
2380     noti_ex_reporter_h handle, int *request_id) {
2381   if (handle == nullptr || request_id == nullptr) {
2382     LOGE("Invalid parameter");
2383     return NOTI_EX_ERROR_INVALID_PARAMETER;
2384   }
2385   try {
2386     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2387     *request_id = stub->DeleteAll();
2388   } catch (Exception &ex) {
2389     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2390     return NOTI_EX_ERROR_IO_ERROR;
2391   }
2392   return NOTI_EX_ERROR_NONE;
2393 }
2394
2395 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
2396     noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
2397   if (handle == nullptr || root_id == nullptr || item == nullptr) {
2398     LOGE("Invalid parameter");
2399     return NOTI_EX_ERROR_INVALID_PARAMETER;
2400   }
2401   try {
2402     ReporterStub* stub = static_cast<ReporterStub*>(handle);
2403     *item = new Handle(stub->FindByRootID(root_id));
2404   } catch (Exception &ex) {
2405     LOGE("%s %d", ex.what(), ex.GetErrorCode());
2406     return NOTI_EX_ERROR_IO_ERROR;
2407   }
2408   return NOTI_EX_ERROR_NONE;
2409 }
2410
2411 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
2412     const char *id, const char *text, const char *hyper_link) {
2413   if (handle == nullptr) {
2414     LOGE("Invalid parameter");
2415     return NOTI_EX_ERROR_INVALID_PARAMETER;
2416   }
2417
2418   auto* p = new (std::nothrow) TextItem(id, std::string(text),
2419                 std::string(hyper_link));
2420   if (p == nullptr) {
2421     LOGE("Out-of-memory");
2422     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2423   }
2424
2425   *handle = new Handle(p);
2426
2427   return NOTI_EX_ERROR_NONE;
2428 }
2429
2430 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
2431     const char *contents) {
2432   if (handle == nullptr) {
2433     LOGE("Invalid parameter");
2434     return NOTI_EX_ERROR_INVALID_PARAMETER;
2435   }
2436
2437   Handle* p = static_cast<Handle*>(handle);
2438   if (!p->IsValidType(AbstractItem::Text)) {
2439     LOGE("Invalid handle type");
2440     return NOTI_EX_ERROR_INVALID_PARAMETER;
2441   }
2442   TextItem* ti = static_cast<TextItem*>(p->Get());
2443   ti->SetContents(std::string(contents));
2444
2445   return NOTI_EX_ERROR_NONE;
2446 }
2447
2448 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
2449     char **contents) {
2450   if (handle == nullptr || contents == nullptr) {
2451     LOGE("Invalid parameter");
2452     return NOTI_EX_ERROR_INVALID_PARAMETER;
2453   }
2454
2455   Handle* p = static_cast<Handle*>(handle);
2456   if (!p->IsValidType(AbstractItem::Text)) {
2457     LOGE("Invalid handle type");
2458     return NOTI_EX_ERROR_INVALID_PARAMETER;
2459   }
2460   TextItem* ti = static_cast<TextItem*>(p->Get());
2461   if (!ti->GetContents().empty()) {
2462     *contents = strdup(ti->GetContents().c_str());
2463     if (*contents == nullptr) {
2464       LOGE("Out-of-memory");
2465       return NOTI_EX_ERROR_OUT_OF_MEMORY;
2466     }
2467   }
2468
2469   return NOTI_EX_ERROR_NONE;
2470 }
2471
2472 extern "C" EXPORT_API int noti_ex_item_text_get_hyperlink(
2473     noti_ex_item_h handle, char **hyper_link) {
2474   if (handle == nullptr || hyper_link == nullptr) {
2475     LOGE("Invalid parameter");
2476     return NOTI_EX_ERROR_INVALID_PARAMETER;
2477   }
2478
2479   Handle* p = static_cast<Handle*>(handle);
2480   if (!p->IsValidType(AbstractItem::Text)) {
2481     LOGE("Invalid handle type");
2482     return NOTI_EX_ERROR_INVALID_PARAMETER;
2483   }
2484   TextItem* ti = static_cast<TextItem*>(p->Get());
2485   if (!ti->GetHyperLink().empty()) {
2486     *hyper_link = strdup(ti->GetHyperLink().c_str());
2487     if (*hyper_link == nullptr) {
2488       LOGE("Out-of-memory");
2489       return NOTI_EX_ERROR_OUT_OF_MEMORY;
2490     }
2491   }
2492
2493   return NOTI_EX_ERROR_NONE;
2494 }
2495
2496 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
2497     const char *id, time_t time) {
2498   TimeItem* p;
2499
2500   if (handle == nullptr) {
2501     LOGE("Invalid parameter");
2502     return NOTI_EX_ERROR_INVALID_PARAMETER;
2503   }
2504
2505   if (time) {
2506     if (id)
2507       p = new (std::nothrow) TimeItem(id, time);
2508     else
2509       p = new (std::nothrow) TimeItem(time);
2510   } else {
2511       p = new (std::nothrow) TimeItem();
2512   }
2513
2514   if (p == nullptr) {
2515     LOGE("Out-of-memory");
2516     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2517   }
2518
2519   *handle = new Handle(p);
2520
2521   return NOTI_EX_ERROR_NONE;
2522 }
2523
2524 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
2525     time_t *time) {
2526   if (handle == nullptr || time == nullptr) {
2527     LOGE("Invalid parameter");
2528     return NOTI_EX_ERROR_INVALID_PARAMETER;
2529   }
2530   Handle* h = static_cast<Handle*>(handle);
2531   if (!h->IsValidType(AbstractItem::Time)) {
2532     LOGE("Invalid handle type");
2533     return NOTI_EX_ERROR_INVALID_PARAMETER;
2534   }
2535   TimeItem* p = static_cast<TimeItem*>(h->Get());
2536   *time = p->GetTime();
2537
2538   return NOTI_EX_ERROR_NONE;
2539 }
2540
2541 extern "C" EXPORT_API int noti_ex_action_visibility_create(
2542     noti_ex_action_h *handle, const char *extra) {
2543   if (handle == nullptr) {
2544     LOGE("Invalid parameter");
2545     return NOTI_EX_ERROR_INVALID_PARAMETER;
2546   }
2547
2548   auto* p = new (std::nothrow) VisibilityAction(extra);
2549   if (p == nullptr) {
2550     LOGE("Out-of-memory");
2551     return NOTI_EX_ERROR_OUT_OF_MEMORY;
2552   }
2553
2554   *handle = p;
2555
2556   return NOTI_EX_ERROR_NONE;
2557 }
2558
2559 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
2560     const char *id, bool visible) {
2561   if (handle == nullptr || id == nullptr) {
2562     LOGE("Invalid parameter");
2563     return NOTI_EX_ERROR_INVALID_PARAMETER;
2564   }
2565
2566   VisibilityAction* p = static_cast<VisibilityAction*>(handle);
2567   p->SetVisibility(id, visible);
2568
2569   return NOTI_EX_ERROR_NONE;
2570 }