Changes in / [0fbd3a6d:793cc25]
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
account.c
r0fbd3a6d r793cc25 95 95 g_free( acc->server ); 96 96 if( *value ) 97 {98 97 acc->server = g_strdup( value ); 99 return value;100 }101 98 else 102 {103 99 acc->server = NULL; 104 return g_strdup( set->def ); 105 } 100 return value; 106 101 } 107 102 else if( strcmp( set->key, "auto_connect" ) == 0 ) -
dcc.c
r0fbd3a6d r793cc25 125 125 file = df->ft; 126 126 file->write = dccs_send_write; 127 file->sending = TRUE; 127 128 128 129 /* listen and request */ -
doc/CREDITS
r0fbd3a6d r793cc25 55 55 - Greg (gropeep.org), for updating the Yahoo! module to fix some issues 56 56 that were there for quite some time already. 57 - misc@mandriva.org for lots of Jabber contributions.58 57 59 58 - And all other users who help us by sending useful bug reports, positive -
doc/user-guide/commands.xml
r0fbd3a6d r793cc25 17 17 18 18 <bitlbee-command name="add"> 19 <syntax>account add <protocol> <username> <password> </syntax>19 <syntax>account add <protocol> <username> <password> [<server>]</syntax> 20 20 21 21 <description> … … 26 26 27 27 <bitlbee-command name="jabber"> 28 <syntax>account add jabber <handle@server.tld> <password> </syntax>28 <syntax>account add jabber <handle@server.tld> <password> [<servertag>]</syntax> 29 29 30 30 <description> … … 50 50 51 51 <bitlbee-command name="oscar"> 52 <syntax>account add oscar <handle> <password> </syntax>52 <syntax>account add oscar <handle> <password> [<servername>]</syntax> 53 53 54 54 <description> 55 55 <para> 56 OSCAR is the protocol used to connect to AIM and/or ICQ. The servers will automatically detect if you're using a numeric or non-numeric username so there's no need to tell which network you want to connect to.56 Specifying a server is required for OSCAR, since OSCAR can be used for both ICQ- and AIM-connections. Although these days it's supposed to be possible to connect to ICQ via AIM-servers and vice versa, we like to stick with this separation for now. For ICQ connections, the servername is <emphasis>login.icq.com</emphasis>, for AIM connections it's <emphasis>login.oscar.aol.com</emphasis>. 57 57 </para> 58 58 </description> 59 59 60 60 <ircexample> 61 <ircline nick="wilmer">account add oscar 72696705 hobbelmeeuw </ircline>61 <ircline nick="wilmer">account add oscar 72696705 hobbelmeeuw login.icq.com</ircline> 62 62 <ircline nick="root">Account successfully added</ircline> 63 63 </ircexample> … … 595 595 <description> 596 596 <para> 597 Can be set for Jabber- and OSCAR-connections. For Jabber, you might have to set this if the servername isn't equal to the part after the @ in the Jabber handle. For OSCAR this shouldn't be necessary anymore in recent BitlBee versions.597 Can be set for Jabber- and OSCAR-connections. For OSCAR, this must be set to <emphasis>login.icq.com</emphasis> if it's an ICQ connection, or <emphasis>login.oscar.aol.com</emphasis> if it's an AIM connection. For Jabber, you have to set this if the servername isn't equal to the part after the @ in the Jabber handle. 598 598 </para> 599 599 </description> -
doc/user-guide/quickstart.xml
r0fbd3a6d r793cc25 38 38 39 39 <ircexample> 40 <ircline nick="you">account add jabber bitlbee@jabber.org QuickStart</ircline>40 <ircline nick="you">account add oscar 72696705 QuickStart login.icq.com</ircline> 41 41 <ircline nick="root">Account successfully added</ircline> 42 42 </ircexample> 43 43 44 44 <para> 45 Other available IM protocols are msn, oscar, and yahoo. Oscar is the protocol used by ICQ and AOL.45 Other available IM protocols are jabber, msn, and yahoo. Oscar is the protocol used by ICQ and AOL. For oscar, you need to specify the IM-server as a fourth argument (for msn and yahoo there is no fourth argument). For AOL Instant Messenger, the server name is <emphasis>login.oscar.aol.com</emphasis>. For ICQ, the server name is <emphasis>login.icq.com</emphasis>. 46 46 </para> 47 47 -
irc_commands.c
r0fbd3a6d r793cc25 207 207 if( c->ic && c->ic->acc->prpl->chat_invite ) 208 208 { 209 c->ic->acc->prpl->chat_invite( c, u->handle, NULL);209 c->ic->acc->prpl->chat_invite( c, "", u->handle ); 210 210 irc_reply( irc, 341, "%s %s", nick, channel ); 211 211 return; -
lib/misc.c
r0fbd3a6d r793cc25 44 44 #include <resolv.h> 45 45 #endif 46 47 #include "ssl_client.h"48 46 49 47 void strip_linefeed(gchar *text) … … 593 591 return g_string_free( ret, FALSE ); 594 592 } 595 596 gboolean ssl_sockerr_again( void *ssl )597 {598 if( ssl )599 return ssl_errno == SSL_AGAIN;600 else601 return sockerr_again();602 } -
lib/misc.h
r0fbd3a6d r793cc25 66 66 G_MODULE_EXPORT char *word_wrap( char *msg, int line_len ); 67 67 68 G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl );69 70 68 #endif -
lib/ssl_gnutls.c
r0fbd3a6d r793cc25 223 223 closesocket( conn->fd ); 224 224 225 if( conn->session ) 226 gnutls_deinit( conn->session ); 227 if( conn->xcred ) 228 gnutls_certificate_free_credentials( conn->xcred ); 225 gnutls_deinit( conn->session ); 226 gnutls_certificate_free_credentials( conn->xcred ); 229 227 g_free( conn ); 230 228 } -
nick.c
r0fbd3a6d r793cc25 154 154 With one difference, we allow dashes. */ 155 155 156 static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^ `-_|";157 static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~ `-_\\";158 159 void nick_strip( char * nick )156 static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^-_|"; 157 static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~-_\\"; 158 159 void nick_strip( char * nick ) 160 160 { 161 161 int i, j; … … 170 170 } 171 171 } 172 if( isdigit( nick[0] ) )173 {174 char *orig;175 176 orig = g_strdup( nick );177 g_snprintf( nick, MAX_NICK_LENGTH, "_%s", orig );178 g_free( orig );179 j ++;180 }181 172 while( j <= MAX_NICK_LENGTH ) 182 173 nick[j++] = '\0'; … … 187 178 const char *s; 188 179 189 /* Empty/long nicks are not allowed , nor numbers at [0]*/190 if( !*nick || isdigit( nick[0] ) ||strlen( nick ) > MAX_NICK_LENGTH )180 /* Empty/long nicks are not allowed */ 181 if( !*nick || strlen( nick ) > MAX_NICK_LENGTH ) 191 182 return( 0 ); 192 183 -
protocols/jabber/conference.c
r0fbd3a6d r793cc25 174 174 175 175 return 1; 176 }177 178 void jabber_chat_invite( struct groupchat *c, char *who, char *message )179 {180 struct xt_node *node;181 struct im_connection *ic = c->ic;182 struct jabber_chat *jc = c->data;183 184 node = xt_new_node( "reason", message, NULL );185 186 node = xt_new_node( "invite", NULL, node );187 xt_add_attr( node, "to", who );188 189 node = xt_new_node( "x", NULL, node );190 xt_add_attr( node, "xmlns", XMLNS_MUC_USER );191 192 node = jabber_make_packet( "message", NULL, jc->name, node );193 194 jabber_write_packet( ic, node );195 196 xt_free_node( node );197 176 } 198 177 -
protocols/jabber/io.c
r0fbd3a6d r793cc25 120 120 return TRUE; 121 121 } 122 else if( st == 0 || ( st < 0 && !s sl_sockerr_again( jd->ssl) ) )122 else if( st == 0 || ( st < 0 && !sockerr_again() ) ) 123 123 { 124 124 /* Set fd to -1 to make sure we won't write to it anymore. */ … … 231 231 } 232 232 } 233 else if( st == 0 || ( st < 0 && !s sl_sockerr_again( jd->ssl) ) )233 else if( st == 0 || ( st < 0 && !sockerr_again() ) ) 234 234 { 235 235 closesocket( jd->fd ); -
protocols/jabber/iq.c
r0fbd3a6d r793cc25 50 50 else if( strcmp( type, "get" ) == 0 ) 51 51 { 52 if( !( ( c = xt_find_node( node->children, "query" ) ) || 53 ( c = xt_find_node( node->children, "ping" ) ) ) || /* O_o WHAT is wrong with just <query/> ????? */ 52 if( !( c = xt_find_node( node->children, "query" ) ) || 54 53 !( s = xt_find_attr( c, "xmlns" ) ) ) 55 54 { … … 82 81 xt_add_child( reply, xt_new_node( "tz", buf, NULL ) ); 83 82 } 84 else if( strcmp( s, XMLNS_PING ) == 0 ) 85 { 86 xt_free_node( reply ); 87 reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), NULL ); 88 if( ( s = xt_find_attr( node, "id" ) ) ) 89 xt_add_attr( reply, "id", s ); 90 pack = 0; 91 } 92 else if( strcmp( s, XMLNS_DISCO_INFO ) == 0 ) 83 else if( strcmp( s, XMLNS_DISCOVER ) == 0 ) 93 84 { 94 85 const char *features[] = { XMLNS_VERSION, … … 96 87 XMLNS_CHATSTATES, 97 88 XMLNS_MUC, 98 XMLNS_PING,99 89 XMLNS_SI, 100 90 XMLNS_BYTESTREAMS, … … 575 565 return st; 576 566 } 577 578 xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );579 580 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid )581 {582 struct xt_node *node, *query;583 struct jabber_buddy *bud;584 585 if( ( bud = jabber_buddy_by_jid( ic, bare_jid , 0 ) ) == NULL )586 {587 /* Who cares about the unknown... */588 imcb_log( ic, "Couldnt find the man: %s", bare_jid);589 return 0;590 }591 592 if( bud->features ) /* been here already */593 return XT_HANDLED;594 595 node = xt_new_node( "query", NULL, NULL );596 xt_add_attr( node, "xmlns", XMLNS_DISCO_INFO );597 598 if( !( query = jabber_make_packet( "iq", "get", bare_jid, node ) ) )599 {600 imcb_log( ic, "WARNING: Couldn't generate feature query" );601 xt_free_node( node );602 }603 604 jabber_cache_add( ic, query, jabber_iq_parse_features );605 606 return jabber_write_packet( ic, query );607 }608 609 xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )610 {611 struct xt_node *c;612 struct jabber_buddy *bud;613 char *feature;614 615 if( !( c = xt_find_node( node->children, "query" ) ) ||616 !( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_INFO ) == 0 ) )617 {618 imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" );619 return XT_HANDLED;620 }621 if( ( bud = jabber_buddy_by_jid( ic, xt_find_attr( node, "from") , 0 ) ) == NULL )622 {623 /* Who cares about the unknown... */624 imcb_log( ic, "Couldnt find the man: %s", xt_find_attr( node, "from"));625 return 0;626 }627 628 c = c->children;629 while( ( c = xt_find_node( c, "feature" ) ) ) {630 feature = xt_find_attr( c, "var" );631 bud->features = g_slist_append(bud->features, g_strdup(feature) );632 c = c->next;633 }634 635 return XT_HANDLED;636 }637 638 xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );639 640 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns )641 {642 struct xt_node *node, *query;643 struct jabber_data *jd = ic->proto_data;644 645 node = xt_new_node( "query", NULL, NULL );646 xt_add_attr( node, "xmlns", xmlns );647 648 if( !( query = jabber_make_packet( "iq", "get", jid, node ) ) )649 {650 imcb_log( ic, "WARNING: Couldn't generate server query" );651 xt_free_node( node );652 }653 654 jd->have_streamhosts--;655 jabber_cache_add( ic, query, jabber_iq_parse_server_features );656 657 return jabber_write_packet( ic, query );658 }659 660 /*661 * Query the server for "items", query each "item" for identities, query each "item" that's a proxy for it's bytestream info662 */663 xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )664 {665 struct xt_node *c;666 struct jabber_data *jd = ic->proto_data;667 668 if( !( c = xt_find_node( node->children, "query" ) ) ||669 !xt_find_attr( node, "from" ) )670 {671 imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" );672 return XT_HANDLED;673 }674 675 jd->have_streamhosts++;676 677 if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_ITEMS ) == 0 )678 {679 char *item, *itemjid;680 681 /* answer from server */682 683 c = c->children;684 while( ( c = xt_find_node( c, "item" ) ) )685 {686 item = xt_find_attr( c, "name" );687 itemjid = xt_find_attr( c, "jid" );688 689 jabber_iq_query_server( ic, itemjid, XMLNS_DISCO_INFO );690 691 c = c->next;692 }693 } else if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_INFO ) == 0 )694 {695 char *category, *type;696 697 /* answer from potential proxy */698 699 c = c->children;700 while( ( c = xt_find_node( c, "identity" ) ) )701 {702 category = xt_find_attr( c, "category" );703 type = xt_find_attr( c, "type" );704 705 if( type && ( strcmp( type, "bytestreams" ) == 0 ) &&706 category && ( strcmp( category, "proxy" ) == 0 ) )707 jabber_iq_query_server( ic, xt_find_attr( node, "from" ), XMLNS_BYTESTREAMS );708 709 c = c->next;710 }711 } else if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_BYTESTREAMS ) == 0 )712 {713 char *host, *jid;714 int port;715 716 /* answer from proxy */717 718 if( ( c = xt_find_node( c->children, "streamhost" ) ) &&719 ( host = xt_find_attr( c, "host" ) ) &&720 ( port = atoi( xt_find_attr( c, "port" ) ) ) &&721 ( jid = xt_find_attr( c, "jid" ) ) )722 {723 jabber_streamhost_t *sh = g_new0( jabber_streamhost_t, 1 );724 sh->jid = g_strdup( jid );725 sh->host = g_strdup( host );726 sprintf( sh->port, "%u", port );727 728 imcb_log( ic, "Proxy found: jid %s host %s port %u", jid, host, port );729 jd->streamhosts = g_slist_append( jd->streamhosts, sh );730 }731 }732 733 if( jd->have_streamhosts == 0 )734 jd->have_streamhosts++;735 return XT_HANDLED;736 } -
protocols/jabber/jabber.c
r0fbd3a6d r793cc25 76 76 jd->username = g_strdup( acc->user ); 77 77 jd->server = strchr( jd->username, '@' ); 78 79 jd->fd = jd->r_inpa = jd->w_inpa = -1;80 78 81 79 if( jd->server == NULL ) … … 234 232 struct jabber_data *jd = ic->proto_data; 235 233 236 if( jd->fd >= 0 ) 237 jabber_end_stream( ic ); 234 jabber_end_stream( ic ); 238 235 239 236 while( ic->groupchats ) … … 253 250 g_free( jd->txq ); 254 251 255 if( jd->node_cache ) 256 g_hash_table_destroy( jd->node_cache ); 252 g_hash_table_destroy( jd->node_cache ); 257 253 258 254 xt_free( jd->xt ); … … 425 421 if( c ) 426 422 jabber_chat_leave( c, NULL ); 427 }428 429 static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg )430 {431 struct jabber_chat *jc = c->data;432 gchar *msg_alt = NULL;433 434 if( msg == NULL )435 msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name );436 437 if( c && who )438 jabber_chat_invite( c, who, msg ? msg : msg_alt );439 440 g_free( msg_alt );441 423 } 442 424 … … 512 494 ret->chat_msg = jabber_chat_msg_; 513 495 ret->chat_topic = jabber_chat_topic_; 514 ret->chat_invite = jabber_chat_invite_;496 // ret->chat_invite = jabber_chat_invite; 515 497 ret->chat_leave = jabber_chat_leave_; 516 498 ret->chat_join = jabber_chat_join_; -
protocols/jabber/jabber.h
r0fbd3a6d r793cc25 57 57 } jabber_buddy_flags_t; 58 58 59 /* Stores a streamhost's(a.k.a. proxy) data */60 typedef struct61 {62 char *jid;63 char *host;64 char port[6];65 } jabber_streamhost_t;66 67 59 struct jabber_data 68 60 { … … 91 83 92 84 GSList *filetransfers; 93 GSList *streamhosts;94 int have_streamhosts;95 85 }; 96 86 … … 121 111 struct jabber_away_state *away_state; 122 112 char *away_message; 123 GSList *features;124 113 125 114 time_t last_act; … … 189 178 #define XMLNS_VERSION "jabber:iq:version" /* XEP-0092 */ 190 179 #define XMLNS_TIME "jabber:iq:time" /* XEP-0090 */ 191 #define XMLNS_PING "urn:xmpp:ping" /* XEP-0199 */192 180 #define XMLNS_VCARD "vcard-temp" /* XEP-0054 */ 193 181 #define XMLNS_DELAY "jabber:x:delay" /* XEP-0091 */ 194 182 #define XMLNS_XDATA "jabber:x:data" /* XEP-0004 */ 195 183 #define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* XEP-0085 */ 196 #define XMLNS_DISCO_INFO "http://jabber.org/protocol/disco#info" /* XEP-0030 */ 197 #define XMLNS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" /* XEP-0030 */ 184 #define XMLNS_DISCOVER "http://jabber.org/protocol/disco#info" /* XEP-0030 */ 198 185 #define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */ 199 186 #define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user" /* XEP-0045 */ … … 212 199 int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ); 213 200 int jabber_remove_from_roster( struct im_connection *ic, char *handle ); 214 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid );215 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns );216 201 217 202 /* si.c */ … … 294 279 void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); 295 280 void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); 296 void jabber_chat_invite( struct groupchat *c, char *who, char *message );297 281 298 282 #endif -
protocols/jabber/s5bytestream.c
r0fbd3a6d r793cc25 30 30 struct jabber_transfer *tf; 31 31 32 jabber_streamhost_t *sh;33 GSList *streamhosts;32 /* <query> element and <streamhost> elements */ 33 struct xt_node *qnode, *shnode; 34 34 35 35 enum … … 74 74 gboolean jabber_bs_abort( struct bs_transfer *bt, char *format, ... ); 75 75 void jabber_bs_canceled( file_transfer_t *ft , char *reason ); 76 void jabber_bs_free_transfer( file_transfer_t *ft 76 void jabber_bs_free_transfer( file_transfer_t *ft); 77 77 gboolean jabber_bs_connect_timeout( gpointer data, gint fd, b_input_condition cond ); 78 78 gboolean jabber_bs_poll( struct bs_transfer *bt, int fd, short *revents ); … … 84 84 gboolean jabber_bs_recv_handshake( gpointer data, gint fd, b_input_condition cond ); 85 85 gboolean jabber_bs_recv_handshake_abort( struct bs_transfer *bt, char *error ); 86 int jabber_bs_recv_request( struct im_connection *ic, struct xt_node *node, struct xt_node *qnode 86 int jabber_bs_recv_request( struct im_connection *ic, struct xt_node *node, struct xt_node *qnode); 87 87 88 88 gboolean jabber_bs_send_handshake_abort( struct bs_transfer *bt, char *error ); 89 gboolean jabber_bs_send_request( struct jabber_transfer *tf, GSList *streamhosts);89 gboolean jabber_bs_send_request( struct jabber_transfer *tf, char *host, char *port ); 90 90 gboolean jabber_bs_send_handshake( gpointer data, gint fd, b_input_condition cond ); 91 91 gboolean jabber_bs_send_listen( struct bs_transfer *bt, struct sockaddr_storage *saddr, char *host, char *port ); 92 static xt_status jabber_bs_send_handle_activate( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );93 void jabber_bs_send_activate( struct bs_transfer *bt );94 92 95 93 /* … … 99 97 struct jabber_transfer *tf = ft->data; 100 98 struct bs_transfer *bt = tf->streamhandle; 101 jabber_streamhost_t *sh;102 99 103 100 if ( tf->watch_in ) … … 108 105 109 106 g_free( bt->pseudoadr ); 110 111 while( bt->streamhosts ) 112 { 113 sh = bt->streamhosts->data; 114 bt->streamhosts = g_slist_remove( bt->streamhosts, sh ); 115 g_free( sh->jid ); 116 g_free( sh->host ); 117 g_free( sh ); 118 } 119 107 xt_free_node( bt->qnode ); 120 108 g_free( bt ); 121 109 … … 123 111 } 124 112 125 /*126 * Checks if buflen data is available on the socket and127 * writes it to buffer if that's the case.128 */129 113 gboolean jabber_bs_peek( struct bs_transfer *bt, void *buffer, int buflen ) 130 114 { … … 163 147 } 164 148 165 /*166 * Polls the socket, checks for errors and removes a connect timer167 * if there is one.168 */169 149 gboolean jabber_bs_poll( struct bs_transfer *bt, int fd, short *revents ) 170 150 { … … 201 181 } 202 182 203 /*204 * Used for receive and send path.205 */206 183 gboolean jabber_bs_abort( struct bs_transfer *bt, char *format, ... ) 207 184 { … … 214 191 va_end( params ); 215 192 if( bt->tf->ft->sending ) 193 return jabber_bs_recv_handshake_abort( bt, error ); 194 else 216 195 return jabber_bs_send_handshake_abort( bt, error ); 217 else218 return jabber_bs_recv_handshake_abort( bt, error );219 196 } 220 197 … … 237 214 GSList *tflist; 238 215 struct bs_transfer *bt; 239 GSList *shlist=NULL;240 struct xt_node *shnode;241 216 242 217 sha1_state_t sha; … … 258 233 { 259 234 imcb_log( ic, "WARNING: Received SI Request for unsupported bytestream mode %s", xt_find_attr( qnode, "mode" ) ); 260 return XT_HANDLED;261 }262 263 shnode = qnode->children;264 while( ( shnode = xt_find_node( shnode, "streamhost" ) ) )265 {266 char *jid, *host;267 int port;268 if( ( jid = xt_find_attr( shnode, "jid" ) ) &&269 ( host = xt_find_attr( shnode, "host" ) ) &&270 ( ( port = atoi( xt_find_attr( shnode, "port" ) ) ) ) )271 {272 jabber_streamhost_t *sh = g_new0( jabber_streamhost_t, 1 );273 sh->jid = g_strdup(jid);274 sh->host = g_strdup(host);275 sprintf( sh->port, "%u", port );276 shlist = g_slist_append( shlist, sh );277 }278 shnode = shnode->next;279 }280 281 if( !shlist )282 {283 imcb_log( ic, "WARNING: Received incomplete SI bytestream request, no parseable streamhost entries");284 235 return XT_HANDLED; 285 236 } … … 323 274 bt = g_new0( struct bs_transfer, 1 ); 324 275 bt->tf = tf; 325 bt-> streamhosts = shlist;326 bt->sh = shlist->data;276 bt->qnode = xt_dup( qnode ); 277 bt->shnode = bt->qnode->children; 327 278 bt->phase = BS_PHASE_CONNECT; 328 279 bt->pseudoadr = g_strdup( hash_hex ); … … 334 285 return XT_HANDLED; 335 286 } 336 337 287 /* 338 288 * This is what a protocol handshake can look like in cooperative multitasking :) … … 355 305 case BS_PHASE_CONNECT: 356 306 { 307 struct xt_node *c; 308 char *host, *port; 357 309 struct addrinfo hints, *rp; 358 310 359 memset( &hints, 0, sizeof( struct addrinfo ) ); 360 hints.ai_socktype = SOCK_STREAM; 361 362 if ( getaddrinfo( bt->sh->host, bt->sh->port, &hints, &rp ) != 0 ) 363 return jabber_bs_abort( bt, "getaddrinfo() failed: %s", strerror( errno ) ); 364 365 ASSERTSOCKOP( bt->tf->fd = fd = socket( rp->ai_family, rp->ai_socktype, 0 ), "Opening socket" ); 366 367 sock_make_nonblocking( fd ); 368 369 imcb_log( bt->tf->ic, "File %s: Connecting to streamhost %s:%s", bt->tf->ft->file_name, bt->sh->host, bt->sh->port ); 370 371 if( ( connect( fd, rp->ai_addr, rp->ai_addrlen ) == -1 ) && 372 ( errno != EINPROGRESS ) ) 373 return jabber_bs_abort( bt , "connect() failed: %s", strerror( errno ) ); 374 375 freeaddrinfo( rp ); 376 377 bt->phase = BS_PHASE_CONNECTED; 378 379 bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt ); 380 381 /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */ 382 bt->connect_timeout = b_timeout_add( JABBER_BS_CONTIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 383 384 bt->tf->watch_in = 0; 385 return FALSE; 311 if( ( c = bt->shnode = xt_find_node( bt->shnode, "streamhost" ) ) && 312 ( port = xt_find_attr( c, "port" ) ) && 313 ( host = xt_find_attr( c, "host" ) ) && 314 xt_find_attr( c, "jid" ) ) 315 { 316 memset( &hints, 0, sizeof( struct addrinfo ) ); 317 hints.ai_socktype = SOCK_STREAM; 318 319 if ( getaddrinfo( host, port, &hints, &rp ) != 0 ) 320 return jabber_bs_abort( bt, "getaddrinfo() failed: %s", strerror( errno ) ); 321 322 ASSERTSOCKOP( bt->tf->fd = fd = socket( rp->ai_family, rp->ai_socktype, 0 ), "Opening socket" ); 323 324 sock_make_nonblocking( fd ); 325 326 imcb_log( bt->tf->ic, "File %s: Connecting to streamhost %s:%s", bt->tf->ft->file_name, host, port ); 327 328 if( ( connect( fd, rp->ai_addr, rp->ai_addrlen ) == -1 ) && 329 ( errno != EINPROGRESS ) ) 330 return jabber_bs_abort( bt , "connect() failed: %s", strerror( errno ) ); 331 332 freeaddrinfo( rp ); 333 334 bt->phase = BS_PHASE_CONNECTED; 335 336 bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt ); 337 338 /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */ 339 bt->connect_timeout = b_timeout_add( JABBER_BS_CONTIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 340 341 bt->tf->watch_in = 0; 342 return FALSE; 343 } else 344 return jabber_bs_abort( bt, c ? "incomplete streamhost entry: host=%s port=%s jid=%s" : NULL, 345 host, port, xt_find_attr( c, "jid" ) ); 386 346 } 387 347 case BS_PHASE_CONNECTED: … … 462 422 socks5_reply.addrlen); 463 423 464 if( bt->tf->ft->sending ) 465 jabber_bs_send_activate( bt ); 466 else 467 jabber_bs_recv_answer_request( bt ); 424 jabber_bs_recv_answer_request( bt ); 468 425 469 426 return FALSE; … … 490 447 struct jabber_transfer *tf = bt->tf; 491 448 struct xt_node *reply, *iqnode; 492 GSList *shlist; 493 494 imcb_log( tf->ic, "Transferring file %s: connection to streamhost %s:%s failed (%s)",495 tf->ft->file_name,496 bt->sh->host,497 bt->sh->port,498 error );499 500 /* Alright, this streamhost failed, let's try the next... */ 501 bt->phase = BS_PHASE_CONNECT;502 shlist = g_slist_find( bt->streamhosts, bt->sh );503 if( shlist && shlist->next )504 {505 bt->sh = shlist->next->data;506 return jabber_bs_recv_handshake( bt, 0, 0 );507 }508 449 450 if( bt->shnode ) 451 { 452 imcb_log( tf->ic, "Transferring file %s: connection to streamhost %s:%s failed (%s)", 453 tf->ft->file_name, 454 xt_find_attr( bt->shnode, "host" ), 455 xt_find_attr( bt->shnode, "port" ), 456 error ); 457 458 /* Alright, this streamhost failed, let's try the next... */ 459 bt->phase = BS_PHASE_CONNECT; 460 bt->shnode = bt->shnode->next; 461 462 /* the if is not neccessary but saves us one recursion */ 463 if( bt->shnode ) 464 return jabber_bs_recv_handshake( bt, 0, 0 ); 465 } 509 466 510 467 /* out of stream hosts */ … … 538 495 imcb_log( tf->ic, "File %s: established SOCKS5 connection to %s:%s", 539 496 tf->ft->file_name, 540 bt->sh->host,541 bt->sh->port);497 xt_find_attr( bt->shnode, "host" ), 498 xt_find_attr( bt->shnode, "port" ) ); 542 499 543 500 tf->ft->data = tf; 501 tf->ft->started = time( NULL ); 544 502 tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt ); 545 503 tf->ft->write_request = jabber_bs_recv_write_request; 546 504 547 505 reply = xt_new_node( "streamhost-used", NULL, NULL ); 548 xt_add_attr( reply, "jid", bt->sh->jid);506 xt_add_attr( reply, "jid", xt_find_attr( bt->shnode, "jid" ) ); 549 507 550 508 reply = xt_new_node( "query", NULL, reply ); … … 593 551 return jabber_bs_abort( bt, "Remote end closed connection" ); 594 552 595 if( tf->bytesread == 0 )596 tf->ft->started = time( NULL );597 598 553 tf->bytesread += ret; 599 554 … … 648 603 return jabber_bs_abort( bt, "BUG: write() called while watching " ); 649 604 650 /* TODO: catch broken pipe */651 605 ASSERTSOCKOP( ret = send( tf->fd, buffer, len, 0 ), "Sending" ); 652 653 if( tf->byteswritten == 0 )654 tf->ft->started = time( NULL );655 606 656 607 tf->byteswritten += ret; … … 714 665 tf->accepted = TRUE; 715 666 716 if( strcmp( jid, tf->ini_jid ) == 0 ) 717 { 718 /* we're streamhost and target */ 719 if( bt->phase == BS_PHASE_REPLY ) 720 { 721 /* handshake went through, let's start transferring */ 722 tf->ft->write_request( tf->ft ); 723 } 724 } else 725 { 726 /* using a proxy */ 727 GSList *shlist; 728 for( shlist = jd->streamhosts ; shlist ; shlist = g_slist_next( shlist ) ) 729 { 730 jabber_streamhost_t *sh = shlist->data; 731 if( strcmp( sh->jid, jid ) == 0 ) 732 { 733 bt->sh = sh; 734 jabber_bs_recv_handshake( bt, 0, 0 ); 735 return XT_HANDLED; 736 } 737 } 738 739 imcb_log( ic, "WARNING: Received SOCKS5 bytestream reply with unknown streamhost %s", jid ); 667 if( bt->phase == BS_PHASE_REPLY ) 668 { 669 /* handshake went through, let's start transferring */ 670 tf->ft->started = time( NULL ); 671 tf->ft->write_request( tf->ft ); 740 672 } 741 673 … … 743 675 } 744 676 745 /*746 * Tell the proxy to activate the stream. Looks like this:747 *748 * <iq type=set>749 * <query xmlns=bs sid=sid>750 * <activate>tgt_jid</activate>751 * </query>752 * </iq>753 */754 void jabber_bs_send_activate( struct bs_transfer *bt )755 {756 struct xt_node *node;757 758 node = xt_new_node( "activate", bt->tf->tgt_jid, NULL );759 node = xt_new_node( "query", NULL, node );760 xt_add_attr( node, "xmlns", XMLNS_BYTESTREAMS );761 xt_add_attr( node, "sid", bt->tf->sid );762 node = jabber_make_packet( "iq", "set", bt->sh->jid, node );763 764 jabber_cache_add( bt->tf->ic, node, jabber_bs_send_handle_activate );765 766 jabber_write_packet( bt->tf->ic, node );767 }768 769 /*770 * The proxy has activated the bytestream.771 * We can finally start pushing some data out.772 */773 static xt_status jabber_bs_send_handle_activate( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )774 {775 char *sid;776 GSList *tflist;777 struct jabber_transfer *tf;778 struct xt_node *query;779 struct jabber_data *jd = ic->proto_data;780 781 query = xt_find_node( orig->children, "query" );782 sid = xt_find_attr( query, "sid" );783 784 for( tflist = jd->filetransfers ; tflist; tflist = g_slist_next(tflist) )785 {786 struct jabber_transfer *tft = tflist->data;787 if( ( strcmp( tft->sid, sid ) == 0 ) )788 {789 tf = tft;790 break;791 }792 }793 794 if( !tf )795 {796 imcb_log( ic, "WARNING: Received SOCKS5 bytestream activation for unknown stream" );797 return XT_HANDLED;798 }799 800 /* handshake went through, let's start transferring */801 tf->ft->write_request( tf->ft );802 803 return XT_HANDLED;804 }805 806 /*807 * Starts a bytestream.808 */809 677 gboolean jabber_bs_send_start( struct jabber_transfer *tf ) 810 678 { 811 char host[INET6_ADDRSTRLEN] ;679 char host[INET6_ADDRSTRLEN], port[6]; 812 680 struct bs_transfer *bt; 813 681 sha1_state_t sha; 814 682 char hash_hex[41]; 815 683 unsigned char hash[20]; 816 int i,ret; 817 struct jabber_data *jd = tf->ic->proto_data; 818 jabber_streamhost_t sh; 819 GSList *streamhosts = jd->streamhosts; 684 int i; 820 685 821 686 /* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value */ … … 837 702 tf->ft->canceled = jabber_bs_canceled; 838 703 839 if ( !jabber_bs_send_listen( bt, &tf->saddr, sh.host = host, sh.port ) )704 if ( !jabber_bs_send_listen( bt, &tf->saddr, host, port ) ) 840 705 return FALSE; 841 706 842 707 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 843 708 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 844 845 sh.jid = tf->ini_jid; 846 847 /* temporarily add listen address to streamhosts, send the request and remove it */ 848 streamhosts = g_slist_prepend( streamhosts, &sh ); 849 ret = jabber_bs_send_request( tf, streamhosts); 850 streamhosts = g_slist_remove( streamhosts, &sh ); 851 852 return ret; 853 } 854 855 gboolean jabber_bs_send_request( struct jabber_transfer *tf, GSList *streamhosts ) 856 { 857 struct xt_node *shnode, *query, *iq; 709 return jabber_bs_send_request( tf, host, port ); 710 } 711 712 gboolean jabber_bs_send_request( struct jabber_transfer *tf, char *host, char *port ) 713 { 714 struct xt_node *sh, *query, *iq; 715 716 sh = xt_new_node( "streamhost", NULL, NULL ); 717 xt_add_attr( sh, "jid", tf->ini_jid ); 718 xt_add_attr( sh, "host", host ); 719 xt_add_attr( sh, "port", port ); 858 720 859 721 query = xt_new_node( "query", NULL, NULL ); … … 861 723 xt_add_attr( query, "sid", tf->sid ); 862 724 xt_add_attr( query, "mode", "tcp" ); 863 864 while( streamhosts ) { 865 jabber_streamhost_t *sh = streamhosts->data; 866 shnode = xt_new_node( "streamhost", NULL, NULL ); 867 xt_add_attr( shnode, "jid", sh->jid ); 868 xt_add_attr( shnode, "host", sh->host ); 869 xt_add_attr( shnode, "port", sh->port ); 870 871 xt_add_child( query, shnode ); 872 873 streamhosts = g_slist_next( streamhosts ); 874 } 875 725 xt_add_child( query, sh ); 876 726 877 727 iq = jabber_make_packet( "iq", "set", tf->tgt_jid, query ); … … 889 739 struct jabber_transfer *tf = bt->tf; 890 740 891 /* TODO: did the receiver get here somehow??? */892 741 imcb_log( tf->ic, "Transferring file %s: SOCKS5 handshake failed: %s", 893 742 tf->ft->file_name, … … 1052 901 { 1053 902 /* streamhost-used message came already in(possible?), let's start sending */ 903 tf->ft->started = time( NULL ); 1054 904 tf->ft->write_request( tf->ft ); 1055 905 } -
protocols/jabber/si.c
r0fbd3a6d r793cc25 83 83 struct jabber_transfer *tf; 84 84 struct jabber_data *jd = ic->proto_data; 85 char *server = jd->server;86 85 87 86 imcb_log( ic, "Trying to send %s(%zd bytes) to %s", ft->file_name, ft->file_size, who ); … … 98 97 jd->filetransfers = g_slist_prepend( jd->filetransfers, tf ); 99 98 100 /* query the buddy's features */101 jabber_iq_query_features( ic, who );102 103 /* query proxies from the server */104 if( !jd->have_streamhosts )105 jabber_iq_query_server( ic, server, XMLNS_DISCO_ITEMS );106 107 /* send the request to our buddy */108 99 jabber_si_send_request( ic, who, tf ); 109 100 110 /* and start the receive logic */111 101 imcb_file_recv_start( ft ); 112 102 } -
protocols/msn/msn.c
r0fbd3a6d r793cc25 241 241 } 242 242 243 static void msn_chat_invite( struct groupchat *c, char * who, char *message)243 static void msn_chat_invite( struct groupchat *c, char *msg, char *who ) 244 244 { 245 245 struct msn_switchboard *sb = msn_sb_by_chat( c ); -
protocols/oscar/aim.h
r0fbd3a6d r793cc25 94 94 * 95 95 */ 96 #define AIM_DEFAULT_LOGIN_SERVER "login. messaging.aol.com"96 #define AIM_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" 97 97 #define AIM_LOGIN_PORT 5190 98 98 -
protocols/oscar/oscar.c
r0fbd3a6d r793cc25 341 341 set_t *s; 342 342 343 s = set_add( &acc->set, "server", AIM_DEFAULT_LOGIN_SERVER, set_eval_account, acc );343 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 344 344 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 345 345 … … 356 356 struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); 357 357 358 if (!isdigit(acc->user[0])) { 358 if (isdigit(acc->user[0])) { 359 odata->icq = TRUE; 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... </bitlbee> */ 363 /* ic->acc->pass[8] = 0; 364 Not touching this anymore now that it belongs to account_t! 365 Let's hope nothing will break. ;-) */ 366 } else { 359 367 ic->flags |= OPT_DOES_HTML; 360 368 } … … 377 385 } 378 386 387 if (acc->server == NULL) { 388 imcb_error(ic, "No servername specified"); 389 imc_logout(ic, FALSE); 390 return; 391 } 392 393 if (g_strcasecmp(acc->server, "login.icq.com") != 0 && 394 g_strcasecmp(acc->server, "login.oscar.aol.com") != 0) { 395 imcb_log(ic, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server); 396 } 397 379 398 imcb_log(ic, _("Signon: %s"), ic->acc->user); 380 399 … … 383 402 384 403 conn->status |= AIM_CONN_STATUS_INPROGRESS; 385 conn->fd = proxy_connect(set_getstr(&acc->set, "server"), 386 AIM_LOGIN_PORT, oscar_login_connect, ic); 404 conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, ic); 387 405 if (conn->fd < 0) { 388 406 imcb_error(ic, _("Couldn't connect to host")); … … 2491 2509 } 2492 2510 2493 void oscar_chat_invite(struct groupchat *c, char * who, char *message)2511 void oscar_chat_invite(struct groupchat *c, char *message, char *who) 2494 2512 { 2495 2513 struct im_connection *ic = c->ic; -
protocols/yahoo/yahoo.c
r0fbd3a6d r793cc25 306 306 } 307 307 308 static void byahoo_chat_invite( struct groupchat *c, char * who, char *msg)308 static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who ) 309 309 { 310 310 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; -
root_commands.c
r0fbd3a6d r793cc25 199 199 break; 200 200 default: 201 irc_usermsg( irc, "Error: `%d'", status );201 irc_usermsg( irc, "Error: '%d'", status ); 202 202 break; 203 203 } … … 234 234 a = account_add( irc, prpl, cmd[3], cmd[4] ); 235 235 if( cmd[5] ) 236 {237 irc_usermsg( irc, "Warning: Passing a servername/other flags to `account add' "238 "is now deprecated. Use `account set' instead." );239 236 set_setstr( &a->set, "server", cmd[5] ); 240 }241 237 242 238 irc_usermsg( irc, "Account successfully added" ); … … 321 317 else 322 318 { 323 irc_usermsg( irc, "No accounts known. Use `account add' to add one." );319 irc_usermsg( irc, "No accounts known. Use 'account add' to add one." ); 324 320 } 325 321 } … … 407 403 } 408 404 409 if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) 405 if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) 406 irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" ); 407 else if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) 410 408 set_reset( &a->set, set_name ); 411 409 else … … 747 745 static void cmd_set( irc_t *irc, char **cmd ) 748 746 { 749 char *set_name = cmd[1];747 char *set_name = NULL; 750 748 751 749 if( cmd[1] && cmd[2] ) 752 750 { 753 if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 751 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) 752 { 753 irc_usermsg( irc, "Warning: Correct syntax: \002set <variable> <value>\002 (without =)" ); 754 return; 755 } 756 else if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 754 757 { 755 758 set_reset( &irc->set, cmd[2] ); … … 759 762 { 760 763 set_setstr( &irc->set, cmd[1], cmd[2] ); 764 set_name = cmd[1]; 761 765 } 762 766 } -
tests/check_nick.c
r0fbd3a6d r793cc25 15 15 "thisisave:ryveryveryverylongnick", 16 16 "t::::est", 17 "test123",18 "123test",19 "123",20 17 NULL }; 21 18 const char *expected[] = { "test", "test", "test", … … 23 20 "thisisaveryveryveryveryl", 24 21 "test", 25 "test123",26 "_123test",27 "_123",28 22 NULL }; 29 23 … … 41 35 START_TEST(test_nick_ok_ok) 42 36 { 43 const char *nicks[] = { "foo", "bar 123", "bla[", "blie]", "BreEZaH",44 "\\od^~", "_123", "_123test", NULL };37 const char *nicks[] = { "foo", "bar", "bla[", "blie]", 38 "BreEZaH", "\\od^~", NULL }; 45 39 int i; 46 40 … … 55 49 { 56 50 const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick", 57 "\nillegalchar", "", "nick%", "123test",NULL };51 "\nillegalchar", "", "nick%", NULL }; 58 52 int i; 59 53
Note: See TracChangeset
for help on using the changeset viewer.