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_app_control_action.h"
26 #include "api/notification_ex_button.h"
27 #include "api/notification_ex_chat_message.h"
28 #include "api/notification_ex_checkbox.h"
29 #include "api/notification_ex_entry.h"
30 #include "api/notification_ex_event_info.h"
31 #include "api/notification_ex_group.h"
32 #include "api/notification_ex_image.h"
33 #include "api/notification_ex_input_selector.h"
34 #include "api/notification_ex_item.h"
35 #include "api/notification_ex_manager.h"
36 #include "api/notification_ex_progress.h"
37 #include "api/notification_ex_reporter.h"
38 #include "api/notification_ex_text.h"
39 #include "api/notification_ex_time.h"
40 #include "api/notification_ex_visibility_action.h"
41 #include "api/notification_ex_visibility_action.h"
42 #include "api/notification_ex_internal.h"
43 #include "notification-ex/reporter.h"
44 #include "notification-ex/app_control_action.h"
45 #include "notification-ex/button_item.h"
46 #include "notification-ex/chat_message_item.h"
47 #include "notification-ex/checkbox_item.h"
48 #include "notification-ex/entry_item.h"
49 #include "notification-ex/group_item.h"
50 #include "notification-ex/input_selector_item.h"
51 #include "notification-ex/abstract_item.h"
52 #include "notification-ex/progress_item.h"
53 #include "notification-ex/time_item.h"
54 #include "notification-ex/visibility_action.h"
55 #include "notification-ex/event_info_internal.h"
56 #include "notification-ex/manager.h"
57 #include "notification-ex/dbus_sender.h"
58 #include "notification-ex/dbus_event_listener.h"
59 #include "notification-ex/exception.h"
60 #include "notification-ex/iitem_info_internal.h"
65 #define LOG_TAG "NOTIFICATION_EX"
70 #define EXPORT_API __attribute__((visibility("default")))
73 using namespace tizen_base;
74 using namespace notification::item;
75 using namespace notification;
81 explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
82 explicit Handle(std::shared_ptr<item::AbstractItem> ptr)
83 : ref_(nullptr), ptr_(move(ptr)) { }
84 virtual ~Handle() = default;
85 item::AbstractItem* Get() const {
91 bool IsValidType(int type) const {
92 return (Get()->GetType() == type
93 || Get()->GetType() >= AbstractItem::Custom);
96 std::shared_ptr<item::AbstractItem> GetPtr() const {
98 return std::shared_ptr<item::AbstractItem>({});
103 item::AbstractItem* ref_;
104 std::shared_ptr<item::AbstractItem> ptr_;
107 class ManagerCallbackInfo {
109 ManagerCallbackInfo(noti_ex_manager_events_s cb, void* user_data)
110 : user_data_(user_data) {
111 cb_.added = cb.added;
112 cb_.updated = cb.updated;
113 cb_.deleted = cb.deleted;
114 cb_.error = cb.error;
117 void InvokeAdded(Manager* manager, const IEventInfo& info,
118 list<shared_ptr<AbstractItem>> addedItem) {
119 if (cb_.added == nullptr)
121 noti_ex_item_h* added_item =
122 (noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
123 if (added_item == nullptr) {
124 LOGE("Out of memory");
129 for (auto& i : addedItem) {
131 static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i)));
134 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
135 cb_.added(static_cast<noti_ex_manager_h>(manager),
136 static_cast<noti_ex_event_info_h>(c_info), added_item,
137 addedItem.size(), user_data_);
140 void InvokeUpdated(Manager* manager, const IEventInfo& info,
141 shared_ptr<item::AbstractItem> updatedItem) {
142 if (cb_.updated == nullptr)
144 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
145 cb_.updated(static_cast<noti_ex_manager_h>(manager),
146 static_cast<noti_ex_event_info_h>(c_info),
147 static_cast<noti_ex_item_h>(new Handle(updatedItem)), user_data_);
150 void InvokeDeleted(Manager* manager, const IEventInfo& info,
151 shared_ptr<item::AbstractItem> deletedItem) {
152 if (cb_.deleted == nullptr)
154 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
155 if (c_info->GetEventType() == static_cast<int>(IEventInfo::EventType::DeleteAll)) {
156 cb_.deleted(static_cast<noti_ex_manager_h>(manager),
157 static_cast<noti_ex_event_info_h>(c_info),
158 nullptr, user_data_);
160 cb_.deleted(static_cast<noti_ex_manager_h>(manager),
161 static_cast<noti_ex_event_info_h>(c_info),
162 static_cast<noti_ex_item_h>(
163 new Handle(deletedItem)), user_data_);
167 void InvokeError(Manager* manager, NotificationError error, int requestId) {
168 if (cb_.error == nullptr)
170 cb_.error(static_cast<noti_ex_manager_h>(manager),
171 static_cast<noti_ex_error_e>(error), requestId, user_data_);
175 noti_ex_manager_events_s cb_;
179 class ManagerStub : public Manager {
181 ManagerStub(std::unique_ptr<IEventSender> sender,
182 std::unique_ptr<IEventListener> listener, std::string receiver_group = "")
183 : Manager(move(sender), move(listener), receiver_group) {
186 void OnAdd(const IEventInfo& info,
187 list<shared_ptr<AbstractItem>> addedItem) override {
188 cb_->InvokeAdded(this, info, addedItem);
191 void OnUpdate(const IEventInfo& info,
192 std::shared_ptr<item::AbstractItem> updatedItem) override {
193 cb_->InvokeUpdated(this, info, updatedItem);
196 void OnDelete(const IEventInfo& info,
197 shared_ptr<item::AbstractItem> deletedItem) override {
198 cb_->InvokeDeleted(this, info, deletedItem);
201 void OnError(NotificationError error, int requestId) override {
202 cb_->InvokeError(this, error, requestId);
205 int SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo> ci) {
207 return NOTI_EX_ERROR_NONE;
210 int ClearManagerCallbackInfo() {
212 return NOTI_EX_ERROR_NONE;
216 unique_ptr<ManagerCallbackInfo> cb_;
220 class ReporterCallbackInfo {
222 ReporterCallbackInfo(noti_ex_reporter_events_s cb, void* user_data)
223 : user_data_(user_data) {
224 cb_.event = cb.event;
225 cb_.error = cb.error;
228 void InvokeEvent(Reporter* reporter, const IEventInfo& info,
229 list<shared_ptr<AbstractItem>> notiList) {
230 if (cb_.event == nullptr)
232 noti_ex_item_h* noti_list =
233 (noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
234 if (noti_list == nullptr) {
235 LOGE("Out of memory");
240 for (auto& i : notiList) {
242 static_cast<noti_ex_item_h>(new Handle(i));
245 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
246 cb_.event(static_cast<noti_ex_reporter_h>(reporter),
247 static_cast<noti_ex_event_info_h>(c_info), noti_list,
248 notiList.size(), user_data_);
252 void InvokeError(Reporter* reporter, NotificationError error, int requestId) {
253 if (cb_.error == nullptr)
255 cb_.error(static_cast<noti_ex_reporter_h>(reporter),
256 static_cast<noti_ex_error_e>(error), requestId, user_data_);
260 noti_ex_reporter_events_s cb_;
264 class ReporterStub : public Reporter {
266 ReporterStub(std::unique_ptr<IEventSender> sender,
267 std::unique_ptr<IEventListener> listener)
268 : Reporter(move(sender), move(listener)) {
271 void OnEvent(const IEventInfo& info,
272 std::list<std::shared_ptr<item::AbstractItem>> notiList) override {
273 cb_->InvokeEvent(this, info, notiList);
276 void OnError(NotificationError error, int requestId) override {
277 cb_->InvokeError(this, error, requestId);
280 int SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo> ci) {
282 return NOTI_EX_ERROR_NONE;
285 int ClearReporterCallbackInfo() {
287 return NOTI_EX_ERROR_NONE;
291 unique_ptr<ReporterCallbackInfo> cb_;
296 void __noti_ex_free_str_array(char** val, int length) {
298 for (i = 0; i < length ; i++)
303 extern "C" EXPORT_API int noti_ex_action_app_control_create(
304 noti_ex_action_h *handle, app_control_h app_control,
306 if (handle == nullptr || app_control == nullptr) {
307 LOGE("Invalid parameter");
308 return NOTI_EX_ERROR_INVALID_PARAMETER;
311 shared_ptr<AbstractAction>* p;
314 p = new (std::nothrow) shared_ptr<AbstractAction>(
315 new (std::nothrow) AppControlAction(app_control, extra));
317 p = new (std::nothrow) shared_ptr<AbstractAction>(
318 new (std::nothrow) AppControlAction(app_control));
322 LOGE("Out-of-memory");
323 return NOTI_EX_ERROR_OUT_OF_MEMORY;
328 return NOTI_EX_ERROR_NONE;
331 extern "C" EXPORT_API int noti_ex_action_app_control_set(
332 noti_ex_action_h handle, app_control_h app_control) {
333 if (handle == nullptr || app_control == nullptr) {
334 LOGE("Invalid parameter");
335 return NOTI_EX_ERROR_INVALID_PARAMETER;
338 shared_ptr<AbstractAction>* ptr =
339 static_cast<shared_ptr<AbstractAction>*>(handle);
340 AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
341 action->SetAppControl(app_control);
343 return NOTI_EX_ERROR_NONE;
346 extern "C" EXPORT_API int noti_ex_action_app_control_get(
347 noti_ex_action_h handle, app_control_h *app_control) {
348 if (handle == nullptr || app_control == nullptr) {
349 LOGE("Invalid parameter");
350 return NOTI_EX_ERROR_INVALID_PARAMETER;
353 shared_ptr<AbstractAction>* ptr =
354 static_cast<shared_ptr<AbstractAction>*>(handle);
355 AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
356 *app_control = action->GetAppControl();
358 return NOTI_EX_ERROR_NONE;
361 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
362 const char *id, const char *title) {
365 if (handle == nullptr || title == nullptr) {
366 LOGE("Invalid parameter");
367 return NOTI_EX_ERROR_INVALID_PARAMETER;
371 p = new (std::nothrow) ButtonItem(id, title);
373 p = new (std::nothrow) ButtonItem(title);
376 LOGE("Out-of-memory");
377 return NOTI_EX_ERROR_OUT_OF_MEMORY;
379 *handle = new Handle(shared_ptr<AbstractItem>(p));
381 return NOTI_EX_ERROR_NONE;
384 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
386 if (handle == nullptr || title == nullptr) {
387 LOGE("Invalid parameter");
388 return NOTI_EX_ERROR_INVALID_PARAMETER;
391 Handle* sp = static_cast<Handle*>(handle);
392 if (!sp->IsValidType(AbstractItem::Button)) {
393 LOGE("Invalid handle type");
394 return NOTI_EX_ERROR_INVALID_PARAMETER;
397 ButtonItem* p = static_cast<ButtonItem*>(sp->Get());
399 if (p->GetMultiLanguage() != nullptr &&
400 !p->GetMultiLanguage()->GetTranslatedString().empty())
401 str = p->GetMultiLanguage()->GetTranslatedString();
402 else if (!p->GetTitle().empty())
405 *title = strdup(str.c_str());
406 if (*title == nullptr) {
407 LOGE("Out-of-memory");
408 return NOTI_EX_ERROR_OUT_OF_MEMORY;
411 return NOTI_EX_ERROR_NONE;
414 extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title(
415 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
416 if (handle == nullptr) {
417 LOGE("Invalid parameter");
418 return NOTI_EX_ERROR_INVALID_PARAMETER;
421 Handle* p = static_cast<Handle*>(handle);
422 if (!p->IsValidType(AbstractItem::Button)) {
423 LOGE("Invalid handle type");
424 return NOTI_EX_ERROR_INVALID_PARAMETER;
427 ButtonItem* bi = static_cast<ButtonItem*>(p->Get());
428 if (multi == nullptr) {
429 bi->SetMultiLanguage(nullptr);
430 return NOTI_EX_ERROR_NONE;
433 shared_ptr<MultiLanguage> mul_ptr =
434 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
436 mul_ptr->UpdateString();
437 bi->SetMultiLanguage(mul_ptr);
439 return NOTI_EX_ERROR_NONE;
442 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
443 noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
444 noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
445 noti_ex_item_chat_message_type_e message_type) {
446 if (handle == nullptr || (text == nullptr && image == nullptr)
447 || name == nullptr || time == nullptr
448 || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
449 LOGE("Invalid parameter");
450 return NOTI_EX_ERROR_INVALID_PARAMETER;
453 auto* p = new (std::nothrow) ChatMessageItem(id,
454 dynamic_pointer_cast<TextItem>(static_cast<Handle*>(name)->GetPtr()),
455 text == nullptr ? nullptr
456 : dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
457 image == nullptr ? nullptr
458 : dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
459 dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
460 static_cast<ChatMessageItem::Type>(message_type));
462 LOGE("Out-of-memory");
463 return NOTI_EX_ERROR_OUT_OF_MEMORY;
466 *handle = new Handle(shared_ptr<AbstractItem>(p));
468 return NOTI_EX_ERROR_NONE;
471 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
472 noti_ex_item_h handle, noti_ex_item_h *name) {
473 if (handle == nullptr || name == nullptr) {
474 LOGE("Invalid parameter");
475 return NOTI_EX_ERROR_INVALID_PARAMETER;
477 Handle* h = static_cast<Handle*>(handle);
478 if (!h->IsValidType(AbstractItem::ChatMessage)) {
479 LOGE("Invalid handle type");
480 return NOTI_EX_ERROR_INVALID_PARAMETER;
482 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
483 if (p->GetNameItem().GetType() == AbstractItem::NullObject)
486 *name = new Handle(&(p->GetNameItem()));
488 return NOTI_EX_ERROR_NONE;
491 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
492 noti_ex_item_h handle, noti_ex_item_h *text) {
493 if (handle == nullptr || text == nullptr) {
494 LOGE("Invalid parameter");
495 return NOTI_EX_ERROR_INVALID_PARAMETER;
498 Handle* h = static_cast<Handle*>(handle);
499 if (!h->IsValidType(AbstractItem::ChatMessage)) {
500 LOGE("Invalid handle type");
501 return NOTI_EX_ERROR_INVALID_PARAMETER;
503 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
504 if (p->GetTextItem().GetType() == AbstractItem::NullObject)
507 *text = new Handle(&(p->GetTextItem()));
509 return NOTI_EX_ERROR_NONE;
512 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
513 noti_ex_item_h handle, noti_ex_item_h *image) {
514 if (handle == nullptr || image == nullptr) {
515 LOGE("Invalid parameter");
516 return NOTI_EX_ERROR_INVALID_PARAMETER;
519 Handle* h = static_cast<Handle*>(handle);
520 if (!h->IsValidType(AbstractItem::ChatMessage)) {
521 LOGE("Invalid handle type");
522 return NOTI_EX_ERROR_INVALID_PARAMETER;
524 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
525 if (p->GetImageItem().GetType() == AbstractItem::NullObject)
528 *image = new Handle(&(p->GetImageItem()));
530 return NOTI_EX_ERROR_NONE;
533 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
534 noti_ex_item_h handle, noti_ex_item_h *time) {
535 if (handle == nullptr || time == nullptr) {
536 LOGE("Invalid parameter");
537 return NOTI_EX_ERROR_INVALID_PARAMETER;
540 Handle* h = static_cast<Handle*>(handle);
541 if (!h->IsValidType(AbstractItem::ChatMessage)) {
542 LOGE("Invalid handle type");
543 return NOTI_EX_ERROR_INVALID_PARAMETER;
545 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
546 if (p->GetTimeItem().GetType() == AbstractItem::NullObject)
549 *time = new Handle(&(p->GetTimeItem()));
551 return NOTI_EX_ERROR_NONE;
554 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
555 noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
556 if (handle == nullptr || message_type == nullptr) {
557 LOGE("Invalid parameter");
558 return NOTI_EX_ERROR_INVALID_PARAMETER;
561 Handle* h = static_cast<Handle*>(handle);
562 if (!h->IsValidType(AbstractItem::ChatMessage)) {
563 LOGE("Invalid handle type");
564 return NOTI_EX_ERROR_INVALID_PARAMETER;
566 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
567 *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
569 return NOTI_EX_ERROR_NONE;
572 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
573 const char *id, const char *title, bool checked) {
576 if (handle == nullptr || title == nullptr) {
577 LOGE("Invalid parameter");
578 return NOTI_EX_ERROR_INVALID_PARAMETER;
581 p = new (std::nothrow) CheckBoxItem(id, title, checked);
583 LOGE("Out-of-memory");
584 return NOTI_EX_ERROR_OUT_OF_MEMORY;
587 *handle = new Handle(shared_ptr<AbstractItem>(p));
589 return NOTI_EX_ERROR_NONE;
592 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
594 if (handle == nullptr || title == nullptr) {
595 LOGE("Invalid parameter");
596 return NOTI_EX_ERROR_INVALID_PARAMETER;
598 Handle* h = static_cast<Handle*>(handle);
599 if (!h->IsValidType(AbstractItem::CheckBox)) {
600 LOGE("Invalid handle type");
601 return NOTI_EX_ERROR_INVALID_PARAMETER;
604 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
606 if (p->GetMultiLanguage() != nullptr &&
607 !p->GetMultiLanguage()->GetTranslatedString().empty())
608 str = p->GetMultiLanguage()->GetTranslatedString();
609 else if (!p->GetTitle().empty())
612 *title = strdup(str.c_str());
613 if (*title == nullptr) {
614 LOGE("Out-of-memory");
615 return NOTI_EX_ERROR_OUT_OF_MEMORY;
618 return NOTI_EX_ERROR_NONE;
621 extern "C" EXPORT_API int noti_ex_item_checkbox_set_multi_language_title(
622 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
623 if (handle == nullptr) {
624 LOGE("Invalid parameter");
625 return NOTI_EX_ERROR_INVALID_PARAMETER;
628 Handle* p = static_cast<Handle*>(handle);
629 if (!p->IsValidType(AbstractItem::CheckBox)) {
630 LOGE("Invalid handle type");
631 return NOTI_EX_ERROR_INVALID_PARAMETER;
634 CheckBoxItem* ci = static_cast<CheckBoxItem*>(p->Get());
635 if (multi == nullptr) {
636 ci->SetMultiLanguage(nullptr);
637 return NOTI_EX_ERROR_NONE;
640 shared_ptr<MultiLanguage> mul_ptr =
641 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
642 mul_ptr->UpdateString();
643 ci->SetMultiLanguage(mul_ptr);
645 return NOTI_EX_ERROR_NONE;
648 extern "C" EXPORT_API int noti_ex_item_checkbox_get_check_state(
649 noti_ex_item_h handle, bool *checked) {
650 if (handle == nullptr || checked == nullptr) {
651 LOGE("Invalid parameter");
652 return NOTI_EX_ERROR_INVALID_PARAMETER;
654 Handle* h = static_cast<Handle*>(handle);
655 if (!h->IsValidType(AbstractItem::CheckBox)) {
656 LOGE("Invalid handle type");
657 return NOTI_EX_ERROR_INVALID_PARAMETER;
659 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
660 *checked = p->IsChecked();
662 return NOTI_EX_ERROR_NONE;
665 extern "C" EXPORT_API int noti_ex_item_checkbox_set_check_state(
666 noti_ex_item_h handle, bool checked) {
667 if (handle == nullptr) {
668 LOGE("Invalid parameter");
669 return NOTI_EX_ERROR_INVALID_PARAMETER;
672 Handle* h = static_cast<Handle*>(handle);
673 if (!h->IsValidType(AbstractItem::CheckBox)) {
674 LOGE("Invalid handle type");
675 return NOTI_EX_ERROR_INVALID_PARAMETER;
678 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
679 p->SetChecked(checked);
681 return NOTI_EX_ERROR_NONE;
684 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
688 if (handle == nullptr) {
689 LOGE("Invalid parameter");
690 return NOTI_EX_ERROR_INVALID_PARAMETER;
693 p = new (std::nothrow) EntryItem(id);
695 LOGE("Out-of-memory");
696 return NOTI_EX_ERROR_OUT_OF_MEMORY;
699 *handle = new Handle(shared_ptr<AbstractItem>(p));
701 return NOTI_EX_ERROR_NONE;
704 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
706 if (handle == nullptr || text == nullptr) {
707 LOGE("Invalid parameter");
708 return NOTI_EX_ERROR_INVALID_PARAMETER;
711 Handle* h = static_cast<Handle*>(handle);
712 if (!h->IsValidType(AbstractItem::Entry)) {
713 LOGE("Invalid handle type");
714 return NOTI_EX_ERROR_INVALID_PARAMETER;
717 EntryItem* p = static_cast<EntryItem*>(h->Get());
719 if (p->GetMultiLanguage() != nullptr &&
720 !p->GetMultiLanguage()->GetTranslatedString().empty())
721 str = p->GetMultiLanguage()->GetTranslatedString();
722 else if (!p->GetText().empty())
725 *text = strdup(str.c_str());
726 if (*text == nullptr) {
727 LOGE("Out-of-memory");
728 return NOTI_EX_ERROR_OUT_OF_MEMORY;
731 return NOTI_EX_ERROR_NONE;
734 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
736 if (handle == nullptr || text == nullptr) {
737 LOGE("Invalid parameter");
738 return NOTI_EX_ERROR_INVALID_PARAMETER;
740 Handle* h = static_cast<Handle*>(handle);
741 if (!h->IsValidType(AbstractItem::Entry)) {
742 LOGE("Invalid handle type");
743 return NOTI_EX_ERROR_INVALID_PARAMETER;
745 EntryItem* p = static_cast<EntryItem*>(h->Get());
746 p->SetText(std::string(text));
748 return NOTI_EX_ERROR_NONE;
751 extern "C" EXPORT_API int noti_ex_item_entry_set_multi_language(
752 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
753 if (handle == nullptr) {
754 LOGE("Invalid parameter");
755 return NOTI_EX_ERROR_INVALID_PARAMETER;
758 Handle* p = static_cast<Handle*>(handle);
759 if (!p->IsValidType(AbstractItem::Entry)) {
760 LOGE("Invalid handle type");
761 return NOTI_EX_ERROR_INVALID_PARAMETER;
764 EntryItem* ei = static_cast<EntryItem*>(p->Get());
765 if (multi == nullptr) {
766 ei->SetMultiLanguage(nullptr);
767 return NOTI_EX_ERROR_NONE;
770 shared_ptr<MultiLanguage> mul_ptr =
771 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
772 ei->SetMultiLanguage(mul_ptr);
773 ei->GetMultiLanguage()->UpdateString();
775 return NOTI_EX_ERROR_NONE;
778 extern "C" EXPORT_API int noti_ex_event_info_clone(noti_ex_event_info_h handle,
779 noti_ex_event_info_h* cloned_handle) {
780 if (handle == nullptr || cloned_handle == nullptr) {
781 LOGE("Invalid parameter");
782 return NOTI_EX_ERROR_INVALID_PARAMETER;
785 Bundle cloned = static_cast<EventInfo*>(handle)->Serialize();
786 EventInfo* info = new EventInfo(cloned);
787 *cloned_handle = info;
788 return NOTI_EX_ERROR_NONE;
791 extern "C" EXPORT_API int noti_ex_event_info_destroy(
792 noti_ex_event_info_h handle) {
793 if (handle == nullptr) {
794 LOGE("Invalid parameter");
795 return NOTI_EX_ERROR_INVALID_PARAMETER;
797 EventInfo* info = static_cast<EventInfo*>(handle);
799 return NOTI_EX_ERROR_NONE;
802 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
803 noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
804 if (handle == nullptr || event_type == nullptr) {
805 LOGE("Invalid parameter");
806 return NOTI_EX_ERROR_INVALID_PARAMETER;
808 EventInfo* info = static_cast<EventInfo*>(handle);
809 *event_type = static_cast<noti_ex_event_info_type_e>(info->GetEventType());
811 return NOTI_EX_ERROR_NONE;
814 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
815 noti_ex_event_info_h handle, char **owner) {
816 if (handle == nullptr || owner == nullptr) {
817 LOGE("Invalid parameter");
818 return NOTI_EX_ERROR_INVALID_PARAMETER;
820 EventInfo* info = static_cast<EventInfo*>(handle);
821 *owner = strdup(info->GetOwner().c_str());
822 return NOTI_EX_ERROR_NONE;
825 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
826 noti_ex_event_info_h handle, char **channel) {
827 if (handle == nullptr || channel == nullptr) {
828 LOGE("Invalid parameter");
829 return NOTI_EX_ERROR_INVALID_PARAMETER;
831 EventInfo* info = static_cast<EventInfo*>(handle);
832 *channel = strdup(info->GetChannel().c_str());
833 return NOTI_EX_ERROR_NONE;
836 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
837 noti_ex_event_info_h handle, char **item_id) {
838 if (handle == nullptr || item_id == nullptr) {
839 LOGE("Invalid parameter");
840 return NOTI_EX_ERROR_INVALID_PARAMETER;
842 EventInfo* info = static_cast<EventInfo*>(handle);
843 *item_id = strdup(info->GetItemId().c_str());
844 return NOTI_EX_ERROR_NONE;
847 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
848 noti_ex_event_info_h handle, int *req_id) {
849 if (handle == nullptr || req_id == nullptr) {
850 LOGE("Invalid parameter");
851 return NOTI_EX_ERROR_INVALID_PARAMETER;
853 EventInfo* info = static_cast<EventInfo*>(handle);
854 *req_id = info->GetRequestId();
855 return NOTI_EX_ERROR_NONE;
858 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
862 if (handle == nullptr) {
863 LOGE("Invalid parameter");
864 return NOTI_EX_ERROR_INVALID_PARAMETER;
868 p = new (std::nothrow) GroupItem(id);
870 p = new (std::nothrow) GroupItem();
873 LOGE("Out-of-memory");
874 return NOTI_EX_ERROR_OUT_OF_MEMORY;
877 *handle = new Handle(shared_ptr<AbstractItem>(p));
879 return NOTI_EX_ERROR_NONE;
882 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
884 if (handle == nullptr) {
885 LOGE("Invalid parameter");
886 return NOTI_EX_ERROR_INVALID_PARAMETER;
888 Handle* h = static_cast<Handle*>(handle);
889 if (!h->IsValidType(AbstractItem::Group)) {
890 LOGE("Invalid handle type");
891 return NOTI_EX_ERROR_INVALID_PARAMETER;
893 GroupItem* p = static_cast<GroupItem*>(h->Get());
894 p->SetDirection(vertical);
896 return NOTI_EX_ERROR_NONE;
899 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
901 if (handle == nullptr) {
902 LOGE("Invalid parameter");
903 return NOTI_EX_ERROR_INVALID_PARAMETER;
905 Handle* h = static_cast<Handle*>(handle);
906 if (!h->IsValidType(AbstractItem::Group)) {
907 LOGE("Invalid handle type");
908 return NOTI_EX_ERROR_INVALID_PARAMETER;
910 GroupItem* p = static_cast<GroupItem*>(h->Get());
911 *vertical = p->IsVertical();
913 return NOTI_EX_ERROR_NONE;
916 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
918 if (handle == nullptr) {
919 LOGE("Invalid parameter");
920 return NOTI_EX_ERROR_INVALID_PARAMETER;
922 Handle* h = static_cast<Handle*>(handle);
923 if (!h->IsValidType(AbstractItem::Group)) {
924 LOGE("Invalid handle type");
925 return NOTI_EX_ERROR_INVALID_PARAMETER;
927 GroupItem* p = static_cast<GroupItem*>(h->Get());
928 if (!p->GetAppLabel().empty()) {
929 *label = strdup(p->GetAppLabel().c_str());
930 if (*label == nullptr) {
931 LOGE("Out-of-memory");
932 return NOTI_EX_ERROR_OUT_OF_MEMORY;
936 return NOTI_EX_ERROR_NONE;
939 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
940 noti_ex_item_h child) {
941 if (handle == nullptr || child == nullptr) {
942 LOGE("Invalid parameter");
943 return NOTI_EX_ERROR_INVALID_PARAMETER;
945 Handle* h = static_cast<Handle*>(handle);
946 if (!h->IsValidType(AbstractItem::Group)) {
947 LOGE("Invalid handle type");
948 return NOTI_EX_ERROR_INVALID_PARAMETER;
950 auto p = static_cast<GroupItem*>(h->Get());
951 p->AddChild((static_cast<Handle*>(child))->GetPtr());
953 return NOTI_EX_ERROR_NONE;
956 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
957 const char *item_id) {
958 if (handle == nullptr || item_id == nullptr) {
959 LOGE("Invalid parameter");
960 return NOTI_EX_ERROR_INVALID_PARAMETER;
962 Handle* h = static_cast<Handle*>(handle);
963 if (!h->IsValidType(AbstractItem::Group)) {
964 LOGE("Invalid handle type");
965 return NOTI_EX_ERROR_INVALID_PARAMETER;
967 GroupItem* p = static_cast<GroupItem*>(h->Get());
968 p->RemoveChild(std::string(item_id));
970 return NOTI_EX_ERROR_NONE;
973 extern "C" EXPORT_API int noti_ex_item_group_foreach_child(noti_ex_item_h handle,
974 noti_ex_item_group_foreach_child_cb callback, void *data) {
975 if (handle == nullptr || callback == nullptr) {
976 LOGE("Invalid parameter");
977 return NOTI_EX_ERROR_INVALID_PARAMETER;
980 Handle* h = static_cast<Handle*>(handle);
981 if (!h->IsValidType(AbstractItem::Group)) {
982 LOGE("Invalid handle type");
983 return NOTI_EX_ERROR_INVALID_PARAMETER;
985 GroupItem* p = static_cast<GroupItem*>(h->Get());
986 list<shared_ptr<AbstractItem>> children = p->GetChildren();
987 LOGI("Retrive (%zd)", children.size());
988 for (auto i : children) {
990 static_cast<noti_ex_item_h>(new Handle(i)), data);
991 if (ret != NOTI_EX_ERROR_NONE) {
992 LOGW("callback return (%d) stop foreach", ret);
997 return NOTI_EX_ERROR_NONE;
1000 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
1001 const char *id, const char *image_path) {
1004 if (handle == nullptr || image_path == nullptr) {
1005 LOGE("Invalid parameter");
1006 return NOTI_EX_ERROR_INVALID_PARAMETER;
1010 p = new (std::nothrow) ImageItem(id, image_path);
1012 p = new (std::nothrow) ImageItem(image_path);
1015 LOGE("Out-of-memory");
1016 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1019 *handle = new Handle(shared_ptr<AbstractItem>(p));
1021 return NOTI_EX_ERROR_NONE;
1024 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
1025 noti_ex_item_h handle, char **image_path) {
1026 if (handle == nullptr || image_path == nullptr) {
1027 LOGE("Invalid parameter");
1028 return NOTI_EX_ERROR_INVALID_PARAMETER;
1030 Handle* h = static_cast<Handle*>(handle);
1031 if (!h->IsValidType(AbstractItem::Image)) {
1032 LOGE("Invalid handle type");
1033 return NOTI_EX_ERROR_INVALID_PARAMETER;
1035 ImageItem* p = static_cast<ImageItem*>(h->Get());
1036 if (!p->GetImagePath().empty()) {
1037 *image_path = strdup(p->GetImagePath().c_str());
1038 if (*image_path == nullptr) {
1039 LOGE("Out-of-memory");
1040 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1044 return NOTI_EX_ERROR_NONE;
1047 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
1048 noti_ex_item_h *handle, const char *id) {
1049 InputSelectorItem* p;
1051 if (handle == nullptr) {
1052 LOGE("Invalid parameter");
1053 return NOTI_EX_ERROR_INVALID_PARAMETER;
1057 p = new (std::nothrow) InputSelectorItem(id);
1059 p = new (std::nothrow) InputSelectorItem();
1062 LOGE("Out-of-memory");
1063 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1066 *handle = new Handle(shared_ptr<AbstractItem>(p));
1068 return NOTI_EX_ERROR_NONE;
1071 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
1072 noti_ex_item_h handle, char ***contents_list, int *count) {
1073 if (handle == nullptr || contents_list == nullptr || count == nullptr) {
1074 LOGE("Invalid parameter");
1075 return NOTI_EX_ERROR_INVALID_PARAMETER;
1078 Handle* h = static_cast<Handle*>(handle);
1079 if (!h->IsValidType(AbstractItem::InputSelector)) {
1080 LOGE("Invalid handle type");
1081 return NOTI_EX_ERROR_INVALID_PARAMETER;
1084 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1085 vector<shared_ptr<MultiLanguage>> arr = p->GetMultiLanguageArr();
1086 list<string> contents;
1087 if (arr.size() == 0) {
1088 contents = p->GetContents();
1090 for (auto& i : arr) {
1091 contents.push_back(i->GetTranslatedString());
1095 char **list = (char**)calloc(contents.size(), sizeof(char*));
1096 if (list == nullptr) {
1097 LOGE("Out of memory");
1098 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1102 for (auto& i : contents) {
1103 list[idx] = strdup(i.c_str());
1104 if (list[idx] == nullptr) {
1105 __noti_ex_free_str_array(list, idx);
1106 LOGE("Out of memory");
1107 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1112 *count = contents.size();
1113 *contents_list = list;
1115 return NOTI_EX_ERROR_NONE;
1118 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
1119 noti_ex_item_h handle, const char **contents, int count) {
1120 if (handle == nullptr || contents == nullptr) {
1121 LOGE("Invalid parameter");
1122 return NOTI_EX_ERROR_INVALID_PARAMETER;
1125 list<string> new_contents;
1126 Handle* h = static_cast<Handle*>(handle);
1127 if (!h->IsValidType(AbstractItem::InputSelector)) {
1128 LOGE("Invalid handle type");
1129 return NOTI_EX_ERROR_INVALID_PARAMETER;
1131 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1132 for (int i = 0; i < count; i++) {
1133 new_contents.push_back(contents[i]);
1135 p->SetContents(move(new_contents));
1137 return NOTI_EX_ERROR_NONE;
1140 extern "C" EXPORT_API int noti_ex_item_input_selector_set_multi_language_contents(
1141 noti_ex_item_h handle, noti_ex_multi_lang_h* multi_language_list, int count) {
1142 if (handle == nullptr) {
1143 LOGE("Invalid parameter");
1144 return NOTI_EX_ERROR_INVALID_PARAMETER;
1147 Handle* p = static_cast<Handle*>(handle);
1148 if (!p->IsValidType(AbstractItem::InputSelector)) {
1149 LOGE("Invalid handle type");
1150 return NOTI_EX_ERROR_INVALID_PARAMETER;
1153 vector<shared_ptr<MultiLanguage>> m_list;
1154 for (int i = 0; i < count; i++) {
1155 shared_ptr<MultiLanguage> mul_ptr =
1156 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi_language_list[i]);
1157 mul_ptr->UpdateString();
1158 m_list.push_back(mul_ptr);
1161 InputSelectorItem* input = static_cast<InputSelectorItem*>(p->Get());
1162 input->SetMultiLanguage(m_list);
1164 return NOTI_EX_ERROR_NONE;
1167 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
1168 unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
1169 if (handle == nullptr) {
1170 LOGE("Invalid parameter");
1171 return NOTI_EX_ERROR_INVALID_PARAMETER;
1174 auto* ptr = new (std::nothrow) shared_ptr<Color>(
1175 new (std::nothrow) Color(a, r, g, b));
1176 if (ptr == nullptr || ptr->get() == nullptr) {
1177 LOGE("Out-of-memory");
1178 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1183 return NOTI_EX_ERROR_NONE;
1186 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
1187 if (handle == nullptr) {
1188 LOGE("Invalid parameter");
1189 return NOTI_EX_ERROR_INVALID_PARAMETER;
1192 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1195 return NOTI_EX_ERROR_NONE;
1198 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
1199 unsigned char *val) {
1200 if (handle == nullptr || val == nullptr) {
1201 LOGE("Invalid parameter");
1202 return NOTI_EX_ERROR_INVALID_PARAMETER;
1205 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1206 *val = (*p)->GetAVal();
1208 return NOTI_EX_ERROR_NONE;
1211 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
1212 unsigned char *val) {
1213 if (handle == nullptr || val == nullptr) {
1214 LOGE("Invalid parameter");
1215 return NOTI_EX_ERROR_INVALID_PARAMETER;
1218 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1219 *val = (*p)->GetRVal();
1221 return NOTI_EX_ERROR_NONE;
1224 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
1225 unsigned char *val) {
1226 if (handle == nullptr || val == nullptr) {
1227 LOGE("Invalid parameter");
1228 return NOTI_EX_ERROR_INVALID_PARAMETER;
1231 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1232 *val = (*p)->GetGVal();
1234 return NOTI_EX_ERROR_NONE;
1237 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
1238 unsigned char *val) {
1239 if (handle == nullptr || val == nullptr) {
1240 LOGE("Invalid parameter");
1241 return NOTI_EX_ERROR_INVALID_PARAMETER;
1244 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1245 *val = (*p)->GetBVal();
1247 return NOTI_EX_ERROR_NONE;
1250 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
1251 int left, int top, int right, int bottom) {
1252 if (handle == nullptr) {
1253 LOGE("Invalid parameter");
1254 return NOTI_EX_ERROR_INVALID_PARAMETER;
1257 auto* ptr = new (std::nothrow) shared_ptr<Padding>(
1258 new (std::nothrow) Padding(left, top, right, bottom));
1259 if (ptr == nullptr || ptr->get() == nullptr) {
1260 LOGE("Out-of-memory");
1261 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1266 return NOTI_EX_ERROR_NONE;
1269 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
1270 if (handle == nullptr) {
1271 LOGE("Invalid parameter");
1272 return NOTI_EX_ERROR_INVALID_PARAMETER;
1275 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1278 return NOTI_EX_ERROR_NONE;
1281 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
1283 if (handle == nullptr || val == nullptr) {
1284 LOGE("Invalid parameter");
1285 return NOTI_EX_ERROR_INVALID_PARAMETER;
1288 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1289 *val = (*p)->GetLeft();
1291 return NOTI_EX_ERROR_NONE;
1294 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
1296 if (handle == nullptr || val == nullptr) {
1297 LOGE("Invalid parameter");
1298 return NOTI_EX_ERROR_INVALID_PARAMETER;
1301 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1302 *val = (*p)->GetTop();
1304 return NOTI_EX_ERROR_NONE;
1307 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
1309 if (handle == nullptr || val == nullptr) {
1310 LOGE("Invalid parameter");
1311 return NOTI_EX_ERROR_INVALID_PARAMETER;
1314 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1315 *val = (*p)->GetRight();
1317 return NOTI_EX_ERROR_NONE;
1320 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
1322 if (handle == nullptr || val == nullptr) {
1323 LOGE("Invalid parameter");
1324 return NOTI_EX_ERROR_INVALID_PARAMETER;
1327 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1328 *val = (*p)->GetBottom();
1330 return NOTI_EX_ERROR_NONE;
1333 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
1334 int x, int y, int w, int h) {
1335 if (handle == nullptr) {
1336 LOGE("Invalid parameter");
1337 return NOTI_EX_ERROR_INVALID_PARAMETER;
1340 auto* ptr = new (std::nothrow) shared_ptr<Geometry>(
1341 new (std::nothrow) Geometry(x, y, w, h));
1342 if (ptr == nullptr || ptr->get() == nullptr) {
1343 LOGE("Out-of-memory");
1344 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1349 return NOTI_EX_ERROR_NONE;
1352 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
1353 if (handle == nullptr) {
1354 LOGE("Invalid parameter");
1355 return NOTI_EX_ERROR_INVALID_PARAMETER;
1358 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1361 return NOTI_EX_ERROR_NONE;
1364 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
1366 if (handle == nullptr || val == nullptr) {
1367 LOGE("Invalid parameter");
1368 return NOTI_EX_ERROR_INVALID_PARAMETER;
1371 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1372 *val = (*p)->GetX();
1374 return NOTI_EX_ERROR_NONE;
1377 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
1379 if (handle == nullptr || val == nullptr) {
1380 LOGE("Invalid parameter");
1381 return NOTI_EX_ERROR_INVALID_PARAMETER;
1384 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1385 *val = (*p)->GetY();
1387 return NOTI_EX_ERROR_NONE;
1390 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
1392 if (handle == nullptr || val == nullptr) {
1393 LOGE("Invalid parameter");
1394 return NOTI_EX_ERROR_INVALID_PARAMETER;
1397 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1398 *val = (*p)->GetWidth();
1400 return NOTI_EX_ERROR_NONE;
1403 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
1405 if (handle == nullptr || val == nullptr) {
1406 LOGE("Invalid parameter");
1407 return NOTI_EX_ERROR_INVALID_PARAMETER;
1410 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1411 *val = (*p)->GetHeight();
1413 return NOTI_EX_ERROR_NONE;
1416 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
1417 noti_ex_color_h color,
1418 noti_ex_padding_h padding,
1419 noti_ex_geometry_h geometry) {
1420 if (handle == nullptr) {
1421 LOGE("Invalid parameter");
1422 return NOTI_EX_ERROR_INVALID_PARAMETER;
1425 shared_ptr<Color> col = (color == nullptr) ?
1426 nullptr : *(static_cast<shared_ptr<Color>*>(color));
1427 shared_ptr<Padding> padd = (padding == nullptr) ?
1428 nullptr : *(static_cast<shared_ptr<Padding>*>(padding));
1429 shared_ptr<Geometry> geo = (geometry == nullptr) ?
1430 nullptr : *(static_cast<shared_ptr<Geometry>*>(geometry));
1432 auto* ptr = new (std::nothrow) shared_ptr<Style>(
1433 new (std::nothrow) Style(col, padd, geo));
1434 if (ptr == nullptr || ptr->get() == nullptr) {
1435 LOGE("Out-of-memory");
1436 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1441 return NOTI_EX_ERROR_NONE;
1444 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
1445 if (handle == nullptr) {
1446 LOGE("Invalid parameter");
1447 return NOTI_EX_ERROR_INVALID_PARAMETER;
1450 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1453 return NOTI_EX_ERROR_NONE;
1456 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
1457 noti_ex_padding_h *padding) {
1458 if (handle == nullptr || padding == nullptr) {
1459 LOGE("Invalid parameter");
1460 return NOTI_EX_ERROR_INVALID_PARAMETER;
1463 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1464 if ((*p)->GetPadding() == nullptr) {
1465 LOGW("Padding info is null");
1466 return NOTI_EX_ERROR_INVALID_PARAMETER;
1469 shared_ptr<Padding>* padd = new (std::nothrow) shared_ptr<Padding>(
1470 new (std::nothrow) Padding(*((*p)->GetPadding())));
1471 if (padd == nullptr || padd->get() == nullptr) {
1472 LOGE("Out-of-memory");
1473 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1478 return NOTI_EX_ERROR_NONE;
1482 extern "C" EXPORT_API int noti_ex_style_set_padding(noti_ex_style_h handle,
1483 noti_ex_padding_h padding) {
1484 if (handle == nullptr) {
1485 LOGE("Invalid parameter");
1486 return NOTI_EX_ERROR_INVALID_PARAMETER;
1489 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1490 if (padding == nullptr) {
1491 (*p)->SetPadding(nullptr);
1492 return NOTI_EX_ERROR_NONE;
1495 shared_ptr<Padding>* padd = static_cast<shared_ptr<Padding>*>(padding);
1496 (*p)->SetPadding(*padd);
1498 return NOTI_EX_ERROR_NONE;
1501 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
1502 noti_ex_color_h *color) {
1503 if (handle == nullptr || color == nullptr) {
1504 LOGE("Invalid parameter");
1505 return NOTI_EX_ERROR_INVALID_PARAMETER;
1508 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1509 if ((*p)->GetColor() == nullptr) {
1510 LOGW("Color info is null");
1511 return NOTI_EX_ERROR_INVALID_PARAMETER;
1514 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1515 new (std::nothrow) Color(*((*p)->GetColor())));
1516 if (col == nullptr || col->get() == nullptr) {
1517 LOGE("Out-of-memory");
1518 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1523 return NOTI_EX_ERROR_NONE;
1526 extern "C" EXPORT_API int noti_ex_style_set_color(
1527 noti_ex_style_h handle, noti_ex_color_h color) {
1528 if (handle == nullptr) {
1529 LOGE("Invalid parameter");
1530 return NOTI_EX_ERROR_INVALID_PARAMETER;
1533 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1534 if (color == nullptr) {
1535 (*p)->SetColor(nullptr);
1536 return NOTI_EX_ERROR_NONE;
1539 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1540 (*p)->SetColor(*col);
1542 return NOTI_EX_ERROR_NONE;
1545 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
1546 noti_ex_geometry_h *geometry) {
1547 if (handle == nullptr || geometry == nullptr) {
1548 LOGE("Invalid parameter");
1549 return NOTI_EX_ERROR_INVALID_PARAMETER;
1552 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1553 if ((*p)->GetGeometry() == nullptr) {
1554 LOGW("Geometry info is null");
1555 return NOTI_EX_ERROR_INVALID_PARAMETER;
1558 shared_ptr<Geometry>* geo = new (std::nothrow) shared_ptr<Geometry>(
1559 new (std::nothrow) Geometry(*((*p)->GetGeometry())));
1560 if (geo == nullptr || geo->get() == nullptr) {
1561 LOGE("Out-of-memory");
1562 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1567 return NOTI_EX_ERROR_NONE;
1570 extern "C" EXPORT_API int noti_ex_style_set_geometry(
1571 noti_ex_style_h handle, noti_ex_geometry_h geometry) {
1572 if (handle == nullptr) {
1573 LOGE("Invalid parameter");
1574 return NOTI_EX_ERROR_INVALID_PARAMETER;
1577 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1578 if (geometry == nullptr) {
1579 (*p)->SetGeometry(nullptr);
1580 return NOTI_EX_ERROR_NONE;
1583 shared_ptr<Geometry>* geo = static_cast<shared_ptr<Geometry>*>(geometry);
1584 (*p)->SetGeometry(*geo);
1586 return NOTI_EX_ERROR_NONE;
1589 extern "C" EXPORT_API int noti_ex_style_get_background_image(
1590 noti_ex_style_h handle, char** background_image) {
1591 if (handle == nullptr || background_image == nullptr) {
1592 LOGE("Invalid parameter");
1593 return NOTI_EX_ERROR_INVALID_PARAMETER;
1596 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1597 *background_image = strdup((*p)->GetBackgroundImage().c_str());
1599 return NOTI_EX_ERROR_NONE;
1602 extern "C" EXPORT_API int noti_ex_style_set_background_image(
1603 noti_ex_style_h handle, char* background_image) {
1604 if (handle == nullptr || background_image == nullptr) {
1605 LOGE("Invalid parameter");
1606 return NOTI_EX_ERROR_INVALID_PARAMETER;
1609 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1610 (*p)->SetBackgroundImage(background_image);
1612 return NOTI_EX_ERROR_NONE;
1615 extern "C" EXPORT_API int noti_ex_style_get_background_color(
1616 noti_ex_style_h handle, noti_ex_color_h* color) {
1617 if (handle == nullptr || color == nullptr) {
1618 LOGE("Invalid parameter");
1619 return NOTI_EX_ERROR_INVALID_PARAMETER;
1622 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1623 if ((*p)->GetBackgroundColor() == nullptr) {
1624 LOGW("Color info is null");
1625 return NOTI_EX_ERROR_INVALID_PARAMETER;
1628 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1629 new (std::nothrow) Color(*((*p)->GetBackgroundColor())));
1630 if (col == nullptr || col->get() == nullptr) {
1631 LOGE("Out-of-memory");
1632 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1637 return NOTI_EX_ERROR_NONE;
1640 extern "C" EXPORT_API int noti_ex_style_set_background_color(
1641 noti_ex_style_h handle, noti_ex_color_h color) {
1642 if (handle == nullptr || color == nullptr) {
1643 LOGE("Invalid parameter");
1644 return NOTI_EX_ERROR_INVALID_PARAMETER;
1647 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1648 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1649 (*p)->SetBackgroundColor(*col);
1651 return NOTI_EX_ERROR_NONE;
1654 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
1655 noti_ex_color_h color) {
1656 if (handle == nullptr || color == nullptr) {
1657 LOGE("Invalid parameter");
1658 return NOTI_EX_ERROR_INVALID_PARAMETER;
1661 shared_ptr<Color>* color_ptr = static_cast<shared_ptr<Color>*>(color);
1662 shared_ptr<LEDInfo>* p = new (std::nothrow) shared_ptr<LEDInfo>(
1663 new (std::nothrow) LEDInfo(*color_ptr));
1665 LOGE("Out-of-memory");
1666 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1671 return NOTI_EX_ERROR_NONE;
1674 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
1675 if (handle == nullptr) {
1676 LOGE("Invalid parameter");
1677 return NOTI_EX_ERROR_INVALID_PARAMETER;
1680 shared_ptr<LEDInfo>* led_ptr =
1681 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1683 return NOTI_EX_ERROR_NONE;
1686 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
1687 noti_ex_led_info_h handle, int ms) {
1688 if (handle == nullptr) {
1689 LOGE("Invalid parameter");
1690 return NOTI_EX_ERROR_INVALID_PARAMETER;
1693 shared_ptr<LEDInfo>* led_ptr =
1694 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1695 (*led_ptr)->SetOnPeriod(ms);
1697 return NOTI_EX_ERROR_NONE;
1700 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
1701 noti_ex_led_info_h handle, int *ms) {
1702 if (handle == nullptr || ms == nullptr) {
1703 LOGE("Invalid parameter");
1704 return NOTI_EX_ERROR_INVALID_PARAMETER;
1707 shared_ptr<LEDInfo>* led_ptr =
1708 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1709 *ms = (*led_ptr)->GetOnPeriod();
1711 return NOTI_EX_ERROR_NONE;
1714 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
1715 noti_ex_led_info_h handle, int ms) {
1716 if (handle == nullptr) {
1717 LOGE("Invalid parameter");
1718 return NOTI_EX_ERROR_INVALID_PARAMETER;
1721 shared_ptr<LEDInfo>* led_ptr =
1722 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1723 (*led_ptr)->SetOffPeriod(ms);
1725 return NOTI_EX_ERROR_NONE;
1728 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
1729 noti_ex_led_info_h handle, int *ms) {
1730 if (handle == nullptr) {
1731 LOGE("Invalid parameter");
1732 return NOTI_EX_ERROR_INVALID_PARAMETER;
1735 shared_ptr<LEDInfo>* led_ptr =
1736 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1737 *ms = (*led_ptr)->GetOffPeriod();
1739 return NOTI_EX_ERROR_NONE;
1742 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1743 noti_ex_led_info_h handle, noti_ex_color_h *color) {
1744 if (handle == nullptr) {
1745 LOGE("Invalid parameter");
1746 return NOTI_EX_ERROR_INVALID_PARAMETER;
1749 shared_ptr<LEDInfo>* led_ptr =
1750 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1751 if ((*led_ptr)->GetColor() == nullptr) {
1752 LOGE("Color is null");
1753 return NOTI_EX_ERROR_INVALID_PARAMETER;
1756 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1757 new (std::nothrow) Color(*((*led_ptr)->GetColor())));
1758 if (col == nullptr || col->get() == nullptr) {
1759 LOGE("Out-of-memory");
1760 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1765 return NOTI_EX_ERROR_NONE;
1768 extern "C" EXPORT_API int noti_ex_led_info_set_color(
1769 noti_ex_led_info_h handle, noti_ex_color_h color) {
1770 if (handle == nullptr) {
1771 LOGE("Invalid parameter");
1772 return NOTI_EX_ERROR_INVALID_PARAMETER;
1775 shared_ptr<LEDInfo>* p = static_cast<shared_ptr<LEDInfo>*>(handle);
1776 if (color == nullptr) {
1777 (*p)->SetColor(nullptr);
1778 return NOTI_EX_ERROR_NONE;
1781 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1782 (*p)->SetColor(*col);
1784 return NOTI_EX_ERROR_NONE;
1787 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1788 if (handle == nullptr) {
1789 LOGE("Invalid parameter");
1790 return NOTI_EX_ERROR_INVALID_PARAMETER;
1793 shared_ptr<AbstractAction>* ptr =
1794 static_cast<shared_ptr<AbstractAction>*>(handle);
1797 return NOTI_EX_ERROR_NONE;
1800 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1802 if (handle == nullptr || type == nullptr) {
1803 LOGE("Invalid parameter");
1804 return NOTI_EX_ERROR_INVALID_PARAMETER;
1807 shared_ptr<AbstractAction>* ptr =
1808 static_cast<shared_ptr<AbstractAction>*>(handle);
1809 *type = (*ptr)->GetType();
1811 return NOTI_EX_ERROR_NONE;
1814 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1816 if (handle == nullptr || local == nullptr) {
1817 LOGE("Invalid parameter");
1818 return NOTI_EX_ERROR_INVALID_PARAMETER;
1821 shared_ptr<AbstractAction>* ptr =
1822 static_cast<shared_ptr<AbstractAction>*>(handle);
1823 *local = (*ptr)->IsLocal();
1825 return NOTI_EX_ERROR_NONE;
1828 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1829 noti_ex_item_h item) {
1830 if (handle == nullptr || item == nullptr) {
1831 LOGE("Invalid parameter");
1832 return NOTI_EX_ERROR_INVALID_PARAMETER;
1834 shared_ptr<AbstractAction>* ptr =
1835 static_cast<shared_ptr<AbstractAction>*>(handle);
1836 Handle* ih = static_cast<Handle*>(item);
1837 (*ptr)->Execute(ih->GetPtr());
1839 return NOTI_EX_ERROR_NONE;
1842 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1844 if (handle == nullptr || extra == nullptr) {
1845 LOGE("Invalid parameter");
1846 return NOTI_EX_ERROR_INVALID_PARAMETER;
1849 shared_ptr<AbstractAction>* ptr =
1850 static_cast<shared_ptr<AbstractAction>*>(handle);
1851 if (!(*ptr)->GetExtra().empty()) {
1852 *extra = strdup((*ptr)->GetExtra().c_str());
1853 if (*extra == nullptr) {
1854 LOGE("Out-of-memory");
1855 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1859 return NOTI_EX_ERROR_NONE;
1862 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1863 noti_ex_item_info_h handle, int *hide_time) {
1864 if (handle == nullptr || hide_time == nullptr) {
1865 LOGE("Invalid parameter");
1866 return NOTI_EX_ERROR_INVALID_PARAMETER;
1868 IItemInfo* p = static_cast<IItemInfo*>(handle);
1869 *hide_time = p->GetHideTime();
1870 return NOTI_EX_ERROR_NONE;
1873 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1874 noti_ex_item_info_h handle, int hide_time) {
1875 if (handle == nullptr) {
1876 LOGE("Invalid parameter");
1877 return NOTI_EX_ERROR_INVALID_PARAMETER;
1879 IItemInfo* p = static_cast<IItemInfo*>(handle);
1880 p->SetHideTime(hide_time);
1881 return NOTI_EX_ERROR_NONE;
1884 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1885 noti_ex_item_info_h handle, int *delete_time) {
1886 if (handle == nullptr || delete_time == nullptr) {
1887 LOGE("Invalid parameter");
1888 return NOTI_EX_ERROR_INVALID_PARAMETER;
1890 IItemInfo* p = static_cast<IItemInfo*>(handle);
1891 *delete_time = p->GetDeleteTime();
1892 return NOTI_EX_ERROR_NONE;
1895 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
1896 noti_ex_item_info_h handle, int delete_time) {
1897 if (handle == nullptr) {
1898 LOGE("Invalid parameter");
1899 return NOTI_EX_ERROR_INVALID_PARAMETER;
1901 IItemInfo* p = static_cast<IItemInfo*>(handle);
1902 p->SetDeleteTime(delete_time);
1903 return NOTI_EX_ERROR_NONE;
1906 extern "C" EXPORT_API int noti_ex_item_info_get_time(
1907 noti_ex_item_info_h handle, time_t *time) {
1908 if (handle == nullptr || time == nullptr) {
1909 LOGE("Invalid parameter");
1910 return NOTI_EX_ERROR_INVALID_PARAMETER;
1913 IItemInfo* p = static_cast<IItemInfo*>(handle);
1914 *time = p->GetTime();
1915 return NOTI_EX_ERROR_NONE;
1918 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
1919 if (handle == nullptr) {
1920 LOGE("Invalid parameter");
1921 return NOTI_EX_ERROR_INVALID_PARAMETER;
1924 Handle* h = static_cast<Handle*>(handle);
1926 return NOTI_EX_ERROR_NONE;
1929 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
1930 const char *id, noti_ex_item_h *item) {
1931 if (handle == nullptr) {
1932 LOGE("Invalid parameter");
1933 return NOTI_EX_ERROR_INVALID_PARAMETER;
1936 Handle* p = static_cast<Handle*>(handle);
1937 AbstractItem& find_item = p->Get()->FindByID(string(id));
1938 if (find_item.GetType() == AbstractItem::NullObject) {
1939 LOGW("Not exist ID");
1941 return NOTI_EX_ERROR_NONE;
1944 *item = new Handle(&find_item);
1945 return NOTI_EX_ERROR_NONE;
1948 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
1950 if (handle == nullptr || type == nullptr) {
1951 LOGE("Invalid parameter");
1952 return NOTI_EX_ERROR_INVALID_PARAMETER;
1955 Handle* h = static_cast<Handle*>(handle);
1956 AbstractItem* p = h->Get();
1957 *type = p->GetType();
1958 return NOTI_EX_ERROR_NONE;
1961 extern "C" EXPORT_API int noti_ex_item_get_shared_paths(noti_ex_item_h handle,
1962 char ***path, int *count) {
1963 if (handle == nullptr || path == nullptr || count == nullptr) {
1964 LOGE("Invalid parameter");
1965 return NOTI_EX_ERROR_INVALID_PARAMETER;
1967 Handle* p = static_cast<Handle*>(handle);
1968 list<string> shared_path = p->Get()->GetSharedPath();
1969 char** tmp_path = (char**)calloc(shared_path.size(), sizeof(char*));
1970 if (tmp_path == nullptr) {
1971 LOGE("Fail to create items");
1972 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1976 for (auto& i : shared_path) {
1977 tmp_path[idx] = strdup(i.c_str());
1978 if (tmp_path[idx] == nullptr) {
1979 __noti_ex_free_str_array(tmp_path, idx);
1980 LOGE("Out of memory");
1981 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1987 *count = shared_path.size();
1988 return NOTI_EX_ERROR_NONE;
1991 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
1993 if (handle == nullptr || id == nullptr) {
1994 LOGE("Invalid parameter");
1995 return NOTI_EX_ERROR_INVALID_PARAMETER;
1997 Handle* h = static_cast<Handle*>(handle);
1998 AbstractItem* p = h->Get();
1999 *id = strdup(p->GetId().c_str());
2000 return NOTI_EX_ERROR_NONE;
2003 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
2005 if (handle == nullptr || id == nullptr) {
2006 LOGE("Invalid parameter");
2007 return NOTI_EX_ERROR_INVALID_PARAMETER;
2009 Handle* p = static_cast<Handle*>(handle);
2010 p->Get()->SetId(id);
2011 return NOTI_EX_ERROR_NONE;
2014 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
2015 noti_ex_action_h *action) {
2016 if (handle == nullptr || action == nullptr) {
2017 LOGE("Invalid parameter");
2018 return NOTI_EX_ERROR_INVALID_PARAMETER;
2020 Handle* p = static_cast<Handle*>(handle);
2021 if (p->Get()->GetAction() == nullptr) {
2023 return NOTI_EX_ERROR_NONE;
2025 *action = static_cast<noti_ex_action_h>(new shared_ptr<AbstractAction>(
2026 p->Get()->GetAction()));
2028 return NOTI_EX_ERROR_NONE;
2031 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
2032 noti_ex_action_h action) {
2033 if (handle == nullptr || action == nullptr) {
2034 LOGE("Invalid parameter");
2035 return NOTI_EX_ERROR_INVALID_PARAMETER;
2038 Handle* p = static_cast<Handle*>(handle);
2040 shared_ptr<AbstractAction>* ptr =
2041 static_cast<shared_ptr<AbstractAction>*>(action);
2042 p->Get()->SetAction(*ptr);
2043 return NOTI_EX_ERROR_NONE;
2046 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
2047 noti_ex_style_h *style) {
2048 if (handle == nullptr || style == nullptr) {
2049 LOGE("Invalid parameter");
2050 return NOTI_EX_ERROR_INVALID_PARAMETER;
2053 Handle* p = static_cast<Handle*>(handle);
2054 shared_ptr<Style> s = p->Get()->GetStyle();
2055 if (s == nullptr || s.get() == nullptr) {
2056 LOGW("Style is null");
2058 return NOTI_EX_ERROR_NONE;
2061 auto* ptr = new (std::nothrow) shared_ptr<Style>(new (std::nothrow) Style(*s));
2062 if (ptr == nullptr || ptr->get() == nullptr) {
2063 LOGE("Out of memory");
2064 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2068 return NOTI_EX_ERROR_NONE;
2071 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
2072 noti_ex_style_h style) {
2073 if (handle == nullptr || style == nullptr) {
2074 LOGE("Invalid parameter");
2075 return NOTI_EX_ERROR_INVALID_PARAMETER;
2078 Handle* p = static_cast<Handle*>(handle);
2079 shared_ptr<Style>* s = static_cast<shared_ptr<Style>*>(style);
2080 p->Get()->SetStyle(*s);
2081 return NOTI_EX_ERROR_NONE;
2084 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
2086 if (handle == nullptr) {
2087 LOGE("Invalid parameter");
2088 return NOTI_EX_ERROR_INVALID_PARAMETER;
2091 Handle* p = static_cast<Handle*>(handle);
2092 p->Get()->SetVisible(visible);
2093 return NOTI_EX_ERROR_NONE;
2096 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
2098 if (handle == nullptr || visible == nullptr) {
2099 LOGE("Invalid parameter");
2100 return NOTI_EX_ERROR_INVALID_PARAMETER;
2103 Handle* p = static_cast<Handle*>(handle);
2104 *visible = p->Get()->GetVisible();
2105 return NOTI_EX_ERROR_NONE;
2108 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
2110 if (handle == nullptr) {
2111 LOGE("Invalid parameter");
2112 return NOTI_EX_ERROR_INVALID_PARAMETER;
2115 Handle* p = static_cast<Handle*>(handle);
2116 p->Get()->SetEnable(enable);
2117 return NOTI_EX_ERROR_NONE;
2120 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
2122 if (handle == nullptr || enable == nullptr) {
2123 LOGE("Invalid parameter");
2124 return NOTI_EX_ERROR_INVALID_PARAMETER;
2127 Handle* p = static_cast<Handle*>(handle);
2128 *enable = p->Get()->GetEnable();
2129 return NOTI_EX_ERROR_NONE;
2132 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
2133 const char *receiver_group) {
2134 if (handle == nullptr || receiver_group == nullptr) {
2135 LOGE("Invalid parameter");
2136 return NOTI_EX_ERROR_INVALID_PARAMETER;
2139 Handle* p = static_cast<Handle*>(handle);
2140 p->Get()->AddReceiver(receiver_group);
2141 return NOTI_EX_ERROR_NONE;
2144 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
2145 const char *receiver_group) {
2146 if (handle == nullptr || receiver_group == nullptr) {
2147 LOGE("Invalid parameter");
2148 return NOTI_EX_ERROR_INVALID_PARAMETER;
2151 Handle* p = static_cast<Handle*>(handle);
2152 p->Get()->RemoveReceiver(receiver_group);
2153 return NOTI_EX_ERROR_NONE;
2156 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
2157 char ***receiver_list, int *count) {
2158 if (handle == nullptr || receiver_list == nullptr || count == nullptr) {
2159 LOGE("Invalid parameter");
2160 return NOTI_EX_ERROR_INVALID_PARAMETER;
2163 Handle* p = static_cast<Handle*>(handle);
2164 list<string> receivers = p->Get()->GetReceiverList();
2165 char **tmp_list = (char**)calloc(receivers.size(), sizeof(char*));
2166 if (tmp_list == nullptr) {
2167 LOGE("Out of memory");
2168 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2172 for (auto& i : receivers) {
2173 tmp_list[idx] = strdup(i.c_str());
2174 if (tmp_list[idx] == nullptr) {
2175 __noti_ex_free_str_array(tmp_list, idx);
2176 LOGE("Out of memory");
2177 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2182 *receiver_list = tmp_list;
2183 *count = receivers.size();
2184 return NOTI_EX_ERROR_NONE;
2187 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
2189 if (handle == nullptr) {
2190 LOGE("Invalid parameter");
2191 return NOTI_EX_ERROR_INVALID_PARAMETER;
2194 Handle* p = static_cast<Handle*>(handle);
2195 p->Get()->SetPolicy(policy);
2196 return NOTI_EX_ERROR_NONE;
2199 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
2201 if (handle == nullptr || policy == nullptr) {
2202 LOGE("Invalid parameter");
2203 return NOTI_EX_ERROR_INVALID_PARAMETER;
2206 Handle* p = static_cast<Handle*>(handle);
2207 *policy = p->Get()->GetPolicy();
2208 return NOTI_EX_ERROR_NONE;
2211 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
2213 if (handle == nullptr || channel == nullptr) {
2214 LOGE("Invalid parameter");
2215 return NOTI_EX_ERROR_INVALID_PARAMETER;
2218 Handle* p = static_cast<Handle*>(handle);
2219 if (!p->Get()->GetChannel().empty())
2220 *channel = strdup(p->Get()->GetChannel().c_str());
2224 return NOTI_EX_ERROR_NONE;
2227 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
2228 const char *channel) {
2229 if (handle == nullptr) {
2230 LOGE("Invalid parameter");
2231 return NOTI_EX_ERROR_INVALID_PARAMETER;
2234 Handle* p = static_cast<Handle*>(handle);
2235 p->Get()->SetChannel(channel);
2236 return NOTI_EX_ERROR_NONE;
2239 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
2240 noti_ex_led_info_h led) {
2241 if (handle == nullptr) {
2242 LOGE("Invalid parameter");
2243 return NOTI_EX_ERROR_INVALID_PARAMETER;
2246 Handle* p = static_cast<Handle*>(handle);
2247 if (led == nullptr) {
2248 p->Get()->SetLEDInfo(nullptr);
2249 return NOTI_EX_ERROR_NONE;
2251 shared_ptr<LEDInfo>* led_ptr =
2252 reinterpret_cast<shared_ptr<LEDInfo>*>(led);
2253 p->Get()->SetLEDInfo(*led_ptr);
2254 return NOTI_EX_ERROR_NONE;
2257 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
2258 noti_ex_led_info_h *led) {
2259 if (handle == nullptr) {
2260 LOGE("Invalid parameter");
2261 return NOTI_EX_ERROR_INVALID_PARAMETER;
2264 Handle* p = static_cast<Handle*>(handle);
2265 if (p->Get()->GetLEDInfo() != nullptr)
2266 *led = new shared_ptr<LEDInfo>(p->Get()->GetLEDInfo());
2269 return NOTI_EX_ERROR_NONE;
2272 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
2274 if (handle == nullptr) {
2275 LOGE("Invalid parameter");
2276 return NOTI_EX_ERROR_INVALID_PARAMETER;
2279 Handle* p = static_cast<Handle*>(handle);
2280 if (path == nullptr)
2281 p->Get()->SetSoundPath("");
2283 p->Get()->SetSoundPath(path);
2284 return NOTI_EX_ERROR_NONE;
2287 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
2289 if (handle == nullptr) {
2290 LOGE("Invalid parameter");
2291 return NOTI_EX_ERROR_INVALID_PARAMETER;
2294 Handle* p = static_cast<Handle*>(handle);
2295 if (path == nullptr)
2296 p->Get()->SetVibrationPath("");
2298 p->Get()->SetVibrationPath(path);
2299 return NOTI_EX_ERROR_NONE;
2302 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
2304 if (handle == nullptr || path == nullptr) {
2305 LOGE("Invalid parameter");
2306 return NOTI_EX_ERROR_INVALID_PARAMETER;
2309 Handle* p = static_cast<Handle*>(handle);
2310 if (p->Get()->GetSoundPath().empty())
2313 *path = strdup(p->Get()->GetSoundPath().c_str());
2314 return NOTI_EX_ERROR_NONE;
2317 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
2319 if (handle == nullptr || path == nullptr) {
2320 LOGE("Invalid parameter");
2321 return NOTI_EX_ERROR_INVALID_PARAMETER;
2324 Handle* p = static_cast<Handle*>(handle);
2325 if (p->Get()->GetVibrationPath().empty())
2328 *path = strdup(p->Get()->GetVibrationPath().c_str());
2329 return NOTI_EX_ERROR_NONE;
2332 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
2333 noti_ex_item_info_h *info) {
2334 if (handle == nullptr || info == nullptr) {
2335 LOGE("Invalid parameter");
2336 return NOTI_EX_ERROR_INVALID_PARAMETER;
2339 Handle* p = static_cast<Handle*>(handle);
2340 if (p->Get()->GetInfo() == nullptr)
2343 *info = static_cast<noti_ex_item_info_h>(p->Get()->GetInfo().get());
2344 return NOTI_EX_ERROR_NONE;
2347 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
2349 if (handle == nullptr || id == nullptr) {
2350 LOGE("Invalid parameter");
2351 return NOTI_EX_ERROR_INVALID_PARAMETER;
2354 Handle* p = static_cast<Handle*>(handle);
2355 if (p->Get()->GetSenderAppId().empty())
2358 *id = strdup(p->Get()->GetSenderAppId().c_str());
2359 return NOTI_EX_ERROR_NONE;
2362 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
2364 if (handle == nullptr || tag == nullptr) {
2365 LOGE("Invalid parameter");
2366 return NOTI_EX_ERROR_INVALID_PARAMETER;
2369 Handle* p = static_cast<Handle*>(handle);
2370 if (p->Get()->GetTag().empty())
2373 *tag = strdup(p->Get()->GetTag().c_str());
2374 return NOTI_EX_ERROR_NONE;
2377 extern "C" EXPORT_API int noti_ex_item_set_tag(noti_ex_item_h handle,
2379 if (handle == nullptr) {
2380 LOGE("Invalid parameter");
2381 return NOTI_EX_ERROR_INVALID_PARAMETER;
2384 Handle* p = static_cast<Handle*>(handle);
2386 p->Get()->SetTag("");
2388 p->Get()->SetTag(tag);
2389 return NOTI_EX_ERROR_NONE;
2392 extern "C" EXPORT_API int noti_ex_item_get_ongoing_state(noti_ex_item_h handle,
2394 if (handle == nullptr || ongoing == nullptr) {
2395 LOGE("Invalid parameter");
2396 return NOTI_EX_ERROR_INVALID_PARAMETER;
2399 Handle* p = static_cast<Handle*>(handle);
2400 *ongoing = p->Get()->GetOnGoingState();
2402 return NOTI_EX_ERROR_NONE;
2405 extern "C" EXPORT_API int noti_ex_item_set_ongoing_state(noti_ex_item_h handle,
2407 if (handle == nullptr) {
2408 LOGE("Invalid parameter");
2409 return NOTI_EX_ERROR_INVALID_PARAMETER;
2412 Handle* p = static_cast<Handle*>(handle);
2413 p->Get()->SetOnGoingState(ongoing);
2415 return NOTI_EX_ERROR_NONE;
2418 extern "C" EXPORT_API int noti_ex_item_check_type_exist(noti_ex_item_h handle,
2419 int type, bool* exist) {
2420 if (handle == nullptr || exist == nullptr) {
2421 LOGE("Invalid parameter");
2422 return NOTI_EX_ERROR_INVALID_PARAMETER;
2425 Handle* p = static_cast<Handle*>(handle);
2426 *exist = p->Get()->IsItemTypeExist(type);
2428 return NOTI_EX_ERROR_NONE;
2431 extern "C" EXPORT_API int noti_ex_item_get_main_type(noti_ex_item_h handle,
2433 if (handle == nullptr || type == nullptr) {
2434 LOGE("Invalid parameter");
2435 return NOTI_EX_ERROR_INVALID_PARAMETER;
2438 Handle* p = static_cast<Handle*>(handle);
2439 *type = p->Get()->GetMainType();
2441 return NOTI_EX_ERROR_NONE;
2444 extern "C" EXPORT_API int noti_ex_item_set_main_type(noti_ex_item_h handle,
2445 const char* id, int type) {
2446 if (handle == nullptr || id == nullptr) {
2447 LOGE("Invalid parameter");
2448 return NOTI_EX_ERROR_INVALID_PARAMETER;
2451 Handle* p = static_cast<Handle*>(handle);
2452 if (!(p->Get()->SetMainType(string(id),
2453 static_cast<AbstractItem::MainType>(type))))
2454 return NOTI_EX_ERROR_INVALID_PARAMETER;
2456 return NOTI_EX_ERROR_NONE;
2459 extern "C" EXPORT_API int noti_ex_item_find_by_main_type(noti_ex_item_h handle,
2460 int type, noti_ex_item_h* item) {
2461 if (handle == nullptr || item == nullptr) {
2462 LOGE("Invalid parameter");
2463 return NOTI_EX_ERROR_INVALID_PARAMETER;
2466 Handle* h = static_cast<Handle*>(handle);
2467 if (!h->IsValidType(AbstractItem::Group)) {
2468 LOGE("Invalid handle type");
2469 return NOTI_EX_ERROR_INVALID_PARAMETER;
2472 GroupItem* p = static_cast<GroupItem*>(h->Get());
2473 AbstractItem& find_item = p->FindByMainType(static_cast<AbstractItem::MainType>(type));
2474 if (find_item.GetType() == AbstractItem::NullObject) {
2475 LOGW("Not exist ID");
2477 return NOTI_EX_ERROR_NONE;
2479 *item = new Handle(&find_item);
2481 return NOTI_EX_ERROR_NONE;
2484 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
2485 const char *receiver_group, noti_ex_manager_events_s event_callbacks,
2487 if (handle == nullptr) {
2488 LOGE("Invalid parameter");
2489 return NOTI_EX_ERROR_INVALID_PARAMETER;
2492 string receiver_group_str = "";
2494 receiver_group_str = string(receiver_group);
2496 ManagerStub* stub = new (std::nothrow) ManagerStub(
2497 unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
2498 unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
2499 receiver_group_str);
2500 if (stub == nullptr) {
2501 LOGE("Fail to create manager");
2502 return NOTI_EX_ERROR_IO_ERROR;
2504 stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
2505 new ManagerCallbackInfo(event_callbacks, data)));
2506 *handle = static_cast<noti_ex_manager_h>(stub);
2508 return NOTI_EX_ERROR_NONE;
2511 extern "C" EXPORT_API int noti_ex_manager_destroy(noti_ex_manager_h handle) {
2512 if (handle == nullptr) {
2513 LOGE("Invalid parameter");
2514 return NOTI_EX_ERROR_INVALID_PARAMETER;
2516 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2518 return NOTI_EX_ERROR_NONE;
2521 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
2522 noti_ex_item_h **items, int *count) {
2523 if (handle == nullptr || items == nullptr || count == nullptr) {
2524 LOGE("Invalid parameter");
2525 return NOTI_EX_ERROR_INVALID_PARAMETER;
2529 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2530 list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
2531 if (item_list.size() == 0) {
2534 return NOTI_EX_ERROR_NONE;
2536 noti_ex_item_h* added_item =
2537 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2538 if (added_item == nullptr) {
2539 LOGE("Fail to create items");
2540 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2544 for (auto& i : item_list) {
2545 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2547 *items = added_item;
2548 *count = item_list.size();
2549 } catch (Exception &ex) {
2550 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2551 return NOTI_EX_ERROR_IO_ERROR;
2553 return NOTI_EX_ERROR_NONE;
2556 extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
2557 noti_ex_manager_h handle, char* channel, noti_ex_item_h** items, int* count) {
2558 if (handle == nullptr || channel == nullptr ||
2559 items == nullptr || count == nullptr) {
2560 LOGE("Invalid parameter");
2561 return NOTI_EX_ERROR_INVALID_PARAMETER;
2565 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2566 list<unique_ptr<item::AbstractItem>> item_list = stub->Get(channel);
2567 if (item_list.size() == 0) {
2570 return NOTI_EX_ERROR_NONE;
2572 noti_ex_item_h* added_item =
2573 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2574 if (added_item == nullptr) {
2575 LOGE("Fail to create items");
2576 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2580 for (auto& i : item_list) {
2581 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2583 *items = added_item;
2584 *count = item_list.size();
2585 } catch (Exception &ex) {
2586 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2587 return NOTI_EX_ERROR_IO_ERROR;
2590 return NOTI_EX_ERROR_NONE;
2593 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
2594 noti_ex_item_h noti, int *request_id) {
2595 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2596 LOGE("Invalid parameter");
2597 return NOTI_EX_ERROR_INVALID_PARAMETER;
2600 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2601 Handle* sp = static_cast<Handle*>(noti);
2602 if (sp->GetPtr().get() == nullptr) {
2603 LOGE("Invalid noti reference can not be sended");
2604 return NOTI_EX_ERROR_INVALID_PARAMETER;
2606 *request_id = stub->Update(sp->GetPtr());
2608 } catch (Exception &ex) {
2609 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2610 return NOTI_EX_ERROR_IO_ERROR;
2612 return NOTI_EX_ERROR_NONE;
2615 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
2616 noti_ex_item_h noti, int *request_id) {
2617 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2618 LOGE("Invalid parameter");
2619 return NOTI_EX_ERROR_INVALID_PARAMETER;
2622 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2623 Handle* item = static_cast<Handle*>(noti);
2624 if (item->GetPtr().get() == nullptr) {
2625 LOGE("Invalid noti reference can not be sended");
2626 return NOTI_EX_ERROR_INVALID_PARAMETER;
2628 *request_id = stub->Delete(item->GetPtr());
2630 } catch (Exception &ex) {
2631 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2632 return NOTI_EX_ERROR_IO_ERROR;
2634 return NOTI_EX_ERROR_NONE;
2637 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
2639 if (handle == nullptr || request_id == nullptr) {
2640 LOGE("Invalid parameter");
2641 return NOTI_EX_ERROR_INVALID_PARAMETER;
2644 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2645 *request_id = stub->DeleteAll();
2646 } catch (Exception &ex) {
2647 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2648 return NOTI_EX_ERROR_IO_ERROR;
2650 return NOTI_EX_ERROR_NONE;
2653 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
2654 noti_ex_item_h noti, int *request_id) {
2655 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2656 LOGE("Invalid parameter");
2657 return NOTI_EX_ERROR_INVALID_PARAMETER;
2660 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2661 Handle* item = static_cast<Handle*>(noti);
2662 if (item->GetPtr().get() == nullptr) {
2663 LOGE("Invalid noti reference can not be sended");
2664 return NOTI_EX_ERROR_INVALID_PARAMETER;
2666 *request_id = stub->Hide(item->GetPtr());
2668 } catch (Exception &ex) {
2669 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2670 return NOTI_EX_ERROR_IO_ERROR;
2672 return NOTI_EX_ERROR_NONE;
2675 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
2676 noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
2677 if (handle == nullptr || root_id == nullptr || item == nullptr) {
2678 LOGE("Invalid parameter");
2679 return NOTI_EX_ERROR_INVALID_PARAMETER;
2682 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2683 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
2684 if (ptr == nullptr) {
2685 LOGW("Not exist ID");
2687 return NOTI_EX_ERROR_NONE;
2689 *item = new Handle(ptr);
2690 } catch (Exception &ex) {
2691 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2692 return NOTI_EX_ERROR_IO_ERROR;
2694 return NOTI_EX_ERROR_NONE;
2697 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
2698 noti_ex_event_info_h info, noti_ex_error_e error) {
2699 if (handle == nullptr || info == nullptr) {
2700 LOGE("Invalid parameter");
2701 return NOTI_EX_ERROR_INVALID_PARAMETER;
2704 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2705 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2706 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2707 static_cast<NotificationError>(error));
2708 } catch (Exception &ex) {
2709 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2710 return NOTI_EX_ERROR_IO_ERROR;
2712 return NOTI_EX_ERROR_NONE;
2715 extern "C" EXPORT_API int noti_ex_manager_get_notification_count(
2716 noti_ex_manager_h handle, int *cnt) {
2718 if (handle == nullptr || cnt == nullptr) {
2719 LOGE("Invalid parameter");
2720 return NOTI_EX_ERROR_INVALID_PARAMETER;
2723 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2724 *cnt = stub->GetCount();
2725 } catch (Exception &ex) {
2726 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2727 return NOTI_EX_ERROR_IO_ERROR;
2729 return NOTI_EX_ERROR_NONE;
2732 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
2733 const char *id, float min, float current, float max) {
2736 if (handle == nullptr) {
2737 LOGE("Invalid parameter");
2738 return NOTI_EX_ERROR_INVALID_PARAMETER;
2742 p = new (std::nothrow) ProgressItem(id, min, current, max);
2744 p = new (std::nothrow) ProgressItem(min, current, max);
2747 LOGE("Out-of-memory");
2748 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2751 *handle = new Handle(shared_ptr<AbstractItem>(p));
2753 return NOTI_EX_ERROR_NONE;
2756 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
2757 noti_ex_item_h handle, float *current) {
2758 if (handle == nullptr || current == nullptr) {
2759 LOGE("Invalid parameter");
2760 return NOTI_EX_ERROR_INVALID_PARAMETER;
2763 Handle *h = static_cast<Handle*>(handle);
2764 if (!h->IsValidType(AbstractItem::Progress)) {
2765 LOGE("Invalid handle type");
2766 return NOTI_EX_ERROR_INVALID_PARAMETER;
2768 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2769 *current = p->GetCurrent();
2771 return NOTI_EX_ERROR_NONE;
2774 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
2775 noti_ex_item_h handle, float current) {
2776 if (handle == nullptr) {
2777 LOGE("Invalid parameter");
2778 return NOTI_EX_ERROR_INVALID_PARAMETER;
2781 Handle *h = static_cast<Handle*>(handle);
2782 if (!h->IsValidType(AbstractItem::Progress)) {
2783 LOGE("Invalid handle type");
2784 return NOTI_EX_ERROR_INVALID_PARAMETER;
2786 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2787 p->SetCurrent(current);
2789 return NOTI_EX_ERROR_NONE;
2792 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
2794 if (handle == nullptr || min == nullptr) {
2795 LOGE("Invalid parameter");
2796 return NOTI_EX_ERROR_INVALID_PARAMETER;
2799 Handle *h = static_cast<Handle*>(handle);
2800 if (!h->IsValidType(AbstractItem::Progress)) {
2801 LOGE("Invalid handle type");
2802 return NOTI_EX_ERROR_INVALID_PARAMETER;
2804 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2807 return NOTI_EX_ERROR_NONE;
2810 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
2812 if (handle == nullptr || max == nullptr) {
2813 LOGE("Invalid parameter");
2814 return NOTI_EX_ERROR_INVALID_PARAMETER;
2817 Handle *h = static_cast<Handle*>(handle);
2818 if (!h->IsValidType(AbstractItem::Progress)) {
2819 LOGE("Invalid handle type");
2820 return NOTI_EX_ERROR_INVALID_PARAMETER;
2822 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2825 return NOTI_EX_ERROR_NONE;
2828 extern "C" EXPORT_API int noti_ex_item_progress_get_type(noti_ex_item_h handle,
2830 if (handle == nullptr || type == nullptr) {
2831 LOGE("Invalid parameter");
2832 return NOTI_EX_ERROR_INVALID_PARAMETER;
2835 Handle *h = static_cast<Handle*>(handle);
2836 if (!h->IsValidType(AbstractItem::Progress)) {
2837 LOGE("Invalid handle type");
2838 return NOTI_EX_ERROR_INVALID_PARAMETER;
2840 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2841 *type = static_cast<noti_ex_item_progress_type_e>(p->GetProgressType());
2843 return NOTI_EX_ERROR_NONE;
2846 extern "C" EXPORT_API int noti_ex_item_progress_set_type(noti_ex_item_h handle,
2848 if (handle == nullptr) {
2849 LOGE("Invalid parameter");
2850 return NOTI_EX_ERROR_INVALID_PARAMETER;
2853 Handle *h = static_cast<Handle*>(handle);
2854 if (!h->IsValidType(AbstractItem::Progress)) {
2855 LOGE("Invalid handle type");
2856 return NOTI_EX_ERROR_INVALID_PARAMETER;
2858 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2859 p->SetProgressType(static_cast<ProgressItem::Type>(type));
2861 return NOTI_EX_ERROR_NONE;
2864 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
2865 noti_ex_reporter_events_s event_callbacks, void *data) {
2866 if (handle == nullptr) {
2867 LOGE("Invalid parameter");
2868 return NOTI_EX_ERROR_INVALID_PARAMETER;
2871 ReporterStub* stub = new (std::nothrow) ReporterStub(
2872 unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
2873 unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())));
2874 if (stub == nullptr) {
2875 LOGE("Fail to create manager");
2876 return NOTI_EX_ERROR_IO_ERROR;
2878 stub->SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo>(
2879 new ReporterCallbackInfo(event_callbacks, data)));
2881 *handle = static_cast<noti_ex_reporter_h>(stub);
2883 return NOTI_EX_ERROR_NONE;
2886 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
2887 if (handle == nullptr) {
2888 LOGE("Invalid parameter");
2889 return NOTI_EX_ERROR_INVALID_PARAMETER;
2891 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2893 return NOTI_EX_ERROR_NONE;
2896 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
2897 noti_ex_event_info_h info, noti_ex_error_e error) {
2898 if (handle == nullptr || info == nullptr) {
2899 LOGE("Invalid parameter");
2900 return NOTI_EX_ERROR_INVALID_PARAMETER;
2903 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2904 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2905 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2906 static_cast<NotificationError>(error));
2907 } catch (Exception &ex) {
2908 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2909 return NOTI_EX_ERROR_IO_ERROR;
2911 return NOTI_EX_ERROR_NONE;
2914 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
2915 noti_ex_item_h noti, int *request_id) {
2916 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2917 LOGE("Invalid parameter");
2918 return NOTI_EX_ERROR_INVALID_PARAMETER;
2921 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2922 Handle* h = static_cast<Handle*>(noti);
2923 if (h->GetPtr().get() == nullptr) {
2924 LOGE("Invalid noti reference can not be sended");
2925 return NOTI_EX_ERROR_INVALID_PARAMETER;
2927 *request_id = stub->Post(h->GetPtr());
2929 } catch (Exception &ex) {
2930 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2931 return NOTI_EX_ERROR_IO_ERROR;
2933 return NOTI_EX_ERROR_NONE;
2936 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
2937 noti_ex_item_h *noti_list, int count, int *request_id) {
2939 if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
2940 LOGE("Invalid parameter");
2941 return NOTI_EX_ERROR_INVALID_PARAMETER;
2944 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2945 list<shared_ptr<item::AbstractItem>> notiList;
2946 for (int i = 0; i < count; i++) {
2947 Handle* item = static_cast<Handle*>(noti_list[i]);
2948 notiList.push_back(item->GetPtr());
2950 *request_id = stub->Post(notiList);
2951 } catch (Exception &ex) {
2952 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2953 return NOTI_EX_ERROR_IO_ERROR;
2955 return NOTI_EX_ERROR_NONE;
2958 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
2959 noti_ex_item_h noti, int *request_id) {
2960 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2961 LOGE("Invalid parameter");
2962 return NOTI_EX_ERROR_INVALID_PARAMETER;
2965 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2966 Handle* item = static_cast<Handle*>(noti);
2967 if (item->GetPtr().get() == nullptr) {
2968 LOGE("Invalid noti reference can not be sended");
2969 return NOTI_EX_ERROR_INVALID_PARAMETER;
2971 *request_id = stub->Update(item->GetPtr());
2973 } catch (Exception &ex) {
2974 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2975 return NOTI_EX_ERROR_IO_ERROR;
2977 return NOTI_EX_ERROR_NONE;
2980 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
2981 noti_ex_item_h noti, int *request_id) {
2982 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2983 LOGE("Invalid parameter");
2984 return NOTI_EX_ERROR_INVALID_PARAMETER;
2987 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2988 Handle* item = static_cast<Handle*>(noti);
2989 if (item->GetPtr().get() == nullptr) {
2990 LOGE("Invalid noti reference can not be sended");
2991 return NOTI_EX_ERROR_INVALID_PARAMETER;
2993 *request_id = stub->Delete(item->GetPtr());
2995 } catch (Exception &ex) {
2996 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2997 return NOTI_EX_ERROR_IO_ERROR;
2999 return NOTI_EX_ERROR_NONE;
3002 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
3003 noti_ex_reporter_h handle, int *request_id) {
3004 if (handle == nullptr || request_id == nullptr) {
3005 LOGE("Invalid parameter");
3006 return NOTI_EX_ERROR_INVALID_PARAMETER;
3009 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3010 *request_id = stub->DeleteAll();
3011 } catch (Exception &ex) {
3012 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3013 return NOTI_EX_ERROR_IO_ERROR;
3015 return NOTI_EX_ERROR_NONE;
3018 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
3019 noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
3020 if (handle == nullptr || root_id == nullptr || item == nullptr) {
3021 LOGE("Invalid parameter");
3022 return NOTI_EX_ERROR_INVALID_PARAMETER;
3025 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3026 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
3027 if (ptr == nullptr) {
3028 LOGW("Not exist ID");
3030 return NOTI_EX_ERROR_NONE;
3032 *item = new Handle(ptr);
3033 } catch (Exception &ex) {
3034 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3035 return NOTI_EX_ERROR_IO_ERROR;
3037 return NOTI_EX_ERROR_NONE;
3040 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
3041 const char *id, const char *text, const char *hyperlink) {
3042 if (handle == nullptr || text == nullptr) {
3043 LOGE("Invalid parameter");
3044 return NOTI_EX_ERROR_INVALID_PARAMETER;
3050 p = new (std::nothrow) TextItem(id, std::string(text),
3051 std::string(hyperlink));
3053 p = new (std::nothrow) TextItem(id, std::string(text));
3056 LOGE("Out-of-memory");
3057 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3060 *handle = new Handle(shared_ptr<AbstractItem>(p));
3062 return NOTI_EX_ERROR_NONE;
3065 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
3066 const char *contents) {
3067 if (handle == nullptr || contents == nullptr) {
3068 LOGE("Invalid parameter");
3069 return NOTI_EX_ERROR_INVALID_PARAMETER;
3072 Handle* p = static_cast<Handle*>(handle);
3073 if (!p->IsValidType(AbstractItem::Text)) {
3074 LOGE("Invalid handle type");
3075 return NOTI_EX_ERROR_INVALID_PARAMETER;
3077 TextItem* ti = static_cast<TextItem*>(p->Get());
3078 ti->SetContents(std::string(contents));
3080 return NOTI_EX_ERROR_NONE;
3083 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
3085 if (handle == nullptr || contents == nullptr) {
3086 LOGE("Invalid parameter");
3087 return NOTI_EX_ERROR_INVALID_PARAMETER;
3090 Handle* p = static_cast<Handle*>(handle);
3091 if (!p->IsValidType(AbstractItem::Text)) {
3092 LOGE("Invalid handle type");
3093 return NOTI_EX_ERROR_INVALID_PARAMETER;
3096 TextItem* ti = static_cast<TextItem*>(p->Get());
3098 if (ti->GetMultiLanguage() != nullptr &&
3099 !ti->GetMultiLanguage()->GetTranslatedString().empty())
3100 str = ti->GetMultiLanguage()->GetTranslatedString();
3101 else if (!ti->GetContents().empty())
3102 str = ti->GetContents();
3104 *contents = strdup(str.c_str());
3105 if (*contents == nullptr) {
3106 LOGE("Out-of-memory");
3107 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3110 return NOTI_EX_ERROR_NONE;
3113 extern "C" EXPORT_API int noti_ex_item_text_get_hyperlink(
3114 noti_ex_item_h handle, char **hyper_link) {
3115 if (handle == nullptr || hyper_link == nullptr) {
3116 LOGE("Invalid parameter");
3117 return NOTI_EX_ERROR_INVALID_PARAMETER;
3120 Handle* p = static_cast<Handle*>(handle);
3121 if (!p->IsValidType(AbstractItem::Text)) {
3122 LOGE("Invalid handle type");
3123 return NOTI_EX_ERROR_INVALID_PARAMETER;
3125 TextItem* ti = static_cast<TextItem*>(p->Get());
3126 if (!ti->GetHyperLink().empty()) {
3127 *hyper_link = strdup(ti->GetHyperLink().c_str());
3128 if (*hyper_link == nullptr) {
3129 LOGE("Out-of-memory");
3130 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3134 return NOTI_EX_ERROR_NONE;
3137 extern "C" EXPORT_API int noti_ex_item_text_set_multi_language(
3138 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
3139 if (handle == nullptr) {
3140 LOGE("Invalid parameter");
3141 return NOTI_EX_ERROR_INVALID_PARAMETER;
3144 Handle* p = static_cast<Handle*>(handle);
3145 if (!p->IsValidType(AbstractItem::Text)) {
3146 LOGE("Invalid handle type");
3147 return NOTI_EX_ERROR_INVALID_PARAMETER;
3150 TextItem* ti = static_cast<TextItem*>(p->Get());
3151 if (multi == nullptr) {
3152 ti->SetMultiLanguage(nullptr);
3153 return NOTI_EX_ERROR_NONE;
3156 shared_ptr<MultiLanguage> mul_ptr =
3157 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
3158 ti->SetMultiLanguage(mul_ptr);
3159 ti->GetMultiLanguage()->UpdateString();
3161 return NOTI_EX_ERROR_NONE;
3164 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
3165 const char *id, time_t time) {
3168 if (handle == nullptr) {
3169 LOGE("Invalid parameter");
3170 return NOTI_EX_ERROR_INVALID_PARAMETER;
3175 p = new (std::nothrow) TimeItem(id, time);
3177 p = new (std::nothrow) TimeItem(time);
3179 p = new (std::nothrow) TimeItem();
3183 LOGE("Out-of-memory");
3184 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3187 *handle = new Handle(shared_ptr<AbstractItem>(p));
3189 return NOTI_EX_ERROR_NONE;
3192 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
3194 if (handle == nullptr || time == nullptr) {
3195 LOGE("Invalid parameter");
3196 return NOTI_EX_ERROR_INVALID_PARAMETER;
3198 Handle* h = static_cast<Handle*>(handle);
3199 if (!h->IsValidType(AbstractItem::Time)) {
3200 LOGE("Invalid handle type");
3201 return NOTI_EX_ERROR_INVALID_PARAMETER;
3203 TimeItem* p = static_cast<TimeItem*>(h->Get());
3204 *time = p->GetTime();
3206 return NOTI_EX_ERROR_NONE;
3209 extern "C" EXPORT_API int noti_ex_item_time_set_time(noti_ex_item_h handle,
3211 if (handle == nullptr) {
3212 LOGE("Invalid parameter");
3213 return NOTI_EX_ERROR_INVALID_PARAMETER;
3215 Handle* h = static_cast<Handle*>(handle);
3216 if (!h->IsValidType(AbstractItem::Time)) {
3217 LOGE("Invalid handle type");
3218 return NOTI_EX_ERROR_INVALID_PARAMETER;
3220 TimeItem* p = static_cast<TimeItem*>(h->Get());
3223 return NOTI_EX_ERROR_NONE;
3226 extern "C" EXPORT_API int noti_ex_action_visibility_create(
3227 noti_ex_action_h *handle, const char *extra) {
3228 if (handle == nullptr) {
3229 LOGE("Invalid parameter");
3230 return NOTI_EX_ERROR_INVALID_PARAMETER;
3233 string extra_str = "";
3235 extra_str = string(extra);
3237 shared_ptr<AbstractAction>* ptr = new (std::nothrow) shared_ptr<AbstractAction>(
3238 new (std::nothrow) VisibilityAction(extra_str));
3239 if (ptr == nullptr) {
3240 LOGE("Out-of-memory");
3241 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3246 return NOTI_EX_ERROR_NONE;
3249 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
3250 const char *id, bool visible) {
3251 if (handle == nullptr || id == nullptr) {
3252 LOGE("Invalid parameter");
3253 return NOTI_EX_ERROR_INVALID_PARAMETER;
3256 shared_ptr<AbstractAction>* ptr =
3257 static_cast<shared_ptr<AbstractAction>*>(handle);
3258 VisibilityAction* action = static_cast<VisibilityAction*>(ptr->get());
3259 action->SetVisibility(id, visible);
3261 return NOTI_EX_ERROR_NONE;
3264 extern "C" EXPORT_API int noti_ex_multi_lang_create(noti_ex_multi_lang_h* handle,
3265 const char* msgid, const char* format, ...) {
3266 if (handle == nullptr || msgid == nullptr || format == nullptr) {
3267 LOGE("Invalid parameter");
3268 return NOTI_EX_ERROR_INVALID_PARAMETER;
3271 const char* format_idx = format;
3274 va_start(args, format);
3275 while (*format_idx != '\0') {
3276 char* arg = nullptr;
3279 stringstream stream;
3280 if (*format_idx == '%') {
3281 switch (*(format_idx + 1)) {
3283 arg = va_arg(args, char *);
3284 arr.push_back(string(arg));
3287 arg_i = va_arg(args, int);
3288 arr.push_back(to_string(arg_i));
3291 arg_f = va_arg(args, double);
3292 stream << std::fixed << std::setprecision(2) << arg_f;
3293 arr.push_back(stream.str());
3301 MultiLanguage* p = new MultiLanguage(string(msgid), format, arr);
3303 LOGE("Out-of-memory");
3304 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3306 *handle = new shared_ptr<MultiLanguage>(p);
3308 return NOTI_EX_ERROR_NONE;
3311 extern "C" EXPORT_API int noti_ex_multi_lang_destroy(noti_ex_multi_lang_h handle) {
3312 if (handle == nullptr) {
3313 LOGE("Invalid parameter");
3314 return NOTI_EX_ERROR_INVALID_PARAMETER;
3317 shared_ptr<MultiLanguage>* mul_ptr =
3318 reinterpret_cast<shared_ptr<MultiLanguage>*>(handle);
3320 return NOTI_EX_ERROR_NONE;
3323 extern "C" EXPORT_API int noti_ex_item_get_private_id(
3324 noti_ex_item_h item, int64_t* private_id) {
3325 if (item == nullptr || private_id == nullptr) {
3326 LOGE("Invalid parameter");
3327 return NOTI_EX_ERROR_INVALID_PARAMETER;
3330 Handle* h = static_cast<Handle*>(item);
3331 *private_id = static_pointer_cast<IItemInfoInternal>(
3332 h->Get()->GetInfo())->GetPrivateId();
3334 return NOTI_EX_ERROR_NONE;
3337 extern "C" EXPORT_API int noti_ex_item_set_private_id(
3338 noti_ex_item_h item, int64_t priv_id) {
3339 if (item == nullptr) {
3340 LOGE("Invalid parameter");
3341 return NOTI_EX_ERROR_INVALID_PARAMETER;
3344 Handle* h = static_cast<Handle*>(item);
3345 static_pointer_cast<IItemInfoInternal>(
3346 h->Get()->GetInfo())->SetPrivateId(priv_id);
3348 return NOTI_EX_ERROR_NONE;
3351 extern "C" EXPORT_API int noti_ex_item_free_string_list(char** list, int count) {
3352 if (list == nullptr) {
3353 LOGE("Invalid parameter");
3354 return NOTI_EX_ERROR_INVALID_PARAMETER;
3357 LOGI("Free strings (%d)", count);
3358 for (int i = 0; i < count; i++)
3362 return NOTI_EX_ERROR_NONE;
3365 extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h handle) {
3366 if (handle == nullptr) {
3367 LOGE("Invalid parameter");
3368 return NOTI_EX_ERROR_INVALID_PARAMETER;
3370 Handle* h = static_cast<Handle*>(handle);
3371 if (!h->IsValidType(AbstractItem::Group)) {
3372 LOGE("Invalid handle type");
3373 return NOTI_EX_ERROR_INVALID_PARAMETER;
3375 GroupItem* p = static_cast<GroupItem*>(h->Get());
3376 p->RemoveChildren();
3378 return NOTI_EX_ERROR_NONE;