<column type="gchararray"/>
<!-- column-name jid -->
<column type="gchararray"/>
+ <!-- column-name status -->
+ <column type="gchararray"/>
</columns>
</object>
<object class="GtkTreeModelFilter" id="RosterTreeModelFilter">
</child>
<child>
<object class="GtkTreeViewColumn" id="RosterTreeViewColumn1">
- <property name="title" translatable="yes">Name</property>
+ <property name="title" translatable="yes">Status</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
- <attribute name="text">0</attribute>
+ <attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="RosterTreeViewColumn2">
- <property name="title" translatable="yes">JID</property>
+ <property name="title" translatable="yes">Name</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
- <attribute name="text">1</attribute>
+ <attribute name="text">0</attribute>
</attributes>
</child>
</object>
static gboolean filter_roster_by_presence(GtkTreeModel *model,
GtkTreeIter *iter, gpointer data)
{
- char *jid_s;
- OFString *jid;
- OFCountedSet *presences = data;
+ char *status;
+ gtk_tree_model_get(model, iter, 2, &status, -1);
- gtk_tree_model_get(model, iter, 1, &jid_s, -1);
-
- // Groups have no JID
- if (!jid_s)
+ // Groups have no status
+ if (!status)
return TRUE;
- jid = [[OFString alloc] initWithUTF8String: jid_s];
-
- g_free(jid_s);
-
- int num = [presences countForObject: jid];
- if (num) {
- [jid release];
- return TRUE;
- } else {
- [jid release];
+ if (!strcmp(status, "unavailable"))
return FALSE;
- }
+
+ return TRUE;
}
@implementation JubGtkRosterUI
valueFunctions: rowRefFunctions];
contactMap = [[OFMutableDictionary alloc] init];
chatMap = [[OFMutableDictionary alloc] init];
- presences = [[OFCountedSet alloc] init];
client = [client_ retain];
[client.contactManager addDelegate: self];
gtk_builder_get_object(builder, "RosterTreeModelFilter"));
gtk_tree_model_filter_set_visible_func(roster_filter,
- filter_roster_by_presence, presences, NULL);
+ filter_roster_by_presence, NULL, NULL);
roster_view = GTK_TREE_VIEW(gtk_builder_get_object(builder,
"RosterTreeView"));
[groupMap release];
[contactMap release];
[chatMap release];
- [presences release];
[client release];
gtk_widget_destroy(roster_window);
if (item.name)
gtk_tree_store_set(roster_model, &contact_iter,
0, [item.name UTF8String],
- 1, [bareJID UTF8String], -1);
+ 1, [bareJID UTF8String],
+ 2, "unavailable", -1);
else
gtk_tree_store_set(roster_model, &contact_iter,
0, [item.JID.node UTF8String],
- 1, [bareJID UTF8String], -1);
+ 1, [bareJID UTF8String],
+ 2, "unavailable", -1);
contact_path = gtk_tree_model_get_path(GTK_TREE_MODEL(
roster_model), &contact_iter);
contact_path = gtk_tree_row_reference_get_path(contact_ref);
gtk_tree_model_get_iter(GTK_TREE_MODEL(roster_model),
&contact_iter, contact_path);
+ gtk_tree_path_free(contact_path);
gtk_tree_store_remove(roster_model, &contact_iter);
- (void)contact: (XMPPContact*)contact
didSendPresence: (XMPPPresence*)presence
{
- if ([presence.type isEqual: @"available"])
- [presences addObject: [presence.from bareJID]];
- else if ([presence.type isEqual: @"unavailable"])
- [presences removeObject: [presence.from bareJID]];
-
g_idle_add_block(^{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeRowReference *ref;
+ OFString *bareJID = [contact.rosterItem.JID bareJID];
+ OFMapTable *contactRows = [contactMap objectForKey: bareJID];
+
+ for (OFString *group in contact.rosterItem.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);
+
+ if ([presence.type isEqual: @"available"])
+ if (presence.show != nil)
+ gtk_tree_store_set(roster_model, &iter,
+ 2, [presence.show UTF8String], -1);
+ else
+ gtk_tree_store_set(roster_model, &iter,
+ 2, "available", -1);
+ else if ([presence.type isEqual: @"unavailable"])
+ gtk_tree_store_set(roster_model, &iter,
+ 2, "unavailable", -1);
+ }
+
gtk_tree_model_filter_refilter(roster_filter);
});
}