#import <ObjXMPP/namespaces.h>
#include <string.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#import "JubGtkRosterUI.h"
#import "JubGObjectMap.h"
_client = [client retain];
[_client.contactManager addDelegate: self];
+ [_client.avatarManager setDelegate: self];
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "data/gtk/roster.ui", NULL);
- (void)dealloc
{
+ [_client.avatarManager setDelegate: nil];
[_client.contactManager removeDelegate: self];
[_groupMap release];
[_contactMap release];
});
}
+- (void)contact: (XMPPContact*)contact
+ didSetAvatar: (OFString*)avatarFile
+{
+ of_log(@"Got an avatar from %@", contact.rosterItem.JID);
+ g_idle_add_block(^{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeRowReference *ref;
+ OFString *bareJID = [contact.rosterItem.JID bareJID];
+ OFMapTable *contactRows = [_contactMap objectForKey: bareJID];
+ OFArray *groups = contact.rosterItem.groups;;
+
+ GdkPixbuf *avatar =
+ gdk_pixbuf_new_from_file([avatarFile UTF8String], NULL);
+
+ if (groups == nil)
+ groups = @[ @"General" ];
+
+ for (OFString *group in groups) {
+ ref = [contactRows valueForKey: group];
+ path = gtk_tree_row_reference_get_path(ref);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model),
+ &iter, path);
+ gtk_tree_path_free(path);
+
+ gtk_tree_store_set(_roster_model, &iter,
+ 4, avatar, -1);
+ }
+ g_object_unref(G_OBJECT(avatar));
+ });
+}
+
- (void)client: (JubChatClient*)client_
didChangePresence: (XMPPPresence*)presence
{