Changeset 81186cab


Ignore:
Timestamp:
2010-04-13T11:38:41Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
21c87a7
Parents:
573dab0
Message:

/away and set away/status stuff back.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • irc_commands.c

    r573dab0 r81186cab  
    352352
    353353#if 0
    354 //#if 0
    355354static void irc_cmd_oper( irc_t *irc, char **cmd )
    356355{
     
    524523        }
    525524}
     525#endif
    526526
    527527static void irc_cmd_away( irc_t *irc, char **cmd )
    528528{
    529         user_t *u = user_find( irc, irc->nick );
    530         char *away = cmd[1];
    531        
    532         if( !u ) return;
    533        
    534         if( away && *away )
    535         {
     529        char *set;
     530       
     531        if( cmd[1] && *cmd[1] )
     532        {
     533                char away[strlen(cmd[1])+1];
    536534                int i, j;
    537535               
    538536                /* Copy away string, but skip control chars. Mainly because
    539537                   Jabber really doesn't like them. */
    540                 u->away = g_malloc( strlen( away ) + 1 );
    541                 for( i = j = 0; away[i]; i ++ )
    542                         if( ( u->away[j] = away[i] ) >= ' ' )
     538                for( i = j = 0; cmd[1][i]; i ++ )
     539                        if( ( away[j] = cmd[1][i] ) >= ' ' )
    543540                                j ++;
    544                 u->away[j] = 0;
    545                
    546                 irc_send_num( irc, 306, ":You're now away: %s", u->away );
    547                 /* irc_umode_set( irc, irc->myhost, "+a" ); */
    548         }
    549         else
    550         {
    551                 if( u->away ) g_free( u->away );
    552                 u->away = NULL;
    553                 /* irc_umode_set( irc, irc->myhost, "-a" ); */
     541                away[j] = '\0';
     542               
     543                irc_send_num( irc, 306, ":You're now away: %s", away );
     544                set = away;
     545        }
     546        else
     547        {
    554548                irc_send_num( irc, 305, ":Welcome back" );
    555         }
    556        
    557         set_setstr( &irc->set, "away", u->away );
    558 }
    559 
     549                set = NULL;
     550        }
     551       
     552        set_setstr( &irc->b->set, "away", set );
     553}
     554
     555#if 0
    560556static void irc_cmd_version( irc_t *irc, char **cmd )
    561557{
     
    613609        { "nickserv",    1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
    614610        { "ns",          1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
     611        { "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },
    615612#if 0
    616613        { "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
     
    621618        { "watch",       1, irc_cmd_watch,       IRC_CMD_LOGGED_IN },
    622619        { "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN },
    623         { "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },
    624620        { "version",     0, irc_cmd_version,     IRC_CMD_LOGGED_IN },
    625621        { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
  • protocols/bee.c

    r573dab0 r81186cab  
     1  /********************************************************************\
     2  * BitlBee -- An IRC to other IM-networks gateway                     *
     3  *                                                                    *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
     5  \********************************************************************/
     6
     7/* Some IM-core stuff                                                   */
     8
     9/*
     10  This program is free software; you can redistribute it and/or modify
     11  it under the terms of the GNU General Public License as published by
     12  the Free Software Foundation; either version 2 of the License, or
     13  (at your option) any later version.
     14
     15  This program is distributed in the hope that it will be useful,
     16  but WITHOUT ANY WARRANTY; without even the implied warranty of
     17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18  GNU General Public License for more details.
     19
     20  You should have received a copy of the GNU General Public License with
     21  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
     22  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
     23  Suite 330, Boston, MA  02111-1307  USA
     24*/
     25
     26#define BITLBEE_CORE
    127#include "bitlbee.h"
     28
     29static char *set_eval_away_status( set_t *set, char *value );
    230
    331bee_t *bee_new()
     
    634        set_t *s;
    735       
    8         s = set_add( &b->set, "away", NULL, NULL/*set_eval_away_status*/, b );
     36        s = set_add( &b->set, "away", NULL, set_eval_away_status, b );
    937        s->flags |= SET_NULL_OK;
    1038        s = set_add( &b->set, "auto_connect", "true", set_eval_bool, b );
     
    1543        s->flags |= SET_NULL_OK;
    1644        s = set_add( &b->set, "save_on_quit", "true", set_eval_bool, b );
    17         s = set_add( &b->set, "status", NULL, NULL/*set_eval_away_status*/, b );
     45        s = set_add( &b->set, "status", NULL, set_eval_away_status, b );
    1846        s->flags |= SET_NULL_OK;
    1947        s = set_add( &b->set, "strip_html", "true", NULL, b );
     
    4674        g_free( b );
    4775}
     76
     77static char *set_eval_away_status( set_t *set, char *value )
     78{
     79        bee_t *bee = set->data;
     80        account_t *a;
     81       
     82        g_free( set->value );
     83        set->value = g_strdup( value );
     84       
     85        for( a = bee->accounts; a; a = a->next )
     86        {
     87                struct im_connection *ic = a->ic;
     88               
     89                if( ic && ic->flags & OPT_LOGGED_IN )
     90                        imc_away_send_update( ic );
     91        }
     92       
     93        return value;
     94}
Note: See TracChangeset for help on using the changeset viewer.