[Galago-commits] r2844 - in trunk/libgalago: . libgalago
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Mon Jun 12 19:57:21 PDT 2006
Author: chipx86
Date: 2006-06-12 19:57:17 -0700 (Mon, 12 Jun 2006)
New Revision: 2844
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-account.c
trunk/libgalago/libgalago/galago-account.h
trunk/libgalago/libgalago/galago-service.c
Log:
Added galago_account_get_avatar_async().
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-06-13 02:55:07 UTC (rev 2843)
+++ trunk/libgalago/ChangeLog 2006-06-13 02:57:17 UTC (rev 2844)
@@ -1,3 +1,10 @@
+Mon Jun 12 19:56:47 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-account.c:
+ * libgalago/galago-account.h:
+ * libgalago/galago-service.c:
+ - Added galago_account_get_avatar_async().
+
Mon Jun 12 19:54:14 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-presence.c:
Modified: trunk/libgalago/libgalago/galago-account.c
===================================================================
--- trunk/libgalago/libgalago/galago-account.c 2006-06-13 02:55:07 UTC (rev 2843)
+++ trunk/libgalago/libgalago/galago-account.c 2006-06-13 02:57:17 UTC (rev 2844)
@@ -1152,24 +1152,95 @@
GalagoImage *
galago_account_get_avatar(const GalagoAccount *account, gboolean query)
{
+ GalagoImage *avatar;
+
g_return_val_if_fail(account != NULL, NULL);
g_return_val_if_fail(GALAGO_IS_ACCOUNT(account), NULL);
- if (account->priv->avatar == NULL && query &&
- GALAGO_OBJECT_IS_REMOTE(account) && !galago_is_daemon() &&
- galago_is_connected())
+ avatar = account->priv->avatar;
+
+ if (avatar == NULL && query && GALAGO_OBJECT_IS_REMOTE(account) &&
+ !galago_is_daemon() && galago_is_connected())
{
- account->priv->avatar =
- galago_dbus_send_message_with_reply(GALAGO_OBJECT(account),
- "GetAvatar",
- galago_value_new_object(GALAGO_TYPE_IMAGE, NULL),
- NULL);
- g_object_notify(G_OBJECT(account), "avatar");
+ avatar = galago_dbus_send_message_with_reply(GALAGO_OBJECT(account),
+ "GetAvatar",
+ galago_value_new_object(GALAGO_TYPE_IMAGE, NULL),
+ NULL);
}
- return account->priv->avatar;
+ return avatar;
}
+/**
+ * galago_account_get_avatar_async
+ * @account: The account.
+ * @cb: The callback function that will be passed the avatar.
+ * @user_data: Custom data to pass to the callback function.
+ * @free_func: Optional function to free @user_data when the request completes.
+ *
+ * Asynchronously retrieves the avatar associated with the specified
+ * account.
+ *
+ * For example:
+ * <informalexample>
+ * <programlisting>
+ * static void
+ * avatar_received_cb(GalagoAccount *account,
+ * GalagoAvatar *avatar,
+ * gpointer user_data)
+ * {
+ * }
+ *
+ * static void
+ * get_avatar(GalagoAccount *account)
+ * {
+ * GalagoCallHandle handle;
+ *
+ * handle = galago_account_get_avatar_async(account,
+ * avatar_received_cb,
+ * NULL, NULL);
+ * }
+ * </programlisting>
+ * </informalexample>
+ *
+ * Returns: A valid #GalagoCallHandle on success. On error, this will return
+ * %GALAGO_CALL_HANDLE_INVALID.
+ *
+ * Since: 0.5.2
+ */
+GalagoCallHandle
+galago_account_get_avatar_async(const GalagoAccount *account,
+ GalagoAccountAvatarCb cb,
+ gpointer user_data,
+ GFreeFunc free_func)
+{
+ GalagoImage *avatar;
+ GalagoCallHandle handle = GALAGO_CALL_HANDLE_INVALID;
+
+ g_return_val_if_fail(account != NULL, handle);
+ g_return_val_if_fail(GALAGO_IS_ACCOUNT(account), handle);
+ g_return_val_if_fail(cb != NULL, handle);
+
+ avatar = galago_account_get_avatar(account, FALSE);
+
+ if (avatar != NULL)
+ {
+ cb((GalagoAccount *)account, avatar, user_data);
+ handle = galago_calls_request_dummy_handle();
+ }
+ else if (GALAGO_OBJECT_IS_REMOTE(account) && !galago_is_daemon() &&
+ galago_is_connected())
+ {
+ handle = galago_dbus_send_message_with_reply_async(
+ GALAGO_OBJECT(account), "GetAvatar", G_CALLBACK(cb),
+ user_data, free_func, g_cclosure_marshal_VOID__POINTER,
+ galago_value_new_object(GALAGO_TYPE_IMAGE, NULL),
+ NULL);
+ }
+
+ return handle;
+}
+
void
_galago_account_set_presence(GalagoAccount *account, GalagoPresence *presence)
{
Modified: trunk/libgalago/libgalago/galago-account.h
===================================================================
--- trunk/libgalago/libgalago/galago-account.h 2006-06-13 02:55:07 UTC (rev 2843)
+++ trunk/libgalago/libgalago/galago-account.h 2006-06-13 02:57:17 UTC (rev 2844)
@@ -33,6 +33,8 @@
typedef void (*GalagoAccountPresenceCb)(GalagoAccount *, GalagoPresence *,
gpointer);
+typedef void (*GalagoAccountAvatarCb)(GalagoAccount *, GalagoImage *,
+ gpointer);
struct _GalagoAccount
{
@@ -125,6 +127,11 @@
void galago_account_set_avatar(GalagoAccount *account, GalagoImage *avatar);
GalagoImage *galago_account_get_avatar(const GalagoAccount *account,
gboolean query);
+GalagoCallHandle galago_account_get_avatar_async(
+ const GalagoAccount *account,
+ GalagoAccountAvatarCb cb,
+ gpointer user_data,
+ GFreeFunc free_func);
G_END_DECLS
Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c 2006-06-13 02:55:07 UTC (rev 2843)
+++ trunk/libgalago/libgalago/galago-service.c 2006-06-13 02:57:17 UTC (rev 2844)
@@ -141,21 +141,24 @@
"The service flags",
GALAGO_TYPE_SERVICE_FLAGS, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(gobject_class, PROP_ID,
g_param_spec_string("id", "ID",
"The service's unique ID",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(gobject_class, PROP_NAME,
g_param_spec_string("name", "Name",
"The service's name",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
}
static void
More information about the galago-commits
mailing list