- Timestamp:
- 2010-06-05T23:21:02Z (15 years ago)
- Branches:
- master
- Children:
- 1fdb0a4
- Parents:
- 3ab1d31 (diff), e774815 (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. - Location:
- protocols
- Files:
-
- 11 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/Makefile
r3ab1d31 rb308cf9 8 8 9 9 -include ../Makefile.settings 10 ifdef SRCDIR 11 SRCDIR := $(SRCDIR)protocols/ 12 endif 10 13 11 14 # [SH] Program variables … … 49 52 $(objects): ../Makefile.settings Makefile 50 53 51 $(objects): %.o: %.c54 $(objects): %.o: $(SRCDIR)%.c 52 55 @echo '*' Compiling $< 53 56 @$(CC) -c $(CFLAGS) $< -o $@ -
protocols/jabber/Makefile
r3ab1d31 rb308cf9 8 8 9 9 -include ../../Makefile.settings 10 ifdef SRCDIR 11 SRCDIR := $(SRCDIR)protocols/jabber/ 12 endif 10 13 11 14 # [SH] Program variables … … 33 36 $(objects): ../../Makefile.settings Makefile 34 37 35 $(objects): %.o: %.c38 $(objects): %.o: $(SRCDIR)%.c 36 39 @echo '*' Compiling $< 37 40 @$(CC) -c $(CFLAGS) $< -o $@ -
protocols/jabber/conference.c
r3ab1d31 rb308cf9 272 272 } 273 273 274 if( bud != jc->me ) 275 { 274 if( bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS ) 275 { 276 /* If JIDs are anonymized, add them to the local 277 list for the duration of this chat. */ 276 278 imcb_add_buddy( ic, bud->ext_jid, NULL ); 277 279 imcb_buddy_nick_hint( ic, bud->ext_jid, bud->resource ); -
protocols/jabber/io.c
r3ab1d31 rb308cf9 64 64 most cases it probably won't be necessary.) */ 65 65 if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 ) 66 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic );66 jd->w_inpa = b_input_add( jd->fd, B_EV_IO_WRITE, jabber_write_callback, ic ); 67 67 } 68 68 else … … 504 504 505 505 if( jd->r_inpa <= 0 ) 506 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic );506 jd->r_inpa = b_input_add( jd->fd, B_EV_IO_READ, jabber_read_callback, ic ); 507 507 508 508 greet = g_strdup_printf( "%s<stream:stream to=\"%s\" xmlns=\"jabber:client\" " -
protocols/jabber/jabber_util.c
r3ab1d31 rb308cf9 671 671 time_t jabber_get_timestamp( struct xt_node *xt ) 672 672 { 673 struct tm tp, utc;674 673 struct xt_node *c; 675 time_t res, tres;676 674 char *s = NULL; 675 struct tm tp; 677 676 678 677 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) … … 692 691 tp.tm_year -= 1900; 693 692 tp.tm_mon --; 694 tp.tm_isdst = -1; /* GRRRRRRRRRRR */ 695 696 res = mktime( &tp ); 697 /* Problem is, mktime() just gave us the GMT timestamp for the 698 given local time... While the given time WAS NOT local. So 699 we should fix this now. 700 701 Now I could choose between messing with environment variables 702 (kludgy) or using timegm() (not portable)... Or doing the 703 following, which I actually prefer... */ 704 gmtime_r( &res, &utc ); 705 utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */ 706 if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min ) 707 /* Sweet! We're in UTC right now... */ 708 return res; 709 710 tres = mktime( &utc ); 711 res += res - tres; 712 713 /* Yes, this is a hack. And it will go wrong around DST changes. 714 BUT this is more likely to be threadsafe than messing with 715 environment variables, and possibly more portable... */ 716 717 return res; 693 694 return mktime_utc( &tp ); 718 695 } 719 696 -
protocols/jabber/message.c
r3ab1d31 rb308cf9 80 80 if( type && strcmp( type, "headline" ) == 0 ) 81 81 { 82 c = xt_find_node( node->children, "subject" );83 g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "");82 if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 ) 83 g_string_append_printf( fullmsg, "Headline: %s\n", c->text ); 84 84 85 85 /* <x xmlns="jabber:x:oob"><url>http://....</url></x> can contain a URL, it seems. */ -
protocols/jabber/s5bytestream.c
r3ab1d31 rb308cf9 406 406 bt->phase = BS_PHASE_CONNECTED; 407 407 408 bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt );408 bt->tf->watch_out = b_input_add( fd, B_EV_IO_WRITE, jabber_bs_recv_handshake, bt ); 409 409 410 410 /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */ … … 433 433 bt->phase = BS_PHASE_REQUEST; 434 434 435 bt->tf->watch_in = b_input_add( fd, GAIM_INPUT_READ, jabber_bs_recv_handshake, bt );435 bt->tf->watch_in = b_input_add( fd, B_EV_IO_READ, jabber_bs_recv_handshake, bt ); 436 436 437 437 bt->tf->watch_out = 0; … … 590 590 591 591 tf->ft->data = tf; 592 tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt );592 tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_recv_read, bt ); 593 593 tf->ft->write_request = jabber_bs_recv_write_request; 594 594 … … 632 632 if( ( ret == -1 ) && ( errno == EAGAIN ) ) 633 633 { 634 tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt );634 tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_recv_read, bt ); 635 635 return FALSE; 636 636 } … … 708 708 imcb_file_finished( ft ); 709 709 else 710 bt->tf->watch_out = b_input_add( tf->fd, GAIM_INPUT_WRITE, jabber_bs_send_can_write, bt );710 bt->tf->watch_out = b_input_add( tf->fd, B_EV_IO_WRITE, jabber_bs_send_can_write, bt ); 711 711 712 712 return TRUE; … … 919 919 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 920 920 921 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt );921 bt->tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_send_handshake, bt ); 922 922 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 923 923 } else { … … 1056 1056 bt->phase = BS_PHASE_CONNECTED; 1057 1057 1058 bt->tf->watch_in = b_input_add( fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt );1058 bt->tf->watch_in = b_input_add( fd, B_EV_IO_READ, jabber_bs_send_handshake, bt ); 1059 1059 return FALSE; 1060 1060 } -
protocols/msn/Makefile
r3ab1d31 rb308cf9 8 8 9 9 -include ../../Makefile.settings 10 ifdef SRCDIR 11 SRCDIR := $(SRCDIR)protocols/msn/ 12 endif 10 13 11 14 # [SH] Program variables … … 33 36 $(objects): ../../Makefile.settings Makefile 34 37 35 $(objects): %.o: %.c38 $(objects): %.o: $(SRCDIR)%.c 36 39 @echo '*' Compiling $< 37 40 @$(CC) -c $(CFLAGS) $< -o $@ -
protocols/msn/invitation.c
r3ab1d31 rb308cf9 209 209 sock_make_nonblocking( fd ); 210 210 211 msn_file->r_event_id = b_input_add( fd, GAIM_INPUT_READ, msn_ftp_read, file );211 msn_file->r_event_id = b_input_add( fd, B_EV_IO_READ, msn_ftp_read, file ); 212 212 213 213 return FALSE; … … 230 230 } 231 231 232 msn_file->r_event_id = b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftps_connected, file );232 msn_file->r_event_id = b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftps_connected, file ); 233 233 234 234 g_snprintf( buf, sizeof( buf ), … … 318 318 319 319 sock_make_nonblocking( msn_file->fd ); 320 msn_file->r_event_id = b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftp_read, file );320 msn_file->r_event_id = b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftp_read, file ); 321 321 322 322 return FALSE; … … 415 415 ( msn_file->data_sent + msn_file->sbufpos - 3 < file->file_size ) ) { 416 416 if( !msn_file->w_event_id ) 417 msn_file->w_event_id = b_input_add( msn_file->fd, GAIM_INPUT_WRITE, msn_ftp_send, file );417 msn_file->w_event_id = b_input_add( msn_file->fd, B_EV_IO_WRITE, msn_ftp_send, file ); 418 418 return TRUE; 419 419 } … … 452 452 /* we might already be listening if this is data from an overflow */ 453 453 if( !msn_file->w_event_id ) 454 msn_file->w_event_id = b_input_add( msn_file->fd, GAIM_INPUT_WRITE, msn_ftp_send, file );454 msn_file->w_event_id = b_input_add( msn_file->fd, B_EV_IO_WRITE, msn_ftp_send, file ); 455 455 } 456 456 … … 617 617 618 618 msn_file->r_event_id = 619 b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftp_read, file );619 b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftp_read, file ); 620 620 621 621 return TRUE; -
protocols/msn/msn.c
r3ab1d31 rb308cf9 31 31 GSList *msn_switchboards; 32 32 33 static char * msn_set_display_name( set_t *set, char *value );33 static char *set_eval_display_name( set_t *set, char *value ); 34 34 35 35 static void msn_init( account_t *acc ) 36 36 { 37 set_t *s; 38 39 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 40 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 41 42 s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 37 set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 38 set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); 39 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 40 set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc ); 43 41 } 44 42 … … 171 169 static void msn_set_my_name( struct im_connection *ic, char *info ) 172 170 { 173 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );171 msn_set_display_name( ic, info ); 174 172 } 175 173 … … 287 285 } 288 286 289 static char * msn_set_display_name( set_t *set, char *value )287 static char *set_eval_display_name( set_t *set, char *value ) 290 288 { 291 289 account_t *acc = set->data; 292 290 struct im_connection *ic = acc->ic; 293 struct msn_data *md; 294 char buf[1024], *fn; 295 296 /* Double-check. */ 291 292 /* Allow any name if we're offline. */ 297 293 if( ic == NULL ) 298 return NULL; 299 300 md = ic->proto_data; 294 return value; 301 295 302 296 if( strlen( value ) > 129 ) … … 305 299 return NULL; 306 300 } 307 308 fn = msn_http_encode( value );309 310 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );311 msn_write( ic, buf, strlen( buf ) );312 g_free( fn );313 301 314 302 /* Returning NULL would be better, because the server still has to 315 303 confirm the name change. However, it looks a bit confusing to the 316 304 user. */ 317 return value;305 return msn_set_display_name( ic, value ) ? value : NULL; 318 306 } 319 307 -
protocols/msn/msn.h
r3ab1d31 rb308cf9 31 31 #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r" 32 32 #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" 33 #define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r" 33 34 34 35 #ifdef DEBUG_MSN … … 53 54 "TypingUser: %s\r\n" \ 54 55 "\r\n\r\n" 56 57 #define SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \ 58 "Content-Type: text/x-ping\r\n" \ 59 "\r\n\r\n" 55 60 56 61 #define PROFILE_URL "http://members.msn.com/" … … 84 89 gint inp; 85 90 struct msn_handler_data *handler; 91 gint keepalive; 86 92 87 93 int trId; … … 162 168 char *msn_http_encode( const char *input ); 163 169 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 170 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); 164 171 165 172 /* tables.c */ … … 180 187 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); 181 188 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); 189 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ); 190 void msn_sb_stop_keepalives( struct msn_switchboard *sb ); 182 191 183 192 /* invitation.c */ -
protocols/msn/msn_util.c
r3ab1d31 rb308cf9 38 38 imcb_error( ic, "Short write() to main server" ); 39 39 imc_logout( ic, TRUE ); 40 return ( 0 );41 } 42 43 return ( 1 );40 return 0; 41 } 42 43 return 1; 44 44 } 45 45 … … 377 377 g_string_free( ret, TRUE ); 378 378 } 379 380 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ) 381 { 382 char *fn = msn_http_encode( rawname ); 383 struct msn_data *md = ic->proto_data; 384 char buf[1024]; 385 386 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); 387 g_free( fn ); 388 389 return msn_write( ic, buf, strlen( buf ) ) != 0; 390 } -
protocols/msn/ns.c
r3ab1d31 rb308cf9 35 35 36 36 static void msn_auth_got_passport_token( struct msn_auth_data *mad ); 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); 37 38 38 39 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 75 76 if( msn_write( ic, s, strlen( s ) ) ) 76 77 { 77 ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic );78 ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic ); 78 79 imcb_log( ic, "Connected to server, waiting for reply" ); 79 80 } … … 231 232 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 233 { 233 set_t *s;234 235 234 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 } 235 msn_ns_got_display_name( ic, cmd[4] ); 248 236 else 249 {250 237 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 251 }252 238 253 239 imcb_log( ic, "Authenticated, getting buddy list" ); … … 436 422 else if( strcmp( cmd[0], "FLN" ) == 0 ) 437 423 { 438 if( cmd[1] ) 439 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 424 if( cmd[1] == NULL ) 425 return 1; 426 427 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 428 429 msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE ); 440 430 } 441 431 else if( strcmp( cmd[0], "NLN" ) == 0 ) … … 463 453 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 464 454 st->name, NULL ); 455 456 msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) ); 465 457 } 466 458 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 567 559 return( 0 ); 568 560 } 561 #if 0 562 /* Discard this one completely for now since I don't care about the ack 563 and since MSN servers can apparently screw up the formatting. */ 569 564 else if( strcmp( cmd[0], "REA" ) == 0 ) 570 565 { … … 597 592 } 598 593 } 594 #endif 599 595 else if( strcmp( cmd[0], "IPG" ) == 0 ) 600 596 { … … 746 742 } 747 743 } 744 745 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) 746 { 747 set_t *s; 748 749 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL ) 750 return FALSE; /* Shouldn't happen.. */ 751 752 http_decode( name ); 753 754 if( s->value && strcmp( s->value, name ) == 0 ) 755 { 756 return TRUE; 757 /* The names match, nothing to worry about. */ 758 } 759 else if( s->value != NULL && 760 ( strcmp( name, ic->acc->user ) == 0 || 761 set_getbool( &ic->acc->set, "local_display_name" ) ) ) 762 { 763 /* The server thinks our display name is our e-mail address 764 which is probably wrong, or the user *wants* us to do this: 765 Always use the locally set display_name. */ 766 return msn_set_display_name( ic, s->value ); 767 } 768 else 769 { 770 if( s->value && *s->value ) 771 imcb_log( ic, "BitlBee thinks your display name is `%s' but " 772 "the MSN server says it's `%s'. Using the MSN " 773 "server's name. Set local_display_name to true " 774 "to use the local name.", s->value, name ); 775 776 if( g_utf8_validate( name, -1, NULL ) ) 777 { 778 g_free( s->value ); 779 s->value = g_strdup( name ); 780 } 781 else 782 { 783 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 784 } 785 786 return TRUE; 787 } 788 } -
protocols/msn/sb.c
r3ab1d31 rb308cf9 180 180 i = strlen( buf ); 181 181 } 182 else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 ) 183 { 184 buf = g_strdup( SB_KEEPALIVE_HEADERS ); 185 i = strlen( buf ); 186 } 182 187 else 183 188 { … … 256 261 257 262 msn_msgq_purge( ic, &sb->msgq ); 263 msn_sb_stop_keepalives( sb ); 258 264 259 265 if( sb->key ) g_free( sb->key ); … … 315 321 316 322 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 317 sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );323 sb->inp = b_input_add( sb->fd, B_EV_IO_READ, msn_sb_callback, sb ); 318 324 else 319 325 debug( "Error %d while connecting to switchboard server", 2 ); … … 328 334 struct msn_data *md = ic->proto_data; 329 335 330 if( msn_handler( sb->handler ) == -1 ) 336 if( msn_handler( sb->handler ) != -1 ) 337 return TRUE; 338 339 if( sb->msgq != NULL ) 331 340 { 332 341 time_t now = time( NULL ); 342 char buf[1024]; 333 343 334 344 if( now - md->first_sb_failure > 600 ) … … 347 357 "There might be problems delivering your messages." ); 348 358 349 if( sb->msgq != NULL ) 350 { 351 char buf[1024]; 352 353 if( md->msgq == NULL ) 354 { 355 md->msgq = sb->msgq; 356 } 357 else 358 { 359 GSList *l; 360 361 for( l = md->msgq; l->next; l = l->next ); 362 l->next = sb->msgq; 363 } 364 sb->msgq = NULL; 365 366 debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." ); 367 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 368 if( !msn_write( ic, buf, strlen( buf ) ) ) 369 return FALSE; 370 } 371 372 msn_sb_destroy( sb ); 373 374 return FALSE; 375 } 376 else 377 { 378 return TRUE; 379 } 359 if( md->msgq == NULL ) 360 { 361 md->msgq = sb->msgq; 362 } 363 else 364 { 365 GSList *l; 366 367 for( l = md->msgq; l->next; l = l->next ); 368 l->next = sb->msgq; 369 } 370 sb->msgq = NULL; 371 372 debug( "Moved queued messages back to the main queue, " 373 "creating a new switchboard to retry." ); 374 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 375 if( !msn_write( ic, buf, strlen( buf ) ) ) 376 return FALSE; 377 } 378 379 msn_sb_destroy( sb ); 380 return FALSE; 380 381 } 381 382 … … 477 478 478 479 sb->ready = 1; 480 481 msn_sb_start_keepalives( sb, FALSE ); 479 482 } 480 483 else if( strcmp( cmd[0], "CAL" ) == 0 ) … … 526 529 } 527 530 531 msn_sb_start_keepalives( sb, FALSE ); 532 528 533 return( st ); 529 534 } … … 587 592 if( sb->who ) 588 593 { 594 msn_sb_stop_keepalives( sb ); 595 589 596 /* This is a single-person chat, and the other person is leaving. */ 590 597 g_free( sb->who ); … … 749 756 return( 1 ); 750 757 } 758 759 static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond ) 760 { 761 struct msn_switchboard *sb = data; 762 return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE ); 763 } 764 765 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ) 766 { 767 struct buddy *b; 768 769 if( sb && sb->who && sb->keepalive == 0 && 770 ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present && 771 set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) ) 772 { 773 if( initial ) 774 msn_sb_keepalive( sb, 0, 0 ); 775 776 sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb ); 777 } 778 } 779 780 void msn_sb_stop_keepalives( struct msn_switchboard *sb ) 781 { 782 if( sb && sb->keepalive > 0 ) 783 { 784 b_event_remove( sb->keepalive ); 785 sb->keepalive = 0; 786 } 787 } -
protocols/nogaim.c
r3ab1d31 rb308cf9 39 39 40 40 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); 41 static char *format_timestamp( irc_t *irc, time_t msg_ts ); 41 42 42 43 GSList *connections; … … 116 117 { 117 118 GList *gl; 118 for (gl = protocols; gl; gl = gl->next) 119 120 for( gl = protocols; gl; gl = gl->next ) 119 121 { 120 122 struct prpl *proto = gl->data; 121 if(!g_strcasecmp(proto->name, name)) 123 124 if( g_strcasecmp( proto->name, name ) == 0 ) 122 125 return proto; 123 126 } 127 124 128 return NULL; 125 129 } … … 132 136 extern void byahoo_initmodule(); 133 137 extern void jabber_initmodule(); 138 extern void twitter_initmodule(); 139 extern void purple_initmodule(); 134 140 135 141 #ifdef WITH_MSN … … 147 153 #ifdef WITH_JABBER 148 154 jabber_initmodule(); 155 #endif 156 157 #ifdef WITH_TWITTER 158 twitter_initmodule(); 159 #endif 160 161 #ifdef WITH_PURPLE 162 purple_initmodule(); 149 163 #endif 150 164 … … 651 665 u->away = u->status_msg = NULL; 652 666 653 if( ( flags & OPT_LOGGED_IN ) && !u->online ) 654 { 667 if( set_getbool( &ic->irc->set, "show_offline" ) && !u->online ) 668 { 669 /* always set users as online */ 655 670 irc_spawn( ic->irc, u ); 656 671 u->online = 1; 672 if( !( flags & OPT_LOGGED_IN ) ) 673 { 674 /* set away message if user isn't really online */ 675 u->away = g_strdup( "User is offline" ); 676 } 677 } 678 else if( ( flags & OPT_LOGGED_IN ) && !u->online ) 679 { 680 irc_spawn( ic->irc, u ); 681 u->online = 1; 657 682 } 658 683 else if( !( flags & OPT_LOGGED_IN ) && u->online ) … … 660 685 struct groupchat *c; 661 686 662 irc_kill( ic->irc, u ); 663 u->online = 0; 664 665 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */ 666 for( c = ic->groupchats; c; c = c->next ) 667 remove_chat_buddy_silent( c, handle ); 668 } 669 687 if( set_getbool( &ic->irc->set, "show_offline" ) ) 688 { 689 /* keep offline users in channel and set away message to "offline" */ 690 u->away = g_strdup( "User is offline" ); 691 692 /* Keep showing him/her in the control channel but not in groupchats. */ 693 for( c = ic->groupchats; c; c = c->next ) 694 { 695 if( remove_chat_buddy_silent( c, handle ) && c->joined ) 696 irc_part( c->ic->irc, u, c->channel ); 697 } 698 } 699 else 700 { 701 /* kill offline users */ 702 irc_kill( ic->irc, u ); 703 u->online = 0; 704 705 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */ 706 for( c = ic->groupchats; c; c = c->next ) 707 remove_chat_buddy_silent( c, handle ); 708 } 709 } 710 670 711 if( flags & OPT_AWAY ) 671 712 { … … 692 733 } 693 734 694 /* LISPy... */ 695 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 696 ( u->online ) && /* Don't touch offline people */ 697 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 698 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 735 /* early if-clause for show_offline even if there is some redundant code here because this isn't LISP but C ;) */ 736 if( set_getbool( &ic->irc->set, "show_offline" ) && set_getbool( &ic->irc->set, "away_devoice" ) ) 699 737 { 700 738 char *from; … … 709 747 ic->irc->myhost ); 710 748 } 711 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 712 u->away?'-':'+', u->nick ); 713 g_free( from ); 749 750 /* if we use show_offline, we op online users, voice away users, and devoice/deop offline users */ 751 if( flags & OPT_LOGGED_IN ) 752 { 753 /* user is "online" (either really online or away) */ 754 irc_write( ic->irc, ":%s MODE %s %cv%co %s %s", from, ic->irc->channel, 755 u->away?'+':'-', u->away?'-':'+', u->nick, u->nick ); 756 } 757 else 758 { 759 /* user is offline */ 760 irc_write( ic->irc, ":%s MODE %s -vo %s %s", from, ic->irc->channel, u->nick, u->nick ); 761 } 762 } 763 else 764 { 765 /* LISPy... */ 766 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 767 ( u->online ) && /* Don't touch offline people */ 768 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 769 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 770 { 771 char *from; 772 773 if( set_getbool( &ic->irc->set, "simulate_netsplit" ) ) 774 { 775 from = g_strdup( ic->irc->myhost ); 776 } 777 else 778 { 779 from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick, 780 ic->irc->myhost ); 781 } 782 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 783 u->away?'-':'+', u->nick ); 784 g_free( from ); 785 } 714 786 } 715 787 } … … 718 790 { 719 791 irc_t *irc = ic->irc; 720 char *wrapped ;792 char *wrapped, *ts = NULL; 721 793 user_t *u; 722 794 … … 760 832 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 761 833 strip_html( msg ); 762 834 835 if( set_getbool( &ic->irc->set, "display_timestamps" ) && 836 ( ts = format_timestamp( irc, sent_at ) ) ) 837 { 838 char *new = g_strconcat( ts, msg, NULL ); 839 g_free( ts ); 840 ts = msg = new; 841 } 842 763 843 wrapped = word_wrap( msg, 425 ); 764 844 irc_msgfrom( irc, u->nick, wrapped ); 765 845 g_free( wrapped ); 846 g_free( ts ); 766 847 } 767 848 … … 805 886 806 887 return c; 888 } 889 890 void imcb_chat_name_hint( struct groupchat *c, const char *name ) 891 { 892 if( !c->joined ) 893 { 894 struct im_connection *ic = c->ic; 895 char stripped[MAX_NICK_LENGTH+1], *full_name; 896 897 strncpy( stripped, name, MAX_NICK_LENGTH ); 898 stripped[MAX_NICK_LENGTH] = '\0'; 899 nick_strip( stripped ); 900 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 901 nick_lc( stripped ); 902 903 full_name = g_strdup_printf( "&%s", stripped ); 904 905 if( stripped[0] && 906 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && 907 irc_chat_by_channel( ic->irc, full_name ) == NULL ) 908 { 909 g_free( c->channel ); 910 c->channel = full_name; 911 } 912 else 913 { 914 g_free( full_name ); 915 } 916 } 807 917 } 808 918 … … 867 977 if( c && u ) 868 978 { 869 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 979 char *ts = NULL; 980 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 981 ts = format_timestamp( ic->irc, sent_at ); 982 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 983 g_free( ts ); 870 984 } 871 985 else … … 1061 1175 } 1062 1176 1063 1064 1177 char *set_eval_timezone( set_t *set, char *value ) 1178 { 1179 char *s; 1180 1181 if( strcmp( value, "local" ) == 0 || 1182 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1183 return value; 1184 1185 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1186 possibly followed by a colon and more numbers. Don't bother bound- 1187 checking them since users are free to shoot themselves in the foot. */ 1188 s = value; 1189 if( *s == '+' || *s == '-' ) 1190 s ++; 1191 1192 /* \d+ */ 1193 if( !isdigit( *s ) ) 1194 return SET_INVALID; 1195 while( *s && isdigit( *s ) ) s ++; 1196 1197 /* EOS? */ 1198 if( *s == '\0' ) 1199 return value; 1200 1201 /* Otherwise, colon */ 1202 if( *s != ':' ) 1203 return SET_INVALID; 1204 s ++; 1205 1206 /* \d+ */ 1207 if( !isdigit( *s ) ) 1208 return SET_INVALID; 1209 while( *s && isdigit( *s ) ) s ++; 1210 1211 /* EOS */ 1212 return *s == '\0' ? value : SET_INVALID; 1213 } 1214 1215 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1216 { 1217 time_t now_ts = time( NULL ); 1218 struct tm now, msg; 1219 char *set; 1220 1221 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1222 it doesn't seem to add to much useful info and/or might be noise. */ 1223 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1224 return NULL; 1225 1226 set = set_getstr( &irc->set, "timezone" ); 1227 if( strcmp( set, "local" ) == 0 ) 1228 { 1229 localtime_r( &now_ts, &now ); 1230 localtime_r( &msg_ts, &msg ); 1231 } 1232 else 1233 { 1234 int hr, min = 0, sign = 60; 1235 1236 if( set[0] == '-' ) 1237 { 1238 sign *= -1; 1239 set ++; 1240 } 1241 else if( set[0] == '+' ) 1242 { 1243 set ++; 1244 } 1245 1246 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1247 { 1248 msg_ts += sign * ( hr * 60 + min ); 1249 now_ts += sign * ( hr * 60 + min ); 1250 } 1251 1252 gmtime_r( &now_ts, &now ); 1253 gmtime_r( &msg_ts, &msg ); 1254 } 1255 1256 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1257 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1258 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1259 else 1260 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1261 "%02d:%02d:%02d\x02]\x02 ", 1262 msg.tm_year + 1900, msg.tm_mon + 1, msg.tm_mday, 1263 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1264 } 1065 1265 1066 1266 /* The plan is to not allow straight calls to prpl functions anymore, but do … … 1105 1305 { 1106 1306 char *away, *msg = NULL; 1307 1308 if( ic->acc->prpl->away_states == NULL || 1309 ic->acc->prpl->set_away == NULL ) 1310 return 0; 1107 1311 1108 1312 away = set_getstr( &ic->acc->set, "away" ) ? -
protocols/nogaim.h
r3ab1d31 rb308cf9 134 134 * - The user sees this name ie. when imcb_log() is used. */ 135 135 const char *name; 136 void *data; 136 137 137 138 /* Added this one to be able to add per-account settings, don't think … … 307 308 * user, too. */ 308 309 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 310 G_MODULE_EXPORT void imcb_chat_name_hint( struct groupchat *c, const char *name ); 309 311 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 310 312 /* To remove a handle from a group chat. Reason can be NULL. */ … … 329 331 330 332 /* Misc. stuff */ 333 char *set_eval_timezone( set_t *set, char *value ); 331 334 char *set_eval_away_devoice( set_t *set, char *value ); 332 335 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); -
protocols/oscar/Makefile
r3ab1d31 rb308cf9 8 8 9 9 -include ../../Makefile.settings 10 ifdef SRCDIR 11 SRCDIR := $(SRCDIR)protocols/oscar/ 12 CFLAGS += -I$(SRCDIR) 13 endif 10 14 11 15 # [SH] Program variables … … 33 37 $(objects): ../../Makefile.settings Makefile 34 38 35 $(objects): %.o: %.c39 $(objects): %.o: $(SRCDIR)%.c 36 40 @echo '*' Compiling $< 37 41 @$(CC) -c $(CFLAGS) $< -o $@ -
protocols/oscar/oscar.c
r3ab1d31 rb308cf9 205 205 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); 206 206 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); 207 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...);208 207 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); 209 208 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); … … 291 290 odata = (struct oscar_data *)ic->proto_data; 292 291 293 if (condition & GAIM_INPUT_READ) {292 if (condition & B_EV_IO_READ) { 294 293 if (aim_get_command(odata->sess, conn) >= 0) { 295 294 aim_rxdispatch(odata->sess); … … 363 362 364 363 aim_conn_completeconnect(sess, conn); 365 ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,364 ic->inpa = b_input_add(conn->fd, B_EV_IO_READ, 366 365 oscar_callback, conn); 367 366 … … 493 492 494 493 aim_conn_completeconnect(sess, bosconn); 495 ic->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ,494 ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ, 496 495 oscar_callback, bosconn); 497 496 imcb_log(ic, _("Connection established, cookie sent")); … … 570 569 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0); 571 570 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0); 572 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0);573 571 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0); 574 572 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); … … 604 602 } 605 603 606 struct pieceofcrap {607 struct im_connection *ic;608 unsigned long offset;609 unsigned long len;610 char *modname;611 int fd;612 aim_conn_t *conn;613 unsigned int inpa;614 };615 616 static gboolean damn_you(gpointer data, gint source, b_input_condition c)617 {618 struct pieceofcrap *pos = data;619 struct oscar_data *od = pos->ic->proto_data;620 char in = '\0';621 int x = 0;622 unsigned char m[17];623 624 while (read(pos->fd, &in, 1) == 1) {625 if (in == '\n')626 x++;627 else if (in != '\r')628 x = 0;629 if (x == 2)630 break;631 in = '\0';632 }633 if (in != '\n') {634 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."635 " You may be disconnected shortly.");636 b_event_remove(pos->inpa);637 closesocket(pos->fd);638 g_free(pos);639 return FALSE;640 }641 /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */642 read(pos->fd, m, 16);643 m[16] = '\0';644 b_event_remove(pos->inpa);645 closesocket(pos->fd);646 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);647 g_free(pos);648 649 return FALSE;650 }651 652 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {653 struct pieceofcrap *pos = data;654 char buf[BUF_LONG];655 656 if (source < 0) {657 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."658 " You may be disconnected shortly.");659 if (pos->modname)660 g_free(pos->modname);661 g_free(pos);662 return FALSE;663 }664 665 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA666 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",667 pos->offset, pos->len, pos->modname ? pos->modname : "");668 write(pos->fd, buf, strlen(buf));669 if (pos->modname)670 g_free(pos->modname);671 pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);672 return FALSE;673 }674 675 604 /* size of icbmui.ocm, the largest module in AIM 3.5 */ 676 605 #define AIM_MAX_FILE_SIZE 98304 677 678 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) {679 va_list ap;680 struct pieceofcrap *pos;681 guint32 offset, len;682 char *modname;683 int fd;684 685 va_start(ap, fr);686 offset = (guint32)va_arg(ap, unsigned long);687 len = (guint32)va_arg(ap, unsigned long);688 modname = va_arg(ap, char *);689 va_end(ap);690 691 if (len == 0) {692 aim_sendmemblock(sess, fr->conn, offset, len, NULL,693 AIM_SENDMEMBLOCK_FLAG_ISREQUEST);694 return 1;695 }696 /* uncomment this when you're convinced it's right. remember, it's been wrong before.697 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {698 char *buf;699 int i = 8;700 if (modname)701 i += strlen(modname);702 buf = g_malloc(i);703 i = 0;704 if (modname) {705 memcpy(buf, modname, strlen(modname));706 i += strlen(modname);707 }708 buf[i++] = offset & 0xff;709 buf[i++] = (offset >> 8) & 0xff;710 buf[i++] = (offset >> 16) & 0xff;711 buf[i++] = (offset >> 24) & 0xff;712 buf[i++] = len & 0xff;713 buf[i++] = (len >> 8) & 0xff;714 buf[i++] = (len >> 16) & 0xff;715 buf[i++] = (len >> 24) & 0xff;716 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);717 g_free(buf);718 return 1;719 }720 */721 722 pos = g_new0(struct pieceofcrap, 1);723 pos->ic = sess->aux_data;724 pos->conn = fr->conn;725 726 pos->offset = offset;727 pos->len = len;728 pos->modname = modname ? g_strdup(modname) : NULL;729 730 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos);731 if (fd < 0) {732 if (pos->modname)733 g_free(pos->modname);734 g_free(pos);735 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM."736 " You may be disconnected shortly.");737 }738 pos->fd = fd;739 740 return 1;741 }742 606 743 607 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { … … 838 702 839 703 aim_conn_completeconnect(sess, tstconn); 840 odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ,704 odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ, 841 705 oscar_callback, tstconn); 842 706 … … 866 730 867 731 aim_conn_completeconnect(sess, tstconn); 868 odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ,732 odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ, 869 733 oscar_callback, tstconn); 870 734 … … 902 766 aim_conn_completeconnect(sess, ccon->conn); 903 767 ccon->inpa = b_input_add(tstconn->fd, 904 GAIM_INPUT_READ,768 B_EV_IO_READ, 905 769 oscar_callback, tstconn); 906 770 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); … … 2651 2515 char * chatname; 2652 2516 2653 chatname = g_strdup_printf("%s%d", ic->acc->user, chat_id++); 2517 chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "", 2518 ic->acc->user, chat_id++); 2654 2519 2655 2520 ret = oscar_chat_join(ic, chatname, NULL, NULL); -
protocols/yahoo/Makefile
r3ab1d31 rb308cf9 8 8 9 9 -include ../../Makefile.settings 10 ifdef SRCDIR 11 SRCDIR := $(SRCDIR)protocols/yahoo/ 12 endif 10 13 11 14 # [SH] Program variables … … 33 36 $(objects): ../../Makefile.settings Makefile 34 37 35 $(objects): %.o: %.c38 $(objects): %.o: $(SRCDIR)%.c 36 39 @echo '*' Compiling $< 37 40 @$(CC) -c $(CFLAGS) $< -o $@ -
protocols/yahoo/yahoo.c
r3ab1d31 rb308cf9 138 138 struct im_connection *ic = imcb_new( acc ); 139 139 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); 140 char *s; 140 141 141 142 yd->logged_in = FALSE; 142 143 yd->current_status = YAHOO_STATUS_AVAILABLE; 144 145 if( ( s = strchr( acc->user, '@' ) ) && g_strcasecmp( s, "@yahoo.com" ) == 0 ) 146 imcb_error( ic, "Your Yahoo! username should just be a username. " 147 "Do not include any @domain part." ); 143 148 144 149 imcb_log( ic, "Connecting" ); … … 681 686 682 687 inp->d = d; 683 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );688 d->tag = inp->h = b_input_add( fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); 684 689 } 685 690 else if( cond == YAHOO_INPUT_WRITE ) … … 692 697 693 698 inp->d = d; 694 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );699 d->tag = inp->h = b_input_add( fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d ); 695 700 } 696 701 else … … 828 833 YList *m; 829 834 835 if( g_strcasecmp( who, ic->acc->user ) == 0 ) 836 /* WTF, Yahoo! seems to echo these now? */ 837 return; 838 830 839 inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); 831 840 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
Note: See TracChangeset
for help on using the changeset viewer.