aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-04-04 20:18:24 -0400
committerWilmer van der Gaast <wilmer@gaast.net>2010-04-04 20:18:24 -0400
commit1d3915951bfbcdfa1a7829a4082e90e154d4a486 (patch)
tree058070d08f0909d0c90f9520ff9a048f15245959
parentf012a9f0bb363cfcbdb6f2d563254ffba26b9fc8 (diff)
Get full names properly. Handling of nick_source setting and
imcb_nick_hint() is probably still broken.
-rw-r--r--irc_im.c42
-rw-r--r--irc_send.c38
-rw-r--r--protocols/bee.h1
-rw-r--r--protocols/bee_user.c1
-rw-r--r--protocols/nogaim.c39
5 files changed, 76 insertions, 45 deletions
diff --git a/irc_im.c b/irc_im.c
index e13a9ab4..812dcde1 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -119,9 +119,51 @@ static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, t
return TRUE;
}
+static gboolean bee_irc_user_fullname( bee_t *bee, bee_user_t *bu )
+{
+ irc_user_t *iu = (irc_user_t *) bu->ui_data;
+ irc_t *irc = (irc_t *) bee->ui_data;
+ char *s;
+
+ if( iu->fullname != iu->nick )
+ g_free( iu->fullname );
+ iu->fullname = g_strdup( bu->fullname );
+
+ /* Strip newlines (unlikely, but IRC-unfriendly so they must go)
+ TODO(wilmer): Do the same with away msgs again! */
+ for( s = iu->fullname; *s; s ++ )
+ if( isspace( *s ) ) *s = ' ';
+
+ if( ( bu->ic->flags & OPT_LOGGED_IN ) && set_getbool( &bee->set, "display_namechanges" ) )
+ {
+ char *msg = g_strdup_printf( "<< \002BitlBee\002 - Changed name to `%s' >>", iu->fullname );
+ irc_send_msg( iu, "NOTICE", irc->user->nick, msg, NULL );
+ }
+
+ s = set_getstr( &bu->ic->acc->set, "nick_source" );
+ if( strcmp( s, "handle" ) != 0 )
+ {
+ char *name = g_strdup( bu->fullname );
+
+ if( strcmp( s, "first_name" ) == 0 )
+ {
+ int i;
+ for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {}
+ name[i] = '\0';
+ }
+
+ imcb_buddy_nick_hint( bu->ic, bu->handle, name );
+
+ g_free( name );
+ }
+
+ return TRUE;
+}
+
const struct bee_ui_funcs irc_ui_funcs = {
bee_irc_user_new,
bee_irc_user_free,
+ bee_irc_user_fullname,
bee_irc_user_status,
bee_irc_user_msg,
};
diff --git a/irc_send.c b/irc_send.c
index 80d9b466..bbf84bd2 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -219,21 +219,31 @@ void irc_send_whois( irc_user_t *iu )
irc_send_num( irc, 311, "%s %s %s * :%s",
iu->nick, iu->user, iu->host, iu->fullname );
- /*
- if( u->ic )
- irc_send_num( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user,
- u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "",
- u->ic->acc->prpl->name );
+ if( iu->bu )
+ {
+ bee_user_t *bu = iu->bu;
+
+ irc_send_num( irc, 312, "%s %s.%s :%s network", iu->nick, bu->ic->acc->user,
+ bu->ic->acc->server && *bu->ic->acc->server ? bu->ic->acc->server : "",
+ bu->ic->acc->prpl->name );
+
+ if( bu->status )
+ {
+ if( bu->status_msg )
+ irc_send_num( irc, 301, "%s :%s (%s)", iu->nick, bu->status, bu->status_msg );
+ else
+ irc_send_num( irc, 301, "%s :%s", iu->nick, bu->status );
+ }
+
+ /*
+ if( u->status_msg )
+ irc_send_num( irc, 333, "%s :Status: %s", u->nick, u->status_msg );
+ */
+ }
else
- irc_send_num( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO );
- */
-
- /*
- if( u->away )
- irc_send_num( irc, 301, "%s :%s", u->nick, u->away );
- if( u->status_msg )
- irc_send_num( irc, 333, "%s :Status: %s", u->nick, u->status_msg );
- */
+ {
+ irc_send_num( irc, 312, "%s %s :%s", iu->nick, irc->root->host, IRCD_INFO " " BITLBEE_VERSION );
+ }
irc_send_num( irc, 318, "%s :End of /WHOIS list", iu->nick );
}
diff --git a/protocols/bee.h b/protocols/bee.h
index 62c73e94..61604265 100644
--- a/protocols/bee.h
+++ b/protocols/bee.h
@@ -67,6 +67,7 @@ typedef struct bee_ui_funcs
{
gboolean (*user_new)( bee_t *bee, struct bee_user *bu );
gboolean (*user_free)( bee_t *bee, struct bee_user *bu );
+ gboolean (*user_fullname)( bee_t *bee, bee_user_t *bu );
gboolean (*user_status)( bee_t *bee, struct bee_user *bu, struct bee_user *old );
gboolean (*user_msg)( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at );
} bee_ui_funcs_t;
diff --git a/protocols/bee_user.c b/protocols/bee_user.c
index 675d37c5..20c760a9 100644
--- a/protocols/bee_user.c
+++ b/protocols/bee_user.c
@@ -168,7 +168,6 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags,
void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
{
bee_t *bee = ic->bee;
- char *wrapped;
bee_user_t *bu;
bu = bee_user_by_handle( bee, ic, handle );
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 141ae9a3..1e00d5ab 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -364,7 +364,6 @@ void imcb_ask( struct im_connection *ic, char *msg, void *data,
void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group )
{
bee_user_t *bu;
- //char nick[MAX_NICK_LENGTH+1], *s;
bee_t *bee = ic->bee;
if( bee_user_by_handle( bee, ic, handle ) )
@@ -384,41 +383,21 @@ void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *g
bu->group = g_strdup( group );
}
-void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname )
+void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *fullname )
{
-#if 0
- user_t *u = user_findhandle( ic, handle );
- char *set;
+ bee_t *bee = ic->bee;
+ bee_user_t *bu = bee_user_by_handle( bee, ic, handle );
- if( !u || !realname ) return;
+ if( !bu || !fullname ) return;
- if( g_strcasecmp( u->realname, realname ) != 0 )
+ if( strcmp( bu->fullname, fullname ) != 0 )
{
- if( u->realname != u->nick ) g_free( u->realname );
-
- u->realname = g_strdup( realname );
+ g_free( bu->fullname );
+ bu->fullname = g_strdup( fullname );
- if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->bee->set, "display_namechanges" ) )
- imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
+ if( bee->ui->user_fullname )
+ bee->ui->user_fullname( bee, bu );
}
-
- set = set_getstr( &ic->acc->set, "nick_source" );
- if( strcmp( set, "handle" ) != 0 )
- {
- char *name = g_strdup( realname );
-
- if( strcmp( set, "first_name" ) == 0 )
- {
- int i;
- for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {}
- name[i] = '\0';
- }
-
- imcb_buddy_nick_hint( ic, handle, name );
-
- g_free( name );
- }
-#endif
}
void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group )