- (void)Jub_addRosterItem: (XMPPRosterItem*)item
group: (OFString*)group
{
- g_idle_add_block(^{
- GtkTreeIter group_iter, contact_iter;
- GtkTreeRowReference *group_ref, *contact_ref;
- GtkTreePath *group_path, *contact_path;
- OFString *bareJID = [item.JID bareJID];
- OFMapTable *contactRows;
-
- if (!(contactRows = [_contactMap objectForKey: bareJID])) {
- contactRows = [OFMapTable
- mapTableWithKeyFunctions: keyFunctions
- valueFunctions: rowRefFunctions];
-
- [_contactMap setObject: contactRows
- forKey: bareJID];
- }
-
- group_ref = [_groupMap valueForKey: group];
-
- if (!group_ref) {
- // Create new group row
- gtk_tree_store_append(_roster_model, &group_iter, NULL);
- gtk_tree_store_set(_roster_model, &group_iter,
- 0, [group UTF8String], -1);
-
- group_path = gtk_tree_model_get_path(GTK_TREE_MODEL(
- _roster_model), &group_iter);
-
- group_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(
- _roster_model), group_path);
+ GtkTreeIter group_iter, contact_iter;
+ GtkTreeRowReference *group_ref, *contact_ref;
+ GtkTreePath *group_path, *contact_path;
+ OFString *bareJID = [item.JID bareJID];
+ OFMapTable *contactRows;
+
+ if (!(contactRows = [_contactMap objectForKey: bareJID])) {
+ contactRows = [OFMapTable
+ mapTableWithKeyFunctions: keyFunctions
+ valueFunctions: rowRefFunctions];
+
+ [_contactMap setObject: contactRows
+ forKey: bareJID];
+ }
- [_groupMap setValue: group_ref
- forKey: group];
- } else {
- // Get iter for existing group row
- group_path = gtk_tree_row_reference_get_path(group_ref);
+ group_ref = [_groupMap valueForKey: group];
- gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model),
- &group_iter, group_path);
- }
- gtk_tree_path_free(group_path);
-
- // Create new contact row
- gtk_tree_store_append(_roster_model, &contact_iter,
- &group_iter);
- if (item.name)
- gtk_tree_store_set(_roster_model, &contact_iter,
- 0, [item.name UTF8String],
- 1, [bareJID UTF8String],
- 2, "unavailable", -1);
- else if (item.JID.node)
- gtk_tree_store_set(_roster_model, &contact_iter,
- 0, [item.JID.node UTF8String],
- 1, [bareJID UTF8String],
- 2, "unavailable", -1);
- else
- gtk_tree_store_set(_roster_model, &contact_iter,
- 0, [item.JID.domain UTF8String],
- 1, [bareJID UTF8String],
- 2, "unavailable", -1);
+ if (!group_ref) {
+ // Create new group row
+ gtk_tree_store_append(_roster_model, &group_iter, NULL);
+ gtk_tree_store_set(_roster_model, &group_iter,
+ 0, [group UTF8String], -1);
- contact_path = gtk_tree_model_get_path(GTK_TREE_MODEL(
- _roster_model), &contact_iter);
+ group_path = gtk_tree_model_get_path(GTK_TREE_MODEL(
+ _roster_model), &group_iter);
- contact_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(
- _roster_model), contact_path);
+ group_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(
+ _roster_model), group_path);
- gtk_tree_path_free(contact_path);
+ [_groupMap setValue: group_ref
+ forKey: group];
+ } else {
+ // Get iter for existing group row
+ group_path = gtk_tree_row_reference_get_path(group_ref);
- [contactRows setValue: contact_ref
- forKey: group];
- });
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model),
+ &group_iter, group_path);
+ }
+ gtk_tree_path_free(group_path);
+
+ // Create new contact row
+ gtk_tree_store_append(_roster_model, &contact_iter, &group_iter);
+ if (item.name)
+ gtk_tree_store_set(_roster_model, &contact_iter,
+ 0, [item.name UTF8String],
+ 1, [bareJID UTF8String],
+ 2, "unavailable", -1);
+ else if (item.JID.node)
+ gtk_tree_store_set(_roster_model, &contact_iter,
+ 0, [item.JID.node UTF8String],
+ 1, [bareJID UTF8String],
+ 2, "unavailable", -1);
+ else
+ gtk_tree_store_set(_roster_model, &contact_iter,
+ 0, [item.JID.domain UTF8String],
+ 1, [bareJID UTF8String],
+ 2, "unavailable", -1);
+
+ contact_path = gtk_tree_model_get_path(GTK_TREE_MODEL(_roster_model),
+ &contact_iter);
+
+ contact_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(_roster_model),
+ contact_path);
+
+ gtk_tree_path_free(contact_path);
+
+ [contactRows setValue: contact_ref
+ forKey: group];
}
- (void)Jub_removeRosterItem: (XMPPRosterItem*)item
group: (OFString*)group
{
- g_idle_add_block(^{
- GtkTreeIter contact_iter, group_iter;
- GtkTreePath *contact_path, *group_path;
- GtkTreeRowReference *contact_ref, *group_ref;
- OFString *bareJID = [item.JID bareJID];
- OFMapTable *contactRows = [_contactMap objectForKey: bareJID];
-
- contact_ref = [contactRows valueForKey: group];
- 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);
-
- group_ref = [_groupMap valueForKey: group];
- group_path = gtk_tree_row_reference_get_path(group_ref);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model),
- &group_iter, group_path);
-
- if (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(
- _roster_model), &group_iter)) {
- gtk_tree_store_remove(_roster_model, &group_iter);
- [_groupMap removeValueForKey: group];
- }
+ GtkTreeIter contact_iter, group_iter;
+ GtkTreePath *contact_path, *group_path;
+ GtkTreeRowReference *contact_ref, *group_ref;
+ OFString *bareJID = [item.JID bareJID];
+ OFMapTable *contactRows = [_contactMap objectForKey: bareJID];
+
+ contact_ref = [contactRows valueForKey: group];
+ 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);
+
+ group_ref = [_groupMap valueForKey: group];
+ group_path = gtk_tree_row_reference_get_path(group_ref);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), &group_iter,
+ group_path);
+
+ if (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(_roster_model),
+ &group_iter)) {
+ gtk_tree_store_remove(_roster_model, &group_iter);
+ [_groupMap removeValueForKey: group];
+ }
- gtk_tree_path_free(group_path);
+ gtk_tree_path_free(group_path);
- [contactRows removeValueForKey: group];
- if([contactRows count] == 0)
- [_contactMap removeObjectForKey: bareJID];
- });
+ [contactRows removeValueForKey: group];
+ if([contactRows count] == 0)
+ [_contactMap removeObjectForKey: bareJID];
}
- (void)contactManager: (XMPPContactManager*)manager
groups = @[ @"General" ];
for (OFString *group in groups)
- [self Jub_addRosterItem: rosterItem
- group: group];
+ [self performSelectorOnGLibThread: @selector(
+ Jub_addRosterItem:group:)
+ withObject: rosterItem
+ withObject: group];
}
- (void)contactManager: (XMPPContactManager*)manager
groups = @[ @"General" ];
for (OFString *group in groups)
- [self Jub_removeRosterItem: rosterItem
- group: group];
+ [self performSelectorOnGLibThread: @selector(
+ Jub_removeRosterItem:group:)
+ withObject: rosterItem
+ withObject: group];
}
- (void)contact: (XMPPContact*)contact
groups = @[ @"General" ];
for (OFString *group in groups)
- [self Jub_removeRosterItem: oldItem
- group: group];
+ [self performSelectorOnGLibThread: @selector(
+ Jub_removeRosterItem:group:)
+ withObject: oldItem
+ withObject: group];
// Add contact to new set of groups
groups = rosterItem.groups;
groups = @[ @"General" ];
for (OFString *group in groups)
- [self Jub_addRosterItem: rosterItem
- group: group];
+ [self performSelectorOnGLibThread: @selector(
+ Jub_addRosterItem:group:)
+ withObject: rosterItem
+ withObject: group];
}
- (void)contact: (XMPPContact*)contact