Changeset 3330468


Ignore:
Timestamp:
2010-03-14T23:15:05Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
81ee561
Parents:
7c5affca (diff), 7e2b593 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging in head.

Files:
27 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r7c5affca r3330468  
    4949
    5050clean: $(subdirs)
    51         rm -f *.o $(OUTFILE) core utils/bitlbeed encode decode
     51        rm -f *.o $(OUTFILE) core utils/bitlbeed
    5252        $(MAKE) -C tests clean
    5353
     
    124124endif
    125125
    126 encode: crypting.c
    127         $(CC) crypting.c lib/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS)
    128 
    129 decode: encode
    130         cp encode decode
    131 
    132126ctags:
    133127        ctags `find . -name "*.c"` `find . -name "*.h"`
  • account.c

    r7c5affca r3330468  
    5454       
    5555        s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a );
     56       
     57        s = set_add( &a->set, "nick_source", "handle", NULL, a );
    5658       
    5759        s = set_add( &a->set, "password", NULL, set_eval_account, a );
  • bitlbee.c

    r7c5affca r3330468  
    109109                chdir( "/" );
    110110               
    111                 /* Sometimes std* are already closed (for example when we're in a RESTARTed
    112                    BitlBee process. So let's only close TTY-fds. */
    113                 if( isatty( 0 ) ) close( 0 );
    114                 if( isatty( 1 ) ) close( 1 );
    115                 if( isatty( 2 ) ) close( 2 );
     111                i = close( 0 ) == 0;
     112                i += close( 1 ) == 0;
     113                i += close( 2 ) == 0;
     114                /* To avoid that something important ends up on one of those
     115                   fd's, open them for something bogus. Otherwise RESTART
     116                   may cause troubles. */
     117                while( i > 0 )
     118                {
     119                        open( "/dev/null", O_WRONLY );
     120                        i --;
     121                }
    116122        }
    117123#endif
  • bitlbee.conf

    r7c5affca r3330468  
    5555##
    5656## Password the user should enter when logging into a closed BitlBee server.
    57 ## You can also have an MD5-encrypted password here. Format: "md5:", followed
    58 ## by a hash as generated for the <user password=""> attribute in a BitlBee
    59 ## XML file (for now there's no easier way to generate the hash).
     57## You can also have a BitlBee-style MD5 hash here. Format: "md5:", followed
     58## by a hash as generated by "bitlbee -x hash <password>".
    6059##
    6160# AuthPassword = ItllBeBitlBee   ## Heh.. Our slogan. ;-)
     
    121120## Proxy = socks5://socksproxy.localnet.com
    122121
     122## Protocols offered by bitlbee
     123##
     124## As recompiling may be quite unpractical for some people, this option
     125## allows to remove the support of protocol, even if compiled in. If
     126## nothing is given, there are no restrictions.
     127##
     128## Protocols = jabber yahoo
     129
    123130
    124131[defaults]
  • bitlbee.h

    r7c5affca r3330468  
    2727#define _BITLBEE_H
    2828
     29#ifndef _GNU_SOURCE
    2930#define _GNU_SOURCE /* Stupid GNU :-P */
     31#endif
    3032
    3133/* Depend on Windows 2000 for now since we need getaddrinfo() */
     
    3335
    3436#define PACKAGE "BitlBee"
    35 #define BITLBEE_VERSION "1.2.4"
     37#define BITLBEE_VERSION "1.2.5"
    3638#define VERSION BITLBEE_VERSION
    3739
  • conf.c

    r7c5affca r3330468  
    6363        conf->ping_timeout = 300;
    6464        conf->user = NULL;
     65        conf->protocols = NULL;
    6566        proxytype = 0;
    6667       
     
    127128                {
    128129                        printf( "Usage: bitlbee [-D/-F [-i <interface>] [-p <port>] [-n] [-v]] [-I]\n"
    129                                 "               [-c <file>] [-d <dir>] [-h]\n"
     130                                "               [-c <file>] [-d <dir>] [-x] [-h]\n"
    130131                                "\n"
    131132                                "An IRC-to-other-chat-networks gateway\n"
     
    143144                                "  -c  Load alternative configuration file\n"
    144145                                "  -d  Specify alternative user configuration directory\n"
     146                                "  -x  Command-line interface to password encryption/hashing\n"
    145147                                "  -h  Show this help page.\n" );
    146148                        return NULL;
     
    306308                                conf->user = g_strdup( ini->value );
    307309                        }
     310                        else if( g_strcasecmp( ini->key, "protocols" ) == 0 )
     311                        {
     312                                g_strfreev( conf->protocols );
     313                                conf->protocols = g_strsplit_set( ini->value, " \t,;", -1 );
     314                        }
    308315                        else
    309316                        {
  • conf.h

    r7c5affca r3330468  
    5050        int ping_timeout;
    5151        char *user;
     52        char **protocols;
    5253} conf_t;
    5354
  • configure

    r7c5affca r3330468  
    159159
    160160echo CFLAGS=$CFLAGS >> Makefile.settings
    161 echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings
     161echo CFLAGS+=-I`pwd` -iquote`pwd`/lib -iquote`pwd`/protocols -I. >> Makefile.settings
    162162
    163163echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
     
    447447fi
    448448
     449if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then
     450        echo
     451        echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.'
     452        echo 'Install xmlto if you want online help to work.'
     453fi
     454
    449455echo
    450456if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
     
    556562;;
    557563Darwin )
     564        echo 'STRIP=\# skip strip' >> Makefile.settings
    558565;;
    559566IRIX )
  • crypting.c

    r7c5affca r3330468  
    132132        return (rv);
    133133}
    134 
    135 #ifdef CRYPTING_MAIN
    136 
    137 /* A little main() function for people who want a stand-alone program to
    138    encode/decode BitlCrypted files. */
    139 
    140 int main( int argc, char *argv[] )
    141 {
    142         char *hash, *action, line[256];
    143         char* (*func)( char *, const char * );
    144        
    145         if( argc < 2 )
    146         {
    147                 fprintf( stderr, "Usage: %s <password>\n\n"
    148                                  "Reads from stdin, writes to stdout.\n"
    149                                  "Call as \"encode\" to encode, \"decode\" to decode.\n", argv[0] );
    150                 return( 1 );
    151         }
    152        
    153         hash = hashpass( argv[1] );
    154         action = argv[0] + strlen( argv[0] ) - strlen( "encode" );
    155        
    156         if( strcmp( action, "encode" ) == 0 )
    157         {
    158                 fwrite( hash, 32, 1, stdout );
    159                 func = obfucrypt;
    160         }
    161         else if( strcmp( action, "decode" ) == 0 )
    162         {
    163                 char hash2[32];
    164                
    165                 fread( hash2, 32, 1, stdin );
    166                 if( memcmp( hash, hash2, 32 ) != 0 )
    167                 {
    168                         fprintf( stderr, "Passwords don't match. Can't decode.\n" );
    169                         return( 1 );
    170                 }
    171                 func = deobfucrypt;
    172         }
    173         else
    174         {
    175                 return( main( 0, NULL ) );
    176         }
    177        
    178         while( fscanf( stdin, "%[^\n]255s", line ) > 0 )
    179         {
    180                 char *out;
    181                
    182                 /* Flush the newline */
    183                 fgetc( stdin );
    184                
    185                 out = func( line, argv[1] );
    186                 printf( "%s\n", out );
    187                 g_free( out );
    188         }
    189        
    190         return( 0 );
    191 }
    192 
    193 #endif
  • doc/CHANGES

    r7c5affca r3330468  
    33
    44http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on
     5
     6Version 1.2.5:
     7- Many bug fixes, including a fix for MSN login issues, Jabber login timing
     8  issues, Yahoo! crashes at login time with huge contact lists,
     9- Avoid linking in a static version of libresolv now that glibc has all
     10  relevant functions available in the dynamic version.
     11- Improved away state code and added the ability to set (non-away) status
     12  messages using "set status" (also possible per account).
     13- Added a post-1.2 equivalent of encode/decode to quickly encrypt/decrypt
     14  passwords in a way that BitlBee can read them.
     15- Allow using the full name for generating nicknames, instead of just the
     16  handle. This is especially useful when using the Facebook XMPP server.
     17- Auto reconnect is now enabled by default since all protocols can properly
     18  detect cases where auto reconnect should be avoided (i.e. concurrent
     19  logins).
    520
    621Version 1.2.4:
  • doc/user-guide/commands.xml

    r7c5affca r3330468  
    608608        </bitlbee-setting>
    609609
     610        <bitlbee-setting name="nick_source" type="string" scope="account">
     611                <default>handle</default>
     612                <possible-values>handle, full_name, first_name</possible-values>
     613
     614                <description>
     615                        <para>
     616                                By default, BitlBee generates a nickname for every contact by taking its handle and chopping off everything after the @. In some cases, this gives very inconvenient nicknames. The Facebook XMPP server is a good example, as all Facebook XMPP handles are numeric.
     617                        </para>
     618
     619                        <para>
     620                                With this setting set to <emphasis>full_name</emphasis>, the person's full name is used to generate a nickname. Or if you don't like long nicknames, set this setting to <emphasis>first_name</emphasis> instead and only the first word will be used. Note that the full name can be full of non-ASCII characters which will be stripped off.
     621                        </para>
     622                </description>
     623        </bitlbee-setting>
     624
    610625        <bitlbee-setting name="ops" type="string" scope="global">
    611626                <default>both</default>
  • irc.c

    r7c5affca r3330468  
    166166        s = set_add( &irc->set, "away_devoice", "true",  set_eval_away_devoice, irc );
    167167        s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
    168         s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc );
     168        s = set_add( &irc->set, "auto_reconnect", "true", set_eval_bool, irc );
    169169        s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc );
    170170        s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc );
  • lib/misc.c

    r7c5affca r3330468  
    3434#include "nogaim.h"
    3535#include "base64.h"
     36#include "md5.h"
    3637#include <stdio.h>
    3738#include <stdlib.h>
     
    523524
    524525/* Word wrapping. Yes, I know this isn't UTF-8 clean. I'm willing to take the risk. */
    525 char *word_wrap( char *msg, int line_len )
     526char *word_wrap( const char *msg, int line_len )
    526527{
    527528        GString *ret = g_string_sized_new( strlen( msg ) + 16 );
  • lib/misc.h

    r7c5affca r3330468  
    6262G_MODULE_EXPORT struct ns_srv_reply *srv_lookup( char *service, char *protocol, char *domain );
    6363
    64 G_MODULE_EXPORT char *word_wrap( char *msg, int line_len );
     64G_MODULE_EXPORT char *word_wrap( const char *msg, int line_len );
    6565
    6666G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl );
  • protocols/jabber/io.c

    r7c5affca r3330468  
    375375       
    376376        if( ( c = xt_find_node( node->children, "bind" ) ) )
    377         {
    378                 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
    379                 xt_add_attr( reply, "xmlns", XMLNS_BIND );
    380                 reply = jabber_make_packet( "iq", "set", NULL, reply );
    381                 jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
    382                
    383                 if( !jabber_write_packet( ic, reply ) )
    384                         return XT_ABORT;
    385                
    386                 jd->flags |= JFLAG_WAIT_BIND;
    387         }
     377                jd->flags |= JFLAG_WANT_BIND;
    388378       
    389379        if( ( c = xt_find_node( node->children, "session" ) ) )
    390         {
    391                 reply = xt_new_node( "session", NULL, NULL );
    392                 xt_add_attr( reply, "xmlns", XMLNS_SESSION );
    393                 reply = jabber_make_packet( "iq", "set", NULL, reply );
    394                 jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
    395                
    396                 if( !jabber_write_packet( ic, reply ) )
    397                         return XT_ABORT;
    398                
    399                 jd->flags |= JFLAG_WAIT_SESSION;
    400         }
     380                jd->flags |= JFLAG_WANT_SESSION;
    401381       
    402382        /* This flag is already set if we authenticated via SASL, so now
    403383           we can resume the session in the new stream, if we don't have
    404384           to bind/initialize the session. */
    405         if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
     385        if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 )
    406386        {
    407387                if( !jabber_get_roster( ic ) )
    408388                        return XT_ABORT;
     389        }
     390        else if( jd->flags & JFLAG_AUTHENTICATED )
     391        {
     392                return jabber_pkt_bind_sess( ic, NULL, NULL );
    409393        }
    410394       
     
    441425        imcb_log( ic, "Converting stream to TLS" );
    442426       
     427        jd->flags |= JFLAG_STARTTLS_DONE;
    443428        jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic );
    444429       
     
    531516                jd->r_inpa = b_input_add( jd->fd, B_EV_IO_READ, jabber_read_callback, ic );
    532517       
    533         greet = g_strdup_printf( "<?xml version='1.0' ?>"
    534                                  "<stream:stream to=\"%s\" xmlns=\"jabber:client\" "
    535                                   "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", jd->server );
     518        greet = g_strdup_printf( "%s<stream:stream to=\"%s\" xmlns=\"jabber:client\" "
     519                                  "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">",
     520                                  ( jd->flags & JFLAG_STARTTLS_DONE ) ? "" : "<?xml version='1.0' ?>",
     521                                  jd->server );
    536522       
    537523        st = jabber_write( ic, greet, strlen( greet ) );
  • protocols/jabber/iq.c

    r7c5affca r3330468  
    298298{
    299299        struct jabber_data *jd = ic->proto_data;
    300         struct xt_node *c;
     300        struct xt_node *c, *reply = NULL;
    301301        char *s;
    302302       
    303         if( ( c = xt_find_node( node->children, "bind" ) ) )
     303        if( node && ( c = xt_find_node( node->children, "bind" ) ) )
    304304        {
    305305                c = xt_find_node( c->children, "jid" );
     
    308308                        imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
    309309               
    310                 jd->flags &= ~JFLAG_WAIT_BIND;
    311         }
    312         else
    313         {
    314                 jd->flags &= ~JFLAG_WAIT_SESSION;
    315         }
    316        
    317         if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
     310                jd->flags &= ~JFLAG_WANT_BIND;
     311        }
     312        else if( node && ( c = xt_find_node( node->children, "session" ) ) )
     313        {
     314                jd->flags &= ~JFLAG_WANT_SESSION;
     315        }
     316       
     317        if( jd->flags & JFLAG_WANT_BIND )
     318        {
     319                reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
     320                xt_add_attr( reply, "xmlns", XMLNS_BIND );
     321        }
     322        else if( jd->flags & JFLAG_WANT_SESSION )
     323        {
     324                reply = xt_new_node( "session", NULL, NULL );
     325                xt_add_attr( reply, "xmlns", XMLNS_SESSION );
     326        }
     327       
     328        if( reply != NULL )
     329        {
     330                reply = jabber_make_packet( "iq", "set", NULL, reply );
     331                jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
     332               
     333                if( !jabber_write_packet( ic, reply ) )
     334                        return XT_ABORT;
     335        }
     336        else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 )
    318337        {
    319338                if( !jabber_get_roster( ic ) )
  • protocols/jabber/jabber.h

    r7c5affca r3330468  
    4040        JFLAG_STREAM_RESTART = 4,       /* Set when we want to restart the stream (after
    4141                                           SASL or TLS). */
    42         JFLAG_WAIT_SESSION = 8,         /* Set if we sent a <session> tag and need a reply
     42        JFLAG_WANT_SESSION = 8,         /* Set if the server wants a <session/> tag
    4343                                           before we continue. */
    44         JFLAG_WAIT_BIND = 16,           /* ... for <bind> tag. */
     44        JFLAG_WANT_BIND = 16,           /* ... for <bind> tag. */
    4545        JFLAG_WANT_TYPING = 32,         /* Set if we ever sent a typing notification, this
    4646                                           activates all XEP-85 related code. */
    4747        JFLAG_XMLCONSOLE = 64,          /* If the user added an xmlconsole buddy. */
     48        JFLAG_STARTTLS_DONE = 128,      /* If a plaintext session was converted to TLS. */
    4849} jabber_flags_t;
    4950
  • protocols/msn/msn.c

    r7c5affca r3330468  
    2626#include "nogaim.h"
    2727#include "msn.h"
     28
     29int msn_chat_id;
     30GSList *msn_connections;
     31GSList *msn_switchboards;
    2832
    2933static char *msn_set_display_name( set_t *set, char *value );
  • protocols/msn/msn.h

    r7c5affca r3330468  
    135135#define STATUS_SB_CHAT_SPARE    8       /* Same, but also for groupchats (not used yet). */
    136136
    137 int msn_chat_id;
     137extern int msn_chat_id;
    138138extern const struct msn_away_state msn_away_state_list[];
    139139extern const struct msn_status_code msn_status_code_list[];
     
    144144   connection), the callback should check whether it's still listed here
    145145   before doing *anything* else. */
    146 GSList *msn_connections;
    147 GSList *msn_switchboards;
     146extern GSList *msn_connections;
     147extern GSList *msn_switchboards;
    148148
    149149/* ns.c */
  • protocols/msn/msn_util.c

    r7c5affca r3330468  
    171171               
    172172                /* End of headers? */
    173                 if( strncmp( text + i - 2, "\n\n", 2 ) == 0 ||
    174                     strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ||
    175                     strncmp( text + i - 2, "\r\r", 2 ) == 0 )
     173                if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) ||
     174                    ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 ||   
     175                                  strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) )
    176176                {
    177177                        break;
  • protocols/msn/ns.c

    r7c5affca r3330468  
    229229                        }
    230230                }
    231                 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 )
     231                else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 )
    232232                {
    233233                        set_t *s;
    234234                       
    235                         http_decode( cmd[4] );
    236                        
    237                         strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );
    238                         ic->displayname[sizeof(ic->displayname)-1] = 0;
    239                        
    240                         if( ( s = set_find( &ic->acc->set, "display_name" ) ) )
    241                         {
    242                                 g_free( s->value );
    243                                 s->value = g_strdup( cmd[4] );
     235                        if( num_parts == 7 )
     236                        {
     237                                http_decode( cmd[4] );
     238                               
     239                                strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );
     240                                ic->displayname[sizeof(ic->displayname)-1] = 0;
     241                               
     242                                if( ( s = set_find( &ic->acc->set, "display_name" ) ) )
     243                                {
     244                                        g_free( s->value );
     245                                        s->value = g_strdup( cmd[4] );
     246                                }
     247                        }
     248                        else
     249                        {
     250                                imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
    244251                        }
    245252                       
  • protocols/nogaim.c

    r7c5affca r3330468  
    9898void register_protocol (struct prpl *p)
    9999{
    100         protocols = g_list_append(protocols, p);
     100        int i;
     101        gboolean refused = global.conf->protocols != NULL;
     102 
     103        for (i = 0; global.conf->protocols && global.conf->protocols[i]; i++)
     104        {
     105                if (g_strcasecmp(p->name, global.conf->protocols[i]) == 0)
     106                        refused = FALSE;
     107        }
     108
     109        if (refused)
     110                log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name);
     111        else
     112                protocols = g_list_append(protocols, p);
    101113}
    102114
     
    379391/* list.c */
    380392
    381 void imcb_add_buddy( struct im_connection *ic, char *handle, char *group )
     393void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group )
    382394{
    383395        user_t *u;
     
    453465}
    454466
    455 void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname )
     467void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname )
    456468{
    457469        user_t *u = user_findhandle( ic, handle );
     470        char *set;
    458471       
    459472        if( !u || !realname ) return;
     
    468481                        imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
    469482        }
    470 }
    471 
    472 void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group )
     483       
     484        set = set_getstr( &ic->acc->set, "nick_source" );
     485        if( strcmp( set, "handle" ) != 0 )
     486        {
     487                char *name = g_strdup( realname );
     488               
     489                if( strcmp( set, "first_name" ) == 0 )
     490                {
     491                        int i;
     492                        for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {}
     493                        name[i] = '\0';
     494                }
     495               
     496                imcb_buddy_nick_hint( ic, handle, name );
     497               
     498                g_free( name );
     499        }
     500}
     501
     502void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group )
    473503{
    474504        user_t *u;
     
    480510/* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM
    481511   modules to suggest a nickname for a handle. */
    482 void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick )
     512void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick )
    483513{
    484514        user_t *u = user_findhandle( ic, handle );
     
    692722}
    693723
    694 void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at )
     724void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
    695725{
    696726        irc_t *irc = ic->irc;
     
    825855}
    826856
    827 void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at )
     857void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )
    828858{
    829859        struct im_connection *ic = c->ic;
     
    897927/* buddy_chat.c */
    898928
    899 void imcb_chat_add_buddy( struct groupchat *b, char *handle )
     929void imcb_chat_add_buddy( struct groupchat *b, const char *handle )
    900930{
    901931        user_t *u = user_findhandle( b->ic, handle );
     
    932962
    933963/* This function is one BIG hack... :-( EREWRITE */
    934 void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason )
     964void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason )
    935965{
    936966        user_t *u;
     
    10811111int imc_away_send_update( struct im_connection *ic )
    10821112{
    1083         char *away, *msg;
     1113        char *away, *msg = NULL;
    10841114       
    10851115        away = set_getstr( &ic->acc->set, "away" ) ?
  • protocols/nogaim.h

    r7c5affca r3330468  
    276276 * user, usually after a login, or if the user added a buddy and the IM
    277277 * server confirms that the add was successful. Don't forget to do this! */
    278 G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, char *handle, char *group );
    279 G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group );
     278G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group );
     279G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group );
    280280G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle );
    281 G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname );
    282 G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick );
     281G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname );
     282G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick );
    283283
    284284/* Buddy activity */
     
    290290/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
    291291/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
    292 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at );
     292G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at );
    293293G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags );
    294294G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle );
     
    303303 *   user, too. */
    304304G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle );
    305 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );
     305G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle );
    306306/* To remove a handle from a group chat. Reason can be NULL. */
    307 G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );
     307G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason );
    308308/* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */
    309 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at );
     309G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at );
    310310/* System messages specific to a groupchat, so they can be displayed in the right context. */
    311311G_MODULE_EXPORT void imcb_chat_log( struct groupchat *c, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
  • protocols/yahoo/libyahoo2.c

    r7c5affca r3330468  
    855855}
    856856
    857 static YList * bud_str2list(char *rawlist)
    858 {
    859         YList * l = NULL;
    860 
    861         char **lines;
    862         char **split;
    863         char **buddies;
    864         char **tmp, **bud;
    865 
    866         lines = y_strsplit(rawlist, "\n", -1);
    867         for (tmp = lines; *tmp; tmp++) {
    868                 struct yahoo_buddy *newbud;
    869 
    870                 split = y_strsplit(*tmp, ":", 2);
    871                 if (!split)
    872                         continue;
    873                 if (!split[0] || !split[1]) {
    874                         y_strfreev(split);
    875                         continue;
    876                 }
    877                 buddies = y_strsplit(split[1], ",", -1);
    878 
    879                 for (bud = buddies; bud && *bud; bud++) {
    880                         newbud = y_new0(struct yahoo_buddy, 1);
    881                         newbud->id = strdup(*bud);
    882                         newbud->group = strdup(split[0]);
    883 
    884                         if(y_list_find_custom(l, newbud, is_same_bud)) {
    885                                 FREE(newbud->id);
    886                                 FREE(newbud->group);
    887                                 FREE(newbud);
    888                                 continue;
    889                         }
    890 
    891                         newbud->real_name = NULL;
    892 
    893                         l = y_list_append(l, newbud);
    894 
    895                         NOTICE(("Added buddy %s to group %s", newbud->id, newbud->group));
    896                 }
    897 
    898                 y_strfreev(buddies);
    899                 y_strfreev(split);
    900         }
    901         y_strfreev(lines);
    902 
    903         return l;
    904 }
    905 
    906857static char * getcookie(char *rawcookie)
    907858{
     
    13601311}
    13611312
    1362 
    1363 static void yahoo_process_status(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
     1313static void yahoo_process_status(struct yahoo_input_data *yid,
     1314        struct yahoo_packet *pkt)
    13641315{
    13651316        YList *l;
    13661317        struct yahoo_data *yd = yid->yd;
    13671318
    1368         struct user
    1369         {
    1370                 char *name;     /* 7    name */
    1371                 int   state;    /* 10   state */
    1372                 int   flags;    /* 13   flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
    1373                 int   mobile;   /* 60   mobile */
    1374                 char *msg;      /* 19   custom status message */
    1375                 int   away;     /* 47   away (or invisible)*/
    1376                 int   buddy_session;    /* 11   state */
    1377                 int   f17;      /* 17   in chat? then what about flags? */
    1378                 int   idle;     /* 137  seconds idle */
    1379                 int   f138;     /* 138  state */
    1380                 char *f184;     /* 184  state */
    1381                 int   f192;     /* 192  state */
    1382                 int   f10001;   /* 10001        state */
    1383                 int   f10002;   /* 10002        state */
    1384                 int   f198;     /* 198  state */
    1385                 char *f197;     /* 197  state */
    1386                 char *f205;     /* 205  state */
    1387                 int   f213;     /* 213  state */
    1388         } *u;
     1319        struct yahoo_process_status_entry *u;
    13891320
    13901321        YList *users = 0;
    1391        
     1322
    13921323        if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
    1393                 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL);
    1394                 return;
    1395         }
     1324                YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
     1325                        YAHOO_LOGIN_DUPL, NULL);
     1326                return;
     1327        }
     1328
     1329        /* Status updates may be spread accross multiple packets and not
     1330           even on buddy boundaries, so keeping some state is important.
     1331           So, continue where we left off, and only add a user entry to
     1332           the list once it's complete (301-315 End buddy). */
     1333        u = yd->half_user;
    13961334
    13971335        for (l = pkt->hash; l; l = l->next) {
     
    13991337
    14001338                switch (pair->key) {
    1401                 case 0: /* we won't actually do anything with this */
     1339                case 300:       /* Begin buddy */
     1340                        if (!strcmp(pair->value, "315") && !u) {
     1341                                u = yd->half_user = y_new0(struct yahoo_process_status_entry, 1);
     1342                        }
     1343                        break;
     1344                case 301:       /* End buddy */
     1345                        if (!strcmp(pair->value, "315") && u) {
     1346                                users = y_list_prepend(users, u);
     1347                                u = yd->half_user = NULL;
     1348                        }
     1349                        break;
     1350                case 0: /* we won't actually do anything with this */
    14021351                        NOTICE(("key %d:%s", pair->key, pair->value));
    14031352                        break;
    1404                 case 1: /* we don't get the full buddy list here. */
     1353                case 1: /* we don't get the full buddy list here. */
    14051354                        if (!yd->logged_in) {
    1406                                 yd->logged_in = TRUE;
    1407                                 if(yd->current_status < 0)
     1355                                yd->logged_in = 1;
     1356                                if (yd->current_status < 0)
    14081357                                        yd->current_status = yd->initial_status;
    1409                                 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL);
     1358                                YAHOO_CALLBACK(ext_yahoo_login_response) (yd->
     1359                                        client_id, YAHOO_LOGIN_OK, NULL);
    14101360                        }
    14111361                        break;
    1412                 case 8: /* how many online buddies we have */
     1362                case 8: /* how many online buddies we have */
    14131363                        NOTICE(("key %d:%s", pair->key, pair->value));
    14141364                        break;
    1415                 case 7: /* the current buddy */
    1416                         u = y_new0(struct user, 1);
     1365                case 7: /* the current buddy */
     1366                        if (!u) {
     1367                                /* This will only happen in case of a single level message */
     1368                                u = y_new0(struct yahoo_process_status_entry, 1);
     1369                                users = y_list_prepend(users, u);
     1370                        }
    14171371                        u->name = pair->value;
    1418                         users = y_list_prepend(users, u);
    1419                         break;
    1420                 case 10: /* state */
    1421                         ((struct user*)users->data)->state = strtol(pair->value, NULL, 10);
    1422                         break;
    1423                 case 19: /* custom status message */
    1424                         ((struct user*)users->data)->msg = pair->value;
    1425                         break;
    1426                 case 47: /* is it an away message or not */
    1427                         ((struct user*)users->data)->away = atoi(pair->value);
    1428                         break;
    1429                 case 137: /* seconds idle */
    1430                         ((struct user*)users->data)->idle = atoi(pair->value);
    1431                         break;
    1432                 case 11: /* this is the buddy's session id */
    1433                         ((struct user*)users->data)->buddy_session = atoi(pair->value);
    1434                         break;
    1435                 case 17: /* in chat? */
    1436                         ((struct user*)users->data)->f17 = atoi(pair->value);
    1437                         break;
    1438                 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
    1439                         ((struct user*)users->data)->flags = atoi(pair->value);
    1440                         break;
    1441                 case 60: /* SMS -> 1 MOBILE USER */
     1372                        break;
     1373                case 10:        /* state */
     1374                        u->state = strtol(pair->value, NULL, 10);
     1375                        break;
     1376                case 19:        /* custom status message */
     1377                        u->msg = pair->value;
     1378                        break;
     1379                case 47:        /* is it an away message or not. Not applicable for YMSG16 anymore */
     1380                        u->away = atoi(pair->value);
     1381                        break;
     1382                case 137:       /* seconds idle */
     1383                        u->idle = atoi(pair->value);
     1384                        break;
     1385                case 11:        /* this is the buddy's session id */
     1386                        u->buddy_session = atoi(pair->value);
     1387                        break;
     1388                case 17:        /* in chat? */
     1389                        u->f17 = atoi(pair->value);
     1390                        break;
     1391                case 13:        /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
     1392                        u->flags = atoi(pair->value);
     1393                        break;
     1394                case 60:        /* SMS -> 1 MOBILE USER */
    14421395                        /* sometimes going offline makes this 2, but invisible never sends it */
    1443                         ((struct user*)users->data)->mobile = atoi(pair->value);
     1396                        u->mobile = atoi(pair->value);
    14441397                        break;
    14451398                case 138:
    1446                         ((struct user*)users->data)->f138 = atoi(pair->value);
     1399                        u->f138 = atoi(pair->value);
    14471400                        break;
    14481401                case 184:
    1449                         ((struct user*)users->data)->f184 = pair->value;
     1402                        u->f184 = pair->value;
    14501403                        break;
    14511404                case 192:
    1452                         ((struct user*)users->data)->f192 = atoi(pair->value);
     1405                        u->f192 = atoi(pair->value);
    14531406                        break;
    14541407                case 10001:
    1455                         ((struct user*)users->data)->f10001 = atoi(pair->value);
     1408                        u->f10001 = atoi(pair->value);
    14561409                        break;
    14571410                case 10002:
    1458                         ((struct user*)users->data)->f10002 = atoi(pair->value);
     1411                        u->f10002 = atoi(pair->value);
    14591412                        break;
    14601413                case 198:
    1461                         ((struct user*)users->data)->f198 = atoi(pair->value);
     1414                        u->f198 = atoi(pair->value);
    14621415                        break;
    14631416                case 197:
    1464                         ((struct user*)users->data)->f197 = pair->value;
     1417                        u->f197 = pair->value;
    14651418                        break;
    14661419                case 205:
    1467                         ((struct user*)users->data)->f205 = pair->value;
     1420                        u->f205 = pair->value;
    14681421                        break;
    14691422                case 213:
    1470                         ((struct user*)users->data)->f213 = atoi(pair->value);
    1471                         break;
    1472                 case 16: /* Custom error message */
    1473                         YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM);
     1423                        u->f213 = atoi(pair->value);
     1424                        break;
     1425                case 16:        /* Custom error message */
     1426                        YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id,
     1427                                pair->value, 0, E_CUSTOM);
    14741428                        break;
    14751429                default:
    1476                         WARNING(("unknown status key %d:%s", pair->key, pair->value));
    1477                         break;
    1478                 }
    1479         }
    1480        
     1430                        WARNING(("unknown status key %d:%s", pair->key,
     1431                                        pair->value));
     1432                        break;
     1433                }
     1434        }
     1435
    14811436        while (users) {
    14821437                YList *t = users;
    1483                 struct user *u = users->data;
     1438                struct yahoo_process_status_entry *u = users->data;
    14841439
    14851440                if (u->name != NULL) {
    1486                         if (pkt->service == YAHOO_SERVICE_LOGOFF) { /* || u->flags == 0) { Not in YMSG16 */
    1487                                 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
     1441                        if (pkt->service ==
     1442                                YAHOO_SERVICE_LOGOFF
     1443                                /*|| u->flags == 0 No flags for YMSG16 */ ) {
     1444                                YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->
     1445                                        client_id, u->name,
     1446                                        YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
    14881447                        } else {
    14891448                                /* Key 47 always seems to be 1 for YMSG16 */
    1490                                 if(!u->state)
     1449                                if (!u->state)
    14911450                                        u->away = 0;
    14921451                                else
    14931452                                        u->away = 1;
    14941453
    1495                                 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile);
     1454                                YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->
     1455                                        client_id, u->name, u->state, u->msg,
     1456                                        u->away, u->idle, u->mobile);
    14961457                        }
    14971458                }
     
    15031464}
    15041465
    1505 static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
     1466static void yahoo_process_buddy_list(struct yahoo_input_data *yid,
     1467        struct yahoo_packet *pkt)
    15061468{
    15071469        struct yahoo_data *yd = yid->yd;
     
    15151477                struct yahoo_pair *pair = l->data;
    15161478
    1517                 switch(pair->key) {
     1479                switch (pair->key) {
    15181480                case 300:
    15191481                case 301:
    15201482                case 302:
     1483                        break;  /* Separators. Our logic does not need them */
    15211484                case 303:
    1522                         if ( 315 == atoi(pair->value) )
     1485                        if (318 == atoi(pair->value))
    15231486                                last_packet = 1;
    15241487                        break;
    15251488                case 65:
    1526                         g_free(cur_group);
    15271489                        cur_group = strdup(pair->value);
    15281490                        break;
     
    15301492                        newbud = y_new0(struct yahoo_buddy, 1);
    15311493                        newbud->id = strdup(pair->value);
    1532                         if (cur_group) {
     1494                        if (cur_group)
    15331495                                newbud->group = strdup(cur_group);
    1534                         } else {
    1535                                 YList *last;
    1536                                 struct yahoo_buddy *lastbud;
    1537                                
    1538                                 for (last = yd->buddies; last && last->next; last = last->next);
    1539                                 if (last) {
    1540                                         lastbud = last->data;
    1541                                         newbud->group = strdup(lastbud->group);
    1542                                 } else {
    1543                                         newbud->group = strdup("Buddies");
    1544                                 }
    1545                         }
     1496                        else if (yd->buddies) {
     1497                                struct yahoo_buddy *lastbud =
     1498                                        (struct yahoo_buddy *)y_list_nth(yd->
     1499                                        buddies,
     1500                                        y_list_length(yd->buddies) - 1)->data;
     1501                                newbud->group = strdup(lastbud->group);
     1502                        } else
     1503                                newbud->group = strdup("Buddies");
    15461504
    15471505                        yd->buddies = y_list_append(yd->buddies, newbud);
     
    15501508                }
    15511509        }
    1552        
    1553         g_free(cur_group);
    15541510
    15551511        /* we could be getting multiple packets here */
    1556         if (last_packet)
    1557                 return;
    1558 
    1559         YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies);
    1560 
    1561         /*** We login at the very end of the packet communication */
     1512        if (pkt->hash && !last_packet)
     1513                return;
     1514
     1515        YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies);
     1516
     1517        /* Logged in */
    15621518        if (!yd->logged_in) {
    1563                 yd->logged_in = TRUE;
    1564                 if(yd->current_status < 0)
     1519                yd->logged_in = 1;
     1520                if (yd->current_status < 0)
    15651521                        yd->current_status = yd->initial_status;
    1566                 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL);
    1567         }
    1568 }
    1569 
    1570 static void yahoo_process_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
     1522                YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
     1523                        YAHOO_LOGIN_OK, NULL);
     1524
     1525                /*
     1526                yahoo_set_away(yd->client_id, yd->initial_status, NULL,
     1527                        (yd->initial_status == YAHOO_STATUS_AVAILABLE) ? 0 : 1);
     1528
     1529                yahoo_get_yab(yd->client_id);
     1530                */
     1531        }
     1532
     1533}
     1534
     1535static void yahoo_process_list(struct yahoo_input_data *yid,
     1536        struct yahoo_packet *pkt)
    15711537{
    15721538        struct yahoo_data *yd = yid->yd;
    15731539        YList *l;
    15741540
    1575         if (!yd->logged_in) {
    1576                 yd->logged_in = TRUE;
    1577                 if(yd->current_status < 0)
    1578                         yd->current_status = yd->initial_status;
    1579                 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL);
    1580         }
    1581 
     1541        /* we could be getting multiple packets here */
    15821542        for (l = pkt->hash; l; l = l->next) {
    15831543                struct yahoo_pair *pair = l->data;
    15841544
    1585                 switch(pair->key) {
    1586                 case 87: /* buddies */
    1587                         if(!yd->rawbuddylist)
    1588                                 yd->rawbuddylist = strdup(pair->value);
    1589                         else {
    1590                                 yd->rawbuddylist = y_string_append(yd->rawbuddylist, pair->value);
     1545                switch (pair->key) {
     1546                case 89:        /* identities */
     1547                        {
     1548                                char **identities =
     1549                                        y_strsplit(pair->value, ",", -1);
     1550                                int i;
     1551                                for (i = 0; identities[i]; i++)
     1552                                        yd->identities =
     1553                                                y_list_append(yd->identities,
     1554                                                strdup(identities[i]));
     1555                                y_strfreev(identities);
    15911556                        }
    1592                         break;
    1593 
    1594                 case 88: /* ignore list */
    1595                         if(!yd->ignorelist)
    1596                                 yd->ignorelist = strdup("Ignore:");
    1597                         yd->ignorelist = y_string_append(yd->ignorelist, pair->value);
    1598                         break;
    1599 
    1600                 case 89: /* identities */
    1601                         {
    1602                         char **identities = y_strsplit(pair->value, ",", -1);
    1603                         int i;
    1604                         for(i=0; identities[i]; i++)
    1605                                 yd->identities = y_list_append(yd->identities,
    1606                                                 strdup(identities[i]));
    1607                         y_strfreev(identities);
    1608                         }
    1609                         YAHOO_CALLBACK(ext_yahoo_got_identities)(yd->client_id, yd->identities);
    1610                         break;
    1611                 case 59: /* cookies */
    1612                         if(yd->ignorelist) {
    1613                                 yd->ignore = bud_str2list(yd->ignorelist);
    1614                                 FREE(yd->ignorelist);
    1615                                 YAHOO_CALLBACK(ext_yahoo_got_ignore)(yd->client_id, yd->ignore);
    1616                         }
    1617                         if(yd->rawbuddylist) {
    1618                                 yd->buddies = bud_str2list(yd->rawbuddylist);
    1619                                 FREE(yd->rawbuddylist);
    1620                                 YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies);
    1621                         }
    1622 
    1623                         if(pair->value[0]=='Y') {
     1557                        YAHOO_CALLBACK(ext_yahoo_got_identities) (yd->client_id,
     1558                                yd->identities);
     1559                        break;
     1560                case 59:        /* cookies */
     1561                        if (pair->value[0] == 'Y') {
    16241562                                FREE(yd->cookie_y);
    16251563                                FREE(yd->login_cookie);
     
    16281566                                yd->login_cookie = getlcookie(yd->cookie_y);
    16291567
    1630                         } else if(pair->value[0]=='T') {
     1568                        } else if (pair->value[0] == 'T') {
    16311569                                FREE(yd->cookie_t);
    16321570                                yd->cookie_t = getcookie(pair->value);
    16331571
    1634                         } else if(pair->value[0]=='C') {
     1572                        } else if (pair->value[0] == 'C') {
    16351573                                FREE(yd->cookie_c);
    16361574                                yd->cookie_c = getcookie(pair->value);
    1637                         } 
    1638 
    1639                         if(yd->cookie_y && yd->cookie_t)
    1640                                 YAHOO_CALLBACK(ext_yahoo_got_cookies)(yd->client_id);
    1641 
    1642                         break;
    1643                 case 3: /* my id */
    1644                 case 90: /* 1 */
    1645                 case 100: /* 0 */
    1646                 case 101: /* NULL */
    1647                 case 102: /* NULL */
    1648                 case 93: /* 86400/1440 */
    1649                         break;
    1650                 }
    1651         }
     1575                        }
     1576
     1577                        break;
     1578                case 3: /* my id */
     1579                case 90:        /* 1 */
     1580                case 100:       /* 0 */
     1581                case 101:       /* NULL */
     1582                case 102:       /* NULL */
     1583                case 93:        /* 86400/1440 */
     1584                        break;
     1585                }
     1586        }
     1587
     1588        if (yd->cookie_y && yd->cookie_t)       /* We don't get cookie_c anymore */
     1589                YAHOO_CALLBACK(ext_yahoo_got_cookies) (yd->client_id);
    16521590}
    16531591
  • protocols/yahoo/yahoo2_types.h

    r7c5affca r3330468  
    196196
    197197        void  *server_settings;
     198       
     199        struct yahoo_process_status_entry *half_user;
    198200};
    199201
     
    261263};
    262264
     265struct yahoo_process_status_entry {
     266        char *name;     /* 7      name */
     267        int state;      /* 10     state */
     268        int flags;      /* 13     flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
     269        int mobile;     /* 60     mobile */
     270        char *msg;      /* 19     custom status message */
     271        int away;       /* 47     away (or invisible) */
     272        int buddy_session; /* 11  state */
     273        int f17;        /* 17     in chat? then what about flags? */
     274        int idle;       /* 137    seconds idle */
     275        int f138;       /* 138    state */
     276        char *f184;     /* 184    state */
     277        int f192;       /* 192    state */
     278        int f10001;     /* 10001  state */
     279        int f10002;     /* 10002  state */
     280        int f198;       /* 198    state */
     281        char *f197;     /* 197    state */
     282        char *f205;     /* 205    state */
     283        int f213;       /* 213    state */
     284};
     285
    263286#ifdef __cplusplus
    264287}
  • root_commands.c

    r7c5affca r3330468  
    143143        storage_status_t status = storage_load( irc, cmd[1] );
    144144        char *account_on[] = { "account", "on", NULL };
     145       
     146        if( strchr( irc->umode, 'R' ) != NULL )
     147        {
     148                irc_usermsg( irc, "You're already logged in." );
     149                return;
     150        }
    145151       
    146152        switch (status) {
     
    11151121                irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] );
    11161122        }
    1117 
    1118 
    1119 
    1120 #if 0
    1121         account_t *a;
    1122         struct im_connection *ic;
    1123         char *chat, *channel, *nick = NULL, *password = NULL;
    1124         struct groupchat *c;
    1125        
    1126         if( !( a = account_get( irc, cmd[1] ) ) )
    1127         {
    1128                 irc_usermsg( irc, "Invalid account" );
    1129                 return;
    1130         }
    1131         else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) )
    1132         {
    1133                 irc_usermsg( irc, "That account is not on-line" );
    1134                 return;
    1135         }
    1136         else if( a->prpl->chat_join == NULL )
    1137         {
    1138                 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] );
    1139                 return;
    1140         }
    1141         ic = a->ic;
    1142        
    1143         chat = cmd[2];
    1144         if( cmd[3] )
    1145         {
    1146                 if( strchr( CTYPES, cmd[3][0] ) == NULL )
    1147                         channel = g_strdup_printf( "&%s", cmd[3] );
    1148                 else
    1149                         channel = g_strdup( cmd[3] );
    1150         }
    1151         else
    1152         {
    1153                 char *s;
    1154                
    1155                 channel = g_strdup_printf( "&%s", chat );
    1156                 if( ( s = strchr( channel, '@' ) ) )
    1157                         *s = 0;
    1158         }
    1159         if( cmd[3] && cmd[4] )
    1160                 nick = cmd[4];
    1161         else
    1162                 nick = irc->nick;
    1163         if( cmd[3] && cmd[4] && cmd[5] )
    1164                 password = cmd[5];
    1165        
    1166         if( !nick_ok( channel + 1 ) )
    1167         {
    1168                 irc_usermsg( irc, "Invalid channel name: %s", channel );
    1169                 g_free( channel );
    1170                 return;
    1171         }
    1172         else if( g_strcasecmp( channel, irc->channel ) == 0 || irc_chat_by_channel( irc, channel ) )
    1173         {
    1174                 irc_usermsg( irc, "Channel already exists: %s", channel );
    1175                 g_free( channel );
    1176                 return;
    1177         }
    1178        
    1179         if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) )
    1180         {
    1181                 g_free( c->channel );
    1182                 c->channel = channel;
    1183         }
    1184         else
    1185         {
    1186                 irc_usermsg( irc, "Tried to join chat, not sure if this was successful" );
    1187                 g_free( channel );
    1188         }
    1189 #endif
    11901123}
    11911124
  • unix.c

    r7c5affca r3330468  
    2525
    2626#include "bitlbee.h"
     27
     28#include "arc.h"
     29#include "base64.h"
    2730#include "commands.h"
    28 #include "crypting.h"
    2931#include "protocols/nogaim.h"
    3032#include "help.h"
    3133#include "ipc.h"
     34#include "md5.h"
     35#include "misc.h"
    3236#include <signal.h>
    3337#include <unistd.h>
     
    4044static void sighandler( int signal );
    4145
     46static int crypt_main( int argc, char *argv[] );
     47
    4248int main( int argc, char *argv[] )
    4349{
     
    4551        char *old_cwd = NULL;
    4652        struct sigaction sig, old;
     53       
     54        if( argc > 1 && strcmp( argv[1], "-x" ) == 0 )
     55                return crypt_main( argc, argv );
    4756       
    4857        log_init();
     
    160169}
    161170
     171static int crypt_main( int argc, char *argv[] )
     172{
     173        int pass_len;
     174        unsigned char *pass_cr, *pass_cl;
     175       
     176        if( argc < 4 || ( strcmp( argv[2], "hash" ) != 0 &&
     177                          strcmp( argv[2], "unhash" ) != 0 && argc < 5 ) )
     178        {
     179                printf( "Supported:\n"
     180                        "  %s -x enc <key> <cleartext password>\n"
     181                        "  %s -x dec <key> <encrypted password>\n"
     182                        "  %s -x hash <cleartext password>\n"
     183                        "  %s -x unhash <hashed password>\n"
     184                        "  %s -x chkhash <hashed password> <cleartext password>\n",
     185                        argv[0], argv[0], argv[0], argv[0], argv[0] );
     186        }
     187        else if( strcmp( argv[2], "enc" ) == 0 )
     188        {
     189                pass_len = arc_encode( argv[4], strlen( argv[4] ), (unsigned char**) &pass_cr, argv[3], 12 );
     190                printf( "%s\n", base64_encode( pass_cr, pass_len ) );
     191        }
     192        else if( strcmp( argv[2], "dec" ) == 0 )
     193        {
     194                pass_len = base64_decode( argv[4], (unsigned char**) &pass_cr );
     195                arc_decode( pass_cr, pass_len, (char**) &pass_cl, argv[3] );
     196                printf( "%s\n", pass_cl );
     197        }
     198        else if( strcmp( argv[2], "hash" ) == 0 )
     199        {
     200                md5_byte_t pass_md5[21];
     201                md5_state_t md5_state;
     202               
     203                random_bytes( pass_md5 + 16, 5 );
     204                md5_init( &md5_state );
     205                md5_append( &md5_state, (md5_byte_t*) argv[3], strlen( argv[3] ) );
     206                md5_append( &md5_state, pass_md5 + 16, 5 ); /* Add the salt. */
     207                md5_finish( &md5_state, pass_md5 );
     208               
     209                printf( "%s\n", base64_encode( pass_md5, 21 ) );
     210        }
     211        else if( strcmp( argv[2], "unhash" ) == 0 )
     212        {
     213                printf( "Hash %s submitted to a massive Beowulf cluster of\n"
     214                        "overclocked 486s. Expect your answer next year somewhere around this time. :-)\n", argv[3] );
     215        }
     216        else if( strcmp( argv[2], "chkhash" ) == 0 )
     217        {
     218                char *hash = strncmp( argv[3], "md5:", 4 ) == 0 ? argv[3] + 4 : argv[3];
     219                int st = md5_verify_password( argv[4], hash );
     220               
     221                printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" );
     222               
     223                return st;
     224        }
     225       
     226        return 0;
     227}
     228
    162229static void sighandler( int signal )
    163230{
     
    215282        return( (double) time->tv_sec + (double) time->tv_usec / 1000000 );
    216283}
    217 
    218 
Note: See TracChangeset for help on using the changeset viewer.