Changes in / [46ad029:601e813]
- Files:
-
- 1 added
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r46ad029 r601e813 19 19 decode 20 20 encode 21 bitlbee.pc 22 .gdb_history -
Makefile
r46ad029 r601e813 11 11 # Program variables 12 12 objects = account.o bitlbee.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o storage_text.o url.o user.o util.o 13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ini.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h url.h user.h protocols/http_client.h protocols/md5.h protocols/nogaim.h protocols/proxy.h protocols/sha.h protocols/ssl_client.h 13 14 subdirs = protocols 14 15 … … 26 27 $(MAKE) -C doc 27 28 28 uninstall: uninstall-bin uninstall-doc 29 uninstall: uninstall-bin uninstall-doc 29 30 @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n' 30 31 … … 62 63 uninstall-bin: 63 64 rm -f $(DESTDIR)$(BINDIR)/$(OUTFILE) 65 66 install-dev: 67 mkdir -p $(DESTDIR)$(INCLUDEDIR) 68 install -m 0644 $(headers) $(DESTDIR)$(INCLUDEDIR) 69 mkdir -p $(DESTDIR)$(PCDIR) 70 install -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR) 71 72 uninstall-dev: 73 rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr)) 74 -rmdir $(DESTDIR)$(INCLUDEDIR) 75 rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc 64 76 65 77 install-etc: -
account.c
r46ad029 r601e813 53 53 { 54 54 account_t *a, *ret = NULL; 55 char *handle, *s; 55 56 int nr; 57 58 /* This checks if the id string ends with (...) */ 59 if( ( handle = strchr( id, '(' ) ) && ( s = strchr( handle, ')' ) ) && s[1] == 0 ) 60 { 61 struct prpl *proto; 62 63 *s = *handle = 0; 64 handle ++; 65 66 if( ( proto = find_protocol( id ) ) ) 67 { 68 for( a = irc->accounts; a; a = a->next ) 69 if( a->prpl == proto && 70 a->prpl->cmp_buddynames( handle, a->user ) == 0 ) 71 ret = a; 72 } 73 74 /* Restore the string. */ 75 handle --; 76 *handle = '('; 77 *s = ')'; 78 79 if( ret ) 80 return ret; 81 } 56 82 57 83 if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) … … 141 167 void account_off( irc_t *irc, account_t *a ) 142 168 { 143 account_offline( a->gc ); 169 a->gc->wants_to_die = TRUE; 170 signoff( a->gc ); 144 171 a->gc = NULL; 145 172 if( a->reconnect ) -
bitlbee.c
r46ad029 r601e813 111 111 BitlBee process. So let's only close TTY-fds. */ 112 112 if( isatty( 0 ) ) close( 0 ); 113 if( isatty( 0) ) close( 1 );114 if( isatty( 0) ) close( 2 );113 if( isatty( 1 ) ) close( 1 ); 114 if( isatty( 2 ) ) close( 2 ); 115 115 } 116 116 #endif -
bitlbee.h
r46ad029 r601e813 99 99 #include "storage.h" 100 100 #include "set.h" 101 #include " protocols/nogaim.h"101 #include "nogaim.h" 102 102 #include "commands.h" 103 103 #include "account.h" … … 108 108 #include "query.h" 109 109 #include "sock.h" 110 #include "util.h" 110 111 111 112 typedef struct global { … … 130 131 void root_command( irc_t *irc, char *command[] ); 131 132 void bitlbee_shutdown( gpointer data ); 132 double gettime( void );133 G_MODULE_EXPORT void http_encode( char *s );134 G_MODULE_EXPORT void http_decode( char *s );135 G_MODULE_EXPORT char *strip_newlines(char *source);136 133 137 134 extern global_t global; -
conf.c
r46ad029 r601e813 95 95 conf->port = i; 96 96 } 97 else if( opt == ' p' )97 else if( opt == 'P' ) 98 98 { 99 99 g_free( conf->pidfile ); -
configure
r46ad029 r601e813 17 17 ipcsocket='/var/run/bitlbee' 18 18 plugindir='$prefix/lib/bitlbee' 19 pcdir='$prefix/lib/pkgconfig' 20 includedir='$prefix/include/bitlbee' 19 21 20 22 msn=1 … … 80 82 pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'` 81 83 ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'` 84 includedir=`eval echo "$includedir" | sed 's/\/\{1,\}/\//g'` 85 pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'` 82 86 83 87 cat<<EOF>Makefile.settings … … 91 95 CONFIG=$config 92 96 IPCSOCKET=$ipcsocket 97 INCLUDEDIR=$includedir 98 PCDIR=$pcdir 93 99 94 100 ARCH=$arch … … 300 306 301 307 echo 302 if [ -z "$BITLBEE_VERSION" -a -d .bzr -a -x "`which bzr`" ]; then 308 if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then 309 nick=`bzr nick` 310 if [ -n "$nick" -a "$nick" != "bitlbee" ]; then 311 nick="-$nick" 312 else 313 nick="" 314 fi 303 315 rev=`bzr revno` 304 316 echo 'Using bzr revision #'$rev' as version number' 305 BITLBEE_VERSION=\"bzr -$rev\"317 BITLBEE_VERSION=\"bzr$nick-$rev\" 306 318 fi 307 319 … … 313 325 fi 314 326 327 cat <<EOF>bitlbee.pc 328 prefix=$prefix 329 includedir=$includedir 330 331 Name: bitlbee 332 Description: IRC to IM gateway 333 Requires: glib-2.0 334 Version: $BITLBEE_VERSION 335 Libs: 336 Cflags: -I\${includedir} 337 338 EOF 339 315 340 protocols='' 316 341 protoobjs='' -
doc/bitlbee.8
r46ad029 r601e813 116 116 .SH AUTHORS 117 117 .PP 118 Wilmer van der Gaast < lintux@lintux.cx>118 Wilmer van der Gaast <wilmer@gaast.net> 119 119 .BR 120 120 Jelmer Vernooij <jelmer@vernstok.nl> -
doc/bitlbee.xinetd
r46ad029 r601e813 14 14 server = /usr/local/sbin/bitlbee 15 15 16 ## xinetd is fucking retarded, what's the use of this port flag if 17 ## it HAS to be the same as in /etc/services ? 18 # port = 6667 16 ## You might want to limit access to localhost only: 17 # bind = 127.0.0.1 18 19 ## Thanks a lot to friedman@splode.com for telling us about the type 20 ## argument, so now this file can be used without having to edit 21 ## /etc/services too. 22 type = UNLISTED 23 port = 6667 19 24 } -
doc/example_plugin.c
r46ad029 r601e813 3 3 * a shared library and place it in the plugin directory: 4 4 * 5 * gcc -o example.so -shared example.c 5 * gcc -o example.so -shared example.c `pkg-config --cflags bitlbee` 6 6 * cp example.so /usr/local/lib/bitlbee 7 7 */ 8 8 #include <stdio.h> 9 #include <bitlbee.h> 9 10 10 11 void init_plugin(void) -
doc/user-guide/commands.xml
r46ad029 r601e813 141 141 <short-description>Add a buddy to your contact list</short-description> 142 142 <syntax>add <connection> <handle> [<nick>]</syntax> 143 <syntax>add -tmp <connection> <handle> [<nick>]</syntax> 143 144 144 145 <description> … … 149 150 <para> 150 151 If you want, you can also tell BitlBee what nick to give the new contact. Of course you can also use the <emphasis>rename</emphasis> command for that, but sometimes this might be more convenient. 152 </para> 153 154 <para> 155 Adding -tmp adds the buddy to the internal BitlBee structures only, not to the real contact list (like done by <emphasis>set handle_unknown add</emphasis>). This allows you to talk to people who are not in your contact list. 151 156 </para> 152 157 </description> … … 197 202 <syntax>block <nick></syntax> 198 203 <syntax>block <connection> <handle></syntax> 204 <syntax>block <connection></syntax> 199 205 200 206 <description> 201 207 <para> 202 208 Puts the specified user on your ignore list. Either specify the user's nick when you have him/her in your contact list or a connection number and a user handle. 209 </para> 210 211 <para> 212 When called with only a connection specification as an argument, the command displays the current block list for that connection. 203 213 </para> 204 214 </description> … … 214 224 Reverse of block. Unignores the specified user or user handle on specified connection. 215 225 </para> 226 227 <para> 228 When called with only a connection specification as an argument, the command displays the current allow list for that connection. 229 </para> 216 230 </description> 217 231 </bitlbee-command> … … 607 621 608 622 <para> 609 To identify yourself in later sessions, you can use the <emphasis>identify</emphasis> command. 623 To identify yourself in later sessions, you can use the <emphasis>identify</emphasis> command. To change your password later, you can use the <emphasis>set password</emphasis> command. 610 624 </para> 611 625 </description> -
help.c
r46ad029 r601e813 116 116 h = h->next; 117 117 } 118 if( h )118 if( h && h->length > 0 ) 119 119 { 120 120 char *s = g_new( char, h->length + 1 ); … … 123 123 { 124 124 g_free( h ); 125 *help =NULL;126 return ( NULL );125 *help = NULL; 126 return NULL; 127 127 } 128 128 mtime = stat->st_mtime; 129 129 130 if( mtime > h->mtime ) { 131 return( NULL ); 132 return( g_strdup( "Help file changed during this session. Please restart to get help back." ) ); 133 } 130 if( mtime > h->mtime ) 131 return NULL; 132 134 133 s[h->length] = 0; 135 134 if( h->fd >= 0 ) … … 142 141 strncpy( s, h->offset.mem_offset, h->length ); 143 142 } 144 return ( s );143 return s; 145 144 } 146 145 147 return ( NULL );146 return NULL; 148 147 } -
ipc.c
r46ad029 r601e813 84 84 void ipc_master_cmd_restart( irc_t *data, char **cmd ) 85 85 { 86 struct bitlbee_child *child = (void*) data;87 88 86 if( global.conf->runmode != RUNMODE_FORKDAEMON ) 89 87 { … … 509 507 } 510 508 511 if (bind(serversock, &un_addr, sizeof(un_addr)) == -1) {509 if (bind(serversock, (struct sockaddr *)&un_addr, sizeof(un_addr)) == -1) { 512 510 log_message( LOGLVL_WARNING, "Unable to bind UNIX socket to %s: %s", IPCSOCKET, strerror(errno) ); 513 511 return 0; … … 573 571 ipc_to_children_str( "OPERMSG :New BitlBee master process started (version " BITLBEE_VERSION ")\r\n" ); 574 572 573 fclose( fp ); 575 574 return 1; 576 575 } -
ipc.h
r46ad029 r601e813 47 47 48 48 void ipc_to_master( char **cmd ); 49 void ipc_to_master_str( char *format, ... ) ;49 void ipc_to_master_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); 50 50 void ipc_to_children( char **cmd ); 51 void ipc_to_children_str( char *format, ... ) ;51 void ipc_to_children_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); 52 52 53 53 /* We need this function in inetd mode, so let's just make it non-static. */ -
irc.c
r46ad029 r601e813 199 199 } 200 200 201 static gboolean irc_free_ userhash( gpointer key, gpointer value, gpointer data )201 static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data ) 202 202 { 203 203 g_free( key ); … … 232 232 irc_connection_list = g_slist_remove( irc_connection_list, irc ); 233 233 234 for (account = irc->accounts; account; account = account->next) 235 if (account->gc) 234 for (account = irc->accounts; account; account = account->next) { 235 if (account->gc) { 236 account->gc->wants_to_die = TRUE; 236 237 signoff(account->gc); 238 } else if (account->reconnect) { 239 cancel_auto_reconnect(account); 240 } 241 } 237 242 238 243 g_free(irc->sendbuffer); … … 282 287 } 283 288 284 g_hash_table_foreach_remove(irc->userhash, irc_free_ userhash, NULL);289 g_hash_table_foreach_remove(irc->userhash, irc_free_hashkey, NULL); 285 290 g_hash_table_destroy(irc->userhash); 286 291 287 g_hash_table_foreach_remove(irc->watches, irc_free_ userhash, NULL);292 g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); 288 293 g_hash_table_destroy(irc->watches); 289 294 … … 343 348 void irc_process( irc_t *irc ) 344 349 { 345 char **lines, *temp, **cmd ;350 char **lines, *temp, **cmd, *cs; 346 351 int i; 347 352 … … 352 357 for( i = 0; *lines[i] != '\0'; i ++ ) 353 358 { 359 char conv[IRC_MAX_LINE+1]; 360 361 /* [WvG] Because irc_tokenize splits at every newline, the lines[] list 362 should end with an empty string. This is why this actually works. 363 Took me a while to figure out, Maurits. :-P */ 354 364 if( lines[i+1] == NULL ) 355 365 { … … 359 369 i ++; 360 370 break; 361 } 371 } 372 373 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 374 { 375 conv[IRC_MAX_LINE] = 0; 376 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 377 lines[i] = conv; 378 } 362 379 363 380 if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) … … 385 402 } 386 403 404 /* Splits a long string into separate lines. The array is NULL-terminated and, unless the string 405 contains an incomplete line at the end, ends with an empty string. */ 387 406 char **irc_tokenize( char *buffer ) 388 407 { … … 425 444 } 426 445 446 /* Split an IRC-style line into little parts/arguments. */ 427 447 char **irc_parse_line( char *line ) 428 448 { … … 484 504 } 485 505 506 /* Converts such an array back into a command string. Mainly used for the IPC code right now. */ 486 507 char *irc_build_line( char **cmd ) 487 508 { … … 536 557 537 558 u = user_find( irc, irc->mynick ); 538 i f( u ) is_private = u->is_private;559 is_private = u->is_private; 539 560 540 561 va_start( params, format ); … … 560 581 { 561 582 int size; 562 char line[IRC_MAX_LINE ];563 583 char line[IRC_MAX_LINE+1], *cs; 584 564 585 if( irc->quit ) 565 586 return; 566 567 g_vsnprintf( line, IRC_MAX_LINE - 3, format, params ); 568 587 588 line[IRC_MAX_LINE] = 0; 589 g_vsnprintf( line, IRC_MAX_LINE - 2, format, params ); 590 569 591 strip_newlines( line ); 592 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 593 { 594 char conv[IRC_MAX_LINE+1]; 595 596 conv[IRC_MAX_LINE] = 0; 597 if( do_iconv( "UTF-8", cs, line, conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 598 strcpy( line, conv ); 599 } 570 600 strcat( line, "\r\n" ); 571 601 572 602 if( irc->sendbuffer != NULL ) { 573 603 size = strlen( irc->sendbuffer ) + strlen( line ); … … 800 830 irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title ); 801 831 else 802 irc_reply( irc, 331, "%s :No topic for this channel" );832 irc_reply( irc, 331, "%s :No topic for this channel", channel ); 803 833 } 804 834 } … … 856 886 if( g_hash_table_lookup( irc->watches, nick ) ) 857 887 { 858 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );888 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" ); 859 889 } 860 890 g_free( nick ); … … 881 911 if( g_hash_table_lookup( irc->watches, nick ) ) 882 912 { 883 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );913 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" ); 884 914 } 885 915 g_free( nick ); … … 981 1011 else if( c && c->gc && c->gc->prpl ) 982 1012 { 983 return( serv_send_chat( irc,c->gc, c->id, s ) );1013 return( bim_chat_msg( c->gc, c->id, s ) ); 984 1014 } 985 1015 … … 991 1021 user_t *u = data; 992 1022 1023 /* Shouldn't happen, but just to be sure. */ 1024 if( u->sendbuf_len < 2 ) 1025 return FALSE; 1026 993 1027 u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */ 994 serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );1028 bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags ); 995 1029 996 1030 g_free( u->sendbuf ); … … 1000 1034 u->sendbuf_flags = 0; 1001 1035 1002 return ( FALSE );1036 return FALSE; 1003 1037 } 1004 1038 … … 1013 1047 if( u->sendbuf_len > 0 && u->sendbuf_flags != flags) 1014 1048 { 1015 / /Flush the buffer1049 /* Flush the buffer */ 1016 1050 g_source_remove( u->sendbuf_timer ); 1017 1051 buddy_send_handler_delayed( u ); … … 1021 1055 { 1022 1056 u->sendbuf_len = strlen( msg ) + 2; 1023 u->sendbuf = g_new (char, u->sendbuf_len );1057 u->sendbuf = g_new( char, u->sendbuf_len ); 1024 1058 u->sendbuf[0] = 0; 1025 1059 u->sendbuf_flags = flags; … … 1028 1062 { 1029 1063 u->sendbuf_len += strlen( msg ) + 1; 1030 u->sendbuf = g_renew 1064 u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len ); 1031 1065 } 1032 1066 … … 1044 1078 else 1045 1079 { 1046 serv_send_im( irc, u, msg, flags );1080 bim_buddy_msg( u->gc, u->handle, msg, flags ); 1047 1081 } 1048 1082 } -
irc.h
r46ad029 r601e813 33 33 #define IRC_PING_STRING "PinglBee" 34 34 35 #define UMODES " iasw"35 #define UMODES "abisw" 36 36 #define UMODES_PRIV "Ro" 37 37 #define CMODES "nt" … … 105 105 106 106 irc_t *irc_new( int fd ); 107 void irc_abort( irc_t *irc, int immed, char *format, ... ) ;107 void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); 108 108 void irc_free( irc_t *irc ); 109 109 … … 114 114 115 115 void irc_vawrite( irc_t *irc, char *format, va_list params ); 116 void irc_write( irc_t *irc, char *format, ... ) ;117 void irc_write_all( int now, char *format, ... ) ;118 void irc_reply( irc_t *irc, int code, char *format, ... ) ;119 G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) ;116 void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 117 void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 118 void irc_reply( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); 119 G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 120 120 char **irc_tokenize( char *buffer ); 121 121 -
irc_commands.c
r46ad029 r601e813 385 385 386 386 if( u && u->online ) 387 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "is online" );387 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" ); 388 388 else 389 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", time( NULL ), "is offline" );389 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" ); 390 390 } 391 391 else if( cmd[i][0] == '-' ) … … 448 448 449 449 if( gc && gc->flags & OPT_LOGGED_IN ) 450 proto_away( gc, u->away );450 bim_set_away( gc, u->away ); 451 451 } 452 452 } … … 509 509 irc->last_pong = gettime(); 510 510 irc->pinging = 0; 511 } 512 513 static void irc_cmd_version( irc_t *irc, char **cmd ) 514 { 515 irc_reply( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU ); 511 516 } 512 517 … … 568 573 { "motd", 0, irc_cmd_motd, IRC_CMD_LOGGED_IN }, 569 574 { "pong", 0, irc_cmd_pong, IRC_CMD_LOGGED_IN }, 575 { "version", 0, irc_cmd_version, IRC_CMD_LOGGED_IN }, 570 576 { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN }, 571 577 { "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, -
log.h
r46ad029 r601e813 54 54 void log_init(void); 55 55 void log_link(int level, int output); 56 void log_message(int level, char *message, ...) ;56 void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 ); 57 57 void log_error(char *functionname); 58 58 -
protocols/http_client.c
r46ad029 r601e813 69 69 70 70 return( req ); 71 } 72 73 void *http_dorequest_url( char *url_string, http_input_function func, gpointer data ) 74 { 75 url_t *url = g_new0( url_t, 1 ); 76 char *request; 77 void *ret; 78 79 if( !url_set( url, url_string ) ) 80 { 81 g_free( url ); 82 return NULL; 83 } 84 85 if( url->proto != PROTO_HTTP && url->proto != PROTO_HTTPS ) 86 { 87 g_free( url ); 88 return NULL; 89 } 90 91 request = g_strdup_printf( "GET %s HTTP/1.0\r\n" 92 "Host: %s\r\n" 93 "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n" 94 "\r\n", url->file, url->host ); 95 96 ret = http_dorequest( url->host, url->port, 97 url->proto == PROTO_HTTPS, request, func, data ); 98 99 g_free( url ); 100 g_free( request ); 101 return ret; 71 102 } 72 103 … … 222 253 evil_server = 1; 223 254 } 224 else 255 else if( end1 ) 225 256 { 226 257 end1 += 2; 227 258 } 228 229 if( end1 ) 230 { 231 *end1 = 0; 232 233 if( evil_server ) 234 req->reply_body = end1 + 1; 235 else 236 req->reply_body = end1 + 2; 237 } 259 else 260 { 261 goto cleanup; 262 } 263 264 *end1 = 0; 265 266 if( evil_server ) 267 req->reply_body = end1 + 1; 268 else 269 req->reply_body = end1 + 2; 270 271 req->body_size = req->reply_headers + req->bytes_read - req->reply_body; 238 272 239 273 if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL ) -
protocols/http_client.h
r46ad029 r601e813 39 39 char *reply_headers; 40 40 char *reply_body; 41 int body_size; 41 42 int finished; 42 43 … … 53 54 54 55 void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ); 56 void *http_dorequest_url( char *url_string, http_input_function func, gpointer data ); -
protocols/jabber/jabber.c
r46ad029 r601e813 1045 1045 */ 1046 1046 if(find_buddy(GJ_GC(jap->gjc), jap->user) == NULL) { 1047 show_got_added(GJ_GC(jap->gjc), NULL, jap->user, NULL, NULL);1047 show_got_added(GJ_GC(jap->gjc), jap->user, NULL); 1048 1048 } 1049 1049 g_free(jap->user); … … 1232 1232 } 1233 1233 1234 x = jutil_presnew(0, NULL, "Online"); 1235 gjab_send(gjc, x); 1236 xmlnode_free(x); 1234 account_online(GJ_GC(gjc)); 1237 1235 } 1238 1236 … … 1250 1248 } else { 1251 1249 gjab_reqroster(gjc); 1252 account_online(GJ_GC(gjc));1253 1250 1254 1251 ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE; … … 1552 1549 if(jd->gjc != NULL) { 1553 1550 gjab_delete(jd->gjc); 1551 /* YAY for modules with their own memory pool managers!... 1554 1552 g_free(jd->gjc->sid); 1553 And a less sarcastic yay for valgrind. :-) */ 1555 1554 jd->gjc = NULL; 1556 1555 } … … 1888 1887 } 1889 1888 1890 static void jabber_set_idle(struct gaim_connection *gc, int idle) {1891 struct jabber_data *jd = (struct jabber_data *)gc->proto_data;1892 jd->idle = idle ? time(NULL) - idle : idle;1893 }1894 1895 1889 static void jabber_keepalive(struct gaim_connection *gc) { 1896 1890 struct jabber_data *jd = (struct jabber_data *)gc->proto_data; 1897 1891 gjab_send_raw(jd->gjc, " \t "); 1898 }1899 1900 static void jabber_buddy_free(struct buddy *b)1901 {1902 while (b->proto_data) {1903 g_free(((GSList *)b->proto_data)->data);1904 b->proto_data = g_slist_remove(b->proto_data, ((GSList *)b->proto_data)->data);1905 }1906 1892 } 1907 1893 … … 2341 2327 } 2342 2328 2343 2344 static GList *jabber_actions()2345 {2346 GList *m = NULL;2347 2348 m = g_list_append(m, _("Set User Info"));2349 /*2350 m = g_list_append(m, _("Set Dir Info"));2351 m = g_list_append(m, _("Change Password"));2352 */2353 2354 return m;2355 }2356 2357 2358 2329 void jabber_init() 2359 2330 { 2360 2331 struct prpl *ret = g_new0(struct prpl, 1); 2361 2332 2362 /* the NULL's aren't required but they're nice to have */2363 2333 ret->name = "jabber"; 2364 2334 ret->away_states = jabber_away_states; 2365 ret->actions = jabber_actions;2366 2335 ret->login = jabber_login; 2367 2336 ret->close = jabber_close; … … 2371 2340 ret->set_away = jabber_set_away; 2372 2341 ret->get_away = jabber_get_away_msg; 2373 ret->set_idle = jabber_set_idle;2374 2342 ret->add_buddy = jabber_add_buddy; 2375 2343 ret->remove_buddy = jabber_remove_buddy; 2376 ret->add_permit = NULL;2377 ret->add_deny = NULL;2378 ret->rem_permit = NULL;2379 ret->rem_deny = NULL;2380 ret->set_permit_deny = NULL;2381 2344 ret->keepalive = jabber_keepalive; 2382 ret->buddy_free = jabber_buddy_free;2383 2345 ret->alias_buddy = jabber_roster_update; 2384 2346 ret->group_buddy = jabber_group_change; -
protocols/jabber/xmlparse.c
r46ad029 r601e813 1461 1461 s = protocolEncodingName; 1462 1462 #endif 1463 if ( (ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s))1463 if (ns ? XmlInitEncodingNS(&initEncoding, &encoding, s) : XmlInitEncoding(&initEncoding, &encoding, s)) 1464 1464 return XML_ERROR_NONE; 1465 1465 return handleUnknownEncoding(parser, protocolEncodingName); … … 1475 1475 int standalone = -1; 1476 1476 if (!(ns 1477 ? XmlParseXmlDeclNS 1478 : XmlParseXmlDecl)(isGeneralTextEntity, 1477 ? XmlParseXmlDeclNS(isGeneralTextEntity, 1479 1478 encoding, 1480 1479 s, … … 1484 1483 &encodingName, 1485 1484 &newEncoding, 1486 &standalone)) 1485 &standalone) 1486 : XmlParseXmlDecl(isGeneralTextEntity, 1487 encoding, 1488 s, 1489 next, 1490 &eventPtr, 1491 &version, 1492 &encodingName, 1493 &newEncoding, 1494 &standalone))) 1487 1495 return XML_ERROR_SYNTAX; 1488 1496 if (!isGeneralTextEntity && standalone == 1) … … 1537 1545 } 1538 1546 enc = (ns 1539 ? XmlInitUnknownEncodingNS 1540 : XmlInitUnknownEncoding)(unknownEncodingMem, 1547 ? XmlInitUnknownEncodingNS(unknownEncodingMem, 1541 1548 info.map, 1542 1549 info.convert, 1543 info.data); 1550 info.data) 1551 : XmlInitUnknownEncoding(unknownEncodingMem, 1552 info.map, 1553 info.convert, 1554 info.data)); 1544 1555 if (enc) { 1545 1556 unknownEncodingData = info.data; -
protocols/msn/msn.h
r46ad029 r601e813 66 66 GSList *msgq; 67 67 GSList *switchboards; 68 const struct msn_away_state *away_state; 69 68 70 int buddycount; 69 const struct msn_away_state *away_state; 71 int groupcount; 72 char **grouplist; 70 73 }; 71 74 -
protocols/msn/msn_util.c
r46ad029 r601e813 46 46 int msn_logged_in( struct gaim_connection *gc ) 47 47 { 48 struct msn_data *md = gc->proto_data;49 char buf[1024];50 51 48 account_online( gc ); 52 53 /* account_online() sets an away state if there is any, so only54 execute this code if we're not away. */55 if( md->away_state == msn_away_state_list )56 {57 g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 );58 return( msn_write( gc, buf, strlen( buf ) ) );59 }60 49 61 50 return( 0 ); … … 141 130 { 142 131 msn_buddy_list_add( bla->gc, "AL", bla->handle, bla->realname ); 132 133 if( find_buddy( bla->gc, bla->handle ) == NULL ) 134 show_got_added( bla->gc, bla->handle, NULL ); 143 135 144 136 g_free( bla->handle ); -
protocols/msn/ns.c
r46ad029 r601e813 257 257 { 258 258 md->buddycount = atoi( cmd[3] ); 259 md->groupcount = atoi( cmd[4] ); 260 if( md->groupcount > 0 ) 261 md->grouplist = g_new0( char *, md->groupcount ); 259 262 260 263 if( !*cmd[3] || md->buddycount == 0 ) … … 269 272 } 270 273 } 271 else if( strcmp( cmd[0], "GTC" ) == 0 )272 {273 }274 else if( strcmp( cmd[0], "BLP" ) == 0 )275 {276 }277 else if( strcmp( cmd[0], "PRP" ) == 0 )278 {279 }280 else if( strcmp( cmd[0], "LSG" ) == 0 )281 {282 }283 274 else if( strcmp( cmd[0], "LST" ) == 0 ) 284 275 { … … 297 288 if( list & 1 ) /* FL */ 298 289 { 299 add_buddy( gc, NULL, cmd[1], cmd[2] ); 290 char *group = NULL; 291 int num; 292 293 if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 ) 294 group = md->grouplist[num]; 295 296 add_buddy( gc, group, cmd[1], cmd[2] ); 300 297 } 301 298 if( list & 2 ) /* AL */ … … 327 324 } 328 325 } 329 else if( strcmp( cmd[0], "BPR" ) == 0 ) 330 { 331 } 332 else if( strcmp( cmd[0], "CHG" ) == 0 ) 333 { 326 else if( strcmp( cmd[0], "LSG" ) == 0 ) 327 { 328 int num; 329 330 if( num_parts != 4 ) 331 { 332 hide_login_progress_error( gc, "Syntax error" ); 333 signoff( gc ); 334 return( 0 ); 335 } 336 337 http_decode( cmd[2] ); 338 num = atoi( cmd[1] ); 339 340 if( num < md->groupcount ) 341 md->grouplist[num] = g_strdup( cmd[2] ); 334 342 } 335 343 else if( strcmp( cmd[0], "CHL" ) == 0 ) … … 357 365 return( msn_write( gc, buf, strlen( buf ) ) ); 358 366 } 359 else if( strcmp( cmd[0], "QRY" ) == 0 )360 {361 }362 else if( strcmp( cmd[0], "QNG" ) == 0 )363 {364 }365 367 else if( strcmp( cmd[0], "ILN" ) == 0 ) 366 368 { … … 478 480 msn_buddy_ask( gc, cmd[4], cmd[5] ); 479 481 } 480 }481 else if( strcmp( cmd[0], "REM" ) == 0 )482 {483 482 } 484 483 else if( strcmp( cmd[0], "OUT" ) == 0 ) -
protocols/msn/sb.c
r46ad029 r601e813 202 202 debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); 203 203 204 if( sb->key ) g_free( sb->key );205 if( sb->who ) g_free( sb->who );206 207 204 if( sb->msgq ) 208 205 { … … 222 219 serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with " 223 220 "unsent message to %s, you'll have to resend it.", 224 m->who ? m->who : "(unknown)" ); 225 } 221 sb->who ? sb->who : "(unknown)" ); 222 } 223 224 if( sb->key ) g_free( sb->key ); 225 if( sb->who ) g_free( sb->who ); 226 226 227 227 if( sb->chat ) -
protocols/nogaim.c
r46ad029 r601e813 14 14 * (except for the function names). 15 15 * 16 * Copyright 2002-200 4 Wilmer van der Gaast <lintux@lintux.cx>16 * Copyright 2002-2006 Wilmer van der Gaast <wilmer@gaast.net> and others 17 17 */ 18 18 … … 37 37 #include "nogaim.h" 38 38 #include <ctype.h> 39 #include <iconv.h>40 41 static char *proto_away_alias[7][5] =42 {43 { "Away from computer", "Away", "Extended away", NULL },44 { "NA", "N/A", "Not available", NULL },45 { "Busy", "Do not disturb", "DND", "Occupied", NULL },46 { "Be right back", "BRB", NULL },47 { "On the phone", "Phone", "On phone", NULL },48 { "Out to lunch", "Lunch", "Food", NULL },49 { NULL }50 };51 static char *proto_away_alias_find( GList *gcm, char *away );52 39 53 40 static int remove_chat_buddy_silent( struct conversation *b, char *handle ); … … 158 145 GSList *get_connections() { return connections; } 159 146 160 int proto_away( struct gaim_connection *gc, char *away )161 {162 GList *m, *ms;163 char *s;164 165 if( !away ) away = "";166 ms = m = gc->prpl->away_states( gc );167 168 while( m )169 {170 if( *away )171 {172 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )173 break;174 }175 else176 {177 if( g_strcasecmp( m->data, "Available" ) == 0 )178 break;179 if( g_strcasecmp( m->data, "Online" ) == 0 )180 break;181 }182 m = m->next;183 }184 185 if( m )186 {187 gc->prpl->set_away( gc, m->data, *away ? away : NULL );188 }189 else190 {191 s = proto_away_alias_find( ms, away );192 if( s )193 {194 gc->prpl->set_away( gc, s, away );195 if( set_getint( gc->irc, "debug" ) )196 serv_got_crap( gc, "Setting away state to %s", s );197 }198 else199 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );200 }201 202 g_list_free( ms );203 204 return( 1 );205 }206 207 static char *proto_away_alias_find( GList *gcm, char *away )208 {209 GList *m;210 int i, j;211 212 for( i = 0; *proto_away_alias[i]; i ++ )213 {214 for( j = 0; proto_away_alias[i][j]; j ++ )215 if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )216 break;217 218 if( !proto_away_alias[i][j] ) /* If we reach the end, this row */219 continue; /* is not what we want. Next! */220 221 /* Now find an entry in this row which exists in gcm */222 for( j = 0; proto_away_alias[i][j]; j ++ )223 {224 m = gcm;225 while( m )226 {227 if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )228 return( proto_away_alias[i][j] );229 m = m->next;230 }231 }232 }233 234 return( NULL );235 }236 237 147 /* multi.c */ 238 148 … … 305 215 { 306 216 va_list params; 307 char text[1024], buf[1024], acc_id[33]; 308 char *msg; 217 char *text; 309 218 account_t *a; 310 219 311 220 va_start( params, format ); 312 g_vsnprintf( text, sizeof( text ),format, params );221 text = g_strdup_vprintf( format, params ); 313 222 va_end( params ); 314 223 315 if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 &&316 do_iconv( "UTF8", set_getstr( gc->irc, "charset" ), text, buf, 0, 1024 ) != -1 )317 msg = buf;318 else319 msg = text;320 321 224 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 322 225 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 323 strip_html( msg);226 strip_html( text ); 324 227 325 228 /* Try to find a different connection on the same protocol. */ … … 328 231 break; 329 232 330 /* If we found one, add the screenname to the acc_id. */233 /* If we found one, include the screenname in the message. */ 331 234 if( a ) 332 g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username);235 irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, text ); 333 236 else 334 g_snprintf( acc_id, 32, "%s", gc->prpl->name);335 336 irc_usermsg( gc->irc, "%s - %s", acc_id, msg);237 irc_usermsg( gc->irc, "%s - %s", gc->prpl->name, text ); 238 239 g_free( text ); 337 240 } 338 241 … … 352 255 353 256 /* MSN servers sometimes redirect you to a different server and do 354 the whole login sequence again, so subsequentcalls to this257 the whole login sequence again, so these "late" calls to this 355 258 function should be handled correctly. (IOW, ignored) */ 356 259 if( gc->flags & OPT_LOGGED_IN ) … … 364 267 gc->flags |= OPT_LOGGED_IN; 365 268 366 if( u && u->away ) proto_away( gc, u->away ); 367 368 if( !strcmp(gc->prpl->name, "icq") ) 369 { 370 for( u = gc->irc->users; u; u = u->next ) 371 if( u->gc == gc ) 372 break; 373 374 if( u == NULL ) 375 serv_got_crap( gc, "\x02""***\x02"" BitlBee now supports ICQ server-side contact lists. " 376 "See \x02""help import_buddies\x02"" for more information." ); 377 } 269 /* Also necessary when we're not away, at least for some of the 270 protocols. */ 271 bim_set_away( gc, u->away ); 378 272 } 379 273 … … 392 286 while( g_source_remove_by_user_data( (gpointer) a ) ); 393 287 a->reconnect = 0; 394 }395 396 void account_offline( struct gaim_connection *gc )397 {398 gc->wants_to_die = TRUE;399 signoff( gc );400 288 } 401 289 … … 470 358 /* list.c */ 471 359 472 int bud_list_cache_exists( struct gaim_connection *gc )473 {474 return( 0 );475 }476 477 void do_import( struct gaim_connection *gc, void *null )478 {479 return;480 }481 482 360 void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ) 483 361 { … … 515 393 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) 516 394 { 517 u->host = g_strdup( gc->user->proto_opt[0] ); 395 char *colon; 396 397 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) 398 u->host = g_strndup( gc->user->proto_opt[0], 399 colon - gc->user->proto_opt[0] ); 400 else 401 u->host = g_strdup( gc->user->proto_opt[0] ); 402 518 403 u->user = g_strdup( handle ); 519 404 … … 531 416 u->gc = gc; 532 417 u->handle = g_strdup( handle ); 418 if( group ) u->group = g_strdup( group ); 533 419 u->send_handler = buddy_send_handler; 534 420 u->last_typing_notice = 0; … … 554 440 } 555 441 556 void do_export( struct gaim_connection *gc )557 {558 return;559 }560 561 442 void signoff_blocked( struct gaim_connection *gc ) 562 443 { … … 568 449 { 569 450 user_t *u = user_findhandle( gc, handle ); 570 char *name, buf[1024];571 451 572 452 if( !u ) return; 573 453 574 /* Convert all UTF-8 */ 575 if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 && 576 do_iconv( "UTF-8", set_getstr( gc->irc, "charset" ), realname, buf, 0, sizeof( buf ) ) != -1 ) 577 name = buf; 578 else 579 name = realname; 580 581 if( g_strcasecmp( u->realname, name ) != 0 ) 454 if( g_strcasecmp( u->realname, realname ) != 0 ) 582 455 { 583 456 if( u->realname != u->nick ) g_free( u->realname ); 584 457 585 u->realname = g_strdup( name );458 u->realname = g_strdup( realname ); 586 459 587 460 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) ) … … 593 466 /* prpl.c */ 594 467 595 void show_got_added( struct gaim_connection *gc, char *id, char *handle, const char *realname, const char *msg ) 596 { 597 return; 468 struct show_got_added_data 469 { 470 struct gaim_connection *gc; 471 char *handle; 472 }; 473 474 void show_got_added_no( gpointer w, struct show_got_added_data *data ) 475 { 476 g_free( data->handle ); 477 g_free( data ); 478 } 479 480 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 481 { 482 data->gc->prpl->add_buddy( data->gc, data->handle ); 483 add_buddy( data->gc, NULL, data->handle, data->handle ); 484 485 return show_got_added_no( w, data ); 486 } 487 488 void show_got_added( struct gaim_connection *gc, char *handle, const char *realname ) 489 { 490 struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 ); 491 char *s; 492 493 /* TODO: Make a setting for this! */ 494 if( user_findhandle( gc, handle ) != NULL ) 495 return; 496 497 s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle ); 498 499 data->gc = gc; 500 data->handle = g_strdup( handle ); 501 query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data ); 598 502 } 599 503 … … 625 529 return; 626 530 } 627 return; 531 /* Why did we have this here.... 532 return; */ 628 533 } 629 534 … … 689 594 irc_t *irc = gc->irc; 690 595 user_t *u; 691 char buf[8192];692 596 693 597 u = user_findhandle( gc, handle ); … … 731 635 strip_html( msg ); 732 636 733 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 &&734 do_iconv( "UTF-8", set_getstr( irc, "charset" ), msg, buf, 0, 8192 ) != -1 )735 msg = buf;736 737 637 while( strlen( msg ) > 425 ) 738 638 { … … 831 731 struct conversation *c; 832 732 user_t *u; 833 char buf[8192];834 733 835 734 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ … … 843 742 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 844 743 strip_html( msg ); 845 846 if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 &&847 do_iconv( "UTF-8", set_getstr( gc->irc, "charset" ), msg, buf, 0, 8192 ) != -1 )848 msg = buf;849 744 850 745 if( c && u ) … … 884 779 } 885 780 886 void serv_finish_login( struct gaim_connection *gc )887 {888 return;889 }890 891 781 892 782 /* buddy_chat.c */ … … 970 860 971 861 return( 0 ); 972 }973 974 975 /* prefs.c */976 977 /* Necessary? */978 void build_block_list()979 {980 return;981 }982 983 void build_allow_list()984 {985 return;986 862 } 987 863 … … 1065 941 } 1066 942 1067 int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) 1068 { 1069 char buf[8192]; 1070 1071 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && 1072 do_iconv( set_getstr( irc, "charset" ), "UTF-8", msg, buf, 0, 8192 ) != -1 ) 943 944 945 946 /* The plan is to not allow straight calls to prpl functions anymore, but do 947 them all from some wrappers. We'll start to define some down here: */ 948 949 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ) 950 { 951 char *buf = NULL; 952 int st; 953 954 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 955 { 956 buf = escape_html( msg ); 1073 957 msg = buf; 1074 1075 if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 1076 { 1077 char *html; 1078 1079 html = escape_html( msg ); 1080 strncpy( buf, html, 8192 ); 1081 g_free( html ); 1082 958 } 959 960 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 961 g_free( buf ); 962 963 return st; 964 } 965 966 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) 967 { 968 char *buf = NULL; 969 int st; 970 971 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 972 { 973 buf = escape_html( msg ); 1083 974 msg = buf; 1084 975 } 1085 976 1086 return( ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags ) ); 1087 } 1088 1089 int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg ) 1090 { 1091 char buf[8192]; 1092 1093 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && 1094 do_iconv( set_getstr( irc, "charset" ), "UTF-8", msg, buf, 0, 8192 ) != -1 ) 1095 msg = buf; 1096 1097 if( gc->flags & OPT_CONN_HTML) { 1098 char * html = escape_html(msg); 1099 strncpy(buf, html, 8192); 1100 g_free(html); 1101 } 1102 1103 return( gc->prpl->chat_send( gc, id, msg ) ); 1104 } 1105 1106 /* Convert from one charset to another. 1107 1108 from_cs, to_cs: Source and destination charsets 1109 src, dst: Source and destination strings 1110 size: Size if src. 0 == use strlen(). strlen() is not reliable for UNICODE/UTF16 strings though. 1111 maxbuf: Maximum number of bytes to write to dst 1112 1113 Returns the number of bytes written to maxbuf or -1 on an error. 1114 */ 1115 signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ) 1116 { 1117 iconv_t cd; 1118 size_t res; 1119 size_t inbytesleft, outbytesleft; 1120 char *inbuf = src; 1121 char *outbuf = dst; 1122 1123 cd = iconv_open( to_cs, from_cs ); 1124 if( cd == (iconv_t) -1 ) 1125 return( -1 ); 1126 1127 inbytesleft = size ? size : strlen( src ); 1128 outbytesleft = maxbuf - 1; 1129 res = iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft ); 1130 *outbuf = '\0'; 1131 iconv_close( cd ); 1132 1133 if( res == (size_t) -1 ) 1134 return( -1 ); 977 st = gc->prpl->chat_send( gc, id, msg ); 978 g_free( buf ); 979 980 return st; 981 } 982 983 static char *bim_away_alias_find( GList *gcm, char *away ); 984 985 int bim_set_away( struct gaim_connection *gc, char *away ) 986 { 987 GList *m, *ms; 988 char *s; 989 990 if( !away ) away = ""; 991 ms = m = gc->prpl->away_states( gc ); 992 993 while( m ) 994 { 995 if( *away ) 996 { 997 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 998 break; 999 } 1000 else 1001 { 1002 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1003 break; 1004 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1005 break; 1006 } 1007 m = m->next; 1008 } 1009 1010 if( m ) 1011 { 1012 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1013 } 1135 1014 else 1136 return( outbuf - dst ); 1137 } 1138 1139 char *set_eval_charset( irc_t *irc, set_t *set, char *value ) 1140 { 1141 iconv_t cd; 1142 1143 if ( g_strncasecmp( value, "none", 4 ) == 0 ) 1144 return( value ); 1145 1146 cd = iconv_open( "UTF-8", value ); 1147 if( cd == (iconv_t) -1 ) 1148 return( NULL ); 1149 1150 iconv_close( cd ); 1151 return( value ); 1152 } 1015 { 1016 s = bim_away_alias_find( ms, away ); 1017 if( s ) 1018 { 1019 gc->prpl->set_away( gc, s, away ); 1020 if( set_getint( gc->irc, "debug" ) ) 1021 serv_got_crap( gc, "Setting away state to %s", s ); 1022 } 1023 else 1024 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1025 } 1026 1027 g_list_free( ms ); 1028 1029 return( 1 ); 1030 } 1031 1032 static char *bim_away_alias_list[8][5] = 1033 { 1034 { "Away from computer", "Away", "Extended away", NULL }, 1035 { "NA", "N/A", "Not available", NULL }, 1036 { "Busy", "Do not disturb", "DND", "Occupied", NULL }, 1037 { "Be right back", "BRB", NULL }, 1038 { "On the phone", "Phone", "On phone", NULL }, 1039 { "Out to lunch", "Lunch", "Food", NULL }, 1040 { "Invisible", "Hidden" }, 1041 { NULL } 1042 }; 1043 1044 static char *bim_away_alias_find( GList *gcm, char *away ) 1045 { 1046 GList *m; 1047 int i, j; 1048 1049 for( i = 0; *bim_away_alias_list[i]; i ++ ) 1050 { 1051 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1052 if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 ) 1053 break; 1054 1055 if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */ 1056 continue; /* is not what we want. Next! */ 1057 1058 /* Now find an entry in this row which exists in gcm */ 1059 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1060 { 1061 m = gcm; 1062 while( m ) 1063 { 1064 if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 ) 1065 return( bim_away_alias_list[i][j] ); 1066 m = m->next; 1067 } 1068 } 1069 } 1070 1071 return( NULL ); 1072 } 1073 1074 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1075 { 1076 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1077 { 1078 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1079 } 1080 1081 gc->prpl->add_permit( gc, handle ); 1082 } 1083 1084 void bim_rem_allow( struct gaim_connection *gc, char *handle ) 1085 { 1086 GSList *l; 1087 1088 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1089 { 1090 g_free( l->data ); 1091 gc->permit = g_slist_delete_link( gc->permit, l ); 1092 } 1093 1094 gc->prpl->rem_permit( gc, handle ); 1095 } 1096 1097 void bim_add_block( struct gaim_connection *gc, char *handle ) 1098 { 1099 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1100 { 1101 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1102 } 1103 1104 gc->prpl->add_deny( gc, handle ); 1105 } 1106 1107 void bim_rem_block( struct gaim_connection *gc, char *handle ) 1108 { 1109 GSList *l; 1110 1111 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1112 { 1113 g_free( l->data ); 1114 gc->deny = g_slist_delete_link( gc->deny, l ); 1115 } 1116 1117 gc->prpl->rem_deny( gc, handle ); 1118 } -
protocols/nogaim.h
r46ad029 r601e813 15 15 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 16 16 * (and possibly other members of the Gaim team) 17 * Copyright 2002-2004 Wilmer van der Gaast < lintux@lintux.cx>17 * Copyright 2002-2004 Wilmer van der Gaast <wilmer@gaast.net> 18 18 */ 19 19 … … 52 52 #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ 53 53 54 #define PERMIT_ALL 155 #define PERMIT_NONE 256 #define PERMIT_SOME 357 #define DENY_SOME 458 59 54 #define WEBSITE "http://www.bitlee.org/" 60 55 #define IM_FLAG_AWAY 0x0020 … … 63 58 #define GAIM_AWAY_CUSTOM "Custom" 64 59 65 #define GAIM_LOGO 066 #define GAIM_ERROR 167 #define GAIM_WARNING 268 #define GAIM_INFO 369 70 60 /* ok. now the fun begins. first we create a connection structure */ 71 struct gaim_connection { 72 /* we need to do either oscar or TOC */ 73 /* we make this as an int in case if we want to add more protocols later */ 61 struct gaim_connection 62 { 74 63 struct prpl *prpl; 75 64 guint32 flags; 76 65 66 /* each connection then can have its own protocol-specific data */ 67 void *proto_data; 68 77 69 /* all connections need an input watcher */ 78 70 int inpa; 71 guint keepalive; 79 72 80 73 /* buddy list stuff. there is still a global groups for the buddy list, but … … 84 77 int permdeny; 85 78 86 /* all connections need a list of chats, even if they don't have chat */87 GSList *buddy_chats;88 89 /* each connection then can have its own protocol-specific data */90 void *proto_data;91 92 79 struct aim_user *user; 93 80 … … 95 82 char displayname[128]; 96 83 char password[32]; 97 guint keepalive;98 /* stuff needed for per-connection idle times */99 guint idle_timer;100 time_t login_time;101 time_t lastsent;102 int is_idle;103 84 104 85 char *away; 105 int is_auto_away;106 86 107 87 int evil; … … 110 90 /* BitlBee */ 111 91 irc_t *irc; 112 int lstitems; /* added for msnP8 */113 92 114 93 struct conversation *conversations; … … 183 162 const char *name; 184 163 185 /* for ICQ and Yahoo, who have off/on per-conversation options */186 /* char *checkbox; this should be per-connection */187 188 GList *(* away_states)(struct gaim_connection *gc);189 GList *(* actions)();190 void (* do_action)(struct gaim_connection *, char *);191 /* user_opts returns a GList* of g_malloc'd struct proto_user_opts */192 GList *(* user_opts)();193 GList *(* chat_info)(struct gaim_connection *);194 195 /* all the server-related functions */196 197 /* a lot of these (like get_dir) are protocol-dependent and should be removed. ones like198 * set_dir (which is also protocol-dependent) can stay though because there's a dialog199 * (i.e. the prpl says you can set your dir info, the ui shows a dialog and needs to call200 * set_dir in order to set it) */201 202 164 void (* login) (struct aim_user *); 165 void (* keepalive) (struct gaim_connection *); 203 166 void (* close) (struct gaim_connection *); 167 204 168 int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); 205 int (* send_typing) (struct gaim_connection *, char *who, int typing);206 void (* set_info) (struct gaim_connection *, char *info);207 void (* get_info) (struct gaim_connection *, char *who);208 169 void (* set_away) (struct gaim_connection *, char *state, char *message); 209 170 void (* get_away) (struct gaim_connection *, char *who); 210 void (* set_idle) (struct gaim_connection *, int idletime); 171 int (* send_typing) (struct gaim_connection *, char *who, int typing); 172 211 173 void (* add_buddy) (struct gaim_connection *, char *name); 174 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 212 175 void (* remove_buddy) (struct gaim_connection *, char *name, char *group); 213 176 void (* add_permit) (struct gaim_connection *, char *name); … … 216 179 void (* rem_deny) (struct gaim_connection *, char *name); 217 180 void (* set_permit_deny)(struct gaim_connection *); 181 182 void (* set_info) (struct gaim_connection *, char *info); 183 void (* get_info) (struct gaim_connection *, char *who); 184 void (* alias_buddy) (struct gaim_connection *, char *who); /* save/store buddy's alias on server list/roster */ 185 186 /* Group chat stuff. */ 218 187 void (* join_chat) (struct gaim_connection *, GList *data); 219 188 void (* chat_invite) (struct gaim_connection *, int id, char *who, char *message); 220 189 void (* chat_leave) (struct gaim_connection *, int id); 221 void (* chat_whisper) (struct gaim_connection *, int id, char *who, char *message);222 190 int (* chat_send) (struct gaim_connection *, int id, char *message); 223 191 int (* chat_open) (struct gaim_connection *, char *who); 224 void (* keepalive) (struct gaim_connection *); 225 226 /* get "chat buddy" info and away message */ 227 void (* get_cb_info) (struct gaim_connection *, int, char *who); 228 void (* get_cb_away) (struct gaim_connection *, int, char *who); 229 230 /* save/store buddy's alias on server list/roster */ 231 void (* alias_buddy) (struct gaim_connection *, char *who); 232 233 /* change a buddy's group on a server list/roster */ 234 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 235 236 /* file transfers */ 237 struct ft_send_req *(* req_send_file) (struct gaim_connection *, const char *file); 238 void (* send_file_part) (struct gaim_connection *, struct ft*, void *data, size_t length); 239 void (* accept_recv_file) (struct gaim_connection *, struct ft*, ft_recv_handler); 240 241 void (* buddy_free) (struct buddy *); 242 192 193 /* DIE! */ 243 194 char *(* get_status_string) (struct gaim_connection *gc, int stat); 244 195 196 GList *(* away_states)(struct gaim_connection *gc); 197 198 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ 245 199 int (* cmp_buddynames) (const char *who1, const char *who2); 246 200 }; … … 259 213 260 214 /* nogaim.c */ 261 int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags); 262 int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg ); 263 264 G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ); 265 char *set_eval_charset( irc_t *irc, set_t *set, char *value ); 215 int bim_set_away( struct gaim_connection *gc, char *away ); 216 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ); 217 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ); 218 219 void bim_add_allow( struct gaim_connection *gc, char *handle ); 220 void bim_rem_allow( struct gaim_connection *gc, char *handle ); 221 void bim_add_block( struct gaim_connection *gc, char *handle ); 222 void bim_rem_block( struct gaim_connection *gc, char *handle ); 266 223 267 224 void nogaim_init(); 268 int proto_away( struct gaim_connection *gc, char *away );269 225 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); 270 226 … … 278 234 G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg ); 279 235 G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg ); 280 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) ;236 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 281 237 G_MODULE_EXPORT void account_online( struct gaim_connection *gc ); 282 G_MODULE_EXPORT void account_offline( struct gaim_connection *gc );283 238 G_MODULE_EXPORT void signoff( struct gaim_connection *gc ); 284 239 … … 288 243 289 244 /* list.c */ 290 G_MODULE_EXPORT int bud_list_cache_exists( struct gaim_connection *gc );291 G_MODULE_EXPORT void do_import( struct gaim_connection *gc, void *null );292 245 G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ); 293 246 G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle ); 294 G_MODULE_EXPORT void do_export( struct gaim_connection *gc );295 247 G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc ); 296 248 … … 302 254 303 255 /* prpl.c */ 304 G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char * id, char *handle, const char *realname, const char *msg);256 G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname ); 305 257 306 258 /* server.c */ … … 313 265 G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id ); 314 266 315 /* util.c */316 G_MODULE_EXPORT void strip_linefeed( gchar *text );317 G_MODULE_EXPORT char *add_cr( char *text );318 G_MODULE_EXPORT char *tobase64( const char *text );319 G_MODULE_EXPORT char *normalize( const char *s );320 G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec );321 G_MODULE_EXPORT void strip_html( char *msg );322 G_MODULE_EXPORT char *escape_html( const char *html );323 G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value);324 G_MODULE_EXPORT char *ipv6_wrap( char *src );325 G_MODULE_EXPORT char *ipv6_unwrap( char *src );326 327 /* prefs.c */328 G_MODULE_EXPORT void build_block_list();329 G_MODULE_EXPORT void build_allow_list();330 331 267 struct conversation *conv_findchannel( char *channel ); 332 268 333 334 269 #endif -
protocols/oscar/aim.h
r46ad029 r601e813 728 728 }; 729 729 730 #define AIM_CHATFLAGS_NOREFLECT 0x0001 731 #define AIM_CHATFLAGS_AWAY 0x0002 730 #define AIM_CHATFLAGS_NOREFLECT 0x0001 731 #define AIM_CHATFLAGS_AWAY 0x0002 732 #define AIM_CHATFLAGS_UNICODE 0x0004 733 #define AIM_CHATFLAGS_ISO_8859_1 0x0008 734 732 735 int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen); 733 736 int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance); -
protocols/oscar/chat.c
r46ad029 r601e813 159 159 if (flags & AIM_CHATFLAGS_AWAY) 160 160 aim_addtlvtochain_noval(&otl, 0x0007); 161 161 162 /* [WvG] This wasn't there originally, but we really should send 163 the right charset flags, as we also do with normal 164 messages. Hope this will work. :-) */ 165 if (flags & AIM_CHATFLAGS_UNICODE) 166 aimbs_put16(&fr->data, 0x0002); 167 else if (flags & AIM_CHATFLAGS_ISO_8859_1) 168 aimbs_put16(&fr->data, 0x0003); 169 else 170 aimbs_put16(&fr->data, 0x0000); 171 172 aimbs_put16(&fr->data, 0x0000); 173 162 174 /* 163 175 * SubTLV: Type 1: Message -
protocols/oscar/oscar.c
r46ad029 r601e813 2 2 * gaim 3 3 * 4 * Some code copyright (C) 2002-2006, Jelmer Vernooij <jelmer@samba.org> 5 * and the BitlBee team. 4 6 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 5 7 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> … … 356 358 if (isdigit(*user->username)) { 357 359 odata->icq = TRUE; 358 /* this is odd but it's necessary for a proper do_import and do_export */ 360 /* This is odd but it's necessary for a proper do_import and do_export. 361 We don't do those anymore, but let's stick with it, just in case 362 it accidentally fixes something else too... */ 359 363 gc->password[8] = 0; 360 364 } else { … … 381 385 if (g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 && 382 386 g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) { 383 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails." );387 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",user->proto_opt[USEROPT_AUTH]); 384 388 } 385 389 … … 1117 1121 aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); 1118 1122 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); 1119 show_got_added(data->gc, NULL, uin, NULL, NULL); 1123 if(find_buddy(data->gc, uin) == NULL) 1124 show_got_added(data->gc, uin, NULL); 1120 1125 1121 1126 g_free(uin); … … 1148 1153 reason = msg + 6; 1149 1154 1150 dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: \n\n%s", uin, reason ? reason : "No reason given.");1155 dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given."); 1151 1156 data->gc = gc; 1152 1157 data->uin = uin; … … 1737 1742 odata->rights.maxdenies = (guint)maxdenies; 1738 1743 1739 // serv_finish_login(gc);1740 1741 if (bud_list_cache_exists(gc))1742 do_import(gc, NULL);1743 1744 1744 aim_clientready(sess, fr->conn); 1745 1745 … … 2060 2060 name = g_strdup(normalize(curitem->name)); 2061 2061 gc->permit = g_slist_append(gc->permit, name); 2062 build_allow_list();2063 2062 tmp++; 2064 2063 } … … 2074 2073 name = g_strdup(normalize(curitem->name)); 2075 2074 gc->deny = g_slist_append(gc->deny, name); 2076 build_block_list();2077 2075 tmp++; 2078 2076 } … … 2096 2094 } /* End of for loop */ 2097 2095 2098 if (tmp)2099 do_export(gc);2100 2096 aim_ssi_enable(sess, fr->conn); 2101 2097 … … 2282 2278 tm.tm_mday = (int)info->birthday; 2283 2279 tm.tm_mon = (int)info->birthmonth-1; 2284 tm.tm_year = (int)info->birthyear -1900;2280 tm.tm_year = (int)info->birthyear%100; 2285 2281 strftime(date, sizeof(date), "%Y-%m-%d", &tm); 2286 2282 info_string_append(str, "\n", _("Birthday"), date); … … 2506 2502 int ret; 2507 2503 guint8 len = strlen(message); 2504 guint16 flags; 2508 2505 char *s; 2509 2506 … … 2514 2511 if (*s & 128) 2515 2512 break; 2516 2513 2514 flags = AIM_CHATFLAGS_NOREFLECT; 2515 2517 2516 /* Message contains high ASCII chars, time for some translation! */ 2518 2517 if (*s) { … … 2521 2520 If we can't, fall back to UTF16. */ 2522 2521 if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { 2522 flags |= AIM_CHATFLAGS_ISO_8859_1; 2523 2523 len = ret; 2524 2524 } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { 2525 flags |= AIM_CHATFLAGS_UNICODE; 2525 2526 len = ret; 2526 2527 } else { … … 2533 2534 } 2534 2535 2535 ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);2536 ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len); 2536 2537 2537 2538 if (s != message) { -
protocols/oscar/oscar_util.c
r46ad029 r601e813 109 109 110 110 curPtr = sn; 111 while ( (*curPtr) != (char) NULL) {111 while ( (*curPtr) != (char) '\0') { 112 112 if ((*curPtr) != ' ') 113 113 i++; … … 140 140 curPtr1 = sn1; 141 141 curPtr2 = sn2; 142 while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) ) {142 while ( (*curPtr1 != (char) '\0') && (*curPtr2 != (char) '\0') ) { 143 143 if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) { 144 144 if (*curPtr1 == ' ') -
protocols/oscar/service.c
r46ad029 r601e813 733 733 int tlvlen; 734 734 735 data = AIM_ICQ_STATE_ WEBAWARE | AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */735 data = AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */ 736 736 737 737 tlvlen = aim_addtlvtochain32(&tl, 0x0006, data); … … 881 881 #endif 882 882 883 /* len can't be 0 here anyway... 883 884 } else if ((offset == 0x00001000) && (len == 0x00000000)) { 884 885 … … 887 888 aimbs_put32(&fr->data, 0xe9800998); 888 889 aimbs_put32(&fr->data, 0xecf8427e); 889 890 */ 890 891 } else 891 892 do_error_dialog(sess->aux_data, "WARNING: unknown hash request", "Gaim"); -
protocols/ssl_nss.c
r46ad029 r601e813 122 122 if( source == -1 ) 123 123 goto ssl_connected_failure; 124 125 124 126 127 125 /* Until we find out how to handle non-blocking I/O with NSS... */ 126 sock_make_blocking( conn->fd ); 127 128 128 conn->prfd = SSL_ImportFD(NULL, PR_ImportTCPSocket(source)); 129 129 SSL_OptionSet(conn->prfd, SSL_SECURITY, PR_TRUE); … … 181 181 return( ((struct scd*)conn)->fd ); 182 182 } 183 184 GaimInputCondition ssl_getdirection( void *conn ) 185 { 186 /* Just in case someone calls us, let's return the most likely case: */ 187 return GAIM_INPUT_READ; 188 } -
protocols/ssl_openssl.c
r46ad029 r601e813 5 5 \********************************************************************/ 6 6 7 /* SSL module - Open TLS version*/7 /* SSL module - OpenSSL version */ 8 8 9 9 /* … … 41 41 struct scd 42 42 { 43 SslInputFunction func;43 ssl_input_function func; 44 44 gpointer data; 45 45 int fd; 46 46 gboolean established; 47 47 48 int inpa; 49 int lasterr; /* Necessary for SSL_get_error */ 48 50 SSL *ssl; 49 51 SSL_CTX *ssl_ctx; … … 54 56 55 57 56 void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )58 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) 57 59 { 58 60 struct scd *conn = g_new0( struct scd, 1 ); … … 93 95 } 94 96 97 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ); 98 95 99 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) 96 100 { … … 98 102 99 103 if( source == -1 ) 100 goto ssl_connected_failure; 101 104 return ssl_handshake( data, -1, cond ); 105 106 /* Make it non-blocking at least during the handshake... */ 107 sock_make_nonblocking( conn->fd ); 102 108 SSL_set_fd( conn->ssl, conn->fd ); 103 109 104 if( SSL_connect( conn->ssl ) < 0 ) 105 goto ssl_connected_failure; 110 return ssl_handshake( data, source, cond ); 111 } 112 113 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) 114 { 115 struct scd *conn = data; 116 int st; 117 118 if( conn->inpa != -1 ) 119 { 120 gaim_input_remove( conn->inpa ); 121 conn->inpa = -1; 122 } 123 124 if( ( st = SSL_connect( conn->ssl ) ) < 0 ) 125 { 126 conn->lasterr = SSL_get_error( conn->ssl, st ); 127 if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE ) 128 goto ssl_connected_failure; 129 130 conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); 131 return; 132 } 106 133 107 134 conn->established = TRUE; 135 sock_make_blocking( conn->fd ); /* For now... */ 108 136 conn->func( conn->data, conn, cond ); 109 137 return; … … 127 155 int ssl_read( void *conn, char *buf, int len ) 128 156 { 157 int st; 158 129 159 if( !((struct scd*)conn)->established ) 130 return( 0 ); 131 132 return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) ); 160 { 161 ssl_errno = SSL_NOHANDSHAKE; 162 return -1; 163 } 164 165 st = SSL_read( ((struct scd*)conn)->ssl, buf, len ); 166 167 ssl_errno = SSL_OK; 168 if( st <= 0 ) 169 { 170 ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); 171 if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) 172 ssl_errno = SSL_AGAIN; 173 } 174 175 return st; 133 176 } 134 177 135 178 int ssl_write( void *conn, const char *buf, int len ) 136 179 { 180 int st; 181 137 182 if( !((struct scd*)conn)->established ) 138 return( 0 ); 139 140 return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) ); 183 { 184 ssl_errno = SSL_NOHANDSHAKE; 185 return -1; 186 } 187 188 st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); 189 190 ssl_errno = SSL_OK; 191 if( st <= 0 ) 192 { 193 ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); 194 if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) 195 ssl_errno = SSL_AGAIN; 196 } 197 198 return st; 141 199 } 142 200 … … 144 202 { 145 203 struct scd *conn = conn_; 204 205 if( conn->inpa != -1 ) 206 gaim_input_remove( conn->inpa ); 146 207 147 208 if( conn->established ) … … 159 220 return( ((struct scd*)conn)->fd ); 160 221 } 222 223 GaimInputCondition ssl_getdirection( void *conn ) 224 { 225 return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); 226 } -
protocols/yahoo/yahoo.c
r46ad029 r601e813 227 227 else if( g_strcasecmp( state, GAIM_AWAY_CUSTOM ) == 0 ) 228 228 { 229 if (gc->is_idle) 230 yd->current_status = YAHOO_STATUS_IDLE; 231 else 232 yd->current_status = YAHOO_STATUS_AVAILABLE; 229 yd->current_status = YAHOO_STATUS_AVAILABLE; 233 230 234 231 gc->away = NULL; 235 232 } 236 233 } 237 else if( gc->is_idle )238 yd->current_status = YAHOO_STATUS_IDLE;239 234 else 240 235 yd->current_status = YAHOO_STATUS_AVAILABLE; … … 615 610 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 616 611 617 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 0, 612 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 613 ( stat == YAHOO_STATUS_IDLE ) ? away : 0, 618 614 ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); 619 615 } -
query.c
r46ad029 r601e813 39 39 q->no = no; 40 40 q->data = data; 41 42 if( strchr( irc->umode, 'b' ) != NULL ) 43 { 44 char *s; 45 46 /* At least for the machine-parseable version, get rid of 47 newlines to make "parsing" easier. */ 48 for( s = q->question; *s; s ++ ) 49 if( *s == '\r' || *s == '\n' ) 50 *s = ' '; 51 } 41 52 42 53 if( irc->queries ) … … 127 138 disp = 1; 128 139 } 129 //Using irc_usermsg instead of serv_got_crap because \x02A is a char too, so a SPACE is needed.130 140 if( ans ) 131 141 { 142 serv_got_crap( q->gc, "Accepted: %s", q->question ); 132 143 q->yes( NULL, q->data ); 133 serv_got_crap( q->gc, "Accepted: %s", q->question );134 144 } 135 145 else 136 146 { 147 serv_got_crap( q->gc, "Rejected: %s", q->question ); 137 148 q->no( NULL, q->data ); 138 serv_got_crap( q->gc, "Rejected: %s", q->question );139 149 } 140 150 q->data = NULL; -
root_commands.c
r46ad029 r601e813 57 57 s --; 58 58 } 59 else 60 { 61 break; 62 } 63 } 64 else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) ) 65 { 66 char *cpy; 67 68 for( cpy = s; *cpy; cpy ++ ) 69 cpy[0] = cpy[1]; 59 70 } 60 71 else if( *s == q ) … … 245 256 int i = 0; 246 257 258 if( strchr( irc->umode, 'b' ) ) 259 irc_usermsg( irc, "Account list:" ); 260 247 261 for( a = irc->accounts; a; a = a->next ) 248 262 { … … 347 361 { 348 362 account_t *a; 363 int add_for_real = 1; 364 365 if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) 366 { 367 add_for_real = 0; 368 cmd ++; /* So evil... :-D */ 369 } 349 370 350 371 if( !( a = account_get( irc, cmd[1] ) ) ) … … 376 397 } 377 398 } 378 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 399 400 /* By making this optional, you can talk to people without having to 401 add them to your *real* (server-side) contact list. */ 402 if( add_for_real ) 403 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 404 379 405 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); 380 406 … … 484 510 account_t *a; 485 511 486 if( !cmd[2] ) 512 if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->gc ) 513 { 514 char *format; 515 GSList *l; 516 517 if( strchr( irc->umode, 'b' ) != NULL ) 518 format = "%s\t%s"; 519 else 520 format = "%-32.32s %-16.16s"; 521 522 irc_usermsg( irc, format, "Handle", "Nickname" ); 523 for( l = a->gc->deny; l; l = l->next ) 524 { 525 user_t *u = user_findhandle( a->gc, l->data ); 526 irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); 527 } 528 irc_usermsg( irc, "End of list." ); 529 530 return; 531 } 532 else if( !cmd[2] ) 487 533 { 488 534 user_t *u = user_find( irc, cmd[1] ); … … 512 558 else 513 559 { 514 gc->prpl->rem_permit( gc, cmd[2] );515 gc->prpl->add_deny( gc, cmd[2] );516 irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] );560 bim_rem_allow( gc, cmd[2] ); 561 bim_add_block( gc, cmd[2] ); 562 irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); 517 563 } 518 564 } … … 523 569 account_t *a; 524 570 525 if( !cmd[2] ) 571 if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->gc ) 572 { 573 char *format; 574 GSList *l; 575 576 if( strchr( irc->umode, 'b' ) != NULL ) 577 format = "%s\t%s"; 578 else 579 format = "%-32.32s %-16.16s"; 580 581 irc_usermsg( irc, format, "Handle", "Nickname" ); 582 for( l = a->gc->deny; l; l = l->next ) 583 { 584 user_t *u = user_findhandle( a->gc, l->data ); 585 irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); 586 } 587 irc_usermsg( irc, "End of list." ); 588 589 return; 590 } 591 else if( !cmd[2] ) 526 592 { 527 593 user_t *u = user_find( irc, cmd[1] ); … … 551 617 else 552 618 { 553 gc->prpl->rem_deny( gc, cmd[2] );554 gc->prpl->add_permit( gc, cmd[2] );555 556 irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] );619 bim_rem_block( gc, cmd[2] ); 620 bim_add_allow( gc, cmd[2] ); 621 622 irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); 557 623 } 558 624 } … … 635 701 int online = 0, away = 0, offline = 0; 636 702 user_t *u; 637 char s[64]; 703 char s[256]; 704 char *format; 638 705 int n_online = 0, n_away = 0, n_offline = 0; 639 706 … … 649 716 online = away = 1; 650 717 651 irc_usermsg( irc, "%-16.16s %-40.40s %s", "Nick", "User/Host/Network", "Status" ); 652 653 if( online == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away ) 654 { 655 g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 656 irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, "Online" ); 718 if( strchr( irc->umode, 'b' ) != NULL ) 719 format = "%s\t%s\t%s"; 720 else 721 format = "%-16.16s %-40.40s %s"; 722 723 irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" ); 724 725 for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away ) 726 { 727 if( online == 1 ) 728 { 729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 730 irc_usermsg( irc, format, u->nick, s, "Online" ); 731 } 732 657 733 n_online ++; 658 734 } 659 735 660 if( away == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away ) 661 { 662 g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 663 irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, u->away ); 736 for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away ) 737 { 738 if( away == 1 ) 739 { 740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 741 irc_usermsg( irc, format, u->nick, s, u->away ); 742 } 664 743 n_away ++; 665 744 } 666 745 667 if( offline == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && !u->online ) 668 { 669 g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 670 irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, "Offline" ); 746 for( u = irc->users; u; u = u->next ) if( u->gc && !u->online ) 747 { 748 if( offline == 1 ) 749 { 750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 751 irc_usermsg( irc, format, u->nick, s, "Offline" ); 752 } 671 753 n_offline ++; 672 754 } … … 697 779 else 698 780 { 699 char utf8[1024];700 701 781 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 702 782 703 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && 704 do_iconv( set_getstr( irc, "charset" ), "UTF-8", cmd[2], utf8, 0, 1024 ) != -1 ) 705 a->gc->prpl->set_info( a->gc, utf8 ); 706 else 707 a->gc->prpl->set_info( a->gc, cmd[2] ); 783 a->gc->prpl->set_info( a->gc, cmd[2] ); 708 784 } 709 785 } -
set.c
r46ad029 r601e813 150 150 if( s ) 151 151 { 152 t->next = s->next; 152 if( t ) 153 t->next = s->next; 154 else 155 irc->set = s->next; 156 153 157 g_free( s->key ); 154 158 if( s->value ) g_free( s->value ); -
user.c
r46ad029 r601e813 168 168 u->nick = g_strdup( newnick ); 169 169 if( !u->user ) u->user = u->nick; 170 if( !u->host ) u-> user = u->host;171 if( !u->realname ) u-> user = u->realname;170 if( !u->host ) u->host = u->nick; 171 if( !u->realname ) u->realname = u->nick; 172 172 173 173 /* Remove the old reference to this user from the hash and create a -
user.h
r46ad029 r601e813 37 37 38 38 char *handle; 39 char *group; 39 40 struct gaim_connection *gc; 40 41 -
util.c
r46ad029 r601e813 39 39 #include <glib.h> 40 40 #include <time.h> 41 #include <iconv.h> 41 42 42 43 void strip_linefeed(gchar *text) … … 445 446 } 446 447 #endif 448 449 /* Convert from one charset to another. 450 451 from_cs, to_cs: Source and destination charsets 452 src, dst: Source and destination strings 453 size: Size if src. 0 == use strlen(). strlen() is not reliable for UNICODE/UTF16 strings though. 454 maxbuf: Maximum number of bytes to write to dst 455 456 Returns the number of bytes written to maxbuf or -1 on an error. 457 */ 458 signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ) 459 { 460 iconv_t cd; 461 size_t res; 462 size_t inbytesleft, outbytesleft; 463 char *inbuf = src; 464 char *outbuf = dst; 465 466 cd = iconv_open( to_cs, from_cs ); 467 if( cd == (iconv_t) -1 ) 468 return( -1 ); 469 470 inbytesleft = size ? size : strlen( src ); 471 outbytesleft = maxbuf - 1; 472 res = iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft ); 473 *outbuf = '\0'; 474 iconv_close( cd ); 475 476 if( res == (size_t) -1 ) 477 return( -1 ); 478 else 479 return( outbuf - dst ); 480 } 481 482 char *set_eval_charset( irc_t *irc, set_t *set, char *value ) 483 { 484 iconv_t cd; 485 486 if ( g_strncasecmp( value, "none", 4 ) == 0 ) 487 return( value ); 488 489 cd = iconv_open( "UTF-8", value ); 490 if( cd == (iconv_t) -1 ) 491 return( NULL ); 492 493 iconv_close( cd ); 494 return( value ); 495 } -
utils/bitlbeed.c
r46ad029 r601e813 6 6 * (without access to /etc/inetd.conf or whatever) * 7 7 * * 8 * Copyright 2002-2004 Wilmer van der Gaast < lintux@debian.org>*8 * Copyright 2002-2004 Wilmer van der Gaast <wilmer@gaast.net> * 9 9 * * 10 10 * Licensed under the GNU General Public License *
Note: See TracChangeset
for help on using the changeset viewer.