Changes in protocols/nogaim.c [85023c6:d444c09]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r85023c6 rd444c09 48 48 49 49 if(!mod) { 50 log_message(LOGLVL_ERROR, "Can't find `%s', not loading ", path);50 log_message(LOGLVL_ERROR, "Can't find `%s', not loading (%s)\n", path, g_module_error()); 51 51 return FALSE; 52 52 } … … 99 99 } 100 100 101 101 102 struct prpl *find_protocol(const char *name) 102 103 { … … 288 289 { 289 290 irc_t *irc = ic->irc; 290 user_t *t, *u ;291 user_t *t, *u = irc->users; 291 292 account_t *a; 292 293 … … 305 306 b_event_remove( ic->inpa ); 306 307 307 u = irc->users;308 308 while( u ) 309 309 { … … 428 428 { 429 429 user_t *u = user_findhandle( ic, handle ); 430 char *s, newnick[MAX_NICK_LENGTH+1]; 430 431 431 432 if( !u || !realname ) return; … … 439 440 if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) 440 441 imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 441 } 442 } 443 444 void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) 445 { 446 user_t *u; 447 448 if( ( u = user_findhandle( ic, handle ) ) ) 449 user_del( ic->irc, u->nick ); 450 } 451 452 /* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM 453 modules to suggest a nickname for a handle. */ 454 void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) 455 { 456 user_t *u = user_findhandle( ic, handle ); 457 char newnick[MAX_NICK_LENGTH+1], *orig_nick; 458 459 if( u && !u->online && !nick_saved( ic->acc, handle ) ) 460 { 461 /* Only do this if the person isn't online yet (which should 462 be the case if we just added it) and if the user hasn't 463 assigned a nickname to this buddy already. */ 464 465 strncpy( newnick, nick, MAX_NICK_LENGTH ); 466 newnick[MAX_NICK_LENGTH] = 0; 467 468 /* Some processing to make sure this string is a valid IRC nickname. */ 469 nick_strip( newnick ); 470 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 471 nick_lc( newnick ); 472 473 if( strcmp( u->nick, newnick ) != 0 ) 474 { 475 /* Only do this if newnick is different from the current one. 476 If rejoining a channel, maybe we got this nick already 477 (and dedupe would only add an underscore. */ 478 nick_dedupe( ic->acc, handle, newnick ); 442 443 if( !u->online && !nick_saved( ic->acc, handle ) ) 444 { 445 /* Detect numeric handles: */ 446 for( s = u->user; isdigit( *s ); s++ ); 479 447 480 /* u->nick will be freed halfway the process, so it can't be 481 passed as an argument. */ 482 orig_nick = g_strdup( u->nick ); 483 user_rename( ic->irc, orig_nick, newnick ); 484 g_free( orig_nick ); 485 } 486 } 487 } 448 if( *s == 0 ) 449 { 450 /* If we reached the end of the string, it only contained numbers. 451 Seems to be an ICQ# then, so hopefully realname contains 452 something more useful. */ 453 strcpy( newnick, realname ); 454 455 /* Some processing to make sure this string is a valid IRC nickname. */ 456 nick_strip( newnick ); 457 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 458 nick_lc( newnick ); 459 460 u->nick = g_strdup( newnick ); 461 } 462 } 463 } 464 } 465 488 466 489 467 /* prpl.c */ … … 576 554 u->online = 0; 577 555 578 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */579 for( c = ic-> groupchats; c; c = c->next )556 /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ 557 for( c = ic->conversations; c; c = c->next ) 580 558 remove_chat_buddy_silent( c, (char*) handle ); 581 559 } … … 608 586 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 609 587 { 610 irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, 611 ic->irc->channel, u->away?'-':'+', u->nick ); 588 char *from; 589 590 if( set_getbool( &ic->irc->set, "simulate_netsplit" ) ) 591 { 592 from = g_strdup( ic->irc->myhost ); 593 } 594 else 595 { 596 from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick, 597 ic->irc->myhost ); 598 } 599 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 600 u->away?'-':'+', u->nick ); 601 g_free( from ); 612 602 } 613 603 } … … 616 606 { 617 607 irc_t *irc = ic->irc; 608 char *wrapped; 618 609 user_t *u; 619 610 … … 658 649 strip_html( msg ); 659 650 660 while( strlen( msg ) > 425 ) 661 { 662 char tmp, *nl; 663 664 tmp = msg[425]; 665 msg[425] = 0; 666 667 /* If there's a newline/space in this string, split up there, 668 looks a bit prettier. */ 669 if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) ) 670 { 671 msg[425] = tmp; 672 tmp = *nl; 673 *nl = 0; 674 } 675 676 irc_msgfrom( irc, u->nick, msg ); 677 678 /* Move on. */ 679 if( nl ) 680 { 681 *nl = tmp; 682 msg = nl + 1; 683 } 684 else 685 { 686 msg[425] = tmp; 687 msg += 425; 688 } 689 } 690 irc_msgfrom( irc, u->nick, msg ); 651 wrapped = word_wrap( msg, 425 ); 652 irc_msgfrom( irc, u->nick, wrapped ); 653 g_free( wrapped ); 691 654 } 692 655 … … 707 670 } 708 671 709 void imcb_chat_ free( struct groupchat *c )672 void imcb_chat_removed( struct groupchat *c ) 710 673 { 711 674 struct im_connection *ic = c->ic; 712 struct groupchat *l ;675 struct groupchat *l = NULL; 713 676 GList *ir; 714 677 … … 730 693 } 731 694 732 /* Find the previous chat in the linked list. */733 for( l = ic->groupchats; l && l->next != c; l = l->next );734 735 695 if( l ) 736 696 l->next = c->next; 737 697 else 738 ic-> groupchats = c->next;698 ic->conversations = c->next; 739 699 740 700 for( ir = c->in_room; ir; ir = ir->next ) … … 750 710 { 751 711 struct im_connection *ic = c->ic; 712 char *wrapped; 752 713 user_t *u; 753 714 … … 762 723 strip_html( msg ); 763 724 725 wrapped = word_wrap( msg, 425 ); 764 726 if( c && u ) 765 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); 727 { 728 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 729 } 766 730 else 767 imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); 731 { 732 imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, wrapped ); 733 } 734 g_free( wrapped ); 768 735 } 769 736 … … 774 741 /* This one just creates the conversation structure, user won't see anything yet */ 775 742 776 if( ic-> groupchats )777 { 778 for( c = ic-> groupchats; c->next; c = c->next );743 if( ic->conversations ) 744 { 745 for( c = ic->conversations; c->next; c = c->next ); 779 746 c = c->next = g_new0( struct groupchat, 1 ); 780 747 } 781 748 else 782 ic-> groupchats = c = g_new0( struct groupchat, 1 );749 ic->conversations = c = g_new0( struct groupchat, 1 ); 783 750 784 751 c->ic = ic; … … 829 796 } 830 797 831 /* This function is one BIG hack... :-( EREWRITE */832 798 void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) 833 799 { … … 841 807 if( g_strcasecmp( handle, b->ic->acc->user ) == 0 ) 842 808 { 843 if( b->joined == 0 )844 return;845 846 809 u = user_find( b->ic->irc, b->ic->irc->nick ); 847 810 b->joined = 0; … … 853 816 } 854 817 855 if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) ) 856 irc_part( b->ic->irc, u, b->channel ); 818 if( remove_chat_buddy_silent( b, handle ) ) 819 if( ( b->joined || me ) && u ) 820 irc_part( b->ic->irc, u, b->channel ); 857 821 } 858 822 … … 880 844 881 845 /* Misc. BitlBee stuff which shouldn't really be here */ 846 847 struct groupchat *chat_by_channel( char *channel ) 848 { 849 struct im_connection *ic; 850 struct groupchat *c; 851 GSList *l; 852 853 /* This finds the connection which has a conversation which belongs to this channel */ 854 for( l = connections; l; l = l->next ) 855 { 856 ic = l->data; 857 for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); 858 if( c ) 859 return c; 860 } 861 862 return NULL; 863 } 882 864 883 865 char *set_eval_away_devoice( set_t *set, char *value ) … … 1113 1095 ic->acc->prpl->rem_deny( ic, handle ); 1114 1096 } 1115 1116 void imcb_clean_handle( struct im_connection *ic, char *handle )1117 {1118 /* Accepts a handle and does whatever is necessary to make it1119 BitlBee-friendly. Currently this means removing everything1120 outside 33-127 (ASCII printable excl spaces), @ (only one1121 is allowed) and ! and : */1122 char out[strlen(handle)+1];1123 int s, d;1124 1125 s = d = 0;1126 while( handle[s] )1127 {1128 if( handle[s] > ' ' && handle[s] != '!' && handle[s] != ':' &&1129 ( handle[s] & 0x80 ) == 0 )1130 {1131 if( handle[s] == '@' )1132 {1133 /* See if we got an @ already? */1134 out[d] = 0;1135 if( strchr( out, '@' ) )1136 continue;1137 }1138 1139 out[d++] = handle[s];1140 }1141 s ++;1142 }1143 out[d] = handle[s];1144 1145 strcpy( handle, out );1146 }
Note: See TracChangeset
for help on using the changeset viewer.