Changes in protocols/jabber/jabber.c [4ac647d:89d736a]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r4ac647d r89d736a 33 33 #include "jabber.h" 34 34 #include "md5.h" 35 #include "base64.h"36 35 37 36 GSList *jabber_connections; 38 37 38 /* First enty is the default */ 39 static const int jabber_port_list[] = { 40 5222, 41 5223, 42 5220, 43 5221, 44 5224, 45 5225, 46 5226, 47 5227, 48 5228, 49 5229, 50 80, 51 443, 52 0 53 }; 54 39 55 static void jabber_init( account_t *acc ) 40 56 { 41 57 set_t *s; 42 43 s = set_add( &acc->set, "port", JABBER_PORT_DEFAULT, set_eval_int, acc ); 58 char str[16]; 59 60 g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] ); 61 s = set_add( &acc->set, "port", str, set_eval_int, acc ); 44 62 s->flags |= ACC_SET_OFFLINE_ONLY; 45 63 … … 62 80 s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc ); 63 81 s->flags |= ACC_SET_OFFLINE_ONLY; 64 65 s = set_add( &acc->set, "proxy", "<local>;<auto>", NULL, acc );66 82 } 67 83 … … 74 90 struct ns_srv_reply *srv = NULL; 75 91 char *connect_to, *s; 92 int i; 76 93 77 94 /* For now this is needed in the _connected() handlers if using … … 179 196 imcb_log( ic, "Connecting" ); 180 197 181 if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN || 182 set_getint( &acc->set, "port" ) > JABBER_PORT_MAX ) 183 { 184 imcb_log( ic, "Incorrect port number, must be in the %d-%d range", 185 JABBER_PORT_MIN, JABBER_PORT_MAX ); 198 for( i = 0; jabber_port_list[i] > 0; i ++ ) 199 if( set_getint( &acc->set, "port" ) == jabber_port_list[i] ) 200 break; 201 202 if( jabber_port_list[i] == 0 ) 203 { 204 imcb_log( ic, "Illegal port number" ); 186 205 imc_logout( ic, FALSE ); 187 206 return; … … 221 240 } 222 241 242 /* This generates an unfinished md5_state_t variable. Every time we generate 243 an ID, we finish the state by adding a sequence number and take the hash. */ 223 244 static void jabber_generate_id_hash( struct jabber_data *jd ) 224 245 { 225 md5_state_t id_hash; 226 md5_byte_t binbuf[16]; 246 md5_byte_t binbuf[4]; 227 247 char *s; 228 248 229 md5_init( & id_hash);230 md5_append( & id_hash, (unsigned char *) jd->username, strlen( jd->username ) );231 md5_append( & id_hash, (unsigned char *) jd->server, strlen( jd->server ) );249 md5_init( &jd->cached_id_prefix ); 250 md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) ); 251 md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) ); 232 252 s = set_getstr( &jd->ic->acc->set, "resource" ); 233 md5_append( &id_hash, (unsigned char *) s, strlen( s ) ); 234 random_bytes( binbuf, 16 ); 235 md5_append( &id_hash, binbuf, 16 ); 236 md5_finish( &id_hash, binbuf ); 237 238 s = base64_encode( binbuf, 9 ); 239 jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); 240 g_free( s ); 253 md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) ); 254 random_bytes( binbuf, 4 ); 255 md5_append( &jd->cached_id_prefix, binbuf, 4 ); 241 256 } 242 257 … … 245 260 struct jabber_data *jd = ic->proto_data; 246 261 247 while( jd->filetransfers )248 imcb_file_canceled( ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );249 250 while( jd->streamhosts )251 {252 jabber_streamhost_t *sh = jd->streamhosts->data;253 jd->streamhosts = g_slist_remove( jd->streamhosts, sh );254 g_free( sh->jid );255 g_free( sh->host );256 g_free( sh );257 }258 259 262 if( jd->fd >= 0 ) 260 263 jabber_end_stream( ic ); … … 281 284 xt_free( jd->xt ); 282 285 283 g_free( jd->cached_id_prefix );284 286 g_free( jd->away_message ); 285 287 g_free( jd->username ); … … 544 546 ret->send_typing = jabber_send_typing; 545 547 ret->handle_cmp = g_strcasecmp; 546 ret->transfer_request = jabber_si_transfer_request;547 548 548 549 register_protocol( ret );
Note: See TracChangeset
for help on using the changeset viewer.