]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/gui/gtk/JubGtkRosterUI.m
Use nodepart in roster, if no other name exists
[jubjub.git] / src / gui / gtk / JubGtkRosterUI.m
index 9a2da292a1f68075d0f02e176e2bf0c9efd9b4bb..06ffd28b4edf8523c919bb01d20f6c4a6c5fbcc8 100644 (file)
@@ -100,26 +100,31 @@ static gboolean refilter_roster(gpointer data)
 -  (void)connection: (XMPPConnection*)connection
   didReceiveMessage: (XMPPMessage*)message
 {
-       JubGtkChatUI *chat = [chatMap objectForKey: [message.from bareJID]];
+       JubGtkChatUI *chat =
+           [chatMap objectForKey: [message.from bareJID]];
        if (chat == nil) {
                OFString * title = [@"Chat with " stringByAppendingString:
                    [message.from bareJID]];
-               chat = [JubGtkChatUI alloc];
-               [[chat initWithTitle: title
-                          sendBlock: ^(OFString *text) {
-                       XMPPMessage *msg =
-                           [XMPPMessage messageWithType: @"chat"];
-                       msg.to = message.from;
-                       msg.body = text;
-                       [connection sendStanza: msg];
-
-                       [chat addMessage: msg.body
-                                 sender: [message.to bareJID]];
-               }] autorelease];
+
+               chat = [[[JubGtkChatUI alloc]
+                   initWithTitle: title
+                      closeBlock: ^{
+                               [chatMap removeObjectForKey:
+                                   [message.from bareJID]];
+                       }
+                       sendBlock: ^(OFString *text) {
+                               XMPPMessage *msg =
+                                   [XMPPMessage messageWithType: @"chat"];
+                               msg.to = message.from;
+                               msg.body = text;
+                               [connection sendStanza: msg];
+                       }
+               ] autorelease];
 
                [chatMap setObject: chat
                            forKey: [message.from bareJID]];
        }
+
        [chat addMessage: message.body
                  sender: [message.from bareJID]];
 }
@@ -128,7 +133,7 @@ static gboolean refilter_roster(gpointer data)
 struct add_roster_item_param {
        OFString *group;
        OFString *name;
-       OFString *jid;
+       XMPPJID *jid;
        OFMapTable *groupMap;
        OFMapTable *contactRows;
        GtkTreeStore *roster_model;
@@ -168,8 +173,14 @@ static gboolean add_roster_item(gpointer user_data)
 
        // Create new contact row
        gtk_tree_store_append(params->roster_model, &contact_iter, &group_iter);
-       gtk_tree_store_set(params->roster_model, &contact_iter,
-           0, [params->name UTF8String], 1, [params->jid UTF8String], -1);
+       if (params->name)
+               gtk_tree_store_set(params->roster_model, &contact_iter,
+                   0, [params->name UTF8String],
+                   1, [[params->jid bareJID] UTF8String], -1);
+       else
+               gtk_tree_store_set(params->roster_model, &contact_iter,
+                   0, [params->jid.node UTF8String],
+                   1, [[params->jid bareJID] UTF8String], -1);
 
        contact_path = gtk_tree_model_get_path(GTK_TREE_MODEL(
                params->roster_model), &contact_iter);
@@ -259,7 +270,7 @@ static gboolean remove_roster_item(gpointer user_data)
                            malloc(sizeof(*params));
                        params->group = [group retain];
                        params->name = [item.name retain];
-                       params->jid = [bareJID retain];
+                       params->jid = [item.JID retain];
                        params->groupMap = [groupMap retain];
                        params->contactRows = [contactRows retain];
                        params->roster_model = g_object_ref(roster_model);
@@ -313,7 +324,7 @@ static gboolean remove_roster_item(gpointer user_data)
                            malloc(sizeof(*params));
                        params->group = [group retain];
                        params->name = [item.name retain];
-                       params->jid = [[item.JID bareJID] retain];
+                       params->jid = [item.JID retain];
                        params->groupMap = [groupMap retain];
                        params->contactRows = [contactRows retain];
                        params->roster_model = g_object_ref(roster_model);