Changes in protocols/nogaim.c [cca0692:573dab0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
rcca0692 r573dab0 38 38 #include "chat.h" 39 39 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 );42 43 40 GSList *connections; 44 41 … … 92 89 } 93 90 #endif 94 95 /* nogaim.c */96 91 97 92 GList *protocols = NULL; … … 126 121 } 127 122 128 /* nogaim.c */129 123 void nogaim_init() 130 124 { … … 133 127 extern void byahoo_initmodule(); 134 128 extern void jabber_initmodule(); 135 extern void twitter_initmodule();136 129 137 130 #ifdef WITH_MSN … … 151 144 #endif 152 145 153 #ifdef WITH_TWITTER154 twitter_initmodule();155 #endif156 157 146 #ifdef WITH_PLUGINS 158 147 load_plugins(); … … 162 151 GSList *get_connections() { return connections; } 163 152 164 /* multi.c */165 166 153 struct im_connection *imcb_new( account_t *acc ) 167 154 { … … 170 157 ic = g_new0( struct im_connection, 1 ); 171 158 172 ic-> irc = acc->irc;159 ic->bee = acc->bee; 173 160 ic->acc = acc; 174 161 acc->ic = ic; … … 184 171 185 172 /* Destroy the pointer to this connection from the account list */ 186 for( a = ic-> irc->accounts; a; a = a->next )173 for( a = ic->bee->accounts; a; a = a->next ) 187 174 if( a->ic == ic ) 188 175 { … … 205 192 va_end( params ); 206 193 207 if( ( g_strcasecmp( set_getstr( &ic-> irc->set, "strip_html" ), "always" ) == 0 ) ||208 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic-> irc->set, "strip_html" ) ) )194 if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) || 195 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) ) 209 196 strip_html( text ); 210 197 211 198 /* Try to find a different connection on the same protocol. */ 212 for( a = ic-> irc->accounts; a; a = a->next )199 for( a = ic->bee->accounts; a; a = a->next ) 213 200 if( a->prpl == ic->acc->prpl && a->ic != ic ) 214 201 break; … … 216 203 /* If we found one, include the screenname in the message. */ 217 204 if( a ) 218 irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text ); 205 /* FIXME(wilmer): ui_log callback or so */ 206 irc_usermsg( ic->bee->ui_data, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text ); 219 207 else 220 irc_usermsg( ic-> irc, "%s - %s", ic->acc->prpl->name, text );208 irc_usermsg( ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text ); 221 209 222 210 g_free( text ); … … 269 257 void imcb_connected( struct im_connection *ic ) 270 258 { 271 irc_t *irc = ic->irc;272 struct chat *c;273 user_t *u;274 275 259 /* MSN servers sometimes redirect you to a different server and do 276 260 the whole login sequence again, so these "late" calls to this … … 279 263 return; 280 264 281 u = user_find( ic->irc, ic->irc->nick );282 283 265 imcb_log( ic, "Logged in" ); 284 266 … … 293 275 ic->acc->auto_reconnect_delay = 0; 294 276 277 /* 295 278 for( c = irc->chatrooms; c; c = c->next ) 296 279 { … … 301 284 chat_join( irc, c, NULL ); 302 285 } 286 */ 303 287 } 304 288 … … 308 292 309 293 a->reconnect = 0; 310 account_on( a-> irc, a );294 account_on( a->bee, a ); 311 295 312 296 return( FALSE ); /* Only have to run the timeout once */ … … 321 305 void imc_logout( struct im_connection *ic, int allow_reconnect ) 322 306 { 323 irc_t *irc = ic->irc; 324 user_t *t, *u; 307 bee_t *bee = ic->bee; 325 308 account_t *a; 309 GSList *l; 326 310 int delay; 327 311 … … 343 327 ic->away = NULL; 344 328 345 u = irc->users; 346 while( u ) 347 { 348 if( u->ic == ic ) 349 { 350 t = u->next; 351 user_del( irc, u->nick ); 352 u = t; 353 } 354 else 355 u = u->next; 356 } 357 358 query_del_by_conn( ic->irc, ic ); 359 360 for( a = irc->accounts; a; a = a->next ) 329 for( l = bee->users; l; ) 330 { 331 bee_user_t *bu = l->data; 332 GSList *next = l->next; 333 334 if( bu->ic == ic ) 335 bee_user_free( bee, bu ); 336 337 l = next; 338 } 339 340 //query_del_by_conn( ic->irc, ic ); 341 342 for( a = bee->accounts; a; a = a->next ) 361 343 if( a->ic == ic ) 362 344 break; … … 366 348 /* Uhm... This is very sick. */ 367 349 } 368 else if( allow_reconnect && set_getbool( & irc->set, "auto_reconnect" ) &&350 else if( allow_reconnect && set_getbool( &bee->set, "auto_reconnect" ) && 369 351 set_getbool( &a->set, "auto_reconnect" ) && 370 352 ( delay = account_reconnect_delay( a ) ) > 0 ) … … 377 359 } 378 360 379 380 /* dialogs.c */381 382 361 void imcb_ask( struct im_connection *ic, char *msg, void *data, 383 362 query_callback doit, query_callback dont ) 384 363 { 385 query_add( ic->irc, ic, msg, doit, dont, data ); 386 } 387 388 389 /* list.c */ 364 query_add( (irc_t *) ic->bee->ui_data, ic, msg, doit, dont, data ); 365 } 390 366 391 367 void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group ) 392 368 { 393 user_t *u; 394 char nick[MAX_NICK_LENGTH+1], *s; 395 irc_t *irc = ic->irc; 396 397 if( user_findhandle( ic, handle ) ) 398 { 399 if( set_getbool( &irc->set, "debug" ) ) 369 bee_user_t *bu; 370 bee_t *bee = ic->bee; 371 372 if( bee_user_by_handle( bee, ic, handle ) ) 373 { 374 if( set_getbool( &bee->set, "debug" ) ) 400 375 imcb_log( ic, "User already exists, ignoring add request: %s", handle ); 401 376 … … 408 383 } 409 384 410 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 411 strcpy( nick, nick_get( ic->acc, handle ) ); 412 413 u = user_add( ic->irc, nick ); 414 415 // if( !realname || !*realname ) realname = nick; 416 // u->realname = g_strdup( realname ); 417 418 if( ( s = strchr( handle, '@' ) ) ) 419 { 420 u->host = g_strdup( s + 1 ); 421 u->user = g_strndup( handle, s - handle ); 422 } 423 else if( ic->acc->server ) 424 { 425 u->host = g_strdup( ic->acc->server ); 426 u->user = g_strdup( handle ); 427 428 /* s/ /_/ ... important for AOL screennames */ 429 for( s = u->user; *s; s ++ ) 430 if( *s == ' ' ) 431 *s = '_'; 432 } 433 else 434 { 435 u->host = g_strdup( ic->acc->prpl->name ); 436 u->user = g_strdup( handle ); 437 } 438 439 u->ic = ic; 440 u->handle = g_strdup( handle ); 441 if( group ) u->group = g_strdup( group ); 442 u->send_handler = buddy_send_handler; 443 u->last_typing_notice = 0; 444 } 445 446 struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) 447 { 448 static struct buddy b[1]; 449 user_t *u; 450 451 u = user_findhandle( ic, handle ); 452 453 if( !u ) 454 return( NULL ); 455 456 memset( b, 0, sizeof( b ) ); 457 strncpy( b->name, handle, 80 ); 458 strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); 459 b->present = u->online; 460 b->ic = u->ic; 461 462 return( b ); 463 } 464 465 void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ) 466 { 467 user_t *u = user_findhandle( ic, handle ); 468 char *set; 469 470 if( !u || !realname ) return; 471 472 if( g_strcasecmp( u->realname, realname ) != 0 ) 473 { 474 if( u->realname != u->nick ) g_free( u->realname ); 475 476 u->realname = g_strdup( realname ); 477 478 if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) 479 imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 480 } 481 482 set = set_getstr( &ic->acc->set, "nick_source" ); 483 if( strcmp( set, "handle" ) != 0 ) 484 { 485 char *name = g_strdup( realname ); 486 487 if( strcmp( set, "first_name" ) == 0 ) 488 { 489 int i; 490 for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} 491 name[i] = '\0'; 492 } 493 494 imcb_buddy_nick_hint( ic, handle, name ); 495 496 g_free( name ); 385 bu = bee_user_new( bee, ic, handle ); 386 bu->group = g_strdup( group ); 387 } 388 389 void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *fullname ) 390 { 391 bee_t *bee = ic->bee; 392 bee_user_t *bu = bee_user_by_handle( bee, ic, handle ); 393 394 if( !bu || !fullname ) return; 395 396 if( !bu->fullname || strcmp( bu->fullname, fullname ) != 0 ) 397 { 398 g_free( bu->fullname ); 399 bu->fullname = g_strdup( fullname ); 400 401 if( bee->ui->user_fullname ) 402 bee->ui->user_fullname( bee, bu ); 497 403 } 498 404 } … … 500 406 void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group ) 501 407 { 502 user_t *u; 503 504 if( ( u = user_findhandle( ic, handle ) ) ) 505 user_del( ic->irc, u->nick ); 408 bee_user_free( ic->bee, bee_user_by_handle( ic->bee, ic, handle ) ); 506 409 } 507 410 … … 510 413 void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick ) 511 414 { 415 #if 0 512 416 user_t *u = user_findhandle( ic, handle ); 513 417 char newnick[MAX_NICK_LENGTH+1], *orig_nick; … … 524 428 /* Some processing to make sure this string is a valid IRC nickname. */ 525 429 nick_strip( newnick ); 526 if( set_getbool( &ic-> irc->set, "lcnicks" ) )430 if( set_getbool( &ic->bee->set, "lcnicks" ) ) 527 431 nick_lc( newnick ); 528 432 … … 541 445 } 542 446 } 447 #endif 543 448 } 544 449 … … 585 490 data->ic = ic; 586 491 data->handle = g_strdup( handle ); 587 query_add( ic->irc, ic, s, imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data ); 492 query_add( (irc_t *) ic->bee->ui_data, ic, s, 493 imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data ); 588 494 } 589 495 … … 610 516 611 517 /* TODO: Make a setting for this! */ 612 if( user_findhandle(ic, handle ) != NULL )518 if( bee_user_by_handle( ic->bee, ic, handle ) != NULL ) 613 519 return; 614 520 … … 617 523 data->ic = ic; 618 524 data->handle = g_strdup( handle ); 619 query_add( ic->irc, ic, s, imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data ); 620 } 621 622 623 /* server.c */ 624 625 void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ) 626 { 627 user_t *u; 628 int oa, oo; 629 630 u = user_findhandle( ic, (char*) handle ); 631 632 if( !u ) 633 { 634 if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) 635 { 636 imcb_add_buddy( ic, (char*) handle, NULL ); 637 u = user_findhandle( ic, (char*) handle ); 638 } 639 else 640 { 641 if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) 642 { 643 imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle ); 644 imcb_log( ic, "flags = %d, state = %s, message = %s", flags, 645 state ? state : "NULL", message ? message : "NULL" ); 646 } 647 648 return; 649 } 650 } 651 652 oa = u->away != NULL; 653 oo = u->online; 654 655 g_free( u->away ); 656 g_free( u->status_msg ); 657 u->away = u->status_msg = NULL; 658 659 if( ( flags & OPT_LOGGED_IN ) && !u->online ) 660 { 661 irc_spawn( ic->irc, u ); 662 u->online = 1; 663 } 664 else if( !( flags & OPT_LOGGED_IN ) && u->online ) 665 { 666 struct groupchat *c; 667 668 irc_kill( ic->irc, u ); 669 u->online = 0; 670 671 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */ 672 for( c = ic->groupchats; c; c = c->next ) 673 remove_chat_buddy_silent( c, handle ); 674 } 675 676 if( flags & OPT_AWAY ) 677 { 678 if( state && message ) 679 { 680 u->away = g_strdup_printf( "%s (%s)", state, message ); 681 } 682 else if( state ) 683 { 684 u->away = g_strdup( state ); 685 } 686 else if( message ) 687 { 688 u->away = g_strdup( message ); 689 } 690 else 691 { 692 u->away = g_strdup( "Away" ); 693 } 694 } 695 else 696 { 697 u->status_msg = g_strdup( message ); 698 } 699 700 /* LISPy... */ 701 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 702 ( u->online ) && /* Don't touch offline people */ 703 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 704 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 705 { 706 char *from; 707 708 if( set_getbool( &ic->irc->set, "simulate_netsplit" ) ) 709 { 710 from = g_strdup( ic->irc->myhost ); 711 } 712 else 713 { 714 from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick, 715 ic->irc->myhost ); 716 } 717 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 718 u->away?'-':'+', u->nick ); 719 g_free( from ); 720 } 721 } 722 723 void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at ) 724 { 725 irc_t *irc = ic->irc; 726 char *wrapped, *ts = NULL; 727 user_t *u; 728 729 u = user_findhandle( ic, handle ); 730 731 if( !u ) 732 { 733 char *h = set_getstr( &irc->set, "handle_unknown" ); 734 735 if( g_strcasecmp( h, "ignore" ) == 0 ) 736 { 737 if( set_getbool( &irc->set, "debug" ) ) 738 imcb_log( ic, "Ignoring message from unknown handle %s", handle ); 739 740 return; 741 } 742 else if( g_strncasecmp( h, "add", 3 ) == 0 ) 743 { 744 int private = set_getbool( &irc->set, "private" ); 745 746 if( h[3] ) 747 { 748 if( g_strcasecmp( h + 3, "_private" ) == 0 ) 749 private = 1; 750 else if( g_strcasecmp( h + 3, "_channel" ) == 0 ) 751 private = 0; 752 } 753 754 imcb_add_buddy( ic, handle, NULL ); 755 u = user_findhandle( ic, handle ); 756 u->is_private = private; 757 } 758 else 759 { 760 imcb_log( ic, "Message from unknown handle %s:", handle ); 761 u = user_find( irc, irc->mynick ); 762 } 763 } 764 765 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 766 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 767 strip_html( msg ); 768 769 if( set_getbool( &ic->irc->set, "display_timestamps" ) && 770 ( ts = format_timestamp( irc, sent_at ) ) ) 771 { 772 char *new = g_strconcat( ts, msg, NULL ); 773 g_free( ts ); 774 ts = msg = new; 775 } 776 777 wrapped = word_wrap( msg, 425 ); 778 irc_msgfrom( irc, u->nick, wrapped ); 779 g_free( wrapped ); 780 g_free( ts ); 781 } 782 783 void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) 784 { 785 user_t *u; 786 787 if( !set_getbool( &ic->irc->set, "typing_notice" ) ) 788 return; 789 790 if( ( u = user_findhandle( ic, handle ) ) ) 791 { 792 char buf[256]; 793 794 g_snprintf( buf, 256, "\1TYPING %d\1", ( flags >> 8 ) & 3 ); 795 irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); 796 } 525 query_add( (irc_t *) ic->bee->ui_data, ic, s, 526 imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data ); 527 } 528 529 struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle ) 530 { 531 return bee_user_by_handle( ic->bee, ic, handle ); 797 532 } 798 533 799 534 struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ) 800 535 { 536 #if 0 801 537 struct groupchat *c; 802 538 … … 816 552 c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); 817 553 818 if( set_getbool( &ic-> irc->set, "debug" ) )554 if( set_getbool( &ic->bee->set, "debug" ) ) 819 555 imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); 820 556 821 557 return c; 822 } 823 824 void imcb_chat_name_hint( struct groupchat *c, const char *name ) 825 { 826 if( !c->joined ) 827 { 828 struct im_connection *ic = c->ic; 829 char stripped[MAX_NICK_LENGTH+1], *full_name; 830 831 strncpy( stripped, name, MAX_NICK_LENGTH ); 832 stripped[MAX_NICK_LENGTH] = '\0'; 833 nick_strip( stripped ); 834 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 835 nick_lc( stripped ); 836 837 full_name = g_strdup_printf( "&%s", stripped ); 838 839 if( stripped[0] && 840 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && 841 irc_chat_by_channel( ic->irc, full_name ) == NULL ) 842 { 843 g_free( c->channel ); 844 c->channel = full_name; 845 } 846 else 847 { 848 g_free( full_name ); 849 } 850 } 558 #endif 559 return NULL; 851 560 } 852 561 853 562 void imcb_chat_free( struct groupchat *c ) 854 563 { 564 #if 0 855 565 struct im_connection *ic = c->ic; 856 566 struct groupchat *l; 857 567 GList *ir; 858 568 859 if( set_getbool( &ic-> irc->set, "debug" ) )569 if( set_getbool( &ic->bee->set, "debug" ) ) 860 570 imcb_log( ic, "You were removed from conversation %p", c ); 861 571 … … 890 600 g_free( c ); 891 601 } 602 #endif 892 603 } 893 604 894 605 void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ) 895 606 { 607 #if 0 896 608 struct im_connection *ic = c->ic; 897 609 char *wrapped; … … 904 616 u = user_findhandle( ic, who ); 905 617 906 if( ( g_strcasecmp( set_getstr( &ic-> irc->set, "strip_html" ), "always" ) == 0 ) ||907 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic-> irc->set, "strip_html" ) ) )618 if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) || 619 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) ) 908 620 strip_html( msg ); 909 621 … … 911 623 if( c && u ) 912 624 { 913 char *ts = NULL; 914 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 915 ts = format_timestamp( ic->irc, sent_at ); 916 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 917 g_free( ts ); 625 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 918 626 } 919 627 else … … 922 630 } 923 631 g_free( wrapped ); 632 #endif 924 633 } 925 634 926 635 void imcb_chat_log( struct groupchat *c, char *format, ... ) 927 636 { 637 #if 0 928 638 irc_t *irc = c->ic->irc; 929 639 va_list params; … … 940 650 941 651 g_free( text ); 652 #endif 942 653 } 943 654 944 655 void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ) 945 656 { 657 #if 0 946 658 struct im_connection *ic = c->ic; 947 659 user_t *u = NULL; … … 954 666 u = user_findhandle( ic, who ); 955 667 956 if( ( g_strcasecmp( set_getstr( &ic-> irc->set, "strip_html" ), "always" ) == 0 ) ||957 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic-> irc->set, "strip_html" ) ) )668 if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) || 669 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) ) 958 670 strip_html( topic ); 959 671 … … 963 675 if( c->joined && u ) 964 676 irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); 965 } 966 967 968 /* buddy_chat.c */ 677 #endif 678 } 969 679 970 680 void imcb_chat_add_buddy( struct groupchat *b, const char *handle ) 971 681 { 682 #if 0 972 683 user_t *u = user_findhandle( b->ic, handle ); 973 684 int me = 0; 974 685 975 if( set_getbool( &b->ic-> irc->set, "debug" ) )686 if( set_getbool( &b->ic->bee->set, "debug" ) ) 976 687 imcb_log( b->ic, "User %s added to conversation %p", handle, b ); 977 688 … … 1000 711 b->in_room = g_list_append( b->in_room, g_strdup( handle ) ); 1001 712 } 713 #endif 1002 714 } 1003 715 … … 1005 717 void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ) 1006 718 { 719 #if 0 1007 720 user_t *u; 1008 721 int me = 0; 1009 722 1010 if( set_getbool( &b->ic-> irc->set, "debug" ) )723 if( set_getbool( &b->ic->bee->set, "debug" ) ) 1011 724 imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" ); 1012 725 … … 1028 741 if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) ) 1029 742 irc_part( b->ic->irc, u, b->channel ); 1030 } 1031 743 #endif 744 } 745 746 #if 0 1032 747 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ) 1033 748 { … … 1048 763 } 1049 764 1050 return( 0 ); 1051 } 765 return 0; 766 } 767 #endif 1052 768 1053 769 1054 770 /* Misc. BitlBee stuff which shouldn't really be here */ 1055 771 #if 0 1056 772 char *set_eval_away_devoice( set_t *set, char *value ) 1057 773 { … … 1066 782 /* Horror.... */ 1067 783 1068 if( st != set_getbool( &irc-> set, "away_devoice" ) )784 if( st != set_getbool( &irc->b->set, "away_devoice" ) ) 1069 785 { 1070 786 char list[80] = ""; … … 1108 824 return value; 1109 825 } 1110 1111 char *set_eval_timezone( set_t *set, char *value ) 1112 { 1113 char *s; 1114 1115 if( strcmp( value, "local" ) == 0 || 1116 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1117 return value; 1118 1119 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1120 possibly followed by a colon and more numbers. Don't bother bound- 1121 checking them since users are free to shoot themselves in the foot. */ 1122 s = value; 1123 if( *s == '+' || *s == '-' ) 1124 s ++; 1125 1126 /* \d+ */ 1127 if( !isdigit( *s ) ) 1128 return SET_INVALID; 1129 while( *s && isdigit( *s ) ) s ++; 1130 1131 /* EOS? */ 1132 if( *s == '\0' ) 1133 return value; 1134 1135 /* Otherwise, colon */ 1136 if( *s != ':' ) 1137 return SET_INVALID; 1138 s ++; 1139 1140 /* \d+ */ 1141 if( !isdigit( *s ) ) 1142 return SET_INVALID; 1143 while( *s && isdigit( *s ) ) s ++; 1144 1145 /* EOS */ 1146 return *s == '\0' ? value : SET_INVALID; 1147 } 1148 1149 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1150 { 1151 time_t now_ts = time( NULL ); 1152 struct tm now, msg; 1153 char *set; 1154 1155 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1156 it doesn't seem to add to much useful info and/or might be noise. */ 1157 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1158 return NULL; 1159 1160 set = set_getstr( &irc->set, "timezone" ); 1161 if( strcmp( set, "local" ) == 0 ) 1162 { 1163 localtime_r( &now_ts, &now ); 1164 localtime_r( &msg_ts, &msg ); 1165 } 1166 else 1167 { 1168 int hr, min = 0, sign = 60; 1169 1170 if( set[0] == '-' ) 1171 { 1172 sign *= -1; 1173 set ++; 1174 } 1175 else if( set[0] == '+' ) 1176 { 1177 set ++; 1178 } 1179 1180 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1181 { 1182 msg_ts += sign * ( hr * 60 + min ); 1183 now_ts += sign * ( hr * 60 + min ); 1184 } 1185 1186 gmtime_r( &now_ts, &now ); 1187 gmtime_r( &msg_ts, &msg ); 1188 } 1189 1190 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1191 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1192 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1193 else 1194 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1195 "%02d:%02d:%02d\x02]\x02 ", 1196 msg.tm_year + 1900, msg.tm_mon, msg.tm_mday, 1197 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1198 } 826 #endif 827 828 1199 829 1200 830 /* The plan is to not allow straight calls to prpl functions anymore, but do 1201 831 them all from some wrappers. We'll start to define some down here: */ 1202 832 1203 int imc_ buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags )833 int imc_chat_msg( struct groupchat *c, char *msg, int flags ) 1204 834 { 1205 835 char *buf = NULL; 1206 int st; 1207 1208 if( ( ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 836 837 if( ( c->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 1209 838 { 1210 839 buf = escape_html( msg ); … … 1212 841 } 1213 842 1214 st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags );1215 g_free( buf );1216 1217 return st;1218 }1219 1220 int imc_chat_msg( struct groupchat *c, char *msg, int flags )1221 {1222 char *buf = NULL;1223 1224 if( ( c->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )1225 {1226 buf = escape_html( msg );1227 msg = buf;1228 }1229 1230 843 c->ic->acc->prpl->chat_msg( c, msg, flags ); 1231 844 g_free( buf ); … … 1240 853 char *away, *msg = NULL; 1241 854 1242 if( ic->acc->prpl->away_states == NULL ||1243 ic->acc->prpl->set_away == NULL )1244 return 0;1245 1246 855 away = set_getstr( &ic->acc->set, "away" ) ? 1247 : set_getstr( &ic-> irc->set, "away" );856 : set_getstr( &ic->bee->set, "away" ); 1248 857 if( away && *away ) 1249 858 { … … 1256 865 away = NULL; 1257 866 msg = set_getstr( &ic->acc->set, "status" ) ? 1258 : set_getstr( &ic-> irc->set, "status" );867 : set_getstr( &ic->bee->set, "status" ); 1259 868 } 1260 869
Note: See TracChangeset
for help on using the changeset viewer.