- (void)contact: (XMPPContact*)contact
didSendPresence: (XMPPPresence*)presence
{
+ OFDictionary *allPresences = [contact presences];
+ XMPPPresence *highPresence = [[[allPresences allObjects] sortedArray]
+ lastObject];
+ OFMutableString *tooltip =
+ [OFMutableString stringWithString: @"<b>Resources:</b>"];
+
+ [allPresences enumerateKeysAndObjectsUsingBlock:
+ ^(OFString *resource, XMPPPresence *pres, BOOL *stop) {
+ [tooltip appendString: @"\n"];
+ [tooltip appendString: resource];
+ if ([pres.type isEqual: @"available"]) {
+ if (pres.show != nil)
+ [tooltip appendFormat: @" (%@)", pres.show];
+ else
+ [tooltip appendString: @" (available)"];
+ } else
+ [tooltip appendString: @" (unavailable)"];
+
+ if (pres.status)
+ [tooltip appendFormat: @": <i>%@</i>", pres.status];
+ }];
+
g_idle_add_block(^{
GtkTreeIter iter;
GtkTreePath *path;
&iter, path);
gtk_tree_path_free(path);
- if ([presence.type isEqual: @"available"])
- if (presence.show != nil)
+ if ([highPresence.type isEqual: @"available"]) {
+ if (highPresence.show != nil)
gtk_tree_store_set(roster_model, &iter,
- 2, [presence.show UTF8String], -1);
+ 2, [highPresence.show UTF8String],
+ -1);
else
gtk_tree_store_set(roster_model, &iter,
2, "available", -1);
- else if ([presence.type isEqual: @"unavailable"])
+ } else
gtk_tree_store_set(roster_model, &iter,
2, "unavailable", -1);
gtk_tree_store_set(roster_model, &iter,
- 3, [presence.status UTF8String], -1);
+ 3, [tooltip UTF8String], -1);
}
gtk_tree_model_filter_refilter(roster_filter);