Mercurial > pidgin.yaz
comparison libpurple/protocols/irc/msgs.c @ 22958:f1dfc0d70d19
Fix irc nick collision handling, as requested by that demanding user elb.
Now we append the extra digit, unless the server responds with a shorter
nick than we requested, in which case we just change the last digit as
before.
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 15 May 2008 15:22:04 +0000 |
parents | f09acca60066 |
children | f47438e456c2 |
comparison
equal
deleted
inserted
replaced
22957:a84b748c4c1e | 22958:f1dfc0d70d19 |
---|---|
935 PurpleConnection *gc = purple_account_get_connection(irc->account); | 935 PurpleConnection *gc = purple_account_get_connection(irc->account); |
936 PurpleConversation *conv; | 936 PurpleConversation *conv; |
937 GSList *chats; | 937 GSList *chats; |
938 char *nick = irc_mask_nick(from); | 938 char *nick = irc_mask_nick(from); |
939 | 939 |
940 irc->nickused = FALSE; | |
941 | |
940 if (!gc) { | 942 if (!gc) { |
941 g_free(nick); | 943 g_free(nick); |
942 return; | 944 return; |
943 } | 945 } |
944 chats = gc->buddy_chats; | 946 chats = gc->buddy_chats; |
983 char *newnick, *buf, *end; | 985 char *newnick, *buf, *end; |
984 | 986 |
985 if (!args || !args[1]) | 987 if (!args || !args[1]) |
986 return; | 988 return; |
987 | 989 |
988 newnick = g_strdup(args[1]); | 990 if (strlen(args[1]) < strlen(irc->reqnick) || irc->nickused) |
991 newnick = g_strdup(args[1]); | |
992 else | |
993 newnick = g_strdup_printf("%s0", args[1]); | |
989 end = newnick + strlen(newnick) - 1; | 994 end = newnick + strlen(newnick) - 1; |
990 /* try fallbacks */ | 995 /* try fallbacks */ |
991 if((*end < '9') && (*end >= '1')) { | 996 if((*end < '9') && (*end >= '1')) { |
992 *end = *end + 1; | 997 *end = *end + 1; |
993 } else *end = '1'; | 998 } else *end = '1'; |
994 | 999 |
1000 g_free(irc->reqnick); | |
1001 irc->reqnick = newnick; | |
1002 irc->nickused = TRUE; | |
1003 | |
995 buf = irc_format(irc, "vn", "NICK", newnick); | 1004 buf = irc_format(irc, "vn", "NICK", newnick); |
996 irc_send(irc, buf); | 1005 irc_send(irc, buf); |
997 g_free(buf); | 1006 g_free(buf); |
998 g_free(newnick); | |
999 } | 1007 } |
1000 | 1008 |
1001 void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | 1009 void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) |
1002 { | 1010 { |
1003 if (!args || !args[0] || !args[1]) | 1011 if (!args || !args[0] || !args[1]) |