ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/src edit_contact_window.c,1.11,1.12 util.c,1


From: Colin Leroy <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/src edit_contact_window.c,1.11,1.12 util.c,1.31,1.32
Date: Wed, 29 Jan 2003 05:41:46 -0500

Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv30894/src

Modified Files:
        edit_contact_window.c util.c 
Log Message:
bugfix



Index: edit_contact_window.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/edit_contact_window.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- edit_contact_window.c       24 Jan 2003 20:41:31 -0000      1.11
+++ edit_contact_window.c       29 Jan 2003 10:41:43 -0000      1.12
@@ -47,8 +47,13 @@
 static void ok_callback( GtkWidget * widget, gpointer data )
 {
        gint service_id = 
get_service_id(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_list)->entry)));
+       grouplist *g = my_contact->group;
+       
         /* Rename log if logging is enabled */
        rename_contact(my_contact, gtk_entry_get_text(GTK_ENTRY(nick)));
+       /* contact may have changed... */
+       my_contact = 
find_contact_in_group_by_nick(gtk_entry_get_text(GTK_ENTRY(nick)), g);
+               
        my_contact->default_chatb = service_id;
        my_contact->default_filetransb = service_id;
        

Index: util.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/util.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- util.c      29 Jan 2003 09:52:40 -0000      1.31
+++ util.c      29 Jan 2003 10:41:43 -0000      1.32
@@ -1365,31 +1365,47 @@
        mid->callback(ecd);
 }
 
-/* FIXME There are bugs here if another contact with the same name 
-   already exists in the same group */
 void rename_contact( struct contact * c, char *newname) 
 {
        LList *l = NULL;
-        rename_nick_log(c->group->name, c->nick, c->group->name, newname);
-        strncpy(c->nick, newname, 254);
-        c->nick[254] = '\0';
-       if (c->label)
-               gtk_label_set_text(GTK_LABEL(c->label), newname);
+       struct contact *con;
        
-       l = c->accounts;
-       while(l) {
-               eb_account *ea = l->data;
-
-               if (RUN_SERVICE(ea)->change_user_name) {
-                       if (!find_suitable_local_account(NULL, ea->service_id))
-                               contact_mgmt_queue_add(ea, MGMT_REN, newname);
-                       else
-                               RUN_SERVICE(ea)->change_user_name(ea, newname);
+       eb_debug(DBG_CORE,"Renaming %s to %s\n",c->nick, newname);
+       con = find_contact_in_group_by_nick(newname, c->group);
+       if(con) {
+               eb_debug(DBG_CORE,"found existing contact\n");
+               rename_nick_log(c->group->name, c->nick, c->group->name, 
con->nick);
+               l = c->accounts;
+               while(l) {
+                       eb_account *ea = l->data;
+                       move_account(con,ea);
+                       l = c->accounts;
                }
+               update_contact_list ();
+               write_contact_list();
+               
+       } else {
+               eb_debug(DBG_CORE,"no existing contact\n");
+
+               rename_nick_log(c->group->name, c->nick, c->group->name, 
newname);
+               strncpy(c->nick, newname, 254);
+               c->nick[254] = '\0';
+               if (c->label)
+                       gtk_label_set_text(GTK_LABEL(c->label), newname);
+               l = c->accounts;
+               while(l) {
+                       eb_account *ea = l->data;
+
+                       if (RUN_SERVICE(ea)->change_user_name) {
+                               if (!find_suitable_local_account(NULL, 
ea->service_id))
+                                       contact_mgmt_queue_add(ea, MGMT_REN, 
newname);
+                               else
+                                       RUN_SERVICE(ea)->change_user_name(ea, 
newname);
+                       }
 
-               l = l->next;
+                       l = l->next;
+               }
        }
-       
        update_contact_list ();
        write_contact_list();
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]