[Galago-commits] r2666 - in trunk/libgalago: . libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Mon Apr 3 21:18:29 PDT 2006
Author: chipx86
Date: 2006-04-03 21:18:21 -0700 (Mon, 03 Apr 2006)
New Revision: 2666
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-core.c
trunk/libgalago/libgalago/galago-core.h
trunk/libgalago/tests/check-libgalago.c
trunk/libgalago/tests/get-avatar.c
trunk/libgalago/tests/get-person-attr.c
trunk/libgalago/tests/get-presence.c
trunk/libgalago/tests/list-accounts.c
trunk/libgalago/tests/list-my-accounts.c
trunk/libgalago/tests/list-people.c
trunk/libgalago/tests/list-services.c
trunk/libgalago/tests/monitor.c
trunk/libgalago/tests/person-attr-test.c
trunk/libgalago/tests/presence-feed-2.c
trunk/libgalago/tests/presence-feed.c
trunk/libgalago/tests/test-bug-36.c
Log:
Kinda big last-minute API change. Patch by Jorn Baayen to replace the feed boolean on galago_init() with flags. This also allows Galago to be used in a way that doesn't require the daemon to be running. That option can be specified by using the GALAGO_INIT_NO_ACTIVATION flag.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/ChangeLog 2006-04-04 04:18:21 UTC (rev 2666)
@@ -1,3 +1,26 @@
+Mon Apr 03 21:09:48 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-core.c:
+ * libgalago/galago-core.h:
+ * tests/check-libgalago.c:
+ * tests/get-avatar.c:
+ * tests/get-person-attr.c:
+ * tests/get-presence.c:
+ * tests/list-accounts.c:
+ * tests/list-my-accounts.c:
+ * tests/list-people.c:
+ * tests/list-services.c:
+ * tests/monitor.c:
+ * tests/person-attr-test.c:
+ * tests/presence-feed-2.c:
+ * tests/presence-feed.c:
+ * tests/test-bug-36.c:
+ - Kinda big last-minute API change. Patch by Jorn Baayen to
+ replace the feed boolean on galago_init() with flags. This also
+ allows Galago to be used in a way that doesn't require the daemon
+ to be running. That option can be specified by using the
+ GALAGO_INIT_NO_ACTIVATION flag.
+
Mon Apr 03 03:05:07 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-account.c:
Modified: trunk/libgalago/libgalago/galago-core.c
===================================================================
--- trunk/libgalago/libgalago/galago-core.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/libgalago/galago-core.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -47,8 +47,9 @@
gboolean filters_added;
gboolean watch_all;
+ GalagoInitFlags flags;
+
gboolean daemon;
- gboolean feed;
gboolean registered;
gboolean daemon_active;
@@ -309,22 +310,25 @@
if (dbus_message_is_error(message, DBUS_ERROR_SERVICE_UNKNOWN))
{
- DBusError error;
-
if (!galago_is_daemon())
{
_galago_dbus_unregister_connection_finish();
}
- dbus_error_init(&error);
+ if (!(_core->flags & GALAGO_INIT_NO_ACTIVATE))
+ {
+ DBusError error;
- if (!dbus_bus_start_service_by_name(_core->dbus_conn,
- GALAGO_DBUS_SERVICE, 0, NULL,
- &error))
- {
- g_warning("Received ServiceDoesNotExist, and cannot "
- "re-activate daemon. Disconnecting for now.");
- dbus_error_free(&error);
+ dbus_error_init(&error);
+
+ if (!dbus_bus_start_service_by_name(_core->dbus_conn,
+ GALAGO_DBUS_SERVICE,
+ 0, NULL, &error))
+ {
+ g_warning("Received ServiceDoesNotExist, and cannot "
+ "re-activate daemon. Disconnecting for now.");
+ dbus_error_free(&error);
+ }
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -686,7 +690,6 @@
static gboolean
_galago_core_connect(void)
{
- gboolean service_activated = TRUE;
DBusError error;
dbus_error_init(&error);
@@ -711,14 +714,16 @@
return TRUE;
}
- if (!dbus_bus_start_service_by_name(_core->dbus_conn, GALAGO_DBUS_SERVICE,
- 0, NULL, &error))
+ if (!(_core->flags & GALAGO_INIT_NO_ACTIVATE))
{
- g_warning("Unable to activate Galago service: %s", error.message);
- dbus_error_free(&error);
- dbus_error_init(&error);
-
- service_activated = FALSE;
+ if (!dbus_bus_start_service_by_name(_core->dbus_conn,
+ GALAGO_DBUS_SERVICE,
+ 0, NULL, &error))
+ {
+ g_warning("Unable to activate Galago service: %s", error.message);
+ dbus_error_free(&error);
+ dbus_error_init(&error);
+ }
}
if (!dbus_connection_add_filter(_core->dbus_conn,
@@ -847,7 +852,7 @@
}
gboolean
-galago_init(const char *name, gboolean feed)
+galago_init(const char *name, GalagoInitFlags flags)
{
GalagoContext *context;
static GOnce first_init = G_ONCE_INIT;
@@ -875,7 +880,7 @@
galago_object_set_dbus_path(GALAGO_OBJECT(_core), GALAGO_DBUS_CORE_OBJECT);
_core->app_name = g_strdup(name);
- _core->feed = feed;
+ _core->flags = flags;
if (!strcmp(name, GALAGO_DAEMON_ID))
_core->daemon = TRUE;
@@ -963,7 +968,7 @@
g_return_val_if_fail(galago_is_initted(), FALSE);
g_return_val_if_fail(galago_is_connected(), FALSE);
- return _core->feed;
+ return (_core->flags & GALAGO_INIT_FEED);
}
#define ADD_SIGNAL_MATCH(iface) \
@@ -1223,6 +1228,7 @@
_galago_dbus_register_connection(void)
{
GList *list, *return_list = NULL;
+ gboolean is_feed;
return_list = g_list_append(return_list,
galago_value_new(GALAGO_VALUE_TYPE_STRING, NULL, NULL));
@@ -1231,10 +1237,12 @@
_core->registering_connection = TRUE;
+ is_feed = galago_is_feed();
+
list = galago_dbus_send_message_with_reply_list(
GALAGO_OBJECT(_core), "Register", return_list,
galago_value_new(GALAGO_VALUE_TYPE_STRING, &_core->app_name, NULL),
- galago_value_new(GALAGO_VALUE_TYPE_BOOLEAN, &_core->feed, NULL),
+ galago_value_new(GALAGO_VALUE_TYPE_BOOLEAN, &is_feed, NULL),
NULL);
_core->registering_connection = FALSE;
Modified: trunk/libgalago/libgalago/galago-core.h
===================================================================
--- trunk/libgalago/libgalago/galago-core.h 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/libgalago/galago-core.h 2006-04-04 04:18:21 UTC (rev 2666)
@@ -40,16 +40,34 @@
/**************************************************************************/
/**
+ * Initialization flags
+ */
+typedef enum
+{
+ /** Connection will be used for querying data only. */
+ GALAGO_INIT_CLIENT = 0,
+
+ /**
+ * Connection will feed presence data. This takes precedence over
+ * GALAGO_INIT_CLIENT.
+ */
+ GALAGO_INIT_FEED = 1 << 0,
+
+ /** The daemon will not be activated automatically. */
+ GALAGO_INIT_NO_ACTIVATION = 1 << 1
+
+} GalagoInitFlags;
+
+/**
* Initializes Galago.
*
- * @param name The ID name used for this connection. It's often the
- * name of the program, without spaces or special characters.
- * @param feed TRUE if this connection should feed presence data. FALSE
- * if it will only be querying for data.
+ * @param name The ID name used for this connection. It's often the
+ * name of the program, without spaces or special characters.
+ * @param flags The flags used for this connection.
*
* @return TRUE if initialization was successful, or FALSE otherwise.
*/
-gboolean galago_init(const char *name, gboolean feed);
+gboolean galago_init(const char *name, GalagoInitFlags flags);
/**
* Uninitializes Galago.
Modified: trunk/libgalago/tests/check-libgalago.c
===================================================================
--- trunk/libgalago/tests/check-libgalago.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/check-libgalago.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -74,12 +74,12 @@
**************************************************************************/
START_TEST(test_init_reinit)
{
- fail_unless(galago_init("check-libgalago", FALSE),
+ fail_unless(galago_init("check-libgalago", GALAGO_INIT_CLIENT),
"Unable to initialize libgalago");
galago_uninit();
- fail_unless(galago_init("check-libgalago", FALSE),
+ fail_unless(galago_init("check-libgalago", GALAGO_INIT_CLIENT),
"Unable to re-initialize libgalago");
}
END_TEST
@@ -90,12 +90,12 @@
*/
START_TEST(test_init_reinit_with_service)
{
- fail_unless(galago_init("check-libgalago", TRUE),
+ fail_unless(galago_init("check-libgalago", GALAGO_INIT_FEED),
"Unable to initialize libgalago");
galago_create_service("dummy-service-1", "Dummy Service 1", 0);
galago_uninit();
- fail_unless(galago_init("check-libgalago", TRUE),
+ fail_unless(galago_init("check-libgalago", GALAGO_INIT_FEED),
"Unable to re-initialize libgalago");
galago_uninit();
}
@@ -109,7 +109,7 @@
{
GalagoPerson *person;
- galago_init("check-libgalago", TRUE);
+ galago_init("check-libgalago", GALAGO_INIT_FEED);
person = make_dummy_person();
fail_unless(person != NULL, "Unable to create person");
@@ -127,7 +127,7 @@
{
GalagoService *service;
- galago_init("check-libgalago", TRUE);
+ galago_init("check-libgalago", GALAGO_INIT_FEED);
service = make_dummy_service();
fail_unless(service != NULL, "Unable to create service");
@@ -140,7 +140,7 @@
{
GalagoAccount *account;
- galago_init("check-libgalago", TRUE);
+ galago_init("check-libgalago", GALAGO_INIT_FEED);
account = make_dummy_account();
fail_unless(account != NULL, "Unable to create account");
@@ -153,7 +153,7 @@
{
GalagoPresence *presence;
- galago_init("check-libgalago", TRUE);
+ galago_init("check-libgalago", GALAGO_INIT_FEED);
presence = make_dummy_presence();
fail_unless(presence != NULL, "Unable to create presence");
@@ -203,42 +203,42 @@
START_TEST(test_dbus_signature_account)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_signature(GALAGO_TYPE_ACCOUNT, GALAGO_OBJECT(make_dummy_account()));
}
END_TEST
START_TEST(test_dbus_signature_image)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_signature(GALAGO_TYPE_IMAGE, GALAGO_OBJECT(make_dummy_image()));
}
END_TEST
START_TEST(test_dbus_signature_person)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_signature(GALAGO_TYPE_PERSON, GALAGO_OBJECT(make_dummy_person()));
}
END_TEST
START_TEST(test_dbus_signature_presence)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_signature(GALAGO_TYPE_PRESENCE, GALAGO_OBJECT(make_dummy_presence()));
}
END_TEST
START_TEST(test_dbus_signature_service)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_signature(GALAGO_TYPE_SERVICE, GALAGO_OBJECT(make_dummy_service()));
}
END_TEST
START_TEST(test_dbus_signature_status)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_signature(GALAGO_TYPE_STATUS, GALAGO_OBJECT(make_dummy_status()));
}
END_TEST
@@ -271,7 +271,7 @@
GalagoAccount *priority_account;
gulong conn_id;
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
person = make_dummy_person();
service = make_dummy_service();
@@ -335,7 +335,7 @@
START_TEST(test_service_normalize)
{
- galago_init("check-libgalago", FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
test_service_normalize_with(0,
"joebobsmith/home");
Modified: trunk/libgalago/tests/get-avatar.c
===================================================================
--- trunk/libgalago/tests/get-avatar.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/get-avatar.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -40,7 +40,7 @@
username = argv[2];
filename = argv[3];
- galago_init("get-avatar", FALSE);
+ galago_init("get-avatar", GALAGO_INIT_CLIENT);
service = galago_get_service(service_id, GALAGO_REMOTE, TRUE);
Modified: trunk/libgalago/tests/get-person-attr.c
===================================================================
--- trunk/libgalago/tests/get-person-attr.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/get-person-attr.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -37,7 +37,7 @@
person_id = argv[1];
attr_name = argv[2];
- galago_init("get-person-attr", FALSE);
+ galago_init("get-person-attr", GALAGO_INIT_CLIENT);
person = galago_get_person(person_id, GALAGO_REMOTE, TRUE);
Modified: trunk/libgalago/tests/get-presence.c
===================================================================
--- trunk/libgalago/tests/get-presence.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/get-presence.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -58,7 +58,7 @@
service_id = argv[1];
username = argv[2];
- galago_init("get-presence", FALSE);
+ galago_init("get-presence", GALAGO_INIT_CLIENT);
service = galago_get_service(service_id, GALAGO_REMOTE, TRUE);
Modified: trunk/libgalago/tests/list-accounts.c
===================================================================
--- trunk/libgalago/tests/list-accounts.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/list-accounts.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -51,7 +51,7 @@
{
char *service_id = NULL;
- if (!galago_init("list-accounts-test", FALSE) ||
+ if (!galago_init("list-accounts-test", GALAGO_INIT_CLIENT) ||
!galago_is_connected())
{
fprintf(stderr, "Unable to connect to the Galago service.\n");
Modified: trunk/libgalago/tests/list-my-accounts.c
===================================================================
--- trunk/libgalago/tests/list-my-accounts.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/list-my-accounts.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -30,7 +30,7 @@
GList *l;
GalagoPerson *me;
- if (!galago_init("list-accounts-test", FALSE) ||
+ if (!galago_init("list-accounts-test", GALAGO_INIT_CLIENT) ||
!galago_is_connected())
{
fprintf(stderr, "Unable to connect to the Galago service.\n");
Modified: trunk/libgalago/tests/list-people.c
===================================================================
--- trunk/libgalago/tests/list-people.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/list-people.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -64,7 +64,7 @@
{
char *person_uid = NULL;
- if (!galago_init("list-people-test", FALSE) ||
+ if (!galago_init("list-people-test", GALAGO_INIT_CLIENT) ||
!galago_is_connected())
{
fprintf(stderr, "Unable to connect to the Galago service.\n");
Modified: trunk/libgalago/tests/list-services.c
===================================================================
--- trunk/libgalago/tests/list-services.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/list-services.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -28,7 +28,7 @@
{
GList *l;
- if (!galago_init("list-services-test", FALSE) ||
+ if (!galago_init("list-services-test", GALAGO_INIT_CLIENT) ||
!galago_is_connected())
{
fprintf(stderr, "Unable to connect to the Galago service.\n");
Modified: trunk/libgalago/tests/monitor.c
===================================================================
--- trunk/libgalago/tests/monitor.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/monitor.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -50,7 +50,7 @@
loop = g_main_loop_new(NULL, FALSE);
- if (!galago_init("monitor", FALSE))
+ if (!galago_init("monitor", GALAGO_INIT_CLIENT))
{
fprintf(stderr, "Unable to initialize Galago and connect "
"to the server\n");
Modified: trunk/libgalago/tests/person-attr-test.c
===================================================================
--- trunk/libgalago/tests/person-attr-test.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/person-attr-test.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -34,7 +34,7 @@
GalagoPresence *presence;
GalagoStatus *status;
- if (!galago_init("person-attr-test-feed", TRUE))
+ if (!galago_init("person-attr-test-feed", GALAGO_INIT_FEED))
exit(1);
/* Setup our test service */
Modified: trunk/libgalago/tests/presence-feed-2.c
===================================================================
--- trunk/libgalago/tests/presence-feed-2.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/presence-feed-2.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -95,7 +95,7 @@
loop = g_main_loop_new(NULL, FALSE);
- if (!galago_init("test-feed-2", TRUE))
+ if (!galago_init("test-feed-2", GALAGO_INIT_FEED))
{
fprintf(stderr, "Unable to initialize Galago and connect "
"to the server\n");
Modified: trunk/libgalago/tests/presence-feed.c
===================================================================
--- trunk/libgalago/tests/presence-feed.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/presence-feed.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -104,7 +104,7 @@
loop = g_main_loop_new(NULL, FALSE);
- if (!galago_init("test-feed", TRUE))
+ if (!galago_init("test-feed", GALAGO_INIT_FEED))
{
fprintf(stderr, "Unable to initialize Galago and connect "
"to the server\n");
Modified: trunk/libgalago/tests/test-bug-36.c
===================================================================
--- trunk/libgalago/tests/test-bug-36.c 2006-04-03 10:23:51 UTC (rev 2665)
+++ trunk/libgalago/tests/test-bug-36.c 2006-04-04 04:18:21 UTC (rev 2666)
@@ -27,7 +27,7 @@
int
main(int argc, char **argv)
{
- if (!galago_init("test-death", TRUE))
+ if (!galago_init("test-death", GALAGO_INIT_FEED))
{
fprintf(stderr, "Unable to initialize Galago and connect "
"to the server\n");
@@ -39,7 +39,7 @@
galago_uninit();
- if (!galago_init("test-death", TRUE))
+ if (!galago_init("test-death", GALAGO_INIT_FEED))
{
fprintf(stderr, "Unable to initialize Galago and connect "
"to the server\n");
More information about the galago-commits
mailing list