? _darcs ? help/sv ? protocols/telepathy/.gossip-telepathy.c.swp ? protocols/telepathy/gossip-telepathy-groups.c ? protocols/telepathy/gossip-telepathy-groups.h Index: protocols/telepathy/Makefile.am =================================================================== RCS file: /cvs/gnome/gossip/protocols/telepathy/Attic/Makefile.am,v retrieving revision 1.1.2.6 diff -u -p -r1.1.2.6 Makefile.am --- protocols/telepathy/Makefile.am 7 Oct 2006 01:50:58 -0000 1.1.2.6 +++ protocols/telepathy/Makefile.am 6 Nov 2006 23:28:06 -0000 @@ -16,6 +16,8 @@ libgossip_telepathy_la_SOURCES = gossip-telepathy-message.h \ gossip-telepathy-contact-list.c \ gossip-telepathy-contact-list.h \ + gossip-telepathy-groups.c \ + gossip-telepathy-groups.h \ gossip-telepathy-cmgr.c \ gossip-telepathy-cmgr.h \ gossip-telepathy-presence.c \ Index: protocols/telepathy/gossip-telepathy-private.h =================================================================== RCS file: /cvs/gnome/gossip/protocols/telepathy/Attic/gossip-telepathy-private.h,v retrieving revision 1.1.2.7 diff -u -p -r1.1.2.7 gossip-telepathy-private.h --- protocols/telepathy/gossip-telepathy-private.h 10 Oct 2006 01:30:47 -0000 1.1.2.7 +++ protocols/telepathy/gossip-telepathy-private.h 6 Nov 2006 23:28:06 -0000 @@ -37,6 +37,7 @@ GossipContact * gossip_telepathy_get_c gboolean get_vcard); DBusGProxy * gossip_telepathy_iface_presence (GossipTelepathy *telepathy); DBusGProxy * gossip_telepathy_iface_aliasing (GossipTelepathy *telepathy); +DBusGProxy * gossip_telepathy_iface_avatars (GossipTelepathy *telepathy); TelepathyListType gossip_telepathy_get_list_type (GossipTelepathy *telepathy, TpChan *list_chan); Index: protocols/telepathy/gossip-telepathy.c =================================================================== RCS file: /cvs/gnome/gossip/protocols/telepathy/Attic/gossip-telepathy.c,v retrieving revision 1.1.2.28 diff -u -p -r1.1.2.28 gossip-telepathy.c --- protocols/telepathy/gossip-telepathy.c 31 Oct 2006 18:26:51 -0000 1.1.2.28 +++ protocols/telepathy/gossip-telepathy.c 6 Nov 2006 23:28:06 -0000 @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -219,8 +220,12 @@ static void telepathy_rename static void telepathy_contact_rename (GossipProtocol *protocol, GossipContact *contact, const gchar *new_name); - - +/* +static void telepathy_avatars_handler (DBusGProxy *proxy, + guint handle, + gchar *new_token, + GossipTelepathy *telepathy); +*/ /* chatrooms */ static void telepathy_chatroom_init (GossipChatroomProviderIface *iface); static GossipChatroomId telepathy_chatroom_join (GossipChatroomProvider *provider, @@ -787,6 +792,7 @@ static void telepathy_connection_setup ( GossipTelepathyPriv *priv; DBusGProxy *presence_iface = NULL; DBusGProxy *aliasing_iface = NULL; +/* DBusGProxy *avatars_iface = NULL;*/ gchar **ifaces = NULL; GError *error = NULL; @@ -833,6 +839,18 @@ static void telepathy_connection_setup ( (telepathy_renamed_handler), telepathy, NULL); } + /* + avatars_iface = + gossip_telepathy_iface_avatars (telepathy); + + if (avatars_iface) { + dbus_g_proxy_connect_signal (DBUS_G_PROXY (avatars_iface), + "AvatarUpdated", + G_CALLBACK + (telepathy_avatars_handler), + telepathy, NULL); + } + */ } void @@ -935,7 +953,42 @@ telepathy_renamed_handler (DBusGProxy } } - +/* +static void +telepathy_avatars_handler (DBusGProxy *proxy, + guint handle, + gchar *new_token, + GossipTelepathy *telepathy) +{ + GossipContact *contact; + GArray *avatar_data; + gchar *mime_type; + GError *error = NULL; + + if (!tp_conn_iface_avatars_request_avatar (proxy, + handle, + &avatar_data, &mime_type, + &error)) + { + gossip_debug (DEBUG_DOMAIN, "Error requesting avatar %d: %s", handle, error->message); + g_clear_error (&error); + return; + } + + contact = gossip_telepathy_get_contact_from_handle (telepathy, + handle, + NULL, + FALSE); + gossip_contact_set_avatar (contact, avatar_data->data, avatar_data->len); + + g_signal_emit_by_name (telepathy, "contact-updated", contact); + + gossip_debug (DEBUG_DOMAIN, "Changing avatar for %d to %s", handle, new_token); + + g_array_free (avatar_data, TRUE); + g_free (mime_type); +} +*/ static void telepathy_logout (GossipProtocol *protocol) { @@ -1001,6 +1054,25 @@ gossip_telepathy_iface_aliasing (GossipT return aliasing_iface; } +DBusGProxy * +gossip_telepathy_iface_avatars (GossipTelepathy *telepathy) +{ + GossipTelepathyPriv *priv; + DBusGProxy *avatars_iface; + + priv = GET_PRIV (telepathy); + + avatars_iface = + tp_conn_get_interface (TELEPATHY_CONN (priv->tp_conn), + TELEPATHY_CONN_IFACE_AVATARS_QUARK); + + if (avatars_iface == NULL) { + g_warning ("Could not get the avatars interface"); + } + + return avatars_iface; +} + static void telepathy_logged_out (GossipTelepathy *telepathy, GossipDisconnectReason reason) @@ -1500,6 +1572,90 @@ telepathy_get_version (GossipProtocol return TRUE; } +static void +gossip_telepathy_groups_members_changed_handler (DBusGProxy *proxy, + gchar *message, + GArray *added, GArray *removed + GArray *local_pending, GArray *remote_pending, + guint actor, TelepathyChannelGroupChangeReason reason, + GossipTelepathy *telepathy) +{ + +} + +static void +gossip_telepathy_handle_server_side_group (GossipTelepathy *telepathy, + guint channel_handle, + TpChan *group_channel) +{ + GossipTelepathyPriv *priv; + DBusGProxy *group_iface; + GArray *group_handles; + gchar **group_names; + GArray *members; + GArray *local_pending; + GArray *remote_pending; + GError *error = NULL; + guint i; + + priv = GET_PRIV (telepathy); + + group_handles = g_array_new (FALSE, FALSE, sizeof (gint)); + g_array_append_val (group_handles, channel_handle); + + if (!tp_conn_inspect_handles (DBUS_G_PROXY (priv->tp_conn), + TP_CONN_HANDLE_TYPE_GROUP, group_handles, + &group_names, &error)) + { + g_warning ("Couldn't get server-side group name"); + g_clear_error (&error); + return; + } + + group_iface = + tp_chan_get_interface (group_channel, + TELEPATHY_CHAN_IFACE_GROUP_QUARK); + + if (group_iface == NULL) { + g_warning ("Could not get the presence interface"); + return; + } + + dbus_g_proxy_connect_signal (DBUS_G_PROXY (group_iface), + "MembersChanged", + G_CALLBACK + (gossip_telepathy_groups_members_changed_handler), + telepathy, NULL); + + if (!tp_chan_iface_group_get_all_members (group_iface, + &members, + &local_pending, + &remote_pending, + &error)) + { + g_warning ("Couldn't get members"); + g_clear_error (&error); + return; + } + + for (i=0; ilen; i++) + { + GList *groups; + guint handle = g_array_index (members, guint, i); + GossipContact *contact = + gossip_telepathy_get_contact_from_handle (telepathy, + handle, + NULL, + FALSE); + g_warning("Group name: %s, contact=%d", group_names[0], handle); + + groups = gossip_contact_get_groups (contact); + groups = g_list_append (groups, group_names[0]); + gossip_contact_set_groups (contact, groups); + } + +} + /* * Telepathy specifics */ @@ -1553,7 +1709,7 @@ telepathy_newchannel_cb (DBusGProxy new_chan->handle_type, dbus_g_proxy_get_path (DBUS_G_PROXY (new_chan))); - if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) == 0) { + if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) == 0 && handle_type == TP_CONN_HANDLE_TYPE_LIST) { TelepathyListType list_type; list_type = gossip_telepathy_get_list_type (telepathy, new_chan); @@ -1581,7 +1737,10 @@ telepathy_newchannel_cb (DBusGProxy default: g_object_unref (G_OBJECT (new_chan)); } - } else if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT) == 0) { + } else if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) == 0 && handle_type == TP_CONN_HANDLE_TYPE_GROUP) { + gossip_debug (DEBUG_DOMAIN, "**Server-Side group Channel**", object_path); + gossip_telepathy_handle_server_side_group (telepathy, channel_handle, new_chan); + } else if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT) == 0 && handle_type == TP_CONN_HANDLE_TYPE_CONTACT) { gossip_debug (DEBUG_DOMAIN, "**Text Channel**", object_path); @@ -1659,6 +1818,7 @@ gossip_telepathy_get_contact_from_handle if (!contact) { gchar **contact_names; DBusGProxy *aliasing_iface; +/* DBusGProxy *avatars_iface;*/ GError *error = NULL; gossip_debug (DEBUG_DOMAIN, "New contact:'%s'", *handle_name); @@ -1684,7 +1844,28 @@ gossip_telepathy_get_contact_from_handle } else { gossip_contact_set_name (contact, *handle_name); } - + /* + avatars_iface = + gossip_telepathy_iface_avatars (telepathy); + + if (avatars_iface) { + GArray *avatar_data; + gchar *mime_type; + GError *error = NULL; + if(tp_conn_iface_avatars_request_avatar(avatars_iface, + handle, + &avatar_data, &mime_type, + &error)) { + gossip_debug (DEBUG_DOMAIN, "Avatar Received"); + gossip_contact_set_avatar (contact, avatar_data->data, avatar_data->len); + g_array_free (avatar_data, TRUE); + g_free (mime_type); + } else { + gossip_debug (DEBUG_DOMAIN, "Could not get avatar:'%s'", error->message); + g_clear_error (&error); + } + } + */ tmp_new_item = TRUE; g_hash_table_insert (priv->contacts,