this should not have been committed as-is, and I'm very disappointed at the lack of testing here.
static Notification_Data *n_data = NULL;
static void
+_notification_free(E_Notification_Notify *notify)
+{
+ EINA_SAFETY_ON_NULL_RETURN(notify);
+ eina_stringshare_del(notify->app_name);
+ eina_stringshare_del(notify->body);
+ eina_stringshare_del(notify->icon.icon);
+ if (notify->icon.icon_path)
+ eina_stringshare_del(notify->icon.icon_path);
+ eina_stringshare_del(notify->sumary);
+ if (notify->icon.raw.data)
+ free(notify->icon.raw.data);
+ free(notify);
+}
+
+static void
hints_dict_iter(void *data, const void *key, Eldbus_Message_Iter *var)
{
E_Notification_Notify *n = data;
if (!n_data->notify_cb)
return NULL;
- n = calloc(1, sizeof(E_Notification_Notify));
- EINA_SAFETY_ON_NULL_RETURN_VAL(n, NULL);
+ n = E_OBJECT_ALLOC(E_Notification_Notify, E_NOTIFICATION_TYPE, _notification_free);
if (!eldbus_message_arguments_get(msg, "susssasa{sv}i", &n->app_name,
&n->replaces_id, &n->icon.icon, &n->sumary,
&n->timeout))
{
ERR("Reading message.");
- free(n);
+ e_object_del(E_OBJECT(n));
return NULL;
}
eldbus_message_iter_dict_iterate(hints_iter, "sv", hints_dict_iter, n);
n->sumary = eina_stringshare_add(n->sumary);
n->body = eina_stringshare_add(n->body);
+ e_object_ref(E_OBJECT(n));
n->id = n_data->notify_cb(n_data->data, n);
reply = eldbus_message_method_return_new(msg);
eldbus_message_arguments_append(reply, "u", n->id);
+ e_object_unref(E_OBJECT(n));
return reply;
}
}
EAPI void
-e_notification_notify_free(E_Notification_Notify *notify)
-{
- EINA_SAFETY_ON_NULL_RETURN(notify);
- eina_stringshare_del(notify->app_name);
- eina_stringshare_del(notify->body);
- eina_stringshare_del(notify->icon.icon);
- if (notify->icon.icon_path)
- eina_stringshare_del(notify->icon.icon_path);
- eina_stringshare_del(notify->sumary);
- if (notify->icon.raw.data)
- free(notify->icon.raw.data);
- free(notify);
-}
-
-EAPI void
e_notification_notify_close(E_Notification_Notify *notify, E_Notification_Notify_Closed_Reason reason)
{
EINA_SAFETY_ON_NULL_RETURN(n_data);
+#ifndef E_TYPEDEFS
+
#ifndef _E_NOTIFICATION_H
#define _E_NOTIFICATION_H
-#include <Eldbus.h>
-#include <Eina.h>
+#define E_NOTIFICATION_TYPE 0x12342166
typedef enum _E_Notification_Notify_Urgency
{
typedef struct _E_Notification_Notify
{
+ E_Object e_obj_inherit;
unsigned int id;
const char *app_name;
unsigned replaces_id;
*/
EAPI void e_notification_server_unregister(void);
-EAPI void e_notification_notify_free(E_Notification_Notify *notify);
EAPI void e_notification_notify_close(E_Notification_Notify *notify, E_Notification_Notify_Closed_Reason reason);
EAPI Evas_Object *e_notification_notify_raw_image_get(E_Notification_Notify *notify, Evas *evas);
EAPI Eina_Bool e_notification_client_send(E_Notification_Notify *notify, E_Notification_Client_Send_Cb cb, const void *data);
#endif
+
+#endif
if (n->replaces_id && (nwin = _e_mod_notify_find(n->replaces_id)))
{
if (nwin->notify)
- e_notification_notify_free(nwin->notify);
+ e_object_del(E_OBJECT(nwin->notify));
nwin->notify = n;
nwin->id = _notify_id;
_e_mod_notify_refresh(nwin);
nwin->win = NULL;
e_notification_notify_close(nwin->notify,
E_NOTIFICATION_NOTIFY_CLOSED_REASON_REQUESTED);
- e_notification_notify_free(nwin->notify);
+ e_object_del(E_OBJECT(nwin->notify));
_nwins = eina_list_remove(_nwins, nwin);
E_FREE(nwin);
}
_notification_notify(E_Notification_Notify *n)
{
unsigned int new_id;
- int popuped;
if (e_desklock_state_get()) return 0;
notification_cfg->next_id++;
new_id = notification_cfg->next_id;
- popuped = notification_popup_notify(n, new_id);
- if (!popuped)
- {
- n->urgency = 4;
- notification_popup_notify(n, new_id);
- }
+ notification_popup_notify(n, new_id);
return new_id;
}
};
-int notification_popup_notify(E_Notification_Notify *n, unsigned int id);
+void notification_popup_notify(E_Notification_Notify *n, unsigned int id);
void notification_popup_shutdown(void);
void notification_popup_close(unsigned int id);
return EINA_FALSE;
}
-int
+void
notification_popup_notify(E_Notification_Notify *n,
unsigned int id)
{
switch (n->urgency)
{
case E_NOTIFICATION_NOTIFY_URGENCY_LOW:
- if (!notification_cfg->show_low) return 0;
+ if (!notification_cfg->show_low) return;
break;
case E_NOTIFICATION_NOTIFY_URGENCY_NORMAL:
- if (!notification_cfg->show_normal) return 0;
+ if (!notification_cfg->show_normal) return;
break;
case E_NOTIFICATION_NOTIFY_URGENCY_CRITICAL:
- if (!notification_cfg->show_critical) return 0;
+ if (!notification_cfg->show_critical) return;
break;
default:
break;
if (n->replaces_id && (popup = _notification_popup_find(n->replaces_id)))
{
if (popup->notif)
- e_notification_notify_free(popup->notif);
+ e_object_del(E_OBJECT(popup->notif));
popup->notif = n;
popup->id = id;
popup = _notification_popup_new(n, id);
if (!popup)
{
- e_notification_notify_free(n);
+ e_object_del(E_OBJECT(n));
ERR("Error creating popup");
- return 0;
+ return;
}
notification_cfg->popups = eina_list_append(notification_cfg->popups, popup);
edje_object_signal_emit(popup->theme, "notification,new", "notification");
if (n->timeout > 0)
popup->timer = ecore_timer_add(n->timeout, (Ecore_Task_Cb)_notification_timer_cb, popup);
-
- return 1;
}
void
if (popup->notif)
{
e_notification_notify_close(popup->notif, reason);
- e_notification_notify_free(popup->notif);
+ e_object_del(E_OBJECT(popup->notif));
}
popup->notif = NULL;
if (popup->pending) return;