From ebaebfe35c82460581fa6db518d8848996c9a0f4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 26 Mar 2010 21:57:00 -0400 Subject: PING and QUIT work now, and adding some files that weren't checked in so far. --- irc_user.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 irc_user.c (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c new file mode 100644 index 00000000..d1f07bb6 --- /dev/null +++ b/irc_user.c @@ -0,0 +1,113 @@ + /********************************************************************\ + * BitlBee -- An IRC to other IM-networks gateway * + * * + * Copyright 2002-2004 Wilmer van der Gaast and others * + \********************************************************************/ + +/* Stuff to handle, save and search IRC buddies */ + +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License with + the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; + if not, write to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "bitlbee.h" + +irc_user_t *irc_user_new( irc_t *irc, const char *nick ) +{ + irc_user_t *iu = g_new0( irc_user_t, 1 ); + + iu->nick = g_strdup( nick ); + iu->user = iu->host = iu->fullname = iu->nick; + + iu->is_private = set_getbool( &irc->b->set, "private" ); + + iu->key = g_strdup( nick ); + nick_lc( iu->key ); + /* Using the hash table for speed and irc->users for easy iteration + through the list (since the GLib API doesn't have anything sane + for that.) */ + g_hash_table_insert( irc->nick_user_hash, iu->key, iu ); + irc->users = g_slist_insert_sorted( irc->users, iu, irc_user_cmp ); + + return iu; +} + +int irc_user_free( irc_t *irc, const char *nick ) +{ + irc_user_t *iu; + + if( !( iu = irc_user_find( irc, nick ) ) ) + return 0; + + irc->users = g_slist_remove( irc->users, iu ); + g_hash_table_remove( irc->nick_user_hash, iu->key ); + + g_free( iu->nick ); + if( iu->nick != iu->user ) g_free( iu->user ); + if( iu->nick != iu->host ) g_free( iu->host ); + if( iu->nick != iu->fullname ) g_free( iu->fullname ); + g_free( iu->sendbuf ); + if( iu->sendbuf_timer ) b_event_remove( iu->sendbuf_timer ); + g_free( iu->key ); + + return 1; +} + +irc_user_t *irc_user_find( irc_t *irc, const char *nick ) +{ + char key[strlen(nick)+1]; + + strcpy( key, nick ); + if( nick_lc( key ) ) + return g_hash_table_lookup( irc->nick_user_hash, key ); + else + return NULL; +} + +int irc_user_rename( irc_t *irc, const char *old, const char *new ) +{ + irc_user_t *iu = irc_user_find( irc, old ); + char key[strlen(new)+1]; + + strcpy( key, new ); + if( iu == NULL || !nick_lc( key ) || irc_user_find( irc, new ) ) + return 0; + + irc->users = g_slist_remove( irc->users, iu ); + g_hash_table_remove( irc->nick_user_hash, iu->key ); + + if( iu->nick == iu->user ) iu->user = NULL; + if( iu->nick == iu->host ) iu->host = NULL; + if( iu->nick == iu->fullname ) iu->fullname = NULL; + g_free( iu->nick ); + iu->nick = g_strdup( new ); + if( iu->user == NULL ) iu->user = g_strdup( iu->nick ); + if( iu->host == NULL ) iu->host = g_strdup( iu->nick ); + if( iu->fullname == NULL ) iu->fullname = g_strdup( iu->nick ); + + iu->key = g_strdup( key ); + g_hash_table_insert( irc->nick_user_hash, iu->key, iu ); + irc->users = g_slist_insert_sorted( irc->users, iu, irc_user_cmp ); + + return 1; +} + +gint irc_user_cmp( gconstpointer a_, gconstpointer b_ ) +{ + const irc_user_t *a = a_, *b = b_; + + return strcmp( a->key, b->key ); +} -- cgit v1.2.3 From b95932eb5a897fd264f3762493285dd7037dccba Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 26 Mar 2010 23:39:23 -0400 Subject: Added WHOIS command. --- irc_user.c | 1 + 1 file changed, 1 insertion(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index d1f07bb6..1de0c4e3 100644 --- a/irc_user.c +++ b/irc_user.c @@ -29,6 +29,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) { irc_user_t *iu = g_new0( irc_user_t, 1 ); + iu->irc = irc; iu->nick = g_strdup( nick ); iu->user = iu->host = iu->fullname = iu->nick; -- cgit v1.2.3 From 280c56a7b24dc08b35a1ecd98c8f4b61435d1100 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 27 Mar 2010 13:36:47 -0400 Subject: Added privmsg handlers to users/channels. root commands are coming back. --- irc_user.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 1de0c4e3..a54fc09e 100644 --- a/irc_user.c +++ b/irc_user.c @@ -50,7 +50,7 @@ int irc_user_free( irc_t *irc, const char *nick ) { irc_user_t *iu; - if( !( iu = irc_user_find( irc, nick ) ) ) + if( !( iu = irc_user_by_name( irc, nick ) ) ) return 0; irc->users = g_slist_remove( irc->users, iu ); @@ -67,7 +67,7 @@ int irc_user_free( irc_t *irc, const char *nick ) return 1; } -irc_user_t *irc_user_find( irc_t *irc, const char *nick ) +irc_user_t *irc_user_by_name( irc_t *irc, const char *nick ) { char key[strlen(nick)+1]; @@ -80,11 +80,11 @@ irc_user_t *irc_user_find( irc_t *irc, const char *nick ) int irc_user_rename( irc_t *irc, const char *old, const char *new ) { - irc_user_t *iu = irc_user_find( irc, old ); + irc_user_t *iu = irc_user_by_name( irc, old ); char key[strlen(new)+1]; strcpy( key, new ); - if( iu == NULL || !nick_lc( key ) || irc_user_find( irc, new ) ) + if( iu == NULL || !nick_lc( key ) || irc_user_by_name( irc, new ) ) return 0; irc->users = g_slist_remove( irc->users, iu ); @@ -112,3 +112,27 @@ gint irc_user_cmp( gconstpointer a_, gconstpointer b_ ) return strcmp( a->key, b->key ); } + +/* User-type dependent functions, for root/NickServ: */ +static gboolean root_privmsg( irc_user_t *iu, const char *msg ) +{ + root_command_string( iu->irc, msg ); + + return TRUE; +} + +const struct irc_user_funcs irc_user_root_funcs = { + root_privmsg, +}; + +/* Echo to yourself: */ +static gboolean self_privmsg( irc_user_t *iu, const char *msg ) +{ + irc_send_msg( iu, "PRIVMSG", iu->nick, msg ); + + return TRUE; +} + +const struct irc_user_funcs irc_user_self_funcs = { + self_privmsg, +}; -- cgit v1.2.3 From 74f1cdef999356e40e3fa3b6a2d89876b6c0c303 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 27 Mar 2010 14:05:38 -0400 Subject: irc_usermsg() works a little bit again. Have to figure out how and where to restore multiline support though. --- irc_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index a54fc09e..ef66f2b5 100644 --- a/irc_user.c +++ b/irc_user.c @@ -33,7 +33,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) iu->nick = g_strdup( nick ); iu->user = iu->host = iu->fullname = iu->nick; - iu->is_private = set_getbool( &irc->b->set, "private" ); + iu->flags = set_getbool( &irc->b->set, "private" ) ? IRC_USER_PRIVATE : 0; iu->key = g_strdup( nick ); nick_lc( iu->key ); @@ -116,6 +116,9 @@ gint irc_user_cmp( gconstpointer a_, gconstpointer b_ ) /* User-type dependent functions, for root/NickServ: */ static gboolean root_privmsg( irc_user_t *iu, const char *msg ) { + g_free( iu->irc->last_root_cmd ); + iu->irc->last_root_cmd = g_strdup( iu->nick ); + root_command_string( iu->irc, msg ); return TRUE; -- cgit v1.2.3 From 6761a40af82d8134ee9fa2ac1d2b34475d297ad8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 27 Mar 2010 22:44:19 -0400 Subject: Restored multi-line message support. --- irc_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index ef66f2b5..d9ea0d94 100644 --- a/irc_user.c +++ b/irc_user.c @@ -131,7 +131,7 @@ const struct irc_user_funcs irc_user_root_funcs = { /* Echo to yourself: */ static gboolean self_privmsg( irc_user_t *iu, const char *msg ) { - irc_send_msg( iu, "PRIVMSG", iu->nick, msg ); + irc_send_msg_raw( iu, "PRIVMSG", iu->nick, msg ); return TRUE; } -- cgit v1.2.3 From 38ee0216a7058b0f227d1c32b288e041a397528a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 27 Mar 2010 23:03:57 -0400 Subject: Remove deleted user from channels too! --- irc_user.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index d9ea0d94..8e20fd15 100644 --- a/irc_user.c +++ b/irc_user.c @@ -49,6 +49,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) int irc_user_free( irc_t *irc, const char *nick ) { irc_user_t *iu; + GSList *l; if( !( iu = irc_user_by_name( irc, nick ) ) ) return 0; @@ -56,6 +57,9 @@ int irc_user_free( irc_t *irc, const char *nick ) irc->users = g_slist_remove( irc->users, iu ); g_hash_table_remove( irc->nick_user_hash, iu->key ); + for( l = irc->channels; l; l = l->next ) + irc_channel_del_user( (irc_channel_t*) l->data, iu ); + g_free( iu->nick ); if( iu->nick != iu->user ) g_free( iu->user ); if( iu->nick != iu->host ) g_free( iu->host ); -- cgit v1.2.3 From fb117aee274bccfb6528288599ef81fe72191e12 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 1 Apr 2010 22:29:45 -0400 Subject: Cleaned lots of compiler warnings so I can get some signal again. --- irc_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 8e20fd15..b3075c3b 100644 --- a/irc_user.c +++ b/irc_user.c @@ -120,10 +120,13 @@ gint irc_user_cmp( gconstpointer a_, gconstpointer b_ ) /* User-type dependent functions, for root/NickServ: */ static gboolean root_privmsg( irc_user_t *iu, const char *msg ) { + char cmd[strlen(msg)+1]; + g_free( iu->irc->last_root_cmd ); iu->irc->last_root_cmd = g_strdup( iu->nick ); - root_command_string( iu->irc, msg ); + strcpy( cmd, msg ); + root_command_string( iu->irc, cmd ); return TRUE; } -- cgit v1.2.3 From 0b5cc72bc7b4192ff5b474b81038c299d03721f1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Apr 2010 20:39:04 -0400 Subject: Send nickname change notifications when necessary. --- irc_user.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index b3075c3b..7f356d8d 100644 --- a/irc_user.c +++ b/irc_user.c @@ -82,15 +82,31 @@ irc_user_t *irc_user_by_name( irc_t *irc, const char *nick ) return NULL; } -int irc_user_rename( irc_t *irc, const char *old, const char *new ) +int irc_user_set_nick( irc_t *irc, const char *old, const char *new ) { irc_user_t *iu = irc_user_by_name( irc, old ); char key[strlen(new)+1]; + GSList *cl; strcpy( key, new ); if( iu == NULL || !nick_lc( key ) || irc_user_by_name( irc, new ) ) return 0; + for( cl = irc->channels; cl; cl = cl->next ) + { + irc_channel_t *ic = cl->data; + + /* Send a NICK update if we're renaming our user, or someone + who's in the same channel like our user. */ + if( iu == irc->user || + ( irc_channel_has_user( ic, irc->user ) && + irc_channel_has_user( ic, iu ) ) ) + { + irc_send_nick( iu, new ); + break; + } + } + irc->users = g_slist_remove( irc->users, iu ); g_hash_table_remove( irc->nick_user_hash, iu->key ); -- cgit v1.2.3 From 57c96f7be2511a0a50015512dc03a30ba0923862 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Apr 2010 21:00:02 -0400 Subject: Restored the rename command. --- irc_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 7f356d8d..8ad20b54 100644 --- a/irc_user.c +++ b/irc_user.c @@ -82,9 +82,9 @@ irc_user_t *irc_user_by_name( irc_t *irc, const char *nick ) return NULL; } -int irc_user_set_nick( irc_t *irc, const char *old, const char *new ) +int irc_user_set_nick( irc_user_t *iu, const char *new ) { - irc_user_t *iu = irc_user_by_name( irc, old ); + irc_t *irc = iu->irc; char key[strlen(new)+1]; GSList *cl; @@ -99,7 +99,7 @@ int irc_user_set_nick( irc_t *irc, const char *old, const char *new ) /* Send a NICK update if we're renaming our user, or someone who's in the same channel like our user. */ if( iu == irc->user || - ( irc_channel_has_user( ic, irc->user ) && + ( ( ic->flags & IRC_CHANNEL_JOINED ) && irc_channel_has_user( ic, iu ) ) ) { irc_send_nick( iu, new ); -- cgit v1.2.3 From eabc9d2c1b1d29aeb47162da64ce2b607c3d43ff Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 12 Apr 2010 00:49:32 +0200 Subject: Fixed cleanup issues when turning off an account. Also fixed syntax of *_user_free(). --- irc_user.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 8ad20b54..b7629490 100644 --- a/irc_user.c +++ b/irc_user.c @@ -46,12 +46,11 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) return iu; } -int irc_user_free( irc_t *irc, const char *nick ) +int irc_user_free( irc_t *irc, irc_user_t *iu ) { - irc_user_t *iu; GSList *l; - if( !( iu = irc_user_by_name( irc, nick ) ) ) + if( !iu ) return 0; irc->users = g_slist_remove( irc->users, iu ); -- cgit v1.2.3 From 24b8bbb2616d685006a279e46a4bd2e8e7cf6694 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 12 Apr 2010 02:06:49 +0200 Subject: Start handling CTCPs, in a saner way than before. --- irc_user.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index b7629490..cf1d1e3e 100644 --- a/irc_user.c +++ b/irc_user.c @@ -146,8 +146,18 @@ static gboolean root_privmsg( irc_user_t *iu, const char *msg ) return TRUE; } +static gboolean root_ctcp( irc_user_t *iu, char * const *ctcp ) +{ + if( g_strcasecmp( ctcp[0], "VERSION" ) == 0 ) + { + } + + return TRUE; +} + const struct irc_user_funcs irc_user_root_funcs = { root_privmsg, + root_ctcp, }; /* Echo to yourself: */ -- cgit v1.2.3 From 7b59872d86160099968d0f8cdafc2853b074d39b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 13 Apr 2010 02:04:55 +0200 Subject: Support for simple VERSION/PING CTCPs to root. --- irc_user.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index cf1d1e3e..7b2d4be1 100644 --- a/irc_user.c +++ b/irc_user.c @@ -150,6 +150,13 @@ static gboolean root_ctcp( irc_user_t *iu, char * const *ctcp ) { if( g_strcasecmp( ctcp[0], "VERSION" ) == 0 ) { + irc_send_msg_f( iu, "NOTICE", iu->irc->user->nick, "\001%s %s\001", + ctcp[0], "BitlBee " BITLBEE_VERSION " " ARCH "/" CPU ); + } + else if( g_strcasecmp( ctcp[0], "PING" ) == 0 ) + { + irc_send_msg_f( iu, "NOTICE", iu->irc->user->nick, "\001%s %s\001", + ctcp[0], ctcp[1] ? : "" ); } return TRUE; -- cgit v1.2.3 From 003a12bd2361cd1ce4d83eeaa1b81d95101ea778 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 14 Apr 2010 15:35:41 +0200 Subject: Restored all remaining IRC commands that make some sense to have at this point. --- irc_user.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 7b2d4be1..13c6d5bd 100644 --- a/irc_user.c +++ b/irc_user.c @@ -132,6 +132,25 @@ gint irc_user_cmp( gconstpointer a_, gconstpointer b_ ) return strcmp( a->key, b->key ); } +const char *irc_user_get_away( irc_user_t *iu ) +{ + irc_t *irc = iu->irc; + bee_user_t *bu = iu->bu; + + if( iu == irc->user ) + return set_getstr( &irc->b->set, "away" ); + else if( bu ) + { + if( !bu->flags & BEE_USER_ONLINE ) + return "Offline"; + else if( bu->flags & BEE_USER_AWAY ) + /* TODO: status msgs, etc. */ + return bu->status; + } + + return NULL; +} + /* User-type dependent functions, for root/NickServ: */ static gboolean root_privmsg( irc_user_t *iu, const char *msg ) { -- cgit v1.2.3 From 4c3519a8e9f8733577b0ca060a80606955f92cce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Apr 2010 00:45:09 +0200 Subject: Restored blist command. --- irc_user.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 13c6d5bd..1884e66e 100644 --- a/irc_user.c +++ b/irc_user.c @@ -144,8 +144,17 @@ const char *irc_user_get_away( irc_user_t *iu ) if( !bu->flags & BEE_USER_ONLINE ) return "Offline"; else if( bu->flags & BEE_USER_AWAY ) - /* TODO: status msgs, etc. */ - return bu->status; + { + if( bu->status_msg ) + { + static char ret[MAX_STRING]; + g_snprintf( ret, MAX_STRING - 1, "%s (%s)", + bu->status ? : "Away", bu->status_msg ); + return ret; + } + else + return bu->status ? : "Away"; + } } return NULL; -- cgit v1.2.3 From 18da20bf7690ca3c1e9cf4b70c2749a11c75b339 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jun 2010 01:33:33 +0100 Subject: Added /part msgs, and the ability to silently remove users from channels (when sending a /quit instead, for example). --- irc_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 1884e66e..e18e67cc 100644 --- a/irc_user.c +++ b/irc_user.c @@ -57,7 +57,7 @@ int irc_user_free( irc_t *irc, irc_user_t *iu ) g_hash_table_remove( irc->nick_user_hash, iu->key ); for( l = irc->channels; l; l = l->next ) - irc_channel_del_user( (irc_channel_t*) l->data, iu ); + irc_channel_del_user( (irc_channel_t*) l->data, iu, FALSE, NULL ); g_free( iu->nick ); if( iu->nick != iu->user ) g_free( iu->user ); -- cgit v1.2.3 From 1f0224cdfd238060810679b3d6ba1a2bc49e4493 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jun 2010 02:11:13 +0100 Subject: Send one /QUIT instead of one or more /PARTs for a user that is being removed. Also restored netsplit simulation. --- irc_user.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index e18e67cc..88db86d7 100644 --- a/irc_user.c +++ b/irc_user.c @@ -49,6 +49,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) int irc_user_free( irc_t *irc, irc_user_t *iu ) { GSList *l; + gboolean send_quit = FALSE; if( !iu ) return 0; @@ -57,7 +58,46 @@ int irc_user_free( irc_t *irc, irc_user_t *iu ) g_hash_table_remove( irc->nick_user_hash, iu->key ); for( l = irc->channels; l; l = l->next ) - irc_channel_del_user( (irc_channel_t*) l->data, iu, FALSE, NULL ); + send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL ); + + if( send_quit ) + { + static struct im_connection *last_ic; + static char *msg; + + if( iu->bu && + ( iu->bu->ic->flags & OPT_LOGGING_OUT ) && + iu->bu->ic != last_ic ) + { + char host_prefix[] = "bitlbee."; + char *s; + + /* Irssi recognises netsplits by quitmsgs with two + hostnames, where a hostname is a "word" with one + of more dots. Mangle no-dot hostnames a bit. */ + if( strchr( irc->root->host, '.' ) ) + *host_prefix = '\0'; + + last_ic = iu->bu->ic; + g_free( msg ); + if( !set_getbool( &irc->b->set, "simulate_netsplit" ) ) + msg = g_strdup( "Account off-line" ); + else if( ( s = strchr( iu->bu->ic->acc->user, '@' ) ) ) + msg = g_strdup_printf( "%s%s %s", host_prefix, + irc->root->host, s + 1 ); + else + msg = g_strdup_printf( "%s%s %s.%s", + host_prefix, irc->root->host, + iu->bu->ic->acc->prpl->name, irc->root->host ); + } + else if( !iu->bu || !( iu->bu->ic->flags & OPT_LOGGING_OUT ) ) + { + g_free( msg ); + msg = g_strdup( "Removed" ); + last_ic = NULL; + } + irc_send_quit( iu, msg ); + } g_free( iu->nick ); if( iu->nick != iu->user ) g_free( iu->user ); -- cgit v1.2.3 From 619dd1882deb7f507882748982744cc275dd92a9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 19:40:08 +0100 Subject: Paste buffer functionality is back, now for users *and* rooms. --- irc_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 88db86d7..3305b072 100644 --- a/irc_user.c +++ b/irc_user.c @@ -103,8 +103,8 @@ int irc_user_free( irc_t *irc, irc_user_t *iu ) if( iu->nick != iu->user ) g_free( iu->user ); if( iu->nick != iu->host ) g_free( iu->host ); if( iu->nick != iu->fullname ) g_free( iu->fullname ); - g_free( iu->sendbuf ); - if( iu->sendbuf_timer ) b_event_remove( iu->sendbuf_timer ); + g_free( iu->pastebuf ); + if( iu->pastebuf_timer ) b_event_remove( iu->pastebuf_timer ); g_free( iu->key ); return 1; -- cgit v1.2.3 From d7db3468f95d6b8ed2a161c71cb5b6ab1a7b5895 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 8 Jun 2010 23:44:16 +0100 Subject: Some cleanup improvements. --- irc_user.c | 1 + 1 file changed, 1 insertion(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 3305b072..9758350a 100644 --- a/irc_user.c +++ b/irc_user.c @@ -106,6 +106,7 @@ int irc_user_free( irc_t *irc, irc_user_t *iu ) g_free( iu->pastebuf ); if( iu->pastebuf_timer ) b_event_remove( iu->pastebuf_timer ); g_free( iu->key ); + g_free( iu ); return 1; } -- cgit v1.2.3 From 92c8d410eb1d26bfe876ae119734772f46c9a7da Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 26 Jun 2010 22:26:41 +0100 Subject: Remember in which channel the user talked to someone and show responses in that same channel. --- irc_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 9758350a..2706eb67 100644 --- a/irc_user.c +++ b/irc_user.c @@ -33,7 +33,10 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) iu->nick = g_strdup( nick ); iu->user = iu->host = iu->fullname = iu->nick; - iu->flags = set_getbool( &irc->b->set, "private" ) ? IRC_USER_PRIVATE : 0; + if( set_getbool( &irc->b->set, "private" ) ) + iu->last_channel = NULL; + else + iu->last_channel = irc->default_channel; iu->key = g_strdup( nick ); nick_lc( iu->key ); -- cgit v1.2.3 From 917a83ee526b8e5baaf451888cd0a3149894697b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 3 Jul 2010 21:38:53 +0100 Subject: Use irc_send_msg instead of irc_send_msg_raw() to echo messages to self, to make sure CTCP ACTIONs work. Not important, just more correct. Other CTCPs sent to oneself are dropped, but why CTCP yourself anyway? --- irc_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 2706eb67..98145ae1 100644 --- a/irc_user.c +++ b/irc_user.c @@ -242,7 +242,7 @@ const struct irc_user_funcs irc_user_root_funcs = { /* Echo to yourself: */ static gboolean self_privmsg( irc_user_t *iu, const char *msg ) { - irc_send_msg_raw( iu, "PRIVMSG", iu->nick, msg ); + irc_send_msg( iu, "PRIVMSG", iu->nick, msg, NULL ); return TRUE; } -- cgit v1.2.3 From 0bd948edfea280cf9f05e21cd5bef4b7fdf3335c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 3 Jul 2010 22:16:41 +0100 Subject: Show a user going offline as a QUIT, not as one or more PARTs, like in the old-style BitlBee. This so that the IRC client will show the notification in query windows as well. Make it a setting though, for bug #539. --- irc_user.c | 92 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 43 deletions(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index 98145ae1..fa509a45 100644 --- a/irc_user.c +++ b/irc_user.c @@ -51,56 +51,47 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick ) int irc_user_free( irc_t *irc, irc_user_t *iu ) { - GSList *l; - gboolean send_quit = FALSE; + static struct im_connection *last_ic; + static char *msg; if( !iu ) return 0; - irc->users = g_slist_remove( irc->users, iu ); - g_hash_table_remove( irc->nick_user_hash, iu->key ); - - for( l = irc->channels; l; l = l->next ) - send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL ); - - if( send_quit ) + if( iu->bu && + ( iu->bu->ic->flags & OPT_LOGGING_OUT ) && + iu->bu->ic != last_ic ) { - static struct im_connection *last_ic; - static char *msg; + char host_prefix[] = "bitlbee."; + char *s; - if( iu->bu && - ( iu->bu->ic->flags & OPT_LOGGING_OUT ) && - iu->bu->ic != last_ic ) - { - char host_prefix[] = "bitlbee."; - char *s; - - /* Irssi recognises netsplits by quitmsgs with two - hostnames, where a hostname is a "word" with one - of more dots. Mangle no-dot hostnames a bit. */ - if( strchr( irc->root->host, '.' ) ) - *host_prefix = '\0'; - - last_ic = iu->bu->ic; - g_free( msg ); - if( !set_getbool( &irc->b->set, "simulate_netsplit" ) ) - msg = g_strdup( "Account off-line" ); - else if( ( s = strchr( iu->bu->ic->acc->user, '@' ) ) ) - msg = g_strdup_printf( "%s%s %s", host_prefix, - irc->root->host, s + 1 ); - else - msg = g_strdup_printf( "%s%s %s.%s", - host_prefix, irc->root->host, - iu->bu->ic->acc->prpl->name, irc->root->host ); - } - else if( !iu->bu || !( iu->bu->ic->flags & OPT_LOGGING_OUT ) ) - { - g_free( msg ); - msg = g_strdup( "Removed" ); - last_ic = NULL; - } - irc_send_quit( iu, msg ); + /* Irssi recognises netsplits by quitmsgs with two + hostnames, where a hostname is a "word" with one + of more dots. Mangle no-dot hostnames a bit. */ + if( strchr( irc->root->host, '.' ) ) + *host_prefix = '\0'; + + last_ic = iu->bu->ic; + g_free( msg ); + if( !set_getbool( &irc->b->set, "simulate_netsplit" ) ) + msg = g_strdup( "Account off-line" ); + else if( ( s = strchr( iu->bu->ic->acc->user, '@' ) ) ) + msg = g_strdup_printf( "%s%s %s", host_prefix, + irc->root->host, s + 1 ); + else + msg = g_strdup_printf( "%s%s %s.%s", + host_prefix, irc->root->host, + iu->bu->ic->acc->prpl->name, irc->root->host ); + } + else if( !iu->bu || !( iu->bu->ic->flags & OPT_LOGGING_OUT ) ) + { + g_free( msg ); + msg = g_strdup( "Removed" ); + last_ic = NULL; } + irc_user_quit( iu, msg ); + + irc->users = g_slist_remove( irc->users, iu ); + g_hash_table_remove( irc->nick_user_hash, iu->key ); g_free( iu->nick ); if( iu->nick != iu->user ) g_free( iu->user ); @@ -204,6 +195,21 @@ const char *irc_user_get_away( irc_user_t *iu ) return NULL; } +void irc_user_quit( irc_user_t *iu, const char *msg ) +{ + GSList *l; + gboolean send_quit = FALSE; + + if( !iu ) + return; + + for( l = iu->irc->channels; l; l = l->next ) + send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL ); + + if( send_quit ) + irc_send_quit( iu, msg ); +} + /* User-type dependent functions, for root/NickServ: */ static gboolean root_privmsg( irc_user_t *iu, const char *msg ) { -- cgit v1.2.3 From 006a84f999248d1bc1c1e36fa3437765d4bd1142 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Jul 2010 21:40:15 +0100 Subject: Kick the user instead of parting him/her when cleaning up a channel. This is what the older version also did so that Irssi won't clean up the window. --- irc_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index fa509a45..cb7ea1e7 100644 --- a/irc_user.c +++ b/irc_user.c @@ -204,7 +204,7 @@ void irc_user_quit( irc_user_t *iu, const char *msg ) return; for( l = iu->irc->channels; l; l = l->next ) - send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL ); + send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, IRC_CDU_SILENT, NULL ); if( send_quit ) irc_send_quit( iu, msg ); -- cgit v1.2.3 From 9a9b520df6044cfc034f9736fb97660a46e879b9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 8 Jul 2010 23:31:01 +0100 Subject: Allow nick changes if they're only different in capitalisation, fixed faulty responses in the NICK command, and fixing crash bug in nick changes before finishing login. --- irc_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index cb7ea1e7..7d29cae0 100644 --- a/irc_user.c +++ b/irc_user.c @@ -119,11 +119,13 @@ irc_user_t *irc_user_by_name( irc_t *irc, const char *nick ) int irc_user_set_nick( irc_user_t *iu, const char *new ) { irc_t *irc = iu->irc; + irc_user_t *new_iu; char key[strlen(new)+1]; GSList *cl; strcpy( key, new ); - if( iu == NULL || !nick_lc( key ) || irc_user_by_name( irc, new ) ) + if( iu == NULL || !nick_lc( key ) || + ( ( new_iu = irc_user_by_name( irc, new ) ) && new_iu != iu ) ) return 0; for( cl = irc->channels; cl; cl = cl->next ) -- cgit v1.2.3 From debe871bbd96a1d4215983265d97b8f0df7a4fbf Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 9 Jul 2010 22:06:38 +0100 Subject: Inform IPC master about nick changes. --- irc_user.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index cb7ea1e7..70f324c7 100644 --- a/irc_user.c +++ b/irc_user.c @@ -24,6 +24,7 @@ */ #include "bitlbee.h" +#include "ipc.h" irc_user_t *irc_user_new( irc_t *irc, const char *nick ) { @@ -157,6 +158,9 @@ int irc_user_set_nick( irc_user_t *iu, const char *new ) g_hash_table_insert( irc->nick_user_hash, iu->key, iu ); irc->users = g_slist_insert_sorted( irc->users, iu, irc_user_cmp ); + if( iu == irc->user ) + ipc_to_master_str( "NICK :%s\r\n", new ); + return 1; } -- cgit v1.2.3