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.
23 #include "api/notification_ex_app_control_action.h"
24 #include "api/notification_ex_button.h"
25 #include "api/notification_ex_chat_message.h"
26 #include "api/notification_ex_checkbox.h"
27 #include "api/notification_ex_entry.h"
28 #include "api/notification_ex_event_info.h"
29 #include "api/notification_ex_group.h"
30 #include "api/notification_ex_image.h"
31 #include "api/notification_ex_input_selector.h"
32 #include "api/notification_ex_item.h"
33 #include "api/notification_ex_manager.h"
34 #include "api/notification_ex_progress.h"
35 #include "api/notification_ex_reporter.h"
36 #include "api/notification_ex_text.h"
37 #include "api/notification_ex_time.h"
38 #include "api/notification_ex_visibility_action.h"
39 #include "notification-ex/reporter.h"
40 #include "notification-ex/app_control_action.h"
41 #include "notification-ex/button_item.h"
42 #include "notification-ex/chat_message_item.h"
43 #include "notification-ex/checkbox_item.h"
44 #include "notification-ex/entry_item.h"
45 #include "notification-ex/group_item.h"
46 #include "notification-ex/input_selector_item.h"
47 #include "notification-ex/abstract_item.h"
48 #include "notification-ex/progress_item.h"
49 #include "notification-ex/time_item.h"
50 #include "notification-ex/visibility_action.h"
55 #define LOG_TAG "NOTIFICATION_EX"
60 #define EXPORT_API __attribute__((visibility("default")))
63 using namespace notification::item;
65 extern "C" EXPORT_API int noti_ex_action_app_control_create(
66 noti_ex_action_h *handle, app_control_h app_control,
68 if (handle == nullptr || app_control == nullptr) {
69 LOGE("Invalid parameter");
70 return NOTI_EX_ERROR_INVALID_PARAMETER;
73 auto* p = new (std::nothrow) AppControlAction(app_control, extra);
75 LOGE("Out-of-memory");
76 return NOTI_EX_ERROR_OUT_OF_MEMORY;
81 return NOTI_EX_ERROR_NONE;
84 extern "C" EXPORT_API int noti_ex_action_app_control_set(
85 noti_ex_action_h handle, app_control_h app_control) {
86 if (handle == nullptr || app_control == nullptr) {
87 LOGE("Invalid parameter");
88 return NOTI_EX_ERROR_INVALID_PARAMETER;
91 AppControlAction* p = static_cast<AppControlAction*>(handle);
92 p->SetAppControl(app_control);
94 return NOTI_EX_ERROR_NONE;
97 extern "C" EXPORT_API int noti_ex_action_app_control_get(
98 noti_ex_action_h handle, app_control_h *app_control) {
99 if (handle == nullptr || app_control == nullptr) {
100 LOGE("Invalid parameter");
101 return NOTI_EX_ERROR_INVALID_PARAMETER;
104 AppControlAction* p = static_cast<AppControlAction*>(handle);
105 *app_control = p->GetAppControl();
107 return NOTI_EX_ERROR_NONE;
110 extern "C" EXPORT_API int noti_ex_item_button_create(noti_ex_item_h *handle,
111 const char *id, const char *title) {
114 if (handle == nullptr || title == nullptr) {
115 LOGE("Invalid parameter");
116 return NOTI_EX_ERROR_INVALID_PARAMETER;
120 p = new (std::nothrow) ButtonItem(id, title);
122 p = new (std::nothrow) ButtonItem(title);
125 LOGE("Out-of-memory");
126 return NOTI_EX_ERROR_OUT_OF_MEMORY;
131 return NOTI_EX_ERROR_NONE;
134 extern "C" EXPORT_API int noti_ex_item_button_get_title(noti_ex_item_h handle,
136 if (handle == nullptr || title == nullptr) {
137 LOGE("Invalid parameter");
138 return NOTI_EX_ERROR_INVALID_PARAMETER;
141 ButtonItem* p = static_cast<ButtonItem*>(handle);
142 if (!p->GetTitle().empty()) {
143 *title = strdup(p->GetTitle().c_str());
144 if (*title == nullptr) {
145 LOGE("Out-of-memory");
146 return NOTI_EX_ERROR_OUT_OF_MEMORY;
150 return NOTI_EX_ERROR_NONE;
153 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
154 noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
155 noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
156 noti_ex_item_chat_message_type_e message_type) {
157 if (handle == nullptr || message_type > NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER) {
158 LOGE("Invalid parameter");
159 return NOTI_EX_ERROR_INVALID_PARAMETER;
162 TextItem* name_ = static_cast<TextItem*>(name);
163 TextItem* text_ = static_cast<TextItem*>(text);
164 ImageItem* image_ = static_cast<ImageItem*>(image);
165 TimeItem* time_ = static_cast<TimeItem*>(time);
167 auto* p = new (std::nothrow) ChatMessageItem(id,
168 static_cast<std::shared_ptr<TextItem>>(name_),
169 static_cast<std::shared_ptr<TextItem>>(text_),
170 static_cast<std::shared_ptr<ImageItem>>(image_),
171 static_cast<std::shared_ptr<TimeItem>>(time_),
172 static_cast<ChatMessageItem::Type>((int)message_type));
174 LOGE("Out-of-memory");
175 return NOTI_EX_ERROR_OUT_OF_MEMORY;
180 return NOTI_EX_ERROR_NONE;
183 extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
184 noti_ex_item_h handle, noti_ex_item_h *name) {
185 if (handle == nullptr || name == nullptr) {
186 LOGE("Invalid parameter");
187 return NOTI_EX_ERROR_INVALID_PARAMETER;
190 ChatMessageItem* p = static_cast<ChatMessageItem*>(handle);
191 *name = &(p->GetNameItem());
193 return NOTI_EX_ERROR_NONE;
196 extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
197 noti_ex_item_h handle, noti_ex_item_h *text) {
198 if (handle == nullptr || text == nullptr) {
199 LOGE("Invalid parameter");
200 return NOTI_EX_ERROR_INVALID_PARAMETER;
203 ChatMessageItem* p = static_cast<ChatMessageItem*>(handle);
204 *text = &(p->GetTextItem());
206 return NOTI_EX_ERROR_NONE;
209 extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
210 noti_ex_item_h handle, noti_ex_item_h *image) {
211 if (handle == nullptr || image == nullptr) {
212 LOGE("Invalid parameter");
213 return NOTI_EX_ERROR_INVALID_PARAMETER;
216 ChatMessageItem* p = static_cast<ChatMessageItem*>(handle);
217 *image = &(p->GetImageItem());
219 return NOTI_EX_ERROR_NONE;
222 extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
223 noti_ex_item_h handle, noti_ex_item_h *time) {
224 if (handle == nullptr || time == nullptr) {
225 LOGE("Invalid parameter");
226 return NOTI_EX_ERROR_INVALID_PARAMETER;
229 ChatMessageItem* p = static_cast<ChatMessageItem*>(handle);
230 *time = &(p->GetTimeItem());
232 return NOTI_EX_ERROR_NONE;
235 extern "C" EXPORT_API int noti_ex_item_chat_message_get_message_type(
236 noti_ex_item_h handle, noti_ex_item_chat_message_type_e *message_type) {
237 if (handle == nullptr || message_type == nullptr) {
238 LOGE("Invalid parameter");
239 return NOTI_EX_ERROR_INVALID_PARAMETER;
242 ChatMessageItem* p = static_cast<ChatMessageItem*>(handle);
243 *message_type = (noti_ex_item_chat_message_type_e)(p->GetMessageType());
245 return NOTI_EX_ERROR_NONE;
248 extern "C" EXPORT_API int noti_ex_item_checkbox_create(noti_ex_item_h *handle,
249 const char *id, const char *title, bool checked) {
252 if (handle == nullptr || title == nullptr) {
253 LOGE("Invalid parameter");
254 return NOTI_EX_ERROR_INVALID_PARAMETER;
257 p = new (std::nothrow) CheckBoxItem(id, title, checked);
259 LOGE("Out-of-memory");
260 return NOTI_EX_ERROR_OUT_OF_MEMORY;
265 return NOTI_EX_ERROR_NONE;
268 extern "C" EXPORT_API int noti_ex_item_checkbox_get_title(noti_ex_item_h handle,
270 if (handle == nullptr || title == nullptr) {
271 LOGE("Invalid parameter");
272 return NOTI_EX_ERROR_INVALID_PARAMETER;
275 CheckBoxItem* p = static_cast<CheckBoxItem*>(handle);
276 if (!p->GetTitle().empty()) {
277 *title = strdup(p->GetTitle().c_str());
278 if (*title == nullptr) {
279 LOGE("Out-of-memory");
280 return NOTI_EX_ERROR_OUT_OF_MEMORY;
284 return NOTI_EX_ERROR_NONE;
287 extern "C" EXPORT_API int noti_ex_item_checkbox_is_checked(noti_ex_item_h handle,
289 if (handle == nullptr || checked == nullptr) {
290 LOGE("Invalid parameter");
291 return NOTI_EX_ERROR_INVALID_PARAMETER;
294 CheckBoxItem* p = static_cast<CheckBoxItem*>(handle);
295 *checked = p->IsChecked();
297 return NOTI_EX_ERROR_NONE;
300 extern "C" EXPORT_API int noti_ex_item_entry_create(noti_ex_item_h *handle,
304 if (handle == nullptr) {
305 LOGE("Invalid parameter");
306 return NOTI_EX_ERROR_INVALID_PARAMETER;
309 p = new (std::nothrow) EntryItem(id);
311 LOGE("Out-of-memory");
312 return NOTI_EX_ERROR_OUT_OF_MEMORY;
317 return NOTI_EX_ERROR_NONE;
320 extern "C" EXPORT_API int noti_ex_item_entry_get_text(noti_ex_item_h handle,
322 if (handle == nullptr || text == nullptr) {
323 LOGE("Invalid parameter");
324 return NOTI_EX_ERROR_INVALID_PARAMETER;
327 EntryItem* p = static_cast<EntryItem*>(handle);
328 if (!p->GetText().empty()) {
329 *text = strdup(p->GetText().c_str());
330 if (*text == nullptr) {
331 LOGE("Out-of-memory");
332 return NOTI_EX_ERROR_OUT_OF_MEMORY;
336 return NOTI_EX_ERROR_NONE;
339 extern "C" EXPORT_API int noti_ex_item_entry_set_text(noti_ex_item_h handle,
341 if (handle == nullptr || text == nullptr) {
342 LOGE("Invalid parameter");
343 return NOTI_EX_ERROR_INVALID_PARAMETER;
346 EntryItem* p = static_cast<EntryItem*>(handle);
347 p->SetText(std::string(text));
349 return NOTI_EX_ERROR_NONE;
352 extern "C" EXPORT_API int noti_ex_event_info_create(noti_ex_event_info_h *handle,
353 noti_ex_event_info_type_e type, const char *owner,
354 const char *channel, const char *item_id) {
355 return NOTI_EX_ERROR_NONE;
358 extern "C" EXPORT_API int noti_ex_event_info_destroy(
359 noti_ex_event_info_h handle) {
360 return NOTI_EX_ERROR_NONE;
363 extern "C" EXPORT_API int noti_ex_event_info_get_event_type(
364 noti_ex_event_info_h handle, noti_ex_event_info_type_e *event_type) {
365 return NOTI_EX_ERROR_NONE;
368 extern "C" EXPORT_API int noti_ex_event_info_get_owner(
369 noti_ex_event_info_h handle, char **owner) {
370 return NOTI_EX_ERROR_NONE;
373 extern "C" EXPORT_API int noti_ex_event_info_get_channel(
374 noti_ex_event_info_h handle, char **channel) {
375 return NOTI_EX_ERROR_NONE;
378 extern "C" EXPORT_API int noti_ex_event_info_get_item_id(
379 noti_ex_event_info_h handle, char **item_id) {
380 return NOTI_EX_ERROR_NONE;
383 extern "C" EXPORT_API int noti_ex_event_info_get_request_id(
384 noti_ex_event_info_h handle, int *req_id) {
385 return NOTI_EX_ERROR_NONE;
388 extern "C" EXPORT_API int noti_ex_item_group_create(noti_ex_item_h *handle,
392 if (handle == nullptr) {
393 LOGE("Invalid parameter");
394 return NOTI_EX_ERROR_INVALID_PARAMETER;
398 p = new (std::nothrow) GroupItem(id);
400 p = new (std::nothrow) GroupItem();
403 LOGE("Out-of-memory");
404 return NOTI_EX_ERROR_OUT_OF_MEMORY;
409 return NOTI_EX_ERROR_NONE;
412 extern "C" EXPORT_API int noti_ex_item_group_set_direction(noti_ex_item_h handle,
414 if (handle == nullptr) {
415 LOGE("Invalid parameter");
416 return NOTI_EX_ERROR_INVALID_PARAMETER;
419 GroupItem* p = static_cast<GroupItem*>(handle);
420 p->SetDirection(vertical);
422 return NOTI_EX_ERROR_NONE;
425 extern "C" EXPORT_API int noti_ex_item_group_is_vertical(noti_ex_item_h handle,
427 if (handle == nullptr) {
428 LOGE("Invalid parameter");
429 return NOTI_EX_ERROR_INVALID_PARAMETER;
432 GroupItem* p = static_cast<GroupItem*>(handle);
433 *vertical = p->IsVertical();
435 return NOTI_EX_ERROR_NONE;
438 extern "C" EXPORT_API int noti_ex_item_group_get_app_label(noti_ex_item_h handle,
440 if (handle == nullptr) {
441 LOGE("Invalid parameter");
442 return NOTI_EX_ERROR_INVALID_PARAMETER;
445 GroupItem* p = static_cast<GroupItem*>(handle);
446 if (!p->GetAppLabel().empty()) {
447 *label = strdup(p->GetAppLabel().c_str());
448 if (*label == nullptr) {
449 LOGE("Out-of-memory");
450 return NOTI_EX_ERROR_OUT_OF_MEMORY;
454 return NOTI_EX_ERROR_NONE;
457 extern "C" EXPORT_API int noti_ex_item_group_add_child(noti_ex_item_h handle,
458 noti_ex_item_h child) {
459 if (handle == nullptr || child == nullptr) {
460 LOGE("Invalid parameter");
461 return NOTI_EX_ERROR_INVALID_PARAMETER;
464 GroupItem* p = static_cast<GroupItem*>(handle);
466 AbstractItem* child_ = static_cast<AbstractItem*>(child);
467 p->AddChild(static_cast<std::shared_ptr<AbstractItem>>(child_));
469 return NOTI_EX_ERROR_NONE;
472 extern "C" EXPORT_API int noti_ex_item_group_remove_child(noti_ex_item_h handle,
473 const char *item_id) {
474 if (handle == nullptr || item_id == nullptr) {
475 LOGE("Invalid parameter");
476 return NOTI_EX_ERROR_INVALID_PARAMETER;
479 GroupItem* p = static_cast<GroupItem*>(handle);
480 p->RemoveChild(std::string(item_id));
482 return NOTI_EX_ERROR_NONE;
485 extern "C" EXPORT_API int noti_ex_item_group_foreach(
486 noti_ex_item_group_foreach_cb callback, void *data) {
487 if (callback == nullptr) {
488 LOGE("Invalid parameter");
489 return NOTI_EX_ERROR_INVALID_PARAMETER;
497 extern "C" EXPORT_API int noti_ex_item_image_create(noti_ex_item_h *handle,
498 const char *id, const char *image_path) {
501 if (handle == nullptr || image_path == nullptr) {
502 LOGE("Invalid parameter");
503 return NOTI_EX_ERROR_INVALID_PARAMETER;
507 p = new (std::nothrow) ImageItem(id, image_path);
509 p = new (std::nothrow) ImageItem(image_path);
512 LOGE("Out-of-memory");
513 return NOTI_EX_ERROR_OUT_OF_MEMORY;
518 return NOTI_EX_ERROR_NONE;
521 extern "C" EXPORT_API int noti_ex_item_image_get_image_path(
522 noti_ex_item_h handle, char **image_path) {
523 if (handle == nullptr || image_path == nullptr) {
524 LOGE("Invalid parameter");
525 return NOTI_EX_ERROR_INVALID_PARAMETER;
528 ImageItem* p = static_cast<ImageItem*>(handle);
529 if (!p->GetImagePath().empty()) {
530 *image_path = strdup(p->GetImagePath().c_str());
531 if (*image_path == nullptr) {
532 LOGE("Out-of-memory");
533 return NOTI_EX_ERROR_OUT_OF_MEMORY;
537 return NOTI_EX_ERROR_NONE;
540 extern "C" EXPORT_API int noti_ex_item_input_selector_create(
541 noti_ex_item_h *handle, const char *id) {
542 InputSelectorItem* p;
544 if (handle == nullptr) {
545 LOGE("Invalid parameter");
546 return NOTI_EX_ERROR_INVALID_PARAMETER;
550 p = new (std::nothrow) InputSelectorItem(id);
552 p = new (std::nothrow) InputSelectorItem();
555 LOGE("Out-of-memory");
556 return NOTI_EX_ERROR_OUT_OF_MEMORY;
561 return NOTI_EX_ERROR_NONE;
564 extern "C" EXPORT_API int noti_ex_item_input_selector_get_contents(
565 noti_ex_item_h handle, char ***list, int *count) {
566 if (handle == nullptr || list == nullptr || count == nullptr) {
567 LOGE("Invalid parameter");
568 return NOTI_EX_ERROR_INVALID_PARAMETER;
573 return NOTI_EX_ERROR_NONE;
576 extern "C" EXPORT_API int noti_ex_item_input_selector_set_contents(
577 noti_ex_item_h handle, const char **contents, int count) {
578 if (handle == nullptr || contents == nullptr) {
579 LOGE("Invalid parameter");
580 return NOTI_EX_ERROR_INVALID_PARAMETER;
585 return NOTI_EX_ERROR_NONE;
588 extern "C" EXPORT_API int noti_ex_color_create(noti_ex_color_h *handle,
589 unsigned char a, unsigned char r, unsigned char g, unsigned char b) {
590 if (handle == nullptr) {
591 LOGE("Invalid parameter");
592 return NOTI_EX_ERROR_INVALID_PARAMETER;
595 auto* p = new (std::nothrow) Color(a, r, g, b);
597 LOGE("Out-of-memory");
598 return NOTI_EX_ERROR_OUT_OF_MEMORY;
603 return NOTI_EX_ERROR_NONE;
606 extern "C" EXPORT_API int noti_ex_color_destroy(noti_ex_color_h handle) {
607 if (handle == nullptr) {
608 LOGE("Invalid parameter");
609 return NOTI_EX_ERROR_INVALID_PARAMETER;
612 Color* p = static_cast<Color*>(handle);
615 return NOTI_EX_ERROR_NONE;
618 extern "C" EXPORT_API int noti_ex_color_get_alpha(noti_ex_color_h handle,
619 unsigned char *val) {
620 if (handle == nullptr || val == nullptr) {
621 LOGE("Invalid parameter");
622 return NOTI_EX_ERROR_INVALID_PARAMETER;
625 Color* p = static_cast<Color*>(handle);
628 return NOTI_EX_ERROR_NONE;
631 extern "C" EXPORT_API int noti_ex_color_get_red(noti_ex_color_h handle,
632 unsigned char *val) {
633 if (handle == nullptr || val == nullptr) {
634 LOGE("Invalid parameter");
635 return NOTI_EX_ERROR_INVALID_PARAMETER;
638 Color* p = static_cast<Color*>(handle);
641 return NOTI_EX_ERROR_NONE;
644 extern "C" EXPORT_API int noti_ex_color_get_green(noti_ex_color_h handle,
645 unsigned char *val) {
646 if (handle == nullptr || val == nullptr) {
647 LOGE("Invalid parameter");
648 return NOTI_EX_ERROR_INVALID_PARAMETER;
651 Color* p = static_cast<Color*>(handle);
654 return NOTI_EX_ERROR_NONE;
657 extern "C" EXPORT_API int noti_ex_color_get_blue(noti_ex_color_h handle,
658 unsigned char *val) {
659 if (handle == nullptr || val == nullptr) {
660 LOGE("Invalid parameter");
661 return NOTI_EX_ERROR_INVALID_PARAMETER;
664 Color* p = static_cast<Color*>(handle);
667 return NOTI_EX_ERROR_NONE;
670 extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
671 int left, int top, int right, int bottom) {
672 if (handle == nullptr) {
673 LOGE("Invalid parameter");
674 return NOTI_EX_ERROR_INVALID_PARAMETER;
677 auto* p = new (std::nothrow) Padding(left, top, right, bottom);
679 LOGE("Out-of-memory");
680 return NOTI_EX_ERROR_OUT_OF_MEMORY;
685 return NOTI_EX_ERROR_NONE;
688 extern "C" EXPORT_API int noti_ex_padding_destroy(noti_ex_padding_h handle) {
689 if (handle == nullptr) {
690 LOGE("Invalid parameter");
691 return NOTI_EX_ERROR_INVALID_PARAMETER;
694 Padding* p = static_cast<Padding*>(handle);
697 return NOTI_EX_ERROR_NONE;
700 extern "C" EXPORT_API int noti_ex_padding_get_left(noti_ex_padding_h handle,
702 if (handle == nullptr || val == nullptr) {
703 LOGE("Invalid parameter");
704 return NOTI_EX_ERROR_INVALID_PARAMETER;
707 Padding* p = static_cast<Padding*>(handle);
710 return NOTI_EX_ERROR_NONE;
713 extern "C" EXPORT_API int noti_ex_padding_get_top(noti_ex_padding_h handle,
715 if (handle == nullptr || val == nullptr) {
716 LOGE("Invalid parameter");
717 return NOTI_EX_ERROR_INVALID_PARAMETER;
720 Padding* p = static_cast<Padding*>(handle);
723 return NOTI_EX_ERROR_NONE;
726 extern "C" EXPORT_API int noti_ex_padding_get_right(noti_ex_padding_h handle,
728 if (handle == nullptr || val == nullptr) {
729 LOGE("Invalid parameter");
730 return NOTI_EX_ERROR_INVALID_PARAMETER;
733 Padding* p = static_cast<Padding*>(handle);
734 *val = p->GetRight();
739 extern "C" EXPORT_API int noti_ex_padding_get_bottom(noti_ex_padding_h handle,
741 if (handle == nullptr || val == nullptr) {
742 LOGE("Invalid parameter");
743 return NOTI_EX_ERROR_INVALID_PARAMETER;
746 Padding* p = static_cast<Padding*>(handle);
747 *val = p->GetBottom();
752 extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
753 int x, int y, int w, int h) {
754 if (handle == nullptr) {
755 LOGE("Invalid parameter");
756 return NOTI_EX_ERROR_INVALID_PARAMETER;
759 auto* p = new (std::nothrow) Geometry(x, y, w, h);
761 LOGE("Out-of-memory");
762 return NOTI_EX_ERROR_OUT_OF_MEMORY;
767 return NOTI_EX_ERROR_NONE;
770 extern "C" EXPORT_API int noti_ex_geometry_destroy(noti_ex_geometry_h handle) {
771 if (handle == nullptr) {
772 LOGE("Invalid parameter");
773 return NOTI_EX_ERROR_INVALID_PARAMETER;
776 Geometry* p = static_cast<Geometry*>(handle);
779 return NOTI_EX_ERROR_NONE;
782 extern "C" EXPORT_API int noti_ex_geometry_get_x(noti_ex_geometry_h handle,
784 if (handle == nullptr || val == nullptr) {
785 LOGE("Invalid parameter");
786 return NOTI_EX_ERROR_INVALID_PARAMETER;
789 Geometry* p = static_cast<Geometry*>(handle);
792 return NOTI_EX_ERROR_NONE;
795 extern "C" EXPORT_API int noti_ex_geometry_get_y(noti_ex_geometry_h handle,
797 if (handle == nullptr || val == nullptr) {
798 LOGE("Invalid parameter");
799 return NOTI_EX_ERROR_INVALID_PARAMETER;
802 Geometry* p = static_cast<Geometry*>(handle);
805 return NOTI_EX_ERROR_NONE;
808 extern "C" EXPORT_API int noti_ex_geometry_get_width(noti_ex_geometry_h handle,
810 if (handle == nullptr || val == nullptr) {
811 LOGE("Invalid parameter");
812 return NOTI_EX_ERROR_INVALID_PARAMETER;
815 Geometry* p = static_cast<Geometry*>(handle);
816 *val = p->GetWidth();
818 return NOTI_EX_ERROR_NONE;
821 extern "C" EXPORT_API int noti_ex_geometry_get_height(noti_ex_geometry_h handle,
823 if (handle == nullptr || val == nullptr) {
824 LOGE("Invalid parameter");
825 return NOTI_EX_ERROR_INVALID_PARAMETER;
828 Geometry* p = static_cast<Geometry*>(handle);
829 *val = p->GetHeight();
831 return NOTI_EX_ERROR_NONE;
834 extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
835 noti_ex_color_h color,
836 noti_ex_padding_h padding,
837 noti_ex_geometry_h geometry) {
838 if (handle == nullptr) {
839 LOGE("Invalid parameter");
840 return NOTI_EX_ERROR_INVALID_PARAMETER;
843 Color* color_ = static_cast<Color*>(color);
844 Padding* padding_ = static_cast<Padding*>(padding);
845 Geometry* geo_ = static_cast<Geometry*>(geometry);
847 auto* p = new (std::nothrow) Style(*color_, *padding_, *geo_);
849 LOGE("Out-of-memory");
850 return NOTI_EX_ERROR_OUT_OF_MEMORY;
855 return NOTI_EX_ERROR_NONE;
858 extern "C" EXPORT_API int noti_ex_style_destroy(noti_ex_style_h handle) {
859 if (handle == nullptr) {
860 LOGE("Invalid parameter");
861 return NOTI_EX_ERROR_INVALID_PARAMETER;
864 Style* p = static_cast<Style*>(handle);
867 return NOTI_EX_ERROR_NONE;
870 extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
871 noti_ex_padding_h *padding) {
872 if (handle == nullptr || padding == nullptr) {
873 LOGE("Invalid parameter");
874 return NOTI_EX_ERROR_INVALID_PARAMETER;
877 Style* p = static_cast<Style*>(handle);
878 Padding* padding_ = new (std::nothrow) Padding(p->GetPadding());
879 if (padding_ == nullptr) {
880 LOGE("Out-of-memory");
881 return NOTI_EX_ERROR_OUT_OF_MEMORY;
886 return NOTI_EX_ERROR_NONE;
889 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
890 noti_ex_color_h *color) {
891 if (handle == nullptr || color == nullptr) {
892 LOGE("Invalid parameter");
893 return NOTI_EX_ERROR_INVALID_PARAMETER;
896 Style* p = static_cast<Style*>(handle);
897 Color* color_ = new (std::nothrow) Color(p->GetColor());
898 if (color_ == nullptr) {
899 LOGE("Out-of-memory");
900 return NOTI_EX_ERROR_OUT_OF_MEMORY;
905 return NOTI_EX_ERROR_NONE;
908 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
909 noti_ex_geometry_h *geometry) {
910 if (handle == nullptr || geometry == nullptr) {
911 LOGE("Invalid parameter");
912 return NOTI_EX_ERROR_INVALID_PARAMETER;
915 Style* p = static_cast<Style*>(handle);
916 Geometry* geo_ = new (std::nothrow) Geometry(p->GetGeometry());
917 if (geo_ == nullptr) {
918 LOGE("Out-of-memory");
919 return NOTI_EX_ERROR_OUT_OF_MEMORY;
924 return NOTI_EX_ERROR_NONE;
927 extern "C" EXPORT_API int noti_ex_led_info_create(noti_ex_led_info_h *handle,
928 noti_ex_color_h color) {
929 if (handle == nullptr) {
930 LOGE("Invalid parameter");
931 return NOTI_EX_ERROR_INVALID_PARAMETER;
934 Color* color_ = static_cast<Color*>(color);
935 auto* p = new (std::nothrow) LEDInfo(*color_);
937 LOGE("Out-of-memory");
938 return NOTI_EX_ERROR_OUT_OF_MEMORY;
943 return NOTI_EX_ERROR_NONE;
946 extern "C" EXPORT_API int noti_ex_led_info_destroy(noti_ex_led_info_h handle) {
947 if (handle == nullptr) {
948 LOGE("Invalid parameter");
949 return NOTI_EX_ERROR_INVALID_PARAMETER;
952 LEDInfo* p = static_cast<LEDInfo*>(handle);
955 return NOTI_EX_ERROR_NONE;
958 extern "C" EXPORT_API int noti_ex_led_info_set_on_period(
959 noti_ex_led_info_h handle, int ms) {
960 if (handle == nullptr) {
961 LOGE("Invalid parameter");
962 return NOTI_EX_ERROR_INVALID_PARAMETER;
965 LEDInfo* p = static_cast<LEDInfo*>(handle);
968 return NOTI_EX_ERROR_NONE;
971 extern "C" EXPORT_API int noti_ex_led_info_get_on_period(
972 noti_ex_led_info_h handle, int *ms) {
973 if (handle == nullptr || ms == nullptr) {
974 LOGE("Invalid parameter");
975 return NOTI_EX_ERROR_INVALID_PARAMETER;
978 LEDInfo* p = static_cast<LEDInfo*>(handle);
979 *ms = p->GetOnPeriod();
981 return NOTI_EX_ERROR_NONE;
984 extern "C" EXPORT_API int noti_ex_led_info_set_off_period(
985 noti_ex_led_info_h handle, int ms) {
986 if (handle == nullptr) {
987 LOGE("Invalid parameter");
988 return NOTI_EX_ERROR_INVALID_PARAMETER;
991 LEDInfo* p = static_cast<LEDInfo*>(handle);
994 return NOTI_EX_ERROR_NONE;
997 extern "C" EXPORT_API int noti_ex_led_info_get_off_period(
998 noti_ex_led_info_h handle, int *ms) {
999 if (handle == nullptr) {
1000 LOGE("Invalid parameter");
1001 return NOTI_EX_ERROR_INVALID_PARAMETER;
1004 LEDInfo* p = static_cast<LEDInfo*>(handle);
1005 *ms = p->GetOffPeriod();
1007 return NOTI_EX_ERROR_NONE;
1010 extern "C" EXPORT_API int noti_ex_led_info_get_color(
1011 noti_ex_led_info_h handle, noti_ex_color_h *color) {
1012 if (handle == nullptr) {
1013 LOGE("Invalid parameter");
1014 return NOTI_EX_ERROR_INVALID_PARAMETER;
1017 LEDInfo* p = static_cast<LEDInfo*>(handle);
1018 Color* color_ = new (std::nothrow) Color(p->GetColor());
1019 if (color_ == nullptr) {
1020 LOGE("Out-of-memory");
1021 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1026 return NOTI_EX_ERROR_NONE;
1029 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
1030 if (handle == nullptr) {
1031 LOGE("Invalid parameter");
1032 return NOTI_EX_ERROR_INVALID_PARAMETER;
1035 AbstractAction* p = static_cast<AbstractAction*>(handle);
1036 p->~AbstractAction();
1038 return NOTI_EX_ERROR_NONE;
1041 extern "C" EXPORT_API int noti_ex_action_get_type(noti_ex_action_h handle,
1043 if (handle == nullptr || type == nullptr) {
1044 LOGE("Invalid parameter");
1045 return NOTI_EX_ERROR_INVALID_PARAMETER;
1048 AbstractAction* p = static_cast<AbstractAction*>(handle);
1049 *type = p->GetType();
1051 return NOTI_EX_ERROR_NONE;
1054 extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
1056 if (handle == nullptr || local == nullptr) {
1057 LOGE("Invalid parameter");
1058 return NOTI_EX_ERROR_INVALID_PARAMETER;
1061 AbstractAction* p = static_cast<AbstractAction*>(handle);
1062 *local = p->IsLocal();
1064 return NOTI_EX_ERROR_NONE;
1067 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
1068 noti_ex_item_h item) {
1069 if (handle == nullptr || item==nullptr) {
1070 LOGE("Invalid parameter");
1071 return NOTI_EX_ERROR_INVALID_PARAMETER;
1074 AbstractAction* p = static_cast<AbstractAction*>(handle);
1075 AbstractItem* item_ = static_cast<AbstractItem*>(item);
1076 p->Execute(static_cast<std::shared_ptr<AbstractItem>>(item_));
1078 return NOTI_EX_ERROR_NONE;
1081 extern "C" EXPORT_API int noti_ex_action_get_extra(noti_ex_action_h handle,
1083 if (handle == nullptr || extra == nullptr) {
1084 LOGE("Invalid parameter");
1085 return NOTI_EX_ERROR_INVALID_PARAMETER;
1088 AbstractAction* p = static_cast<AbstractAction*>(handle);
1089 if (!p->GetExtra().empty()) {
1090 *extra = strdup(p->GetExtra().c_str());
1091 if (*extra == nullptr) {
1092 LOGE("Out-of-memory");
1093 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1097 return NOTI_EX_ERROR_NONE;
1100 extern "C" EXPORT_API int noti_ex_item_info_get_hide_time(
1101 noti_ex_item_info_h handle, int *hide_time) {
1105 extern "C" EXPORT_API int noti_ex_item_info_set_hide_time(
1106 noti_ex_item_info_h handle, int hide_time) {
1110 extern "C" EXPORT_API int noti_ex_item_info_get_delete_time(
1111 noti_ex_item_info_h handle, int *delete_time) {
1115 extern "C" EXPORT_API int noti_ex_item_info_set_delete_time(
1116 noti_ex_item_info_h handle, int delete_time) {
1120 extern "C" EXPORT_API int noti_ex_item_info_get_time(
1121 noti_ex_item_info_h handle, time_t *time) {
1125 extern "C" EXPORT_API int noti_ex_item_destroy(noti_ex_item_h handle) {
1129 extern "C" EXPORT_API int noti_ex_item_find_by_id(noti_ex_item_h handle,
1130 const char *id, noti_ex_item_h *item) {
1134 extern "C" EXPORT_API int noti_ex_item_get_type(noti_ex_item_h handle,
1139 extern "C" EXPORT_API int noti_ex_item_get_shared_path(noti_ex_item_h handle,
1140 char ***path, int *count) {
1144 extern "C" EXPORT_API int noti_ex_item_get_id(noti_ex_item_h handle,
1149 extern "C" EXPORT_API int noti_ex_item_set_id(noti_ex_item_h handle,
1154 extern "C" EXPORT_API int noti_ex_item_get_action(noti_ex_item_h handle,
1155 noti_ex_action_h *action) {
1159 extern "C" EXPORT_API int noti_ex_item_set_action(noti_ex_item_h handle,
1160 noti_ex_action_h action) {
1164 extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
1165 noti_ex_style_h *style) {
1169 extern "C" EXPORT_API int noti_ex_item_set_style(noti_ex_item_h handle,
1170 noti_ex_style_h style) {
1174 extern "C" EXPORT_API int noti_ex_item_set_visible(noti_ex_item_h handle,
1179 extern "C" EXPORT_API int noti_ex_item_get_visible(noti_ex_item_h handle,
1184 extern "C" EXPORT_API int noti_ex_item_set_enable(noti_ex_item_h handle,
1189 extern "C" EXPORT_API int noti_ex_item_get_enable(noti_ex_item_h handle,
1194 extern "C" EXPORT_API int noti_ex_item_add_receiver(noti_ex_item_h handle,
1195 const char *receiver_group) {
1199 extern "C" EXPORT_API int noti_ex_item_remove_receiver(noti_ex_item_h handle,
1200 const char *receiver_group) {
1204 extern "C" EXPORT_API int noti_ex_item_get_receiver_list(noti_ex_item_h handle,
1205 char ***list, int *count) {
1209 extern "C" EXPORT_API int noti_ex_item_set_policy(noti_ex_item_h handle,
1214 extern "C" EXPORT_API int noti_ex_item_get_policy(noti_ex_item_h handle,
1219 extern "C" EXPORT_API int noti_ex_item_get_channel(noti_ex_item_h handle,
1224 extern "C" EXPORT_API int noti_ex_item_set_channel(noti_ex_item_h handle,
1225 const char *channel) {
1229 extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
1230 noti_ex_led_info_h led) {
1234 extern "C" EXPORT_API int noti_ex_item_get_led_info(noti_ex_item_h handle,
1235 noti_ex_led_info_h *led) {
1239 extern "C" EXPORT_API int noti_ex_item_set_sound_path(noti_ex_item_h handle,
1244 extern "C" EXPORT_API int noti_ex_item_set_vibration_path(noti_ex_item_h handle,
1249 extern "C" EXPORT_API int noti_ex_item_get_sound_path(noti_ex_item_h handle,
1254 extern "C" EXPORT_API int noti_ex_item_get_vibration_path(noti_ex_item_h handle,
1259 extern "C" EXPORT_API int noti_ex_item_get_info(noti_ex_item_h handle,
1260 noti_ex_item_info_h *info) {
1264 extern "C" EXPORT_API int noti_ex_item_get_sender_app_id(noti_ex_item_h handle,
1269 extern "C" EXPORT_API int noti_ex_item_set_sender_app_id(noti_ex_item_h handle,
1274 extern "C" EXPORT_API int noti_ex_item_get_tag(noti_ex_item_h handle,
1279 extern "C" EXPORT_API int noti_ex_item_set_tag(noti_ex_item_h handle,
1284 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
1285 const char *receiver_group, noti_ex_manager_events_s event_callbacks,
1290 extern "C" EXPORT_API int noti_ex_manager_deatroy(noti_ex_manager_h handle) {
1294 extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
1295 noti_ex_item_h **items, int *count) {
1299 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
1300 noti_ex_item_h noti, int *request_id) {
1304 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
1305 noti_ex_item_h noti, int *request_id) {
1309 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
1314 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
1315 noti_ex_item_h noti, int *request_id) {
1319 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
1320 noti_ex_manager_h handle, const char *root_id, noti_ex_item_h *item) {
1324 extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
1325 noti_ex_event_info_h info, noti_ex_error_e error, int *request_id) {
1329 extern "C" EXPORT_API int noti_ex_manager_get_count(noti_ex_manager_h handle,
1334 extern "C" EXPORT_API int noti_ex_item_progress_create(noti_ex_item_h *handle,
1335 const char *id, float min, float current, float max) {
1338 if (handle == nullptr) {
1339 LOGE("Invalid parameter");
1340 return NOTI_EX_ERROR_INVALID_PARAMETER;
1344 p = new (std::nothrow) ProgressItem(id, min, current, max);
1346 p = new (std::nothrow) ProgressItem(min, current, max);
1349 LOGE("Out-of-memory");
1350 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1355 return NOTI_EX_ERROR_NONE;
1358 extern "C" EXPORT_API int noti_ex_item_progress_get_current(
1359 noti_ex_item_h handle, float *current) {
1360 if (handle == nullptr || current == nullptr) {
1361 LOGE("Invalid parameter");
1362 return NOTI_EX_ERROR_INVALID_PARAMETER;
1365 ProgressItem* p = static_cast<ProgressItem*>(handle);
1366 *current = p->GetCurrent();
1368 return NOTI_EX_ERROR_NONE;
1371 extern "C" EXPORT_API int noti_ex_item_progress_set_current(
1372 noti_ex_item_h handle, float current) {
1373 if (handle == nullptr) {
1374 LOGE("Invalid parameter");
1375 return NOTI_EX_ERROR_INVALID_PARAMETER;
1378 ProgressItem* p = static_cast<ProgressItem*>(handle);
1379 p->SetCurrent(current);
1381 return NOTI_EX_ERROR_NONE;
1384 extern "C" EXPORT_API int noti_ex_item_progress_get_min(noti_ex_item_h handle,
1386 if (handle == nullptr || min == nullptr) {
1387 LOGE("Invalid parameter");
1388 return NOTI_EX_ERROR_INVALID_PARAMETER;
1391 ProgressItem* p = static_cast<ProgressItem*>(handle);
1394 return NOTI_EX_ERROR_NONE;
1397 extern "C" EXPORT_API int noti_ex_item_progress_get_max(noti_ex_item_h handle,
1399 if (handle == nullptr || max == nullptr) {
1400 LOGE("Invalid parameter");
1401 return NOTI_EX_ERROR_INVALID_PARAMETER;
1404 ProgressItem* p = static_cast<ProgressItem*>(handle);
1407 return NOTI_EX_ERROR_NONE;
1410 extern "C" EXPORT_API int noti_ex_reporter_create(noti_ex_reporter_h *handle,
1411 noti_ex_reporter_events_s event_callbacks, void *data) {
1412 return NOTI_EX_ERROR_NONE;
1415 extern "C" EXPORT_API int noti_ex_reporter_destroy(noti_ex_reporter_h handle) {
1416 return NOTI_EX_ERROR_NONE;
1419 extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
1420 noti_ex_event_info_h info, noti_ex_error_e error, int *request_id) {
1424 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
1425 noti_ex_item_h noti, int *request_id) {
1429 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
1430 noti_ex_item_h *noti_list, int count, int *request_id) {
1434 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
1435 noti_ex_item_h noti, int *request_id) {
1439 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
1440 noti_ex_item_h noti, int *request_id) {
1444 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
1445 noti_ex_reporter_h handle, int *request_id) {
1449 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
1450 noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
1454 extern "C" EXPORT_API int noti_ex_item_text_create(noti_ex_item_h *handle,
1455 const char *id, const char *text, const char *hyper_link) {
1456 if (handle == nullptr) {
1457 LOGE("Invalid parameter");
1458 return NOTI_EX_ERROR_INVALID_PARAMETER;
1461 auto* p = new (std::nothrow) TextItem(id, std::string(text),
1462 std::string(hyper_link));
1464 LOGE("Out-of-memory");
1465 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1470 return NOTI_EX_ERROR_NONE;
1473 extern "C" EXPORT_API int noti_ex_item_text_set_contents(noti_ex_item_h handle,
1474 const char *contents) {
1475 if (handle == nullptr) {
1476 LOGE("Invalid parameter");
1477 return NOTI_EX_ERROR_INVALID_PARAMETER;
1480 TextItem* p = static_cast<TextItem*>(handle);
1481 p->SetContents(std::string(contents));
1483 return NOTI_EX_ERROR_NONE;
1486 extern "C" EXPORT_API int noti_ex_item_text_get_contents(noti_ex_item_h handle,
1488 if (handle == nullptr || contents == nullptr) {
1489 LOGE("Invalid parameter");
1490 return NOTI_EX_ERROR_INVALID_PARAMETER;
1493 TextItem* p = static_cast<TextItem*>(handle);
1494 if (!p->GetContents().empty()) {
1495 *contents = strdup(p->GetContents().c_str());
1496 if (*contents == nullptr) {
1497 LOGE("Out-of-memory");
1498 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1502 return NOTI_EX_ERROR_NONE;
1505 extern "C" EXPORT_API int noti_ex_item_text_get_hyper_link(
1506 noti_ex_item_h handle, char **hyper_link) {
1507 if (handle == nullptr || hyper_link == nullptr) {
1508 LOGE("Invalid parameter");
1509 return NOTI_EX_ERROR_INVALID_PARAMETER;
1512 TextItem* p = static_cast<TextItem*>(handle);
1513 if (!p->GetHyperLink().empty()) {
1514 *hyper_link = strdup(p->GetHyperLink().c_str());
1515 if (*hyper_link == nullptr) {
1516 LOGE("Out-of-memory");
1517 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1521 return NOTI_EX_ERROR_NONE;
1524 extern "C" EXPORT_API int noti_ex_item_time_create(noti_ex_item_h *handle,
1525 const char *id, time_t time) {
1528 if (handle == nullptr) {
1529 LOGE("Invalid parameter");
1530 return NOTI_EX_ERROR_INVALID_PARAMETER;
1535 p = new (std::nothrow) TimeItem(id, time);
1537 p = new (std::nothrow) TimeItem(time);
1539 p = new (std::nothrow) TimeItem();
1543 LOGE("Out-of-memory");
1544 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1549 return NOTI_EX_ERROR_NONE;
1552 extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
1554 if (handle == nullptr || time == nullptr) {
1555 LOGE("Invalid parameter");
1556 return NOTI_EX_ERROR_INVALID_PARAMETER;
1559 TimeItem*p = static_cast<TimeItem*>(handle);
1560 *time = p->GetTime();
1562 return NOTI_EX_ERROR_NONE;
1565 extern "C" EXPORT_API int noti_ex_action_visibility_create(
1566 noti_ex_action_h *handle, const char *extra) {
1567 if (handle == nullptr) {
1568 LOGE("Invalid parameter");
1569 return NOTI_EX_ERROR_INVALID_PARAMETER;
1572 auto* p = new (std::nothrow) VisibilityAction(extra);
1574 LOGE("Out-of-memory");
1575 return NOTI_EX_ERROR_OUT_OF_MEMORY;
1580 return NOTI_EX_ERROR_NONE;
1583 extern "C" EXPORT_API int noti_ex_action_visibility_set(noti_ex_action_h handle,
1584 const char *id, bool visible) {
1585 if (handle == nullptr || id == nullptr) {
1586 LOGE("Invalid parameter");
1587 return NOTI_EX_ERROR_INVALID_PARAMETER;
1590 VisibilityAction* p = static_cast<VisibilityAction*>(handle);
1591 p->SetVisibility(id, visible);