2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include "api/notification_ex.h"
26 #include "api/notification_ex_internal.h"
27 #include "notification-ex/reporter.h"
28 #include "notification-ex/app_control_action.h"
29 #include "notification-ex/button_item.h"
30 #include "notification-ex/chat_message_item.h"
31 #include "notification-ex/checkbox_item.h"
32 #include "notification-ex/entry_item.h"
33 #include "notification-ex/group_item.h"
34 #include "notification-ex/input_selector_item.h"
35 #include "notification-ex/abstract_item.h"
36 #include "notification-ex/progress_item.h"
37 #include "notification-ex/time_item.h"
38 #include "notification-ex/visibility_action.h"
39 #include "notification-ex/event_info_internal.h"
40 #include "notification-ex/manager.h"
41 #include "notification-ex/dbus_sender.h"
42 #include "notification-ex/dbus_event_listener.h"
43 #include "notification-ex/exception.h"
44 #include "notification-ex/iitem_info_internal.h"
49 #define LOG_TAG "NOTIFICATION_EX"
54 #define EXPORT_API __attribute__((visibility("default")))
57 using namespace tizen_base;
58 using namespace notification::item;
59 using namespace notification;
65 explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
66 explicit Handle(std::shared_ptr<item::AbstractItem> ptr)
67 : ref_(nullptr), ptr_(move(ptr)) { }
68 virtual ~Handle() = default;
69 item::AbstractItem* Get() const {
75 bool IsValidType(int type) const {
76 return (Get()->GetType() == type
77 || Get()->GetType() >= AbstractItem::Custom);
80 std::shared_ptr<item::AbstractItem> GetPtr() const {
82 return std::shared_ptr<item::AbstractItem>({});
87 item::AbstractItem* ref_;
88 std::shared_ptr<item::AbstractItem> ptr_;
91 class ManagerCallbackInfo {
93 ManagerCallbackInfo(noti_ex_manager_events_s cb, void* user_data)
94 : user_data_(user_data) {
96 cb_.updated = cb.updated;
97 cb_.deleted = cb.deleted;
101 void InvokeAdded(Manager* manager, const IEventInfo& info,
102 list<shared_ptr<AbstractItem>> addedItem) {
103 if (cb_.added == nullptr)
105 noti_ex_item_h* added_item =
106 (noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
107 if (added_item == nullptr) {
108 LOGE("Out of memory");
113 for (auto& i : addedItem) {
115 static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i)));
118 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
119 cb_.added(static_cast<noti_ex_manager_h>(manager),
120 static_cast<noti_ex_event_info_h>(c_info), added_item,
121 addedItem.size(), user_data_);
124 void InvokeUpdated(Manager* manager, const IEventInfo& info,
125 shared_ptr<item::AbstractItem> updatedItem) {
126 if (cb_.updated == nullptr)
128 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
129 cb_.updated(static_cast<noti_ex_manager_h>(manager),
130 static_cast<noti_ex_event_info_h>(c_info),
131 static_cast<noti_ex_item_h>(new Handle(updatedItem)), user_data_);
134 void InvokeDeleted(Manager* manager, const IEventInfo& info,
135 shared_ptr<item::AbstractItem> deletedItem) {
136 if (cb_.deleted == nullptr)
138 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
139 if (c_info->GetEventType() == static_cast<int>(IEventInfo::EventType::DeleteAll)) {
140 cb_.deleted(static_cast<noti_ex_manager_h>(manager),
141 static_cast<noti_ex_event_info_h>(c_info),
142 nullptr, user_data_);
144 cb_.deleted(static_cast<noti_ex_manager_h>(manager),
145 static_cast<noti_ex_event_info_h>(c_info),
146 static_cast<noti_ex_item_h>(
147 new Handle(deletedItem)), user_data_);
151 void InvokeError(Manager* manager, NotificationError error, int requestId) {
152 if (cb_.error == nullptr)
154 cb_.error(static_cast<noti_ex_manager_h>(manager),
155 static_cast<noti_ex_error_e>(error), requestId, user_data_);
159 noti_ex_manager_events_s cb_;
163 class ManagerStub : public Manager {
165 ManagerStub(std::unique_ptr<IEventSender> sender,
166 std::unique_ptr<IEventListener> listener, std::string receiver_group = "")
167 : Manager(move(sender), move(listener), receiver_group) {
170 void OnAdd(const IEventInfo& info,
171 list<shared_ptr<AbstractItem>> addedItem) override {
172 cb_->InvokeAdded(this, info, addedItem);
175 void OnUpdate(const IEventInfo& info,
176 std::shared_ptr<item::AbstractItem> updatedItem) override {
177 cb_->InvokeUpdated(this, info, updatedItem);
180 void OnDelete(const IEventInfo& info,
181 shared_ptr<item::AbstractItem> deletedItem) override {
182 cb_->InvokeDeleted(this, info, deletedItem);
185 void OnError(NotificationError error, int requestId) override {
186 cb_->InvokeError(this, error, requestId);
189 int SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo> ci) {
191 return NOTI_EX_ERROR_NONE;
194 int ClearManagerCallbackInfo() {
196 return NOTI_EX_ERROR_NONE;
200 unique_ptr<ManagerCallbackInfo> cb_;
204 class ReporterCallbackInfo {
206 ReporterCallbackInfo(noti_ex_reporter_events_s cb, void* user_data)
207 : user_data_(user_data) {
208 cb_.event = cb.event;
209 cb_.error = cb.error;
212 void InvokeEvent(Reporter* reporter, const IEventInfo& info,
213 list<shared_ptr<AbstractItem>> notiList) {
214 if (cb_.event == nullptr)
216 noti_ex_item_h* noti_list =
217 (noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
218 if (noti_list == nullptr) {
219 LOGE("Out of memory");
224 for (auto& i : notiList) {
226 static_cast<noti_ex_item_h>(new Handle(i));
229 IEventInfo* c_info = const_cast<IEventInfo*>(&info);
230 cb_.event(static_cast<noti_ex_reporter_h>(reporter),
231 static_cast<noti_ex_event_info_h>(c_info), noti_list,
232 notiList.size(), user_data_);
236 void InvokeError(Reporter* reporter, NotificationError error, int requestId) {
237 if (cb_.error == nullptr)
239 cb_.error(static_cast<noti_ex_reporter_h>(reporter),
240 static_cast<noti_ex_error_e>(error), requestId, user_data_);
244 noti_ex_reporter_events_s cb_;
248 class ReporterStub : public Reporter {
250 ReporterStub(std::unique_ptr<IEventSender> sender,
251 std::unique_ptr<IEventListener> listener)
252 : Reporter(move(sender), move(listener)) {
255 void OnEvent(const IEventInfo& info,
256 std::list<std::shared_ptr<item::AbstractItem>> notiList) override {
257 cb_->InvokeEvent(this, info, notiList);
260 void OnError(NotificationError error, int requestId) override {
261 cb_->InvokeError(this, error, requestId);
264 int SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo> ci) {
266 return NOTI_EX_ERROR_NONE;
269 int ClearReporterCallbackInfo() {
271 return NOTI_EX_ERROR_NONE;
275 unique_ptr<ReporterCallbackInfo> cb_;
280 void __noti_ex_free_str_array(char** val, int length) {
282 for (i = 0; i < length ; i++)
287 extern "C" EXPORT_API int noti_ex_action_app_control_create(
288 noti_ex_action_h *handle, app_control_h app_control,
290 if (handle == nullptr || app_control == nullptr) {
291 LOGE("Invalid parameter");
292 return NOTI_EX_ERROR_INVALID_PARAMETER;
295 shared_ptr<AbstractAction>* p;
298 p = new (std::nothrow) shared_ptr<AbstractAction>(
299 new (std::nothrow) AppControlAction(app_control, extra));
301 p = new (std::nothrow) shared_ptr<AbstractAction>(
302 new (std::nothrow) AppControlAction(app_control));
306 LOGE("Out-of-memory");
307 return NOTI_EX_ERROR_OUT_OF_MEMORY;
312 return NOTI_EX_ERROR_NONE;
315 extern "C" EXPORT_API int noti_ex_action_app_control_set(
316 noti_ex_action_h handle, app_control_h app_control) {
317 if (handle == nullptr || app_control == nullptr) {
318 LOGE("Invalid parameter");
319 return NOTI_EX_ERROR_INVALID_PARAMETER;
322 shared_ptr<AbstractAction>* ptr =
323 static_cast<shared_ptr<AbstractAction>*>(handle);
324 AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
325 action->SetAppControl(app_control);
327 return NOTI_EX_ERROR_NONE;
330 extern "C" EXPORT_API int noti_ex_action_app_control_get(
331 noti_ex_action_h handle, app_control_h *app_control) {
332 if (handle == nullptr || app_control == nullptr) {
333 LOGE("Invalid parameter");
334 return NOTI_EX_ERROR_INVALID_PARAMETER;
337 shared_ptr<AbstractAction>* ptr =
338 static_cast<shared_ptr<AbstractAction>*>(handle);
339 AppControlAction* action = static_cast<AppControlAction*>(ptr->get());
342 int r = app_control_clone(&clone, action->GetAppControl());
343 if (r != APP_CONTROL_ERROR_NONE) {
344 LOGE("failed to create a app_control handle : %d", r);
345 return NOTI_EX_ERROR_INVALID_PARAMETER;
348 *app_control = clone;
350 return NOTI_EX_ERROR_NONE;
353 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
354 const char *id, const char *title) {
357 if (handle == nullptr || title == nullptr) {
358 LOGE("Invalid parameter");
359 return NOTI_EX_ERROR_INVALID_PARAMETER;
363 p = new (std::nothrow) ButtonItem(id, title);
365 p = new (std::nothrow) ButtonItem(title);
368 LOGE("Out-of-memory");
369 return NOTI_EX_ERROR_OUT_OF_MEMORY;
371 *handle = new Handle(shared_ptr<AbstractItem>(p));
373 return NOTI_EX_ERROR_NONE;
376 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
378 if (handle == nullptr || title == nullptr) {
379 LOGE("Invalid parameter");
380 return NOTI_EX_ERROR_INVALID_PARAMETER;
383 Handle* sp = static_cast<Handle*>(handle);
384 if (!sp->IsValidType(AbstractItem::Button)) {
385 LOGE("Invalid handle type");
386 return NOTI_EX_ERROR_INVALID_PARAMETER;
389 ButtonItem* p = static_cast<ButtonItem*>(sp->Get());
391 if (p->GetMultiLanguage() != nullptr &&
392 !p->GetMultiLanguage()->GetTranslatedString().empty())
393 str = p->GetMultiLanguage()->GetTranslatedString();
394 else if (!p->GetTitle().empty())
397 *title = strdup(str.c_str());
398 if (*title == nullptr) {
399 LOGE("Out-of-memory");
400 return NOTI_EX_ERROR_OUT_OF_MEMORY;
403 return NOTI_EX_ERROR_NONE;
406 extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title(
407 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
408 if (handle == nullptr) {
409 LOGE("Invalid parameter");
410 return NOTI_EX_ERROR_INVALID_PARAMETER;
413 Handle* p = static_cast<Handle*>(handle);
414 if (!p->IsValidType(AbstractItem::Button)) {
415 LOGE("Invalid handle type");
416 return NOTI_EX_ERROR_INVALID_PARAMETER;
419 ButtonItem* bi = static_cast<ButtonItem*>(p->Get());
420 if (multi == nullptr) {
421 bi->SetMultiLanguage(nullptr);
422 return NOTI_EX_ERROR_NONE;
425 shared_ptr<MultiLanguage> mul_ptr =
426 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
428 mul_ptr->UpdateString();
429 bi->SetMultiLanguage(mul_ptr);
431 return NOTI_EX_ERROR_NONE;
434 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
435 noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
436 noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
437 noti_ex_item_chat_message_type_e message_type) {
438 if (handle == nullptr || (text == nullptr && image == nullptr)
439 || name == nullptr || time == nullptr
440 || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
441 LOGE("Invalid parameter");
442 return NOTI_EX_ERROR_INVALID_PARAMETER;
445 auto* p = new (std::nothrow) ChatMessageItem(id,
446 dynamic_pointer_cast<TextItem>(static_cast<Handle*>(name)->GetPtr()),
447 text == nullptr ? nullptr
448 : dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
449 image == nullptr ? nullptr
450 : dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
451 dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
452 static_cast<ChatMessageItem::Type>(message_type));
454 LOGE("Out-of-memory");
455 return NOTI_EX_ERROR_OUT_OF_MEMORY;
458 *handle = new Handle(shared_ptr<AbstractItem>(p));
460 return NOTI_EX_ERROR_NONE;
463 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
464 noti_ex_item_h handle, noti_ex_item_h *name) {
465 if (handle == nullptr || name == nullptr) {
466 LOGE("Invalid parameter");
467 return NOTI_EX_ERROR_INVALID_PARAMETER;
469 Handle* h = static_cast<Handle*>(handle);
470 if (!h->IsValidType(AbstractItem::ChatMessage)) {
471 LOGE("Invalid handle type");
472 return NOTI_EX_ERROR_INVALID_PARAMETER;
474 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
475 if (p->GetNameItem().GetType() == AbstractItem::NullObject)
478 *name = new Handle(&(p->GetNameItem()));
480 return NOTI_EX_ERROR_NONE;
483 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
484 noti_ex_item_h handle, noti_ex_item_h *text) {
485 if (handle == nullptr || text == nullptr) {
486 LOGE("Invalid parameter");
487 return NOTI_EX_ERROR_INVALID_PARAMETER;
490 Handle* h = static_cast<Handle*>(handle);
491 if (!h->IsValidType(AbstractItem::ChatMessage)) {
492 LOGE("Invalid handle type");
493 return NOTI_EX_ERROR_INVALID_PARAMETER;
495 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
496 if (p->GetTextItem().GetType() == AbstractItem::NullObject)
499 *text = new Handle(&(p->GetTextItem()));
501 return NOTI_EX_ERROR_NONE;
504 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
505 noti_ex_item_h handle, noti_ex_item_h *image) {
506 if (handle == nullptr || image == nullptr) {
507 LOGE("Invalid parameter");
508 return NOTI_EX_ERROR_INVALID_PARAMETER;
511 Handle* h = static_cast<Handle*>(handle);
512 if (!h->IsValidType(AbstractItem::ChatMessage)) {
513 LOGE("Invalid handle type");
514 return NOTI_EX_ERROR_INVALID_PARAMETER;
516 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
517 if (p->GetImageItem().GetType() == AbstractItem::NullObject)
520 *image = new Handle(&(p->GetImageItem()));
522 return NOTI_EX_ERROR_NONE;
525 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
526 noti_ex_item_h handle, noti_ex_item_h *time) {
527 if (handle == nullptr || time == nullptr) {
528 LOGE("Invalid parameter");
529 return NOTI_EX_ERROR_INVALID_PARAMETER;
532 Handle* h = static_cast<Handle*>(handle);
533 if (!h->IsValidType(AbstractItem::ChatMessage)) {
534 LOGE("Invalid handle type");
535 return NOTI_EX_ERROR_INVALID_PARAMETER;
537 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
538 if (p->GetTimeItem().GetType() == AbstractItem::NullObject)
541 *time = new Handle(&(p->GetTimeItem()));
543 return NOTI_EX_ERROR_NONE;
546 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
547 noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
548 if (handle == nullptr || message_type == nullptr) {
549 LOGE("Invalid parameter");
550 return NOTI_EX_ERROR_INVALID_PARAMETER;
553 Handle* h = static_cast<Handle*>(handle);
554 if (!h->IsValidType(AbstractItem::ChatMessage)) {
555 LOGE("Invalid handle type");
556 return NOTI_EX_ERROR_INVALID_PARAMETER;
558 ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
559 *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
561 return NOTI_EX_ERROR_NONE;
564 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
565 const char *id, const char *title, bool checked) {
568 if (handle == nullptr || title == nullptr) {
569 LOGE("Invalid parameter");
570 return NOTI_EX_ERROR_INVALID_PARAMETER;
573 p = new (std::nothrow) CheckBoxItem(id, title, checked);
575 LOGE("Out-of-memory");
576 return NOTI_EX_ERROR_OUT_OF_MEMORY;
579 *handle = new Handle(shared_ptr<AbstractItem>(p));
581 return NOTI_EX_ERROR_NONE;
584 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
586 if (handle == nullptr || title == nullptr) {
587 LOGE("Invalid parameter");
588 return NOTI_EX_ERROR_INVALID_PARAMETER;
590 Handle* h = static_cast<Handle*>(handle);
591 if (!h->IsValidType(AbstractItem::CheckBox)) {
592 LOGE("Invalid handle type");
593 return NOTI_EX_ERROR_INVALID_PARAMETER;
596 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
598 if (p->GetMultiLanguage() != nullptr &&
599 !p->GetMultiLanguage()->GetTranslatedString().empty())
600 str = p->GetMultiLanguage()->GetTranslatedString();
601 else if (!p->GetTitle().empty())
604 *title = strdup(str.c_str());
605 if (*title == nullptr) {
606 LOGE("Out-of-memory");
607 return NOTI_EX_ERROR_OUT_OF_MEMORY;
610 return NOTI_EX_ERROR_NONE;
613 extern "C" EXPORT_API int noti_ex_item_checkbox_set_multi_language_title(
614 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
615 if (handle == nullptr) {
616 LOGE("Invalid parameter");
617 return NOTI_EX_ERROR_INVALID_PARAMETER;
620 Handle* p = static_cast<Handle*>(handle);
621 if (!p->IsValidType(AbstractItem::CheckBox)) {
622 LOGE("Invalid handle type");
623 return NOTI_EX_ERROR_INVALID_PARAMETER;
626 CheckBoxItem* ci = static_cast<CheckBoxItem*>(p->Get());
627 if (multi == nullptr) {
628 ci->SetMultiLanguage(nullptr);
629 return NOTI_EX_ERROR_NONE;
632 shared_ptr<MultiLanguage> mul_ptr =
633 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
634 mul_ptr->UpdateString();
635 ci->SetMultiLanguage(mul_ptr);
637 return NOTI_EX_ERROR_NONE;
640 extern "C" EXPORT_API int noti_ex_item_checkbox_get_check_state(
641 noti_ex_item_h handle, bool *checked) {
642 if (handle == nullptr || checked == nullptr) {
643 LOGE("Invalid parameter");
644 return NOTI_EX_ERROR_INVALID_PARAMETER;
646 Handle* h = static_cast<Handle*>(handle);
647 if (!h->IsValidType(AbstractItem::CheckBox)) {
648 LOGE("Invalid handle type");
649 return NOTI_EX_ERROR_INVALID_PARAMETER;
651 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
652 *checked = p->IsChecked();
654 return NOTI_EX_ERROR_NONE;
657 extern "C" EXPORT_API int noti_ex_item_checkbox_set_check_state(
658 noti_ex_item_h handle, bool checked) {
659 if (handle == nullptr) {
660 LOGE("Invalid parameter");
661 return NOTI_EX_ERROR_INVALID_PARAMETER;
664 Handle* h = static_cast<Handle*>(handle);
665 if (!h->IsValidType(AbstractItem::CheckBox)) {
666 LOGE("Invalid handle type");
667 return NOTI_EX_ERROR_INVALID_PARAMETER;
670 CheckBoxItem* p = static_cast<CheckBoxItem*>(h->Get());
671 p->SetChecked(checked);
673 return NOTI_EX_ERROR_NONE;
676 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
680 if (handle == nullptr) {
681 LOGE("Invalid parameter");
682 return NOTI_EX_ERROR_INVALID_PARAMETER;
685 p = new (std::nothrow) EntryItem(id);
687 LOGE("Out-of-memory");
688 return NOTI_EX_ERROR_OUT_OF_MEMORY;
691 *handle = new Handle(shared_ptr<AbstractItem>(p));
693 return NOTI_EX_ERROR_NONE;
696 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
698 if (handle == nullptr || text == nullptr) {
699 LOGE("Invalid parameter");
700 return NOTI_EX_ERROR_INVALID_PARAMETER;
703 Handle* h = static_cast<Handle*>(handle);
704 if (!h->IsValidType(AbstractItem::Entry)) {
705 LOGE("Invalid handle type");
706 return NOTI_EX_ERROR_INVALID_PARAMETER;
709 EntryItem* p = static_cast<EntryItem*>(h->Get());
711 if (p->GetMultiLanguage() != nullptr &&
712 !p->GetMultiLanguage()->GetTranslatedString().empty())
713 str = p->GetMultiLanguage()->GetTranslatedString();
714 else if (!p->GetText().empty())
717 *text = strdup(str.c_str());
718 if (*text == nullptr) {
719 LOGE("Out-of-memory");
720 return NOTI_EX_ERROR_OUT_OF_MEMORY;
723 return NOTI_EX_ERROR_NONE;
726 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
728 if (handle == nullptr || text == nullptr) {
729 LOGE("Invalid parameter");
730 return NOTI_EX_ERROR_INVALID_PARAMETER;
732 Handle* h = static_cast<Handle*>(handle);
733 if (!h->IsValidType(AbstractItem::Entry)) {
734 LOGE("Invalid handle type");
735 return NOTI_EX_ERROR_INVALID_PARAMETER;
737 EntryItem* p = static_cast<EntryItem*>(h->Get());
738 p->SetText(std::string(text));
740 return NOTI_EX_ERROR_NONE;
743 extern "C" EXPORT_API int noti_ex_item_entry_set_multi_language(
744 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
745 if (handle == nullptr) {
746 LOGE("Invalid parameter");
747 return NOTI_EX_ERROR_INVALID_PARAMETER;
750 Handle* p = static_cast<Handle*>(handle);
751 if (!p->IsValidType(AbstractItem::Entry)) {
752 LOGE("Invalid handle type");
753 return NOTI_EX_ERROR_INVALID_PARAMETER;
756 EntryItem* ei = static_cast<EntryItem*>(p->Get());
757 if (multi == nullptr) {
758 ei->SetMultiLanguage(nullptr);
759 return NOTI_EX_ERROR_NONE;
762 shared_ptr<MultiLanguage> mul_ptr =
763 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
764 ei->SetMultiLanguage(mul_ptr);
765 ei->GetMultiLanguage()->UpdateString();
767 return NOTI_EX_ERROR_NONE;
770 extern "C" EXPORT_API int noti_ex_event_info_clone(noti_ex_event_info_h handle,
771 noti_ex_event_info_h* cloned_handle) {
772 if (handle == nullptr || cloned_handle == nullptr) {
773 LOGE("Invalid parameter");
774 return NOTI_EX_ERROR_INVALID_PARAMETER;
777 Bundle cloned = static_cast<EventInfo*>(handle)->Serialize();
778 EventInfo* info = new EventInfo(cloned);
779 *cloned_handle = info;
780 return NOTI_EX_ERROR_NONE;
783 extern "C" EXPORT_API int noti_ex_event_info_destroy(
784 noti_ex_event_info_h handle) {
785 if (handle == nullptr) {
786 LOGE("Invalid parameter");
787 return NOTI_EX_ERROR_INVALID_PARAMETER;
789 EventInfo* info = static_cast<EventInfo*>(handle);
791 return NOTI_EX_ERROR_NONE;
794 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
795 noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
796 if (handle == nullptr || event_type == nullptr) {
797 LOGE("Invalid parameter");
798 return NOTI_EX_ERROR_INVALID_PARAMETER;
800 EventInfo* info = static_cast<EventInfo*>(handle);
801 *event_type = static_cast<noti_ex_event_info_type_e>(info->GetEventType());
803 return NOTI_EX_ERROR_NONE;
806 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
807 noti_ex_event_info_h handle, char **owner) {
808 if (handle == nullptr || owner == nullptr) {
809 LOGE("Invalid parameter");
810 return NOTI_EX_ERROR_INVALID_PARAMETER;
812 EventInfo* info = static_cast<EventInfo*>(handle);
813 *owner = strdup(info->GetOwner().c_str());
814 return NOTI_EX_ERROR_NONE;
817 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
818 noti_ex_event_info_h handle, char **channel) {
819 if (handle == nullptr || channel == nullptr) {
820 LOGE("Invalid parameter");
821 return NOTI_EX_ERROR_INVALID_PARAMETER;
823 EventInfo* info = static_cast<EventInfo*>(handle);
824 *channel = strdup(info->GetChannel().c_str());
825 return NOTI_EX_ERROR_NONE;
828 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
829 noti_ex_event_info_h handle, char **item_id) {
830 if (handle == nullptr || item_id == nullptr) {
831 LOGE("Invalid parameter");
832 return NOTI_EX_ERROR_INVALID_PARAMETER;
834 EventInfo* info = static_cast<EventInfo*>(handle);
835 *item_id = strdup(info->GetItemId().c_str());
836 return NOTI_EX_ERROR_NONE;
839 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
840 noti_ex_event_info_h handle, int *req_id) {
841 if (handle == nullptr || req_id == nullptr) {
842 LOGE("Invalid parameter");
843 return NOTI_EX_ERROR_INVALID_PARAMETER;
845 EventInfo* info = static_cast<EventInfo*>(handle);
846 *req_id = info->GetRequestId();
847 return NOTI_EX_ERROR_NONE;
850 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
854 if (handle == nullptr) {
855 LOGE("Invalid parameter");
856 return NOTI_EX_ERROR_INVALID_PARAMETER;
860 p = new (std::nothrow) GroupItem(id);
862 p = new (std::nothrow) GroupItem();
865 LOGE("Out-of-memory");
866 return NOTI_EX_ERROR_OUT_OF_MEMORY;
869 *handle = new Handle(shared_ptr<AbstractItem>(p));
871 return NOTI_EX_ERROR_NONE;
874 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
876 if (handle == nullptr) {
877 LOGE("Invalid parameter");
878 return NOTI_EX_ERROR_INVALID_PARAMETER;
880 Handle* h = static_cast<Handle*>(handle);
881 if (!h->IsValidType(AbstractItem::Group)) {
882 LOGE("Invalid handle type");
883 return NOTI_EX_ERROR_INVALID_PARAMETER;
885 GroupItem* p = static_cast<GroupItem*>(h->Get());
886 p->SetDirection(vertical);
888 return NOTI_EX_ERROR_NONE;
891 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
893 if (handle == nullptr) {
894 LOGE("Invalid parameter");
895 return NOTI_EX_ERROR_INVALID_PARAMETER;
897 Handle* h = static_cast<Handle*>(handle);
898 if (!h->IsValidType(AbstractItem::Group)) {
899 LOGE("Invalid handle type");
900 return NOTI_EX_ERROR_INVALID_PARAMETER;
902 GroupItem* p = static_cast<GroupItem*>(h->Get());
903 *vertical = p->IsVertical();
905 return NOTI_EX_ERROR_NONE;
908 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
910 if (handle == nullptr) {
911 LOGE("Invalid parameter");
912 return NOTI_EX_ERROR_INVALID_PARAMETER;
914 Handle* h = static_cast<Handle*>(handle);
915 if (!h->IsValidType(AbstractItem::Group)) {
916 LOGE("Invalid handle type");
917 return NOTI_EX_ERROR_INVALID_PARAMETER;
919 GroupItem* p = static_cast<GroupItem*>(h->Get());
920 if (!p->GetAppLabel().empty()) {
921 *label = strdup(p->GetAppLabel().c_str());
922 if (*label == nullptr) {
923 LOGE("Out-of-memory");
924 return NOTI_EX_ERROR_OUT_OF_MEMORY;
928 return NOTI_EX_ERROR_NONE;
931 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
932 noti_ex_item_h child) {
933 if (handle == nullptr || child == nullptr) {
934 LOGE("Invalid parameter");
935 return NOTI_EX_ERROR_INVALID_PARAMETER;
937 Handle* h = static_cast<Handle*>(handle);
938 if (!h->IsValidType(AbstractItem::Group)) {
939 LOGE("Invalid handle type");
940 return NOTI_EX_ERROR_INVALID_PARAMETER;
942 auto p = static_cast<GroupItem*>(h->Get());
943 p->AddChild((static_cast<Handle*>(child))->GetPtr());
945 return NOTI_EX_ERROR_NONE;
948 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
949 const char *item_id) {
950 if (handle == nullptr || item_id == nullptr) {
951 LOGE("Invalid parameter");
952 return NOTI_EX_ERROR_INVALID_PARAMETER;
954 Handle* h = static_cast<Handle*>(handle);
955 if (!h->IsValidType(AbstractItem::Group)) {
956 LOGE("Invalid handle type");
957 return NOTI_EX_ERROR_INVALID_PARAMETER;
959 GroupItem* p = static_cast<GroupItem*>(h->Get());
960 p->RemoveChild(std::string(item_id));
962 return NOTI_EX_ERROR_NONE;
965 extern "C" EXPORT_API int noti_ex_item_group_foreach_child(noti_ex_item_h handle,
966 noti_ex_item_group_foreach_child_cb callback, void *data) {
967 if (handle == nullptr || callback == nullptr) {
968 LOGE("Invalid parameter");
969 return NOTI_EX_ERROR_INVALID_PARAMETER;
972 Handle* h = static_cast<Handle*>(handle);
973 if (!h->IsValidType(AbstractItem::Group)) {
974 LOGE("Invalid handle type");
975 return NOTI_EX_ERROR_INVALID_PARAMETER;
977 GroupItem* p = static_cast<GroupItem*>(h->Get());
978 list<shared_ptr<AbstractItem>> children = p->GetChildren();
979 LOGI("Retrive (%zd)", children.size());
980 for (auto i : children) {
982 static_cast<noti_ex_item_h>(new Handle(i)), data);
983 if (ret != NOTI_EX_ERROR_NONE) {
984 LOGW("callback return (%d) stop foreach", ret);
989 return NOTI_EX_ERROR_NONE;
992 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
993 const char *id, const char *image_path) {
996 if (handle == nullptr || image_path == nullptr) {
997 LOGE("Invalid parameter");
998 return NOTI_EX_ERROR_INVALID_PARAMETER;
1002 p = new (std::nothrow) ImageItem(id, image_path);
1004 p = new (std::nothrow) ImageItem(image_path);
1007 LOGE("Out-of-memory");
1008 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1011 *handle = new Handle(shared_ptr<AbstractItem>(p));
1013 return NOTI_EX_ERROR_NONE;
1016 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
1017 noti_ex_item_h handle, char **image_path) {
1018 if (handle == nullptr || image_path == nullptr) {
1019 LOGE("Invalid parameter");
1020 return NOTI_EX_ERROR_INVALID_PARAMETER;
1022 Handle* h = static_cast<Handle*>(handle);
1023 if (!h->IsValidType(AbstractItem::Image)) {
1024 LOGE("Invalid handle type");
1025 return NOTI_EX_ERROR_INVALID_PARAMETER;
1027 ImageItem* p = static_cast<ImageItem*>(h->Get());
1028 if (!p->GetImagePath().empty()) {
1029 *image_path = strdup(p->GetImagePath().c_str());
1030 if (*image_path == nullptr) {
1031 LOGE("Out-of-memory");
1032 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1035 *image_path = nullptr;
1038 return NOTI_EX_ERROR_NONE;
1041 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
1042 noti_ex_item_h *handle, const char *id) {
1043 InputSelectorItem* p;
1045 if (handle == nullptr) {
1046 LOGE("Invalid parameter");
1047 return NOTI_EX_ERROR_INVALID_PARAMETER;
1051 p = new (std::nothrow) InputSelectorItem(id);
1053 p = new (std::nothrow) InputSelectorItem();
1056 LOGE("Out-of-memory");
1057 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1060 *handle = new Handle(shared_ptr<AbstractItem>(p));
1062 return NOTI_EX_ERROR_NONE;
1065 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
1066 noti_ex_item_h handle, char ***contents_list, int *count) {
1067 if (handle == nullptr || contents_list == nullptr || count == nullptr) {
1068 LOGE("Invalid parameter");
1069 return NOTI_EX_ERROR_INVALID_PARAMETER;
1072 Handle* h = static_cast<Handle*>(handle);
1073 if (!h->IsValidType(AbstractItem::InputSelector)) {
1074 LOGE("Invalid handle type");
1075 return NOTI_EX_ERROR_INVALID_PARAMETER;
1078 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1079 vector<shared_ptr<MultiLanguage>> arr = p->GetMultiLanguageArr();
1080 list<string> contents;
1081 if (arr.size() == 0) {
1082 contents = p->GetContents();
1084 for (auto& i : arr) {
1085 contents.push_back(i->GetTranslatedString());
1089 char **list = (char**)calloc(contents.size(), sizeof(char*));
1090 if (list == nullptr) {
1091 LOGE("Out of memory");
1092 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1096 for (auto& i : contents) {
1097 list[idx] = strdup(i.c_str());
1098 if (list[idx] == nullptr) {
1099 __noti_ex_free_str_array(list, idx);
1100 LOGE("Out of memory");
1101 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1106 *count = contents.size();
1107 *contents_list = list;
1109 return NOTI_EX_ERROR_NONE;
1112 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
1113 noti_ex_item_h handle, const char **contents, int count) {
1114 if (handle == nullptr || contents == nullptr) {
1115 LOGE("Invalid parameter");
1116 return NOTI_EX_ERROR_INVALID_PARAMETER;
1119 list<string> new_contents;
1120 Handle* h = static_cast<Handle*>(handle);
1121 if (!h->IsValidType(AbstractItem::InputSelector)) {
1122 LOGE("Invalid handle type");
1123 return NOTI_EX_ERROR_INVALID_PARAMETER;
1125 InputSelectorItem* p = static_cast<InputSelectorItem*>(h->Get());
1126 for (int i = 0; i < count; i++) {
1127 new_contents.push_back(contents[i]);
1129 p->SetContents(move(new_contents));
1131 return NOTI_EX_ERROR_NONE;
1134 extern "C" EXPORT_API int noti_ex_item_input_selector_set_multi_language_contents(
1135 noti_ex_item_h handle, noti_ex_multi_lang_h* multi_language_list, int count) {
1136 if (handle == nullptr) {
1137 LOGE("Invalid parameter");
1138 return NOTI_EX_ERROR_INVALID_PARAMETER;
1141 Handle* p = static_cast<Handle*>(handle);
1142 if (!p->IsValidType(AbstractItem::InputSelector)) {
1143 LOGE("Invalid handle type");
1144 return NOTI_EX_ERROR_INVALID_PARAMETER;
1147 vector<shared_ptr<MultiLanguage>> m_list;
1148 for (int i = 0; i < count; i++) {
1149 shared_ptr<MultiLanguage> mul_ptr =
1150 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi_language_list[i]);
1151 mul_ptr->UpdateString();
1152 m_list.push_back(mul_ptr);
1155 InputSelectorItem* input = static_cast<InputSelectorItem*>(p->Get());
1156 input->SetMultiLanguage(m_list);
1158 return NOTI_EX_ERROR_NONE;
1161 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
1162 unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
1163 if (handle == nullptr) {
1164 LOGE("Invalid parameter");
1165 return NOTI_EX_ERROR_INVALID_PARAMETER;
1168 auto* ptr = new (std::nothrow) shared_ptr<Color>(
1169 new (std::nothrow) Color(a, r, g, b));
1170 if (ptr == nullptr || ptr->get() == nullptr) {
1171 LOGE("Out-of-memory");
1172 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1177 return NOTI_EX_ERROR_NONE;
1180 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
1181 if (handle == nullptr) {
1182 LOGE("Invalid parameter");
1183 return NOTI_EX_ERROR_INVALID_PARAMETER;
1186 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1189 return NOTI_EX_ERROR_NONE;
1192 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
1193 unsigned char *val) {
1194 if (handle == nullptr || val == nullptr) {
1195 LOGE("Invalid parameter");
1196 return NOTI_EX_ERROR_INVALID_PARAMETER;
1199 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1200 *val = (*p)->GetAVal();
1202 return NOTI_EX_ERROR_NONE;
1205 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
1206 unsigned char *val) {
1207 if (handle == nullptr || val == nullptr) {
1208 LOGE("Invalid parameter");
1209 return NOTI_EX_ERROR_INVALID_PARAMETER;
1212 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1213 *val = (*p)->GetRVal();
1215 return NOTI_EX_ERROR_NONE;
1218 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
1219 unsigned char *val) {
1220 if (handle == nullptr || val == nullptr) {
1221 LOGE("Invalid parameter");
1222 return NOTI_EX_ERROR_INVALID_PARAMETER;
1225 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1226 *val = (*p)->GetGVal();
1228 return NOTI_EX_ERROR_NONE;
1231 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
1232 unsigned char *val) {
1233 if (handle == nullptr || val == nullptr) {
1234 LOGE("Invalid parameter");
1235 return NOTI_EX_ERROR_INVALID_PARAMETER;
1238 shared_ptr<Color>* p = static_cast<shared_ptr<Color>*>(handle);
1239 *val = (*p)->GetBVal();
1241 return NOTI_EX_ERROR_NONE;
1244 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
1245 int left, int top, int right, int bottom) {
1246 if (handle == nullptr) {
1247 LOGE("Invalid parameter");
1248 return NOTI_EX_ERROR_INVALID_PARAMETER;
1251 auto* ptr = new (std::nothrow) shared_ptr<Padding>(
1252 new (std::nothrow) Padding(left, top, right, bottom));
1253 if (ptr == nullptr || ptr->get() == nullptr) {
1254 LOGE("Out-of-memory");
1255 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1260 return NOTI_EX_ERROR_NONE;
1263 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
1264 if (handle == nullptr) {
1265 LOGE("Invalid parameter");
1266 return NOTI_EX_ERROR_INVALID_PARAMETER;
1269 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1272 return NOTI_EX_ERROR_NONE;
1275 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
1277 if (handle == nullptr || val == nullptr) {
1278 LOGE("Invalid parameter");
1279 return NOTI_EX_ERROR_INVALID_PARAMETER;
1282 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1283 *val = (*p)->GetLeft();
1285 return NOTI_EX_ERROR_NONE;
1288 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
1290 if (handle == nullptr || val == nullptr) {
1291 LOGE("Invalid parameter");
1292 return NOTI_EX_ERROR_INVALID_PARAMETER;
1295 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1296 *val = (*p)->GetTop();
1298 return NOTI_EX_ERROR_NONE;
1301 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
1303 if (handle == nullptr || val == nullptr) {
1304 LOGE("Invalid parameter");
1305 return NOTI_EX_ERROR_INVALID_PARAMETER;
1308 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1309 *val = (*p)->GetRight();
1311 return NOTI_EX_ERROR_NONE;
1314 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
1316 if (handle == nullptr || val == nullptr) {
1317 LOGE("Invalid parameter");
1318 return NOTI_EX_ERROR_INVALID_PARAMETER;
1321 shared_ptr<Padding>* p = static_cast<shared_ptr<Padding>*>(handle);
1322 *val = (*p)->GetBottom();
1324 return NOTI_EX_ERROR_NONE;
1327 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
1328 int x, int y, int w, int h) {
1329 if (handle == nullptr) {
1330 LOGE("Invalid parameter");
1331 return NOTI_EX_ERROR_INVALID_PARAMETER;
1334 auto* ptr = new (std::nothrow) shared_ptr<Geometry>(
1335 new (std::nothrow) Geometry(x, y, w, h));
1336 if (ptr == nullptr || ptr->get() == nullptr) {
1337 LOGE("Out-of-memory");
1338 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1343 return NOTI_EX_ERROR_NONE;
1346 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
1347 if (handle == nullptr) {
1348 LOGE("Invalid parameter");
1349 return NOTI_EX_ERROR_INVALID_PARAMETER;
1352 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1355 return NOTI_EX_ERROR_NONE;
1358 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
1360 if (handle == nullptr || val == nullptr) {
1361 LOGE("Invalid parameter");
1362 return NOTI_EX_ERROR_INVALID_PARAMETER;
1365 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1366 *val = (*p)->GetX();
1368 return NOTI_EX_ERROR_NONE;
1371 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
1373 if (handle == nullptr || val == nullptr) {
1374 LOGE("Invalid parameter");
1375 return NOTI_EX_ERROR_INVALID_PARAMETER;
1378 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1379 *val = (*p)->GetY();
1381 return NOTI_EX_ERROR_NONE;
1384 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
1386 if (handle == nullptr || val == nullptr) {
1387 LOGE("Invalid parameter");
1388 return NOTI_EX_ERROR_INVALID_PARAMETER;
1391 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1392 *val = (*p)->GetWidth();
1394 return NOTI_EX_ERROR_NONE;
1397 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
1399 if (handle == nullptr || val == nullptr) {
1400 LOGE("Invalid parameter");
1401 return NOTI_EX_ERROR_INVALID_PARAMETER;
1404 shared_ptr<Geometry>* p = static_cast<shared_ptr<Geometry>*>(handle);
1405 *val = (*p)->GetHeight();
1407 return NOTI_EX_ERROR_NONE;
1410 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
1411 noti_ex_color_h color,
1412 noti_ex_padding_h padding,
1413 noti_ex_geometry_h geometry) {
1414 if (handle == nullptr) {
1415 LOGE("Invalid parameter");
1416 return NOTI_EX_ERROR_INVALID_PARAMETER;
1419 shared_ptr<Color> col = (color == nullptr) ?
1420 nullptr : *(static_cast<shared_ptr<Color>*>(color));
1421 shared_ptr<Padding> padd = (padding == nullptr) ?
1422 nullptr : *(static_cast<shared_ptr<Padding>*>(padding));
1423 shared_ptr<Geometry> geo = (geometry == nullptr) ?
1424 nullptr : *(static_cast<shared_ptr<Geometry>*>(geometry));
1426 auto* ptr = new (std::nothrow) shared_ptr<Style>(
1427 new (std::nothrow) Style(col, padd, geo));
1428 if (ptr == nullptr || ptr->get() == nullptr) {
1429 LOGE("Out-of-memory");
1430 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1435 return NOTI_EX_ERROR_NONE;
1438 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
1439 if (handle == nullptr) {
1440 LOGE("Invalid parameter");
1441 return NOTI_EX_ERROR_INVALID_PARAMETER;
1444 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1447 return NOTI_EX_ERROR_NONE;
1450 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
1451 noti_ex_padding_h *padding) {
1452 if (handle == nullptr || padding == nullptr) {
1453 LOGE("Invalid parameter");
1454 return NOTI_EX_ERROR_INVALID_PARAMETER;
1457 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1458 if ((*p)->GetPadding() == nullptr) {
1459 LOGW("Padding info is null");
1460 return NOTI_EX_ERROR_INVALID_PARAMETER;
1463 shared_ptr<Padding>* padd = new (std::nothrow) shared_ptr<Padding>(
1464 new (std::nothrow) Padding(*((*p)->GetPadding())));
1465 if (padd == nullptr || padd->get() == nullptr) {
1466 LOGE("Out-of-memory");
1468 return NOTI_EX_ERROR_NONE;
1473 return NOTI_EX_ERROR_NONE;
1477 extern "C" EXPORT_API int noti_ex_style_set_padding(noti_ex_style_h handle,
1478 noti_ex_padding_h padding) {
1479 if (handle == nullptr) {
1480 LOGE("Invalid parameter");
1481 return NOTI_EX_ERROR_INVALID_PARAMETER;
1484 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1485 if (padding == nullptr) {
1486 (*p)->SetPadding(nullptr);
1487 return NOTI_EX_ERROR_NONE;
1490 shared_ptr<Padding>* padd = static_cast<shared_ptr<Padding>*>(padding);
1491 (*p)->SetPadding(*padd);
1493 return NOTI_EX_ERROR_NONE;
1496 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
1497 noti_ex_color_h *color) {
1498 if (handle == nullptr || color == nullptr) {
1499 LOGE("Invalid parameter");
1500 return NOTI_EX_ERROR_INVALID_PARAMETER;
1503 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1504 if ((*p)->GetColor() == nullptr) {
1505 LOGW("Color info is null");
1507 return NOTI_EX_ERROR_NONE;
1510 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1511 new (std::nothrow) Color(*((*p)->GetColor())));
1512 if (col == nullptr || col->get() == nullptr) {
1513 LOGE("Out-of-memory");
1514 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1519 return NOTI_EX_ERROR_NONE;
1522 extern "C" EXPORT_API int noti_ex_style_set_color(
1523 noti_ex_style_h handle, noti_ex_color_h color) {
1524 if (handle == nullptr) {
1525 LOGE("Invalid parameter");
1526 return NOTI_EX_ERROR_INVALID_PARAMETER;
1529 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1530 if (color == nullptr) {
1531 (*p)->SetColor(nullptr);
1532 return NOTI_EX_ERROR_NONE;
1535 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1536 (*p)->SetColor(*col);
1538 return NOTI_EX_ERROR_NONE;
1541 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
1542 noti_ex_geometry_h *geometry) {
1543 if (handle == nullptr || geometry == nullptr) {
1544 LOGE("Invalid parameter");
1545 return NOTI_EX_ERROR_INVALID_PARAMETER;
1548 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1549 if ((*p)->GetGeometry() == nullptr) {
1550 LOGW("Geometry info is null");
1551 *geometry = nullptr;
1552 return NOTI_EX_ERROR_NONE;
1555 shared_ptr<Geometry>* geo = new (std::nothrow) shared_ptr<Geometry>(
1556 new (std::nothrow) Geometry(*((*p)->GetGeometry())));
1557 if (geo == nullptr || geo->get() == nullptr) {
1558 LOGE("Out-of-memory");
1559 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1564 return NOTI_EX_ERROR_NONE;
1567 extern "C" EXPORT_API int noti_ex_style_set_geometry(
1568 noti_ex_style_h handle, noti_ex_geometry_h geometry) {
1569 if (handle == nullptr) {
1570 LOGE("Invalid parameter");
1571 return NOTI_EX_ERROR_INVALID_PARAMETER;
1574 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1575 if (geometry == nullptr) {
1576 (*p)->SetGeometry(nullptr);
1577 return NOTI_EX_ERROR_NONE;
1580 shared_ptr<Geometry>* geo = static_cast<shared_ptr<Geometry>*>(geometry);
1581 (*p)->SetGeometry(*geo);
1583 return NOTI_EX_ERROR_NONE;
1586 extern "C" EXPORT_API int noti_ex_style_get_background_image(
1587 noti_ex_style_h handle, char** background_image) {
1588 if (handle == nullptr || background_image == nullptr) {
1589 LOGE("Invalid parameter");
1590 return NOTI_EX_ERROR_INVALID_PARAMETER;
1593 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1595 if ((*p)->GetBackgroundImage().empty())
1596 *background_image = nullptr;
1598 *background_image = strdup((*p)->GetBackgroundImage().c_str());
1600 return NOTI_EX_ERROR_NONE;
1603 extern "C" EXPORT_API int noti_ex_style_set_background_image(
1604 noti_ex_style_h handle, char* background_image) {
1605 if (handle == nullptr) {
1606 LOGE("Invalid parameter");
1607 return NOTI_EX_ERROR_INVALID_PARAMETER;
1610 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1611 if (background_image == nullptr)
1612 (*p)->SetBackgroundImage("");
1614 (*p)->SetBackgroundImage(background_image);
1616 return NOTI_EX_ERROR_NONE;
1619 extern "C" EXPORT_API int noti_ex_style_get_background_color(
1620 noti_ex_style_h handle, noti_ex_color_h* color) {
1621 if (handle == nullptr || color == nullptr) {
1622 LOGE("Invalid parameter");
1623 return NOTI_EX_ERROR_INVALID_PARAMETER;
1626 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1627 if ((*p)->GetBackgroundColor() == nullptr) {
1628 LOGW("Color info is null");
1630 return NOTI_EX_ERROR_NONE;
1633 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1634 new (std::nothrow) Color(*((*p)->GetBackgroundColor())));
1635 if (col == nullptr || col->get() == nullptr) {
1636 LOGE("Out-of-memory");
1637 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1642 return NOTI_EX_ERROR_NONE;
1645 extern "C" EXPORT_API int noti_ex_style_set_background_color(
1646 noti_ex_style_h handle, noti_ex_color_h color) {
1647 if (handle == nullptr) {
1648 LOGE("Invalid parameter");
1649 return NOTI_EX_ERROR_INVALID_PARAMETER;
1652 shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
1653 if (color == nullptr) {
1654 (*p)->SetBackgroundColor(nullptr);
1655 return NOTI_EX_ERROR_NONE;
1658 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1659 (*p)->SetBackgroundColor(*col);
1661 return NOTI_EX_ERROR_NONE;
1664 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
1665 noti_ex_color_h color) {
1666 if (handle == nullptr || color == nullptr) {
1667 LOGE("Invalid parameter");
1668 return NOTI_EX_ERROR_INVALID_PARAMETER;
1671 shared_ptr<Color>* color_ptr = static_cast<shared_ptr<Color>*>(color);
1672 shared_ptr<LEDInfo>* p = new (std::nothrow) shared_ptr<LEDInfo>(
1673 new (std::nothrow) LEDInfo(*color_ptr));
1675 LOGE("Out-of-memory");
1676 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1681 return NOTI_EX_ERROR_NONE;
1684 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
1685 if (handle == nullptr) {
1686 LOGE("Invalid parameter");
1687 return NOTI_EX_ERROR_INVALID_PARAMETER;
1690 shared_ptr<LEDInfo>* led_ptr =
1691 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1693 return NOTI_EX_ERROR_NONE;
1696 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
1697 noti_ex_led_info_h handle, int ms) {
1698 if (handle == nullptr) {
1699 LOGE("Invalid parameter");
1700 return NOTI_EX_ERROR_INVALID_PARAMETER;
1703 shared_ptr<LEDInfo>* led_ptr =
1704 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1705 (*led_ptr)->SetOnPeriod(ms);
1707 return NOTI_EX_ERROR_NONE;
1710 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
1711 noti_ex_led_info_h handle, int *ms) {
1712 if (handle == nullptr || ms == nullptr) {
1713 LOGE("Invalid parameter");
1714 return NOTI_EX_ERROR_INVALID_PARAMETER;
1717 shared_ptr<LEDInfo>* led_ptr =
1718 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1719 *ms = (*led_ptr)->GetOnPeriod();
1721 return NOTI_EX_ERROR_NONE;
1724 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
1725 noti_ex_led_info_h handle, int ms) {
1726 if (handle == nullptr) {
1727 LOGE("Invalid parameter");
1728 return NOTI_EX_ERROR_INVALID_PARAMETER;
1731 shared_ptr<LEDInfo>* led_ptr =
1732 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1733 (*led_ptr)->SetOffPeriod(ms);
1735 return NOTI_EX_ERROR_NONE;
1738 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
1739 noti_ex_led_info_h handle, int *ms) {
1740 if (handle == nullptr) {
1741 LOGE("Invalid parameter");
1742 return NOTI_EX_ERROR_INVALID_PARAMETER;
1745 shared_ptr<LEDInfo>* led_ptr =
1746 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1747 *ms = (*led_ptr)->GetOffPeriod();
1749 return NOTI_EX_ERROR_NONE;
1752 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1753 noti_ex_led_info_h handle, noti_ex_color_h *color) {
1754 if (handle == nullptr) {
1755 LOGE("Invalid parameter");
1756 return NOTI_EX_ERROR_INVALID_PARAMETER;
1759 shared_ptr<LEDInfo>* led_ptr =
1760 reinterpret_cast<shared_ptr<LEDInfo>*>(handle);
1761 if ((*led_ptr)->GetColor() == nullptr) {
1762 LOGW("Color is null");
1764 return NOTI_EX_ERROR_NONE;
1767 shared_ptr<Color>* col = new (std::nothrow) shared_ptr<Color>(
1768 new (std::nothrow) Color(*((*led_ptr)->GetColor())));
1769 if (col == nullptr || col->get() == nullptr) {
1770 LOGE("Out-of-memory");
1771 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1776 return NOTI_EX_ERROR_NONE;
1779 extern "C" EXPORT_API int noti_ex_led_info_set_color(
1780 noti_ex_led_info_h handle, noti_ex_color_h color) {
1781 if (handle == nullptr) {
1782 LOGE("Invalid parameter");
1783 return NOTI_EX_ERROR_INVALID_PARAMETER;
1786 shared_ptr<LEDInfo>* p = static_cast<shared_ptr<LEDInfo>*>(handle);
1787 if (color == nullptr) {
1788 (*p)->SetColor(nullptr);
1789 return NOTI_EX_ERROR_NONE;
1792 shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
1793 (*p)->SetColor(*col);
1795 return NOTI_EX_ERROR_NONE;
1798 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1799 if (handle == nullptr) {
1800 LOGE("Invalid parameter");
1801 return NOTI_EX_ERROR_INVALID_PARAMETER;
1804 shared_ptr<AbstractAction>* ptr =
1805 static_cast<shared_ptr<AbstractAction>*>(handle);
1808 return NOTI_EX_ERROR_NONE;
1811 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1813 if (handle == nullptr || type == nullptr) {
1814 LOGE("Invalid parameter");
1815 return NOTI_EX_ERROR_INVALID_PARAMETER;
1818 shared_ptr<AbstractAction>* ptr =
1819 static_cast<shared_ptr<AbstractAction>*>(handle);
1820 *type = (*ptr)->GetType();
1822 return NOTI_EX_ERROR_NONE;
1825 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1827 if (handle == nullptr || local == nullptr) {
1828 LOGE("Invalid parameter");
1829 return NOTI_EX_ERROR_INVALID_PARAMETER;
1832 shared_ptr<AbstractAction>* ptr =
1833 static_cast<shared_ptr<AbstractAction>*>(handle);
1834 *local = (*ptr)->IsLocal();
1836 return NOTI_EX_ERROR_NONE;
1839 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1840 noti_ex_item_h item) {
1841 if (handle == nullptr || item == nullptr) {
1842 LOGE("Invalid parameter");
1843 return NOTI_EX_ERROR_INVALID_PARAMETER;
1845 shared_ptr<AbstractAction>* ptr =
1846 static_cast<shared_ptr<AbstractAction>*>(handle);
1847 Handle* ih = static_cast<Handle*>(item);
1848 (*ptr)->Execute(ih->GetPtr());
1850 return NOTI_EX_ERROR_NONE;
1853 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1855 if (handle == nullptr || extra == nullptr) {
1856 LOGE("Invalid parameter");
1857 return NOTI_EX_ERROR_INVALID_PARAMETER;
1860 shared_ptr<AbstractAction>* ptr =
1861 static_cast<shared_ptr<AbstractAction>*>(handle);
1862 if (!(*ptr)->GetExtra().empty()) {
1863 *extra = strdup((*ptr)->GetExtra().c_str());
1864 if (*extra == nullptr) {
1865 LOGE("Out-of-memory");
1866 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1872 return NOTI_EX_ERROR_NONE;
1875 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1876 noti_ex_item_info_h handle, int *hide_time) {
1877 if (handle == nullptr || hide_time == nullptr) {
1878 LOGE("Invalid parameter");
1879 return NOTI_EX_ERROR_INVALID_PARAMETER;
1881 IItemInfo* p = static_cast<IItemInfo*>(handle);
1882 *hide_time = p->GetHideTime();
1883 return NOTI_EX_ERROR_NONE;
1886 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1887 noti_ex_item_info_h handle, int hide_time) {
1888 if (handle == nullptr) {
1889 LOGE("Invalid parameter");
1890 return NOTI_EX_ERROR_INVALID_PARAMETER;
1892 IItemInfo* p = static_cast<IItemInfo*>(handle);
1893 p->SetHideTime(hide_time);
1894 return NOTI_EX_ERROR_NONE;
1897 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1898 noti_ex_item_info_h handle, int *delete_time) {
1899 if (handle == nullptr || delete_time == nullptr) {
1900 LOGE("Invalid parameter");
1901 return NOTI_EX_ERROR_INVALID_PARAMETER;
1903 IItemInfo* p = static_cast<IItemInfo*>(handle);
1904 *delete_time = p->GetDeleteTime();
1905 return NOTI_EX_ERROR_NONE;
1908 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
1909 noti_ex_item_info_h handle, int delete_time) {
1910 if (handle == nullptr) {
1911 LOGE("Invalid parameter");
1912 return NOTI_EX_ERROR_INVALID_PARAMETER;
1914 IItemInfo* p = static_cast<IItemInfo*>(handle);
1915 p->SetDeleteTime(delete_time);
1916 return NOTI_EX_ERROR_NONE;
1919 extern "C" EXPORT_API int noti_ex_item_info_get_time(
1920 noti_ex_item_info_h handle, time_t *time) {
1921 if (handle == nullptr || time == nullptr) {
1922 LOGE("Invalid parameter");
1923 return NOTI_EX_ERROR_INVALID_PARAMETER;
1926 IItemInfo* p = static_cast<IItemInfo*>(handle);
1927 *time = p->GetTime();
1928 return NOTI_EX_ERROR_NONE;
1931 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
1932 if (handle == nullptr) {
1933 LOGE("Invalid parameter");
1934 return NOTI_EX_ERROR_INVALID_PARAMETER;
1937 Handle* h = static_cast<Handle*>(handle);
1939 return NOTI_EX_ERROR_NONE;
1942 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
1943 const char *id, noti_ex_item_h *item) {
1944 if (handle == nullptr) {
1945 LOGE("Invalid parameter");
1946 return NOTI_EX_ERROR_INVALID_PARAMETER;
1949 Handle* p = static_cast<Handle*>(handle);
1950 AbstractItem& find_item = p->Get()->FindByID(string(id));
1951 if (find_item.GetType() == AbstractItem::NullObject) {
1952 LOGW("Not exist ID");
1954 return NOTI_EX_ERROR_NONE;
1957 *item = new Handle(&find_item);
1958 return NOTI_EX_ERROR_NONE;
1961 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
1963 if (handle == nullptr || type == nullptr) {
1964 LOGE("Invalid parameter");
1965 return NOTI_EX_ERROR_INVALID_PARAMETER;
1968 Handle* h = static_cast<Handle*>(handle);
1969 AbstractItem* p = h->Get();
1970 *type = p->GetType();
1971 return NOTI_EX_ERROR_NONE;
1974 extern "C" EXPORT_API int noti_ex_item_get_shared_paths(noti_ex_item_h handle,
1975 char ***path, int *count) {
1976 if (handle == nullptr || path == nullptr || count == nullptr) {
1977 LOGE("Invalid parameter");
1978 return NOTI_EX_ERROR_INVALID_PARAMETER;
1980 Handle* p = static_cast<Handle*>(handle);
1981 list<string> shared_path = p->Get()->GetSharedPath();
1982 char** tmp_path = (char**)calloc(shared_path.size(), sizeof(char*));
1983 if (tmp_path == nullptr) {
1984 LOGE("Fail to create items");
1985 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1989 for (auto& i : shared_path) {
1990 tmp_path[idx] = strdup(i.c_str());
1991 if (tmp_path[idx] == nullptr) {
1992 __noti_ex_free_str_array(tmp_path, idx);
1993 LOGE("Out of memory");
1994 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2000 *count = shared_path.size();
2001 return NOTI_EX_ERROR_NONE;
2004 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
2006 if (handle == nullptr || id == nullptr) {
2007 LOGE("Invalid parameter");
2008 return NOTI_EX_ERROR_INVALID_PARAMETER;
2010 Handle* h = static_cast<Handle*>(handle);
2011 AbstractItem* p = h->Get();
2012 *id = strdup(p->GetId().c_str());
2013 return NOTI_EX_ERROR_NONE;
2016 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
2018 if (handle == nullptr || id == nullptr) {
2019 LOGE("Invalid parameter");
2020 return NOTI_EX_ERROR_INVALID_PARAMETER;
2022 Handle* p = static_cast<Handle*>(handle);
2023 p->Get()->SetId(id);
2024 return NOTI_EX_ERROR_NONE;
2027 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
2028 noti_ex_action_h *action) {
2029 if (handle == nullptr || action == nullptr) {
2030 LOGE("Invalid parameter");
2031 return NOTI_EX_ERROR_INVALID_PARAMETER;
2033 Handle* p = static_cast<Handle*>(handle);
2034 if (p->Get()->GetAction() == nullptr) {
2036 return NOTI_EX_ERROR_NONE;
2038 *action = static_cast<noti_ex_action_h>(new shared_ptr<AbstractAction>(
2039 p->Get()->GetAction()));
2041 return NOTI_EX_ERROR_NONE;
2044 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
2045 noti_ex_action_h action) {
2046 if (handle == nullptr) {
2047 LOGE("Invalid parameter");
2048 return NOTI_EX_ERROR_INVALID_PARAMETER;
2051 Handle* p = static_cast<Handle*>(handle);
2052 if (action == nullptr) {
2053 p->Get()->SetAction(nullptr);
2054 return NOTI_EX_ERROR_NONE;
2057 shared_ptr<AbstractAction>* ptr =
2058 static_cast<shared_ptr<AbstractAction>*>(action);
2059 p->Get()->SetAction(*ptr);
2060 return NOTI_EX_ERROR_NONE;
2063 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
2064 noti_ex_style_h *style) {
2065 if (handle == nullptr || style == nullptr) {
2066 LOGE("Invalid parameter");
2067 return NOTI_EX_ERROR_INVALID_PARAMETER;
2070 Handle* p = static_cast<Handle*>(handle);
2071 shared_ptr<Style> s = p->Get()->GetStyle();
2072 if (s.get() == nullptr) {
2073 LOGW("Style is null");
2075 return NOTI_EX_ERROR_NONE;
2078 auto* ptr = new (std::nothrow) shared_ptr<Style>(new (std::nothrow) Style(*s));
2079 if (ptr == nullptr || ptr->get() == nullptr) {
2080 LOGE("Out of memory");
2081 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2085 return NOTI_EX_ERROR_NONE;
2088 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
2089 noti_ex_style_h style) {
2090 if (handle == nullptr) {
2091 LOGE("Invalid parameter");
2092 return NOTI_EX_ERROR_INVALID_PARAMETER;
2095 Handle* p = static_cast<Handle*>(handle);
2096 if (style == nullptr) {
2097 p->Get()->SetStyle(nullptr);
2098 return NOTI_EX_ERROR_NONE;
2101 shared_ptr<Style>* s = static_cast<shared_ptr<Style>*>(style);
2102 p->Get()->SetStyle(*s);
2103 return NOTI_EX_ERROR_NONE;
2106 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
2108 if (handle == nullptr) {
2109 LOGE("Invalid parameter");
2110 return NOTI_EX_ERROR_INVALID_PARAMETER;
2113 Handle* p = static_cast<Handle*>(handle);
2114 p->Get()->SetVisible(visible);
2115 return NOTI_EX_ERROR_NONE;
2118 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
2120 if (handle == nullptr || visible == nullptr) {
2121 LOGE("Invalid parameter");
2122 return NOTI_EX_ERROR_INVALID_PARAMETER;
2125 Handle* p = static_cast<Handle*>(handle);
2126 *visible = p->Get()->GetVisible();
2127 return NOTI_EX_ERROR_NONE;
2130 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
2132 if (handle == nullptr) {
2133 LOGE("Invalid parameter");
2134 return NOTI_EX_ERROR_INVALID_PARAMETER;
2137 Handle* p = static_cast<Handle*>(handle);
2138 p->Get()->SetEnable(enable);
2139 return NOTI_EX_ERROR_NONE;
2142 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
2144 if (handle == nullptr || enable == nullptr) {
2145 LOGE("Invalid parameter");
2146 return NOTI_EX_ERROR_INVALID_PARAMETER;
2149 Handle* p = static_cast<Handle*>(handle);
2150 *enable = p->Get()->GetEnable();
2151 return NOTI_EX_ERROR_NONE;
2154 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
2155 const char *receiver_group) {
2156 if (handle == nullptr || receiver_group == nullptr) {
2157 LOGE("Invalid parameter");
2158 return NOTI_EX_ERROR_INVALID_PARAMETER;
2161 Handle* p = static_cast<Handle*>(handle);
2162 p->Get()->AddReceiver(receiver_group);
2163 return NOTI_EX_ERROR_NONE;
2166 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
2167 const char *receiver_group) {
2168 if (handle == nullptr || receiver_group == nullptr) {
2169 LOGE("Invalid parameter");
2170 return NOTI_EX_ERROR_INVALID_PARAMETER;
2173 Handle* p = static_cast<Handle*>(handle);
2174 p->Get()->RemoveReceiver(receiver_group);
2175 return NOTI_EX_ERROR_NONE;
2178 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
2179 char ***receiver_list, int *count) {
2180 if (handle == nullptr || receiver_list == nullptr || count == nullptr) {
2181 LOGE("Invalid parameter");
2182 return NOTI_EX_ERROR_INVALID_PARAMETER;
2185 Handle* p = static_cast<Handle*>(handle);
2186 list<string> receivers = p->Get()->GetReceiverList();
2187 if (receivers.size() == 0) {
2188 *receiver_list = nullptr;
2190 return NOTI_EX_ERROR_NONE;
2193 char **tmp_list = (char**)calloc(receivers.size(), sizeof(char*));
2194 if (tmp_list == nullptr) {
2195 LOGE("Out of memory");
2196 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2200 for (auto& i : receivers) {
2201 tmp_list[idx] = strdup(i.c_str());
2202 if (tmp_list[idx] == nullptr) {
2203 __noti_ex_free_str_array(tmp_list, idx);
2204 LOGE("Out of memory");
2205 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2210 *receiver_list = tmp_list;
2211 *count = receivers.size();
2212 return NOTI_EX_ERROR_NONE;
2215 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
2217 if (handle == nullptr) {
2218 LOGE("Invalid parameter");
2219 return NOTI_EX_ERROR_INVALID_PARAMETER;
2222 Handle* p = static_cast<Handle*>(handle);
2223 p->Get()->SetPolicy(policy);
2224 return NOTI_EX_ERROR_NONE;
2227 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
2229 if (handle == nullptr || policy == nullptr) {
2230 LOGE("Invalid parameter");
2231 return NOTI_EX_ERROR_INVALID_PARAMETER;
2234 Handle* p = static_cast<Handle*>(handle);
2235 *policy = p->Get()->GetPolicy();
2236 return NOTI_EX_ERROR_NONE;
2239 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
2241 if (handle == nullptr || channel == nullptr) {
2242 LOGE("Invalid parameter");
2243 return NOTI_EX_ERROR_INVALID_PARAMETER;
2246 Handle* p = static_cast<Handle*>(handle);
2247 if (!p->Get()->GetChannel().empty())
2248 *channel = strdup(p->Get()->GetChannel().c_str());
2252 return NOTI_EX_ERROR_NONE;
2255 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
2256 const char *channel) {
2257 if (handle == nullptr) {
2258 LOGE("Invalid parameter");
2259 return NOTI_EX_ERROR_INVALID_PARAMETER;
2262 Handle* p = static_cast<Handle*>(handle);
2263 p->Get()->SetChannel(channel);
2264 return NOTI_EX_ERROR_NONE;
2267 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
2268 noti_ex_led_info_h led) {
2269 if (handle == nullptr) {
2270 LOGE("Invalid parameter");
2271 return NOTI_EX_ERROR_INVALID_PARAMETER;
2274 Handle* p = static_cast<Handle*>(handle);
2275 if (led == nullptr) {
2276 p->Get()->SetLEDInfo(nullptr);
2277 return NOTI_EX_ERROR_NONE;
2279 shared_ptr<LEDInfo>* led_ptr =
2280 reinterpret_cast<shared_ptr<LEDInfo>*>(led);
2281 p->Get()->SetLEDInfo(*led_ptr);
2282 return NOTI_EX_ERROR_NONE;
2285 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
2286 noti_ex_led_info_h *led) {
2287 if (handle == nullptr) {
2288 LOGE("Invalid parameter");
2289 return NOTI_EX_ERROR_INVALID_PARAMETER;
2292 Handle* p = static_cast<Handle*>(handle);
2293 if (p->Get()->GetLEDInfo() != nullptr)
2294 *led = new shared_ptr<LEDInfo>(p->Get()->GetLEDInfo());
2297 return NOTI_EX_ERROR_NONE;
2300 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
2302 if (handle == nullptr) {
2303 LOGE("Invalid parameter");
2304 return NOTI_EX_ERROR_INVALID_PARAMETER;
2307 Handle* p = static_cast<Handle*>(handle);
2308 if (path == nullptr)
2309 p->Get()->SetSoundPath("");
2311 p->Get()->SetSoundPath(path);
2312 return NOTI_EX_ERROR_NONE;
2315 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
2317 if (handle == nullptr) {
2318 LOGE("Invalid parameter");
2319 return NOTI_EX_ERROR_INVALID_PARAMETER;
2322 Handle* p = static_cast<Handle*>(handle);
2323 if (path == nullptr)
2324 p->Get()->SetVibrationPath("");
2326 p->Get()->SetVibrationPath(path);
2327 return NOTI_EX_ERROR_NONE;
2330 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
2332 if (handle == nullptr || path == nullptr) {
2333 LOGE("Invalid parameter");
2334 return NOTI_EX_ERROR_INVALID_PARAMETER;
2337 Handle* p = static_cast<Handle*>(handle);
2338 if (p->Get()->GetSoundPath().empty())
2341 *path = strdup(p->Get()->GetSoundPath().c_str());
2342 return NOTI_EX_ERROR_NONE;
2345 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
2347 if (handle == nullptr || path == nullptr) {
2348 LOGE("Invalid parameter");
2349 return NOTI_EX_ERROR_INVALID_PARAMETER;
2352 Handle* p = static_cast<Handle*>(handle);
2353 if (p->Get()->GetVibrationPath().empty())
2356 *path = strdup(p->Get()->GetVibrationPath().c_str());
2357 return NOTI_EX_ERROR_NONE;
2360 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
2361 noti_ex_item_info_h *info) {
2362 if (handle == nullptr || info == nullptr) {
2363 LOGE("Invalid parameter");
2364 return NOTI_EX_ERROR_INVALID_PARAMETER;
2367 Handle* p = static_cast<Handle*>(handle);
2368 if (p->Get()->GetInfo() == nullptr)
2371 *info = static_cast<noti_ex_item_info_h>(p->Get()->GetInfo().get());
2372 return NOTI_EX_ERROR_NONE;
2375 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
2377 if (handle == nullptr || id == nullptr) {
2378 LOGE("Invalid parameter");
2379 return NOTI_EX_ERROR_INVALID_PARAMETER;
2382 Handle* p = static_cast<Handle*>(handle);
2383 if (p->Get()->GetSenderAppId().empty())
2386 *id = strdup(p->Get()->GetSenderAppId().c_str());
2387 return NOTI_EX_ERROR_NONE;
2390 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
2392 if (handle == nullptr || tag == nullptr) {
2393 LOGE("Invalid parameter");
2394 return NOTI_EX_ERROR_INVALID_PARAMETER;
2397 Handle* p = static_cast<Handle*>(handle);
2398 if (p->Get()->GetTag().empty())
2401 *tag = strdup(p->Get()->GetTag().c_str());
2402 return NOTI_EX_ERROR_NONE;
2405 extern "C" EXPORT_API int noti_ex_item_set_tag(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);
2414 p->Get()->SetTag("");
2416 p->Get()->SetTag(tag);
2417 return NOTI_EX_ERROR_NONE;
2420 extern "C" EXPORT_API int noti_ex_item_get_ongoing_state(noti_ex_item_h handle,
2422 if (handle == nullptr || ongoing == nullptr) {
2423 LOGE("Invalid parameter");
2424 return NOTI_EX_ERROR_INVALID_PARAMETER;
2427 Handle* p = static_cast<Handle*>(handle);
2428 *ongoing = p->Get()->GetOnGoingState();
2430 return NOTI_EX_ERROR_NONE;
2433 extern "C" EXPORT_API int noti_ex_item_set_ongoing_state(noti_ex_item_h handle,
2435 if (handle == nullptr) {
2436 LOGE("Invalid parameter");
2437 return NOTI_EX_ERROR_INVALID_PARAMETER;
2440 Handle* p = static_cast<Handle*>(handle);
2441 p->Get()->SetOnGoingState(ongoing);
2443 return NOTI_EX_ERROR_NONE;
2446 extern "C" EXPORT_API int noti_ex_item_check_type_exist(noti_ex_item_h handle,
2447 int type, bool* exist) {
2448 if (handle == nullptr || exist == nullptr) {
2449 LOGE("Invalid parameter");
2450 return NOTI_EX_ERROR_INVALID_PARAMETER;
2453 Handle* p = static_cast<Handle*>(handle);
2454 *exist = p->Get()->IsItemTypeExist(type);
2456 return NOTI_EX_ERROR_NONE;
2459 extern "C" EXPORT_API int noti_ex_item_get_main_type(noti_ex_item_h handle,
2461 if (handle == nullptr || type == nullptr) {
2462 LOGE("Invalid parameter");
2463 return NOTI_EX_ERROR_INVALID_PARAMETER;
2466 Handle* p = static_cast<Handle*>(handle);
2467 *type = p->Get()->GetMainType();
2469 return NOTI_EX_ERROR_NONE;
2472 extern "C" EXPORT_API int noti_ex_item_set_main_type(noti_ex_item_h handle,
2473 const char* id, int type) {
2474 if (handle == nullptr || id == nullptr) {
2475 LOGE("Invalid parameter");
2476 return NOTI_EX_ERROR_INVALID_PARAMETER;
2479 Handle* p = static_cast<Handle*>(handle);
2480 if (!(p->Get()->SetMainType(string(id),
2481 static_cast<AbstractItem::MainType>(type))))
2482 return NOTI_EX_ERROR_INVALID_PARAMETER;
2484 return NOTI_EX_ERROR_NONE;
2487 extern "C" EXPORT_API int noti_ex_item_find_by_main_type(noti_ex_item_h handle,
2488 int type, noti_ex_item_h* item) {
2489 if (handle == nullptr || item == nullptr) {
2490 LOGE("Invalid parameter");
2491 return NOTI_EX_ERROR_INVALID_PARAMETER;
2494 Handle* h = static_cast<Handle*>(handle);
2495 if (!h->IsValidType(AbstractItem::Group)) {
2496 LOGE("Invalid handle type");
2497 return NOTI_EX_ERROR_INVALID_PARAMETER;
2500 GroupItem* p = static_cast<GroupItem*>(h->Get());
2501 AbstractItem& find_item = p->FindByMainType(static_cast<AbstractItem::MainType>(type));
2502 if (find_item.GetType() == AbstractItem::NullObject) {
2503 LOGW("Not exist ID");
2505 return NOTI_EX_ERROR_NONE;
2507 *item = new Handle(&find_item);
2509 return NOTI_EX_ERROR_NONE;
2512 extern "C" EXPORT_API int noti_ex_item_get_extension_data(noti_ex_item_h handle,
2513 const char *key, bundle **value) {
2514 if (handle == nullptr || key == nullptr || value == nullptr) {
2515 LOGE("Invalid handle type");
2516 return NOTI_EX_ERROR_INVALID_PARAMETER;
2519 Handle* p = static_cast<Handle*>(handle);
2521 Bundle b = p->Get()->GetExtensionData(key);
2522 if (b.GetCount() == 0)
2525 *value = b.GetHandle();
2527 return NOTI_EX_ERROR_NONE;
2530 extern "C" EXPORT_API int noti_ex_item_set_extension_data(noti_ex_item_h handle,
2531 const char *key, bundle *value) {
2532 if (handle == nullptr || key == nullptr || value == nullptr) {
2533 LOGE("Invalid handle type");
2534 return NOTI_EX_ERROR_INVALID_PARAMETER;
2537 Bundle b = Bundle(value);
2539 Handle* p = static_cast<Handle*>(handle);
2540 p->Get()->SetExtensionData(key, b);
2542 return NOTI_EX_ERROR_NONE;
2545 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
2546 const char *receiver_group, noti_ex_manager_events_s event_callbacks,
2548 if (handle == nullptr) {
2549 LOGE("Invalid parameter");
2550 return NOTI_EX_ERROR_INVALID_PARAMETER;
2553 string receiver_group_str = "";
2555 receiver_group_str = string(receiver_group);
2557 ManagerStub* stub = new (std::nothrow) ManagerStub(
2558 unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
2559 unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
2560 receiver_group_str);
2561 if (stub == nullptr) {
2562 LOGE("Fail to create manager");
2563 return NOTI_EX_ERROR_IO_ERROR;
2565 stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
2566 new ManagerCallbackInfo(event_callbacks, data)));
2567 *handle = static_cast<noti_ex_manager_h>(stub);
2569 return NOTI_EX_ERROR_NONE;
2572 extern "C" EXPORT_API int noti_ex_manager_destroy(noti_ex_manager_h handle) {
2573 if (handle == nullptr) {
2574 LOGE("Invalid parameter");
2575 return NOTI_EX_ERROR_INVALID_PARAMETER;
2577 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2579 return NOTI_EX_ERROR_NONE;
2582 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
2583 noti_ex_item_h **items, int *count) {
2584 if (handle == nullptr || items == nullptr || count == nullptr) {
2585 LOGE("Invalid parameter");
2586 return NOTI_EX_ERROR_INVALID_PARAMETER;
2590 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2591 list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
2592 if (item_list.size() == 0) {
2595 return NOTI_EX_ERROR_NONE;
2597 noti_ex_item_h* added_item =
2598 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2599 if (added_item == nullptr) {
2600 LOGE("Fail to create items");
2601 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2605 for (auto& i : item_list) {
2606 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2608 *items = added_item;
2609 *count = item_list.size();
2610 } catch (Exception &ex) {
2611 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2612 return NOTI_EX_ERROR_IO_ERROR;
2614 return NOTI_EX_ERROR_NONE;
2617 extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
2618 noti_ex_manager_h handle, char* channel, noti_ex_item_h** items, int* count) {
2619 if (handle == nullptr || channel == nullptr ||
2620 items == nullptr || count == nullptr) {
2621 LOGE("Invalid parameter");
2622 return NOTI_EX_ERROR_INVALID_PARAMETER;
2626 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2627 list<unique_ptr<item::AbstractItem>> item_list = stub->Get(channel);
2628 if (item_list.size() == 0) {
2631 return NOTI_EX_ERROR_NONE;
2633 noti_ex_item_h* added_item =
2634 (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
2635 if (added_item == nullptr) {
2636 LOGE("Fail to create items");
2637 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2641 for (auto& i : item_list) {
2642 added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
2644 *items = added_item;
2645 *count = item_list.size();
2646 } catch (Exception &ex) {
2647 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2648 return NOTI_EX_ERROR_IO_ERROR;
2651 return NOTI_EX_ERROR_NONE;
2654 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
2655 noti_ex_item_h noti, int *request_id) {
2656 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2657 LOGE("Invalid parameter");
2658 return NOTI_EX_ERROR_INVALID_PARAMETER;
2661 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2662 Handle* sp = static_cast<Handle*>(noti);
2663 if (sp->GetPtr().get() == nullptr) {
2664 LOGE("Invalid noti reference can not be sended");
2665 return NOTI_EX_ERROR_INVALID_PARAMETER;
2667 *request_id = stub->Update(sp->GetPtr());
2669 } catch (Exception &ex) {
2670 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2671 return NOTI_EX_ERROR_IO_ERROR;
2673 return NOTI_EX_ERROR_NONE;
2676 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
2677 noti_ex_item_h noti, int *request_id) {
2678 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2679 LOGE("Invalid parameter");
2680 return NOTI_EX_ERROR_INVALID_PARAMETER;
2683 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2684 Handle* item = static_cast<Handle*>(noti);
2685 if (item->GetPtr().get() == nullptr) {
2686 LOGE("Invalid noti reference can not be sended");
2687 return NOTI_EX_ERROR_INVALID_PARAMETER;
2689 *request_id = stub->Delete(item->GetPtr());
2691 } catch (Exception &ex) {
2692 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2693 return NOTI_EX_ERROR_IO_ERROR;
2695 return NOTI_EX_ERROR_NONE;
2698 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
2700 if (handle == nullptr || request_id == nullptr) {
2701 LOGE("Invalid parameter");
2702 return NOTI_EX_ERROR_INVALID_PARAMETER;
2705 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2706 *request_id = stub->DeleteAll();
2707 } catch (Exception &ex) {
2708 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2709 return NOTI_EX_ERROR_IO_ERROR;
2711 return NOTI_EX_ERROR_NONE;
2714 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
2715 noti_ex_item_h noti, int *request_id) {
2716 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2717 LOGE("Invalid parameter");
2718 return NOTI_EX_ERROR_INVALID_PARAMETER;
2721 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2722 Handle* item = static_cast<Handle*>(noti);
2723 if (item->GetPtr().get() == nullptr) {
2724 LOGE("Invalid noti reference can not be sended");
2725 return NOTI_EX_ERROR_INVALID_PARAMETER;
2727 *request_id = stub->Hide(item->GetPtr());
2729 } catch (Exception &ex) {
2730 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2731 return NOTI_EX_ERROR_IO_ERROR;
2733 return NOTI_EX_ERROR_NONE;
2736 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
2737 noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
2738 if (handle == nullptr || root_id == nullptr || item == nullptr) {
2739 LOGE("Invalid parameter");
2740 return NOTI_EX_ERROR_INVALID_PARAMETER;
2743 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2744 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
2745 if (ptr == nullptr) {
2746 LOGW("Not exist ID");
2748 return NOTI_EX_ERROR_NONE;
2750 *item = new Handle(ptr);
2751 } catch (Exception &ex) {
2752 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2753 return NOTI_EX_ERROR_IO_ERROR;
2755 return NOTI_EX_ERROR_NONE;
2758 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
2759 noti_ex_event_info_h info, noti_ex_error_e error) {
2760 if (handle == nullptr || info == nullptr) {
2761 LOGE("Invalid parameter");
2762 return NOTI_EX_ERROR_INVALID_PARAMETER;
2765 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2766 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2767 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2768 static_cast<NotificationError>(error));
2769 } catch (Exception &ex) {
2770 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2771 return NOTI_EX_ERROR_IO_ERROR;
2773 return NOTI_EX_ERROR_NONE;
2776 extern "C" EXPORT_API int noti_ex_manager_get_notification_count(
2777 noti_ex_manager_h handle, int *cnt) {
2779 if (handle == nullptr || cnt == nullptr) {
2780 LOGE("Invalid parameter");
2781 return NOTI_EX_ERROR_INVALID_PARAMETER;
2784 ManagerStub* stub = static_cast<ManagerStub*>(handle);
2785 *cnt = stub->GetCount();
2786 } catch (Exception &ex) {
2787 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2788 return NOTI_EX_ERROR_IO_ERROR;
2790 return NOTI_EX_ERROR_NONE;
2793 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
2794 const char *id, float min, float current, float max) {
2797 if (handle == nullptr) {
2798 LOGE("Invalid parameter");
2799 return NOTI_EX_ERROR_INVALID_PARAMETER;
2803 p = new (std::nothrow) ProgressItem(id, min, current, max);
2805 p = new (std::nothrow) ProgressItem(min, current, max);
2808 LOGE("Out-of-memory");
2809 return NOTI_EX_ERROR_OUT_OF_MEMORY;
2812 *handle = new Handle(shared_ptr<AbstractItem>(p));
2814 return NOTI_EX_ERROR_NONE;
2817 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
2818 noti_ex_item_h handle, float *current) {
2819 if (handle == nullptr || current == nullptr) {
2820 LOGE("Invalid parameter");
2821 return NOTI_EX_ERROR_INVALID_PARAMETER;
2824 Handle *h = static_cast<Handle*>(handle);
2825 if (!h->IsValidType(AbstractItem::Progress)) {
2826 LOGE("Invalid handle type");
2827 return NOTI_EX_ERROR_INVALID_PARAMETER;
2829 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2830 *current = p->GetCurrent();
2832 return NOTI_EX_ERROR_NONE;
2835 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
2836 noti_ex_item_h handle, float current) {
2837 if (handle == nullptr) {
2838 LOGE("Invalid parameter");
2839 return NOTI_EX_ERROR_INVALID_PARAMETER;
2842 Handle *h = static_cast<Handle*>(handle);
2843 if (!h->IsValidType(AbstractItem::Progress)) {
2844 LOGE("Invalid handle type");
2845 return NOTI_EX_ERROR_INVALID_PARAMETER;
2847 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2848 p->SetCurrent(current);
2850 return NOTI_EX_ERROR_NONE;
2853 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
2855 if (handle == nullptr || min == nullptr) {
2856 LOGE("Invalid parameter");
2857 return NOTI_EX_ERROR_INVALID_PARAMETER;
2860 Handle *h = static_cast<Handle*>(handle);
2861 if (!h->IsValidType(AbstractItem::Progress)) {
2862 LOGE("Invalid handle type");
2863 return NOTI_EX_ERROR_INVALID_PARAMETER;
2865 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2868 return NOTI_EX_ERROR_NONE;
2871 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
2873 if (handle == nullptr || max == nullptr) {
2874 LOGE("Invalid parameter");
2875 return NOTI_EX_ERROR_INVALID_PARAMETER;
2878 Handle *h = static_cast<Handle*>(handle);
2879 if (!h->IsValidType(AbstractItem::Progress)) {
2880 LOGE("Invalid handle type");
2881 return NOTI_EX_ERROR_INVALID_PARAMETER;
2883 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2886 return NOTI_EX_ERROR_NONE;
2889 extern "C" EXPORT_API int noti_ex_item_progress_get_type(noti_ex_item_h handle,
2891 if (handle == nullptr || type == nullptr) {
2892 LOGE("Invalid parameter");
2893 return NOTI_EX_ERROR_INVALID_PARAMETER;
2896 Handle *h = static_cast<Handle*>(handle);
2897 if (!h->IsValidType(AbstractItem::Progress)) {
2898 LOGE("Invalid handle type");
2899 return NOTI_EX_ERROR_INVALID_PARAMETER;
2901 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2902 *type = static_cast<noti_ex_item_progress_type_e>(p->GetProgressType());
2904 return NOTI_EX_ERROR_NONE;
2907 extern "C" EXPORT_API int noti_ex_item_progress_set_type(noti_ex_item_h handle,
2909 if (handle == nullptr) {
2910 LOGE("Invalid parameter");
2911 return NOTI_EX_ERROR_INVALID_PARAMETER;
2914 Handle *h = static_cast<Handle*>(handle);
2915 if (!h->IsValidType(AbstractItem::Progress)) {
2916 LOGE("Invalid handle type");
2917 return NOTI_EX_ERROR_INVALID_PARAMETER;
2919 ProgressItem* p = static_cast<ProgressItem*>(h->Get());
2920 p->SetProgressType(static_cast<ProgressItem::Type>(type));
2922 return NOTI_EX_ERROR_NONE;
2925 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
2926 noti_ex_reporter_events_s event_callbacks, void *data) {
2927 if (handle == nullptr) {
2928 LOGE("Invalid parameter");
2929 return NOTI_EX_ERROR_INVALID_PARAMETER;
2932 ReporterStub* stub = new (std::nothrow) ReporterStub(
2933 unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
2934 unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())));
2935 if (stub == nullptr) {
2936 LOGE("Fail to create manager");
2937 return NOTI_EX_ERROR_IO_ERROR;
2939 stub->SetReporterCallbackInfo(unique_ptr<ReporterCallbackInfo>(
2940 new ReporterCallbackInfo(event_callbacks, data)));
2942 *handle = static_cast<noti_ex_reporter_h>(stub);
2944 return NOTI_EX_ERROR_NONE;
2947 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
2948 if (handle == nullptr) {
2949 LOGE("Invalid parameter");
2950 return NOTI_EX_ERROR_INVALID_PARAMETER;
2952 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2954 return NOTI_EX_ERROR_NONE;
2957 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
2958 noti_ex_event_info_h info, noti_ex_error_e error) {
2959 if (handle == nullptr || info == nullptr) {
2960 LOGE("Invalid parameter");
2961 return NOTI_EX_ERROR_INVALID_PARAMETER;
2964 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2965 IEventInfo* c_info = static_cast<IEventInfo*>(info);
2966 stub->SendError(static_cast<const IEventInfo&>(*c_info),
2967 static_cast<NotificationError>(error));
2968 } catch (Exception &ex) {
2969 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2970 return NOTI_EX_ERROR_IO_ERROR;
2972 return NOTI_EX_ERROR_NONE;
2975 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
2976 noti_ex_item_h noti, int *request_id) {
2977 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
2978 LOGE("Invalid parameter");
2979 return NOTI_EX_ERROR_INVALID_PARAMETER;
2982 ReporterStub* stub = static_cast<ReporterStub*>(handle);
2983 Handle* h = static_cast<Handle*>(noti);
2984 if (h->GetPtr().get() == nullptr) {
2985 LOGE("Invalid noti reference can not be sended");
2986 return NOTI_EX_ERROR_INVALID_PARAMETER;
2988 *request_id = stub->Post(h->GetPtr());
2990 } catch (Exception &ex) {
2991 LOGE("%s %d", ex.what(), ex.GetErrorCode());
2992 return NOTI_EX_ERROR_IO_ERROR;
2994 return NOTI_EX_ERROR_NONE;
2997 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
2998 noti_ex_item_h *noti_list, int count, int *request_id) {
3000 if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
3001 LOGE("Invalid parameter");
3002 return NOTI_EX_ERROR_INVALID_PARAMETER;
3005 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3006 list<shared_ptr<item::AbstractItem>> notiList;
3007 for (int i = 0; i < count; i++) {
3008 Handle* item = static_cast<Handle*>(noti_list[i]);
3009 notiList.push_back(item->GetPtr());
3011 *request_id = stub->Post(notiList);
3012 } catch (Exception &ex) {
3013 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3014 return NOTI_EX_ERROR_IO_ERROR;
3016 return NOTI_EX_ERROR_NONE;
3019 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
3020 noti_ex_item_h noti, int *request_id) {
3021 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3022 LOGE("Invalid parameter");
3023 return NOTI_EX_ERROR_INVALID_PARAMETER;
3026 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3027 Handle* item = static_cast<Handle*>(noti);
3028 if (item->GetPtr().get() == nullptr) {
3029 LOGE("Invalid noti reference can not be sended");
3030 return NOTI_EX_ERROR_INVALID_PARAMETER;
3032 *request_id = stub->Update(item->GetPtr());
3034 } catch (Exception &ex) {
3035 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3036 return NOTI_EX_ERROR_IO_ERROR;
3038 return NOTI_EX_ERROR_NONE;
3041 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
3042 noti_ex_item_h noti, int *request_id) {
3043 if (handle == nullptr || noti == nullptr || request_id == nullptr) {
3044 LOGE("Invalid parameter");
3045 return NOTI_EX_ERROR_INVALID_PARAMETER;
3048 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3049 Handle* item = static_cast<Handle*>(noti);
3050 if (item->GetPtr().get() == nullptr) {
3051 LOGE("Invalid noti reference can not be sended");
3052 return NOTI_EX_ERROR_INVALID_PARAMETER;
3054 *request_id = stub->Delete(item->GetPtr());
3056 } catch (Exception &ex) {
3057 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3058 return NOTI_EX_ERROR_IO_ERROR;
3060 return NOTI_EX_ERROR_NONE;
3063 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
3064 noti_ex_reporter_h handle, int *request_id) {
3065 if (handle == nullptr || request_id == nullptr) {
3066 LOGE("Invalid parameter");
3067 return NOTI_EX_ERROR_INVALID_PARAMETER;
3070 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3071 *request_id = stub->DeleteAll();
3072 } catch (Exception &ex) {
3073 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3074 return NOTI_EX_ERROR_IO_ERROR;
3076 return NOTI_EX_ERROR_NONE;
3079 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
3080 noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
3081 if (handle == nullptr || root_id == nullptr || item == nullptr) {
3082 LOGE("Invalid parameter");
3083 return NOTI_EX_ERROR_INVALID_PARAMETER;
3086 ReporterStub* stub = static_cast<ReporterStub*>(handle);
3087 shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
3088 if (ptr == nullptr) {
3089 LOGW("Not exist ID");
3091 return NOTI_EX_ERROR_NONE;
3093 *item = new Handle(ptr);
3094 } catch (Exception &ex) {
3095 LOGE("%s %d", ex.what(), ex.GetErrorCode());
3096 return NOTI_EX_ERROR_IO_ERROR;
3098 return NOTI_EX_ERROR_NONE;
3101 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
3102 const char *id, const char *text, const char *hyperlink) {
3103 if (handle == nullptr || text == nullptr) {
3104 LOGE("Invalid parameter");
3105 return NOTI_EX_ERROR_INVALID_PARAMETER;
3111 p = new (std::nothrow) TextItem(id, std::string(text),
3112 std::string(hyperlink));
3114 p = new (std::nothrow) TextItem(id, std::string(text));
3117 LOGE("Out-of-memory");
3118 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3121 *handle = new Handle(shared_ptr<AbstractItem>(p));
3123 return NOTI_EX_ERROR_NONE;
3126 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
3127 const char *contents) {
3128 if (handle == nullptr || contents == nullptr) {
3129 LOGE("Invalid parameter");
3130 return NOTI_EX_ERROR_INVALID_PARAMETER;
3133 Handle* p = static_cast<Handle*>(handle);
3134 if (!p->IsValidType(AbstractItem::Text)) {
3135 LOGE("Invalid handle type");
3136 return NOTI_EX_ERROR_INVALID_PARAMETER;
3138 TextItem* ti = static_cast<TextItem*>(p->Get());
3139 ti->SetContents(std::string(contents));
3141 return NOTI_EX_ERROR_NONE;
3144 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
3146 if (handle == nullptr || contents == nullptr) {
3147 LOGE("Invalid parameter");
3148 return NOTI_EX_ERROR_INVALID_PARAMETER;
3151 Handle* p = static_cast<Handle*>(handle);
3152 if (!p->IsValidType(AbstractItem::Text)) {
3153 LOGE("Invalid handle type");
3154 return NOTI_EX_ERROR_INVALID_PARAMETER;
3157 TextItem* ti = static_cast<TextItem*>(p->Get());
3159 if (ti->GetMultiLanguage() != nullptr &&
3160 !ti->GetMultiLanguage()->GetTranslatedString().empty())
3161 str = ti->GetMultiLanguage()->GetTranslatedString();
3162 else if (!ti->GetContents().empty())
3163 str = ti->GetContents();
3165 *contents = strdup(str.c_str());
3166 if (*contents == nullptr) {
3167 LOGE("Out-of-memory");
3168 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3171 return NOTI_EX_ERROR_NONE;
3174 extern "C" EXPORT_API int noti_ex_item_text_get_hyperlink(
3175 noti_ex_item_h handle, char **hyper_link) {
3176 if (handle == nullptr || hyper_link == nullptr) {
3177 LOGE("Invalid parameter");
3178 return NOTI_EX_ERROR_INVALID_PARAMETER;
3181 Handle* p = static_cast<Handle*>(handle);
3182 if (!p->IsValidType(AbstractItem::Text)) {
3183 LOGE("Invalid handle type");
3184 return NOTI_EX_ERROR_INVALID_PARAMETER;
3186 TextItem* ti = static_cast<TextItem*>(p->Get());
3187 if (!ti->GetHyperLink().empty()) {
3188 *hyper_link = strdup(ti->GetHyperLink().c_str());
3189 if (*hyper_link == nullptr) {
3190 LOGE("Out-of-memory");
3191 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3194 *hyper_link = nullptr;
3197 return NOTI_EX_ERROR_NONE;
3200 extern "C" EXPORT_API int noti_ex_item_text_set_multi_language(
3201 noti_ex_item_h handle, noti_ex_multi_lang_h multi) {
3202 if (handle == nullptr) {
3203 LOGE("Invalid parameter");
3204 return NOTI_EX_ERROR_INVALID_PARAMETER;
3207 Handle* p = static_cast<Handle*>(handle);
3208 if (!p->IsValidType(AbstractItem::Text)) {
3209 LOGE("Invalid handle type");
3210 return NOTI_EX_ERROR_INVALID_PARAMETER;
3213 TextItem* ti = static_cast<TextItem*>(p->Get());
3214 if (multi == nullptr) {
3215 ti->SetMultiLanguage(nullptr);
3216 return NOTI_EX_ERROR_NONE;
3219 shared_ptr<MultiLanguage> mul_ptr =
3220 *reinterpret_cast<shared_ptr<MultiLanguage>*>(multi);
3221 ti->SetMultiLanguage(mul_ptr);
3222 ti->GetMultiLanguage()->UpdateString();
3224 return NOTI_EX_ERROR_NONE;
3227 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
3228 const char *id, time_t time) {
3231 if (handle == nullptr) {
3232 LOGE("Invalid parameter");
3233 return NOTI_EX_ERROR_INVALID_PARAMETER;
3238 p = new (std::nothrow) TimeItem(id, time);
3240 p = new (std::nothrow) TimeItem(time);
3242 p = new (std::nothrow) TimeItem();
3246 LOGE("Out-of-memory");
3247 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3250 *handle = new Handle(shared_ptr<AbstractItem>(p));
3252 return NOTI_EX_ERROR_NONE;
3255 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
3257 if (handle == nullptr || time == nullptr) {
3258 LOGE("Invalid parameter");
3259 return NOTI_EX_ERROR_INVALID_PARAMETER;
3261 Handle* h = static_cast<Handle*>(handle);
3262 if (!h->IsValidType(AbstractItem::Time)) {
3263 LOGE("Invalid handle type");
3264 return NOTI_EX_ERROR_INVALID_PARAMETER;
3266 TimeItem* p = static_cast<TimeItem*>(h->Get());
3267 *time = p->GetTime();
3269 return NOTI_EX_ERROR_NONE;
3272 extern "C" EXPORT_API int noti_ex_item_time_set_time(noti_ex_item_h handle,
3274 if (handle == nullptr) {
3275 LOGE("Invalid parameter");
3276 return NOTI_EX_ERROR_INVALID_PARAMETER;
3278 Handle* h = static_cast<Handle*>(handle);
3279 if (!h->IsValidType(AbstractItem::Time)) {
3280 LOGE("Invalid handle type");
3281 return NOTI_EX_ERROR_INVALID_PARAMETER;
3283 TimeItem* p = static_cast<TimeItem*>(h->Get());
3286 return NOTI_EX_ERROR_NONE;
3289 extern "C" EXPORT_API int noti_ex_action_visibility_create(
3290 noti_ex_action_h *handle, const char *extra) {
3291 if (handle == nullptr) {
3292 LOGE("Invalid parameter");
3293 return NOTI_EX_ERROR_INVALID_PARAMETER;
3296 string extra_str = "";
3298 extra_str = string(extra);
3300 shared_ptr<AbstractAction>* ptr = new (std::nothrow) shared_ptr<AbstractAction>(
3301 new (std::nothrow) VisibilityAction(extra_str));
3302 if (ptr == nullptr) {
3303 LOGE("Out-of-memory");
3304 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3309 return NOTI_EX_ERROR_NONE;
3312 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
3313 const char *id, bool visible) {
3314 if (handle == nullptr || id == nullptr) {
3315 LOGE("Invalid parameter");
3316 return NOTI_EX_ERROR_INVALID_PARAMETER;
3319 shared_ptr<AbstractAction>* ptr =
3320 static_cast<shared_ptr<AbstractAction>*>(handle);
3321 VisibilityAction* action = static_cast<VisibilityAction*>(ptr->get());
3322 action->SetVisibility(id, visible);
3324 return NOTI_EX_ERROR_NONE;
3327 extern "C" EXPORT_API int noti_ex_multi_lang_create(noti_ex_multi_lang_h* handle,
3328 const char* msgid, const char* format, ...) {
3329 if (handle == nullptr || msgid == nullptr || format == nullptr) {
3330 LOGE("Invalid parameter");
3331 return NOTI_EX_ERROR_INVALID_PARAMETER;
3334 const char* format_idx = format;
3337 va_start(args, format);
3338 while (*format_idx != '\0') {
3339 char* arg = nullptr;
3342 stringstream stream;
3343 if (*format_idx == '%') {
3344 switch (*(format_idx + 1)) {
3346 arg = va_arg(args, char *);
3347 arr.push_back(string(arg));
3350 arg_i = va_arg(args, int);
3351 arr.push_back(to_string(arg_i));
3354 arg_f = va_arg(args, double);
3355 stream << std::fixed << std::setprecision(2) << arg_f;
3356 arr.push_back(stream.str());
3364 MultiLanguage* p = new MultiLanguage(string(msgid), format, arr);
3366 LOGE("Out-of-memory");
3367 return NOTI_EX_ERROR_OUT_OF_MEMORY;
3369 *handle = new shared_ptr<MultiLanguage>(p);
3371 return NOTI_EX_ERROR_NONE;
3374 extern "C" EXPORT_API int noti_ex_multi_lang_destroy(noti_ex_multi_lang_h handle) {
3375 if (handle == nullptr) {
3376 LOGE("Invalid parameter");
3377 return NOTI_EX_ERROR_INVALID_PARAMETER;
3380 shared_ptr<MultiLanguage>* mul_ptr =
3381 reinterpret_cast<shared_ptr<MultiLanguage>*>(handle);
3383 return NOTI_EX_ERROR_NONE;
3386 extern "C" EXPORT_API int noti_ex_item_get_private_id(
3387 noti_ex_item_h item, int64_t* private_id) {
3388 if (item == nullptr || private_id == nullptr) {
3389 LOGE("Invalid parameter");
3390 return NOTI_EX_ERROR_INVALID_PARAMETER;
3393 Handle* h = static_cast<Handle*>(item);
3394 *private_id = static_pointer_cast<IItemInfoInternal>(
3395 h->Get()->GetInfo())->GetPrivateId();
3397 return NOTI_EX_ERROR_NONE;
3400 extern "C" EXPORT_API int noti_ex_item_set_private_id(
3401 noti_ex_item_h item, int64_t priv_id) {
3402 if (item == nullptr) {
3403 LOGE("Invalid parameter");
3404 return NOTI_EX_ERROR_INVALID_PARAMETER;
3407 Handle* h = static_cast<Handle*>(item);
3408 static_pointer_cast<IItemInfoInternal>(
3409 h->Get()->GetInfo())->SetPrivateId(priv_id);
3411 return NOTI_EX_ERROR_NONE;
3414 extern "C" EXPORT_API int noti_ex_item_free_string_list(char** list, int count) {
3415 if (list == nullptr) {
3416 LOGE("Invalid parameter");
3417 return NOTI_EX_ERROR_INVALID_PARAMETER;
3420 LOGI("Free strings (%d)", count);
3421 for (int i = 0; i < count; i++)
3425 return NOTI_EX_ERROR_NONE;
3428 extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h handle) {
3429 if (handle == nullptr) {
3430 LOGE("Invalid parameter");
3431 return NOTI_EX_ERROR_INVALID_PARAMETER;
3433 Handle* h = static_cast<Handle*>(handle);
3434 if (!h->IsValidType(AbstractItem::Group)) {
3435 LOGE("Invalid handle type");
3436 return NOTI_EX_ERROR_INVALID_PARAMETER;
3438 GroupItem* p = static_cast<GroupItem*>(h->Get());
3439 p->RemoveChildren();
3441 return NOTI_EX_ERROR_NONE;