1 // Copyright 2013 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ewk_notification_h
6 #define ewk_notification_h
10 #include "ewk_export.h"
11 #include "ewk_security_origin.h"
17 struct _Ewk_Notification_Permission {
22 typedef struct Ewk_Notification Ewk_Notification;
23 typedef struct _Ewk_Notification_Permission Ewk_Notification_Permission;
24 typedef struct Ewk_Notification_Permission_Request Ewk_Notification_Permission_Request;
25 typedef void (*Ewk_Notification_Show_Callback)(Ewk_Notification*, void*);
26 typedef void (*Ewk_Notification_Cancel_Callback)(uint64_t, void*);
29 * Sets callbacks for notifications handling.
31 * These callbacks will receive all notifications from all webview instances.
32 * @e show_callback is used to display notification UI. Embeder should call
33 * ewk_notification_showed after it displays notification UI. @e cancel_callback
34 * will be called after notification is closed by engine. It's used to notify
35 * embeder that related notification UI should be destroyed.
37 * @param show_callback notification show callback. Can't be NULL
38 * @param cancel_callback notification close callback. Can't be NULL
39 * @param user_data extra data for callback
41 * @return EINA_TRUE on success, EINA_FALSE on failure (i.e. when ewk_init was not called)
43 EXPORT_API Eina_Bool ewk_notification_callbacks_set(Ewk_Notification_Show_Callback show_callback, Ewk_Notification_Cancel_Callback cancel_callback, void* user_data);
46 * Resets notification callbacks to NULL
48 * @return EINA_TRUE on success, EINA_FALSE on failure (i.e. when ewk_init was not called)
50 EXPORT_API Eina_Bool ewk_notification_callbacks_reset();
53 * Get notification icon as Evas_Object
55 * @param ewk_notification pointer to notification data
56 * @param evas canvas where icon object will be added
58 * @return Evas_Object containing icon if successful, @c NULL otherwise.
59 * Caller takes ownership of returned Evas_Object.
61 EXPORT_API Evas_Object* ewk_notification_icon_get(const Ewk_Notification* ewk_notification, Evas* evas);
64 * Save notification icon as PNG image
66 * @param ewk_notification notification data pointer
67 * @param path path where file will be saved
69 * @return EINA_TRUE on success
71 EXPORT_API Eina_Bool ewk_notification_icon_save_as_png(
72 const Ewk_Notification* ewk_notification, const char* path);
75 * Requests for getting body of notification.
77 * @param ewk_notification pointer of notificaion data
79 * @return body of notification
80 * Lifetime only valid as long as @a ewk_notification is valid.
82 EXPORT_API const char* ewk_notification_body_get(const Ewk_Notification* ewk_notification);
85 * Notify that notification is clicked.
87 * @param notification_id identifier of notification
89 * @return EINA_TRUE on success, EINA_FALSE if notification id is invalid
91 EXPORT_API Eina_Bool ewk_notification_clicked(uint64_t notification_id);
94 * Requests for getting icon url of notification.
96 * @param ewk_notification pointer of notification data
98 * @return Always returns NULL - this API is deprecated.
102 EINA_DEPRECATED EXPORT_API const char* ewk_notification_icon_url_get(const Ewk_Notification* ewk_notification);
105 * Requests for getting id of notification.
107 * @param ewk_notification pointer of notification data
109 * @return id of notification
111 EXPORT_API uint64_t ewk_notification_id_get(const Ewk_Notification* ewk_notification);
114 * Requests for setting cached notification permissions.
116 * By calling this notification permission is replaced as passed ewk_notification_permissions.
118 * @param context context object
119 * @param ewk_notification_permissions list of cached permissions(Ewk_Notification_Permission)
121 * @return EINA_TRUE if successful, EINA_FALSE if ewk_init was not called
123 EXPORT_API Eina_Bool ewk_notification_cached_permissions_set(Eina_List *ewk_notification_permissions);
126 * Requests for getting origin of notification permission request.
128 * @param request Ewk_Notification_Permission_Request object to get origin for notification permission request
130 * @return security origin of notification permission request
131 * Lifetime only valid as long as @a ewk_notification is valid.
133 EXPORT_API const Ewk_Security_Origin* ewk_notification_permission_request_origin_get(const Ewk_Notification_Permission_Request* request);
136 * Reply the result about notification permission.
138 * @param request Ewk_Notification_Permission_Request object to get the
139 * infomation about notification permission request.
140 * @param allow result about notification permission
142 * @return EINA_TRUE is successful. EINA_FALSE if reply was already called for
143 * this request or if request is NULL
145 EXPORT_API Eina_Bool ewk_notification_permission_reply(Ewk_Notification_Permission_Request *request, Eina_Bool allow);
148 * Deprecated, use ewk_notification_permission_reply instead.
149 * Sets permission of notification.
151 * @param request Ewk_Notification_Permission_Request object to allow/deny notification permission
152 * request is freed in this function.
153 * @param allowed @c EINA_TRUE if permission is allowed, @c EINA_FALSE if permission is denied
155 * @return EINA_TRUE is successful. EINA_FALSE if reply was already called for
156 * this request or if request is NULL
159 * @see ewk_notification_permission_reply
161 EINA_DEPRECATED EXPORT_API Eina_Bool ewk_notification_permission_request_set(Ewk_Notification_Permission_Request* request, Eina_Bool allowed);
164 * Suspend the operation for permission request.
166 * This suspends the operation for permission request.
167 * This is very useful to decide the policy from the additional UI operation like the popup.
169 * @param request Ewk_Notification_Permission_Request object to suspend notification permission request
171 EXPORT_API Eina_Bool ewk_notification_permission_request_suspend(Ewk_Notification_Permission_Request* request);
174 * Notify that notification policies are removed.
176 * @param context context object
177 * @param origins list of security origins(made by UAs)
179 EXPORT_API Eina_Bool ewk_notification_policies_removed(Eina_List* origins);
182 * Requests for getting security origin of notification.
184 * @param ewk_notification pointer of notification data
186 * @return security origin of notification
187 * Lifetime only valid as long as @a ewk_notification is valid.
189 EXPORT_API const Ewk_Security_Origin* ewk_notification_security_origin_get(const Ewk_Notification* ewk_notification);
192 * Notify that notification is showed.
194 * @param notification_id identifier of notification
196 EXPORT_API Eina_Bool ewk_notification_showed(uint64_t notification_id);
199 * Notify that notification was closed.
201 * @param notification_id identifier of notification
202 * @param by_user informs whether notification was closed by user
203 * action or by some other application logic
205 EXPORT_API Eina_Bool ewk_notification_closed(uint64_t notification_id, Eina_Bool by_user);
208 * Requests for getting title of notification.
210 * @param ewk_notification pointer of notification data
212 * @return title of notification
213 * Lifetime only valid as long as @a ewk_notification is valid.
215 EXPORT_API const char* ewk_notification_title_get(const Ewk_Notification* ewk_notification);
218 * Query if the notification is silent
220 * @param ewk_notification pointer of notification data
222 * @return @c EINA_TRUE if the notification must be silent, @c EINA_FALSE
225 EXPORT_API Eina_Bool ewk_notification_silent_get(const Ewk_Notification* ewk_notification);
230 #endif // ewk_notification_h