Changeset 5f8ab6a9
- Timestamp:
- 2010-06-03T10:41:03Z (14 years ago)
- Branches:
- master
- Children:
- 814aa52
- Parents:
- 3f81999 (diff), f9928cb (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. - Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r3f81999 r5f8ab6a9 49 49 50 50 clean: $(subdirs) 51 rm -f *.o $(OUTFILE) core utils/bitlbeed encode decode51 rm -f *.o $(OUTFILE) core utils/bitlbeed 52 52 $(MAKE) -C tests clean 53 53 … … 126 126 endif 127 127 128 encode: crypting.c129 $(CC) crypting.c lib/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS)130 131 decode: encode132 cp encode decode133 134 128 ctags: 135 129 ctags `find . -name "*.c"` `find . -name "*.h"` -
account.c
r3f81999 r5f8ab6a9 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 04Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 27 27 #include "bitlbee.h" 28 28 #include "account.h" 29 #include "chat.h" 29 30 30 31 account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) … … 54 55 s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a ); 55 56 57 s = set_add( &a->set, "nick_source", "handle", NULL, a ); 58 56 59 s = set_add( &a->set, "password", NULL, set_eval_account, a ); 57 60 s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; … … 68 71 prpl->init( a ); 69 72 70 return( a ); 73 s = set_add( &a->set, "away", NULL, set_eval_account, a ); 74 s->flags |= SET_NULL_OK; 75 76 if( a->flags & ACC_FLAG_STATUS_MESSAGE ) 77 { 78 s = set_add( &a->set, "status", NULL, set_eval_account, a ); 79 s->flags |= SET_NULL_OK; 80 } 81 82 return a; 71 83 } 72 84 … … 120 132 121 133 acc->auto_connect = bool2int( value ); 134 return value; 135 } 136 else if( strcmp( set->key, "away" ) == 0 || 137 strcmp( set->key, "status" ) == 0 ) 138 { 139 if( acc->ic && acc->ic->flags & OPT_LOGGED_IN ) 140 { 141 /* If we're currently on-line, set the var now already 142 (bit of a hack) and send an update. */ 143 g_free( set->value ); 144 set->value = g_strdup( value ); 145 146 imc_away_send_update( acc->ic ); 147 } 148 122 149 return value; 123 150 } … … 266 293 p->max = 86400; 267 294 268 /* Format: /[0-9]+([*+][0-9]+(<[0-9+]) )/ */295 /* Format: /[0-9]+([*+][0-9]+(<[0-9+])?)?/ */ 269 296 while( *value && isdigit( *value ) ) 270 297 p->start = p->start * 10 + *value++ - '0'; -
account.h
r3f81999 r5f8ab6a9 37 37 int auto_reconnect_delay; 38 38 int reconnect; 39 int flags; 39 40 40 41 set_t *set; … … 56 57 int account_reconnect_delay( account_t *a ); 57 58 58 #define ACC_SET_NOSAVE 0x01 59 #define ACC_SET_OFFLINE_ONLY 0x02 60 #define ACC_SET_ONLINE_ONLY 0x04 59 typedef enum 60 { 61 ACC_SET_NOSAVE = 0x01, /* Don't save this setting (i.e. stored elsewhere). */ 62 ACC_SET_OFFLINE_ONLY = 0x02, /* Allow changes only if the acct is offline. */ 63 ACC_SET_ONLINE_ONLY = 0x04, /* Allow changes only if the acct is online. */ 64 } account_set_flag_t; 65 66 typedef enum 67 { 68 ACC_FLAG_AWAY_MESSAGE = 0x01, /* Supports away messages instead of just states. */ 69 ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */ 70 } account_flag_t; 61 71 62 72 #endif -
bitlbee.c
r3f81999 r5f8ab6a9 109 109 chdir( "/" ); 110 110 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 if( getenv( "_BITLBEE_RESTART_STATE" ) == NULL ) 112 for( i = 0; i < 3; i ++ ) 113 if( close( i ) == 0 ) 114 { 115 /* Keep something bogus on those fd's just in case. */ 116 open( "/dev/null", O_WRONLY ); 117 } 116 118 } 117 119 #endif -
bitlbee.conf
r3f81999 r5f8ab6a9 55 55 ## 56 56 ## 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>". 60 59 ## 61 60 # AuthPassword = ItllBeBitlBee ## Heh.. Our slogan. ;-) … … 128 127 ## Proxy = socks5://socksproxy.localnet.com 129 128 129 ## Protocols offered by bitlbee 130 ## 131 ## As recompiling may be quite unpractical for some people, this option 132 ## allows to remove the support of protocol, even if compiled in. If 133 ## nothing is given, there are no restrictions. 134 ## 135 ## Protocols = jabber yahoo 136 130 137 131 138 [defaults] -
bitlbee.h
r3f81999 r5f8ab6a9 27 27 #define _BITLBEE_H 28 28 29 #ifndef _GNU_SOURCE 29 30 #define _GNU_SOURCE /* Stupid GNU :-P */ 31 #endif 30 32 31 33 /* Depend on Windows 2000 for now since we need getaddrinfo() */ … … 36 38 37 39 #define PACKAGE "BitlBee" 38 #define BITLBEE_VERSION "1.2. 4"40 #define BITLBEE_VERSION "1.2.5" 39 41 #define VERSION BITLBEE_VERSION 40 42 … … 132 134 #include "account.h" 133 135 #include "nick.h" 134 #include "chat.h"135 136 #include "conf.h" 136 137 #include "log.h" -
chat.c
r3f81999 r5f8ab6a9 25 25 26 26 #include "bitlbee.h" 27 #include "chat.h" 27 28 28 29 struct chat *chat_add( irc_t *irc, account_t *acc, char *handle, char *channel ) -
chat.h
r3f81999 r5f8ab6a9 24 24 */ 25 25 26 #ifndef _CHAT_H 27 #define _CHAT_H 28 26 29 struct chat 27 30 { … … 45 48 46 49 int chat_join( irc_t *irc, struct chat *c, const char *password ); 50 51 #endif -
conf.c
r3f81999 r5f8ab6a9 64 64 conf->ping_timeout = 300; 65 65 conf->user = NULL; 66 conf->protocols = NULL; 66 67 proxytype = 0; 67 68 … … 128 129 { 129 130 printf( "Usage: bitlbee [-D/-F [-i <interface>] [-p <port>] [-n] [-v]] [-I]\n" 130 " [-c <file>] [-d <dir>] [- h]\n"131 " [-c <file>] [-d <dir>] [-x] [-h]\n" 131 132 "\n" 132 133 "An IRC-to-other-chat-networks gateway\n" … … 144 145 " -c Load alternative configuration file\n" 145 146 " -d Specify alternative user configuration directory\n" 147 " -x Command-line interface to password encryption/hashing\n" 146 148 " -h Show this help page.\n" ); 147 149 return NULL; … … 312 314 conf->user = g_strdup( ini->value ); 313 315 } 316 else if( g_strcasecmp( ini->key, "protocols" ) == 0 ) 317 { 318 g_strfreev( conf->protocols ); 319 conf->protocols = g_strsplit_set( ini->value, " \t,;", -1 ); 320 } 314 321 else 315 322 { -
conf.h
r3f81999 r5f8ab6a9 51 51 int ping_timeout; 52 52 char *user; 53 char **protocols; 53 54 } conf_t; 54 55 -
configure
r3f81999 r5f8ab6a9 158 158 159 159 echo CFLAGS=$CFLAGS >> Makefile.settings 160 echo CFLAGS+=-I`pwd` - I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings160 echo CFLAGS+=-I`pwd` -iquote`pwd`/lib -iquote`pwd`/protocols -I. >> Makefile.settings 161 161 162 162 echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings … … 269 269 detect_ldap() 270 270 { 271 TMPFILE= `mktemp`271 TMPFILE=$(mktemp) 272 272 if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then 273 273 cat<<EOF>>Makefile.settings … … 282 282 ret=0 283 283 fi 284 } 285 286 RESOLV_TESTCODE=' 287 #include <arpa/nameser.h> 288 #include <resolv.h> 289 290 int main() 291 { 292 ns_initparse( NULL, 0, NULL ); 293 ns_parserr( NULL, ns_s_an, 0, NULL ); 294 } 295 ' 296 297 detect_resolv_dynamic() 298 { 299 echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -lresolv >/dev/null 2>/dev/null 300 if [ "$?" = "0" ]; then 301 echo 'EFLAGS+=-lresolv' >> Makefile.settings 302 return 0 303 fi 304 305 return 1 306 } 307 308 detect_resolv_static() 309 { 310 for i in $systemlibdirs; do 311 if [ -f $i/libresolv.a ]; then 312 echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null 313 if [ "$?" = "0" ]; then 314 echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings 315 return 0 316 fi 317 fi 318 done 319 320 return 1 284 321 } 285 322 … … 325 362 326 363 ## Yes, you, at the console! How can you authenticate if you don't have any SSL!? 327 if [ "$msn" = "1" ]; then364 if [ "$msn" = "1" -o "$yahoo" = "1" ]; then 328 365 echo 329 echo 'Real SSL support is necessary for MSN authentication, will build without' 330 echo 'MSN protocol support.' 366 echo 'WARNING: The MSN and Yahoo! modules will not work without SSL. Disabling.' 331 367 msn=0 368 yahoo=0 332 369 fi 333 370 … … 351 388 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 352 389 353 for i in $systemlibdirs; do 354 if [ -f $i/libresolv.a ]; then 355 echo '#define HAVE_RESOLV_A' >> config.h 356 echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings 357 break 358 fi 359 done 390 if detect_resolv_dynamic || detect_resolv_static; then 391 echo '#define HAVE_RESOLV_A' >> config.h 392 fi 360 393 361 394 STORAGES="text xml" … … 435 468 fi 436 469 470 if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then 471 echo 472 echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.' 473 echo 'Install xmlto if you want online help to work.' 474 fi 475 437 476 echo 438 477 if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then … … 520 559 ;; 521 560 Darwin ) 561 echo 'STRIP=\# skip strip' >> Makefile.settings 522 562 ;; 523 563 IRIX ) -
crypting.c
r3f81999 r5f8ab6a9 132 132 return (rv); 133 133 } 134 135 #ifdef CRYPTING_MAIN136 137 /* A little main() function for people who want a stand-alone program to138 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 else174 {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
r3f81999 r5f8ab6a9 3 3 4 4 http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on 5 6 Version 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) and see them in 13 blist and /whois output. 14 - Added a post-1.2 equivalent of encode/decode to quickly encrypt/decrypt 15 passwords in a way that BitlBee can read them. 16 - Allow using the full name for generating nicknames, instead of just the 17 handle. This is especially useful when using the Facebook XMPP server. 18 - Auto reconnect is now enabled by default since all protocols can properly 19 detect cases where auto reconnect should be avoided (i.e. concurrent 20 logins). 21 - Changed the default resource_select setting which should reduce message 22 routing issues on Jabber (i.e. messages going someone's phone instead of 23 the main client). 24 25 Fixed 17 Mar 2010 5 26 6 27 Version 1.2.4: -
doc/user-guide/commands.xml
r3f81999 r5f8ab6a9 585 585 </bitlbee-setting> 586 586 587 <bitlbee-setting name="away" type="string" scope="both"> 588 <description> 589 <para> 590 To mark yourself as away, it is recommended to just use <emphasis>/away</emphasis>, like on normal IRC networks. If you want to mark yourself as away on only one IM network, you can use this per-account setting. 591 </para> 592 593 <para> 594 You can set it to any value and BitlBee will try to map it to the most appropriate away state for every open IM connection, or set it as a free-form away message where possible. 595 </para> 596 597 <para> 598 Any per-account away setting will override globally set away states. To un-set the setting, use <emphasis>set -del away</emphasis>. 599 </para> 600 </description> 601 </bitlbee-setting> 602 587 603 <bitlbee-setting name="away_devoice" type="boolean" scope="global"> 588 604 <default>true</default> … … 818 834 </bitlbee-setting> 819 835 836 <bitlbee-setting name="nick_source" type="string" scope="account"> 837 <default>handle</default> 838 <possible-values>handle, full_name, first_name</possible-values> 839 840 <description> 841 <para> 842 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. 843 </para> 844 845 <para> 846 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. 847 </para> 848 </description> 849 </bitlbee-setting> 850 851 <bitlbee-setting name="ops" type="string" scope="global"> 852 <default>both</default> 853 <possible-values>both, root, user, none</possible-values> 854 855 <description> 856 <para> 857 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can change these states using this setting. 858 </para> 859 860 <para> 861 The value "both" means both user and root get ops. "root" means, well, just root. "user" means just the user. "none" means nobody will get operator status. 862 </para> 863 </description> 864 </bitlbee-setting> 865 820 866 <bitlbee-setting name="password" type="string" scope="both"> 821 867 <description> … … 896 942 897 943 <bitlbee-setting name="resource_select" type="string" scope="account"> 898 <default> priority</default>944 <default>activity</default> 899 945 <possible-values>priority, activity</possible-values> 900 946 … … 954 1000 <para> 955 1001 Currently only available for Jabber connections. Set this to true if the server accepts SSL connections. 1002 </para> 1003 </description> 1004 </bitlbee-setting> 1005 1006 <bitlbee-setting name="status" type="string" scope="both"> 1007 <description> 1008 <para> 1009 Certain protocols (like Jabber/XMPP) support status messages, similar to away messages. They can be used to indicate things like your location or activity, without showing up as away/busy. 1010 </para> 1011 1012 <para> 1013 This setting can be used to set such a message. It will be available as a per-account setting for protocols that support it, and also as a global setting (which will then automatically be used for all protocols that support it). 1014 </para> 1015 1016 <para> 1017 Away states set using <emphasis>/away</emphasis> or the <emphasis>away</emphasis> setting will override this setting. To un-set the setting, use <emphasis>set -del status</emphasis>. 956 1018 </para> 957 1019 </description> -
doc/user-guide/misc.xml
r3f81999 r5f8ab6a9 77 77 78 78 <para> 79 Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the <emphasis>chat add</emphasis> command to join them. See <emphasis>help chat _add</emphasis> for more information.79 Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the <emphasis>chat add</emphasis> command to join them. See <emphasis>help chat add</emphasis> for more information. 80 80 </para> 81 81 … … 86 86 87 87 <para> 88 As you might've expected, you can just use the <emphasis>/away</emphasis> command in your IRC client to set an away-state. BitlBee supports most away-states supported by the protocols.88 To mark yourself as away, you can just use the <emphasis>/away</emphasis> command in your IRC client. BitlBee supports most away-states supported by the protocols. 89 89 </para> 90 90 91 91 <para> 92 Not all away states are supported by all protocols, and some protocols have different names for them. BitlBee will try to pick the best available alias from this listfor every connection:92 Away states have different names accross different protocols. BitlBee will try to pick the best available option for every connection: 93 93 </para> 94 94 95 95 <simplelist> 96 <member>Away from computer, Away, Extended away</member>97 <member>NA , N/A, Not available</member>98 <member>Busy, D o not disturb, DND, Occupied</member>99 <member>B e right back, BRB</member>100 <member> On the phone, Phone, On phone</member>101 <member> Out to lunch,Lunch, Food</member>96 <member>Away</member> 97 <member>NA</member> 98 <member>Busy, DND</member> 99 <member>BRB</member> 100 <member>Phone</member> 101 <member>Lunch, Food</member> 102 102 <member>Invisible, Hidden</member> 103 103 </simplelist> 104 104 105 105 <para> 106 So <emphasis>/away Food</emphasis> will set your state to "Out to lunch" on your MSN connection, and for most other connections the default, "Away" or "Away from computer"will be chosen.106 So <emphasis>/away Food</emphasis> will set your state to "Out to lunch" on your MSN connection, and for most other connections the default, "Away" will be chosen. 107 107 </para> 108 108 … … 111 111 </para> 112 112 113 <para> 114 If you want to set an away state for only one of your connections, you can use the per-account <emphasis>away</emphasis> setting. See <emphasis>help set away</emphasis>. 115 </para> 116 113 117 </sect1> 114 118 -
irc.c
r3f81999 r5f8ab6a9 81 81 } 82 82 83 static char *set_eval_away_status( set_t *set, char *value ) 84 { 85 irc_t *irc = set->data; 86 account_t *a; 87 88 g_free( set->value ); 89 set->value = g_strdup( value ); 90 91 for( a = irc->accounts; a; a = a->next ) 92 { 93 struct im_connection *ic = a->ic; 94 95 if( ic && ic->flags & OPT_LOGGED_IN ) 96 imc_away_send_update( ic ); 97 } 98 99 return value; 100 } 101 83 102 irc_t *irc_new( int fd ) 84 103 { … … 147 166 148 167 168 s = set_add( &irc->set, "away", NULL, set_eval_away_status, irc ); 169 s->flags |= SET_NULL_OK; 149 170 s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 150 s = set_add( &irc->set, "auto_reconnect", " false", set_eval_bool, irc );171 s = set_add( &irc->set, "auto_reconnect", "true", set_eval_bool, irc ); 151 172 s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc ); 152 173 s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); -
irc_commands.c
r3f81999 r5f8ab6a9 27 27 #include "bitlbee.h" 28 28 #include "ipc.h" 29 #include "chat.h" 29 30 30 31 static void irc_cmd_pass( irc_t *irc, char **cmd ) … … 447 448 user_t *u = user_find( irc, irc->nick ); 448 449 char *away = cmd[1]; 449 account_t *a;450 450 451 451 if( !u ) return; … … 474 474 } 475 475 476 for( a = irc->accounts; a; a = a->next ) 477 { 478 struct im_connection *ic = a->ic; 479 480 if( ic && ic->flags & OPT_LOGGED_IN ) 481 imc_set_away( ic, u->away ); 482 } 476 set_setstr( &irc->set, "away", u->away ); 483 477 } 484 478 … … 503 497 else if( u->away ) 504 498 irc_reply( irc, 301, "%s :%s", u->nick, u->away ); 499 if( u->status_msg ) 500 irc_reply( irc, 333, "%s :Status: %s", u->nick, u->status_msg ); 505 501 506 502 irc_reply( irc, 318, "%s :End of /WHOIS list", nick ); -
lib/misc.c
r3f81999 r5f8ab6a9 34 34 #include "nogaim.h" 35 35 #include "base64.h" 36 #include "md5.h" 36 37 #include <stdio.h> 37 38 #include <stdlib.h> … … 46 47 #endif 47 48 49 #include "md5.h" 48 50 #include "ssl_client.h" 49 51 … … 532 534 533 535 /* Word wrapping. Yes, I know this isn't UTF-8 clean. I'm willing to take the risk. */ 534 char *word_wrap( c har *msg, int line_len )536 char *word_wrap( const char *msg, int line_len ) 535 537 { 536 538 GString *ret = g_string_sized_new( strlen( msg ) + 16 ); -
lib/misc.h
r3f81999 r5f8ab6a9 62 62 G_MODULE_EXPORT struct ns_srv_reply *srv_lookup( char *service, char *protocol, char *domain ); 63 63 64 G_MODULE_EXPORT char *word_wrap( c har *msg, int line_len );64 G_MODULE_EXPORT char *word_wrap( const char *msg, int line_len ); 65 65 66 66 G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); -
protocols/jabber/io.c
r3f81999 r5f8ab6a9 375 375 376 376 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; 388 378 389 379 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 } 401 402 /* This flag is already set if we authenticated via SASL, so now 403 we can resume the session in the new stream, if we don't have 404 to bind/initialize the session. */ 405 if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 406 { 407 if( !jabber_get_roster( ic ) ) 408 return XT_ABORT; 409 } 380 jd->flags |= JFLAG_WANT_SESSION; 381 382 if( jd->flags & JFLAG_AUTHENTICATED ) 383 return jabber_pkt_bind_sess( ic, NULL, NULL ); 410 384 411 385 return XT_HANDLED; … … 441 415 imcb_log( ic, "Converting stream to TLS" ); 442 416 417 jd->flags |= JFLAG_STARTTLS_DONE; 443 418 jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic ); 444 419 … … 531 506 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic ); 532 507 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 ); 508 greet = g_strdup_printf( "%s<stream:stream to=\"%s\" xmlns=\"jabber:client\" " 509 "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", 510 ( jd->flags & JFLAG_STARTTLS_DONE ) ? "" : "<?xml version='1.0' ?>", 511 jd->server ); 536 512 537 513 st = jabber_write( ic, greet, strlen( greet ) ); -
protocols/jabber/iq.c
r3f81999 r5f8ab6a9 298 298 { 299 299 struct jabber_data *jd = ic->proto_data; 300 struct xt_node *c ;300 struct xt_node *c, *reply = NULL; 301 301 char *s; 302 302 303 if( ( c = xt_find_node( node->children, "bind" ) ) )303 if( node && ( c = xt_find_node( node->children, "bind" ) ) ) 304 304 { 305 305 c = xt_find_node( c->children, "jid" ); … … 307 307 strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) 308 308 imcb_log( ic, "Server changed session resource string to `%s'", s + 1 ); 309 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 ) 309 } 310 311 if( jd->flags & JFLAG_WANT_BIND ) 312 { 313 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); 314 xt_add_attr( reply, "xmlns", XMLNS_BIND ); 315 jd->flags &= ~JFLAG_WANT_BIND; 316 } 317 else if( jd->flags & JFLAG_WANT_SESSION ) 318 { 319 reply = xt_new_node( "session", NULL, NULL ); 320 xt_add_attr( reply, "xmlns", XMLNS_SESSION ); 321 jd->flags &= ~JFLAG_WANT_SESSION; 322 } 323 324 if( reply != NULL ) 325 { 326 reply = jabber_make_packet( "iq", "set", NULL, reply ); 327 jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); 328 329 if( !jabber_write_packet( ic, reply ) ) 330 return XT_ABORT; 331 } 332 else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) 318 333 { 319 334 if( !jabber_get_roster( ic ) ) -
protocols/jabber/jabber.c
r3f81999 r5f8ab6a9 67 67 s->flags |= ACC_SET_OFFLINE_ONLY; 68 68 69 s = set_add( &acc->set, "resource_select", " priority", NULL, acc );69 s = set_add( &acc->set, "resource_select", "activity", NULL, acc ); 70 70 71 71 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); … … 80 80 s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc ); 81 81 s->flags |= ACC_SET_OFFLINE_ONLY; 82 83 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; 82 84 } 83 85 … … 364 366 while( bud ) 365 367 { 366 imcb_log( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s", 367 bud->full_jid, bud->priority, 368 bud->away_state ? bud->away_state->full_name : "(none)", 369 bud->away_message ? : "(none)" ); 368 imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority ); 369 if( bud->away_state ) 370 imcb_log( ic, "Away state: %s", bud->away_state->full_name ); 371 imcb_log( ic, "Status message: %s", bud->away_message ? : "(none)" ); 372 370 373 bud = bud->next; 371 374 } … … 377 380 { 378 381 struct jabber_data *jd = ic->proto_data; 379 struct jabber_away_state *state; 380 381 /* Save all this info. We need it, for example, when changing the priority setting. */ 382 state = (void *) jabber_away_state_by_name( state_txt ); 383 jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */ 382 383 /* state_txt == NULL -> Not away. 384 Unknown state -> fall back to the first defined away state. */ 385 jd->away_state = state_txt ? jabber_away_state_by_name( state_txt ) 386 ? : jabber_away_state_list : NULL; 387 384 388 g_free( jd->away_message ); 385 389 jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL; -
protocols/jabber/jabber.h
r3f81999 r5f8ab6a9 27 27 #include <glib.h> 28 28 29 #include "bitlbee.h" 30 #include "md5.h" 29 31 #include "xmltree.h" 30 #include "bitlbee.h"31 32 32 33 extern GSList *jabber_connections; … … 39 40 JFLAG_STREAM_RESTART = 4, /* Set when we want to restart the stream (after 40 41 SASL or TLS). */ 41 JFLAG_WA IT_SESSION = 8, /* Set if we sent a <session> tag and need a reply42 JFLAG_WANT_SESSION = 8, /* Set if the server wants a <session/> tag 42 43 before we continue. */ 43 JFLAG_WA IT_BIND = 16, /* ... for <bind> tag. */44 JFLAG_WANT_BIND = 16, /* ... for <bind> tag. */ 44 45 JFLAG_WANT_TYPING = 32, /* Set if we ever sent a typing notification, this 45 46 activates all XEP-85 related code. */ 46 47 JFLAG_XMLCONSOLE = 64, /* If the user added an xmlconsole buddy. */ 48 JFLAG_STARTTLS_DONE = 128, /* If a plaintext session was converted to TLS. */ 47 49 } jabber_flags_t; 48 50 … … 83 85 /* After changing one of these two (or the priority setting), call 84 86 presence_send_update() to inform the server about the changes. */ 85 struct jabber_away_state *away_state;87 const struct jabber_away_state *away_state; 86 88 char *away_message; 87 89 -
protocols/jabber/jabber_util.c
r3f81999 r5f8ab6a9 228 228 { 229 229 { "away", "Away" }, 230 { "chat", "Free for Chat" }, 230 { "chat", "Free for Chat" }, /* WTF actually uses this? */ 231 231 { "dnd", "Do not Disturb" }, 232 232 { "xa", "Extended Away" }, 233 { "", "Online" },234 233 { "", NULL } 235 234 }; … … 238 237 { 239 238 int i; 239 240 if( code == NULL ) 241 return NULL; 240 242 241 243 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) … … 249 251 { 250 252 int i; 253 254 if( name == NULL ) 255 return NULL; 251 256 252 257 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) -
protocols/jabber/presence.c
r3f81999 r5f8ab6a9 190 190 int is_away = 0; 191 191 192 if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||193 strcmp( send_presence->away_state->code, "chat" ) == 0 ))192 if( send_presence->away_state && 193 strcmp( send_presence->away_state->code, "chat" ) != 0 ) 194 194 is_away = OPT_AWAY; 195 195 196 196 imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away, 197 ( is_away && send_presence->away_state ) ? 198 send_presence->away_state->full_name : NULL, 197 is_away ? send_presence->away_state->full_name : NULL, 199 198 send_presence->away_message ); 200 199 } … … 209 208 struct jabber_data *jd = ic->proto_data; 210 209 struct xt_node *node, *cap; 211 char *show = jd->away_state->code;212 char *status = jd->away_message;213 210 struct groupchat *c; 214 211 int st; … … 216 213 node = jabber_make_packet( "presence", NULL, NULL, NULL ); 217 214 xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) ); 218 if( show && *show)219 xt_add_child( node, xt_new_node( "show", show, NULL ) );220 if( status)221 xt_add_child( node, xt_new_node( "status", status, NULL ) );215 if( jd->away_state ) 216 xt_add_child( node, xt_new_node( "show", jd->away_state->code, NULL ) ); 217 if( jd->away_message ) 218 xt_add_child( node, xt_new_node( "status", jd->away_message, NULL ) ); 222 219 223 220 /* This makes the packet slightly bigger, but clients interested in -
protocols/msn/msn.c
r3f81999 r5f8ab6a9 26 26 #include "nogaim.h" 27 27 #include "msn.h" 28 29 int msn_chat_id; 30 GSList *msn_connections; 31 GSList *msn_switchboards; 28 32 29 33 static char *msn_set_display_name( set_t *set, char *value ); … … 139 143 140 144 if( l == NULL ) 141 for( i = 0; msn_away_state_list[i].number > -1; i ++ ) 142 l = g_list_append( l, (void*) msn_away_state_list[i].name ); 145 for( i = 0; *msn_away_state_list[i].code; i ++ ) 146 if( *msn_away_state_list[i].name ) 147 l = g_list_append( l, (void*) msn_away_state_list[i].name ); 143 148 144 149 return l; … … 149 154 char buf[1024]; 150 155 struct msn_data *md = ic->proto_data; 151 const struct msn_away_state *st;152 153 if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 )154 st = msn_away_state_by_name( "Away" );156 157 if( state ) 158 md->away_state = msn_away_state_by_name( state ) ? : 159 msn_away_state_list + 1; 155 160 else 156 st = msn_away_state_by_name( state ); 157 158 if( !st ) st = msn_away_state_list; 159 md->away_state = st; 160 161 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); 161 md->away_state = msn_away_state_list; 162 163 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code ); 162 164 msn_write( ic, buf, strlen( buf ) ); 163 165 } -
protocols/msn/msn.h
r3f81999 r5f8ab6a9 97 97 struct msn_away_state 98 98 { 99 int number;100 99 char code[4]; 101 100 char name[16]; … … 136 135 #define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ 137 136 138 int msn_chat_id;137 extern int msn_chat_id; 139 138 extern const struct msn_away_state msn_away_state_list[]; 140 139 extern const struct msn_status_code msn_status_code_list[]; … … 145 144 connection), the callback should check whether it's still listed here 146 145 before doing *anything* else. */ 147 GSList *msn_connections;148 GSList *msn_switchboards;146 extern GSList *msn_connections; 147 extern GSList *msn_switchboards; 149 148 150 149 /* ns.c */ -
protocols/msn/msn_util.c
r3f81999 r5f8ab6a9 171 171 172 172 /* 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 ) ) ) 176 176 { 177 177 break; … … 374 374 *list = NULL; 375 375 376 imcb_log( ic, ret->str );376 imcb_log( ic, "%s", ret->str ); 377 377 g_string_free( ret, TRUE ); 378 378 } -
protocols/msn/ns.c
r3f81999 r5f8ab6a9 229 229 } 230 230 } 231 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 )231 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 232 { 233 233 set_t *s; 234 234 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" ); 244 251 } 245 252 … … 406 413 { 407 414 /* FIXME: Warn/Bomb about unknown away state? */ 408 st = msn_away_state_list; 409 } 410 411 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | 412 ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); 415 st = msn_away_state_list + 1; 416 } 417 418 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | 419 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 420 st->name, NULL ); 413 421 } 414 422 else if( strcmp( cmd[0], "FLN" ) == 0 ) … … 435 443 { 436 444 /* FIXME: Warn/Bomb about unknown away state? */ 437 st = msn_away_state_list; 438 } 439 440 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | 441 ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); 445 st = msn_away_state_list + 1; 446 } 447 448 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | 449 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 450 st->name, NULL ); 442 451 } 443 452 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 649 658 } 650 659 651 if( arg1 )g_free( arg1 );652 if( mtype )g_free( mtype );660 g_free( arg1 ); 661 g_free( mtype ); 653 662 } 654 663 else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 ) … … 658 667 else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 ) 659 668 { 660 char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); 661 char *folders = msn_findheader( body, "Folders-Unread:", blen ); 662 663 if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) ) 669 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 664 670 { 665 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 671 char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); 672 char *folders = msn_findheader( body, "Folders-Unread:", blen ); 673 674 if( inbox && folders ) 675 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 676 677 g_free( inbox ); 678 g_free( folders ); 666 679 } 667 680 } 668 681 else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) 669 682 { 670 char *from = msn_findheader( body, "From-Addr:", blen ); 671 char *fromname = msn_findheader( body, "From:", blen ); 672 673 if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) ) 683 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 674 684 { 675 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 685 char *from = msn_findheader( body, "From-Addr:", blen ); 686 char *fromname = msn_findheader( body, "From:", blen ); 687 688 if( from && fromname ) 689 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 690 691 g_free( from ); 692 g_free( fromname ); 676 693 } 677 694 } -
protocols/msn/tables.c
r3f81999 r5f8ab6a9 29 29 const struct msn_away_state msn_away_state_list[] = 30 30 { 31 { 0, "NLN", "Available" },32 { 1, "BSY", "Busy" },33 { 3, "IDL", "Idle" },34 { 5, "BRB", "Be Right Back" },35 { 7, "AWY", "Away" },36 { 9,"PHN", "On the Phone" },37 { 11,"LUN", "Out to Lunch" },38 { 13,"HDN", "Hidden" },39 { -1,"", "" }31 { "NLN", "" }, 32 { "AWY", "Away" }, 33 { "BSY", "Busy" }, 34 { "IDL", "Idle" }, 35 { "BRB", "Be Right Back" }, 36 { "PHN", "On the Phone" }, 37 { "LUN", "Out to Lunch" }, 38 { "HDN", "Hidden" }, 39 { "", "" } 40 40 }; 41 42 const struct msn_away_state *msn_away_state_by_number( int number )43 {44 int i;45 46 for( i = 0; msn_away_state_list[i].number > -1; i ++ )47 if( msn_away_state_list[i].number == number )48 return( msn_away_state_list + i );49 50 return( NULL );51 }52 41 53 42 const struct msn_away_state *msn_away_state_by_code( char *code ) … … 55 44 int i; 56 45 57 for( i = 0; msn_away_state_list[i].number > -1; i ++ )46 for( i = 0; *msn_away_state_list[i].code; i ++ ) 58 47 if( g_strcasecmp( msn_away_state_list[i].code, code ) == 0 ) 59 48 return( msn_away_state_list + i ); 60 49 61 return ( NULL );50 return NULL; 62 51 } 63 52 … … 66 55 int i; 67 56 68 for( i = 0; msn_away_state_list[i].number > -1; i ++ )57 for( i = 0; *msn_away_state_list[i].code; i ++ ) 69 58 if( g_strcasecmp( msn_away_state_list[i].name, name ) == 0 ) 70 59 return( msn_away_state_list + i ); 71 60 72 return ( NULL );61 return NULL; 73 62 } 74 63 -
protocols/nogaim.c
r3f81999 r5f8ab6a9 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 06Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 33 33 34 34 #define BITLBEE_CORE 35 #include <ctype.h> 36 35 37 #include "nogaim.h" 36 #include <ctype.h>38 #include "chat.h" 37 39 38 40 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); … … 96 98 void register_protocol (struct prpl *p) 97 99 { 98 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); 99 113 } 100 114 … … 266 280 ic->flags |= OPT_LOGGED_IN; 267 281 268 /* Also necessary when we're not away, at least for some of the 269 protocols. */ 270 imc_set_away( ic, u->away ); 282 /* Necessary to send initial presence status, even if we're not away. */ 283 imc_away_send_update( ic ); 271 284 272 285 /* Apparently we're connected successfully, so reset the … … 370 383 /* list.c */ 371 384 372 void imcb_add_buddy( struct im_connection *ic, c har *handle,char *group )385 void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group ) 373 386 { 374 387 user_t *u; … … 444 457 } 445 458 446 void imcb_rename_buddy( struct im_connection *ic, c har *handle,char *realname )459 void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ) 447 460 { 448 461 user_t *u = user_findhandle( ic, handle ); 462 char *set; 449 463 450 464 if( !u || !realname ) return; … … 459 473 imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 460 474 } 461 } 462 463 void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) 475 476 set = set_getstr( &ic->acc->set, "nick_source" ); 477 if( strcmp( set, "handle" ) != 0 ) 478 { 479 char *name = g_strdup( realname ); 480 481 if( strcmp( set, "first_name" ) == 0 ) 482 { 483 int i; 484 for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} 485 name[i] = '\0'; 486 } 487 488 imcb_buddy_nick_hint( ic, handle, name ); 489 490 g_free( name ); 491 } 492 } 493 494 void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group ) 464 495 { 465 496 user_t *u; … … 471 502 /* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM 472 503 modules to suggest a nickname for a handle. */ 473 void imcb_buddy_nick_hint( struct im_connection *ic, c har *handle,char *nick )504 void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick ) 474 505 { 475 506 user_t *u = user_findhandle( ic, handle ); … … 616 647 oo = u->online; 617 648 618 if( u->away ) 619 { 620 g_free( u->away ); 621 u->away = NULL; 622 } 649 g_free( u->away ); 650 g_free( u->status_msg ); 651 u->away = u->status_msg = NULL; 623 652 624 653 if( ( flags & OPT_LOGGED_IN ) && !u->online ) … … 658 687 } 659 688 } 660 /* else waste_any_state_information_for_now(); */ 689 else 690 { 691 u->status_msg = g_strdup( message ); 692 } 661 693 662 694 /* LISPy... */ … … 692 724 } 693 725 694 void imcb_buddy_msg( struct im_connection *ic, c har *handle, char *msg, uint32_t flags, time_t sent_at )726 void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at ) 695 727 { 696 728 irc_t *irc = ic->irc; … … 833 865 } 834 866 835 void imcb_chat_msg( struct groupchat *c, c har *who, char *msg, uint32_t flags, time_t sent_at )867 void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ) 836 868 { 837 869 struct im_connection *ic = c->ic; … … 905 937 /* buddy_chat.c */ 906 938 907 void imcb_chat_add_buddy( struct groupchat *b, c har *handle )939 void imcb_chat_add_buddy( struct groupchat *b, const char *handle ) 908 940 { 909 941 user_t *u = user_findhandle( b->ic, handle ); … … 940 972 941 973 /* This function is one BIG hack... :-( EREWRITE */ 942 void imcb_chat_remove_buddy( struct groupchat *b, c har *handle,char *reason )974 void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ) 943 975 { 944 976 user_t *u; … … 1026 1058 } 1027 1059 1028 static char *imc_away_alias_find( GList *gcm, char *away ); 1029 1030 int imc_set_away( struct im_connection *ic, char *away ) 1031 { 1032 GList *m, *ms; 1033 char *s; 1034 1035 if( !away ) away = ""; 1036 ms = m = ic->acc->prpl->away_states( ic ); 1037 1038 while( m ) 1039 { 1040 if( *away ) 1041 { 1042 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1043 break; 1044 } 1045 else 1046 { 1047 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1048 break; 1049 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1050 break; 1051 } 1052 m = m->next; 1053 } 1054 1055 if( m ) 1056 { 1057 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); 1058 } 1059 else 1060 { 1061 s = imc_away_alias_find( ms, away ); 1062 if( s ) 1063 { 1064 ic->acc->prpl->set_away( ic, s, away ); 1065 if( set_getbool( &ic->irc->set, "debug" ) ) 1066 imcb_log( ic, "Setting away state to %s", s ); 1067 } 1068 else 1069 ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); 1070 } 1071 1072 return( 1 ); 1060 static char *imc_away_state_find( GList *gcm, char *away, char **message ); 1061 1062 int imc_away_send_update( struct im_connection *ic ) 1063 { 1064 char *away, *msg = NULL; 1065 1066 away = set_getstr( &ic->acc->set, "away" ) ? 1067 : set_getstr( &ic->irc->set, "away" ); 1068 if( away && *away ) 1069 { 1070 GList *m = ic->acc->prpl->away_states( ic ); 1071 msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; 1072 away = imc_away_state_find( m, away, &msg ) ? : m->data; 1073 } 1074 else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE ) 1075 { 1076 away = NULL; 1077 msg = set_getstr( &ic->acc->set, "status" ) ? 1078 : set_getstr( &ic->irc->set, "status" ); 1079 } 1080 1081 ic->acc->prpl->set_away( ic, away, msg ); 1082 1083 return 1; 1073 1084 } 1074 1085 … … 1085 1096 }; 1086 1097 1087 static char *imc_away_ alias_find( GList *gcm, char *away)1098 static char *imc_away_state_find( GList *gcm, char *away, char **message ) 1088 1099 { 1089 1100 GList *m; 1090 1101 int i, j; 1091 1102 1103 for( m = gcm; m; m = m->next ) 1104 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1105 { 1106 /* At least the Yahoo! module works better if message 1107 contains no data unless it adds something to what 1108 we have in state already. */ 1109 if( strlen( m->data ) == strlen( away ) ) 1110 *message = NULL; 1111 1112 return m->data; 1113 } 1114 1092 1115 for( i = 0; *imc_away_alias_list[i]; i ++ ) 1093 1116 { 1117 int keep_message; 1118 1094 1119 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1095 1120 if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 ) 1121 { 1122 keep_message = strlen( away ) != strlen( imc_away_alias_list[i][j] ); 1096 1123 break; 1124 } 1097 1125 1098 1126 if( !imc_away_alias_list[i][j] ) /* If we reach the end, this row */ … … 1102 1130 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1103 1131 { 1104 m = gcm; 1105 while( m ) 1106 { 1132 for( m = gcm; m; m = m->next ) 1107 1133 if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 ) 1108 return( imc_away_alias_list[i][j] ); 1109 m = m->next; 1110 } 1111 } 1112 } 1113 1114 return( NULL ); 1134 { 1135 if( !keep_message ) 1136 *message = NULL; 1137 1138 return imc_away_alias_list[i][j]; 1139 } 1140 } 1141 1142 /* No need to look further, apparently this state doesn't 1143 have any good alias for this protocol. */ 1144 break; 1145 } 1146 1147 return NULL; 1115 1148 } 1116 1149 -
protocols/nogaim.h
r3f81999 r5f8ab6a9 39 39 #define _NOGAIM_H 40 40 41 #include <stdint.h> 42 41 43 #include "bitlbee.h" 42 44 #include "account.h" 43 45 #include "proxy.h" 44 46 #include "query.h" 45 #include "md5.h"46 47 47 48 #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ 48 49 49 50 #define WEBSITE "http://www.bitlbee.org/" 50 #define GAIM_AWAY_CUSTOM "Custom"51 51 52 52 /* Sharing flags between all kinds of things. I just hope I won't hit any … … 221 221 222 222 /* You can tell what away states your protocol supports, so that 223 * BitlBee will try to map the IRC away reasons to them , or use224 * GAIM_AWAY_CUSTOM when calling skype_set_away(). */223 * BitlBee will try to map the IRC away reasons to them. If your 224 * protocol doesn't have any, just return one generic "Away". */ 225 225 GList *(* away_states)(struct im_connection *ic); 226 226 … … 279 279 * user, usually after a login, or if the user added a buddy and the IM 280 280 * server confirms that the add was successful. Don't forget to do this! */ 281 G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, c har *handle,char *group );282 G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, c har *handle, char *group );281 G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group ); 282 G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group ); 283 283 G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ); 284 G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, c har *handle,char *realname );285 G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, c har *handle,char *nick );284 G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ); 285 G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick ); 286 286 287 287 /* Buddy activity */ … … 293 293 /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); 294 294 /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */ 295 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, c har *handle, char *msg, uint32_t flags, time_t sent_at );295 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at ); 296 296 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ); 297 297 G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle ); … … 306 306 * user, too. */ 307 307 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 308 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, c har *handle );308 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 309 309 /* To remove a handle from a group chat. Reason can be NULL. */ 310 G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, c har *handle,char *reason );310 G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ); 311 311 /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */ 312 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, c har *who, char *msg, uint32_t flags, time_t sent_at );312 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ); 313 313 /* System messages specific to a groupchat, so they can be displayed in the right context. */ 314 314 G_MODULE_EXPORT void imcb_chat_log( struct groupchat *c, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); … … 318 318 319 319 /* Actions, or whatever. */ 320 int imc_ set_away( struct im_connection *ic, char *away);320 int imc_away_send_update( struct im_connection *ic ); 321 321 int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ); 322 322 int imc_chat_msg( struct groupchat *c, char *msg, int flags ); -
protocols/oscar/oscar.c
r3f81999 r5f8ab6a9 380 380 s->flags |= ACC_SET_OFFLINE_ONLY; 381 381 } 382 383 acc->flags |= ACC_FLAG_AWAY_MESSAGE; 382 384 } 383 385 … … 1952 1954 static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) 1953 1955 { 1956 if (state == NULL) 1957 state = ""; 1954 1958 1955 1959 if (!g_strcasecmp(state, _("Visible"))) { … … 1959 1963 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); 1960 1964 return; 1961 } /* else... */ 1965 } else if (message == NULL) { 1966 message = state; 1967 } 1962 1968 1963 1969 if (od->rights.maxawaymsglen == 0) … … 2002 2008 } 2003 2009 2004 if ( !g_strcasecmp(state, "Online")) {2010 if (state == NULL) { 2005 2011 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); 2006 2012 } else if (!g_strcasecmp(state, "Away")) { … … 2027 2033 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); 2028 2034 ic->away = g_strdup(msg); 2029 } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)){2035 } else { 2030 2036 if (no_message) { 2031 2037 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); … … 2276 2282 { 2277 2283 struct oscar_data *od = ic->proto_data; 2278 GList *m = NULL; 2279 2280 if (!od->icq) 2281 return g_list_append(m, GAIM_AWAY_CUSTOM); 2282 2283 m = g_list_append(m, "Online"); 2284 m = g_list_append(m, "Away"); 2285 m = g_list_append(m, "Do Not Disturb"); 2286 m = g_list_append(m, "Not Available"); 2287 m = g_list_append(m, "Occupied"); 2288 m = g_list_append(m, "Free For Chat"); 2289 m = g_list_append(m, "Invisible"); 2290 2291 return m; 2284 2285 if (od->icq) { 2286 static GList *m = NULL; 2287 m = g_list_append(m, "Away"); 2288 m = g_list_append(m, "Do Not Disturb"); 2289 m = g_list_append(m, "Not Available"); 2290 m = g_list_append(m, "Occupied"); 2291 m = g_list_append(m, "Free For Chat"); 2292 m = g_list_append(m, "Invisible"); 2293 return m; 2294 } else { 2295 static GList *m = NULL; 2296 m = g_list_append(m, "Away"); 2297 return m; 2298 } 2292 2299 } 2293 2300 -
protocols/yahoo/libyahoo2.c
r3f81999 r5f8ab6a9 857 857 } 858 858 859 static YList * bud_str2list(char *rawlist)860 {861 YList * l = NULL;862 863 char **lines;864 char **split;865 char **buddies;866 char **tmp, **bud;867 868 lines = y_strsplit(rawlist, "\n", -1);869 for (tmp = lines; *tmp; tmp++) {870 struct yahoo_buddy *newbud;871 872 split = y_strsplit(*tmp, ":", 2);873 if (!split)874 continue;875 if (!split[0] || !split[1]) {876 y_strfreev(split);877 continue;878 }879 buddies = y_strsplit(split[1], ",", -1);880 881 for (bud = buddies; bud && *bud; bud++) {882 newbud = y_new0(struct yahoo_buddy, 1);883 newbud->id = strdup(*bud);884 newbud->group = strdup(split[0]);885 886 if(y_list_find_custom(l, newbud, is_same_bud)) {887 FREE(newbud->id);888 FREE(newbud->group);889 FREE(newbud);890 continue;891 }892 893 newbud->real_name = NULL;894 895 l = y_list_append(l, newbud);896 897 NOTICE(("Added buddy %s to group %s", newbud->id, newbud->group));898 }899 900 y_strfreev(buddies);901 y_strfreev(split);902 }903 y_strfreev(lines);904 905 return l;906 }907 908 859 static char * getcookie(char *rawcookie) 909 860 { … … 1362 1313 } 1363 1314 1364 1365 static void yahoo_process_status(struct yahoo_input_data *yid,struct yahoo_packet *pkt)1315 static void yahoo_process_status(struct yahoo_input_data *yid, 1316 struct yahoo_packet *pkt) 1366 1317 { 1367 1318 YList *l; 1368 1319 struct yahoo_data *yd = yid->yd; 1369 1320 1370 struct user 1371 { 1372 char *name; /* 7 name */ 1373 int state; /* 10 state */ 1374 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1375 int mobile; /* 60 mobile */ 1376 char *msg; /* 19 custom status message */ 1377 int away; /* 47 away (or invisible)*/ 1378 int buddy_session; /* 11 state */ 1379 int f17; /* 17 in chat? then what about flags? */ 1380 int idle; /* 137 seconds idle */ 1381 int f138; /* 138 state */ 1382 char *f184; /* 184 state */ 1383 int f192; /* 192 state */ 1384 int f10001; /* 10001 state */ 1385 int f10002; /* 10002 state */ 1386 int f198; /* 198 state */ 1387 char *f197; /* 197 state */ 1388 char *f205; /* 205 state */ 1389 int f213; /* 213 state */ 1390 } *u; 1321 struct yahoo_process_status_entry *u; 1391 1322 1392 1323 YList *users = 0; 1393 1324 1394 1325 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 1395 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL); 1396 return; 1397 } 1326 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1327 YAHOO_LOGIN_DUPL, NULL); 1328 return; 1329 } 1330 1331 /* Status updates may be spread accross multiple packets and not 1332 even on buddy boundaries, so keeping some state is important. 1333 So, continue where we left off, and only add a user entry to 1334 the list once it's complete (301-315 End buddy). */ 1335 u = yd->half_user; 1398 1336 1399 1337 for (l = pkt->hash; l; l = l->next) { … … 1401 1339 1402 1340 switch (pair->key) { 1403 case 0: /* we won't actually do anything with this */ 1341 case 300: /* Begin buddy */ 1342 if (!strcmp(pair->value, "315") && !u) { 1343 u = yd->half_user = y_new0(struct yahoo_process_status_entry, 1); 1344 } 1345 break; 1346 case 301: /* End buddy */ 1347 if (!strcmp(pair->value, "315") && u) { 1348 /* Sometimes user info comes in an odd format with no 1349 "begin buddy" but *with* an "end buddy". Don't add 1350 it twice. */ 1351 if (!y_list_find(users, u)) 1352 users = y_list_prepend(users, u); 1353 u = yd->half_user = NULL; 1354 } 1355 break; 1356 case 0: /* we won't actually do anything with this */ 1404 1357 NOTICE(("key %d:%s", pair->key, pair->value)); 1405 1358 break; 1406 case 1: 1359 case 1: /* we don't get the full buddy list here. */ 1407 1360 if (!yd->logged_in) { 1408 yd->logged_in = TRUE;1409 if (yd->current_status < 0)1361 yd->logged_in = 1; 1362 if (yd->current_status < 0) 1410 1363 yd->current_status = yd->initial_status; 1411 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); 1364 YAHOO_CALLBACK(ext_yahoo_login_response) (yd-> 1365 client_id, YAHOO_LOGIN_OK, NULL); 1412 1366 } 1413 1367 break; 1414 case 8: 1368 case 8: /* how many online buddies we have */ 1415 1369 NOTICE(("key %d:%s", pair->key, pair->value)); 1416 1370 break; 1417 case 7: /* the current buddy */ 1418 u = y_new0(struct user, 1); 1371 case 7: /* the current buddy */ 1372 if (!u) { 1373 /* This will only happen in case of a single level message */ 1374 u = y_new0(struct yahoo_process_status_entry, 1); 1375 users = y_list_prepend(users, u); 1376 } 1419 1377 u->name = pair->value; 1420 users = y_list_prepend(users, u); 1421 break; 1422 case 10: /* state */ 1423 ((struct user*)users->data)->state = strtol(pair->value, NULL, 10); 1424 break; 1425 case 19: /* custom status message */ 1426 ((struct user*)users->data)->msg = pair->value; 1427 break; 1428 case 47: /* is it an away message or not */ 1429 ((struct user*)users->data)->away = atoi(pair->value); 1430 break; 1431 case 137: /* seconds idle */ 1432 ((struct user*)users->data)->idle = atoi(pair->value); 1433 break; 1434 case 11: /* this is the buddy's session id */ 1435 ((struct user*)users->data)->buddy_session = atoi(pair->value); 1436 break; 1437 case 17: /* in chat? */ 1438 ((struct user*)users->data)->f17 = atoi(pair->value); 1439 break; 1440 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1441 ((struct user*)users->data)->flags = atoi(pair->value); 1442 break; 1443 case 60: /* SMS -> 1 MOBILE USER */ 1378 break; 1379 case 10: /* state */ 1380 u->state = strtol(pair->value, NULL, 10); 1381 break; 1382 case 19: /* custom status message */ 1383 u->msg = pair->value; 1384 break; 1385 case 47: /* is it an away message or not. Not applicable for YMSG16 anymore */ 1386 u->away = atoi(pair->value); 1387 break; 1388 case 137: /* seconds idle */ 1389 u->idle = atoi(pair->value); 1390 break; 1391 case 11: /* this is the buddy's session id */ 1392 u->buddy_session = atoi(pair->value); 1393 break; 1394 case 17: /* in chat? */ 1395 u->f17 = atoi(pair->value); 1396 break; 1397 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1398 u->flags = atoi(pair->value); 1399 break; 1400 case 60: /* SMS -> 1 MOBILE USER */ 1444 1401 /* sometimes going offline makes this 2, but invisible never sends it */ 1445 ((struct user*)users->data)->mobile = atoi(pair->value);1402 u->mobile = atoi(pair->value); 1446 1403 break; 1447 1404 case 138: 1448 ((struct user*)users->data)->f138 = atoi(pair->value);1405 u->f138 = atoi(pair->value); 1449 1406 break; 1450 1407 case 184: 1451 ((struct user*)users->data)->f184 = pair->value;1408 u->f184 = pair->value; 1452 1409 break; 1453 1410 case 192: 1454 ((struct user*)users->data)->f192 = atoi(pair->value);1411 u->f192 = atoi(pair->value); 1455 1412 break; 1456 1413 case 10001: 1457 ((struct user*)users->data)->f10001 = atoi(pair->value);1414 u->f10001 = atoi(pair->value); 1458 1415 break; 1459 1416 case 10002: 1460 ((struct user*)users->data)->f10002 = atoi(pair->value);1417 u->f10002 = atoi(pair->value); 1461 1418 break; 1462 1419 case 198: 1463 ((struct user*)users->data)->f198 = atoi(pair->value);1420 u->f198 = atoi(pair->value); 1464 1421 break; 1465 1422 case 197: 1466 ((struct user*)users->data)->f197 = pair->value;1423 u->f197 = pair->value; 1467 1424 break; 1468 1425 case 205: 1469 ((struct user*)users->data)->f205 = pair->value;1426 u->f205 = pair->value; 1470 1427 break; 1471 1428 case 213: 1472 ((struct user*)users->data)->f213 = atoi(pair->value); 1473 break; 1474 case 16: /* Custom error message */ 1475 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM); 1429 u->f213 = atoi(pair->value); 1430 break; 1431 case 16: /* Custom error message */ 1432 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, 1433 pair->value, 0, E_CUSTOM); 1476 1434 break; 1477 1435 default: 1478 WARNING(("unknown status key %d:%s", pair->key, pair->value)); 1479 break; 1480 } 1481 } 1482 1436 WARNING(("unknown status key %d:%s", pair->key, 1437 pair->value)); 1438 break; 1439 } 1440 } 1441 1483 1442 while (users) { 1484 1443 YList *t = users; 1485 struct user*u = users->data;1444 struct yahoo_process_status_entry *u = users->data; 1486 1445 1487 1446 if (u->name != NULL) { 1488 if (pkt->service == YAHOO_SERVICE_LOGOFF) { /* || u->flags == 0) { Not in YMSG16 */ 1489 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1447 if (pkt->service == 1448 YAHOO_SERVICE_LOGOFF 1449 /*|| u->flags == 0 No flags for YMSG16 */ ) { 1450 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd-> 1451 client_id, u->name, 1452 YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1490 1453 } else { 1491 1454 /* Key 47 always seems to be 1 for YMSG16 */ 1492 if (!u->state)1455 if (!u->state) 1493 1456 u->away = 0; 1494 1457 else 1495 1458 u->away = 1; 1496 1459 1497 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); 1460 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd-> 1461 client_id, u->name, u->state, u->msg, 1462 u->away, u->idle, u->mobile); 1498 1463 } 1499 1464 } … … 1505 1470 } 1506 1471 1507 static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1472 static void yahoo_process_buddy_list(struct yahoo_input_data *yid, 1473 struct yahoo_packet *pkt) 1508 1474 { 1509 1475 struct yahoo_data *yd = yid->yd; … … 1517 1483 struct yahoo_pair *pair = l->data; 1518 1484 1519 switch (pair->key) {1485 switch (pair->key) { 1520 1486 case 300: 1521 1487 case 301: 1522 1488 case 302: 1489 break; /* Separators. Our logic does not need them */ 1523 1490 case 303: 1524 if ( 315 == atoi(pair->value))1491 if (318 == atoi(pair->value)) 1525 1492 last_packet = 1; 1526 1493 break; 1527 1494 case 65: 1528 g_free(cur_group);1529 1495 cur_group = strdup(pair->value); 1530 1496 break; … … 1532 1498 newbud = y_new0(struct yahoo_buddy, 1); 1533 1499 newbud->id = strdup(pair->value); 1534 if (cur_group)1500 if (cur_group) 1535 1501 newbud->group = strdup(cur_group); 1536 else { 1537 struct yahoo_buddy *lastbud = (struct yahoo_buddy *)y_list_nth( 1538 yd->buddies, y_list_length(yd->buddies)-1)->data; 1502 else if (yd->buddies) { 1503 struct yahoo_buddy *lastbud = 1504 (struct yahoo_buddy *)y_list_nth(yd-> 1505 buddies, 1506 y_list_length(yd->buddies) - 1)->data; 1539 1507 newbud->group = strdup(lastbud->group); 1540 } 1508 } else 1509 newbud->group = strdup("Buddies"); 1541 1510 1542 1511 yd->buddies = y_list_append(yd->buddies, newbud); … … 1545 1514 } 1546 1515 } 1547 1548 g_free(cur_group);1549 1516 1550 1517 /* we could be getting multiple packets here */ 1551 if ( last_packet)1552 return; 1553 1554 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies);1555 1556 /* ** We login at the very end of the packet communication */1518 if (pkt->hash && !last_packet) 1519 return; 1520 1521 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies); 1522 1523 /* Logged in */ 1557 1524 if (!yd->logged_in) { 1558 yd->logged_in = TRUE;1559 if (yd->current_status < 0)1525 yd->logged_in = 1; 1526 if (yd->current_status < 0) 1560 1527 yd->current_status = yd->initial_status; 1561 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); 1562 } 1563 } 1564 1565 static void yahoo_process_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1528 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1529 YAHOO_LOGIN_OK, NULL); 1530 1531 /* 1532 yahoo_set_away(yd->client_id, yd->initial_status, NULL, 1533 (yd->initial_status == YAHOO_STATUS_AVAILABLE) ? 0 : 1); 1534 1535 yahoo_get_yab(yd->client_id); 1536 */ 1537 } 1538 1539 } 1540 1541 static void yahoo_process_list(struct yahoo_input_data *yid, 1542 struct yahoo_packet *pkt) 1566 1543 { 1567 1544 struct yahoo_data *yd = yid->yd; 1568 1545 YList *l; 1569 1546 1570 if (!yd->logged_in) { 1571 yd->logged_in = TRUE; 1572 if(yd->current_status < 0) 1573 yd->current_status = yd->initial_status; 1574 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); 1575 } 1576 1547 /* we could be getting multiple packets here */ 1577 1548 for (l = pkt->hash; l; l = l->next) { 1578 1549 struct yahoo_pair *pair = l->data; 1579 1550 1580 switch(pair->key) { 1581 case 87: /* buddies */ 1582 if(!yd->rawbuddylist) 1583 yd->rawbuddylist = strdup(pair->value); 1584 else { 1585 yd->rawbuddylist = y_string_append(yd->rawbuddylist, pair->value); 1551 switch (pair->key) { 1552 case 89: /* identities */ 1553 { 1554 char **identities = 1555 y_strsplit(pair->value, ",", -1); 1556 int i; 1557 for (i = 0; identities[i]; i++) 1558 yd->identities = 1559 y_list_append(yd->identities, 1560 strdup(identities[i])); 1561 y_strfreev(identities); 1586 1562 } 1587 break; 1588 1589 case 88: /* ignore list */ 1590 if(!yd->ignorelist) 1591 yd->ignorelist = strdup("Ignore:"); 1592 yd->ignorelist = y_string_append(yd->ignorelist, pair->value); 1593 break; 1594 1595 case 89: /* identities */ 1596 { 1597 char **identities = y_strsplit(pair->value, ",", -1); 1598 int i; 1599 for(i=0; identities[i]; i++) 1600 yd->identities = y_list_append(yd->identities, 1601 strdup(identities[i])); 1602 y_strfreev(identities); 1603 } 1604 YAHOO_CALLBACK(ext_yahoo_got_identities)(yd->client_id, yd->identities); 1605 break; 1606 case 59: /* cookies */ 1607 if(yd->ignorelist) { 1608 yd->ignore = bud_str2list(yd->ignorelist); 1609 FREE(yd->ignorelist); 1610 YAHOO_CALLBACK(ext_yahoo_got_ignore)(yd->client_id, yd->ignore); 1611 } 1612 if(yd->rawbuddylist) { 1613 yd->buddies = bud_str2list(yd->rawbuddylist); 1614 FREE(yd->rawbuddylist); 1615 YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies); 1616 } 1617 1618 if(pair->value[0]=='Y') { 1563 YAHOO_CALLBACK(ext_yahoo_got_identities) (yd->client_id, 1564 yd->identities); 1565 break; 1566 case 59: /* cookies */ 1567 if (pair->value[0] == 'Y') { 1619 1568 FREE(yd->cookie_y); 1620 1569 FREE(yd->login_cookie); … … 1623 1572 yd->login_cookie = getlcookie(yd->cookie_y); 1624 1573 1625 } else if (pair->value[0]=='T') {1574 } else if (pair->value[0] == 'T') { 1626 1575 FREE(yd->cookie_t); 1627 1576 yd->cookie_t = getcookie(pair->value); 1628 1577 1629 } else if (pair->value[0]=='C') {1578 } else if (pair->value[0] == 'C') { 1630 1579 FREE(yd->cookie_c); 1631 1580 yd->cookie_c = getcookie(pair->value); 1632 } 1633 1634 if(yd->cookie_y && yd->cookie_t)1635 YAHOO_CALLBACK(ext_yahoo_got_cookies)(yd->client_id);1636 1637 break;1638 case 3: /* my id*/1639 case 90: /* 1*/1640 case 100: /*0 */1641 case 101: /* NULL */1642 case 102: /* NULL */1643 case 93: /* 86400/1440 */1644 break; 1645 }1646 }1581 } 1582 1583 break; 1584 case 3: /* my id */ 1585 case 90: /* 1 */ 1586 case 100: /* 0 */ 1587 case 101: /* NULL */ 1588 case 102: /* NULL */ 1589 case 93: /* 86400/1440 */ 1590 break; 1591 } 1592 } 1593 1594 if (yd->cookie_y && yd->cookie_t) /* We don't get cookie_c anymore */ 1595 YAHOO_CALLBACK(ext_yahoo_got_cookies) (yd->client_id); 1647 1596 } 1648 1597 … … 2395 2344 { 2396 2345 struct yahoo_https_auth_data *had = req->data; 2397 struct yahoo_input_data *yid = had->yid;2398 struct yahoo_data *yd = yid->yd;2346 struct yahoo_input_data *yid; 2347 struct yahoo_data *yd; 2399 2348 int st; 2349 2350 if (y_list_find(inputs, had->yid) == NULL) 2351 return; 2352 2353 yid = had->yid; 2354 yd = yid->yd; 2400 2355 2401 2356 if (req->status_code != 200) { … … 2438 2393 { 2439 2394 struct yahoo_https_auth_data *had = req->data; 2440 struct yahoo_input_data *yid = had->yid;2441 struct yahoo_data *yd = yid->yd;2395 struct yahoo_input_data *yid; 2396 struct yahoo_data *yd; 2442 2397 struct yahoo_packet *pack; 2443 char *crumb ;2398 char *crumb = NULL; 2444 2399 int st; 2400 2401 if (y_list_find(inputs, had->yid) == NULL) 2402 return; 2403 2404 yid = had->yid; 2405 yd = yid->yd; 2445 2406 2446 2407 md5_byte_t result[16]; … … 4082 4043 4083 4044 yd = yid->yd; 4084 4085 4045 old_status = yd->current_status; 4086 4087 if (msg && strncmp(msg,"Invisible",9)) { 4088 yd->current_status = YAHOO_STATUS_CUSTOM; 4089 } else { 4090 yd->current_status = state; 4091 } 4046 yd->current_status = state; 4092 4047 4093 4048 /* Thank you libpurple :) */ … … 4104 4059 snprintf(s, sizeof(s), "%d", yd->current_status); 4105 4060 yahoo_packet_hash(pkt, 10, s); 4106 4107 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 4108 yahoo_packet_hash(pkt, 19, msg); 4109 } else { 4110 yahoo_packet_hash(pkt, 19, ""); 4111 } 4112 4061 yahoo_packet_hash(pkt, 19, msg && state == YAHOO_STATUS_CUSTOM ? msg : ""); 4113 4062 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 4114 4115 4063 yahoo_send_packet(yid, pkt, 0); 4116 4064 yahoo_packet_free(pkt); -
protocols/yahoo/yahoo.c
r3f81999 r5f8ab6a9 130 130 { 131 131 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 132 133 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; 132 134 } 133 135 … … 197 199 { 198 200 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 199 char *away; 200 201 away = NULL; 202 203 if( state && msg && g_strcasecmp( state, msg ) != 0 ) 204 { 205 yd->current_status = YAHOO_STATUS_CUSTOM; 206 away = ""; 207 } 208 else if( state ) 209 { 210 /* Set msg to NULL since (if it isn't NULL already) it's equal 211 to state. msg must be empty if we want to use an existing 212 away state. */ 213 msg = NULL; 214 215 away = ""; 216 if( g_strcasecmp( state, "Available" ) == 0 ) 217 { 218 yd->current_status = YAHOO_STATUS_AVAILABLE; 219 away = NULL; 220 } 221 else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) 201 202 if( state && msg == NULL ) 203 { 204 /* Use these states only if msg doesn't contain additional 205 info since away messages are only supported with CUSTOM. */ 206 if( g_strcasecmp( state, "Be Right Back" ) == 0 ) 222 207 yd->current_status = YAHOO_STATUS_BRB; 223 208 else if( g_strcasecmp( state, "Busy" ) == 0 ) … … 239 224 else if( g_strcasecmp( state, "Invisible" ) == 0 ) 240 225 yd->current_status = YAHOO_STATUS_INVISIBLE; 241 else if( g_strcasecmp( state, GAIM_AWAY_CUSTOM ) == 0 ) 242 { 243 yd->current_status = YAHOO_STATUS_AVAILABLE; 244 245 away = NULL; 246 } 247 } 226 else 227 yd->current_status = YAHOO_STATUS_CUSTOM; 228 } 229 else if( msg ) 230 yd->current_status = YAHOO_STATUS_CUSTOM; 248 231 else 249 232 yd->current_status = YAHOO_STATUS_AVAILABLE; 250 233 251 yahoo_set_away( yd->y2_id, yd->current_status, msg, away != NULL? 2 : 0 );234 yahoo_set_away( yd->y2_id, yd->current_status, msg, state ? 2 : 0 ); 252 235 } 253 236 … … 258 241 if( m == NULL ) 259 242 { 260 m = g_list_append( m, "Available" );261 243 m = g_list_append( m, "Be Right Back" ); 262 244 m = g_list_append( m, "Busy" ); … … 269 251 m = g_list_append( m, "Stepped Out" ); 270 252 m = g_list_append( m, "Invisible" ); 271 m = g_list_append( m, GAIM_AWAY_CUSTOM );272 253 } 273 254 -
protocols/yahoo/yahoo2_types.h
r3f81999 r5f8ab6a9 196 196 197 197 void *server_settings; 198 199 struct yahoo_process_status_entry *half_user; 198 200 }; 199 201 … … 261 263 }; 262 264 265 struct 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 263 286 #ifdef __cplusplus 264 287 } -
root_commands.c
r3f81999 r5f8ab6a9 30 30 #include "help.h" 31 31 #include "otr.h" 32 #include "chat.h" 32 33 33 34 #include <string.h> … … 143 144 storage_status_t status = storage_load( irc, cmd[1] ); 144 145 char *account_on[] = { "account", "on", NULL }; 146 147 if( strchr( irc->umode, 'R' ) != NULL ) 148 { 149 irc_usermsg( irc, "You're already logged in." ); 150 return; 151 } 145 152 146 153 switch (status) { … … 912 919 online = 1; 913 920 else 914 online = 921 online = away = 1; 915 922 916 923 if( strchr( irc->umode, 'b' ) != NULL ) … … 925 932 if( online == 1 ) 926 933 { 934 char st[256] = "Online"; 935 936 if( u->status_msg ) 937 g_snprintf( st, sizeof( st ) - 1, "Online (%s)", u->status_msg ); 938 927 939 g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); 928 irc_usermsg( irc, format, u->nick, s, "Online");940 irc_usermsg( irc, format, u->nick, s, st ); 929 941 } 930 942 … … 1119 1131 irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); 1120 1132 } 1121 1122 1123 1124 #if 01125 account_t *a;1126 struct im_connection *ic;1127 char *chat, *channel, *nick = NULL, *password = NULL;1128 struct groupchat *c;1129 1130 if( !( a = account_get( irc, cmd[1] ) ) )1131 {1132 irc_usermsg( irc, "Invalid account" );1133 return;1134 }1135 else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) )1136 {1137 irc_usermsg( irc, "That account is not on-line" );1138 return;1139 }1140 else if( a->prpl->chat_join == NULL )1141 {1142 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] );1143 return;1144 }1145 ic = a->ic;1146 1147 chat = cmd[2];1148 if( cmd[3] )1149 {1150 if( strchr( CTYPES, cmd[3][0] ) == NULL )1151 channel = g_strdup_printf( "&%s", cmd[3] );1152 else1153 channel = g_strdup( cmd[3] );1154 }1155 else1156 {1157 char *s;1158 1159 channel = g_strdup_printf( "&%s", chat );1160 if( ( s = strchr( channel, '@' ) ) )1161 *s = 0;1162 }1163 if( cmd[3] && cmd[4] )1164 nick = cmd[4];1165 else1166 nick = irc->nick;1167 if( cmd[3] && cmd[4] && cmd[5] )1168 password = cmd[5];1169 1170 if( !nick_ok( channel + 1 ) )1171 {1172 irc_usermsg( irc, "Invalid channel name: %s", channel );1173 g_free( channel );1174 return;1175 }1176 else if( g_strcasecmp( channel, irc->channel ) == 0 || irc_chat_by_channel( irc, channel ) )1177 {1178 irc_usermsg( irc, "Channel already exists: %s", channel );1179 g_free( channel );1180 return;1181 }1182 1183 if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) )1184 {1185 g_free( c->channel );1186 c->channel = channel;1187 }1188 else1189 {1190 irc_usermsg( irc, "Tried to join chat, not sure if this was successful" );1191 g_free( channel );1192 }1193 #endif1194 1133 } 1195 1134 -
storage_xml.c
r3f81999 r5f8ab6a9 29 29 #include "arc.h" 30 30 #include "md5.h" 31 #include "chat.h" 31 32 32 33 #if GLIB_CHECK_VERSION(2,8,0) -
unix.c
r3f81999 r5f8ab6a9 25 25 26 26 #include "bitlbee.h" 27 28 #include "arc.h" 29 #include "base64.h" 27 30 #include "commands.h" 28 31 #include "crypting.h" … … 32 35 #include "ipc.h" 33 36 #include "lib/ssl_client.h" 37 #include "md5.h" 38 #include "misc.h" 34 39 #include <signal.h> 35 40 #include <unistd.h> … … 42 47 static void sighandler( int signal ); 43 48 49 static int crypt_main( int argc, char *argv[] ); 50 44 51 int main( int argc, char *argv[] ) 45 52 { … … 47 54 char *old_cwd = NULL; 48 55 struct sigaction sig, old; 56 57 if( argc > 1 && strcmp( argv[1], "-x" ) == 0 ) 58 return crypt_main( argc, argv ); 49 59 50 60 log_init(); … … 168 178 } 169 179 180 static int crypt_main( int argc, char *argv[] ) 181 { 182 int pass_len; 183 unsigned char *pass_cr, *pass_cl; 184 185 if( argc < 4 || ( strcmp( argv[2], "hash" ) != 0 && 186 strcmp( argv[2], "unhash" ) != 0 && argc < 5 ) ) 187 { 188 printf( "Supported:\n" 189 " %s -x enc <key> <cleartext password>\n" 190 " %s -x dec <key> <encrypted password>\n" 191 " %s -x hash <cleartext password>\n" 192 " %s -x unhash <hashed password>\n" 193 " %s -x chkhash <hashed password> <cleartext password>\n", 194 argv[0], argv[0], argv[0], argv[0], argv[0] ); 195 } 196 else if( strcmp( argv[2], "enc" ) == 0 ) 197 { 198 pass_len = arc_encode( argv[4], strlen( argv[4] ), (unsigned char**) &pass_cr, argv[3], 12 ); 199 printf( "%s\n", base64_encode( pass_cr, pass_len ) ); 200 } 201 else if( strcmp( argv[2], "dec" ) == 0 ) 202 { 203 pass_len = base64_decode( argv[4], (unsigned char**) &pass_cr ); 204 arc_decode( pass_cr, pass_len, (char**) &pass_cl, argv[3] ); 205 printf( "%s\n", pass_cl ); 206 } 207 else if( strcmp( argv[2], "hash" ) == 0 ) 208 { 209 md5_byte_t pass_md5[21]; 210 md5_state_t md5_state; 211 212 random_bytes( pass_md5 + 16, 5 ); 213 md5_init( &md5_state ); 214 md5_append( &md5_state, (md5_byte_t*) argv[3], strlen( argv[3] ) ); 215 md5_append( &md5_state, pass_md5 + 16, 5 ); /* Add the salt. */ 216 md5_finish( &md5_state, pass_md5 ); 217 218 printf( "%s\n", base64_encode( pass_md5, 21 ) ); 219 } 220 else if( strcmp( argv[2], "unhash" ) == 0 ) 221 { 222 printf( "Hash %s submitted to a massive Beowulf cluster of\n" 223 "overclocked 486s. Expect your answer next year somewhere around this time. :-)\n", argv[3] ); 224 } 225 else if( strcmp( argv[2], "chkhash" ) == 0 ) 226 { 227 char *hash = strncmp( argv[3], "md5:", 4 ) == 0 ? argv[3] + 4 : argv[3]; 228 int st = md5_verify_password( argv[4], hash ); 229 230 printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" ); 231 232 return st; 233 } 234 235 return 0; 236 } 237 170 238 static void sighandler( int signal ) 171 239 { -
user.h
r3f81999 r5f8ab6a9 34 34 35 35 char *away; 36 char *status_msg; /* Non-IRC extension, but nice on IM. */ 36 37 37 38 char is_private;
Note: See TracChangeset
for help on using the changeset viewer.