Add back notify_get_server_info() and notify_get_server_caps().
This commit is contained in:
parent
29b5c2b8ea
commit
85981b247c
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Sun Jan 15 17:52:39 PST 2006 Christian Hammond <chipx86@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@redhat.com>
|
Thu Jan 12 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||||
|
|
||||||
* libnotify/notifynotification.c (notify_notification_set_user_data):
|
* libnotify/notifynotification.c (notify_notification_set_user_data):
|
||||||
|
|
|
@ -1033,11 +1033,13 @@
|
||||||
<paramdef>out STRING <parameter>name</parameter></paramdef>
|
<paramdef>out STRING <parameter>name</parameter></paramdef>
|
||||||
<paramdef>out STRING <parameter>vendor</parameter></paramdef>
|
<paramdef>out STRING <parameter>vendor</parameter></paramdef>
|
||||||
<paramdef>out STRING <parameter>version</parameter></paramdef>
|
<paramdef>out STRING <parameter>version</parameter></paramdef>
|
||||||
|
<paramdef>out STRING <parameter>spec_version</parameter></paramdef>
|
||||||
</funcprototype>
|
</funcprototype>
|
||||||
</funcsynopsis>
|
</funcsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This message returns the information on the server. Specifically,
|
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>
|
</para>
|
||||||
<table>
|
<table>
|
||||||
<title>GetServerInformation Return Values</title>
|
<title>GetServerInformation Return Values</title>
|
||||||
|
@ -1068,6 +1070,11 @@
|
||||||
<entry>STRING</entry>
|
<entry>STRING</entry>
|
||||||
<entry>The server's version number.</entry>
|
<entry>The server's version number.</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><parameter>spec_version</parameter></entry>
|
||||||
|
<entry>STRING</entry>
|
||||||
|
<entry>The supported specification version number.</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
|
|
||||||
static gboolean _initted = FALSE;
|
static gboolean _initted = FALSE;
|
||||||
static gchar *_app_name = NULL;
|
static gchar *_app_name = NULL;
|
||||||
|
static DBusGProxy *_proxy = NULL;
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define format_func __attribute__((format(printf, 1, 2)))
|
# define format_func __attribute__((format(printf, 1, 2)))
|
||||||
#else /* no format string checking with this compiler */
|
#else /* no format string checking with this compiler */
|
||||||
|
@ -85,7 +87,7 @@ notify_init (const char *app_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
_notify_get_app_name (void)
|
notify_get_app_name (void)
|
||||||
{
|
{
|
||||||
return _app_name;
|
return _app_name;
|
||||||
}
|
}
|
||||||
|
@ -108,3 +110,83 @@ notify_is_initted (void)
|
||||||
{
|
{
|
||||||
return _initted;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
* License along with this library; if not, write to the
|
* License along with this library; if not, write to the
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* 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_
|
#ifndef _LIBNOTIFY_NOTIFY_H_
|
||||||
|
@ -61,8 +58,30 @@ void notify_uninit(void);
|
||||||
*/
|
*/
|
||||||
gboolean notify_is_initted(void);
|
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_ */
|
#endif /* _LIBNOTIFY_NOTIFY_H_ */
|
||||||
|
|
|
@ -530,7 +530,7 @@ _notify_notification_show_internal (NotifyNotification *notification,
|
||||||
/*TODO: make this nonblocking */
|
/*TODO: make this nonblocking */
|
||||||
if (!ignore_reply)
|
if (!ignore_reply)
|
||||||
dbus_g_proxy_call (priv->proxy, "Notify", &tmp_error,
|
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,
|
G_TYPE_STRING,
|
||||||
(priv->icon_name != NULL) ? priv->icon_name : "",
|
(priv->icon_name != NULL) ? priv->icon_name : "",
|
||||||
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
|
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
|
||||||
|
@ -543,7 +543,7 @@ _notify_notification_show_internal (NotifyNotification *notification,
|
||||||
G_TYPE_UINT, &priv->id, G_TYPE_INVALID);
|
G_TYPE_UINT, &priv->id, G_TYPE_INVALID);
|
||||||
else
|
else
|
||||||
dbus_g_proxy_call_no_reply (priv->proxy, "Notify",
|
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,
|
G_TYPE_STRING,
|
||||||
(priv->icon_name != NULL) ? priv->icon_name : "",
|
(priv->icon_name != NULL) ? priv->icon_name : "",
|
||||||
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
|
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
|
||||||
|
|
|
@ -10,6 +10,7 @@ endif
|
||||||
noinst_PROGRAMS = \
|
noinst_PROGRAMS = \
|
||||||
test-replace \
|
test-replace \
|
||||||
test-replace-widget \
|
test-replace-widget \
|
||||||
|
test-server-info \
|
||||||
test-default-action \
|
test-default-action \
|
||||||
test-multi-actions \
|
test-multi-actions \
|
||||||
test-image \
|
test-image \
|
||||||
|
@ -26,16 +27,25 @@ common_ldflags = \
|
||||||
|
|
||||||
test_replace_SOURCES = test-replace.c
|
test_replace_SOURCES = test-replace.c
|
||||||
test_replace_LDADD = $(common_ldflags)
|
test_replace_LDADD = $(common_ldflags)
|
||||||
|
|
||||||
test_replace_widget_SOURCES = test-replace-widget.c
|
test_replace_widget_SOURCES = test-replace-widget.c
|
||||||
test_replace_widget_LDADD = $(common_ldflags)
|
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_SOURCES = test-default-action.c
|
||||||
test_default_action_LDADD = $(common_ldflags)
|
test_default_action_LDADD = $(common_ldflags)
|
||||||
|
|
||||||
test_multi_actions_SOURCES = test-multi-actions.c
|
test_multi_actions_SOURCES = test-multi-actions.c
|
||||||
test_multi_actions_LDADD = $(common_ldflags)
|
test_multi_actions_LDADD = $(common_ldflags)
|
||||||
|
|
||||||
test_image_SOURCES = test-image.c
|
test_image_SOURCES = test-image.c
|
||||||
test_image_LDADD = $(common_ldflags)
|
test_image_LDADD = $(common_ldflags)
|
||||||
|
|
||||||
test_basic_SOURCES = test-basic.c
|
test_basic_SOURCES = test-basic.c
|
||||||
test_basic_LDADD = $(common_ldflags)
|
test_basic_LDADD = $(common_ldflags)
|
||||||
|
|
||||||
test_error_SOURCES = test-error.c
|
test_error_SOURCES = test-error.c
|
||||||
test_error_LDADD = $(common_ldflags)
|
test_error_LDADD = $(common_ldflags)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* @file tests/test-server-info.c Retrieves the server info and caps
|
||||||
|
*
|
||||||
|
* @Copyright (C) 2004 Mike Hearn <mike@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;
|
||||||
|
}
|
|
@ -32,7 +32,7 @@ int main() {
|
||||||
"This notification should point to 150, 10",
|
"This notification should point to 150, 10",
|
||||||
NULL, NULL);
|
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);
|
notify_notification_set_hint_int32 (n, "y", 10);
|
||||||
|
|
||||||
if (!notify_notification_show (n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
|
|
Loading…
Reference in New Issue