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());
340 *app_control = action->GetAppControl();
342 return NOTI_EX_ERROR_NONE;
345 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
346 const char *id, const char *title) {
349 if (handle == nullptr || title == nullptr) {
350 LOGE("Invalid parameter");
351 return NOTI_EX_ERROR_INVALID_PARAMETER;
355 p = new (std::nothrow) ButtonItem(id, title);
357 p = new (std::nothrow) ButtonItem(title);
360 LOGE("Out-of-memory");
361 return NOTI_EX_ERROR_OUT_OF_MEMORY;
363 *handle = new Handle(shared_ptr<AbstractItem>(p));
365 return NOTI_EX_ERROR_NONE;
368 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
370 if (handle == nullptr || title == nullptr) {
371 LOGE("Invalid parameter");
372 return NOTI_EX_ERROR_INVALID_PARAMETER;
375 Handle* sp = static_cast<Handle*>(handle);
376 if (!sp->IsValidType(AbstractItem::Button)) {
377 LOGE("Invalid handle type");
378 return NOTI_EX_ERROR_INVALID_PARAMETER;
381 ButtonItem* p = static_cast<ButtonItem*>(sp->Get());
383 if (p->GetMultiLanguage() != nullptr &&
384 !p->GetMultiLanguage()->GetTranslatedString().empty())
385 str = p->GetMultiLanguage()->GetTranslatedString();
386 else if (!p->GetTitle().empty())
389 *title = strdup(str.c_str());
390 if (*title == nullptr) {
391 LOGE("Out-of-memory");
392 return NOTI_EX_ERROR_OUT_OF_MEMORY;
395 return NOTI_EX_ERROR_NONE;
398 extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title(
399 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
400 if (handle == nullptr) {
401 LOGE("Invalid parameter");
402 return NOTI_EX_ERROR_INVALID_PARAMETER;
405 Handle* p = static_cast<Handle*>(handle);
406 if (!p->IsValidType(AbstractItem::Button)) {
407 LOGE("Invalid handle type");
408 return NOTI_EX_ERROR_INVALID_PARAMETER;
411 ButtonItem* bi = static_cast<ButtonItem*>(p->Get());
412 if (multi == nullptr) {
413 bi->SetMultiLanguage(nullptr);
414 return NOTI_EX_ERROR_NONE;
417 shared_ptr<MultiLanguage> mul_ptr =
418 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
420 mul_ptr->UpdateString();
421 bi->SetMultiLanguage(mul_ptr);
423 return NOTI_EX_ERROR_NONE;
426 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
427 noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
428 noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
429 noti_ex_item_chat_message_type_e message_type) {
430 if (handle == nullptr || (text == nullptr && image == nullptr)
431 || name == nullptr || time == nullptr
432 || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
433 LOGE("Invalid parameter");
434 return NOTI_EX_ERROR_INVALID_PARAMETER;
437 auto* p = new (std::nothrow) ChatMessageItem(id,
438 dynamic_pointer_cast<TextItem>(static_cast<Handle*>(name)->GetPtr()),
439 text == nullptr ? nullptr
440 : dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
441 image == nullptr ? nullptr
442 : dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
443 dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
444 static_cast<ChatMessageItem::Type>(message_type));
446 LOGE("Out-of-memory");
447 return NOTI_EX_ERROR_OUT_OF_MEMORY;
450 *handle = new Handle(shared_ptr<AbstractItem>(p));
452 return NOTI_EX_ERROR_NONE;
455 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
456 noti_ex_item_h handle, noti_ex_item_h *name) {
457 if (handle == nullptr || name == nullptr) {
458 LOGE("Invalid parameter");
459 return NOTI_EX_ERROR_INVALID_PARAMETER;
461 Handle* h = static_cast<Handle*>(handle);
462 if (!h->IsValidType(AbstractItem::ChatMessage)) {
463 LOGE("Invalid handle type");
464 return NOTI_EX_ERROR_INVALID_PARAMETER;
466 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
467 if (p->GetNameItem().GetType() == AbstractItem::NullObject)
470 *name = new Handle(&(p->GetNameItem()));
472 return NOTI_EX_ERROR_NONE;
475 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
476 noti_ex_item_h handle, noti_ex_item_h *text) {
477 if (handle == nullptr || text == nullptr) {
478 LOGE("Invalid parameter");
479 return NOTI_EX_ERROR_INVALID_PARAMETER;
482 Handle* h = static_cast<Handle*>(handle);
483 if (!h->IsValidType(AbstractItem::ChatMessage)) {
484 LOGE("Invalid handle type");
485 return NOTI_EX_ERROR_INVALID_PARAMETER;
487 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
488 if (p->GetTextItem().GetType() == AbstractItem::NullObject)
491 *text = new Handle(&(p->GetTextItem()));
493 return NOTI_EX_ERROR_NONE;
496 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
497 noti_ex_item_h handle, noti_ex_item_h *image) {
498 if (handle == nullptr || image == nullptr) {
499 LOGE("Invalid parameter");
500 return NOTI_EX_ERROR_INVALID_PARAMETER;
503 Handle* h = static_cast<Handle*>(handle);
504 if (!h->IsValidType(AbstractItem::ChatMessage)) {
505 LOGE("Invalid handle type");
506 return NOTI_EX_ERROR_INVALID_PARAMETER;
508 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
509 if (p->GetImageItem().GetType() == AbstractItem::NullObject)
512 *image = new Handle(&(p->GetImageItem()));
514 return NOTI_EX_ERROR_NONE;
517 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
518 noti_ex_item_h handle, noti_ex_item_h *time) {
519 if (handle == nullptr || time == nullptr) {
520 LOGE("Invalid parameter");
521 return NOTI_EX_ERROR_INVALID_PARAMETER;
524 Handle* h = static_cast<Handle*>(handle);
525 if (!h->IsValidType(AbstractItem::ChatMessage)) {
526 LOGE("Invalid handle type");
527 return NOTI_EX_ERROR_INVALID_PARAMETER;
529 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
530 if (p->GetTimeItem().GetType() == AbstractItem::NullObject)
533 *time = new Handle(&(p->GetTimeItem()));
535 return NOTI_EX_ERROR_NONE;
538 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
539 noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
540 if (handle == nullptr || message_type == nullptr) {
541 LOGE("Invalid parameter");
542 return NOTI_EX_ERROR_INVALID_PARAMETER;
545 Handle* h = static_cast<Handle*>(handle);
546 if (!h->IsValidType(AbstractItem::ChatMessage)) {
547 LOGE("Invalid handle type");
548 return NOTI_EX_ERROR_INVALID_PARAMETER;
550 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
551 *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
553 return NOTI_EX_ERROR_NONE;
556 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
557 const char *id, const char *title, bool checked) {
560 if (handle == nullptr || title == nullptr) {
561 LOGE("Invalid parameter");
562 return NOTI_EX_ERROR_INVALID_PARAMETER;
565 p = new (std::nothrow) CheckBoxItem(id, title, checked);
567 LOGE("Out-of-memory");
568 return NOTI_EX_ERROR_OUT_OF_MEMORY;
571 *handle = new Handle(shared_ptr<AbstractItem>(p));
573 return NOTI_EX_ERROR_NONE;
576 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
578 if (handle == nullptr || title == nullptr) {
579 LOGE("Invalid parameter");
580 return NOTI_EX_ERROR_INVALID_PARAMETER;
582 Handle* h = static_cast<Handle*>(handle);
583 if (!h->IsValidType(AbstractItem::CheckBox)) {
584 LOGE("Invalid handle type");
585 return NOTI_EX_ERROR_INVALID_PARAMETER;
588 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
590 if (p->GetMultiLanguage() != nullptr &&
591 !p->GetMultiLanguage()->GetTranslatedString().empty())
592 str = p->GetMultiLanguage()->GetTranslatedString();
593 else if (!p->GetTitle().empty())
596 *title = strdup(str.c_str());
597 if (*title == nullptr) {
598 LOGE("Out-of-memory");
599 return NOTI_EX_ERROR_OUT_OF_MEMORY;
602 return NOTI_EX_ERROR_NONE;
605 extern "C" EXPORT_API int noti_ex_item_checkbox_set_multi_language_title(
606 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
607 if (handle == nullptr) {
608 LOGE("Invalid parameter");
609 return NOTI_EX_ERROR_INVALID_PARAMETER;
612 Handle* p = static_cast<Handle*>(handle);
613 if (!p->IsValidType(AbstractItem::CheckBox)) {
614 LOGE("Invalid handle type");
615 return NOTI_EX_ERROR_INVALID_PARAMETER;
618 CheckBoxItem* ci = static_cast<CheckBoxItem*>(p->Get());
619 if (multi == nullptr) {
620 ci->SetMultiLanguage(nullptr);
621 return NOTI_EX_ERROR_NONE;
624 shared_ptr<MultiLanguage> mul_ptr =
625 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
626 mul_ptr->UpdateString();
627 ci->SetMultiLanguage(mul_ptr);
629 return NOTI_EX_ERROR_NONE;
632 extern "C" EXPORT_API int noti_ex_item_checkbox_get_check_state(
633 noti_ex_item_h handle, bool *checked) {
634 if (handle == nullptr || checked == nullptr) {
635 LOGE("Invalid parameter");
636 return NOTI_EX_ERROR_INVALID_PARAMETER;
638 Handle* h = static_cast<Handle*>(handle);
639 if (!h->IsValidType(AbstractItem::CheckBox)) {
640 LOGE("Invalid handle type");
641 return NOTI_EX_ERROR_INVALID_PARAMETER;
643 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
644 *checked = p->IsChecked();
646 return NOTI_EX_ERROR_NONE;
649 extern "C" EXPORT_API int noti_ex_item_checkbox_set_check_state(
650 noti_ex_item_h handle, bool checked) {
651 if (handle == nullptr) {
652 LOGE("Invalid parameter");
653 return NOTI_EX_ERROR_INVALID_PARAMETER;
656 Handle* h = static_cast<Handle*>(handle);
657 if (!h->IsValidType(AbstractItem::CheckBox)) {
658 LOGE("Invalid handle type");
659 return NOTI_EX_ERROR_INVALID_PARAMETER;
662 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
663 p->SetChecked(checked);
665 return NOTI_EX_ERROR_NONE;
668 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
672 if (handle == nullptr) {
673 LOGE("Invalid parameter");
674 return NOTI_EX_ERROR_INVALID_PARAMETER;
677 p = new (std::nothrow) EntryItem(id);
679 LOGE("Out-of-memory");
680 return NOTI_EX_ERROR_OUT_OF_MEMORY;
683 *handle = new Handle(shared_ptr<AbstractItem>(p));
685 return NOTI_EX_ERROR_NONE;
688 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
690 if (handle == nullptr || text == nullptr) {
691 LOGE("Invalid parameter");
692 return NOTI_EX_ERROR_INVALID_PARAMETER;
695 Handle* h = static_cast<Handle*>(handle);
696 if (!h->IsValidType(AbstractItem::Entry)) {
697 LOGE("Invalid handle type");
698 return NOTI_EX_ERROR_INVALID_PARAMETER;
701 EntryItem* p = static_cast<EntryItem*>(h->Get());
703 if (p->GetMultiLanguage() != nullptr &&
704 !p->GetMultiLanguage()->GetTranslatedString().empty())
705 str = p->GetMultiLanguage()->GetTranslatedString();
706 else if (!p->GetText().empty())
709 *text = strdup(str.c_str());
710 if (*text == nullptr) {
711 LOGE("Out-of-memory");
712 return NOTI_EX_ERROR_OUT_OF_MEMORY;
715 return NOTI_EX_ERROR_NONE;
718 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
720 if (handle == nullptr || text == nullptr) {
721 LOGE("Invalid parameter");
722 return NOTI_EX_ERROR_INVALID_PARAMETER;
724 Handle* h = static_cast<Handle*>(handle);
725 if (!h->IsValidType(AbstractItem::Entry)) {
726 LOGE("Invalid handle type");
727 return NOTI_EX_ERROR_INVALID_PARAMETER;
729 EntryItem* p = static_cast<EntryItem*>(h->Get());
730 p->SetText(std::string(text));
732 return NOTI_EX_ERROR_NONE;
735 extern "C" EXPORT_API int noti_ex_item_entry_set_multi_language(
736 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
737 if (handle == nullptr) {
738 LOGE("Invalid parameter");
739 return NOTI_EX_ERROR_INVALID_PARAMETER;
742 Handle* p = static_cast<Handle*>(handle);
743 if (!p->IsValidType(AbstractItem::Entry)) {
744 LOGE("Invalid handle type");
745 return NOTI_EX_ERROR_INVALID_PARAMETER;
748 EntryItem* ei = static_cast<EntryItem*>(p->Get());
749 if (multi == nullptr) {
750 ei->SetMultiLanguage(nullptr);
751 return NOTI_EX_ERROR_NONE;
754 shared_ptr<MultiLanguage> mul_ptr =
755 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
756 ei->SetMultiLanguage(mul_ptr);
757 ei->GetMultiLanguage()->UpdateString();
759 return NOTI_EX_ERROR_NONE;
762 extern "C" EXPORT_API int noti_ex_event_info_clone(noti_ex_event_info_h handle,
763 noti_ex_event_info_h* cloned_handle) {
764 if (handle == nullptr || cloned_handle == nullptr) {
765 LOGE("Invalid parameter");
766 return NOTI_EX_ERROR_INVALID_PARAMETER;
769 Bundle cloned = static_cast<EventInfo*>(handle)->Serialize();
770 EventInfo* info = new EventInfo(cloned);
771 *cloned_handle = info;
772 return NOTI_EX_ERROR_NONE;
775 extern "C" EXPORT_API int noti_ex_event_info_destroy(
776 noti_ex_event_info_h handle) {
777 if (handle == nullptr) {
778 LOGE("Invalid parameter");
779 return NOTI_EX_ERROR_INVALID_PARAMETER;
781 EventInfo* info = static_cast<EventInfo*>(handle);
783 return NOTI_EX_ERROR_NONE;
786 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
787 noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
788 if (handle == nullptr || event_type == nullptr) {
789 LOGE("Invalid parameter");
790 return NOTI_EX_ERROR_INVALID_PARAMETER;
792 EventInfo* info = static_cast<EventInfo*>(handle);
793 *event_type = static_cast<noti_ex_event_info_type_e>(info->GetEventType());
795 return NOTI_EX_ERROR_NONE;
798 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
799 noti_ex_event_info_h handle, char **owner) {
800 if (handle == nullptr || owner == nullptr) {
801 LOGE("Invalid parameter");
802 return NOTI_EX_ERROR_INVALID_PARAMETER;
804 EventInfo* info = static_cast<EventInfo*>(handle);
805 *owner = strdup(info->GetOwner().c_str());
806 return NOTI_EX_ERROR_NONE;
809 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
810 noti_ex_event_info_h handle, char **channel) {
811 if (handle == nullptr || channel == nullptr) {
812 LOGE("Invalid parameter");
813 return NOTI_EX_ERROR_INVALID_PARAMETER;
815 EventInfo* info = static_cast<EventInfo*>(handle);
816 *channel = strdup(info->GetChannel().c_str());
817 return NOTI_EX_ERROR_NONE;
820 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
821 noti_ex_event_info_h handle, char **item_id) {
822 if (handle == nullptr || item_id == nullptr) {
823 LOGE("Invalid parameter");
824 return NOTI_EX_ERROR_INVALID_PARAMETER;
826 EventInfo* info = static_cast<EventInfo*>(handle);
827 *item_id = strdup(info->GetItemId().c_str());
828 return NOTI_EX_ERROR_NONE;
831 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
832 noti_ex_event_info_h handle, int *req_id) {
833 if (handle == nullptr || req_id == nullptr) {
834 LOGE("Invalid parameter");
835 return NOTI_EX_ERROR_INVALID_PARAMETER;
837 EventInfo* info = static_cast<EventInfo*>(handle);
838 *req_id = info->GetRequestId();
839 return NOTI_EX_ERROR_NONE;
842 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
846 if (handle == nullptr) {
847 LOGE("Invalid parameter");
848 return NOTI_EX_ERROR_INVALID_PARAMETER;
852 p = new (std::nothrow) GroupItem(id);
854 p = new (std::nothrow) GroupItem();
857 LOGE("Out-of-memory");
858 return NOTI_EX_ERROR_OUT_OF_MEMORY;
861 *handle = new Handle(shared_ptr<AbstractItem>(p));
863 return NOTI_EX_ERROR_NONE;
866 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
868 if (handle == nullptr) {
869 LOGE("Invalid parameter");
870 return NOTI_EX_ERROR_INVALID_PARAMETER;
872 Handle* h = static_cast<Handle*>(handle);
873 if (!h->IsValidType(AbstractItem::Group)) {
874 LOGE("Invalid handle type");
875 return NOTI_EX_ERROR_INVALID_PARAMETER;
877 GroupItem* p = static_cast<GroupItem*>(h->Get());
878 p->SetDirection(vertical);
880 return NOTI_EX_ERROR_NONE;
883 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
885 if (handle == nullptr) {
886 LOGE("Invalid parameter");
887 return NOTI_EX_ERROR_INVALID_PARAMETER;
889 Handle* h = static_cast<Handle*>(handle);
890 if (!h->IsValidType(AbstractItem::Group)) {
891 LOGE("Invalid handle type");
892 return NOTI_EX_ERROR_INVALID_PARAMETER;
894 GroupItem* p = static_cast<GroupItem*>(h->Get());
895 *vertical = p->IsVertical();
897 return NOTI_EX_ERROR_NONE;
900 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
902 if (handle == nullptr) {
903 LOGE("Invalid parameter");
904 return NOTI_EX_ERROR_INVALID_PARAMETER;
906 Handle* h = static_cast<Handle*>(handle);
907 if (!h->IsValidType(AbstractItem::Group)) {
908 LOGE("Invalid handle type");
909 return NOTI_EX_ERROR_INVALID_PARAMETER;
911 GroupItem* p = static_cast<GroupItem*>(h->Get());
912 if (!p->GetAppLabel().empty()) {
913 *label = strdup(p->GetAppLabel().c_str());
914 if (*label == nullptr) {
915 LOGE("Out-of-memory");
916 return NOTI_EX_ERROR_OUT_OF_MEMORY;
920 return NOTI_EX_ERROR_NONE;
923 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
924 noti_ex_item_h child) {
925 if (handle == nullptr || child == nullptr) {
926 LOGE("Invalid parameter");
927 return NOTI_EX_ERROR_INVALID_PARAMETER;
929 Handle* h = static_cast<Handle*>(handle);
930 if (!h->IsValidType(AbstractItem::Group)) {
931 LOGE("Invalid handle type");
932 return NOTI_EX_ERROR_INVALID_PARAMETER;
934 auto p = static_cast<GroupItem*>(h->Get());
935 p->AddChild((static_cast<Handle*>(child))->GetPtr());
937 return NOTI_EX_ERROR_NONE;
940 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
941 const char *item_id) {
942 if (handle == nullptr || item_id == nullptr) {
943 LOGE("Invalid parameter");
944 return NOTI_EX_ERROR_INVALID_PARAMETER;
946 Handle* h = static_cast<Handle*>(handle);
947 if (!h->IsValidType(AbstractItem::Group)) {
948 LOGE("Invalid handle type");
949 return NOTI_EX_ERROR_INVALID_PARAMETER;
951 GroupItem* p = static_cast<GroupItem*>(h->Get());
952 p->RemoveChild(std::string(item_id));
954 return NOTI_EX_ERROR_NONE;
957 extern "C" EXPORT_API int noti_ex_item_group_foreach_child(noti_ex_item_h handle,
958 noti_ex_item_group_foreach_child_cb callback, void *data) {
959 if (handle == nullptr || callback == nullptr) {
960 LOGE("Invalid parameter");
961 return NOTI_EX_ERROR_INVALID_PARAMETER;
964 Handle* h = static_cast<Handle*>(handle);
965 if (!h->IsValidType(AbstractItem::Group)) {
966 LOGE("Invalid handle type");
967 return NOTI_EX_ERROR_INVALID_PARAMETER;
969 GroupItem* p = static_cast<GroupItem*>(h->Get());
970 list<shared_ptr<AbstractItem>> children = p->GetChildren();
971 LOGI("Retrive (%zd)", children.size());
972 for (auto i : children) {
974 static_cast<noti_ex_item_h>(new Handle(i)), data);
975 if (ret != NOTI_EX_ERROR_NONE) {
976 LOGW("callback return (%d) stop foreach", ret);
981 return NOTI_EX_ERROR_NONE;
984 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
985 const char *id, const char *image_path) {
988 if (handle == nullptr || image_path == nullptr) {
989 LOGE("Invalid parameter");
990 return NOTI_EX_ERROR_INVALID_PARAMETER;
994 p = new (std::nothrow) ImageItem(id, image_path);
996 p = new (std::nothrow) ImageItem(image_path);
999 LOGE("Out-of-memory");
1000 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1003 *handle = new Handle(shared_ptr<AbstractItem>(p));
1005 return NOTI_EX_ERROR_NONE;
1008 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
1009 noti_ex_item_h handle, char **image_path) {
1010 if (handle == nullptr || image_path == nullptr) {
1011 LOGE("Invalid parameter");
1012 return NOTI_EX_ERROR_INVALID_PARAMETER;
1014 Handle* h = static_cast<Handle*>(handle);
1015 if (!h->IsValidType(AbstractItem::Image)) {
1016 LOGE("Invalid handle type");
1017 return NOTI_EX_ERROR_INVALID_PARAMETER;
1019 ImageItem* p = static_cast<ImageItem*>(h->Get());
1020 if (!p->GetImagePath().empty()) {
1021 *image_path = strdup(p->GetImagePath().c_str());
1022 if (*image_path == nullptr) {
1023 LOGE("Out-of-memory");
1024 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1027 *image_path = nullptr;
1030 return NOTI_EX_ERROR_NONE;
1033 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
1034 noti_ex_item_h *handle, const char *id) {
1035 InputSelectorItem* p;
1037 if (handle == nullptr) {
1038 LOGE("Invalid parameter");
1039 return NOTI_EX_ERROR_INVALID_PARAMETER;
1043 p = new (std::nothrow) InputSelectorItem(id);
1045 p = new (std::nothrow) InputSelectorItem();
1048 LOGE("Out-of-memory");
1049 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1052 *handle = new Handle(shared_ptr<AbstractItem>(p));
1054 return NOTI_EX_ERROR_NONE;
1057 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
1058 noti_ex_item_h handle, char ***contents_list, int *count) {
1059 if (handle == nullptr || contents_list == nullptr || count == nullptr) {
1060 LOGE("Invalid parameter");
1061 return NOTI_EX_ERROR_INVALID_PARAMETER;
1064 Handle* h = static_cast<Handle*>(handle);
1065 if (!h->IsValidType(AbstractItem::InputSelector)) {
1066 LOGE("Invalid handle type");
1067 return NOTI_EX_ERROR_INVALID_PARAMETER;
1070 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1071 vector<shared_ptr<MultiLanguage>> arr = p->GetMultiLanguageArr();
1072 list<string> contents;
1073 if (arr.size() == 0) {
1074 contents = p->GetContents();
1076 for (auto& i : arr) {
1077 contents.push_back(i->GetTranslatedString());
1081 char **list = (char**)calloc(contents.size(), sizeof(char*));
1082 if (list == nullptr) {
1083 LOGE("Out of memory");
1084 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1088 for (auto& i : contents) {
1089 list[idx] = strdup(i.c_str());
1090 if (list[idx] == nullptr) {
1091 __noti_ex_free_str_array(list, idx);
1092 LOGE("Out of memory");
1093 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1098 *count = contents.size();
1099 *contents_list = list;
1101 return NOTI_EX_ERROR_NONE;
1104 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
1105 noti_ex_item_h handle, const char **contents, int count) {
1106 if (handle == nullptr || contents == nullptr) {
1107 LOGE("Invalid parameter");
1108 return NOTI_EX_ERROR_INVALID_PARAMETER;
1111 list<string> new_contents;
1112 Handle* h = static_cast<Handle*>(handle);
1113 if (!h->IsValidType(AbstractItem::InputSelector)) {
1114 LOGE("Invalid handle type");
1115 return NOTI_EX_ERROR_INVALID_PARAMETER;
1117 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1118 for (int i = 0; i < count; i++) {
1119 new_contents.push_back(contents[i]);
1121 p->SetContents(move(new_contents));
1123 return NOTI_EX_ERROR_NONE;
1126 extern "C" EXPORT_API int noti_ex_item_input_selector_set_multi_language_contents(
1127 noti_ex_item_h handle, noti_ex_multi_lang_h* multi_language_list, int count) {
1128 if (handle == nullptr) {
1129 LOGE("Invalid parameter");
1130 return NOTI_EX_ERROR_INVALID_PARAMETER;
1133 Handle* p = static_cast<Handle*>(handle);
1134 if (!p->IsValidType(AbstractItem::InputSelector)) {
1135 LOGE("Invalid handle type");
1136 return NOTI_EX_ERROR_INVALID_PARAMETER;
1139 vector<shared_ptr<MultiLanguage>> m_list;
1140 for (int i = 0; i < count; i++) {
1141 shared_ptr<MultiLanguage> mul_ptr =
1142 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi_language_list[i]);
1143 mul_ptr->UpdateString();
1144 m_list.push_back(mul_ptr);
1147 InputSelectorItem* input = static_cast<InputSelectorItem*>(p->Get());
1148 input->SetMultiLanguage(m_list);
1150 return NOTI_EX_ERROR_NONE;
1153 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
1154 unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
1155 if (handle == nullptr) {
1156 LOGE("Invalid parameter");
1157 return NOTI_EX_ERROR_INVALID_PARAMETER;
1160 auto* ptr = new (std::nothrow) shared_ptr<Color>(
1161 new (std::nothrow) Color(a, r, g, b));
1162 if (ptr == nullptr || ptr->get() == nullptr) {
1163 LOGE("Out-of-memory");
1164 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1169 return NOTI_EX_ERROR_NONE;
1172 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
1173 if (handle == nullptr) {
1174 LOGE("Invalid parameter");
1175 return NOTI_EX_ERROR_INVALID_PARAMETER;
1178 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1181 return NOTI_EX_ERROR_NONE;
1184 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
1185 unsigned char *val) {
1186 if (handle == nullptr || val == nullptr) {
1187 LOGE("Invalid parameter");
1188 return NOTI_EX_ERROR_INVALID_PARAMETER;
1191 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1192 *val = (*p)->GetAVal();
1194 return NOTI_EX_ERROR_NONE;
1197 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
1198 unsigned char *val) {
1199 if (handle == nullptr || val == nullptr) {
1200 LOGE("Invalid parameter");
1201 return NOTI_EX_ERROR_INVALID_PARAMETER;
1204 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1205 *val = (*p)->GetRVal();
1207 return NOTI_EX_ERROR_NONE;
1210 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
1211 unsigned char *val) {
1212 if (handle == nullptr || val == nullptr) {
1213 LOGE("Invalid parameter");
1214 return NOTI_EX_ERROR_INVALID_PARAMETER;
1217 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1218 *val = (*p)->GetGVal();
1220 return NOTI_EX_ERROR_NONE;
1223 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
1224 unsigned char *val) {
1225 if (handle == nullptr || val == nullptr) {
1226 LOGE("Invalid parameter");
1227 return NOTI_EX_ERROR_INVALID_PARAMETER;
1230 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1231 *val = (*p)->GetBVal();
1233 return NOTI_EX_ERROR_NONE;
1236 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
1237 int left, int top, int right, int bottom) {
1238 if (handle == nullptr) {
1239 LOGE("Invalid parameter");
1240 return NOTI_EX_ERROR_INVALID_PARAMETER;
1243 auto* ptr = new (std::nothrow) shared_ptr<Padding>(
1244 new (std::nothrow) Padding(left, top, right, bottom));
1245 if (ptr == nullptr || ptr->get() == nullptr) {
1246 LOGE("Out-of-memory");
1247 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1252 return NOTI_EX_ERROR_NONE;
1255 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
1256 if (handle == nullptr) {
1257 LOGE("Invalid parameter");
1258 return NOTI_EX_ERROR_INVALID_PARAMETER;
1261 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1264 return NOTI_EX_ERROR_NONE;
1267 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
1269 if (handle == nullptr || val == nullptr) {
1270 LOGE("Invalid parameter");
1271 return NOTI_EX_ERROR_INVALID_PARAMETER;
1274 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1275 *val = (*p)->GetLeft();
1277 return NOTI_EX_ERROR_NONE;
1280 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
1282 if (handle == nullptr || val == nullptr) {
1283 LOGE("Invalid parameter");
1284 return NOTI_EX_ERROR_INVALID_PARAMETER;
1287 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1288 *val = (*p)->GetTop();
1290 return NOTI_EX_ERROR_NONE;
1293 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
1295 if (handle == nullptr || val == nullptr) {
1296 LOGE("Invalid parameter");
1297 return NOTI_EX_ERROR_INVALID_PARAMETER;
1300 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1301 *val = (*p)->GetRight();
1303 return NOTI_EX_ERROR_NONE;
1306 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
1308 if (handle == nullptr || val == nullptr) {
1309 LOGE("Invalid parameter");
1310 return NOTI_EX_ERROR_INVALID_PARAMETER;
1313 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1314 *val = (*p)->GetBottom();
1316 return NOTI_EX_ERROR_NONE;
1319 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
1320 int x, int y, int w, int h) {
1321 if (handle == nullptr) {
1322 LOGE("Invalid parameter");
1323 return NOTI_EX_ERROR_INVALID_PARAMETER;
1326 auto* ptr = new (std::nothrow) shared_ptr<Geometry>(
1327 new (std::nothrow) Geometry(x, y, w, h));
1328 if (ptr == nullptr || ptr->get() == nullptr) {
1329 LOGE("Out-of-memory");
1330 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1335 return NOTI_EX_ERROR_NONE;
1338 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
1339 if (handle == nullptr) {
1340 LOGE("Invalid parameter");
1341 return NOTI_EX_ERROR_INVALID_PARAMETER;
1344 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1347 return NOTI_EX_ERROR_NONE;
1350 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
1352 if (handle == nullptr || val == nullptr) {
1353 LOGE("Invalid parameter");
1354 return NOTI_EX_ERROR_INVALID_PARAMETER;
1357 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1358 *val = (*p)->GetX();
1360 return NOTI_EX_ERROR_NONE;
1363 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
1365 if (handle == nullptr || val == nullptr) {
1366 LOGE("Invalid parameter");
1367 return NOTI_EX_ERROR_INVALID_PARAMETER;
1370 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1371 *val = (*p)->GetY();
1373 return NOTI_EX_ERROR_NONE;
1376 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
1378 if (handle == nullptr || val == nullptr) {
1379 LOGE("Invalid parameter");
1380 return NOTI_EX_ERROR_INVALID_PARAMETER;
1383 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1384 *val = (*p)->GetWidth();
1386 return NOTI_EX_ERROR_NONE;
1389 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
1391 if (handle == nullptr || val == nullptr) {
1392 LOGE("Invalid parameter");
1393 return NOTI_EX_ERROR_INVALID_PARAMETER;
1396 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1397 *val = (*p)->GetHeight();
1399 return NOTI_EX_ERROR_NONE;
1402 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
1403 noti_ex_color_h color,
1404 noti_ex_padding_h padding,
1405 noti_ex_geometry_h geometry) {
1406 if (handle == nullptr) {
1407 LOGE("Invalid parameter");
1408 return NOTI_EX_ERROR_INVALID_PARAMETER;
1411 shared_ptr<Color> col = (color == nullptr) ?
1412 nullptr : *(static_cast<shared_ptr<Color>*>(color));
1413 shared_ptr<Padding> padd = (padding == nullptr) ?
1414 nullptr : *(static_cast<shared_ptr<Padding>*>(padding));
1415 shared_ptr<Geometry> geo = (geometry == nullptr) ?
1416 nullptr : *(static_cast<shared_ptr<Geometry>*>(geometry));
1418 auto* ptr = new (std::nothrow) shared_ptr<Style>(
1419 new (std::nothrow) Style(col, padd, geo));
1420 if (ptr == nullptr || ptr->get() == nullptr) {
1421 LOGE("Out-of-memory");
1422 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1427 return NOTI_EX_ERROR_NONE;
1430 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
1431 if (handle == nullptr) {
1432 LOGE("Invalid parameter");
1433 return NOTI_EX_ERROR_INVALID_PARAMETER;
1436 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1439 return NOTI_EX_ERROR_NONE;
1442 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
1443 noti_ex_padding_h *padding) {
1444 if (handle == nullptr || padding == nullptr) {
1445 LOGE("Invalid parameter");
1446 return NOTI_EX_ERROR_INVALID_PARAMETER;
1449 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1450 if ((*p)->GetPadding() == nullptr) {
1451 LOGW("Padding info is null");
1452 return NOTI_EX_ERROR_INVALID_PARAMETER;
1455 shared_ptr<Padding>* padd = new (std::nothrow) shared_ptr<Padding>(
1456 new (std::nothrow) Padding(*((*p)->GetPadding())));
1457 if (padd == nullptr || padd->get() == nullptr) {
1458 LOGE("Out-of-memory");
1460 return NOTI_EX_ERROR_NONE;
1465 return NOTI_EX_ERROR_NONE;
1469 extern "C" EXPORT_API int noti_ex_style_set_padding(noti_ex_style_h handle,
1470 noti_ex_padding_h padding) {
1471 if (handle == nullptr) {
1472 LOGE("Invalid parameter");
1473 return NOTI_EX_ERROR_INVALID_PARAMETER;
1476 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1477 if (padding == nullptr) {
1478 (*p)->SetPadding(nullptr);
1479 return NOTI_EX_ERROR_NONE;
1482 shared_ptr<Padding>* padd = static_cast<shared_ptr<Padding>*>(padding);
1483 (*p)->SetPadding(*padd);
1485 return NOTI_EX_ERROR_NONE;
1488 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
1489 noti_ex_color_h *color) {
1490 if (handle == nullptr || color == nullptr) {
1491 LOGE("Invalid parameter");
1492 return NOTI_EX_ERROR_INVALID_PARAMETER;
1495 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1496 if ((*p)->GetColor() == nullptr) {
1497 LOGW("Color info is null");
1499 return NOTI_EX_ERROR_NONE;
1502 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1503 new (std::nothrow) Color(*((*p)->GetColor())));
1504 if (col == nullptr || col->get() == nullptr) {
1505 LOGE("Out-of-memory");
1506 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1511 return NOTI_EX_ERROR_NONE;
1514 extern "C" EXPORT_API int noti_ex_style_set_color(
1515 noti_ex_style_h handle, noti_ex_color_h color) {
1516 if (handle == nullptr) {
1517 LOGE("Invalid parameter");
1518 return NOTI_EX_ERROR_INVALID_PARAMETER;
1521 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1522 if (color == nullptr) {
1523 (*p)->SetColor(nullptr);
1524 return NOTI_EX_ERROR_NONE;
1527 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1528 (*p)->SetColor(*col);
1530 return NOTI_EX_ERROR_NONE;
1533 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
1534 noti_ex_geometry_h *geometry) {
1535 if (handle == nullptr || geometry == nullptr) {
1536 LOGE("Invalid parameter");
1537 return NOTI_EX_ERROR_INVALID_PARAMETER;
1540 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1541 if ((*p)->GetGeometry() == nullptr) {
1542 LOGW("Geometry info is null");
1543 *geometry = nullptr;
1544 return NOTI_EX_ERROR_NONE;
1547 shared_ptr<Geometry>* geo = new (std::nothrow) shared_ptr<Geometry>(
1548 new (std::nothrow) Geometry(*((*p)->GetGeometry())));
1549 if (geo == nullptr || geo->get() == nullptr) {
1550 LOGE("Out-of-memory");
1551 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1556 return NOTI_EX_ERROR_NONE;
1559 extern "C" EXPORT_API int noti_ex_style_set_geometry(
1560 noti_ex_style_h handle, noti_ex_geometry_h geometry) {
1561 if (handle == nullptr) {
1562 LOGE("Invalid parameter");
1563 return NOTI_EX_ERROR_INVALID_PARAMETER;
1566 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1567 if (geometry == nullptr) {
1568 (*p)->SetGeometry(nullptr);
1569 return NOTI_EX_ERROR_NONE;
1572 shared_ptr<Geometry>* geo = static_cast<shared_ptr<Geometry>*>(geometry);
1573 (*p)->SetGeometry(*geo);
1575 return NOTI_EX_ERROR_NONE;
1578 extern "C" EXPORT_API int noti_ex_style_get_background_image(
1579 noti_ex_style_h handle, char** background_image) {
1580 if (handle == nullptr || background_image == nullptr) {
1581 LOGE("Invalid parameter");
1582 return NOTI_EX_ERROR_INVALID_PARAMETER;
1585 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1587 if ((*p)->GetBackgroundImage().empty())
1588 *background_image = nullptr;
1590 *background_image = strdup((*p)->GetBackgroundImage().c_str());
1592 return NOTI_EX_ERROR_NONE;
1595 extern "C" EXPORT_API int noti_ex_style_set_background_image(
1596 noti_ex_style_h handle, char* background_image) {
1597 if (handle == nullptr) {
1598 LOGE("Invalid parameter");
1599 return NOTI_EX_ERROR_INVALID_PARAMETER;
1602 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1603 if (background_image == nullptr)
1604 (*p)->SetBackgroundImage("");
1606 (*p)->SetBackgroundImage(background_image);
1608 return NOTI_EX_ERROR_NONE;
1611 extern "C" EXPORT_API int noti_ex_style_get_background_color(
1612 noti_ex_style_h handle, noti_ex_color_h* color) {
1613 if (handle == nullptr || color == nullptr) {
1614 LOGE("Invalid parameter");
1615 return NOTI_EX_ERROR_INVALID_PARAMETER;
1618 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1619 if ((*p)->GetBackgroundColor() == nullptr) {
1620 LOGW("Color info is null");
1622 return NOTI_EX_ERROR_NONE;
1625 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1626 new (std::nothrow) Color(*((*p)->GetBackgroundColor())));
1627 if (col == nullptr || col->get() == nullptr) {
1628 LOGE("Out-of-memory");
1629 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1634 return NOTI_EX_ERROR_NONE;
1637 extern "C" EXPORT_API int noti_ex_style_set_background_color(
1638 noti_ex_style_h handle, noti_ex_color_h color) {
1639 if (handle == nullptr) {
1640 LOGE("Invalid parameter");
1641 return NOTI_EX_ERROR_INVALID_PARAMETER;
1644 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1645 if (color == nullptr) {
1646 (*p)->SetBackgroundColor(nullptr);
1647 return NOTI_EX_ERROR_NONE;
1650 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1651 (*p)->SetBackgroundColor(*col);
1653 return NOTI_EX_ERROR_NONE;
1656 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
1657 noti_ex_color_h color) {
1658 if (handle == nullptr || color == nullptr) {
1659 LOGE("Invalid parameter");
1660 return NOTI_EX_ERROR_INVALID_PARAMETER;
1663 shared_ptr<Color>* color_ptr = static_cast<shared_ptr<Color>*>(color);
1664 shared_ptr<LEDInfo>* p = new (std::nothrow) shared_ptr<LEDInfo>(
1665 new (std::nothrow) LEDInfo(*color_ptr));
1667 LOGE("Out-of-memory");
1668 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1673 return NOTI_EX_ERROR_NONE;
1676 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
1677 if (handle == nullptr) {
1678 LOGE("Invalid parameter");
1679 return NOTI_EX_ERROR_INVALID_PARAMETER;
1682 shared_ptr<LEDInfo>* led_ptr =
1683 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1685 return NOTI_EX_ERROR_NONE;
1688 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
1689 noti_ex_led_info_h handle, int ms) {
1690 if (handle == nullptr) {
1691 LOGE("Invalid parameter");
1692 return NOTI_EX_ERROR_INVALID_PARAMETER;
1695 shared_ptr<LEDInfo>* led_ptr =
1696 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1697 (*led_ptr)->SetOnPeriod(ms);
1699 return NOTI_EX_ERROR_NONE;
1702 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
1703 noti_ex_led_info_h handle, int *ms) {
1704 if (handle == nullptr || ms == nullptr) {
1705 LOGE("Invalid parameter");
1706 return NOTI_EX_ERROR_INVALID_PARAMETER;
1709 shared_ptr<LEDInfo>* led_ptr =
1710 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1711 *ms = (*led_ptr)->GetOnPeriod();
1713 return NOTI_EX_ERROR_NONE;
1716 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
1717 noti_ex_led_info_h handle, int ms) {
1718 if (handle == nullptr) {
1719 LOGE("Invalid parameter");
1720 return NOTI_EX_ERROR_INVALID_PARAMETER;
1723 shared_ptr<LEDInfo>* led_ptr =
1724 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1725 (*led_ptr)->SetOffPeriod(ms);
1727 return NOTI_EX_ERROR_NONE;
1730 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
1731 noti_ex_led_info_h handle, int *ms) {
1732 if (handle == nullptr) {
1733 LOGE("Invalid parameter");
1734 return NOTI_EX_ERROR_INVALID_PARAMETER;
1737 shared_ptr<LEDInfo>* led_ptr =
1738 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1739 *ms = (*led_ptr)->GetOffPeriod();
1741 return NOTI_EX_ERROR_NONE;
1744 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1745 noti_ex_led_info_h handle, noti_ex_color_h *color) {
1746 if (handle == nullptr) {
1747 LOGE("Invalid parameter");
1748 return NOTI_EX_ERROR_INVALID_PARAMETER;
1751 shared_ptr<LEDInfo>* led_ptr =
1752 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1753 if ((*led_ptr)->GetColor() == nullptr) {
1754 LOGW("Color is null");
1756 return NOTI_EX_ERROR_NONE;
1759 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1760 new (std::nothrow) Color(*((*led_ptr)->GetColor())));
1761 if (col == nullptr || col->get() == nullptr) {
1762 LOGE("Out-of-memory");
1763 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1768 return NOTI_EX_ERROR_NONE;
1771 extern "C" EXPORT_API int noti_ex_led_info_set_color(
1772 noti_ex_led_info_h handle, noti_ex_color_h color) {
1773 if (handle == nullptr) {
1774 LOGE("Invalid parameter");
1775 return NOTI_EX_ERROR_INVALID_PARAMETER;
1778 shared_ptr<LEDInfo>* p = static_cast<shared_ptr<LEDInfo>*>(handle);
1779 if (color == nullptr) {
1780 (*p)->SetColor(nullptr);
1781 return NOTI_EX_ERROR_NONE;
1784 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1785 (*p)->SetColor(*col);
1787 return NOTI_EX_ERROR_NONE;
1790 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1791 if (handle == nullptr) {
1792 LOGE("Invalid parameter");
1793 return NOTI_EX_ERROR_INVALID_PARAMETER;
1796 shared_ptr<AbstractAction>* ptr =
1797 static_cast<shared_ptr<AbstractAction>*>(handle);
1800 return NOTI_EX_ERROR_NONE;
1803 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1805 if (handle == nullptr || type == nullptr) {
1806 LOGE("Invalid parameter");
1807 return NOTI_EX_ERROR_INVALID_PARAMETER;
1810 shared_ptr<AbstractAction>* ptr =
1811 static_cast<shared_ptr<AbstractAction>*>(handle);
1812 *type = (*ptr)->GetType();
1814 return NOTI_EX_ERROR_NONE;
1817 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1819 if (handle == nullptr || local == nullptr) {
1820 LOGE("Invalid parameter");
1821 return NOTI_EX_ERROR_INVALID_PARAMETER;
1824 shared_ptr<AbstractAction>* ptr =
1825 static_cast<shared_ptr<AbstractAction>*>(handle);
1826 *local = (*ptr)->IsLocal();
1828 return NOTI_EX_ERROR_NONE;
1831 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1832 noti_ex_item_h item) {
1833 if (handle == nullptr || item == nullptr) {
1834 LOGE("Invalid parameter");
1835 return NOTI_EX_ERROR_INVALID_PARAMETER;
1837 shared_ptr<AbstractAction>* ptr =
1838 static_cast<shared_ptr<AbstractAction>*>(handle);
1839 Handle* ih = static_cast<Handle*>(item);
1840 (*ptr)->Execute(ih->GetPtr());
1842 return NOTI_EX_ERROR_NONE;
1845 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1847 if (handle == nullptr || extra == nullptr) {
1848 LOGE("Invalid parameter");
1849 return NOTI_EX_ERROR_INVALID_PARAMETER;
1852 shared_ptr<AbstractAction>* ptr =
1853 static_cast<shared_ptr<AbstractAction>*>(handle);
1854 if (!(*ptr)->GetExtra().empty()) {
1855 *extra = strdup((*ptr)->GetExtra().c_str());
1856 if (*extra == nullptr) {
1857 LOGE("Out-of-memory");
1858 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1864 return NOTI_EX_ERROR_NONE;
1867 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1868 noti_ex_item_info_h handle, int *hide_time) {
1869 if (handle == nullptr || hide_time == nullptr) {
1870 LOGE("Invalid parameter");
1871 return NOTI_EX_ERROR_INVALID_PARAMETER;
1873 IItemInfo* p = static_cast<IItemInfo*>(handle);
1874 *hide_time = p->GetHideTime();
1875 return NOTI_EX_ERROR_NONE;
1878 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1879 noti_ex_item_info_h handle, int hide_time) {
1880 if (handle == nullptr) {
1881 LOGE("Invalid parameter");
1882 return NOTI_EX_ERROR_INVALID_PARAMETER;
1884 IItemInfo* p = static_cast<IItemInfo*>(handle);
1885 p->SetHideTime(hide_time);
1886 return NOTI_EX_ERROR_NONE;
1889 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1890 noti_ex_item_info_h handle, int *delete_time) {
1891 if (handle == nullptr || delete_time == nullptr) {
1892 LOGE("Invalid parameter");
1893 return NOTI_EX_ERROR_INVALID_PARAMETER;
1895 IItemInfo* p = static_cast<IItemInfo*>(handle);
1896 *delete_time = p->GetDeleteTime();
1897 return NOTI_EX_ERROR_NONE;
1900 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
1901 noti_ex_item_info_h handle, int delete_time) {
1902 if (handle == nullptr) {
1903 LOGE("Invalid parameter");
1904 return NOTI_EX_ERROR_INVALID_PARAMETER;
1906 IItemInfo* p = static_cast<IItemInfo*>(handle);
1907 p->SetDeleteTime(delete_time);
1908 return NOTI_EX_ERROR_NONE;
1911 extern "C" EXPORT_API int noti_ex_item_info_get_time(
1912 noti_ex_item_info_h handle, time_t *time) {
1913 if (handle == nullptr || time == nullptr) {
1914 LOGE("Invalid parameter");
1915 return NOTI_EX_ERROR_INVALID_PARAMETER;
1918 IItemInfo* p = static_cast<IItemInfo*>(handle);
1919 *time = p->GetTime();
1920 return NOTI_EX_ERROR_NONE;
1923 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
1924 if (handle == nullptr) {
1925 LOGE("Invalid parameter");
1926 return NOTI_EX_ERROR_INVALID_PARAMETER;
1929 Handle* h = static_cast<Handle*>(handle);
1931 return NOTI_EX_ERROR_NONE;
1934 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
1935 const char *id, noti_ex_item_h *item) {
1936 if (handle == nullptr) {
1937 LOGE("Invalid parameter");
1938 return NOTI_EX_ERROR_INVALID_PARAMETER;
1941 Handle* p = static_cast<Handle*>(handle);
1942 AbstractItem& find_item = p->Get()->FindByID(string(id));
1943 if (find_item.GetType() == AbstractItem::NullObject) {
1944 LOGW("Not exist ID");
1946 return NOTI_EX_ERROR_NONE;
1949 *item = new Handle(&find_item);
1950 return NOTI_EX_ERROR_NONE;
1953 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
1955 if (handle == nullptr || type == nullptr) {
1956 LOGE("Invalid parameter");
1957 return NOTI_EX_ERROR_INVALID_PARAMETER;
1960 Handle* h = static_cast<Handle*>(handle);
1961 AbstractItem* p = h->Get();
1962 *type = p->GetType();
1963 return NOTI_EX_ERROR_NONE;
1966 extern "C" EXPORT_API int noti_ex_item_get_shared_paths(noti_ex_item_h handle,
1967 char ***path, int *count) {
1968 if (handle == nullptr || path == nullptr || count == nullptr) {
1969 LOGE("Invalid parameter");
1970 return NOTI_EX_ERROR_INVALID_PARAMETER;
1972 Handle* p = static_cast<Handle*>(handle);
1973 list<string> shared_path = p->Get()->GetSharedPath();
1974 char** tmp_path = (char**)calloc(shared_path.size(), sizeof(char*));
1975 if (tmp_path == nullptr) {
1976 LOGE("Fail to create items");
1977 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1981 for (auto& i : shared_path) {
1982 tmp_path[idx] = strdup(i.c_str());
1983 if (tmp_path[idx] == nullptr) {
1984 __noti_ex_free_str_array(tmp_path, idx);
1985 LOGE("Out of memory");
1986 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1992 *count = shared_path.size();
1993 return NOTI_EX_ERROR_NONE;
1996 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
1998 if (handle == nullptr || id == nullptr) {
1999 LOGE("Invalid parameter");
2000 return NOTI_EX_ERROR_INVALID_PARAMETER;
2002 Handle* h = static_cast<Handle*>(handle);
2003 AbstractItem* p = h->Get();
2004 *id = strdup(p->GetId().c_str());
2005 return NOTI_EX_ERROR_NONE;
2008 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
2010 if (handle == nullptr || id == nullptr) {
2011 LOGE("Invalid parameter");
2012 return NOTI_EX_ERROR_INVALID_PARAMETER;
2014 Handle* p = static_cast<Handle*>(handle);
2015 p->Get()->SetId(id);
2016 return NOTI_EX_ERROR_NONE;
2019 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
2020 noti_ex_action_h *action) {
2021 if (handle == nullptr || action == nullptr) {
2022 LOGE("Invalid parameter");
2023 return NOTI_EX_ERROR_INVALID_PARAMETER;
2025 Handle* p = static_cast<Handle*>(handle);
2026 if (p->Get()->GetAction() == nullptr) {
2028 return NOTI_EX_ERROR_NONE;
2030 *action = static_cast<noti_ex_action_h>(new shared_ptr<AbstractAction>(
2031 p->Get()->GetAction()));
2033 return NOTI_EX_ERROR_NONE;
2036 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
2037 noti_ex_action_h action) {
2038 if (handle == nullptr) {
2039 LOGE("Invalid parameter");
2040 return NOTI_EX_ERROR_INVALID_PARAMETER;
2043 Handle* p = static_cast<Handle*>(handle);
2044 if (action == nullptr) {
2045 p->Get()->SetAction(nullptr);
2046 return NOTI_EX_ERROR_NONE;
2049 shared_ptr<AbstractAction>* ptr =
2050 static_cast<shared_ptr<AbstractAction>*>(action);
2051 p->Get()->SetAction(*ptr);
2052 return NOTI_EX_ERROR_NONE;
2055 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
2056 noti_ex_style_h *style) {
2057 if (handle == nullptr || style == nullptr) {
2058 LOGE("Invalid parameter");
2059 return NOTI_EX_ERROR_INVALID_PARAMETER;
2062 Handle* p = static_cast<Handle*>(handle);
2063 shared_ptr<Style> s = p->Get()->GetStyle();
2064 if (s.get() == nullptr) {
2065 LOGW("Style is null");
2067 return NOTI_EX_ERROR_NONE;
2070 auto* ptr = new (std::nothrow) shared_ptr<Style>(new (std::nothrow) Style(*s));
2071 if (ptr == nullptr || ptr->get() == nullptr) {
2072 LOGE("Out of memory");
2073 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2077 return NOTI_EX_ERROR_NONE;
2080 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
2081 noti_ex_style_h style) {
2082 if (handle == nullptr) {
2083 LOGE("Invalid parameter");
2084 return NOTI_EX_ERROR_INVALID_PARAMETER;
2087 Handle* p = static_cast<Handle*>(handle);
2088 if (style == nullptr) {
2089 p->Get()->SetStyle(nullptr);
2090 return NOTI_EX_ERROR_NONE;
2093 shared_ptr<Style>* s = static_cast<shared_ptr<Style>*>(style);
2094 p->Get()->SetStyle(*s);
2095 return NOTI_EX_ERROR_NONE;
2098 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
2100 if (handle == nullptr) {
2101 LOGE("Invalid parameter");
2102 return NOTI_EX_ERROR_INVALID_PARAMETER;
2105 Handle* p = static_cast<Handle*>(handle);
2106 p->Get()->SetVisible(visible);
2107 return NOTI_EX_ERROR_NONE;
2110 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
2112 if (handle == nullptr || visible == nullptr) {
2113 LOGE("Invalid parameter");
2114 return NOTI_EX_ERROR_INVALID_PARAMETER;
2117 Handle* p = static_cast<Handle*>(handle);
2118 *visible = p->Get()->GetVisible();
2119 return NOTI_EX_ERROR_NONE;
2122 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
2124 if (handle == nullptr) {
2125 LOGE("Invalid parameter");
2126 return NOTI_EX_ERROR_INVALID_PARAMETER;
2129 Handle* p = static_cast<Handle*>(handle);
2130 p->Get()->SetEnable(enable);
2131 return NOTI_EX_ERROR_NONE;
2134 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
2136 if (handle == nullptr || enable == nullptr) {
2137 LOGE("Invalid parameter");
2138 return NOTI_EX_ERROR_INVALID_PARAMETER;
2141 Handle* p = static_cast<Handle*>(handle);
2142 *enable = p->Get()->GetEnable();
2143 return NOTI_EX_ERROR_NONE;
2146 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
2147 const char *receiver_group) {
2148 if (handle == nullptr || receiver_group == nullptr) {
2149 LOGE("Invalid parameter");
2150 return NOTI_EX_ERROR_INVALID_PARAMETER;
2153 Handle* p = static_cast<Handle*>(handle);
2154 p->Get()->AddReceiver(receiver_group);
2155 return NOTI_EX_ERROR_NONE;
2158 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
2159 const char *receiver_group) {
2160 if (handle == nullptr || receiver_group == nullptr) {
2161 LOGE("Invalid parameter");
2162 return NOTI_EX_ERROR_INVALID_PARAMETER;
2165 Handle* p = static_cast<Handle*>(handle);
2166 p->Get()->RemoveReceiver(receiver_group);
2167 return NOTI_EX_ERROR_NONE;
2170 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
2171 char ***receiver_list, int *count) {
2172 if (handle == nullptr || receiver_list == nullptr || count == nullptr) {
2173 LOGE("Invalid parameter");
2174 return NOTI_EX_ERROR_INVALID_PARAMETER;
2177 Handle* p = static_cast<Handle*>(handle);
2178 list<string> receivers = p->Get()->GetReceiverList();
2179 if (receivers.size() == 0) {
2180 *receiver_list = nullptr;
2182 return NOTI_EX_ERROR_NONE;
2185 char **tmp_list = (char**)calloc(receivers.size(), sizeof(char*));
2186 if (tmp_list == nullptr) {
2187 LOGE("Out of memory");
2188 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2192 for (auto& i : receivers) {
2193 tmp_list[idx] = strdup(i.c_str());
2194 if (tmp_list[idx] == nullptr) {
2195 __noti_ex_free_str_array(tmp_list, idx);
2196 LOGE("Out of memory");
2197 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2202 *receiver_list = tmp_list;
2203 *count = receivers.size();
2204 return NOTI_EX_ERROR_NONE;
2207 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
2209 if (handle == nullptr) {
2210 LOGE("Invalid parameter");
2211 return NOTI_EX_ERROR_INVALID_PARAMETER;
2214 Handle* p = static_cast<Handle*>(handle);
2215 p->Get()->SetPolicy(policy);
2216 return NOTI_EX_ERROR_NONE;
2219 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
2221 if (handle == nullptr || policy == nullptr) {
2222 LOGE("Invalid parameter");
2223 return NOTI_EX_ERROR_INVALID_PARAMETER;
2226 Handle* p = static_cast<Handle*>(handle);
2227 *policy = p->Get()->GetPolicy();
2228 return NOTI_EX_ERROR_NONE;
2231 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
2233 if (handle == nullptr || channel == nullptr) {
2234 LOGE("Invalid parameter");
2235 return NOTI_EX_ERROR_INVALID_PARAMETER;
2238 Handle* p = static_cast<Handle*>(handle);
2239 if (!p->Get()->GetChannel().empty())
2240 *channel = strdup(p->Get()->GetChannel().c_str());
2244 return NOTI_EX_ERROR_NONE;
2247 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
2248 const char *channel) {
2249 if (handle == nullptr) {
2250 LOGE("Invalid parameter");
2251 return NOTI_EX_ERROR_INVALID_PARAMETER;
2254 Handle* p = static_cast<Handle*>(handle);
2255 p->Get()->SetChannel(channel);
2256 return NOTI_EX_ERROR_NONE;
2259 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
2260 noti_ex_led_info_h led) {
2261 if (handle == nullptr) {
2262 LOGE("Invalid parameter");
2263 return NOTI_EX_ERROR_INVALID_PARAMETER;
2266 Handle* p = static_cast<Handle*>(handle);
2267 if (led == nullptr) {
2268 p->Get()->SetLEDInfo(nullptr);
2269 return NOTI_EX_ERROR_NONE;
2271 shared_ptr<LEDInfo>* led_ptr =
2272 reinterpret_cast<shared_ptr<LEDInfo>*>(led);
2273 p->Get()->SetLEDInfo(*led_ptr);
2274 return NOTI_EX_ERROR_NONE;
2277 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
2278 noti_ex_led_info_h *led) {
2279 if (handle == nullptr) {
2280 LOGE("Invalid parameter");
2281 return NOTI_EX_ERROR_INVALID_PARAMETER;
2284 Handle* p = static_cast<Handle*>(handle);
2285 if (p->Get()->GetLEDInfo() != nullptr)
2286 *led = new shared_ptr<LEDInfo>(p->Get()->GetLEDInfo());
2289 return NOTI_EX_ERROR_NONE;
2292 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
2294 if (handle == nullptr) {
2295 LOGE("Invalid parameter");
2296 return NOTI_EX_ERROR_INVALID_PARAMETER;
2299 Handle* p = static_cast<Handle*>(handle);
2300 if (path == nullptr)
2301 p->Get()->SetSoundPath("");
2303 p->Get()->SetSoundPath(path);
2304 return NOTI_EX_ERROR_NONE;
2307 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
2309 if (handle == nullptr) {
2310 LOGE("Invalid parameter");
2311 return NOTI_EX_ERROR_INVALID_PARAMETER;
2314 Handle* p = static_cast<Handle*>(handle);
2315 if (path == nullptr)
2316 p->Get()->SetVibrationPath("");
2318 p->Get()->SetVibrationPath(path);
2319 return NOTI_EX_ERROR_NONE;
2322 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
2324 if (handle == nullptr || path == nullptr) {
2325 LOGE("Invalid parameter");
2326 return NOTI_EX_ERROR_INVALID_PARAMETER;
2329 Handle* p = static_cast<Handle*>(handle);
2330 if (p->Get()->GetSoundPath().empty())
2333 *path = strdup(p->Get()->GetSoundPath().c_str());
2334 return NOTI_EX_ERROR_NONE;
2337 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
2339 if (handle == nullptr || path == nullptr) {
2340 LOGE("Invalid parameter");
2341 return NOTI_EX_ERROR_INVALID_PARAMETER;
2344 Handle* p = static_cast<Handle*>(handle);
2345 if (p->Get()->GetVibrationPath().empty())
2348 *path = strdup(p->Get()->GetVibrationPath().c_str());
2349 return NOTI_EX_ERROR_NONE;
2352 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
2353 noti_ex_item_info_h *info) {
2354 if (handle == nullptr || info == nullptr) {
2355 LOGE("Invalid parameter");
2356 return NOTI_EX_ERROR_INVALID_PARAMETER;
2359 Handle* p = static_cast<Handle*>(handle);
2360 if (p->Get()->GetInfo() == nullptr)
2363 *info = static_cast<noti_ex_item_info_h>(p->Get()->GetInfo().get());
2364 return NOTI_EX_ERROR_NONE;
2367 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
2369 if (handle == nullptr || id == nullptr) {
2370 LOGE("Invalid parameter");
2371 return NOTI_EX_ERROR_INVALID_PARAMETER;
2374 Handle* p = static_cast<Handle*>(handle);
2375 if (p->Get()->GetSenderAppId().empty())
2378 *id = strdup(p->Get()->GetSenderAppId().c_str());
2379 return NOTI_EX_ERROR_NONE;
2382 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
2384 if (handle == nullptr || tag == nullptr) {
2385 LOGE("Invalid parameter");
2386 return NOTI_EX_ERROR_INVALID_PARAMETER;
2389 Handle* p = static_cast<Handle*>(handle);
2390 if (p->Get()->GetTag().empty())
2393 *tag = strdup(p->Get()->GetTag().c_str());
2394 return NOTI_EX_ERROR_NONE;
2397 extern "C" EXPORT_API int noti_ex_item_set_tag(noti_ex_item_h handle,
2399 if (handle == nullptr) {
2400 LOGE("Invalid parameter");
2401 return NOTI_EX_ERROR_INVALID_PARAMETER;
2404 Handle* p = static_cast<Handle*>(handle);
2406 p->Get()->SetTag("");
2408 p->Get()->SetTag(tag);
2409 return NOTI_EX_ERROR_NONE;
2412 extern "C" EXPORT_API int noti_ex_item_get_ongoing_state(noti_ex_item_h handle,
2414 if (handle == nullptr || ongoing == nullptr) {
2415 LOGE("Invalid parameter");
2416 return NOTI_EX_ERROR_INVALID_PARAMETER;
2419 Handle* p = static_cast<Handle*>(handle);
2420 *ongoing = p->Get()->GetOnGoingState();
2422 return NOTI_EX_ERROR_NONE;
2425 extern "C" EXPORT_API int noti_ex_item_set_ongoing_state(noti_ex_item_h handle,
2427 if (handle == nullptr) {
2428 LOGE("Invalid parameter");
2429 return NOTI_EX_ERROR_INVALID_PARAMETER;
2432 Handle* p = static_cast<Handle*>(handle);
2433 p->Get()->SetOnGoingState(ongoing);
2435 return NOTI_EX_ERROR_NONE;
2438 extern "C" EXPORT_API int noti_ex_item_check_type_exist(noti_ex_item_h handle,
2439 int type, bool* exist) {
2440 if (handle == nullptr || exist == nullptr) {
2441 LOGE("Invalid parameter");
2442 return NOTI_EX_ERROR_INVALID_PARAMETER;
2445 Handle* p = static_cast<Handle*>(handle);
2446 *exist = p->Get()->IsItemTypeExist(type);
2448 return NOTI_EX_ERROR_NONE;
2451 extern "C" EXPORT_API int noti_ex_item_get_main_type(noti_ex_item_h handle,
2453 if (handle == nullptr || type == nullptr) {
2454 LOGE("Invalid parameter");
2455 return NOTI_EX_ERROR_INVALID_PARAMETER;
2458 Handle* p = static_cast<Handle*>(handle);
2459 *type = p->Get()->GetMainType();
2461 return NOTI_EX_ERROR_NONE;
2464 extern "C" EXPORT_API int noti_ex_item_set_main_type(noti_ex_item_h handle,
2465 const char* id, int type) {
2466 if (handle == nullptr || id == nullptr) {
2467 LOGE("Invalid parameter");
2468 return NOTI_EX_ERROR_INVALID_PARAMETER;
2471 Handle* p = static_cast<Handle*>(handle);
2472 if (!(p->Get()->SetMainType(string(id),
2473 static_cast<AbstractItem::MainType>(type))))
2474 return NOTI_EX_ERROR_INVALID_PARAMETER;
2476 return NOTI_EX_ERROR_NONE;
2479 extern "C" EXPORT_API int noti_ex_item_find_by_main_type(noti_ex_item_h handle,
2480 int type, noti_ex_item_h* item) {
2481 if (handle == nullptr || item == nullptr) {
2482 LOGE("Invalid parameter");
2483 return NOTI_EX_ERROR_INVALID_PARAMETER;
2486 Handle* h = static_cast<Handle*>(handle);
2487 if (!h->IsValidType(AbstractItem::Group)) {
2488 LOGE("Invalid handle type");
2489 return NOTI_EX_ERROR_INVALID_PARAMETER;
2492 GroupItem* p = static_cast<GroupItem*>(h->Get());
2493 AbstractItem& find_item = p->FindByMainType(static_cast<AbstractItem::MainType>(type));
2494 if (find_item.GetType() == AbstractItem::NullObject) {
2495 LOGW("Not exist ID");
2497 return NOTI_EX_ERROR_NONE;
2499 *item = new Handle(&find_item);
2501 return NOTI_EX_ERROR_NONE;
2504 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
2505 const char *receiver_group, noti_ex_manager_events_s event_callbacks,
2507 if (handle == nullptr) {
2508 LOGE("Invalid parameter");
2509 return NOTI_EX_ERROR_INVALID_PARAMETER;
2512 string receiver_group_str = "";
2514 receiver_group_str = string(receiver_group);
2516 ManagerStub* stub = new (std::nothrow) ManagerStub(
2517 unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
2518 unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
2519 receiver_group_str);
2520 if (stub == nullptr) {
2521 LOGE("Fail to create manager");
2522 return NOTI_EX_ERROR_IO_ERROR;
2524 stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
2525 new ManagerCallbackInfo(event_callbacks, data)));
2526 *handle = static_cast<noti_ex_manager_h>(stub);
2528 return NOTI_EX_ERROR_NONE;
2531 extern "C" EXPORT_API int noti_ex_manager_destroy(noti_ex_manager_h handle) {
2532 if (handle == nullptr) {
2533 LOGE("Invalid parameter");
2534 return NOTI_EX_ERROR_INVALID_PARAMETER;
2536 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2538 return NOTI_EX_ERROR_NONE;
2541 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
2542 noti_ex_item_h **items, int *count) {
2543 if (handle == nullptr || items == nullptr || count == nullptr) {
2544 LOGE("Invalid parameter");
2545 return NOTI_EX_ERROR_INVALID_PARAMETER;
2549 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2550 list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
2551 if (item_list.size() == 0) {
2554 return NOTI_EX_ERROR_NONE;
2556 noti_ex_item_h* added_item =
2557 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2558 if (added_item == nullptr) {
2559 LOGE("Fail to create items");
2560 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2564 for (auto& i : item_list) {
2565 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2567 *items = added_item;
2568 *count = item_list.size();
2569 } catch (Exception &ex) {
2570 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2571 return NOTI_EX_ERROR_IO_ERROR;
2573 return NOTI_EX_ERROR_NONE;
2576 extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
2577 noti_ex_manager_h handle, char* channel, noti_ex_item_h** items, int* count) {
2578 if (handle == nullptr || channel == nullptr ||
2579 items == nullptr || count == nullptr) {
2580 LOGE("Invalid parameter");
2581 return NOTI_EX_ERROR_INVALID_PARAMETER;
2585 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2586 list<unique_ptr<item::AbstractItem>> item_list = stub->Get(channel);
2587 if (item_list.size() == 0) {
2590 return NOTI_EX_ERROR_NONE;
2592 noti_ex_item_h* added_item =
2593 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2594 if (added_item == nullptr) {
2595 LOGE("Fail to create items");
2596 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2600 for (auto& i : item_list) {
2601 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2603 *items = added_item;
2604 *count = item_list.size();
2605 } catch (Exception &ex) {
2606 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2607 return NOTI_EX_ERROR_IO_ERROR;
2610 return NOTI_EX_ERROR_NONE;
2613 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
2614 noti_ex_item_h noti, int *request_id) {
2615 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2616 LOGE("Invalid parameter");
2617 return NOTI_EX_ERROR_INVALID_PARAMETER;
2620 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2621 Handle* sp = static_cast<Handle*>(noti);
2622 if (sp->GetPtr().get() == nullptr) {
2623 LOGE("Invalid noti reference can not be sended");
2624 return NOTI_EX_ERROR_INVALID_PARAMETER;
2626 *request_id = stub->Update(sp->GetPtr());
2628 } catch (Exception &ex) {
2629 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2630 return NOTI_EX_ERROR_IO_ERROR;
2632 return NOTI_EX_ERROR_NONE;
2635 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
2636 noti_ex_item_h noti, int *request_id) {
2637 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2638 LOGE("Invalid parameter");
2639 return NOTI_EX_ERROR_INVALID_PARAMETER;
2642 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2643 Handle* item = static_cast<Handle*>(noti);
2644 if (item->GetPtr().get() == nullptr) {
2645 LOGE("Invalid noti reference can not be sended");
2646 return NOTI_EX_ERROR_INVALID_PARAMETER;
2648 *request_id = stub->Delete(item->GetPtr());
2650 } catch (Exception &ex) {
2651 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2652 return NOTI_EX_ERROR_IO_ERROR;
2654 return NOTI_EX_ERROR_NONE;
2657 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
2659 if (handle == nullptr || request_id == nullptr) {
2660 LOGE("Invalid parameter");
2661 return NOTI_EX_ERROR_INVALID_PARAMETER;
2664 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2665 *request_id = stub->DeleteAll();
2666 } catch (Exception &ex) {
2667 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2668 return NOTI_EX_ERROR_IO_ERROR;
2670 return NOTI_EX_ERROR_NONE;
2673 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
2674 noti_ex_item_h noti, int *request_id) {
2675 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2676 LOGE("Invalid parameter");
2677 return NOTI_EX_ERROR_INVALID_PARAMETER;
2680 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2681 Handle* item = static_cast<Handle*>(noti);
2682 if (item->GetPtr().get() == nullptr) {
2683 LOGE("Invalid noti reference can not be sended");
2684 return NOTI_EX_ERROR_INVALID_PARAMETER;
2686 *request_id = stub->Hide(item->GetPtr());
2688 } catch (Exception &ex) {
2689 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2690 return NOTI_EX_ERROR_IO_ERROR;
2692 return NOTI_EX_ERROR_NONE;
2695 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
2696 noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
2697 if (handle == nullptr || root_id == nullptr || item == nullptr) {
2698 LOGE("Invalid parameter");
2699 return NOTI_EX_ERROR_INVALID_PARAMETER;
2702 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2703 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
2704 if (ptr == nullptr) {
2705 LOGW("Not exist ID");
2707 return NOTI_EX_ERROR_NONE;
2709 *item = new Handle(ptr);
2710 } catch (Exception &ex) {
2711 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2712 return NOTI_EX_ERROR_IO_ERROR;
2714 return NOTI_EX_ERROR_NONE;
2717 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
2718 noti_ex_event_info_h info, noti_ex_error_e error) {
2719 if (handle == nullptr || info == nullptr) {
2720 LOGE("Invalid parameter");
2721 return NOTI_EX_ERROR_INVALID_PARAMETER;
2724 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2725 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2726 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2727 static_cast<NotificationError>(error));
2728 } catch (Exception &ex) {
2729 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2730 return NOTI_EX_ERROR_IO_ERROR;
2732 return NOTI_EX_ERROR_NONE;
2735 extern "C" EXPORT_API int noti_ex_manager_get_notification_count(
2736 noti_ex_manager_h handle, int *cnt) {
2738 if (handle == nullptr || cnt == nullptr) {
2739 LOGE("Invalid parameter");
2740 return NOTI_EX_ERROR_INVALID_PARAMETER;
2743 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2744 *cnt = stub->GetCount();
2745 } catch (Exception &ex) {
2746 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2747 return NOTI_EX_ERROR_IO_ERROR;
2749 return NOTI_EX_ERROR_NONE;
2752 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
2753 const char *id, float min, float current, float max) {
2756 if (handle == nullptr) {
2757 LOGE("Invalid parameter");
2758 return NOTI_EX_ERROR_INVALID_PARAMETER;
2762 p = new (std::nothrow) ProgressItem(id, min, current, max);
2764 p = new (std::nothrow) ProgressItem(min, current, max);
2767 LOGE("Out-of-memory");
2768 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2771 *handle = new Handle(shared_ptr<AbstractItem>(p));
2773 return NOTI_EX_ERROR_NONE;
2776 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
2777 noti_ex_item_h handle, float *current) {
2778 if (handle == nullptr || current == nullptr) {
2779 LOGE("Invalid parameter");
2780 return NOTI_EX_ERROR_INVALID_PARAMETER;
2783 Handle *h = static_cast<Handle*>(handle);
2784 if (!h->IsValidType(AbstractItem::Progress)) {
2785 LOGE("Invalid handle type");
2786 return NOTI_EX_ERROR_INVALID_PARAMETER;
2788 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2789 *current = p->GetCurrent();
2791 return NOTI_EX_ERROR_NONE;
2794 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
2795 noti_ex_item_h handle, float current) {
2796 if (handle == nullptr) {
2797 LOGE("Invalid parameter");
2798 return NOTI_EX_ERROR_INVALID_PARAMETER;
2801 Handle *h = static_cast<Handle*>(handle);
2802 if (!h->IsValidType(AbstractItem::Progress)) {
2803 LOGE("Invalid handle type");
2804 return NOTI_EX_ERROR_INVALID_PARAMETER;
2806 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2807 p->SetCurrent(current);
2809 return NOTI_EX_ERROR_NONE;
2812 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
2814 if (handle == nullptr || min == nullptr) {
2815 LOGE("Invalid parameter");
2816 return NOTI_EX_ERROR_INVALID_PARAMETER;
2819 Handle *h = static_cast<Handle*>(handle);
2820 if (!h->IsValidType(AbstractItem::Progress)) {
2821 LOGE("Invalid handle type");
2822 return NOTI_EX_ERROR_INVALID_PARAMETER;
2824 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2827 return NOTI_EX_ERROR_NONE;
2830 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
2832 if (handle == nullptr || max == nullptr) {
2833 LOGE("Invalid parameter");
2834 return NOTI_EX_ERROR_INVALID_PARAMETER;
2837 Handle *h = static_cast<Handle*>(handle);
2838 if (!h->IsValidType(AbstractItem::Progress)) {
2839 LOGE("Invalid handle type");
2840 return NOTI_EX_ERROR_INVALID_PARAMETER;
2842 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2845 return NOTI_EX_ERROR_NONE;
2848 extern "C" EXPORT_API int noti_ex_item_progress_get_type(noti_ex_item_h handle,
2850 if (handle == nullptr || type == nullptr) {
2851 LOGE("Invalid parameter");
2852 return NOTI_EX_ERROR_INVALID_PARAMETER;
2855 Handle *h = static_cast<Handle*>(handle);
2856 if (!h->IsValidType(AbstractItem::Progress)) {
2857 LOGE("Invalid handle type");
2858 return NOTI_EX_ERROR_INVALID_PARAMETER;
2860 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2861 *type = static_cast<noti_ex_item_progress_type_e>(p->GetProgressType());
2863 return NOTI_EX_ERROR_NONE;
2866 extern "C" EXPORT_API int noti_ex_item_progress_set_type(noti_ex_item_h handle,
2868 if (handle == nullptr) {
2869 LOGE("Invalid parameter");
2870 return NOTI_EX_ERROR_INVALID_PARAMETER;
2873 Handle *h = static_cast<Handle*>(handle);
2874 if (!h->IsValidType(AbstractItem::Progress)) {
2875 LOGE("Invalid handle type");
2876 return NOTI_EX_ERROR_INVALID_PARAMETER;
2878 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2879 p->SetProgressType(static_cast<ProgressItem::Type>(type));
2881 return NOTI_EX_ERROR_NONE;
2884 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
2885 noti_ex_reporter_events_s event_callbacks, void *data) {
2886 if (handle == nullptr) {
2887 LOGE("Invalid parameter");
2888 return NOTI_EX_ERROR_INVALID_PARAMETER;
2891 ReporterStub* stub = new (std::nothrow) ReporterStub(
2892 unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
2893 unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())));
2894 if (stub == nullptr) {
2895 LOGE("Fail to create manager");
2896 return NOTI_EX_ERROR_IO_ERROR;
2898 stub->SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo>(
2899 new ReporterCallbackInfo(event_callbacks, data)));
2901 *handle = static_cast<noti_ex_reporter_h>(stub);
2903 return NOTI_EX_ERROR_NONE;
2906 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
2907 if (handle == nullptr) {
2908 LOGE("Invalid parameter");
2909 return NOTI_EX_ERROR_INVALID_PARAMETER;
2911 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2913 return NOTI_EX_ERROR_NONE;
2916 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
2917 noti_ex_event_info_h info, noti_ex_error_e error) {
2918 if (handle == nullptr || info == nullptr) {
2919 LOGE("Invalid parameter");
2920 return NOTI_EX_ERROR_INVALID_PARAMETER;
2923 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2924 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2925 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2926 static_cast<NotificationError>(error));
2927 } catch (Exception &ex) {
2928 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2929 return NOTI_EX_ERROR_IO_ERROR;
2931 return NOTI_EX_ERROR_NONE;
2934 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
2935 noti_ex_item_h noti, int *request_id) {
2936 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2937 LOGE("Invalid parameter");
2938 return NOTI_EX_ERROR_INVALID_PARAMETER;
2941 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2942 Handle* h = static_cast<Handle*>(noti);
2943 if (h->GetPtr().get() == nullptr) {
2944 LOGE("Invalid noti reference can not be sended");
2945 return NOTI_EX_ERROR_INVALID_PARAMETER;
2947 *request_id = stub->Post(h->GetPtr());
2949 } catch (Exception &ex) {
2950 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2951 return NOTI_EX_ERROR_IO_ERROR;
2953 return NOTI_EX_ERROR_NONE;
2956 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
2957 noti_ex_item_h *noti_list, int count, int *request_id) {
2959 if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
2960 LOGE("Invalid parameter");
2961 return NOTI_EX_ERROR_INVALID_PARAMETER;
2964 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2965 list<shared_ptr<item::AbstractItem>> notiList;
2966 for (int i = 0; i < count; i++) {
2967 Handle* item = static_cast<Handle*>(noti_list[i]);
2968 notiList.push_back(item->GetPtr());
2970 *request_id = stub->Post(notiList);
2971 } catch (Exception &ex) {
2972 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2973 return NOTI_EX_ERROR_IO_ERROR;
2975 return NOTI_EX_ERROR_NONE;
2978 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
2979 noti_ex_item_h noti, int *request_id) {
2980 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2981 LOGE("Invalid parameter");
2982 return NOTI_EX_ERROR_INVALID_PARAMETER;
2985 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2986 Handle* item = static_cast<Handle*>(noti);
2987 if (item->GetPtr().get() == nullptr) {
2988 LOGE("Invalid noti reference can not be sended");
2989 return NOTI_EX_ERROR_INVALID_PARAMETER;
2991 *request_id = stub->Update(item->GetPtr());
2993 } catch (Exception &ex) {
2994 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2995 return NOTI_EX_ERROR_IO_ERROR;
2997 return NOTI_EX_ERROR_NONE;
3000 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
3001 noti_ex_item_h noti, int *request_id) {
3002 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3003 LOGE("Invalid parameter");
3004 return NOTI_EX_ERROR_INVALID_PARAMETER;
3007 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3008 Handle* item = static_cast<Handle*>(noti);
3009 if (item->GetPtr().get() == nullptr) {
3010 LOGE("Invalid noti reference can not be sended");
3011 return NOTI_EX_ERROR_INVALID_PARAMETER;
3013 *request_id = stub->Delete(item->GetPtr());
3015 } catch (Exception &ex) {
3016 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3017 return NOTI_EX_ERROR_IO_ERROR;
3019 return NOTI_EX_ERROR_NONE;
3022 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
3023 noti_ex_reporter_h handle, int *request_id) {
3024 if (handle == nullptr || request_id == nullptr) {
3025 LOGE("Invalid parameter");
3026 return NOTI_EX_ERROR_INVALID_PARAMETER;
3029 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3030 *request_id = stub->DeleteAll();
3031 } catch (Exception &ex) {
3032 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3033 return NOTI_EX_ERROR_IO_ERROR;
3035 return NOTI_EX_ERROR_NONE;
3038 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
3039 noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
3040 if (handle == nullptr || root_id == nullptr || item == nullptr) {
3041 LOGE("Invalid parameter");
3042 return NOTI_EX_ERROR_INVALID_PARAMETER;
3045 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3046 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
3047 if (ptr == nullptr) {
3048 LOGW("Not exist ID");
3050 return NOTI_EX_ERROR_NONE;
3052 *item = new Handle(ptr);
3053 } catch (Exception &ex) {
3054 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3055 return NOTI_EX_ERROR_IO_ERROR;
3057 return NOTI_EX_ERROR_NONE;
3060 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
3061 const char *id, const char *text, const char *hyperlink) {
3062 if (handle == nullptr || text == nullptr) {
3063 LOGE("Invalid parameter");
3064 return NOTI_EX_ERROR_INVALID_PARAMETER;
3070 p = new (std::nothrow) TextItem(id, std::string(text),
3071 std::string(hyperlink));
3073 p = new (std::nothrow) TextItem(id, std::string(text));
3076 LOGE("Out-of-memory");
3077 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3080 *handle = new Handle(shared_ptr<AbstractItem>(p));
3082 return NOTI_EX_ERROR_NONE;
3085 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
3086 const char *contents) {
3087 if (handle == nullptr || contents == nullptr) {
3088 LOGE("Invalid parameter");
3089 return NOTI_EX_ERROR_INVALID_PARAMETER;
3092 Handle* p = static_cast<Handle*>(handle);
3093 if (!p->IsValidType(AbstractItem::Text)) {
3094 LOGE("Invalid handle type");
3095 return NOTI_EX_ERROR_INVALID_PARAMETER;
3097 TextItem* ti = static_cast<TextItem*>(p->Get());
3098 ti->SetContents(std::string(contents));
3100 return NOTI_EX_ERROR_NONE;
3103 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
3105 if (handle == nullptr || contents == nullptr) {
3106 LOGE("Invalid parameter");
3107 return NOTI_EX_ERROR_INVALID_PARAMETER;
3110 Handle* p = static_cast<Handle*>(handle);
3111 if (!p->IsValidType(AbstractItem::Text)) {
3112 LOGE("Invalid handle type");
3113 return NOTI_EX_ERROR_INVALID_PARAMETER;
3116 TextItem* ti = static_cast<TextItem*>(p->Get());
3118 if (ti->GetMultiLanguage() != nullptr &&
3119 !ti->GetMultiLanguage()->GetTranslatedString().empty())
3120 str = ti->GetMultiLanguage()->GetTranslatedString();
3121 else if (!ti->GetContents().empty())
3122 str = ti->GetContents();
3124 *contents = strdup(str.c_str());
3125 if (*contents == nullptr) {
3126 LOGE("Out-of-memory");
3127 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3130 return NOTI_EX_ERROR_NONE;
3133 extern "C" EXPORT_API int noti_ex_item_text_get_hyperlink(
3134 noti_ex_item_h handle, char **hyper_link) {
3135 if (handle == nullptr || hyper_link == nullptr) {
3136 LOGE("Invalid parameter");
3137 return NOTI_EX_ERROR_INVALID_PARAMETER;
3140 Handle* p = static_cast<Handle*>(handle);
3141 if (!p->IsValidType(AbstractItem::Text)) {
3142 LOGE("Invalid handle type");
3143 return NOTI_EX_ERROR_INVALID_PARAMETER;
3145 TextItem* ti = static_cast<TextItem*>(p->Get());
3146 if (!ti->GetHyperLink().empty()) {
3147 *hyper_link = strdup(ti->GetHyperLink().c_str());
3148 if (*hyper_link == nullptr) {
3149 LOGE("Out-of-memory");
3150 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3153 *hyper_link = nullptr;
3156 return NOTI_EX_ERROR_NONE;
3159 extern "C" EXPORT_API int noti_ex_item_text_set_multi_language(
3160 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
3161 if (handle == nullptr) {
3162 LOGE("Invalid parameter");
3163 return NOTI_EX_ERROR_INVALID_PARAMETER;
3166 Handle* p = static_cast<Handle*>(handle);
3167 if (!p->IsValidType(AbstractItem::Text)) {
3168 LOGE("Invalid handle type");
3169 return NOTI_EX_ERROR_INVALID_PARAMETER;
3172 TextItem* ti = static_cast<TextItem*>(p->Get());
3173 if (multi == nullptr) {
3174 ti->SetMultiLanguage(nullptr);
3175 return NOTI_EX_ERROR_NONE;
3178 shared_ptr<MultiLanguage> mul_ptr =
3179 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
3180 ti->SetMultiLanguage(mul_ptr);
3181 ti->GetMultiLanguage()->UpdateString();
3183 return NOTI_EX_ERROR_NONE;
3186 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
3187 const char *id, time_t time) {
3190 if (handle == nullptr) {
3191 LOGE("Invalid parameter");
3192 return NOTI_EX_ERROR_INVALID_PARAMETER;
3197 p = new (std::nothrow) TimeItem(id, time);
3199 p = new (std::nothrow) TimeItem(time);
3201 p = new (std::nothrow) TimeItem();
3205 LOGE("Out-of-memory");
3206 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3209 *handle = new Handle(shared_ptr<AbstractItem>(p));
3211 return NOTI_EX_ERROR_NONE;
3214 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
3216 if (handle == nullptr || time == nullptr) {
3217 LOGE("Invalid parameter");
3218 return NOTI_EX_ERROR_INVALID_PARAMETER;
3220 Handle* h = static_cast<Handle*>(handle);
3221 if (!h->IsValidType(AbstractItem::Time)) {
3222 LOGE("Invalid handle type");
3223 return NOTI_EX_ERROR_INVALID_PARAMETER;
3225 TimeItem* p = static_cast<TimeItem*>(h->Get());
3226 *time = p->GetTime();
3228 return NOTI_EX_ERROR_NONE;
3231 extern "C" EXPORT_API int noti_ex_item_time_set_time(noti_ex_item_h handle,
3233 if (handle == nullptr) {
3234 LOGE("Invalid parameter");
3235 return NOTI_EX_ERROR_INVALID_PARAMETER;
3237 Handle* h = static_cast<Handle*>(handle);
3238 if (!h->IsValidType(AbstractItem::Time)) {
3239 LOGE("Invalid handle type");
3240 return NOTI_EX_ERROR_INVALID_PARAMETER;
3242 TimeItem* p = static_cast<TimeItem*>(h->Get());
3245 return NOTI_EX_ERROR_NONE;
3248 extern "C" EXPORT_API int noti_ex_action_visibility_create(
3249 noti_ex_action_h *handle, const char *extra) {
3250 if (handle == nullptr) {
3251 LOGE("Invalid parameter");
3252 return NOTI_EX_ERROR_INVALID_PARAMETER;
3255 string extra_str = "";
3257 extra_str = string(extra);
3259 shared_ptr<AbstractAction>* ptr = new (std::nothrow) shared_ptr<AbstractAction>(
3260 new (std::nothrow) VisibilityAction(extra_str));
3261 if (ptr == nullptr) {
3262 LOGE("Out-of-memory");
3263 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3268 return NOTI_EX_ERROR_NONE;
3271 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
3272 const char *id, bool visible) {
3273 if (handle == nullptr || id == nullptr) {
3274 LOGE("Invalid parameter");
3275 return NOTI_EX_ERROR_INVALID_PARAMETER;
3278 shared_ptr<AbstractAction>* ptr =
3279 static_cast<shared_ptr<AbstractAction>*>(handle);
3280 VisibilityAction* action = static_cast<VisibilityAction*>(ptr->get());
3281 action->SetVisibility(id, visible);
3283 return NOTI_EX_ERROR_NONE;
3286 extern "C" EXPORT_API int noti_ex_multi_lang_create(noti_ex_multi_lang_h* handle,
3287 const char* msgid, const char* format, ...) {
3288 if (handle == nullptr || msgid == nullptr || format == nullptr) {
3289 LOGE("Invalid parameter");
3290 return NOTI_EX_ERROR_INVALID_PARAMETER;
3293 const char* format_idx = format;
3296 va_start(args, format);
3297 while (*format_idx != '\0') {
3298 char* arg = nullptr;
3301 stringstream stream;
3302 if (*format_idx == '%') {
3303 switch (*(format_idx + 1)) {
3305 arg = va_arg(args, char *);
3306 arr.push_back(string(arg));
3309 arg_i = va_arg(args, int);
3310 arr.push_back(to_string(arg_i));
3313 arg_f = va_arg(args, double);
3314 stream << std::fixed << std::setprecision(2) << arg_f;
3315 arr.push_back(stream.str());
3323 MultiLanguage* p = new MultiLanguage(string(msgid), format, arr);
3325 LOGE("Out-of-memory");
3326 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3328 *handle = new shared_ptr<MultiLanguage>(p);
3330 return NOTI_EX_ERROR_NONE;
3333 extern "C" EXPORT_API int noti_ex_multi_lang_destroy(noti_ex_multi_lang_h handle) {
3334 if (handle == nullptr) {
3335 LOGE("Invalid parameter");
3336 return NOTI_EX_ERROR_INVALID_PARAMETER;
3339 shared_ptr<MultiLanguage>* mul_ptr =
3340 reinterpret_cast<shared_ptr<MultiLanguage>*>(handle);
3342 return NOTI_EX_ERROR_NONE;
3345 extern "C" EXPORT_API int noti_ex_item_get_private_id(
3346 noti_ex_item_h item, int64_t* private_id) {
3347 if (item == nullptr || private_id == nullptr) {
3348 LOGE("Invalid parameter");
3349 return NOTI_EX_ERROR_INVALID_PARAMETER;
3352 Handle* h = static_cast<Handle*>(item);
3353 *private_id = static_pointer_cast<IItemInfoInternal>(
3354 h->Get()->GetInfo())->GetPrivateId();
3356 return NOTI_EX_ERROR_NONE;
3359 extern "C" EXPORT_API int noti_ex_item_set_private_id(
3360 noti_ex_item_h item, int64_t priv_id) {
3361 if (item == nullptr) {
3362 LOGE("Invalid parameter");
3363 return NOTI_EX_ERROR_INVALID_PARAMETER;
3366 Handle* h = static_cast<Handle*>(item);
3367 static_pointer_cast<IItemInfoInternal>(
3368 h->Get()->GetInfo())->SetPrivateId(priv_id);
3370 return NOTI_EX_ERROR_NONE;
3373 extern "C" EXPORT_API int noti_ex_item_free_string_list(char** list, int count) {
3374 if (list == nullptr) {
3375 LOGE("Invalid parameter");
3376 return NOTI_EX_ERROR_INVALID_PARAMETER;
3379 LOGI("Free strings (%d)", count);
3380 for (int i = 0; i < count; i++)
3384 return NOTI_EX_ERROR_NONE;
3387 extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h handle) {
3388 if (handle == nullptr) {
3389 LOGE("Invalid parameter");
3390 return NOTI_EX_ERROR_INVALID_PARAMETER;
3392 Handle* h = static_cast<Handle*>(handle);
3393 if (!h->IsValidType(AbstractItem::Group)) {
3394 LOGE("Invalid handle type");
3395 return NOTI_EX_ERROR_INVALID_PARAMETER;
3397 GroupItem* p = static_cast<GroupItem*>(h->Get());
3398 p->RemoveChildren();
3400 return NOTI_EX_ERROR_NONE;