[maemo-commits] [maemo-commits] r9809 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Feb 13 10:28:57 EET 2007
- Previous message: [maemo-commits] r9808 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop
- Next message: [maemo-commits] r9810 - in projects/haf/branches/hildon-libs/hildon-1: . examples src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2007-02-13 10:28:55 +0200 (Tue, 13 Feb 2007) New Revision: 9809 Added: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.c projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.h projects/haf/branches/maemo-af-desktop/hildon-desktop/src/notification-manager.xml Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog projects/haf/branches/maemo-af-desktop/hildon-desktop/src/Makefile.am projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c Log: 2007-02-13 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-desktop.c, src/hd-notification-manager.[ch], src/notification-manager.xml, src/Makefile.am: add Desktop Notification compliant notification service to HDDesktop. Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2007-02-12 13:42:26 UTC (rev 9808) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2007-02-13 08:28:55 UTC (rev 9809) @@ -1,3 +1,9 @@ +2007-02-13 Lucas Rocha <lucas.rocha at nokia.com> + + * src/hd-desktop.c, src/hd-notification-manager.[ch], + src/notification-manager.xml, src/Makefile.am: add Desktop + Notification compliant notification service to HDDesktop. + 2007-02-12 Moises Martinez <moises.martinez at nokia.com> * libhildondesktop/hildon-desktop-panel.c: Refactored to use Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/Makefile.am =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/Makefile.am 2007-02-12 13:42:26 UTC (rev 9808) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/Makefile.am 2007-02-13 08:28:55 UTC (rev 9809) @@ -13,6 +13,7 @@ $(OSSO_HELP_CFLAGS) \ $(GCONF_CFLAGS) \ $(LIBXML_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ -I$(top_srcdir) \ -DLOCALEDIR=\"$(localedir)\" \ -DDATADIR=\"$(datadir)\" \ @@ -31,7 +32,8 @@ $(HILDON_FM_LIBS) \ $(OSSO_LIBS) \ $(GCONF_LIBS) \ - $(OSSO_HELP_LIBS) + $(OSSO_HELP_LIBS) \ + $(DBUS_GLIB_LIBS) hildon_desktop_LDADD = \ $(top_srcdir)/libhildondesktop/libhildondesktop.la \ @@ -77,7 +79,13 @@ hn-others-button.c \ hn-others-button.h +BUILT_SOURCES = hd-notification-service.h + +hd-notification-service.h: notification-manager.xml + dbus-binding-tool --prefix=hd_notification_service --mode=glib-server --output=hd-notification-service.h $< + hildon_desktop_SOURCES = \ + $(BUILT_SOURCES) \ $(PLUGIN_MANAGER_SOURCES) \ $(HOME_SOURCES) \ $(APP_SWITCHER_SOURCES) \ @@ -90,7 +98,11 @@ hd-panel-window.h \ hd-panel-window-dialog.c \ hd-panel-window-dialog.h \ + hd-notification-manager.c \ + hd-notification-manager.h \ hd-config.h \ main.c -CLEANFILES = *~ +EXTRA_DIST = notification-manager.xml + +CLEANFILES = *~ $(BUILT_SOURCES) Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c 2007-02-12 13:42:26 UTC (rev 9808) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c 2007-02-13 08:28:55 UTC (rev 9809) @@ -43,6 +43,7 @@ #include "hd-select-plugins-dialog.h" #include "hd-config.h" #include "hd-plugin-manager.h" +#include "hd-notification-manager.h" #include "hd-home-window.h" #include "hd-panel-window.h" #include "hd-panel-window-dialog.h" @@ -69,6 +70,7 @@ gchar *config_file; GHashTable *containers; GObject *pm; + GObject *nm; #ifdef HAVE_LIBOSSO osso_context_t *osso_context; #endif @@ -859,6 +861,8 @@ (GDestroyNotify) hd_desktop_free_container_info); desktop->priv->pm = hd_plugin_manager_new (); + + desktop->priv->nm = hd_notification_manager_new (); } static void @@ -889,6 +893,12 @@ priv->pm = NULL; } + if (priv->nm) + { + g_object_unref (priv->nm); + priv->nm = NULL; + } + G_OBJECT_CLASS (hd_desktop_parent_class)->finalize (object); } Added: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.c 2007-02-12 13:42:26 UTC (rev 9808) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.c 2007-02-13 08:28:55 UTC (rev 9809) @@ -0,0 +1,185 @@ +/* + * This file is part of hildon-desktop + * + * Copyright (C) 2006 Nokia Corporation. + * + * Author: Lucas Rocha <lucas.rocha at nokia.com> + * Contact: Karoliina Salminen <karoliina.t.salminen at nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtk.h> +#include <glib.h> +#include <glib-object.h> +#include <dbus/dbus-glib-bindings.h> + +#include <hildon-widgets/hildon-banner.h> + +#include "hd-notification-manager.h" +#include "hd-notification-service.h" + +#define HD_NOTIFICATION_MANAGER_GET_PRIVATE(object) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((object), HD_TYPE_NOTIFICATION_MANAGER, HDNotificationManagerPrivate)) + +G_DEFINE_TYPE (HDNotificationManager, hd_notification_manager, G_TYPE_OBJECT); + +#define HD_NOTIFICATION_MANAGER_DBUS_NAME "org.freedesktop.Notifications" +#define HD_NOTIFICATION_MANAGER_DBUS_PATH "/org/freedesktop/Notifications" + +#define HD_NOTIFICATION_MANAGER_ICON_SIZE 48 + +static void +hd_notification_manager_init (HDNotificationManager *nm) +{ + DBusGConnection *connection; + DBusGProxy *bus_proxy; + GError *error = NULL; + guint request_name_result; + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + + if (error != NULL) + { + g_warning ("Failed to open connection to bus: %s\n", + error->message); + + g_error_free (error); + + return; + } + + bus_proxy = dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + if (!org_freedesktop_DBus_request_name (bus_proxy, + HD_NOTIFICATION_MANAGER_DBUS_NAME, + DBUS_NAME_FLAG_DO_NOT_QUEUE, + &request_name_result, + &error)) + { + g_warning ("Could not register name: %s", error->message); + + g_error_free (error); + + return; + } + + g_object_unref (bus_proxy); + + if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) return; + + dbus_g_object_type_install_info (HD_TYPE_NOTIFICATION_MANAGER, + &dbus_glib_hd_notification_service_object_info); + + dbus_g_connection_register_g_object (connection, + HD_NOTIFICATION_MANAGER_DBUS_PATH, + G_OBJECT (nm)); +} + +static void +hd_notification_manager_class_init (HDNotificationManagerClass *class) +{ +} + +GObject * +hd_notification_manager_new (void) +{ + GObject *nm = g_object_new (HD_TYPE_NOTIFICATION_MANAGER, NULL); + + return nm; +} + +gboolean +hd_notification_manager_notify_handler (HDNotificationManager *nm, + const gchar *app_name, + guint id, + const gchar *icon, + const gchar *summary, + const gchar *body, + gchar **actions, + GHashTable *hints, + gint timeout, + DBusGMethodInvocation *context) +{ + gchar *message = NULL; + + g_return_val_if_fail (summary != NULL, FALSE); + g_return_val_if_fail (body != NULL, FALSE); + + if (summary != NULL && body != NULL) + { + message = g_strdup_printf ("<b>%s</b>\n%s", summary, body); + } + else if (summary != NULL) + { + message = g_strdup (summary); + } + else + { + message = g_strdup (body); + } + + hildon_banner_show_information_with_markup (NULL, icon, message); + + g_free (message); + + return TRUE; +} + +gboolean +hd_notification_manager_get_capabilities (HDNotificationManager *nm, gchar ***caps) +{ + *caps = g_new0(gchar *, 4); + + (*caps)[0] = g_strdup ("body"); + (*caps)[1] = g_strdup ("body-markup"); + (*caps)[2] = g_strdup ("icon-static"); + (*caps)[3] = NULL; + + return TRUE; +} + +gboolean +hd_notification_manager_get_server_info (HDNotificationManager *nm, + gchar **out_name, + gchar **out_vendor, + gchar **out_version, + gchar **out_spec_ver) +{ + *out_name = g_strdup ("Hildon Desktop Notification Manager"); + *out_vendor = g_strdup ("Nokia"); + *out_version = g_strdup (VERSION); + *out_spec_ver = g_strdup ("0.9"); + + return TRUE; +} + +gboolean +hd_notification_manager_close_notification_handler (HDNotificationManager *nm, + guint id, + GError **error) +{ + g_debug ("CALLING CLOSE NOTIFICATION"); + + return TRUE; +} Added: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.h =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.h 2007-02-12 13:42:26 UTC (rev 9808) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-notification-manager.h 2007-02-13 08:28:55 UTC (rev 9809) @@ -0,0 +1,87 @@ +/* + * This file is part of hildon-desktop + * + * Copyright (C) 2006 Nokia Corporation. + * + * Author: Lucas Rocha <lucas.rocha at nokia.com> + * Contact: Karoliina Salminen <karoliina.t.salminen at nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef __HD_NOTIFICATION_MANAGER_H__ +#define __HD_NOTIFICATION_MANAGER_H__ + +#include <gtk/gtk.h> +#include <glib.h> +#include <glib-object.h> +#include <dbus/dbus-glib-bindings.h> + +G_BEGIN_DECLS + +typedef struct _HDNotificationManager HDNotificationManager; +typedef struct _HDNotificationManagerClass HDNotificationManagerClass; +typedef struct _HDNotificationManagerPrivate HDNotificationManagerPrivate; + +#define HD_TYPE_NOTIFICATION_MANAGER (hd_notification_manager_get_type ()) +#define HD_NOTIFICATION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HD_TYPE_NOTIFICATION_MANAGER, HDNotificationManager)) +#define HD_NOTIFICATION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HD_TYPE_NOTIFICATION_MANAGER, HDNotificationManagerClass)) +#define HD_IS_NOTIFICATION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HD_TYPE_NOTIFICATION_MANAGER)) +#define HD_IS_NOTIFICATION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HD_TYPE_NOTIFICATION_MANAGER)) +#define HD_NOTIFICATION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HD_TYPE_NOTIFICATION_MANAGER, HDNotificationManagerClass)) + +struct _HDNotificationManager +{ + GObject gobject; + + HDNotificationManagerPrivate *priv; +}; + +struct _HDNotificationManagerClass +{ + GObjectClass parent_class; +}; + +GType hd_notification_manager_get_type (void); + +GObject *hd_notification_manager_new (void); + +gboolean hd_notification_manager_notify_handler (HDNotificationManager *nm, + const gchar *app_name, + guint id, + const gchar *icon, + const gchar *summary, + const gchar *body, + gchar **actions, + GHashTable *hints, + gint timeout, + DBusGMethodInvocation *context); + +gboolean hd_notification_manager_get_capabilities (HDNotificationManager *nm, + gchar ***caps); + +gboolean hd_notification_manager_get_server_info (HDNotificationManager *nm, + gchar **out_name, + gchar **out_vendor, + gchar **out_version, + gchar **out_spec_ver); + +gboolean hd_notification_manager_close_notification_handler (HDNotificationManager *nm, + guint id, GError **error); + +G_END_DECLS + +#endif /* __HD_NOTIFICATION_MANAGER_H__ */ Added: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/notification-manager.xml =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/notification-manager.xml 2007-02-12 13:42:26 UTC (rev 9808) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/notification-manager.xml 2007-02-13 08:28:55 UTC (rev 9809) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/org/freedesktop/Notifications"> + + <interface name="org.freedesktop.Notifications"> + + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="HDNotificationManager"/> + + <method name="Notify"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="hd_notification_manager_notify_handler"/> + + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + + <arg type="s" name="app_name" direction="in" /> + <arg type="u" name="id" direction="in" /> + <arg type="s" name="icon" direction="in" /> + <arg type="s" name="summary" direction="in" /> + <arg type="s" name="body" direction="in" /> + <arg type="as" name="actions" direction="in" /> + <arg type="a{sv}" name="hints" direction="in" /> + <arg type="i" name="timeout" direction="in" /> + <arg type="u" name="return_id" direction="out" /> + </method> + + <method name="CloseNotification"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="hd_notification_manager_close_notification_handler"/> + + <arg type="u" name="id" direction="in" /> + </method> + + <method name="GetCapabilities"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="hd_notification_manager_get_capabilities"/> + + <arg type="as" name="return_caps" direction="out"/> + </method> + + <method name="GetServerInformation"> + + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="hd_notification_manager_get_server_info"/> + + <arg type="s" name="return_name" direction="out"/> + <arg type="s" name="return_vendor" direction="out"/> + <arg type="s" name="return_version" direction="out"/> + <arg type="s" name="return_spec_version" direction="out"/> + </method> + + </interface> + +</node>
- Previous message: [maemo-commits] r9808 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop
- Next message: [maemo-commits] r9810 - in projects/haf/branches/hildon-libs/hildon-1: . examples src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]