diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-10-12 01:08:58 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-10-12 01:08:58 +0100 |
commit | eda54e40d04c83028d84e91c895a550c1929b436 (patch) | |
tree | 878f985af2ab5d2b9c59e8c955448bc4e9ddec17 /protocols/nogaim.c | |
parent | 82135c7178b6379f35741991f6c06bb308143194 (diff) | |
parent | d444c09e6c7ac6fc3c1686af0e63c09805d8cd00 (diff) |
Merge from devel.
Diffstat (limited to 'protocols/nogaim.c')
-rw-r--r-- | protocols/nogaim.c | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 4b0b738b..3307b0f5 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -47,7 +47,7 @@ gboolean load_plugin(char *path) GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); if(!mod) { - log_message(LOGLVL_ERROR, "Can't find `%s', not loading", path); + log_message(LOGLVL_ERROR, "Can't find `%s', not loading (%s)\n", path, g_module_error()); return FALSE; } @@ -607,14 +607,27 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ { - irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, - ic->irc->channel, u->away?'-':'+', u->nick ); + char *from; + + if( set_getbool( &ic->irc->set, "simulate_netsplit" ) ) + { + from = g_strdup( ic->irc->myhost ); + } + else + { + from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick, + ic->irc->myhost ); + } + irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, + u->away?'-':'+', u->nick ); + g_free( from ); } } void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; + char *wrapped; user_t *u; u = user_findhandle( ic, handle ); @@ -657,37 +670,9 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); - while( strlen( msg ) > 425 ) - { - char tmp, *nl; - - tmp = msg[425]; - msg[425] = 0; - - /* If there's a newline/space in this string, split up there, - looks a bit prettier. */ - if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) ) - { - msg[425] = tmp; - tmp = *nl; - *nl = 0; - } - - irc_msgfrom( irc, u->nick, msg ); - - /* Move on. */ - if( nl ) - { - *nl = tmp; - msg = nl + 1; - } - else - { - msg[425] = tmp; - msg += 425; - } - } - irc_msgfrom( irc, u->nick, msg ); + wrapped = word_wrap( msg, 425 ); + irc_msgfrom( irc, u->nick, wrapped ); + g_free( wrapped ); } void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ) @@ -749,6 +734,7 @@ void imcb_chat_free( struct groupchat *c ) void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ) { struct im_connection *ic = c->ic; + char *wrapped; user_t *u; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ @@ -761,10 +747,16 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); + wrapped = word_wrap( msg, 425 ); if( c && u ) - irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); + { + irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); + } else - imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); + { + imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, wrapped ); + } + g_free( wrapped ); } struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) |