diff options
Diffstat (limited to 'protocols/nogaim.c')
-rw-r--r-- | protocols/nogaim.c | 134 |
1 files changed, 39 insertions, 95 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2248d11e..5535e093 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -724,8 +724,10 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, u->status_msg = g_strdup( message ); } - /* early if-clause for show_offline even if there is some redundant code here because this isn't LISP but C ;) */ - if( set_getbool( &ic->irc->set, "show_offline" ) && set_getbool( &ic->irc->set, "away_devoice" ) ) + /* LISPy... */ + if( ( u->online ) && /* Don't touch offline people */ + ( ( u->online != oo ) || /* Do joining people */ + ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* Do people changing state */ { char *from; @@ -739,42 +741,30 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, ic->irc->myhost ); } - /* if we use show_offline, we op online users, voice away users, and devoice/deop offline users */ - if( flags & OPT_LOGGED_IN ) - { - /* user is "online" (either really online or away) */ - irc_write( ic->irc, ":%s MODE %s %cv%co %s %s", from, ic->irc->channel, - u->away?'+':'-', u->away?'-':'+', u->nick, u->nick ); + if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "online")) { + irc_write( ic->irc, ":%s MODE %s +v %s", from, ic->irc->channel, u->nick ); } - else - { - /* user is offline */ - irc_write( ic->irc, ":%s MODE %s -vo %s %s", from, ic->irc->channel, u->nick, u->nick ); + if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "online")) { + irc_write( ic->irc, ":%s MODE %s +h %s", from, ic->irc->channel, u->nick ); + } + if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "online")) { + irc_write( ic->irc, ":%s MODE %s +o %s", from, ic->irc->channel, u->nick ); } - } - else - { - /* LISPy... */ - if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ - ( u->online ) && /* Don't touch offline people */ - ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ - ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ - { - 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 ); - } + if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "notaway")) { irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, - u->away?'-':'+', u->nick ); - g_free( from ); + u->away?'-':'+', u->nick ); + } + if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "notaway")) { + irc_write( ic->irc, ":%s MODE %s %ch %s", from, ic->irc->channel, + u->away?'-':'+', u->nick ); } + if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "notaway")) { + irc_write( ic->irc, ":%s MODE %s %co %s", from, ic->irc->channel, + u->away?'-':'+', u->nick ); + } + + g_free( from ); } } @@ -783,9 +773,15 @@ void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, ui irc_t *irc = ic->irc; char *wrapped, *ts = NULL; user_t *u; - + + /* pass the message through OTR */ + msg = otr_handle_message(ic, handle, msg); + if(!msg) { + /* this was an internal OTR protocol message */ + return; + } + u = user_findhandle( ic, handle ); - if( !u ) { char *h = set_getstr( &irc->set, "handle_unknown" ); @@ -795,6 +791,7 @@ void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, ui if( set_getbool( &irc->set, "debug" ) ) imcb_log( ic, "Ignoring message from unknown handle %s", handle ); + g_free(msg); return; } else if( g_strncasecmp( h, "add", 3 ) == 0 ) @@ -828,13 +825,14 @@ void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, ui ( ts = format_timestamp( irc, sent_at ) ) ) { char *new = g_strconcat( ts, msg, NULL ); - g_free( ts ); - ts = msg = new; + g_free( msg ); + msg = new; } wrapped = word_wrap( msg, 425 ); irc_msgfrom( irc, u->nick, wrapped ); g_free( wrapped ); + g_free( msg ); g_free( ts ); } @@ -1111,61 +1109,6 @@ static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ) /* Misc. BitlBee stuff which shouldn't really be here */ -char *set_eval_away_devoice( set_t *set, char *value ) -{ - irc_t *irc = set->data; - int st; - - if( !is_bool( value ) ) - return SET_INVALID; - - st = bool2int( value ); - - /* Horror.... */ - - if( st != set_getbool( &irc->set, "away_devoice" ) ) - { - char list[80] = ""; - user_t *u = irc->users; - int i = 0, count = 0; - char pm; - char v[80]; - - if( st ) - pm = '+'; - else - pm = '-'; - - while( u ) - { - if( u->ic && u->online && !u->away ) - { - if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) - { - for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; - irc_write( irc, ":%s MODE %s %c%s%s", - irc->myhost, - irc->channel, pm, v, list ); - - *list = 0; - count = 0; - } - - sprintf( list + strlen( list ), " %s", u->nick ); - count ++; - } - u = u->next; - } - - /* $v = 'v' x $i */ - for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; - irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost, - irc->channel, pm, v, list ); - } - - return value; -} - char *set_eval_timezone( set_t *set, char *value ) { char *s; @@ -1268,10 +1211,11 @@ int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags buf = escape_html( msg ); msg = buf; } + + /* if compiled without otr support, this just calls the prpl buddy_msg */ + st = otr_send_message(ic, handle, msg, flags); - st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags ); - g_free( buf ); - + g_free(buf); return st; } |