2004-09-25 05:05:10 -05:00
|
|
|
/*
|
|
|
|
* @file tests/test-default-action.c Unit test: default action
|
|
|
|
*
|
|
|
|
* @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 <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#define DBUS_API_SUBJECT_TO_CHANGE 1
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
#include <dbus/dbus-glib.h>
|
2004-09-25 14:59:43 -05:00
|
|
|
#include <dbus/dbus-glib-lowlevel.h>
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-25 14:59:43 -05:00
|
|
|
static GMainLoop *loop;
|
|
|
|
static NotifyHandle *n;
|
2004-09-25 05:05:10 -05:00
|
|
|
|
|
|
|
static void callback(NotifyHandle *handle, guint32 uid, void *user_data)
|
|
|
|
{
|
2004-09-29 23:53:30 -05:00
|
|
|
assert( uid == 0 );
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
notify_close(n);
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
g_main_loop_quit(loop);
|
2004-09-25 05:05:10 -05:00
|
|
|
}
|
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
if (!notify_init("Default Action Test")) exit(1);
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
|
|
|
loop = g_main_loop_new(NULL, FALSE);
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
dbus_connection_setup_with_g_main(conn, NULL);
|
2004-09-25 14:59:43 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
n = notify_send_notification(NULL, // replaces nothing
|
|
|
|
"presence.online",
|
|
|
|
NOTIFY_URGENCY_NORMAL,
|
|
|
|
"Matt is online", NULL,
|
|
|
|
NULL, // no icon
|
|
|
|
FALSE, 0, // does not expire
|
|
|
|
NULL, // no user data
|
|
|
|
1,
|
|
|
|
0, "default", callback); // 1 action
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
if (!n) {
|
|
|
|
fprintf(stderr, "failed to send notification\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
g_main_loop_run(loop);
|
2004-09-25 05:05:10 -05:00
|
|
|
|
2004-09-29 23:53:30 -05:00
|
|
|
return 0;
|
2004-09-25 05:05:10 -05:00
|
|
|
}
|