示例#1
0
文件: irc_im.c 项目: meh/bitlbee
static gboolean bee_irc_user_status(bee_t *bee, bee_user_t *bu, bee_user_t *old)
{
	irc_t *irc = bee->ui_data;
	irc_user_t *iu = bu->ui_data;

	/* Do this outside the if below since away state can change without
	   the online state changing. */
	iu->flags &= ~IRC_USER_AWAY;
	if (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) {
		iu->flags |= IRC_USER_AWAY;
	}

	if ((bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE)) {
		if (bu->flags & BEE_USER_ONLINE) {
			if (g_hash_table_lookup(irc->watches, iu->key)) {
				irc_send_num(irc, 600, "%s %s %s %d :%s", iu->nick, iu->user,
				             iu->host, (int) time(NULL), "logged online");
			}
		} else {
			if (g_hash_table_lookup(irc->watches, iu->key)) {
				irc_send_num(irc, 601, "%s %s %s %d :%s", iu->nick, iu->user,
				             iu->host, (int) time(NULL), "logged offline");
			}

			/* Send a QUIT since those will also show up in any
			   query windows the user may have, plus it's only
			   one QUIT instead of possibly many (in case of
			   multiple control chans). If there's a channel that
			   shows offline people, a JOIN will follow. */
			if (set_getbool(&bee->set, "offline_user_quits")) {
				irc_user_quit(iu, "Leaving...");
			}
		}
	}

	/* Reset this one since the info may have changed. */
	iu->away_reply_timeout = 0;

	bee_irc_channel_update(irc, NULL, iu);

	/* If away-notify enabled, send status updates when:
	 * Away or Online state changes
	 * Status changes (e.g. "Away" to "Mobile")
	 * Status message changes
	 */
	if ((irc->caps & CAP_AWAY_NOTIFY) &&
	    ((bu->flags & BEE_USER_AWAY) != (old->flags & BEE_USER_AWAY) ||
	     (bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE) ||
	     (g_strcmp0(bu->status, old->status) != 0) ||
	     (g_strcmp0(bu->status_msg, old->status_msg) != 0))) {
		irc_send_away_notify(iu);
	}

	return TRUE;
}
示例#2
0
文件: irc_user.c 项目: AlD/bitlbee
int irc_user_free( irc_t *irc, irc_user_t *iu )
{
	static struct im_connection *last_ic;
	static char *msg;
	
	if( !iu )
		return 0;
	
	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_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 );
	if( iu->nick != iu->host ) g_free( iu->host );
	if( iu->nick != iu->fullname ) g_free( iu->fullname );
	g_free( iu->pastebuf );
	if( iu->pastebuf_timer ) b_event_remove( iu->pastebuf_timer );
	g_free( iu->key );
	g_free( iu );
	
	return 1;
}
示例#3
0
static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old )
{
	irc_t *irc = bee->ui_data;
	irc_user_t *iu = bu->ui_data;
	
	/* Do this outside the if below since away state can change without
	   the online state changing. */
	iu->flags &= ~IRC_USER_AWAY;
	if( bu->flags & BEE_USER_AWAY || !( bu->flags & BEE_USER_ONLINE ) )
		iu->flags |= IRC_USER_AWAY;
	
	if( ( bu->flags & BEE_USER_ONLINE ) != ( old->flags & BEE_USER_ONLINE ) )
	{
		if( bu->flags & BEE_USER_ONLINE )
		{
			if( g_hash_table_lookup( irc->watches, iu->key ) )
				irc_send_num( irc, 600, "%s %s %s %d :%s", iu->nick, iu->user,
				              iu->host, (int) time( NULL ), "logged online" );
		}
		else
		{
			if( g_hash_table_lookup( irc->watches, iu->key ) )
				irc_send_num( irc, 601, "%s %s %s %d :%s", iu->nick, iu->user,
				              iu->host, (int) time( NULL ), "logged offline" );
			
			/* Send a QUIT since those will also show up in any
			   query windows the user may have, plus it's only
			   one QUIT instead of possibly many (in case of
			   multiple control chans). If there's a channel that
			   shows offline people, a JOIN will follow. */
			if( set_getbool( &bee->set, "offline_user_quits" ) )
				irc_user_quit( iu, "Leaving..." );
		}
	}
	
	/* Reset this one since the info may have changed. */
	iu->away_reply_timeout = 0;
	
	bee_irc_channel_update( irc, NULL, iu );
	
	return TRUE;
}