[Galago-commits] r2432 - in trunk/libnotify: . docs libnotify tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Jan 15 17:53:08 PST 2006
Author: chipx86
Date: 2006-01-15 17:53:06 -0800 (Sun, 15 Jan 2006)
New Revision: 2432
Added:
trunk/libnotify/tests/test-server-info.c
Modified:
trunk/libnotify/ChangeLog
trunk/libnotify/docs/notification-spec.xml
trunk/libnotify/libnotify/notify.c
trunk/libnotify/libnotify/notify.h
trunk/libnotify/libnotify/notifynotification.c
trunk/libnotify/tests/
trunk/libnotify/tests/Makefile.am
trunk/libnotify/tests/test-xy.c
Log:
Add back notify_get_server_info() and notify_get_server_caps().
Modified: trunk/libnotify/ChangeLog
===================================================================
--- trunk/libnotify/ChangeLog 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/ChangeLog 2006-01-16 01:53:06 UTC (rev 2432)
@@ -1,3 +1,14 @@
+Sun Jan 15 17:52:39 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * docs/notification-spec.xml:
+ * libnotify/notify.c:
+ * libnotify/notify.h:
+ * libnotify/notifynotification.c:
+ * tests/Makefile.am:
+ A tests/test-server-info.c:
+ * tests/test-xy.c:
+ - Add back notify_get_server_info() and notify_get_server_caps().
+
Thu Jan 12 2006 John (J5) Palmieri <johnp at redhat.com>
* libnotify/notifynotification.c (notify_notification_set_user_data):
Modified: trunk/libnotify/docs/notification-spec.xml
===================================================================
--- trunk/libnotify/docs/notification-spec.xml 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/docs/notification-spec.xml 2006-01-16 01:53:06 UTC (rev 2432)
@@ -1033,11 +1033,13 @@
<paramdef>out STRING <parameter>name</parameter></paramdef>
<paramdef>out STRING <parameter>vendor</parameter></paramdef>
<paramdef>out STRING <parameter>version</parameter></paramdef>
+ <paramdef>out STRING <parameter>spec_version</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This message returns the information on the server. Specifically,
- the server name, vendor, and version number.
+ the server name, vendor, version number, and specification version number
+ supported.
</para>
<table>
<title>GetServerInformation Return Values</title>
@@ -1068,6 +1070,11 @@
<entry>STRING</entry>
<entry>The server's version number.</entry>
</row>
+ <row>
+ <entry><parameter>spec_version</parameter></entry>
+ <entry>STRING</entry>
+ <entry>The supported specification version number.</entry>
+ </row>
</tbody>
</tgroup>
</table>
Modified: trunk/libnotify/libnotify/notify.c
===================================================================
--- trunk/libnotify/libnotify/notify.c 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/libnotify/notify.c 2006-01-16 01:53:06 UTC (rev 2432)
@@ -40,6 +40,8 @@
static gboolean _initted = FALSE;
static gchar *_app_name = NULL;
+static DBusGProxy *_proxy = NULL;
+
#ifdef __GNUC__
# define format_func __attribute__((format(printf, 1, 2)))
#else /* no format string checking with this compiler */
@@ -85,7 +87,7 @@
}
const gchar *
-_notify_get_app_name (void)
+notify_get_app_name (void)
{
return _app_name;
}
@@ -108,3 +110,83 @@
{
return _initted;
}
+
+static DBusGProxy *
+get_proxy(void)
+{
+ DBusGConnection *bus;
+ GError *error = NULL;
+
+ if (_proxy != NULL)
+ return _proxy;
+
+ bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+ if (error != NULL)
+ {
+ g_message("Unable to get session bus: %s", error->message);
+ g_error_free(error);
+ return NULL;
+ }
+
+ _proxy = dbus_g_proxy_new_for_name(bus,
+ NOTIFY_DBUS_NAME,
+ NOTIFY_DBUS_CORE_OBJECT,
+ NOTIFY_DBUS_CORE_INTERFACE);
+ dbus_g_connection_unref(bus);
+
+ return _proxy;
+}
+
+GList *
+notify_get_server_caps(void)
+{
+ GError *error = NULL;
+ char **caps = NULL, **cap;
+ GList *result = NULL;
+ DBusGProxy *proxy = get_proxy();
+
+ g_return_val_if_fail(proxy != NULL, NULL);
+
+ if (!dbus_g_proxy_call(proxy, "GetCapabilities", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRV, &caps, G_TYPE_INVALID))
+ {
+ g_message("GetCapabilities call failed: %s", error->message);
+ g_error_free(error);
+ return NULL;
+ }
+
+ for (cap = caps; *cap != NULL; cap++)
+ {
+ result = g_list_append(result, g_strdup(*cap));
+ }
+
+ g_strfreev(caps);
+
+ return result;
+}
+
+gboolean
+notify_get_server_info(char **ret_name, char **ret_vendor,
+ char **ret_version, char **ret_spec_version)
+{
+ GError *error = NULL;
+ DBusGProxy *proxy = get_proxy();
+
+ g_return_val_if_fail(proxy != NULL, FALSE);
+
+ if (!dbus_g_proxy_call(proxy, "GetServerInformation", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, ret_name,
+ G_TYPE_STRING, ret_vendor,
+ G_TYPE_STRING, ret_version,
+ G_TYPE_STRING, ret_spec_version,
+ G_TYPE_INVALID))
+ {
+ g_message("GetServerInformation call failed: %s", error->message);
+ return FALSE;
+ }
+
+ return TRUE;
+}
Modified: trunk/libnotify/libnotify/notify.h
===================================================================
--- trunk/libnotify/libnotify/notify.h 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/libnotify/notify.h 2006-01-16 01:53:06 UTC (rev 2432)
@@ -18,9 +18,6 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
- *
- * @todo We talk about URIs, but they are actually file paths not URIs
- * @todo Un-glibify?
*/
#ifndef _LIBNOTIFY_NOTIFY_H_
@@ -61,8 +58,30 @@
*/
gboolean notify_is_initted(void);
-const gchar *_notify_get_app_name(void);
+const gchar *notify_get_app_name(void);
+
+/**
+ * Returns the capabilities of the notification server.
+ *
+ * @return A list of capability strings. These strings must be freed.
+ */
+GList *notify_get_server_caps(void);
+
+/**
+ * Returns the server notification information.
+ *
+ * The strings returned must be freed.
+ *
+ * @param ret_name The returned product name of the server.
+ * @param ret_vendor The returned vendor.
+ * @param ret_version The returned server version.
+ * @param ret_spec_ver The returned specification version supported.
+ *
+ * @return TRUE if the call succeeded, or FALSE if there were errors.
+ */
+gboolean notify_get_server_info(char **ret_name, char **ret_vendor,
+ char **ret_version, char **ret_spec_version);
+
/*@}*/
-
#endif /* _LIBNOTIFY_NOTIFY_H_ */
Modified: trunk/libnotify/libnotify/notifynotification.c
===================================================================
--- trunk/libnotify/libnotify/notifynotification.c 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/libnotify/notifynotification.c 2006-01-16 01:53:06 UTC (rev 2432)
@@ -530,7 +530,7 @@
/*TODO: make this nonblocking */
if (!ignore_reply)
dbus_g_proxy_call (priv->proxy, "Notify", &tmp_error,
- G_TYPE_STRING, _notify_get_app_name (),
+ G_TYPE_STRING, notify_get_app_name (),
G_TYPE_STRING,
(priv->icon_name != NULL) ? priv->icon_name : "",
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
@@ -543,7 +543,7 @@
G_TYPE_UINT, &priv->id, G_TYPE_INVALID);
else
dbus_g_proxy_call_no_reply (priv->proxy, "Notify",
- G_TYPE_STRING, _notify_get_app_name (),
+ G_TYPE_STRING, notify_get_app_name (),
G_TYPE_STRING,
(priv->icon_name != NULL) ? priv->icon_name : "",
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
Property changes on: trunk/libnotify/tests
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
core*
test-animation
test-basic
test-default-action
test-error
test-image
test-markup
test-multi-actions
test-replace
test-replace-widget
test-xy
test-xy-stress
.deps
.libs
+ Makefile
Makefile.in
core*
test-animation
test-basic
test-default-action
test-error
test-image
test-markup
test-multi-actions
test-replace
test-replace-widget
test-server-info
test-xy
test-xy-stress
.deps
.libs
.*.swp
Modified: trunk/libnotify/tests/Makefile.am
===================================================================
--- trunk/libnotify/tests/Makefile.am 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/tests/Makefile.am 2006-01-16 01:53:06 UTC (rev 2432)
@@ -10,6 +10,7 @@
noinst_PROGRAMS = \
test-replace \
test-replace-widget \
+ test-server-info \
test-default-action \
test-multi-actions \
test-image \
@@ -26,16 +27,25 @@
test_replace_SOURCES = test-replace.c
test_replace_LDADD = $(common_ldflags)
+
test_replace_widget_SOURCES = test-replace-widget.c
test_replace_widget_LDADD = $(common_ldflags)
+
+test_server_info_SOURCES = test-server-info.c
+test_server_info_LDADD = $(common_ldflags)
+
test_default_action_SOURCES = test-default-action.c
test_default_action_LDADD = $(common_ldflags)
+
test_multi_actions_SOURCES = test-multi-actions.c
test_multi_actions_LDADD = $(common_ldflags)
+
test_image_SOURCES = test-image.c
test_image_LDADD = $(common_ldflags)
+
test_basic_SOURCES = test-basic.c
test_basic_LDADD = $(common_ldflags)
+
test_error_SOURCES = test-error.c
test_error_LDADD = $(common_ldflags)
Added: trunk/libnotify/tests/test-server-info.c
===================================================================
--- trunk/libnotify/tests/test-server-info.c 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/tests/test-server-info.c 2006-01-16 01:53:06 UTC (rev 2432)
@@ -0,0 +1,60 @@
+/*
+ * @file tests/test-server-info.c Retrieves the server info and caps
+ *
+ * @Copyright (C) 2004 Mike Hearn <mike at navi.cx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <libnotify/notify.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char **argv)
+{
+ notify_init("TestCaps");
+ GList *l, *caps;
+ char *name, *vendor, *version, *spec_version;
+
+ if (!notify_get_server_info(&name, &vendor, &version, &spec_version))
+ {
+ fprintf(stderr, "Failed to receive server info.\n");
+ exit(1);
+ }
+
+ printf("Name: %s\n", name);
+ printf("Vendor: %s\n", vendor);
+ printf("Version: %s\n", version);
+ printf("Spec Version: %s\n", spec_version);
+ printf("Capabilities:\n");
+
+ caps = notify_get_server_caps();
+
+ if (caps == NULL)
+ {
+ fprintf(stderr, "Failed to receive server caps.\n");
+ exit(1);
+ }
+
+ for (l = caps; l != NULL; l = l->next)
+ printf("\t%s\n", (char *)l->data);
+
+ g_list_foreach(caps, (GFunc)g_free, NULL);
+ g_list_free(caps);
+
+ return 0;
+}
Modified: trunk/libnotify/tests/test-xy.c
===================================================================
--- trunk/libnotify/tests/test-xy.c 2006-01-16 01:52:00 UTC (rev 2431)
+++ trunk/libnotify/tests/test-xy.c 2006-01-16 01:53:06 UTC (rev 2432)
@@ -32,7 +32,7 @@
"This notification should point to 150, 10",
NULL, NULL);
- notify_notification_set_hint_int32 (n, "x", 30);
+ notify_notification_set_hint_int32 (n, "x", 150);
notify_notification_set_hint_int32 (n, "y", 10);
if (!notify_notification_show (n, NULL)) {
More information about the galago-commits
mailing list