2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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"
49 #define LOG_TAG "NOTIFICATION_EX"
54 #define EXPORT_API __attribute__((visibility("default")))
57 using namespace tizen_base;
58 using namespace notification::item;
59 using namespace notification;
65 explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
66 explicit Handle(std::shared_ptr<item::AbstractItem> ptr)
67 : ref_(nullptr), ptr_(move(ptr)) { }
68 virtual ~Handle() = default;
69 item::AbstractItem* Get() const {
75 bool IsValidType(int type) const {
76 return (Get()->GetType() == type
77 || Get()->GetType() >= AbstractItem::Custom);
80 std::shared_ptr<item::AbstractItem> GetPtr() const {
82 return std::shared_ptr<item::AbstractItem>({});
87 item::AbstractItem* ref_;
88 std::shared_ptr<item::AbstractItem> ptr_;
91 class ManagerCallbackInfo {
93 ManagerCallbackInfo(noti_ex_manager_events_s cb, void* user_data)
94 : user_data_(user_data) {
96 cb_.updated = cb.updated;
97 cb_.deleted = cb.deleted;
101 void InvokeAdded(Manager* manager, const IEventInfo& info,
102 list<shared_ptr<AbstractItem>> addedItem) {
103 if (cb_.added == nullptr)
105 noti_ex_item_h* added_item =
106 (noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
107 if (added_item == nullptr) {
108 LOGE("Out of memory");
113 for (auto& i : addedItem) {
115 static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i)));
118 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
119 cb_.added(static_cast<noti_ex_manager_h>(manager),
120 static_cast<noti_ex_event_info_h>(c_info), added_item,
121 addedItem.size(), user_data_);
124 void InvokeUpdated(Manager* manager, const IEventInfo& info,
125 shared_ptr<item::AbstractItem> updatedItem) {
126 if (cb_.updated == nullptr)
128 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
129 cb_.updated(static_cast<noti_ex_manager_h>(manager),
130 static_cast<noti_ex_event_info_h>(c_info),
131 static_cast<noti_ex_item_h>(new Handle(updatedItem)), user_data_);
134 void InvokeDeleted(Manager* manager, const IEventInfo& info,
135 shared_ptr<item::AbstractItem> deletedItem) {
136 if (cb_.deleted == nullptr)
138 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
139 if (c_info->GetEventType() == static_cast<int>(IEventInfo::EventType::DeleteAll)) {
140 cb_.deleted(static_cast<noti_ex_manager_h>(manager),
141 static_cast<noti_ex_event_info_h>(c_info),
142 nullptr, user_data_);
144 cb_.deleted(static_cast<noti_ex_manager_h>(manager),
145 static_cast<noti_ex_event_info_h>(c_info),
146 static_cast<noti_ex_item_h>(
147 new Handle(deletedItem)), user_data_);
151 void InvokeError(Manager* manager, NotificationError error, int requestId) {
152 if (cb_.error == nullptr)
154 cb_.error(static_cast<noti_ex_manager_h>(manager),
155 static_cast<noti_ex_error_e>(error), requestId, user_data_);
159 noti_ex_manager_events_s cb_;
163 class ManagerStub : public Manager {
165 ManagerStub(std::unique_ptr<IEventSender> sender,
166 std::unique_ptr<IEventListener> listener, std::string receiver_group = "")
167 : Manager(move(sender), move(listener), receiver_group) {
170 void OnAdd(const IEventInfo& info,
171 list<shared_ptr<AbstractItem>> addedItem) override {
172 cb_->InvokeAdded(this, info, addedItem);
175 void OnUpdate(const IEventInfo& info,
176 std::shared_ptr<item::AbstractItem> updatedItem) override {
177 cb_->InvokeUpdated(this, info, updatedItem);
180 void OnDelete(const IEventInfo& info,
181 shared_ptr<item::AbstractItem> deletedItem) override {
182 cb_->InvokeDeleted(this, info, deletedItem);
185 void OnError(NotificationError error, int requestId) override {
186 cb_->InvokeError(this, error, requestId);
189 int SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo> ci) {
191 return NOTI_EX_ERROR_NONE;
194 int ClearManagerCallbackInfo() {
196 return NOTI_EX_ERROR_NONE;
200 unique_ptr<ManagerCallbackInfo> cb_;
204 class ReporterCallbackInfo {
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;
212 void InvokeEvent(Reporter* reporter, const IEventInfo& info,
213 list<shared_ptr<AbstractItem>> notiList) {
214 if (cb_.event == nullptr)
216 noti_ex_item_h* noti_list =
217 (noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
218 if (noti_list == nullptr) {
219 LOGE("Out of memory");
224 for (auto& i : notiList) {
226 static_cast<noti_ex_item_h>(new Handle(i));
229 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
230 cb_.event(static_cast<noti_ex_reporter_h>(reporter),
231 static_cast<noti_ex_event_info_h>(c_info), noti_list,
232 notiList.size(), user_data_);
236 void InvokeError(Reporter* reporter, NotificationError error, int requestId) {
237 if (cb_.error == nullptr)
239 cb_.error(static_cast<noti_ex_reporter_h>(reporter),
240 static_cast<noti_ex_error_e>(error), requestId, user_data_);
244 noti_ex_reporter_events_s cb_;
248 class ReporterStub : public Reporter {
250 ReporterStub(std::unique_ptr<IEventSender> sender,
251 std::unique_ptr<IEventListener> listener)
252 : Reporter(move(sender), move(listener)) {
255 void OnEvent(const IEventInfo& info,
256 std::list<std::shared_ptr<item::AbstractItem>> notiList) override {
257 cb_->InvokeEvent(this, info, notiList);
260 void OnError(NotificationError error, int requestId) override {
261 cb_->InvokeError(this, error, requestId);
264 int SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo> ci) {
266 return NOTI_EX_ERROR_NONE;
269 int ClearReporterCallbackInfo() {
271 return NOTI_EX_ERROR_NONE;
275 unique_ptr<ReporterCallbackInfo> cb_;
280 void __noti_ex_free_str_array(char** val, int length) {
282 for (i = 0; i < length ; i++)
287 extern "C" EXPORT_API int noti_ex_action_app_control_create(
288 noti_ex_action_h *handle, app_control_h app_control,
290 if (handle == nullptr || app_control == nullptr) {
291 LOGE("Invalid parameter");
292 return NOTI_EX_ERROR_INVALID_PARAMETER;
295 shared_ptr<AbstractAction>* p;
298 p = new (std::nothrow) shared_ptr<AbstractAction>(
299 new (std::nothrow) AppControlAction(app_control, extra));
301 p = new (std::nothrow) shared_ptr<AbstractAction>(
302 new (std::nothrow) AppControlAction(app_control));
306 LOGE("Out-of-memory");
307 return NOTI_EX_ERROR_OUT_OF_MEMORY;
312 return NOTI_EX_ERROR_NONE;
315 extern "C" EXPORT_API int noti_ex_action_app_control_set(
316 noti_ex_action_h handle, app_control_h app_control) {
317 if (handle == nullptr || app_control == nullptr) {
318 LOGE("Invalid parameter");
319 return NOTI_EX_ERROR_INVALID_PARAMETER;
322 shared_ptr<AbstractAction>* ptr =
323 static_cast<shared_ptr<AbstractAction>*>(handle);
324 AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
325 action->SetAppControl(app_control);
327 return NOTI_EX_ERROR_NONE;
330 extern "C" EXPORT_API int noti_ex_action_app_control_get(
331 noti_ex_action_h handle, app_control_h *app_control) {
332 if (handle == nullptr || app_control == nullptr) {
333 LOGE("Invalid parameter");
334 return NOTI_EX_ERROR_INVALID_PARAMETER;
337 shared_ptr<AbstractAction>* ptr =
338 static_cast<shared_ptr<AbstractAction>*>(handle);
339 AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
342 int r = app_control_clone(&clone, action->GetAppControl());
343 if (r != APP_CONTROL_ERROR_NONE) {
344 LOGE("failed to create a app_control handle : %d", r);
345 return NOTI_EX_ERROR_INVALID_PARAMETER;
348 *app_control = clone;
350 return NOTI_EX_ERROR_NONE;
353 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
354 const char *id, const char *title) {
357 if (handle == nullptr || title == nullptr) {
358 LOGE("Invalid parameter");
359 return NOTI_EX_ERROR_INVALID_PARAMETER;
363 p = new (std::nothrow) ButtonItem(id, title);
365 p = new (std::nothrow) ButtonItem(title);
368 LOGE("Out-of-memory");
369 return NOTI_EX_ERROR_OUT_OF_MEMORY;
371 *handle = new Handle(shared_ptr<AbstractItem>(p));
373 return NOTI_EX_ERROR_NONE;
376 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
378 if (handle == nullptr || title == nullptr) {
379 LOGE("Invalid parameter");
380 return NOTI_EX_ERROR_INVALID_PARAMETER;
383 Handle* sp = static_cast<Handle*>(handle);
384 if (!sp->IsValidType(AbstractItem::Button)) {
385 LOGE("Invalid handle type");
386 return NOTI_EX_ERROR_INVALID_PARAMETER;
389 ButtonItem* p = static_cast<ButtonItem*>(sp->Get());
391 if (p->GetMultiLanguage() != nullptr &&
392 !p->GetMultiLanguage()->GetTranslatedString().empty())
393 str = p->GetMultiLanguage()->GetTranslatedString();
394 else if (!p->GetTitle().empty())
397 *title = strdup(str.c_str());
398 if (*title == nullptr) {
399 LOGE("Out-of-memory");
400 return NOTI_EX_ERROR_OUT_OF_MEMORY;
403 return NOTI_EX_ERROR_NONE;
406 extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title(
407 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
408 if (handle == nullptr) {
409 LOGE("Invalid parameter");
410 return NOTI_EX_ERROR_INVALID_PARAMETER;
413 Handle* p = static_cast<Handle*>(handle);
414 if (!p->IsValidType(AbstractItem::Button)) {
415 LOGE("Invalid handle type");
416 return NOTI_EX_ERROR_INVALID_PARAMETER;
419 ButtonItem* bi = static_cast<ButtonItem*>(p->Get());
420 if (multi == nullptr) {
421 bi->SetMultiLanguage(nullptr);
422 return NOTI_EX_ERROR_NONE;
425 shared_ptr<MultiLanguage> mul_ptr =
426 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
428 mul_ptr->UpdateString();
429 bi->SetMultiLanguage(mul_ptr);
431 return NOTI_EX_ERROR_NONE;
434 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
435 noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
436 noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
437 noti_ex_item_chat_message_type_e message_type) {
438 if (handle == nullptr || (text == nullptr && image == nullptr)
439 || name == nullptr || time == nullptr
440 || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
441 LOGE("Invalid parameter");
442 return NOTI_EX_ERROR_INVALID_PARAMETER;
445 auto* p = new (std::nothrow) ChatMessageItem(id,
446 dynamic_pointer_cast<TextItem>(static_cast<Handle*>(name)->GetPtr()),
447 text == nullptr ? nullptr
448 : dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
449 image == nullptr ? nullptr
450 : dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
451 dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
452 static_cast<ChatMessageItem::Type>(message_type));
454 LOGE("Out-of-memory");
455 return NOTI_EX_ERROR_OUT_OF_MEMORY;
458 *handle = new Handle(shared_ptr<AbstractItem>(p));
460 return NOTI_EX_ERROR_NONE;
463 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
464 noti_ex_item_h handle, noti_ex_item_h *name) {
465 if (handle == nullptr || name == nullptr) {
466 LOGE("Invalid parameter");
467 return NOTI_EX_ERROR_INVALID_PARAMETER;
469 Handle* h = static_cast<Handle*>(handle);
470 if (!h->IsValidType(AbstractItem::ChatMessage)) {
471 LOGE("Invalid handle type");
472 return NOTI_EX_ERROR_INVALID_PARAMETER;
474 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
475 if (p->GetNameItem().GetType() == AbstractItem::NullObject)
478 *name = new Handle(&(p->GetNameItem()));
480 return NOTI_EX_ERROR_NONE;
483 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
484 noti_ex_item_h handle, noti_ex_item_h *text) {
485 if (handle == nullptr || text == nullptr) {
486 LOGE("Invalid parameter");
487 return NOTI_EX_ERROR_INVALID_PARAMETER;
490 Handle* h = static_cast<Handle*>(handle);
491 if (!h->IsValidType(AbstractItem::ChatMessage)) {
492 LOGE("Invalid handle type");
493 return NOTI_EX_ERROR_INVALID_PARAMETER;
495 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
496 if (p->GetTextItem().GetType() == AbstractItem::NullObject)
499 *text = new Handle(&(p->GetTextItem()));
501 return NOTI_EX_ERROR_NONE;
504 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
505 noti_ex_item_h handle, noti_ex_item_h *image) {
506 if (handle == nullptr || image == nullptr) {
507 LOGE("Invalid parameter");
508 return NOTI_EX_ERROR_INVALID_PARAMETER;
511 Handle* h = static_cast<Handle*>(handle);
512 if (!h->IsValidType(AbstractItem::ChatMessage)) {
513 LOGE("Invalid handle type");
514 return NOTI_EX_ERROR_INVALID_PARAMETER;
516 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
517 if (p->GetImageItem().GetType() == AbstractItem::NullObject)
520 *image = new Handle(&(p->GetImageItem()));
522 return NOTI_EX_ERROR_NONE;
525 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
526 noti_ex_item_h handle, noti_ex_item_h *time) {
527 if (handle == nullptr || time == nullptr) {
528 LOGE("Invalid parameter");
529 return NOTI_EX_ERROR_INVALID_PARAMETER;
532 Handle* h = static_cast<Handle*>(handle);
533 if (!h->IsValidType(AbstractItem::ChatMessage)) {
534 LOGE("Invalid handle type");
535 return NOTI_EX_ERROR_INVALID_PARAMETER;
537 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
538 if (p->GetTimeItem().GetType() == AbstractItem::NullObject)
541 *time = new Handle(&(p->GetTimeItem()));
543 return NOTI_EX_ERROR_NONE;
546 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
547 noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
548 if (handle == nullptr || message_type == nullptr) {
549 LOGE("Invalid parameter");
550 return NOTI_EX_ERROR_INVALID_PARAMETER;
553 Handle* h = static_cast<Handle*>(handle);
554 if (!h->IsValidType(AbstractItem::ChatMessage)) {
555 LOGE("Invalid handle type");
556 return NOTI_EX_ERROR_INVALID_PARAMETER;
558 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
559 *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
561 return NOTI_EX_ERROR_NONE;
564 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
565 const char *id, const char *title, bool checked) {
568 if (handle == nullptr || title == nullptr) {
569 LOGE("Invalid parameter");
570 return NOTI_EX_ERROR_INVALID_PARAMETER;
573 p = new (std::nothrow) CheckBoxItem(id, title, checked);
575 LOGE("Out-of-memory");
576 return NOTI_EX_ERROR_OUT_OF_MEMORY;
579 *handle = new Handle(shared_ptr<AbstractItem>(p));
581 return NOTI_EX_ERROR_NONE;
584 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
586 if (handle == nullptr || title == nullptr) {
587 LOGE("Invalid parameter");
588 return NOTI_EX_ERROR_INVALID_PARAMETER;
590 Handle* h = static_cast<Handle*>(handle);
591 if (!h->IsValidType(AbstractItem::CheckBox)) {
592 LOGE("Invalid handle type");
593 return NOTI_EX_ERROR_INVALID_PARAMETER;
596 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
598 if (p->GetMultiLanguage() != nullptr &&
599 !p->GetMultiLanguage()->GetTranslatedString().empty())
600 str = p->GetMultiLanguage()->GetTranslatedString();
601 else if (!p->GetTitle().empty())
604 *title = strdup(str.c_str());
605 if (*title == nullptr) {
606 LOGE("Out-of-memory");
607 return NOTI_EX_ERROR_OUT_OF_MEMORY;
610 return NOTI_EX_ERROR_NONE;
613 extern "C" EXPORT_API int noti_ex_item_checkbox_set_multi_language_title(
614 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
615 if (handle == nullptr) {
616 LOGE("Invalid parameter");
617 return NOTI_EX_ERROR_INVALID_PARAMETER;
620 Handle* p = static_cast<Handle*>(handle);
621 if (!p->IsValidType(AbstractItem::CheckBox)) {
622 LOGE("Invalid handle type");
623 return NOTI_EX_ERROR_INVALID_PARAMETER;
626 CheckBoxItem* ci = static_cast<CheckBoxItem*>(p->Get());
627 if (multi == nullptr) {
628 ci->SetMultiLanguage(nullptr);
629 return NOTI_EX_ERROR_NONE;
632 shared_ptr<MultiLanguage> mul_ptr =
633 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
634 mul_ptr->UpdateString();
635 ci->SetMultiLanguage(mul_ptr);
637 return NOTI_EX_ERROR_NONE;
640 extern "C" EXPORT_API int noti_ex_item_checkbox_get_check_state(
641 noti_ex_item_h handle, bool *checked) {
642 if (handle == nullptr || checked == nullptr) {
643 LOGE("Invalid parameter");
644 return NOTI_EX_ERROR_INVALID_PARAMETER;
646 Handle* h = static_cast<Handle*>(handle);
647 if (!h->IsValidType(AbstractItem::CheckBox)) {
648 LOGE("Invalid handle type");
649 return NOTI_EX_ERROR_INVALID_PARAMETER;
651 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
652 *checked = p->IsChecked();
654 return NOTI_EX_ERROR_NONE;
657 extern "C" EXPORT_API int noti_ex_item_checkbox_set_check_state(
658 noti_ex_item_h handle, bool checked) {
659 if (handle == nullptr) {
660 LOGE("Invalid parameter");
661 return NOTI_EX_ERROR_INVALID_PARAMETER;
664 Handle* h = static_cast<Handle*>(handle);
665 if (!h->IsValidType(AbstractItem::CheckBox)) {
666 LOGE("Invalid handle type");
667 return NOTI_EX_ERROR_INVALID_PARAMETER;
670 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
671 p->SetChecked(checked);
673 return NOTI_EX_ERROR_NONE;
676 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
680 if (handle == nullptr) {
681 LOGE("Invalid parameter");
682 return NOTI_EX_ERROR_INVALID_PARAMETER;
685 p = new (std::nothrow) EntryItem(id);
687 LOGE("Out-of-memory");
688 return NOTI_EX_ERROR_OUT_OF_MEMORY;
691 *handle = new Handle(shared_ptr<AbstractItem>(p));
693 return NOTI_EX_ERROR_NONE;
696 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
698 if (handle == nullptr || text == nullptr) {
699 LOGE("Invalid parameter");
700 return NOTI_EX_ERROR_INVALID_PARAMETER;
703 Handle* h = static_cast<Handle*>(handle);
704 if (!h->IsValidType(AbstractItem::Entry)) {
705 LOGE("Invalid handle type");
706 return NOTI_EX_ERROR_INVALID_PARAMETER;
709 EntryItem* p = static_cast<EntryItem*>(h->Get());
711 if (p->GetMultiLanguage() != nullptr &&
712 !p->GetMultiLanguage()->GetTranslatedString().empty())
713 str = p->GetMultiLanguage()->GetTranslatedString();
714 else if (!p->GetText().empty())
717 *text = strdup(str.c_str());
718 if (*text == nullptr) {
719 LOGE("Out-of-memory");
720 return NOTI_EX_ERROR_OUT_OF_MEMORY;
723 return NOTI_EX_ERROR_NONE;
726 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
728 if (handle == nullptr || text == nullptr) {
729 LOGE("Invalid parameter");
730 return NOTI_EX_ERROR_INVALID_PARAMETER;
732 Handle* h = static_cast<Handle*>(handle);
733 if (!h->IsValidType(AbstractItem::Entry)) {
734 LOGE("Invalid handle type");
735 return NOTI_EX_ERROR_INVALID_PARAMETER;
737 EntryItem* p = static_cast<EntryItem*>(h->Get());
738 p->SetText(std::string(text));
740 return NOTI_EX_ERROR_NONE;
743 extern "C" EXPORT_API int noti_ex_item_entry_set_multi_language(
744 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
745 if (handle == nullptr) {
746 LOGE("Invalid parameter");
747 return NOTI_EX_ERROR_INVALID_PARAMETER;
750 Handle* p = static_cast<Handle*>(handle);
751 if (!p->IsValidType(AbstractItem::Entry)) {
752 LOGE("Invalid handle type");
753 return NOTI_EX_ERROR_INVALID_PARAMETER;
756 EntryItem* ei = static_cast<EntryItem*>(p->Get());
757 if (multi == nullptr) {
758 ei->SetMultiLanguage(nullptr);
759 return NOTI_EX_ERROR_NONE;
762 shared_ptr<MultiLanguage> mul_ptr =
763 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
764 ei->SetMultiLanguage(mul_ptr);
765 ei->GetMultiLanguage()->UpdateString();
767 return NOTI_EX_ERROR_NONE;
770 extern "C" EXPORT_API int noti_ex_event_info_clone(noti_ex_event_info_h handle,
771 noti_ex_event_info_h* cloned_handle) {
772 if (handle == nullptr || cloned_handle == nullptr) {
773 LOGE("Invalid parameter");
774 return NOTI_EX_ERROR_INVALID_PARAMETER;
777 Bundle cloned = static_cast<EventInfo*>(handle)->Serialize();
778 EventInfo* info = new EventInfo(cloned);
779 *cloned_handle = info;
780 return NOTI_EX_ERROR_NONE;
783 extern "C" EXPORT_API int noti_ex_event_info_destroy(
784 noti_ex_event_info_h handle) {
785 if (handle == nullptr) {
786 LOGE("Invalid parameter");
787 return NOTI_EX_ERROR_INVALID_PARAMETER;
789 EventInfo* info = static_cast<EventInfo*>(handle);
791 return NOTI_EX_ERROR_NONE;
794 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
795 noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
796 if (handle == nullptr || event_type == nullptr) {
797 LOGE("Invalid parameter");
798 return NOTI_EX_ERROR_INVALID_PARAMETER;
800 EventInfo* info = static_cast<EventInfo*>(handle);
801 *event_type = static_cast<noti_ex_event_info_type_e>(info->GetEventType());
803 return NOTI_EX_ERROR_NONE;
806 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
807 noti_ex_event_info_h handle, char **owner) {
808 if (handle == nullptr || owner == nullptr) {
809 LOGE("Invalid parameter");
810 return NOTI_EX_ERROR_INVALID_PARAMETER;
812 EventInfo* info = static_cast<EventInfo*>(handle);
813 *owner = strdup(info->GetOwner().c_str());
814 return NOTI_EX_ERROR_NONE;
817 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
818 noti_ex_event_info_h handle, char **channel) {
819 if (handle == nullptr || channel == nullptr) {
820 LOGE("Invalid parameter");
821 return NOTI_EX_ERROR_INVALID_PARAMETER;
823 EventInfo* info = static_cast<EventInfo*>(handle);
824 *channel = strdup(info->GetChannel().c_str());
825 return NOTI_EX_ERROR_NONE;
828 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
829 noti_ex_event_info_h handle, char **item_id) {
830 if (handle == nullptr || item_id == nullptr) {
831 LOGE("Invalid parameter");
832 return NOTI_EX_ERROR_INVALID_PARAMETER;
834 EventInfo* info = static_cast<EventInfo*>(handle);
835 *item_id = strdup(info->GetItemId().c_str());
836 return NOTI_EX_ERROR_NONE;
839 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
840 noti_ex_event_info_h handle, int *req_id) {
841 if (handle == nullptr || req_id == nullptr) {
842 LOGE("Invalid parameter");
843 return NOTI_EX_ERROR_INVALID_PARAMETER;
845 EventInfo* info = static_cast<EventInfo*>(handle);
846 *req_id = info->GetRequestId();
847 return NOTI_EX_ERROR_NONE;
850 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
854 if (handle == nullptr) {
855 LOGE("Invalid parameter");
856 return NOTI_EX_ERROR_INVALID_PARAMETER;
860 p = new (std::nothrow) GroupItem(id);
862 p = new (std::nothrow) GroupItem();
865 LOGE("Out-of-memory");
866 return NOTI_EX_ERROR_OUT_OF_MEMORY;
869 *handle = new Handle(shared_ptr<AbstractItem>(p));
871 return NOTI_EX_ERROR_NONE;
874 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
876 if (handle == nullptr) {
877 LOGE("Invalid parameter");
878 return NOTI_EX_ERROR_INVALID_PARAMETER;
880 Handle* h = static_cast<Handle*>(handle);
881 if (!h->IsValidType(AbstractItem::Group)) {
882 LOGE("Invalid handle type");
883 return NOTI_EX_ERROR_INVALID_PARAMETER;
885 GroupItem* p = static_cast<GroupItem*>(h->Get());
886 p->SetDirection(vertical);
888 return NOTI_EX_ERROR_NONE;
891 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
893 if (handle == nullptr) {
894 LOGE("Invalid parameter");
895 return NOTI_EX_ERROR_INVALID_PARAMETER;
897 Handle* h = static_cast<Handle*>(handle);
898 if (!h->IsValidType(AbstractItem::Group)) {
899 LOGE("Invalid handle type");
900 return NOTI_EX_ERROR_INVALID_PARAMETER;
902 GroupItem* p = static_cast<GroupItem*>(h->Get());
903 *vertical = p->IsVertical();
905 return NOTI_EX_ERROR_NONE;
908 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
910 if (handle == nullptr) {
911 LOGE("Invalid parameter");
912 return NOTI_EX_ERROR_INVALID_PARAMETER;
914 Handle* h = static_cast<Handle*>(handle);
915 if (!h->IsValidType(AbstractItem::Group)) {
916 LOGE("Invalid handle type");
917 return NOTI_EX_ERROR_INVALID_PARAMETER;
919 GroupItem* p = static_cast<GroupItem*>(h->Get());
920 if (!p->GetAppLabel().empty()) {
921 *label = strdup(p->GetAppLabel().c_str());
922 if (*label == nullptr) {
923 LOGE("Out-of-memory");
924 return NOTI_EX_ERROR_OUT_OF_MEMORY;
928 return NOTI_EX_ERROR_NONE;
931 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
932 noti_ex_item_h child) {
933 if (handle == nullptr || child == nullptr) {
934 LOGE("Invalid parameter");
935 return NOTI_EX_ERROR_INVALID_PARAMETER;
937 Handle* h = static_cast<Handle*>(handle);
938 if (!h->IsValidType(AbstractItem::Group)) {
939 LOGE("Invalid handle type");
940 return NOTI_EX_ERROR_INVALID_PARAMETER;
942 auto p = static_cast<GroupItem*>(h->Get());
943 p->AddChild((static_cast<Handle*>(child))->GetPtr());
945 return NOTI_EX_ERROR_NONE;
948 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
949 const char *item_id) {
950 if (handle == nullptr || item_id == nullptr) {
951 LOGE("Invalid parameter");
952 return NOTI_EX_ERROR_INVALID_PARAMETER;
954 Handle* h = static_cast<Handle*>(handle);
955 if (!h->IsValidType(AbstractItem::Group)) {
956 LOGE("Invalid handle type");
957 return NOTI_EX_ERROR_INVALID_PARAMETER;
959 GroupItem* p = static_cast<GroupItem*>(h->Get());
960 p->RemoveChild(std::string(item_id));
962 return NOTI_EX_ERROR_NONE;
965 extern "C" EXPORT_API int noti_ex_item_group_foreach_child(noti_ex_item_h handle,
966 noti_ex_item_group_foreach_child_cb callback, void *data) {
967 if (handle == nullptr || callback == nullptr) {
968 LOGE("Invalid parameter");
969 return NOTI_EX_ERROR_INVALID_PARAMETER;
972 Handle* h = static_cast<Handle*>(handle);
973 if (!h->IsValidType(AbstractItem::Group)) {
974 LOGE("Invalid handle type");
975 return NOTI_EX_ERROR_INVALID_PARAMETER;
977 GroupItem* p = static_cast<GroupItem*>(h->Get());
978 list<shared_ptr<AbstractItem>> children = p->GetChildren();
979 LOGI("Retrive (%zd)", children.size());
980 for (auto i : children) {
982 static_cast<noti_ex_item_h>(new Handle(i)), data);
983 if (ret != NOTI_EX_ERROR_NONE) {
984 LOGW("callback return (%d) stop foreach", ret);
989 return NOTI_EX_ERROR_NONE;
992 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
993 const char *id, const char *image_path) {
996 if (handle == nullptr || image_path == nullptr) {
997 LOGE("Invalid parameter");
998 return NOTI_EX_ERROR_INVALID_PARAMETER;
1002 p = new (std::nothrow) ImageItem(id, image_path);
1004 p = new (std::nothrow) ImageItem(image_path);
1007 LOGE("Out-of-memory");
1008 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1011 *handle = new Handle(shared_ptr<AbstractItem>(p));
1013 return NOTI_EX_ERROR_NONE;
1016 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
1017 noti_ex_item_h handle, char **image_path) {
1018 if (handle == nullptr || image_path == nullptr) {
1019 LOGE("Invalid parameter");
1020 return NOTI_EX_ERROR_INVALID_PARAMETER;
1022 Handle* h = static_cast<Handle*>(handle);
1023 if (!h->IsValidType(AbstractItem::Image)) {
1024 LOGE("Invalid handle type");
1025 return NOTI_EX_ERROR_INVALID_PARAMETER;
1027 ImageItem* p = static_cast<ImageItem*>(h->Get());
1028 if (!p->GetImagePath().empty()) {
1029 *image_path = strdup(p->GetImagePath().c_str());
1030 if (*image_path == nullptr) {
1031 LOGE("Out-of-memory");
1032 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1035 *image_path = nullptr;
1038 return NOTI_EX_ERROR_NONE;
1041 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
1042 noti_ex_item_h *handle, const char *id) {
1043 InputSelectorItem* p;
1045 if (handle == nullptr) {
1046 LOGE("Invalid parameter");
1047 return NOTI_EX_ERROR_INVALID_PARAMETER;
1051 p = new (std::nothrow) InputSelectorItem(id);
1053 p = new (std::nothrow) InputSelectorItem();
1056 LOGE("Out-of-memory");
1057 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1060 *handle = new Handle(shared_ptr<AbstractItem>(p));
1062 return NOTI_EX_ERROR_NONE;
1065 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
1066 noti_ex_item_h handle, char ***contents_list, int *count) {
1067 if (handle == nullptr || contents_list == nullptr || count == nullptr) {
1068 LOGE("Invalid parameter");
1069 return NOTI_EX_ERROR_INVALID_PARAMETER;
1072 Handle* h = static_cast<Handle*>(handle);
1073 if (!h->IsValidType(AbstractItem::InputSelector)) {
1074 LOGE("Invalid handle type");
1075 return NOTI_EX_ERROR_INVALID_PARAMETER;
1078 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1079 vector<shared_ptr<MultiLanguage>> arr = p->GetMultiLanguageArr();
1080 list<string> contents;
1081 if (arr.size() == 0) {
1082 contents = p->GetContents();
1084 for (auto& i : arr) {
1085 contents.push_back(i->GetTranslatedString());
1089 char **list = (char**)calloc(contents.size(), sizeof(char*));
1090 if (list == nullptr) {
1091 LOGE("Out of memory");
1092 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1096 for (auto& i : contents) {
1097 list[idx] = strdup(i.c_str());
1098 if (list[idx] == nullptr) {
1099 __noti_ex_free_str_array(list, idx);
1100 LOGE("Out of memory");
1101 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1106 *count = contents.size();
1107 *contents_list = list;
1109 return NOTI_EX_ERROR_NONE;
1112 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
1113 noti_ex_item_h handle, const char **contents, int count) {
1114 if (handle == nullptr || contents == nullptr) {
1115 LOGE("Invalid parameter");
1116 return NOTI_EX_ERROR_INVALID_PARAMETER;
1119 list<string> new_contents;
1120 Handle* h = static_cast<Handle*>(handle);
1121 if (!h->IsValidType(AbstractItem::InputSelector)) {
1122 LOGE("Invalid handle type");
1123 return NOTI_EX_ERROR_INVALID_PARAMETER;
1125 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1126 for (int i = 0; i < count; i++) {
1127 new_contents.push_back(contents[i]);
1129 p->SetContents(move(new_contents));
1131 return NOTI_EX_ERROR_NONE;
1134 extern "C" EXPORT_API int noti_ex_item_input_selector_set_multi_language_contents(
1135 noti_ex_item_h handle, noti_ex_multi_lang_h* multi_language_list, int count) {
1136 if (handle == nullptr) {
1137 LOGE("Invalid parameter");
1138 return NOTI_EX_ERROR_INVALID_PARAMETER;
1141 Handle* p = static_cast<Handle*>(handle);
1142 if (!p->IsValidType(AbstractItem::InputSelector)) {
1143 LOGE("Invalid handle type");
1144 return NOTI_EX_ERROR_INVALID_PARAMETER;
1147 vector<shared_ptr<MultiLanguage>> m_list;
1148 for (int i = 0; i < count; i++) {
1149 shared_ptr<MultiLanguage> mul_ptr =
1150 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi_language_list[i]);
1151 mul_ptr->UpdateString();
1152 m_list.push_back(mul_ptr);
1155 InputSelectorItem* input = static_cast<InputSelectorItem*>(p->Get());
1156 input->SetMultiLanguage(m_list);
1158 return NOTI_EX_ERROR_NONE;
1161 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
1162 unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
1163 if (handle == nullptr) {
1164 LOGE("Invalid parameter");
1165 return NOTI_EX_ERROR_INVALID_PARAMETER;
1168 auto* ptr = new (std::nothrow) shared_ptr<Color>(
1169 new (std::nothrow) Color(a, r, g, b));
1170 if (ptr == nullptr || ptr->get() == nullptr) {
1171 LOGE("Out-of-memory");
1172 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1177 return NOTI_EX_ERROR_NONE;
1180 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
1181 if (handle == nullptr) {
1182 LOGE("Invalid parameter");
1183 return NOTI_EX_ERROR_INVALID_PARAMETER;
1186 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1189 return NOTI_EX_ERROR_NONE;
1192 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
1193 unsigned char *val) {
1194 if (handle == nullptr || val == nullptr) {
1195 LOGE("Invalid parameter");
1196 return NOTI_EX_ERROR_INVALID_PARAMETER;
1199 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1200 *val = (*p)->GetAVal();
1202 return NOTI_EX_ERROR_NONE;
1205 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
1206 unsigned char *val) {
1207 if (handle == nullptr || val == nullptr) {
1208 LOGE("Invalid parameter");
1209 return NOTI_EX_ERROR_INVALID_PARAMETER;
1212 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1213 *val = (*p)->GetRVal();
1215 return NOTI_EX_ERROR_NONE;
1218 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
1219 unsigned char *val) {
1220 if (handle == nullptr || val == nullptr) {
1221 LOGE("Invalid parameter");
1222 return NOTI_EX_ERROR_INVALID_PARAMETER;
1225 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1226 *val = (*p)->GetGVal();
1228 return NOTI_EX_ERROR_NONE;
1231 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
1232 unsigned char *val) {
1233 if (handle == nullptr || val == nullptr) {
1234 LOGE("Invalid parameter");
1235 return NOTI_EX_ERROR_INVALID_PARAMETER;
1238 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1239 *val = (*p)->GetBVal();
1241 return NOTI_EX_ERROR_NONE;
1244 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
1245 int left, int top, int right, int bottom) {
1246 if (handle == nullptr) {
1247 LOGE("Invalid parameter");
1248 return NOTI_EX_ERROR_INVALID_PARAMETER;
1251 auto* ptr = new (std::nothrow) shared_ptr<Padding>(
1252 new (std::nothrow) Padding(left, top, right, bottom));
1253 if (ptr == nullptr || ptr->get() == nullptr) {
1254 LOGE("Out-of-memory");
1255 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1260 return NOTI_EX_ERROR_NONE;
1263 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
1264 if (handle == nullptr) {
1265 LOGE("Invalid parameter");
1266 return NOTI_EX_ERROR_INVALID_PARAMETER;
1269 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1272 return NOTI_EX_ERROR_NONE;
1275 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
1277 if (handle == nullptr || val == nullptr) {
1278 LOGE("Invalid parameter");
1279 return NOTI_EX_ERROR_INVALID_PARAMETER;
1282 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1283 *val = (*p)->GetLeft();
1285 return NOTI_EX_ERROR_NONE;
1288 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
1290 if (handle == nullptr || val == nullptr) {
1291 LOGE("Invalid parameter");
1292 return NOTI_EX_ERROR_INVALID_PARAMETER;
1295 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1296 *val = (*p)->GetTop();
1298 return NOTI_EX_ERROR_NONE;
1301 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
1303 if (handle == nullptr || val == nullptr) {
1304 LOGE("Invalid parameter");
1305 return NOTI_EX_ERROR_INVALID_PARAMETER;
1308 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1309 *val = (*p)->GetRight();
1311 return NOTI_EX_ERROR_NONE;
1314 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
1316 if (handle == nullptr || val == nullptr) {
1317 LOGE("Invalid parameter");
1318 return NOTI_EX_ERROR_INVALID_PARAMETER;
1321 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1322 *val = (*p)->GetBottom();
1324 return NOTI_EX_ERROR_NONE;
1327 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
1328 int x, int y, int w, int h) {
1329 if (handle == nullptr) {
1330 LOGE("Invalid parameter");
1331 return NOTI_EX_ERROR_INVALID_PARAMETER;
1334 auto* ptr = new (std::nothrow) shared_ptr<Geometry>(
1335 new (std::nothrow) Geometry(x, y, w, h));
1336 if (ptr == nullptr || ptr->get() == nullptr) {
1337 LOGE("Out-of-memory");
1338 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1343 return NOTI_EX_ERROR_NONE;
1346 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
1347 if (handle == nullptr) {
1348 LOGE("Invalid parameter");
1349 return NOTI_EX_ERROR_INVALID_PARAMETER;
1352 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1355 return NOTI_EX_ERROR_NONE;
1358 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
1360 if (handle == nullptr || val == nullptr) {
1361 LOGE("Invalid parameter");
1362 return NOTI_EX_ERROR_INVALID_PARAMETER;
1365 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1366 *val = (*p)->GetX();
1368 return NOTI_EX_ERROR_NONE;
1371 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
1373 if (handle == nullptr || val == nullptr) {
1374 LOGE("Invalid parameter");
1375 return NOTI_EX_ERROR_INVALID_PARAMETER;
1378 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1379 *val = (*p)->GetY();
1381 return NOTI_EX_ERROR_NONE;
1384 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
1386 if (handle == nullptr || val == nullptr) {
1387 LOGE("Invalid parameter");
1388 return NOTI_EX_ERROR_INVALID_PARAMETER;
1391 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1392 *val = (*p)->GetWidth();
1394 return NOTI_EX_ERROR_NONE;
1397 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
1399 if (handle == nullptr || val == nullptr) {
1400 LOGE("Invalid parameter");
1401 return NOTI_EX_ERROR_INVALID_PARAMETER;
1404 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1405 *val = (*p)->GetHeight();
1407 return NOTI_EX_ERROR_NONE;
1410 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
1411 noti_ex_color_h color,
1412 noti_ex_padding_h padding,
1413 noti_ex_geometry_h geometry) {
1414 if (handle == nullptr) {
1415 LOGE("Invalid parameter");
1416 return NOTI_EX_ERROR_INVALID_PARAMETER;
1419 shared_ptr<Color> col = (color == nullptr) ?
1420 nullptr : *(static_cast<shared_ptr<Color>*>(color));
1421 shared_ptr<Padding> padd = (padding == nullptr) ?
1422 nullptr : *(static_cast<shared_ptr<Padding>*>(padding));
1423 shared_ptr<Geometry> geo = (geometry == nullptr) ?
1424 nullptr : *(static_cast<shared_ptr<Geometry>*>(geometry));
1426 auto* ptr = new (std::nothrow) shared_ptr<Style>(
1427 new (std::nothrow) Style(col, padd, geo));
1428 if (ptr == nullptr || ptr->get() == nullptr) {
1429 LOGE("Out-of-memory");
1430 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1435 return NOTI_EX_ERROR_NONE;
1438 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
1439 if (handle == nullptr) {
1440 LOGE("Invalid parameter");
1441 return NOTI_EX_ERROR_INVALID_PARAMETER;
1444 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1447 return NOTI_EX_ERROR_NONE;
1450 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
1451 noti_ex_padding_h *padding) {
1452 if (handle == nullptr || padding == nullptr) {
1453 LOGE("Invalid parameter");
1454 return NOTI_EX_ERROR_INVALID_PARAMETER;
1457 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1458 if ((*p)->GetPadding() == nullptr) {
1459 LOGW("Padding info is null");
1460 return NOTI_EX_ERROR_INVALID_PARAMETER;
1463 shared_ptr<Padding>* padd = new (std::nothrow) shared_ptr<Padding>(
1464 new (std::nothrow) Padding(*((*p)->GetPadding())));
1465 if (padd == nullptr || padd->get() == nullptr) {
1466 LOGE("Out-of-memory");
1468 return NOTI_EX_ERROR_NONE;
1473 return NOTI_EX_ERROR_NONE;
1477 extern "C" EXPORT_API int noti_ex_style_set_padding(noti_ex_style_h handle,
1478 noti_ex_padding_h padding) {
1479 if (handle == nullptr) {
1480 LOGE("Invalid parameter");
1481 return NOTI_EX_ERROR_INVALID_PARAMETER;
1484 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1485 if (padding == nullptr) {
1486 (*p)->SetPadding(nullptr);
1487 return NOTI_EX_ERROR_NONE;
1490 shared_ptr<Padding>* padd = static_cast<shared_ptr<Padding>*>(padding);
1491 (*p)->SetPadding(*padd);
1493 return NOTI_EX_ERROR_NONE;
1496 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
1497 noti_ex_color_h *color) {
1498 if (handle == nullptr || color == nullptr) {
1499 LOGE("Invalid parameter");
1500 return NOTI_EX_ERROR_INVALID_PARAMETER;
1503 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1504 if ((*p)->GetColor() == nullptr) {
1505 LOGW("Color info is null");
1507 return NOTI_EX_ERROR_NONE;
1510 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1511 new (std::nothrow) Color(*((*p)->GetColor())));
1512 if (col == nullptr || col->get() == nullptr) {
1513 LOGE("Out-of-memory");
1514 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1519 return NOTI_EX_ERROR_NONE;
1522 extern "C" EXPORT_API int noti_ex_style_set_color(
1523 noti_ex_style_h handle, noti_ex_color_h color) {
1524 if (handle == nullptr) {
1525 LOGE("Invalid parameter");
1526 return NOTI_EX_ERROR_INVALID_PARAMETER;
1529 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1530 if (color == nullptr) {
1531 (*p)->SetColor(nullptr);
1532 return NOTI_EX_ERROR_NONE;
1535 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1536 (*p)->SetColor(*col);
1538 return NOTI_EX_ERROR_NONE;
1541 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
1542 noti_ex_geometry_h *geometry) {
1543 if (handle == nullptr || geometry == nullptr) {
1544 LOGE("Invalid parameter");
1545 return NOTI_EX_ERROR_INVALID_PARAMETER;
1548 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1549 if ((*p)->GetGeometry() == nullptr) {
1550 LOGW("Geometry info is null");
1551 *geometry = nullptr;
1552 return NOTI_EX_ERROR_NONE;
1555 shared_ptr<Geometry>* geo = new (std::nothrow) shared_ptr<Geometry>(
1556 new (std::nothrow) Geometry(*((*p)->GetGeometry())));
1557 if (geo == nullptr || geo->get() == nullptr) {
1558 LOGE("Out-of-memory");
1559 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1564 return NOTI_EX_ERROR_NONE;
1567 extern "C" EXPORT_API int noti_ex_style_set_geometry(
1568 noti_ex_style_h handle, noti_ex_geometry_h geometry) {
1569 if (handle == nullptr) {
1570 LOGE("Invalid parameter");
1571 return NOTI_EX_ERROR_INVALID_PARAMETER;
1574 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1575 if (geometry == nullptr) {
1576 (*p)->SetGeometry(nullptr);
1577 return NOTI_EX_ERROR_NONE;
1580 shared_ptr<Geometry>* geo = static_cast<shared_ptr<Geometry>*>(geometry);
1581 (*p)->SetGeometry(*geo);
1583 return NOTI_EX_ERROR_NONE;
1586 extern "C" EXPORT_API int noti_ex_style_get_background_image(
1587 noti_ex_style_h handle, char** background_image) {
1588 if (handle == nullptr || background_image == nullptr) {
1589 LOGE("Invalid parameter");
1590 return NOTI_EX_ERROR_INVALID_PARAMETER;
1593 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1595 if ((*p)->GetBackgroundImage().empty())
1596 *background_image = nullptr;
1598 *background_image = strdup((*p)->GetBackgroundImage().c_str());
1600 return NOTI_EX_ERROR_NONE;
1603 extern "C" EXPORT_API int noti_ex_style_set_background_image(
1604 noti_ex_style_h handle, char* background_image) {
1605 if (handle == nullptr) {
1606 LOGE("Invalid parameter");
1607 return NOTI_EX_ERROR_INVALID_PARAMETER;
1610 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1611 if (background_image == nullptr)
1612 (*p)->SetBackgroundImage("");
1614 (*p)->SetBackgroundImage(background_image);
1616 return NOTI_EX_ERROR_NONE;
1619 extern "C" EXPORT_API int noti_ex_style_get_background_color(
1620 noti_ex_style_h handle, noti_ex_color_h* color) {
1621 if (handle == nullptr || color == nullptr) {
1622 LOGE("Invalid parameter");
1623 return NOTI_EX_ERROR_INVALID_PARAMETER;
1626 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1627 if ((*p)->GetBackgroundColor() == nullptr) {
1628 LOGW("Color info is null");
1630 return NOTI_EX_ERROR_NONE;
1633 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1634 new (std::nothrow) Color(*((*p)->GetBackgroundColor())));
1635 if (col == nullptr || col->get() == nullptr) {
1636 LOGE("Out-of-memory");
1637 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1642 return NOTI_EX_ERROR_NONE;
1645 extern "C" EXPORT_API int noti_ex_style_set_background_color(
1646 noti_ex_style_h handle, noti_ex_color_h color) {
1647 if (handle == nullptr) {
1648 LOGE("Invalid parameter");
1649 return NOTI_EX_ERROR_INVALID_PARAMETER;
1652 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1653 if (color == nullptr) {
1654 (*p)->SetBackgroundColor(nullptr);
1655 return NOTI_EX_ERROR_NONE;
1658 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1659 (*p)->SetBackgroundColor(*col);
1661 return NOTI_EX_ERROR_NONE;
1664 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
1665 noti_ex_color_h color) {
1666 if (handle == nullptr || color == nullptr) {
1667 LOGE("Invalid parameter");
1668 return NOTI_EX_ERROR_INVALID_PARAMETER;
1671 shared_ptr<Color>* color_ptr = static_cast<shared_ptr<Color>*>(color);
1672 shared_ptr<LEDInfo>* p = new (std::nothrow) shared_ptr<LEDInfo>(
1673 new (std::nothrow) LEDInfo(*color_ptr));
1675 LOGE("Out-of-memory");
1676 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1681 return NOTI_EX_ERROR_NONE;
1684 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
1685 if (handle == nullptr) {
1686 LOGE("Invalid parameter");
1687 return NOTI_EX_ERROR_INVALID_PARAMETER;
1690 shared_ptr<LEDInfo>* led_ptr =
1691 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1693 return NOTI_EX_ERROR_NONE;
1696 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
1697 noti_ex_led_info_h handle, int ms) {
1698 if (handle == nullptr) {
1699 LOGE("Invalid parameter");
1700 return NOTI_EX_ERROR_INVALID_PARAMETER;
1703 shared_ptr<LEDInfo>* led_ptr =
1704 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1705 (*led_ptr)->SetOnPeriod(ms);
1707 return NOTI_EX_ERROR_NONE;
1710 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
1711 noti_ex_led_info_h handle, int *ms) {
1712 if (handle == nullptr || ms == nullptr) {
1713 LOGE("Invalid parameter");
1714 return NOTI_EX_ERROR_INVALID_PARAMETER;
1717 shared_ptr<LEDInfo>* led_ptr =
1718 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1719 *ms = (*led_ptr)->GetOnPeriod();
1721 return NOTI_EX_ERROR_NONE;
1724 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
1725 noti_ex_led_info_h handle, int ms) {
1726 if (handle == nullptr) {
1727 LOGE("Invalid parameter");
1728 return NOTI_EX_ERROR_INVALID_PARAMETER;
1731 shared_ptr<LEDInfo>* led_ptr =
1732 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1733 (*led_ptr)->SetOffPeriod(ms);
1735 return NOTI_EX_ERROR_NONE;
1738 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
1739 noti_ex_led_info_h handle, int *ms) {
1740 if (handle == nullptr) {
1741 LOGE("Invalid parameter");
1742 return NOTI_EX_ERROR_INVALID_PARAMETER;
1745 shared_ptr<LEDInfo>* led_ptr =
1746 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1747 *ms = (*led_ptr)->GetOffPeriod();
1749 return NOTI_EX_ERROR_NONE;
1752 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1753 noti_ex_led_info_h handle, noti_ex_color_h *color) {
1754 if (handle == nullptr) {
1755 LOGE("Invalid parameter");
1756 return NOTI_EX_ERROR_INVALID_PARAMETER;
1759 shared_ptr<LEDInfo>* led_ptr =
1760 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1761 if ((*led_ptr)->GetColor() == nullptr) {
1762 LOGW("Color is null");
1764 return NOTI_EX_ERROR_NONE;
1767 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1768 new (std::nothrow) Color(*((*led_ptr)->GetColor())));
1769 if (col == nullptr || col->get() == nullptr) {
1770 LOGE("Out-of-memory");
1771 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1776 return NOTI_EX_ERROR_NONE;
1779 extern "C" EXPORT_API int noti_ex_led_info_set_color(
1780 noti_ex_led_info_h handle, noti_ex_color_h color) {
1781 if (handle == nullptr) {
1782 LOGE("Invalid parameter");
1783 return NOTI_EX_ERROR_INVALID_PARAMETER;
1786 shared_ptr<LEDInfo>* p = static_cast<shared_ptr<LEDInfo>*>(handle);
1787 if (color == nullptr) {
1788 (*p)->SetColor(nullptr);
1789 return NOTI_EX_ERROR_NONE;
1792 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1793 (*p)->SetColor(*col);
1795 return NOTI_EX_ERROR_NONE;
1798 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1799 if (handle == nullptr) {
1800 LOGE("Invalid parameter");
1801 return NOTI_EX_ERROR_INVALID_PARAMETER;
1804 shared_ptr<AbstractAction>* ptr =
1805 static_cast<shared_ptr<AbstractAction>*>(handle);
1808 return NOTI_EX_ERROR_NONE;
1811 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1813 if (handle == nullptr || type == nullptr) {
1814 LOGE("Invalid parameter");
1815 return NOTI_EX_ERROR_INVALID_PARAMETER;
1818 shared_ptr<AbstractAction>* ptr =
1819 static_cast<shared_ptr<AbstractAction>*>(handle);
1820 *type = (*ptr)->GetType();
1822 return NOTI_EX_ERROR_NONE;
1825 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1827 if (handle == nullptr || local == nullptr) {
1828 LOGE("Invalid parameter");
1829 return NOTI_EX_ERROR_INVALID_PARAMETER;
1832 shared_ptr<AbstractAction>* ptr =
1833 static_cast<shared_ptr<AbstractAction>*>(handle);
1834 *local = (*ptr)->IsLocal();
1836 return NOTI_EX_ERROR_NONE;
1839 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1840 noti_ex_item_h item) {
1841 if (handle == nullptr || item == nullptr) {
1842 LOGE("Invalid parameter");
1843 return NOTI_EX_ERROR_INVALID_PARAMETER;
1845 shared_ptr<AbstractAction>* ptr =
1846 static_cast<shared_ptr<AbstractAction>*>(handle);
1847 Handle* ih = static_cast<Handle*>(item);
1848 (*ptr)->Execute(ih->GetPtr());
1850 return NOTI_EX_ERROR_NONE;
1853 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1855 if (handle == nullptr || extra == nullptr) {
1856 LOGE("Invalid parameter");
1857 return NOTI_EX_ERROR_INVALID_PARAMETER;
1860 shared_ptr<AbstractAction>* ptr =
1861 static_cast<shared_ptr<AbstractAction>*>(handle);
1862 if (!(*ptr)->GetExtra().empty()) {
1863 *extra = strdup((*ptr)->GetExtra().c_str());
1864 if (*extra == nullptr) {
1865 LOGE("Out-of-memory");
1866 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1872 return NOTI_EX_ERROR_NONE;
1875 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1876 noti_ex_item_info_h handle, int *hide_time) {
1877 if (handle == nullptr || hide_time == nullptr) {
1878 LOGE("Invalid parameter");
1879 return NOTI_EX_ERROR_INVALID_PARAMETER;
1881 IItemInfo* p = static_cast<IItemInfo*>(handle);
1882 *hide_time = p->GetHideTime();
1883 return NOTI_EX_ERROR_NONE;
1886 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1887 noti_ex_item_info_h handle, int hide_time) {
1888 if (handle == nullptr) {
1889 LOGE("Invalid parameter");
1890 return NOTI_EX_ERROR_INVALID_PARAMETER;
1892 IItemInfo* p = static_cast<IItemInfo*>(handle);
1893 p->SetHideTime(hide_time);
1894 return NOTI_EX_ERROR_NONE;
1897 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1898 noti_ex_item_info_h handle, int *delete_time) {
1899 if (handle == nullptr || delete_time == nullptr) {
1900 LOGE("Invalid parameter");
1901 return NOTI_EX_ERROR_INVALID_PARAMETER;
1903 IItemInfo* p = static_cast<IItemInfo*>(handle);
1904 *delete_time = p->GetDeleteTime();
1905 return NOTI_EX_ERROR_NONE;
1908 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
1909 noti_ex_item_info_h handle, int delete_time) {
1910 if (handle == nullptr) {
1911 LOGE("Invalid parameter");
1912 return NOTI_EX_ERROR_INVALID_PARAMETER;
1914 IItemInfo* p = static_cast<IItemInfo*>(handle);
1915 p->SetDeleteTime(delete_time);
1916 return NOTI_EX_ERROR_NONE;
1919 extern "C" EXPORT_API int noti_ex_item_info_get_time(
1920 noti_ex_item_info_h handle, time_t *time) {
1921 if (handle == nullptr || time == nullptr) {
1922 LOGE("Invalid parameter");
1923 return NOTI_EX_ERROR_INVALID_PARAMETER;
1926 IItemInfo* p = static_cast<IItemInfo*>(handle);
1927 *time = p->GetTime();
1928 return NOTI_EX_ERROR_NONE;
1931 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
1932 if (handle == nullptr) {
1933 LOGE("Invalid parameter");
1934 return NOTI_EX_ERROR_INVALID_PARAMETER;
1937 Handle* h = static_cast<Handle*>(handle);
1939 return NOTI_EX_ERROR_NONE;
1942 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
1943 const char *id, noti_ex_item_h *item) {
1944 if (handle == nullptr) {
1945 LOGE("Invalid parameter");
1946 return NOTI_EX_ERROR_INVALID_PARAMETER;
1949 Handle* p = static_cast<Handle*>(handle);
1950 AbstractItem& find_item = p->Get()->FindByID(string(id));
1951 if (find_item.GetType() == AbstractItem::NullObject) {
1952 LOGW("Not exist ID");
1954 return NOTI_EX_ERROR_NONE;
1957 *item = new Handle(&find_item);
1958 return NOTI_EX_ERROR_NONE;
1961 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
1963 if (handle == nullptr || type == nullptr) {
1964 LOGE("Invalid parameter");
1965 return NOTI_EX_ERROR_INVALID_PARAMETER;
1968 Handle* h = static_cast<Handle*>(handle);
1969 AbstractItem* p = h->Get();
1970 *type = p->GetType();
1971 return NOTI_EX_ERROR_NONE;
1974 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
1976 if (handle == nullptr || id == nullptr) {
1977 LOGE("Invalid parameter");
1978 return NOTI_EX_ERROR_INVALID_PARAMETER;
1980 Handle* h = static_cast<Handle*>(handle);
1981 AbstractItem* p = h->Get();
1982 *id = strdup(p->GetId().c_str());
1983 return NOTI_EX_ERROR_NONE;
1986 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
1988 if (handle == nullptr || id == nullptr) {
1989 LOGE("Invalid parameter");
1990 return NOTI_EX_ERROR_INVALID_PARAMETER;
1992 Handle* p = static_cast<Handle*>(handle);
1993 p->Get()->SetId(id);
1994 return NOTI_EX_ERROR_NONE;
1997 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
1998 noti_ex_action_h *action) {
1999 if (handle == nullptr || action == nullptr) {
2000 LOGE("Invalid parameter");
2001 return NOTI_EX_ERROR_INVALID_PARAMETER;
2003 Handle* p = static_cast<Handle*>(handle);
2004 if (p->Get()->GetAction() == nullptr) {
2006 return NOTI_EX_ERROR_NONE;
2008 *action = static_cast<noti_ex_action_h>(new shared_ptr<AbstractAction>(
2009 p->Get()->GetAction()));
2011 return NOTI_EX_ERROR_NONE;
2014 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
2015 noti_ex_action_h action) {
2016 if (handle == nullptr) {
2017 LOGE("Invalid parameter");
2018 return NOTI_EX_ERROR_INVALID_PARAMETER;
2021 Handle* p = static_cast<Handle*>(handle);
2022 if (action == nullptr) {
2023 p->Get()->SetAction(nullptr);
2024 return NOTI_EX_ERROR_NONE;
2027 shared_ptr<AbstractAction>* ptr =
2028 static_cast<shared_ptr<AbstractAction>*>(action);
2029 p->Get()->SetAction(*ptr);
2030 return NOTI_EX_ERROR_NONE;
2033 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
2034 noti_ex_style_h *style) {
2035 if (handle == nullptr || style == nullptr) {
2036 LOGE("Invalid parameter");
2037 return NOTI_EX_ERROR_INVALID_PARAMETER;
2040 Handle* p = static_cast<Handle*>(handle);
2041 shared_ptr<Style> s = p->Get()->GetStyle();
2042 if (s.get() == nullptr) {
2043 LOGW("Style is null");
2045 return NOTI_EX_ERROR_NONE;
2048 auto* ptr = new (std::nothrow) shared_ptr<Style>(new (std::nothrow) Style(*s));
2049 if (ptr == nullptr || ptr->get() == nullptr) {
2050 LOGE("Out of memory");
2051 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2055 return NOTI_EX_ERROR_NONE;
2058 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
2059 noti_ex_style_h style) {
2060 if (handle == nullptr) {
2061 LOGE("Invalid parameter");
2062 return NOTI_EX_ERROR_INVALID_PARAMETER;
2065 Handle* p = static_cast<Handle*>(handle);
2066 if (style == nullptr) {
2067 p->Get()->SetStyle(nullptr);
2068 return NOTI_EX_ERROR_NONE;
2071 shared_ptr<Style>* s = static_cast<shared_ptr<Style>*>(style);
2072 p->Get()->SetStyle(*s);
2073 return NOTI_EX_ERROR_NONE;
2076 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
2078 if (handle == nullptr) {
2079 LOGE("Invalid parameter");
2080 return NOTI_EX_ERROR_INVALID_PARAMETER;
2083 Handle* p = static_cast<Handle*>(handle);
2084 p->Get()->SetVisible(visible);
2085 return NOTI_EX_ERROR_NONE;
2088 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
2090 if (handle == nullptr || visible == nullptr) {
2091 LOGE("Invalid parameter");
2092 return NOTI_EX_ERROR_INVALID_PARAMETER;
2095 Handle* p = static_cast<Handle*>(handle);
2096 *visible = p->Get()->GetVisible();
2097 return NOTI_EX_ERROR_NONE;
2100 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
2102 if (handle == nullptr) {
2103 LOGE("Invalid parameter");
2104 return NOTI_EX_ERROR_INVALID_PARAMETER;
2107 Handle* p = static_cast<Handle*>(handle);
2108 p->Get()->SetEnable(enable);
2109 return NOTI_EX_ERROR_NONE;
2112 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
2114 if (handle == nullptr || enable == nullptr) {
2115 LOGE("Invalid parameter");
2116 return NOTI_EX_ERROR_INVALID_PARAMETER;
2119 Handle* p = static_cast<Handle*>(handle);
2120 *enable = p->Get()->GetEnable();
2121 return NOTI_EX_ERROR_NONE;
2124 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
2125 const char *receiver_group) {
2126 if (handle == nullptr || receiver_group == nullptr) {
2127 LOGE("Invalid parameter");
2128 return NOTI_EX_ERROR_INVALID_PARAMETER;
2131 Handle* p = static_cast<Handle*>(handle);
2132 p->Get()->AddReceiver(receiver_group);
2133 return NOTI_EX_ERROR_NONE;
2136 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
2137 const char *receiver_group) {
2138 if (handle == nullptr || receiver_group == nullptr) {
2139 LOGE("Invalid parameter");
2140 return NOTI_EX_ERROR_INVALID_PARAMETER;
2143 Handle* p = static_cast<Handle*>(handle);
2144 p->Get()->RemoveReceiver(receiver_group);
2145 return NOTI_EX_ERROR_NONE;
2148 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
2149 char ***receiver_list, int *count) {
2150 if (handle == nullptr || receiver_list == nullptr || count == nullptr) {
2151 LOGE("Invalid parameter");
2152 return NOTI_EX_ERROR_INVALID_PARAMETER;
2155 Handle* p = static_cast<Handle*>(handle);
2156 list<string> receivers = p->Get()->GetReceiverList();
2157 if (receivers.size() == 0) {
2158 *receiver_list = nullptr;
2160 return NOTI_EX_ERROR_NONE;
2163 char **tmp_list = (char**)calloc(receivers.size(), sizeof(char*));
2164 if (tmp_list == nullptr) {
2165 LOGE("Out of memory");
2166 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2170 for (auto& i : receivers) {
2171 tmp_list[idx] = strdup(i.c_str());
2172 if (tmp_list[idx] == nullptr) {
2173 __noti_ex_free_str_array(tmp_list, idx);
2174 LOGE("Out of memory");
2175 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2180 *receiver_list = tmp_list;
2181 *count = receivers.size();
2182 return NOTI_EX_ERROR_NONE;
2185 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
2187 if (handle == nullptr) {
2188 LOGE("Invalid parameter");
2189 return NOTI_EX_ERROR_INVALID_PARAMETER;
2192 Handle* p = static_cast<Handle*>(handle);
2193 p->Get()->SetPolicy(policy);
2194 return NOTI_EX_ERROR_NONE;
2197 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
2199 if (handle == nullptr || policy == nullptr) {
2200 LOGE("Invalid parameter");
2201 return NOTI_EX_ERROR_INVALID_PARAMETER;
2204 Handle* p = static_cast<Handle*>(handle);
2205 *policy = p->Get()->GetPolicy();
2206 return NOTI_EX_ERROR_NONE;
2209 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
2211 if (handle == nullptr || channel == nullptr) {
2212 LOGE("Invalid parameter");
2213 return NOTI_EX_ERROR_INVALID_PARAMETER;
2216 Handle* p = static_cast<Handle*>(handle);
2217 if (!p->Get()->GetChannel().empty())
2218 *channel = strdup(p->Get()->GetChannel().c_str());
2222 return NOTI_EX_ERROR_NONE;
2225 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
2226 const char *channel) {
2227 if (handle == nullptr) {
2228 LOGE("Invalid parameter");
2229 return NOTI_EX_ERROR_INVALID_PARAMETER;
2232 Handle* p = static_cast<Handle*>(handle);
2233 p->Get()->SetChannel(channel);
2234 return NOTI_EX_ERROR_NONE;
2237 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
2238 noti_ex_led_info_h led) {
2239 if (handle == nullptr) {
2240 LOGE("Invalid parameter");
2241 return NOTI_EX_ERROR_INVALID_PARAMETER;
2244 Handle* p = static_cast<Handle*>(handle);
2245 if (led == nullptr) {
2246 p->Get()->SetLEDInfo(nullptr);
2247 return NOTI_EX_ERROR_NONE;
2249 shared_ptr<LEDInfo>* led_ptr =
2250 reinterpret_cast<shared_ptr<LEDInfo>*>(led);
2251 p->Get()->SetLEDInfo(*led_ptr);
2252 return NOTI_EX_ERROR_NONE;
2255 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
2256 noti_ex_led_info_h *led) {
2257 if (handle == nullptr) {
2258 LOGE("Invalid parameter");
2259 return NOTI_EX_ERROR_INVALID_PARAMETER;
2262 Handle* p = static_cast<Handle*>(handle);
2263 if (p->Get()->GetLEDInfo() != nullptr)
2264 *led = new shared_ptr<LEDInfo>(p->Get()->GetLEDInfo());
2267 return NOTI_EX_ERROR_NONE;
2270 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
2272 if (handle == nullptr) {
2273 LOGE("Invalid parameter");
2274 return NOTI_EX_ERROR_INVALID_PARAMETER;
2277 Handle* p = static_cast<Handle*>(handle);
2278 if (path == nullptr)
2279 p->Get()->SetSoundPath("");
2281 p->Get()->SetSoundPath(path);
2282 return NOTI_EX_ERROR_NONE;
2285 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
2287 if (handle == nullptr) {
2288 LOGE("Invalid parameter");
2289 return NOTI_EX_ERROR_INVALID_PARAMETER;
2292 Handle* p = static_cast<Handle*>(handle);
2293 if (path == nullptr)
2294 p->Get()->SetVibrationPath("");
2296 p->Get()->SetVibrationPath(path);
2297 return NOTI_EX_ERROR_NONE;
2300 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
2302 if (handle == nullptr || path == nullptr) {
2303 LOGE("Invalid parameter");
2304 return NOTI_EX_ERROR_INVALID_PARAMETER;
2307 Handle* p = static_cast<Handle*>(handle);
2308 if (p->Get()->GetSoundPath().empty())
2311 *path = strdup(p->Get()->GetSoundPath().c_str());
2312 return NOTI_EX_ERROR_NONE;
2315 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
2317 if (handle == nullptr || path == nullptr) {
2318 LOGE("Invalid parameter");
2319 return NOTI_EX_ERROR_INVALID_PARAMETER;
2322 Handle* p = static_cast<Handle*>(handle);
2323 if (p->Get()->GetVibrationPath().empty())
2326 *path = strdup(p->Get()->GetVibrationPath().c_str());
2327 return NOTI_EX_ERROR_NONE;
2330 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
2331 noti_ex_item_info_h *info) {
2332 if (handle == nullptr || info == nullptr) {
2333 LOGE("Invalid parameter");
2334 return NOTI_EX_ERROR_INVALID_PARAMETER;
2337 Handle* p = static_cast<Handle*>(handle);
2338 if (p->Get()->GetInfo() == nullptr)
2341 *info = static_cast<noti_ex_item_info_h>(p->Get()->GetInfo().get());
2342 return NOTI_EX_ERROR_NONE;
2345 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
2347 if (handle == nullptr || id == nullptr) {
2348 LOGE("Invalid parameter");
2349 return NOTI_EX_ERROR_INVALID_PARAMETER;
2352 Handle* p = static_cast<Handle*>(handle);
2353 if (p->Get()->GetSenderAppId().empty())
2356 *id = strdup(p->Get()->GetSenderAppId().c_str());
2357 return NOTI_EX_ERROR_NONE;
2360 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
2362 if (handle == nullptr || tag == nullptr) {
2363 LOGE("Invalid parameter");
2364 return NOTI_EX_ERROR_INVALID_PARAMETER;
2367 Handle* p = static_cast<Handle*>(handle);
2368 if (p->Get()->GetTag().empty())
2371 *tag = strdup(p->Get()->GetTag().c_str());
2372 return NOTI_EX_ERROR_NONE;
2375 extern "C" EXPORT_API int noti_ex_item_set_tag(noti_ex_item_h handle,
2377 if (handle == nullptr) {
2378 LOGE("Invalid parameter");
2379 return NOTI_EX_ERROR_INVALID_PARAMETER;
2382 Handle* p = static_cast<Handle*>(handle);
2384 p->Get()->SetTag("");
2386 p->Get()->SetTag(tag);
2387 return NOTI_EX_ERROR_NONE;
2390 extern "C" EXPORT_API int noti_ex_item_get_ongoing_state(noti_ex_item_h handle,
2392 if (handle == nullptr || ongoing == nullptr) {
2393 LOGE("Invalid parameter");
2394 return NOTI_EX_ERROR_INVALID_PARAMETER;
2397 Handle* p = static_cast<Handle*>(handle);
2398 *ongoing = p->Get()->GetOnGoingState();
2400 return NOTI_EX_ERROR_NONE;
2403 extern "C" EXPORT_API int noti_ex_item_set_ongoing_state(noti_ex_item_h handle,
2405 if (handle == nullptr) {
2406 LOGE("Invalid parameter");
2407 return NOTI_EX_ERROR_INVALID_PARAMETER;
2410 Handle* p = static_cast<Handle*>(handle);
2411 p->Get()->SetOnGoingState(ongoing);
2413 return NOTI_EX_ERROR_NONE;
2416 extern "C" EXPORT_API int noti_ex_item_check_type_exist(noti_ex_item_h handle,
2417 int type, bool* exist) {
2418 if (handle == nullptr || exist == nullptr) {
2419 LOGE("Invalid parameter");
2420 return NOTI_EX_ERROR_INVALID_PARAMETER;
2423 Handle* p = static_cast<Handle*>(handle);
2424 *exist = p->Get()->IsItemTypeExist(type);
2426 return NOTI_EX_ERROR_NONE;
2429 extern "C" EXPORT_API int noti_ex_item_get_main_type(noti_ex_item_h handle,
2431 if (handle == nullptr || type == nullptr) {
2432 LOGE("Invalid parameter");
2433 return NOTI_EX_ERROR_INVALID_PARAMETER;
2436 Handle* p = static_cast<Handle*>(handle);
2437 *type = p->Get()->GetMainType();
2439 return NOTI_EX_ERROR_NONE;
2442 extern "C" EXPORT_API int noti_ex_item_set_main_type(noti_ex_item_h handle,
2443 const char* id, int type) {
2444 if (handle == nullptr || id == nullptr) {
2445 LOGE("Invalid parameter");
2446 return NOTI_EX_ERROR_INVALID_PARAMETER;
2449 Handle* p = static_cast<Handle*>(handle);
2450 if (!(p->Get()->SetMainType(string(id),
2451 static_cast<AbstractItem::MainType>(type))))
2452 return NOTI_EX_ERROR_INVALID_PARAMETER;
2454 return NOTI_EX_ERROR_NONE;
2457 extern "C" EXPORT_API int noti_ex_item_find_by_main_type(noti_ex_item_h handle,
2458 int type, noti_ex_item_h* item) {
2459 if (handle == nullptr || item == nullptr) {
2460 LOGE("Invalid parameter");
2461 return NOTI_EX_ERROR_INVALID_PARAMETER;
2464 Handle* h = static_cast<Handle*>(handle);
2465 if (!h->IsValidType(AbstractItem::Group)) {
2466 LOGE("Invalid handle type");
2467 return NOTI_EX_ERROR_INVALID_PARAMETER;
2470 GroupItem* p = static_cast<GroupItem*>(h->Get());
2471 AbstractItem& find_item = p->FindByMainType(static_cast<AbstractItem::MainType>(type));
2472 if (find_item.GetType() == AbstractItem::NullObject) {
2473 LOGW("Not exist ID");
2475 return NOTI_EX_ERROR_NONE;
2477 *item = new Handle(&find_item);
2479 return NOTI_EX_ERROR_NONE;
2482 extern "C" EXPORT_API int noti_ex_item_get_extension_data(noti_ex_item_h handle,
2483 const char *key, bundle **value) {
2484 if (handle == nullptr || key == nullptr || value == nullptr) {
2485 LOGE("Invalid handle type");
2486 return NOTI_EX_ERROR_INVALID_PARAMETER;
2489 Handle* p = static_cast<Handle*>(handle);
2491 Bundle b = p->Get()->GetExtensionData(key);
2492 if (b.GetCount() == 0)
2495 *value = b.GetHandle();
2497 return NOTI_EX_ERROR_NONE;
2500 extern "C" EXPORT_API int noti_ex_item_set_extension_data(noti_ex_item_h handle,
2501 const char *key, bundle *value) {
2502 if (handle == nullptr || key == nullptr || value == nullptr) {
2503 LOGE("Invalid handle type");
2504 return NOTI_EX_ERROR_INVALID_PARAMETER;
2507 Bundle b = Bundle(value);
2509 Handle* p = static_cast<Handle*>(handle);
2510 p->Get()->SetExtensionData(key, b);
2512 return NOTI_EX_ERROR_NONE;
2515 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
2516 const char *receiver_group, noti_ex_manager_events_s event_callbacks,
2518 if (handle == nullptr) {
2519 LOGE("Invalid parameter");
2520 return NOTI_EX_ERROR_INVALID_PARAMETER;
2523 string receiver_group_str = "";
2525 receiver_group_str = string(receiver_group);
2527 ManagerStub* stub = new (std::nothrow) ManagerStub(
2528 unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
2529 unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
2530 receiver_group_str);
2531 if (stub == nullptr) {
2532 LOGE("Fail to create manager");
2533 return NOTI_EX_ERROR_IO_ERROR;
2535 stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
2536 new ManagerCallbackInfo(event_callbacks, data)));
2537 *handle = static_cast<noti_ex_manager_h>(stub);
2539 return NOTI_EX_ERROR_NONE;
2542 extern "C" EXPORT_API int noti_ex_manager_destroy(noti_ex_manager_h handle) {
2543 if (handle == nullptr) {
2544 LOGE("Invalid parameter");
2545 return NOTI_EX_ERROR_INVALID_PARAMETER;
2547 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2549 return NOTI_EX_ERROR_NONE;
2552 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
2553 noti_ex_item_h **items, int *count) {
2554 if (handle == nullptr || items == nullptr || count == nullptr) {
2555 LOGE("Invalid parameter");
2556 return NOTI_EX_ERROR_INVALID_PARAMETER;
2560 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2561 list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
2562 if (item_list.size() == 0) {
2565 return NOTI_EX_ERROR_NONE;
2567 noti_ex_item_h* added_item =
2568 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2569 if (added_item == nullptr) {
2570 LOGE("Fail to create items");
2571 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2575 for (auto& i : item_list) {
2576 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2578 *items = added_item;
2579 *count = item_list.size();
2580 } catch (Exception &ex) {
2581 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2582 return NOTI_EX_ERROR_IO_ERROR;
2584 return NOTI_EX_ERROR_NONE;
2587 extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
2588 noti_ex_manager_h handle, char* channel, noti_ex_item_h** items, int* count) {
2589 if (handle == nullptr || channel == nullptr ||
2590 items == nullptr || count == nullptr) {
2591 LOGE("Invalid parameter");
2592 return NOTI_EX_ERROR_INVALID_PARAMETER;
2596 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2597 list<unique_ptr<item::AbstractItem>> item_list = stub->Get(channel);
2598 if (item_list.size() == 0) {
2601 return NOTI_EX_ERROR_NONE;
2603 noti_ex_item_h* added_item =
2604 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2605 if (added_item == nullptr) {
2606 LOGE("Fail to create items");
2607 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2611 for (auto& i : item_list) {
2612 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2614 *items = added_item;
2615 *count = item_list.size();
2616 } catch (Exception &ex) {
2617 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2618 return NOTI_EX_ERROR_IO_ERROR;
2621 return NOTI_EX_ERROR_NONE;
2624 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
2625 noti_ex_item_h noti, int *request_id) {
2626 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2627 LOGE("Invalid parameter");
2628 return NOTI_EX_ERROR_INVALID_PARAMETER;
2631 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2632 Handle* sp = static_cast<Handle*>(noti);
2633 if (sp->GetPtr().get() == nullptr) {
2634 LOGE("Invalid noti reference can not be sended");
2635 return NOTI_EX_ERROR_INVALID_PARAMETER;
2637 *request_id = stub->Update(sp->GetPtr());
2639 } catch (Exception &ex) {
2640 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2641 return NOTI_EX_ERROR_IO_ERROR;
2643 return NOTI_EX_ERROR_NONE;
2646 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
2647 noti_ex_item_h noti, int *request_id) {
2648 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2649 LOGE("Invalid parameter");
2650 return NOTI_EX_ERROR_INVALID_PARAMETER;
2653 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2654 Handle* item = static_cast<Handle*>(noti);
2655 if (item->GetPtr().get() == nullptr) {
2656 LOGE("Invalid noti reference can not be sended");
2657 return NOTI_EX_ERROR_INVALID_PARAMETER;
2659 *request_id = stub->Delete(item->GetPtr());
2661 } catch (Exception &ex) {
2662 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2663 return NOTI_EX_ERROR_IO_ERROR;
2665 return NOTI_EX_ERROR_NONE;
2668 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
2670 if (handle == nullptr || request_id == nullptr) {
2671 LOGE("Invalid parameter");
2672 return NOTI_EX_ERROR_INVALID_PARAMETER;
2675 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2676 *request_id = stub->DeleteAll();
2677 } catch (Exception &ex) {
2678 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2679 return NOTI_EX_ERROR_IO_ERROR;
2681 return NOTI_EX_ERROR_NONE;
2684 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
2685 noti_ex_item_h noti, int *request_id) {
2686 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2687 LOGE("Invalid parameter");
2688 return NOTI_EX_ERROR_INVALID_PARAMETER;
2691 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2692 Handle* item = static_cast<Handle*>(noti);
2693 if (item->GetPtr().get() == nullptr) {
2694 LOGE("Invalid noti reference can not be sended");
2695 return NOTI_EX_ERROR_INVALID_PARAMETER;
2697 *request_id = stub->Hide(item->GetPtr());
2699 } catch (Exception &ex) {
2700 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2701 return NOTI_EX_ERROR_IO_ERROR;
2703 return NOTI_EX_ERROR_NONE;
2706 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
2707 noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
2708 if (handle == nullptr || root_id == nullptr || item == nullptr) {
2709 LOGE("Invalid parameter");
2710 return NOTI_EX_ERROR_INVALID_PARAMETER;
2713 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2714 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
2715 if (ptr == nullptr) {
2716 LOGW("Not exist ID");
2718 return NOTI_EX_ERROR_NONE;
2720 *item = new Handle(ptr);
2721 } catch (Exception &ex) {
2722 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2723 return NOTI_EX_ERROR_IO_ERROR;
2725 return NOTI_EX_ERROR_NONE;
2728 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
2729 noti_ex_event_info_h info, noti_ex_error_e error) {
2730 if (handle == nullptr || info == nullptr) {
2731 LOGE("Invalid parameter");
2732 return NOTI_EX_ERROR_INVALID_PARAMETER;
2735 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2736 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2737 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2738 static_cast<NotificationError>(error));
2739 } catch (Exception &ex) {
2740 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2741 return NOTI_EX_ERROR_IO_ERROR;
2743 return NOTI_EX_ERROR_NONE;
2746 extern "C" EXPORT_API int noti_ex_manager_get_notification_count(
2747 noti_ex_manager_h handle, int *cnt) {
2749 if (handle == nullptr || cnt == nullptr) {
2750 LOGE("Invalid parameter");
2751 return NOTI_EX_ERROR_INVALID_PARAMETER;
2754 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2755 *cnt = stub->GetCount();
2756 } catch (Exception &ex) {
2757 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2758 return NOTI_EX_ERROR_IO_ERROR;
2760 return NOTI_EX_ERROR_NONE;
2763 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
2764 const char *id, float min, float current, float max) {
2767 if (handle == nullptr) {
2768 LOGE("Invalid parameter");
2769 return NOTI_EX_ERROR_INVALID_PARAMETER;
2773 p = new (std::nothrow) ProgressItem(id, min, current, max);
2775 p = new (std::nothrow) ProgressItem(min, current, max);
2778 LOGE("Out-of-memory");
2779 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2782 *handle = new Handle(shared_ptr<AbstractItem>(p));
2784 return NOTI_EX_ERROR_NONE;
2787 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
2788 noti_ex_item_h handle, float *current) {
2789 if (handle == nullptr || current == nullptr) {
2790 LOGE("Invalid parameter");
2791 return NOTI_EX_ERROR_INVALID_PARAMETER;
2794 Handle *h = static_cast<Handle*>(handle);
2795 if (!h->IsValidType(AbstractItem::Progress)) {
2796 LOGE("Invalid handle type");
2797 return NOTI_EX_ERROR_INVALID_PARAMETER;
2799 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2800 *current = p->GetCurrent();
2802 return NOTI_EX_ERROR_NONE;
2805 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
2806 noti_ex_item_h handle, float current) {
2807 if (handle == nullptr) {
2808 LOGE("Invalid parameter");
2809 return NOTI_EX_ERROR_INVALID_PARAMETER;
2812 Handle *h = static_cast<Handle*>(handle);
2813 if (!h->IsValidType(AbstractItem::Progress)) {
2814 LOGE("Invalid handle type");
2815 return NOTI_EX_ERROR_INVALID_PARAMETER;
2817 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2818 p->SetCurrent(current);
2820 return NOTI_EX_ERROR_NONE;
2823 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
2825 if (handle == nullptr || min == nullptr) {
2826 LOGE("Invalid parameter");
2827 return NOTI_EX_ERROR_INVALID_PARAMETER;
2830 Handle *h = static_cast<Handle*>(handle);
2831 if (!h->IsValidType(AbstractItem::Progress)) {
2832 LOGE("Invalid handle type");
2833 return NOTI_EX_ERROR_INVALID_PARAMETER;
2835 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2838 return NOTI_EX_ERROR_NONE;
2841 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
2843 if (handle == nullptr || max == nullptr) {
2844 LOGE("Invalid parameter");
2845 return NOTI_EX_ERROR_INVALID_PARAMETER;
2848 Handle *h = static_cast<Handle*>(handle);
2849 if (!h->IsValidType(AbstractItem::Progress)) {
2850 LOGE("Invalid handle type");
2851 return NOTI_EX_ERROR_INVALID_PARAMETER;
2853 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2856 return NOTI_EX_ERROR_NONE;
2859 extern "C" EXPORT_API int noti_ex_item_progress_get_type(noti_ex_item_h handle,
2861 if (handle == nullptr || type == nullptr) {
2862 LOGE("Invalid parameter");
2863 return NOTI_EX_ERROR_INVALID_PARAMETER;
2866 Handle *h = static_cast<Handle*>(handle);
2867 if (!h->IsValidType(AbstractItem::Progress)) {
2868 LOGE("Invalid handle type");
2869 return NOTI_EX_ERROR_INVALID_PARAMETER;
2871 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2872 *type = static_cast<noti_ex_item_progress_type_e>(p->GetProgressType());
2874 return NOTI_EX_ERROR_NONE;
2877 extern "C" EXPORT_API int noti_ex_item_progress_set_type(noti_ex_item_h handle,
2879 if (handle == nullptr) {
2880 LOGE("Invalid parameter");
2881 return NOTI_EX_ERROR_INVALID_PARAMETER;
2884 Handle *h = static_cast<Handle*>(handle);
2885 if (!h->IsValidType(AbstractItem::Progress)) {
2886 LOGE("Invalid handle type");
2887 return NOTI_EX_ERROR_INVALID_PARAMETER;
2889 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2890 p->SetProgressType(static_cast<ProgressItem::Type>(type));
2892 return NOTI_EX_ERROR_NONE;
2895 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
2896 noti_ex_reporter_events_s event_callbacks, void *data) {
2897 if (handle == nullptr) {
2898 LOGE("Invalid parameter");
2899 return NOTI_EX_ERROR_INVALID_PARAMETER;
2902 ReporterStub* stub = new (std::nothrow) ReporterStub(
2903 unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
2904 unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())));
2905 if (stub == nullptr) {
2906 LOGE("Fail to create manager");
2907 return NOTI_EX_ERROR_IO_ERROR;
2909 stub->SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo>(
2910 new ReporterCallbackInfo(event_callbacks, data)));
2912 *handle = static_cast<noti_ex_reporter_h>(stub);
2914 return NOTI_EX_ERROR_NONE;
2917 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
2918 if (handle == nullptr) {
2919 LOGE("Invalid parameter");
2920 return NOTI_EX_ERROR_INVALID_PARAMETER;
2922 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2924 return NOTI_EX_ERROR_NONE;
2927 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
2928 noti_ex_event_info_h info, noti_ex_error_e error) {
2929 if (handle == nullptr || info == nullptr) {
2930 LOGE("Invalid parameter");
2931 return NOTI_EX_ERROR_INVALID_PARAMETER;
2934 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2935 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2936 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2937 static_cast<NotificationError>(error));
2938 } catch (Exception &ex) {
2939 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2940 return NOTI_EX_ERROR_IO_ERROR;
2942 return NOTI_EX_ERROR_NONE;
2945 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
2946 noti_ex_item_h noti, int *request_id) {
2947 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2948 LOGE("Invalid parameter");
2949 return NOTI_EX_ERROR_INVALID_PARAMETER;
2952 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2953 Handle* h = static_cast<Handle*>(noti);
2954 if (h->GetPtr().get() == nullptr) {
2955 LOGE("Invalid noti reference can not be sended");
2956 return NOTI_EX_ERROR_INVALID_PARAMETER;
2958 *request_id = stub->Post(h->GetPtr());
2960 } catch (Exception &ex) {
2961 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2962 return NOTI_EX_ERROR_IO_ERROR;
2964 return NOTI_EX_ERROR_NONE;
2967 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
2968 noti_ex_item_h *noti_list, int count, int *request_id) {
2970 if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
2971 LOGE("Invalid parameter");
2972 return NOTI_EX_ERROR_INVALID_PARAMETER;
2975 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2976 list<shared_ptr<item::AbstractItem>> notiList;
2977 for (int i = 0; i < count; i++) {
2978 Handle* item = static_cast<Handle*>(noti_list[i]);
2979 notiList.push_back(item->GetPtr());
2981 *request_id = stub->Post(notiList);
2982 } catch (Exception &ex) {
2983 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2984 return NOTI_EX_ERROR_IO_ERROR;
2986 return NOTI_EX_ERROR_NONE;
2989 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
2990 noti_ex_item_h noti, int *request_id) {
2991 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2992 LOGE("Invalid parameter");
2993 return NOTI_EX_ERROR_INVALID_PARAMETER;
2996 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2997 Handle* item = static_cast<Handle*>(noti);
2998 if (item->GetPtr().get() == nullptr) {
2999 LOGE("Invalid noti reference can not be sended");
3000 return NOTI_EX_ERROR_INVALID_PARAMETER;
3002 *request_id = stub->Update(item->GetPtr());
3004 } catch (Exception &ex) {
3005 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3006 return NOTI_EX_ERROR_IO_ERROR;
3008 return NOTI_EX_ERROR_NONE;
3011 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
3012 noti_ex_item_h noti, int *request_id) {
3013 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3014 LOGE("Invalid parameter");
3015 return NOTI_EX_ERROR_INVALID_PARAMETER;
3018 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3019 Handle* item = static_cast<Handle*>(noti);
3020 if (item->GetPtr().get() == nullptr) {
3021 LOGE("Invalid noti reference can not be sended");
3022 return NOTI_EX_ERROR_INVALID_PARAMETER;
3024 *request_id = stub->Delete(item->GetPtr());
3026 } catch (Exception &ex) {
3027 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3028 return NOTI_EX_ERROR_IO_ERROR;
3030 return NOTI_EX_ERROR_NONE;
3033 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
3034 noti_ex_reporter_h handle, int *request_id) {
3035 if (handle == nullptr || request_id == nullptr) {
3036 LOGE("Invalid parameter");
3037 return NOTI_EX_ERROR_INVALID_PARAMETER;
3040 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3041 *request_id = stub->DeleteAll();
3042 } catch (Exception &ex) {
3043 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3044 return NOTI_EX_ERROR_IO_ERROR;
3046 return NOTI_EX_ERROR_NONE;
3049 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
3050 noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
3051 if (handle == nullptr || root_id == nullptr || item == nullptr) {
3052 LOGE("Invalid parameter");
3053 return NOTI_EX_ERROR_INVALID_PARAMETER;
3056 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3057 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
3058 if (ptr == nullptr) {
3059 LOGW("Not exist ID");
3061 return NOTI_EX_ERROR_NONE;
3063 *item = new Handle(ptr);
3064 } catch (Exception &ex) {
3065 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3066 return NOTI_EX_ERROR_IO_ERROR;
3068 return NOTI_EX_ERROR_NONE;
3071 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
3072 const char *id, const char *text, const char *hyperlink) {
3073 if (handle == nullptr || text == nullptr) {
3074 LOGE("Invalid parameter");
3075 return NOTI_EX_ERROR_INVALID_PARAMETER;
3084 p = new (std::nothrow) TextItem(id, std::string(text),
3085 std::string(hyperlink));
3087 p = new (std::nothrow) TextItem(id, std::string(text));
3090 LOGE("Out-of-memory");
3091 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3094 *handle = new Handle(shared_ptr<AbstractItem>(p));
3096 return NOTI_EX_ERROR_NONE;
3099 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
3100 const char *contents) {
3101 if (handle == nullptr || contents == nullptr) {
3102 LOGE("Invalid parameter");
3103 return NOTI_EX_ERROR_INVALID_PARAMETER;
3106 Handle* p = static_cast<Handle*>(handle);
3107 if (!p->IsValidType(AbstractItem::Text)) {
3108 LOGE("Invalid handle type");
3109 return NOTI_EX_ERROR_INVALID_PARAMETER;
3111 TextItem* ti = static_cast<TextItem*>(p->Get());
3112 ti->SetContents(std::string(contents));
3114 return NOTI_EX_ERROR_NONE;
3117 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
3119 if (handle == nullptr || contents == nullptr) {
3120 LOGE("Invalid parameter");
3121 return NOTI_EX_ERROR_INVALID_PARAMETER;
3124 Handle* p = static_cast<Handle*>(handle);
3125 if (!p->IsValidType(AbstractItem::Text)) {
3126 LOGE("Invalid handle type");
3127 return NOTI_EX_ERROR_INVALID_PARAMETER;
3130 TextItem* ti = static_cast<TextItem*>(p->Get());
3132 if (ti->GetMultiLanguage() != nullptr &&
3133 !ti->GetMultiLanguage()->GetTranslatedString().empty())
3134 str = ti->GetMultiLanguage()->GetTranslatedString();
3135 else if (!ti->GetContents().empty())
3136 str = ti->GetContents();
3138 *contents = strdup(str.c_str());
3139 if (*contents == nullptr) {
3140 LOGE("Out-of-memory");
3141 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3144 return NOTI_EX_ERROR_NONE;
3147 extern "C" EXPORT_API int noti_ex_item_text_get_hyperlink(
3148 noti_ex_item_h handle, char **hyper_link) {
3149 if (handle == nullptr || hyper_link == nullptr) {
3150 LOGE("Invalid parameter");
3151 return NOTI_EX_ERROR_INVALID_PARAMETER;
3154 Handle* p = static_cast<Handle*>(handle);
3155 if (!p->IsValidType(AbstractItem::Text)) {
3156 LOGE("Invalid handle type");
3157 return NOTI_EX_ERROR_INVALID_PARAMETER;
3159 TextItem* ti = static_cast<TextItem*>(p->Get());
3160 if (!ti->GetHyperLink().empty()) {
3161 *hyper_link = strdup(ti->GetHyperLink().c_str());
3162 if (*hyper_link == nullptr) {
3163 LOGE("Out-of-memory");
3164 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3167 *hyper_link = nullptr;
3170 return NOTI_EX_ERROR_NONE;
3173 extern "C" EXPORT_API int noti_ex_item_text_set_multi_language(
3174 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
3175 if (handle == nullptr) {
3176 LOGE("Invalid parameter");
3177 return NOTI_EX_ERROR_INVALID_PARAMETER;
3180 Handle* p = static_cast<Handle*>(handle);
3181 if (!p->IsValidType(AbstractItem::Text)) {
3182 LOGE("Invalid handle type");
3183 return NOTI_EX_ERROR_INVALID_PARAMETER;
3186 TextItem* ti = static_cast<TextItem*>(p->Get());
3187 if (multi == nullptr) {
3188 ti->SetMultiLanguage(nullptr);
3189 return NOTI_EX_ERROR_NONE;
3192 shared_ptr<MultiLanguage> mul_ptr =
3193 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
3194 ti->SetMultiLanguage(mul_ptr);
3195 ti->GetMultiLanguage()->UpdateString();
3197 return NOTI_EX_ERROR_NONE;
3200 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
3201 const char *id, time_t time) {
3204 if (handle == nullptr) {
3205 LOGE("Invalid parameter");
3206 return NOTI_EX_ERROR_INVALID_PARAMETER;
3211 p = new (std::nothrow) TimeItem(id, time);
3213 p = new (std::nothrow) TimeItem(time);
3215 p = new (std::nothrow) TimeItem();
3219 LOGE("Out-of-memory");
3220 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3223 *handle = new Handle(shared_ptr<AbstractItem>(p));
3225 return NOTI_EX_ERROR_NONE;
3228 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
3230 if (handle == nullptr || time == nullptr) {
3231 LOGE("Invalid parameter");
3232 return NOTI_EX_ERROR_INVALID_PARAMETER;
3234 Handle* h = static_cast<Handle*>(handle);
3235 if (!h->IsValidType(AbstractItem::Time)) {
3236 LOGE("Invalid handle type");
3237 return NOTI_EX_ERROR_INVALID_PARAMETER;
3239 TimeItem* p = static_cast<TimeItem*>(h->Get());
3240 *time = p->GetTime();
3242 return NOTI_EX_ERROR_NONE;
3245 extern "C" EXPORT_API int noti_ex_item_time_set_time(noti_ex_item_h handle,
3247 if (handle == nullptr) {
3248 LOGE("Invalid parameter");
3249 return NOTI_EX_ERROR_INVALID_PARAMETER;
3251 Handle* h = static_cast<Handle*>(handle);
3252 if (!h->IsValidType(AbstractItem::Time)) {
3253 LOGE("Invalid handle type");
3254 return NOTI_EX_ERROR_INVALID_PARAMETER;
3256 TimeItem* p = static_cast<TimeItem*>(h->Get());
3259 return NOTI_EX_ERROR_NONE;
3262 extern "C" EXPORT_API int noti_ex_action_visibility_create(
3263 noti_ex_action_h *handle, const char *extra) {
3264 if (handle == nullptr) {
3265 LOGE("Invalid parameter");
3266 return NOTI_EX_ERROR_INVALID_PARAMETER;
3269 string extra_str = "";
3271 extra_str = string(extra);
3273 shared_ptr<AbstractAction>* ptr = new (std::nothrow) shared_ptr<AbstractAction>(
3274 new (std::nothrow) VisibilityAction(extra_str));
3275 if (ptr == nullptr) {
3276 LOGE("Out-of-memory");
3277 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3282 return NOTI_EX_ERROR_NONE;
3285 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
3286 const char *id, bool visible) {
3287 if (handle == nullptr || id == nullptr) {
3288 LOGE("Invalid parameter");
3289 return NOTI_EX_ERROR_INVALID_PARAMETER;
3292 shared_ptr<AbstractAction>* ptr =
3293 static_cast<shared_ptr<AbstractAction>*>(handle);
3294 VisibilityAction* action = static_cast<VisibilityAction*>(ptr->get());
3295 action->SetVisibility(id, visible);
3297 return NOTI_EX_ERROR_NONE;
3300 extern "C" EXPORT_API int noti_ex_multi_lang_create(noti_ex_multi_lang_h* handle,
3301 const char* msgid, const char* format, ...) {
3302 if (handle == nullptr || msgid == nullptr || format == nullptr) {
3303 LOGE("Invalid parameter");
3304 return NOTI_EX_ERROR_INVALID_PARAMETER;
3307 const char* format_idx = format;
3310 va_start(args, format);
3311 while (*format_idx != '\0') {
3312 char* arg = nullptr;
3315 stringstream stream;
3316 if (*format_idx == '%') {
3317 switch (*(format_idx + 1)) {
3319 arg = va_arg(args, char *);
3320 arr.push_back(string(arg));
3323 arg_i = va_arg(args, int);
3324 arr.push_back(to_string(arg_i));
3327 arg_f = va_arg(args, double);
3328 stream << std::fixed << std::setprecision(2) << arg_f;
3329 arr.push_back(stream.str());
3337 MultiLanguage* p = new MultiLanguage(string(msgid), format, arr);
3339 LOGE("Out-of-memory");
3340 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3342 *handle = new shared_ptr<MultiLanguage>(p);
3344 return NOTI_EX_ERROR_NONE;
3347 extern "C" EXPORT_API int noti_ex_multi_lang_destroy(noti_ex_multi_lang_h handle) {
3348 if (handle == nullptr) {
3349 LOGE("Invalid parameter");
3350 return NOTI_EX_ERROR_INVALID_PARAMETER;
3353 shared_ptr<MultiLanguage>* mul_ptr =
3354 reinterpret_cast<shared_ptr<MultiLanguage>*>(handle);
3356 return NOTI_EX_ERROR_NONE;
3359 extern "C" EXPORT_API int noti_ex_item_get_private_id(
3360 noti_ex_item_h item, int64_t* private_id) {
3361 if (item == nullptr || private_id == nullptr) {
3362 LOGE("Invalid parameter");
3363 return NOTI_EX_ERROR_INVALID_PARAMETER;
3366 Handle* h = static_cast<Handle*>(item);
3367 *private_id = static_pointer_cast<IItemInfoInternal>(
3368 h->Get()->GetInfo())->GetPrivateId();
3370 return NOTI_EX_ERROR_NONE;
3373 extern "C" EXPORT_API int noti_ex_item_set_private_id(
3374 noti_ex_item_h item, int64_t priv_id) {
3375 if (item == nullptr) {
3376 LOGE("Invalid parameter");
3377 return NOTI_EX_ERROR_INVALID_PARAMETER;
3380 Handle* h = static_cast<Handle*>(item);
3381 static_pointer_cast<IItemInfoInternal>(
3382 h->Get()->GetInfo())->SetPrivateId(priv_id);
3384 return NOTI_EX_ERROR_NONE;
3387 extern "C" EXPORT_API int noti_ex_item_free_string_list(char** list, int count) {
3388 if (list == nullptr) {
3389 LOGE("Invalid parameter");
3390 return NOTI_EX_ERROR_INVALID_PARAMETER;
3393 LOGI("Free strings (%d)", count);
3394 for (int i = 0; i < count; i++)
3398 return NOTI_EX_ERROR_NONE;
3401 extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h handle) {
3402 if (handle == nullptr) {
3403 LOGE("Invalid parameter");
3404 return NOTI_EX_ERROR_INVALID_PARAMETER;
3406 Handle* h = static_cast<Handle*>(handle);
3407 if (!h->IsValidType(AbstractItem::Group)) {
3408 LOGE("Invalid handle type");
3409 return NOTI_EX_ERROR_INVALID_PARAMETER;
3411 GroupItem* p = static_cast<GroupItem*>(h->Get());
3412 p->RemoveChildren();
3414 return NOTI_EX_ERROR_NONE;