Index: protocols/jabber/conference.c
===================================================================
--- protocols/jabber/conference.c	(revision 54f2f55f983f4b6bb8a58772bbd1137580e3307f)
+++ protocols/jabber/conference.c	(revision d06eabf19ec3f849d8bab22c13d43e4eba9a48ee)
@@ -160,4 +160,7 @@
 		imcb_chat_add_buddy( chat, bud->ext_jid );
 		if( s ) *s = '/';
+		
+		if( bud != jc->me )
+			imcb_buddy_nick_hint( ic, bud->ext_jid, bud->resource );
 	}
 	else if( type ) /* This only gets called if type is NULL or "unavailable" */
Index: protocols/jabber/iq.c
===================================================================
--- protocols/jabber/iq.c	(revision 54f2f55f983f4b6bb8a58772bbd1137580e3307f)
+++ protocols/jabber/iq.c	(revision d06eabf19ec3f849d8bab22c13d43e4eba9a48ee)
@@ -373,5 +373,9 @@
 					                           group->text : NULL );
 				
-				imcb_rename_buddy( ic, jid, name );
+				if( name )
+				{
+					imcb_rename_buddy( ic, jid, name );
+					imcb_buddy_nick_hint( ic, jid, name );
+				}
 			}
 			else if( strcmp( sub, "remove" ) == 0 )
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 54f2f55f983f4b6bb8a58772bbd1137580e3307f)
+++ protocols/nogaim.c	(revision d06eabf19ec3f849d8bab22c13d43e4eba9a48ee)
@@ -428,5 +428,4 @@
 {
 	user_t *u = user_findhandle( ic, handle );
-	char *s, newnick[MAX_NICK_LENGTH+1];
 	
 	if( !u || !realname ) return;
@@ -440,28 +439,32 @@
 		if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
 			imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
-		
-		if( !u->online && !nick_saved( ic->acc, handle ) )
-		{
-			/* Detect numeric handles: */
-			for( s = u->user; isdigit( *s ); s++ );
-			
-			if( *s == 0 )
-			{
-				/* If we reached the end of the string, it only contained numbers.
-				   Seems to be an ICQ# then, so hopefully realname contains
-				   something more useful. */
-				strcpy( newnick, realname );
-				
-				/* Some processing to make sure this string is a valid IRC nickname. */
-				nick_strip( newnick );
-				if( set_getbool( &ic->irc->set, "lcnicks" ) )
-					nick_lc( newnick );
-				
-				u->nick = g_strdup( newnick );
-			}
-		}
-	}
-}
-
+	}
+}
+
+/* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM
+   modules to suggest a nickname for a handle. */
+void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick )
+{
+	user_t *u = user_findhandle( ic, handle );
+	char newnick[MAX_NICK_LENGTH+1];
+	
+	if( !u->online && !nick_saved( ic->acc, handle ) )
+	{
+		/* Only do this if the person isn't online yet (which should
+		   be the case if we just added it) and if the user hasn't
+		   assigned a nickname to this buddy already. */
+		
+		strcpy( newnick, nick );
+		
+		/* Some processing to make sure this string is a valid IRC nickname. */
+		nick_strip( newnick );
+		if( set_getbool( &ic->irc->set, "lcnicks" ) )
+			nick_lc( newnick );
+		
+		nick_dedupe( ic->acc, handle, newnick );
+		
+		u->nick = g_strdup( newnick );
+	}
+}
 
 /* prpl.c */
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 54f2f55f983f4b6bb8a58772bbd1137580e3307f)
+++ protocols/nogaim.h	(revision d06eabf19ec3f849d8bab22c13d43e4eba9a48ee)
@@ -194,4 +194,5 @@
 G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle );
 G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname );
+G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick );
 
 /* Buddy activity */
Index: protocols/oscar/oscar.c
===================================================================
--- protocols/oscar/oscar.c	(revision 54f2f55f983f4b6bb8a58772bbd1137580e3307f)
+++ protocols/oscar/oscar.c	(revision d06eabf19ec3f849d8bab22c13d43e4eba9a48ee)
@@ -2022,4 +2022,5 @@
 					
 					if (realname) {
+						imcb_buddy_nick_hint(ic, curitem->name, realname);
 						imcb_rename_buddy(ic, curitem->name, realname);
 						g_free(realname);
