[Galago-commits] r2865 - in branches/libgalago/push-presence: .
libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Jun 18 01:16:43 PDT 2006
Author: chipx86
Date: 2006-06-18 01:16:38 -0700 (Sun, 18 Jun 2006)
New Revision: 2865
Modified:
branches/libgalago/push-presence/ChangeLog
branches/libgalago/push-presence/libgalago/galago-presence.c
branches/libgalago/push-presence/libgalago/galago-presence.h
branches/libgalago/push-presence/libgalago/galago-status-type.c
branches/libgalago/push-presence/libgalago/galago-status-type.h
branches/libgalago/push-presence/tests/check-libgalago.c
branches/libgalago/push-presence/tests/get-presence.c
branches/libgalago/push-presence/tests/person-attr-test.c
branches/libgalago/push-presence/tests/presence-feed-2.c
branches/libgalago/push-presence/tests/presence-feed.c
Log:
- Added galago_status_type_new_with_attributes().
- Add stubs for the new status functions for GalagoPresence.
- Fix up the test programs so that they compile, and added some test cases.
Modified: branches/libgalago/push-presence/ChangeLog
===================================================================
--- branches/libgalago/push-presence/ChangeLog 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/ChangeLog 2006-06-18 08:16:38 UTC (rev 2865)
@@ -1,3 +1,19 @@
+Sun Jun 18 01:15:15 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-presence.c:
+ * libgalago/galago-presence.h:
+ * libgalago/galago-status-type.c:
+ * libgalago/galago-status-type.h:
+ * tests/check-libgalago.c:
+ * tests/get-presence.c:
+ * tests/person-attr-test.c:
+ * tests/presence-feed-2.c:
+ * tests/presence-feed.c:
+ - Added galago_status_type_new_with_attributes().
+ - Add stubs for the new status functions for GalagoPresence.
+ - Fix up the test programs so that they compile, and added some
+ test cases.
+
Wed Jun 14 02:03:42 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-status-type.c:
Modified: branches/libgalago/push-presence/libgalago/galago-presence.c
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-presence.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/libgalago/galago-presence.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -505,6 +505,73 @@
#endif
}
+void
+galago_presence_enable_status(GalagoPresence *presence,
+ const char *status_id,
+ const char *attr_id,
+ GValue *attr_value, ...)
+{
+ g_return_if_fail(presence != NULL);
+ g_return_if_fail(GALAGO_IS_PRESENCE(presence));
+ g_return_if_fail(status_id != NULL && *status_id != '\0');
+ g_return_if_fail(attr_id == NULL || attr_value != NULL);
+}
+
+void
+galago_presence_disable_status(GalagoPresence *presence,
+ const char *status_id)
+{
+ g_return_if_fail(presence != NULL);
+ g_return_if_fail(GALAGO_IS_PRESENCE(presence));
+ g_return_if_fail(status_id != NULL && *status_id != '\0');
+}
+
+GList *
+galago_presence_get_enabled_statuses(const GalagoPresence *presence)
+{
+ g_return_val_if_fail(presence != NULL, NULL);
+ g_return_val_if_fail(GALAGO_IS_PRESENCE(presence), NULL);
+
+ return NULL;
+}
+
+gboolean
+galago_presence_get_status_enabled(const GalagoPresence *presence,
+ const char *status_id)
+{
+ g_return_val_if_fail(presence != NULL, FALSE);
+ g_return_val_if_fail(GALAGO_IS_PRESENCE(presence), FALSE);
+ g_return_val_if_fail(status_id != NULL && *status_id != '\0', FALSE);
+
+ return FALSE;
+}
+
+void
+galago_presence_set_status_attrs(GalagoPresence *presence,
+ const char *status_id,
+ const char *attr_id,
+ GValue *attr_value, ...)
+{
+ g_return_if_fail(presence != NULL);
+ g_return_if_fail(GALAGO_IS_PRESENCE(presence));
+ g_return_if_fail(status_id != NULL && *status_id != '\0');
+ g_return_if_fail(attr_id != NULL && *attr_id != '\0');
+ g_return_if_fail(attr_value != NULL);
+}
+
+const GValue *
+galago_presence_get_status_attr(GalagoPresence *presence,
+ const char *status_id,
+ const char *attr_id)
+{
+ g_return_val_if_fail(presence != NULL, NULL);
+ g_return_val_if_fail(GALAGO_IS_PRESENCE(presence), NULL);
+ g_return_val_if_fail(status_id != NULL && *status_id != '\0', NULL);
+ g_return_val_if_fail(attr_id != NULL && *attr_id != '\0', NULL);
+
+ return NULL;
+}
+
/**
* galago_presence_compare
* @presence1: The first presence.
Modified: branches/libgalago/push-presence/libgalago/galago-presence.h
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-presence.h 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/libgalago/galago-presence.h 2006-06-18 08:16:38 UTC (rev 2865)
@@ -102,17 +102,22 @@
gboolean galago_presence_is_available(const GalagoPresence *presence);
void galago_presence_enable_status(GalagoPresence *presence,
- const GalagoStatusType *status_type, ...);
-void galago_presence_disable_status(GalagoPresence *presence);
+ const char *status_id,
+ const char *attr_id,
+ GValue *attr_value,
+ ...);
+void galago_presence_disable_status(GalagoPresence *presence,
+ const char *status_id);
GList *galago_presence_get_enabled_statuses(const GalagoPresence *presence);
-gboolean galago_presence_get_status_enabled(const GalagoPresence *presence);
+gboolean galago_presence_get_status_enabled(const GalagoPresence *presence,
+ const char *status_id);
void galago_presence_set_status_attrs(GalagoPresence *presence,
- const GalagoStatusType *status_type,
- GValue *value, ...);
-const GValue *galago_presence_get_status_attr(
- GalagoPresence *presence,
- const GalagoStatusType *status_type,
- const char *attr_name);
+ const char *status_id,
+ const char *attr_id,
+ GValue *attr_value, ...);
+const GValue *galago_presence_get_status_attr(GalagoPresence *presence,
+ const char *status_id,
+ const char *attr_name);
int galago_presence_compare(const GalagoPresence *presence1,
const GalagoPresence *presence2);
Modified: branches/libgalago/push-presence/libgalago/galago-status-type.c
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-status-type.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/libgalago/galago-status-type.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -490,6 +490,35 @@
NULL);
}
+GalagoStatusType *
+galago_status_type_new_with_attributes(GalagoStatusPrimitive primitive,
+ const char *id,
+ const char *name,
+ gboolean exclusive,
+ GalagoStatusAttr *attr, ...)
+{
+ GalagoStatusType *status_type;
+ va_list args;
+
+ g_return_val_if_fail(galago_is_initted(), NULL);
+ g_return_val_if_fail(primitive != GALAGO_STATUS_UNSET, NULL);
+ g_return_val_if_fail(id != NULL && *id != '\0', NULL);
+ g_return_val_if_fail(attr != NULL, NULL);
+
+ status_type = galago_status_type_new(primitive, id, name, exclusive);
+
+ va_start(args, attr);
+ do
+ {
+ galago_status_type_add_attribute(status_type, attr);
+ }
+ while ((attr = (GalagoStatusAttr *)va_arg(args,
+ GalagoStatusAttr *)) != NULL);
+ va_end(args);
+
+ return status_type;
+}
+
void
galago_status_type_add_attribute(GalagoStatusType *status_type,
GalagoStatusAttr *attr)
Modified: branches/libgalago/push-presence/libgalago/galago-status-type.h
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-status-type.h 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/libgalago/galago-status-type.h 2006-06-18 08:16:38 UTC (rev 2865)
@@ -93,6 +93,14 @@
const char *name,
gboolean exclusive);
+GalagoStatusType *galago_status_type_new_with_attributes(
+ GalagoStatusPrimitive primitive,
+ const char *id,
+ const char *name,
+ gboolean exclusive,
+ GalagoStatusAttr *attr,
+ ...);
+
void galago_status_type_add_attribute(GalagoStatusType *status_type,
GalagoStatusAttr *attr);
Modified: branches/libgalago/push-presence/tests/check-libgalago.c
===================================================================
--- branches/libgalago/push-presence/tests/check-libgalago.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/tests/check-libgalago.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -63,10 +63,10 @@
return galago_account_create_presence(make_dummy_account());
}
-static GalagoStatus *
-make_dummy_status(void)
+static GalagoStatusType *
+make_dummy_status_type(void)
{
- return galago_status_new(GALAGO_STATUS_AWAY, "away", "Away", TRUE);
+ return galago_status_type_new(GALAGO_STATUS_AWAY, "away", "Away", TRUE);
}
/**************************************************************************
@@ -236,10 +236,11 @@
}
END_TEST
-START_TEST(test_dbus_signature_status)
+START_TEST(test_dbus_signature_status_type)
{
galago_init("check-libgalago", GALAGO_INIT_CLIENT);
- test_signature(GALAGO_TYPE_STATUS, GALAGO_OBJECT(make_dummy_status()));
+ test_signature(GALAGO_TYPE_STATUS_TYPE,
+ GALAGO_OBJECT(make_dummy_status_type()));
}
END_TEST
@@ -481,7 +482,27 @@
}
END_TEST
+
/**************************************************************************
+ * Feed Registration
+ **************************************************************************/
+START_TEST(test_feed_registration)
+{
+ GalagoService *service;
+
+ fail_unless(galago_init("check-libgalago", GALAGO_INIT_FEED),
+ "Unable to initialize libgalago");
+ service = galago_create_service("dummy-service-1", "Dummy Service 1", 0);
+ galago_service_register_status(service,
+ galago_status_type_new_with_attributes(
+ GALAGO_STATUS_AWAY, "away", "Away", TRUE,
+ galago_status_attr_new(GALAGO_STATUS_ATTR_MESSAGE, NULL,
+ G_TYPE_STRING)));
+}
+END_TEST
+
+
+/**************************************************************************
* Core tests
**************************************************************************/
START_TEST(test_core)
@@ -517,12 +538,12 @@
ADD_TCASE("create_presence", test_create_presence);
/* Test D-BUS object signature support */
- ADD_TCASE("dbus_signature_account", test_dbus_signature_account);
- ADD_TCASE("dbus_signature_image", test_dbus_signature_image);
- ADD_TCASE("dbus_signature_person", test_dbus_signature_person);
- ADD_TCASE("dbus_signature_presence", test_dbus_signature_presence);
- ADD_TCASE("dbus_signature_service", test_dbus_signature_service);
- ADD_TCASE("dbus_signature_status", test_dbus_signature_status);
+ ADD_TCASE("dbus_signature_account", test_dbus_signature_account);
+ ADD_TCASE("dbus_signature_image", test_dbus_signature_image);
+ ADD_TCASE("dbus_signature_person", test_dbus_signature_person);
+ ADD_TCASE("dbus_signature_presence", test_dbus_signature_presence);
+ ADD_TCASE("dbus_signature_service", test_dbus_signature_service);
+ ADD_TCASE("dbus_signature_status_type", test_dbus_signature_status_type);
/* Test the Person object */
ADD_TCASE("person_priority_accounts", test_person_priority_accounts);
@@ -538,6 +559,9 @@
ADD_TCASE("service_get_account_async", test_service_get_account_async);
ADD_TCASE("account_get_presence_async", test_account_get_presence_async);
+ /* Test feed registration */
+ ADD_TCASE("feed_registration", test_feed_registration);
+
return s;
}
Modified: branches/libgalago/push-presence/tests/get-presence.c
===================================================================
--- branches/libgalago/push-presence/tests/get-presence.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/tests/get-presence.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -22,10 +22,11 @@
#include <stdio.h>
#include <string.h>
+#if 0
static const char *
-get_name_from_status_type(GalagoStatusType type)
+get_name_from_status_primitive(GalagoStatusPrimitive primitive)
{
- switch (type)
+ switch (primitive)
{
case GALAGO_STATUS_UNSET: return "Unset";
case GALAGO_STATUS_OFFLINE: return "Offline";
@@ -37,14 +38,19 @@
return NULL;
};
}
+#endif
int
main(int argc, char **argv)
{
+#if 0
GList *l;
+#endif
char *username, *service_id;
GalagoPresence *presence;
- GalagoStatus *status;
+#if 0
+ GalagoStatusType *status_type;
+#endif
GalagoAccount *account;
GalagoService *service;
GalagoPerson *person;
@@ -104,6 +110,8 @@
printf("Status(es):\n");
+#warning Not yet updated for galago status registration changes!
+#if 0
for (l = galago_presence_get_statuses(presence);
l != NULL;
l = l->next)
@@ -155,6 +163,7 @@
}
}
}
+#endif
}
return 0;
Modified: branches/libgalago/push-presence/tests/person-attr-test.c
===================================================================
--- branches/libgalago/push-presence/tests/person-attr-test.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/tests/person-attr-test.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -32,22 +32,20 @@
GalagoAccount *account;
GalagoPerson *person;
GalagoPresence *presence;
- GalagoStatus *status;
if (!galago_init("person-attr-test-feed", GALAGO_INIT_FEED))
exit(1);
/* Setup our test service */
- service = galago_create_service("lathiat", "Lathiats Godly Program", 0);
+ service = galago_create_service("lathiat", "Lathiats Godly Program", 0);
+ galago_service_register_status(service,
+ galago_status_type_new(GALAGO_STATUS_AVAILABLE, "harass",
+ "Taking harassments", TRUE));
person = galago_create_person("dizzy");
account = galago_service_create_account(service, person, "lathiat");
presence = galago_account_create_presence(account);
+ galago_presence_enable_status(presence, "harass", NULL, NULL);
- status = galago_status_new(GALAGO_STATUS_AVAILABLE, "harass",
- "Taking harassments", TRUE);
-
- galago_presence_add_status(presence, status);
-
galago_object_set_attr_string(GALAGO_OBJECT(person),
"email", "lathiat at bur.st");
galago_object_set_attr_string(GALAGO_OBJECT(person),
Modified: branches/libgalago/push-presence/tests/presence-feed-2.c
===================================================================
--- branches/libgalago/push-presence/tests/presence-feed-2.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/tests/presence-feed-2.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -31,11 +31,23 @@
GalagoAccount *contact;
GalagoPerson *me, *person;
GalagoPresence *presence;
- GalagoStatus *status;
+ GValue *value;
/* Setup our services */
- aim_service = galago_create_service(GALAGO_SERVICE_ID_AIM, NULL, 0);
+ aim_service = galago_create_service(GALAGO_SERVICE_ID_AIM, NULL, 0);
+ galago_service_register_status(aim_service,
+ galago_status_type_new_with_attributes(
+ GALAGO_STATUS_AWAY, "away", "Away", TRUE,
+ galago_status_attr_new(GALAGO_STATUS_ATTR_MESSAGE, NULL,
+ G_TYPE_STRING)));
+
yahoo_service = galago_create_service(GALAGO_SERVICE_ID_YAHOO, NULL, 0);
+ galago_service_register_status(yahoo_service,
+ galago_status_type_new(GALAGO_STATUS_OFFLINE, "offline", "Offline",
+ TRUE));
+ galago_service_register_status(yahoo_service,
+ galago_status_type_new(GALAGO_STATUS_AVAILABLE, "available",
+ "Available", TRUE));
/* Create our local person */
me = galago_get_me(GALAGO_LOCAL, FALSE);
@@ -44,13 +56,12 @@
account = galago_service_create_account(aim_service, me, "GalagoAIMUser2");
presence = galago_account_create_presence(account);
- status = galago_status_new(GALAGO_STATUS_AWAY, "available", "Available",
- TRUE);
- galago_object_set_attr_string(GALAGO_OBJECT(status), "message",
- "Talk to me!");
+ value = g_new0(GValue, 1);
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, "Talk to me!");
+ galago_presence_enable_status(presence, "available",
+ GALAGO_STATUS_ATTR_MESSAGE, value);
- galago_presence_add_status(presence, status);
-
/* Add contacts to our AIM account */
person = galago_create_person("gonkulator");
contact = galago_service_create_account(aim_service, person, "lottabs2");
@@ -70,20 +81,14 @@
account = galago_service_create_account(yahoo_service, me,
"GalagoYahooUser");
presence = galago_account_create_presence(account);
+ galago_presence_enable_status(presence, "available", NULL, NULL);
- status = galago_status_new(GALAGO_STATUS_AVAILABLE, "available",
- "Available", TRUE);
-
- galago_presence_add_status(presence, status);
-
/* Add contacts to our Yahoo account */
person = galago_create_person("chipx86");
contact = galago_service_create_account(yahoo_service, person, "ChipX86");
presence = galago_account_create_presence(contact);
- status = galago_status_new(GALAGO_STATUS_AVAILABLE, "available",
- "Available", TRUE);
- galago_presence_add_status(presence, status);
+ galago_presence_enable_status(presence, "available", NULL, NULL);
galago_account_add_contact(account, contact);
}
Modified: branches/libgalago/push-presence/tests/presence-feed.c
===================================================================
--- branches/libgalago/push-presence/tests/presence-feed.c 2006-06-18 06:52:25 UTC (rev 2864)
+++ branches/libgalago/push-presence/tests/presence-feed.c 2006-06-18 08:16:38 UTC (rev 2865)
@@ -32,11 +32,28 @@
GalagoAccount *contact;
GalagoPerson *me, *person;
GalagoPresence *presence;
- GalagoStatus *status;
+ GValue *value;
/* Setup our services */
- aim_service = galago_create_service(GALAGO_SERVICE_ID_AIM, NULL, 0);
+ aim_service = galago_create_service(GALAGO_SERVICE_ID_AIM, NULL, 0);
+ galago_service_register_status(aim_service,
+ galago_status_type_new_with_attributes(
+ GALAGO_STATUS_AVAILABLE, "available", "Available", TRUE,
+ galago_status_attr_new(GALAGO_STATUS_ATTR_MESSAGE, NULL,
+ G_TYPE_STRING)));
+ galago_service_register_status(aim_service,
+ galago_status_type_new_with_attributes(
+ GALAGO_STATUS_AWAY, "away", "Away", TRUE,
+ galago_status_attr_new(GALAGO_STATUS_ATTR_MESSAGE, NULL,
+ G_TYPE_STRING)));
+
jabber_service = galago_create_service(GALAGO_SERVICE_ID_JABBER, NULL, 0);
+ galago_service_register_status(jabber_service,
+ galago_status_type_new(GALAGO_STATUS_OFFLINE, "offline", "Offline",
+ TRUE));
+ galago_service_register_status(jabber_service,
+ galago_status_type_new(GALAGO_STATUS_AVAILABLE, "available",
+ "Available", TRUE));
/* Create our local person */
me = galago_get_me(GALAGO_LOCAL, FALSE);
@@ -45,13 +62,14 @@
account = galago_service_create_account(aim_service, me, "GalagoAIMUser");
presence = galago_account_create_presence(account);
+ value = g_new0(GValue, 1);
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, "I'm eating dinner.");
+
galago_presence_set_idle(presence, TRUE, time(NULL));
+ galago_presence_enable_status(presence, "away",
+ GALAGO_STATUS_ATTR_MESSAGE, value);
- status = galago_status_new(GALAGO_STATUS_AWAY, "away", "Away", TRUE);
- galago_object_set_attr_string(GALAGO_OBJECT(status), "message",
- "I'm eating dinner.");
- galago_presence_add_status(presence, status);
-
/* Add contacts to our AIM account */
person = galago_create_person("gonkulator-1");
contact = galago_service_create_account(aim_service, person, "lottabs2");
@@ -68,32 +86,22 @@
account = galago_service_create_account(jabber_service, me,
"jabberuser at galago.sf.net");
presence = galago_account_create_presence(account);
+ galago_presence_enable_status(presence, "available", NULL, NULL);
- status = galago_status_new(GALAGO_STATUS_AVAILABLE, "available",
- "Available", TRUE);
-
- galago_presence_add_status(presence, status);
-
/* Add contacts to our Jabber account */
person = galago_create_person(NULL);
contact = galago_service_create_account(jabber_service, person,
"caedan at jabber.org");
presence = galago_account_create_presence(contact);
+ galago_presence_enable_status(presence, "available", NULL, NULL);
- status = galago_status_new(GALAGO_STATUS_AVAILABLE, "available",
- "Available", TRUE);
- galago_presence_add_status(presence, status);
-
galago_account_add_contact(account, contact);
contact = galago_service_create_account(jabber_service, person,
"caelum at chipx86.com");
presence = galago_account_create_presence(contact);
+ galago_presence_enable_status(presence, "offline", NULL, NULL);
- status = galago_status_new(GALAGO_STATUS_OFFLINE, "offline", "Offline",
- TRUE);
- galago_presence_add_status(presence, status);
-
galago_account_add_contact(account, contact);
}
More information about the galago-commits
mailing list