#include <wayland-server.h>
#include <tizen-extension-server-protocol.h>
-#include "tizen_notification-server-protocol.h"
typedef struct _Pol_Wayland
{
wl_resource_set_implementation(res, &_e_tizen_policy_interface, cdata, NULL);
}
-static void
-_e_tizen_notification_set_level_cb(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource, uint32_t level)
-{
- E_Pixmap *ep;
- E_Client *ec;
- Notification_Level *nl;
-
- /* get the pixmap from this surface so we can find the client */
- if (!(ep = wl_resource_get_user_data(surface_resource)))
- {
- wl_resource_post_error(surface_resource,
- WL_DISPLAY_ERROR_INVALID_OBJECT,
- "No Pixmap Set On Surface");
- return;
- }
-
- /* make sure it's a wayland pixmap */
- if (e_pixmap_type_get(ep) != E_PIXMAP_TYPE_WL) return;
-
- /* find the client for this pixmap */
- ec = e_pixmap_client_get(ep);
- if (ec)
- {
- /* remove not processed level set */
- nl = eina_hash_find(hash_notification_levels, &surface_resource);
- if (nl) eina_hash_del_by_key(hash_notification_levels, &surface_resource);
-
- e_mod_pol_notification_level_apply(ec, level);
-
- /* Add other error handling code on notification send done. */
- tizen_notification_send_done(resource,
- surface_resource,
- level,
- TIZEN_NOTIFICATION_ERROR_STATE_NONE);
- }
- else
- {
- nl = eina_hash_find(hash_notification_levels, &surface_resource);
- if (!nl)
- {
- nl = E_NEW(Notification_Level, 1);
- EINA_SAFETY_ON_NULL_RETURN(nl);
- eina_hash_add(hash_notification_levels, &surface_resource, nl);
- }
-
- nl->level = level;
- nl->interface = resource;
- nl->surface = surface_resource;
- }
-}
-
-static const struct tizen_notification_interface _e_tizen_notification_interface =
-{
- _e_tizen_notification_set_level_cb
-};
-
-static Eina_Bool
-_e_tizen_notification_levels_remove(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
- const void *tp EINA_UNUSED, const void *resource)
-{
- Notification_Level *nl = eina_hash_find(hash_notification_levels, key);
- if (!nl)
- return EINA_TRUE;
-
- if (nl->interface != resource)
- return EINA_TRUE;
-
- eina_hash_del_by_key(hash_notification_levels, key);
-
- return EINA_TRUE;
-}
-
-static void
-_e_tizen_notification_destroy(struct wl_resource *resource)
-{
- if (!resource) return;
-
- eina_hash_foreach(hash_notification_levels,
- (Eina_Hash_Foreach)_e_tizen_notification_levels_remove, resource);
-}
-
-static void
-_e_tizen_notification_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id)
-{
- E_Comp_Data *cdata;
- struct wl_resource *res;
-
- if (!(cdata = data))
- {
- wl_client_post_no_memory(client);
- return;
- }
-
- if (!(res = wl_resource_create(client,
- &tizen_notification_interface,
- version,
- id)))
- {
- ERR("Could not create tizen_notification resource: %m");
- wl_client_post_no_memory(client);
- return;
- }
-
- wl_resource_set_implementation(res,
- &_e_tizen_notification_interface,
- cdata,
- _e_tizen_notification_destroy);
-}
-
static void
_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
{
return EINA_FALSE;
}
- if (!wl_global_create(cdata->wl.disp,
- &tizen_notification_interface,
- 1,
- cdata,
- _e_tizen_notification_bind_cb))
- {
- ERR("Could not add tizen_notification to wayland globals: %m");
- return EINA_FALSE;
- }
-
hash_pol_wayland = eina_hash_pointer_new(free);
hash_notification_levels = eina_hash_pointer_new(free);
hash_policy_conformants = eina_hash_pointer_new(free);
e_mod_pol_notification_level_apply(ec, nl->level);
// Add other error handling code on notification send done.
- tizen_notification_send_done(nl->interface,
- nl->surface,
- nl->level,
- TIZEN_NOTIFICATION_ERROR_STATE_NONE);
+ tizen_policy_send_notification_done(nl->interface,
+ nl->surface,
+ nl->level,
+ TIZEN_POLICY_ERROR_STATE_NONE);
eina_hash_del_by_key(hash_notification_levels, &surface);
}
+++ /dev/null
-#include <stdlib.h>
-#include <stdint.h>
-#include "wayland-util.h"
-
-extern const struct wl_interface wl_surface_interface;
-
-static const struct wl_interface *types[] = {
- &wl_surface_interface,
- NULL,
- &wl_surface_interface,
- NULL,
- NULL,
-};
-
-static const struct wl_message tizen_notification_requests[] = {
- { "set_level", "oi", types + 0 },
-};
-
-static const struct wl_message tizen_notification_events[] = {
- { "done", "oiu", types + 2 },
-};
-
-WL_EXPORT const struct wl_interface tizen_notification_interface = {
- "tizen_notification", 1,
- 1, tizen_notification_requests,
- 1, tizen_notification_events,
-};
-
+++ /dev/null
-#ifndef TIZEN_NOTIFICATION_SERVER_PROTOCOL_H
-#define TIZEN_NOTIFICATION_SERVER_PROTOCOL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-#include <stddef.h>
-#include "wayland-server.h"
-
-struct wl_client;
-struct wl_resource;
-
-struct tizen_notification;
-
-extern const struct wl_interface tizen_notification_interface;
-
-#ifndef TIZEN_NOTIFICATION_LEVEL_ENUM
-#define TIZEN_NOTIFICATION_LEVEL_ENUM
-enum tizen_notification_level {
- TIZEN_NOTIFICATION_LEVEL_1 = 0,
- TIZEN_NOTIFICATION_LEVEL_2 = 1,
- TIZEN_NOTIFICATION_LEVEL_3 = 2,
- TIZEN_NOTIFICATION_LEVEL_NONE = -1,
- TIZEN_NOTIFICATION_LEVEL_DEFAULT = 10,
- TIZEN_NOTIFICATION_LEVEL_MEDIUM = 20,
- TIZEN_NOTIFICATION_LEVEL_HIGH = 30,
- TIZEN_NOTIFICATION_LEVEL_TOP = 40,
-};
-#endif /* TIZEN_NOTIFICATION_LEVEL_ENUM */
-
-#ifndef TIZEN_NOTIFICATION_ERROR_STATE_ENUM
-#define TIZEN_NOTIFICATION_ERROR_STATE_ENUM
-enum tizen_notification_error_state {
- TIZEN_NOTIFICATION_ERROR_STATE_NONE = 0,
- TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED = 1,
-};
-#endif /* TIZEN_NOTIFICATION_ERROR_STATE_ENUM */
-
-struct tizen_notification_interface {
- /**
- * set_level - (none)
- * @surface: (none)
- * @level: (none)
- */
- void (*set_level)(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *surface,
- int32_t level);
-};
-
-#define TIZEN_NOTIFICATION_DONE 0
-
-#define TIZEN_NOTIFICATION_DONE_SINCE_VERSION 1
-
-static inline void
-tizen_notification_send_done(struct wl_resource *resource_, struct wl_resource *surface, int32_t level, uint32_t error_state)
-{
- wl_resource_post_event(resource_, TIZEN_NOTIFICATION_DONE, surface, level, error_state);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-<protocol name="tizen_notification">
- <interface name="tizen_notification" version="1">
- <enum name="level">
- <entry name="1" value="0"/>
- <entry name="2" value="1"/>
- <entry name="3" value="2"/>
- <entry name="none" value="-1"/>
- <entry name="default" value="10"/>
- <entry name="medium" value="20"/>
- <entry name="high" value="30"/>
- <entry name="top" value="40"/>
- </enum>
-
- <request name="set_level">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="level" type="int"/>
- </request>
-
- <enum name="error_state">
- <entry name="none" value="0"/>
- <entry name="permission_denied" value="1"/>
- </enum>
-
- <event name="done">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="level" type="int"/>
- <arg name="error_state" type="uint"/>
- </event>
-
- </interface>
-</protocol>