Changeset 0da65d5
- Timestamp:
- 2007-03-31T05:40:45Z (16 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
account.c
rfa29d093 r0da65d5 65 65 /* This function adds some more settings (and might want to do more 66 66 things that have to be done now, although I can't think of anything. */ 67 if( prpl-> acc_init )68 prpl-> acc_init( a );67 if( prpl->init ) 68 prpl->init( a ); 69 69 70 70 return( a ); … … 76 76 77 77 /* Double-check: We refuse to edit on-line accounts. */ 78 if( set->flags & ACC_SET_OFFLINE_ONLY && acc-> gc )78 if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic ) 79 79 return NULL; 80 80 … … 180 180 if( a == acc ) 181 181 { 182 if( a-> gc ) return; /* Caller should have checked, accounts still in use can't be deleted. */182 if( a->ic ) return; /* Caller should have checked, accounts still in use can't be deleted. */ 183 183 184 184 if( l ) … … 209 209 void account_on( irc_t *irc, account_t *a ) 210 210 { 211 if( a-> gc )211 if( a->ic ) 212 212 { 213 213 /* Trying to enable an already-enabled account */ … … 223 223 void account_off( irc_t *irc, account_t *a ) 224 224 { 225 a-> gc->wants_to_die = TRUE;226 signoff( a-> gc );227 a-> gc = NULL;225 a->ic->wants_to_die = TRUE; 226 signoff( a->ic ); 227 a->ic = NULL; 228 228 if( a->reconnect ) 229 229 { -
account.h
rfa29d093 r0da65d5 41 41 42 42 struct irc *irc; 43 struct gaim_connection *gc;43 struct im_connection *ic; 44 44 struct account *next; 45 45 } account_t; -
irc.c
rfa29d093 r0da65d5 230 230 231 231 for (account = irc->accounts; account; account = account->next) { 232 if (account-> gc) {233 account-> gc->wants_to_die = TRUE;234 signoff(account-> gc);232 if (account->ic) { 233 account->ic->wants_to_die = TRUE; 234 signoff(account->ic); 235 235 } else if (account->reconnect) { 236 236 cancel_auto_reconnect(account); … … 256 256 257 257 while (irc->accounts) 258 if (irc->accounts-> gc == NULL)258 if (irc->accounts->ic == NULL) 259 259 account_del(irc, irc->accounts); 260 260 else … … 633 633 user_t *u; 634 634 char namelist[385] = ""; 635 struct conversation*c = NULL;635 struct groupchat *c = NULL; 636 636 char *ops = set_getstr( &irc->set, "ops" ); 637 637 … … 649 649 } 650 650 651 if( u-> gc && !u->away && set_getbool( &irc->set, "away_devoice" ) )651 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 652 652 strcat( namelist, "+" ); 653 653 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || … … 668 668 strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick ); 669 669 670 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c-> gc, l->data ) ) )670 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) ) 671 671 { 672 672 if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 ) … … 812 812 else 813 813 { 814 struct conversation*c = chat_by_channel( channel );814 struct groupchat *c = chat_by_channel( channel ); 815 815 816 816 if( c ) … … 911 911 char reason[128]; 912 912 913 if( u-> gc && u->gc->flags & OPT_LOGGING_OUT )914 { 915 if( u-> gc->acc->server )913 if( u->ic && u->ic->flags & OPT_LOGGING_OUT ) 914 { 915 if( u->ic->acc->server ) 916 916 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 917 u-> gc->acc->server );918 else if( ( s = strchr( u-> gc->username, '@' ) ) )917 u->ic->acc->server ); 918 else if( ( s = strchr( u->ic->username, '@' ) ) ) 919 919 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 920 920 s + 1 ); 921 921 else 922 922 g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost, 923 u-> gc->acc->prpl->name, irc->myhost );923 u->ic->acc->prpl->name, irc->myhost ); 924 924 925 925 /* proto_opt might contain garbage after the : */ … … 945 945 int irc_send( irc_t *irc, char *nick, char *s, int flags ) 946 946 { 947 struct conversation*c = NULL;947 struct groupchat *c = NULL; 948 948 user_t *u = NULL; 949 949 … … 997 997 else if( g_strncasecmp( s + 1, "TYPING", 6 ) == 0 ) 998 998 { 999 if( u && u-> gc && u->gc->acc->prpl->send_typing && strlen( s ) >= 10 )999 if( u && u->ic && u->ic->acc->prpl->send_typing && strlen( s ) >= 10 ) 1000 1000 { 1001 1001 time_t current_typing_notice = time( NULL ); … … 1003 1003 if( current_typing_notice - u->last_typing_notice >= 5 ) 1004 1004 { 1005 u-> gc->acc->prpl->send_typing( u->gc, u->handle, s[8] == '1' );1005 u->ic->acc->prpl->send_typing( u->ic, u->handle, s[8] == '1' ); 1006 1006 u->last_typing_notice = current_typing_notice; 1007 1007 } … … 1036 1036 } 1037 1037 } 1038 else if( c && c-> gc && c->gc->acc && c->gc->acc->prpl )1039 { 1040 return( bim_chat_msg( c, s ) );1038 else if( c && c->ic && c->ic->acc && c->ic->acc->prpl ) 1039 { 1040 return( bim_chat_msg( c, s, 0 ) ); 1041 1041 } 1042 1042 … … 1053 1053 1054 1054 u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */ 1055 bim_buddy_msg( u-> gc, u->handle, u->sendbuf, u->sendbuf_flags );1055 bim_buddy_msg( u->ic, u->handle, u->sendbuf, u->sendbuf_flags ); 1056 1056 1057 1057 g_free( u->sendbuf ); … … 1066 1066 void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags ) 1067 1067 { 1068 if( !u || !u-> gc ) return;1068 if( !u || !u->ic ) return; 1069 1069 1070 1070 if( set_getbool( &irc->set, "buddy_sendbuffer" ) && set_getint( &irc->set, "buddy_sendbuffer_delay" ) > 0 ) … … 1105 1105 else 1106 1106 { 1107 bim_buddy_msg( u-> gc, u->handle, msg, flags );1107 bim_buddy_msg( u->ic, u->handle, msg, flags ); 1108 1108 } 1109 1109 } -
irc_commands.c
rfa29d093 r0da65d5 134 134 static void irc_cmd_part( irc_t *irc, char **cmd ) 135 135 { 136 struct conversation*c;136 struct groupchat *c; 137 137 138 138 if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) … … 150 150 irc_part( irc, u, c->channel ); 151 151 152 if( c-> gc )152 if( c->ic ) 153 153 { 154 154 c->joined = 0; 155 c-> gc->acc->prpl->chat_leave( c );155 c->ic->acc->prpl->chat_leave( c ); 156 156 } 157 157 } … … 173 173 user_t *u = user_find( irc, cmd[1] + 1 ); 174 174 175 if( u && u-> gc && u->gc->acc->prpl->chat_open)175 if( u && u->ic && u->ic->acc->prpl->chat_with ) 176 176 { 177 177 irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); 178 178 179 if( !u-> gc->acc->prpl->chat_open( u->gc, u->handle ) )179 if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) 180 180 { 181 181 irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); … … 201 201 { 202 202 char *nick = cmd[1], *channel = cmd[2]; 203 struct conversation*c = chat_by_channel( channel );203 struct groupchat *c = chat_by_channel( channel ); 204 204 user_t *u = user_find( irc, nick ); 205 205 206 if( u && c && ( u-> gc == c->gc ) )207 if( c-> gc && c->gc->acc->prpl->chat_invite )208 { 209 c-> gc->acc->prpl->chat_invite( c, "", u->handle );206 if( u && c && ( u->ic == c->ic ) ) 207 if( c->ic && c->ic->acc->prpl->chat_invite ) 208 { 209 c->ic->acc->prpl->chat_invite( c, "", u->handle ); 210 210 irc_reply( irc, 341, "%s %s", nick, channel ); 211 211 return; … … 271 271 char *channel = cmd[1]; 272 272 user_t *u = irc->users; 273 struct conversation*c;273 struct groupchat *c; 274 274 GList *l; 275 275 … … 290 290 for( l = c->in_room; l; l = l->next ) 291 291 { 292 if( ( u = user_findhandle( c-> gc, l->data ) ) )292 if( ( u = user_findhandle( c->ic, l->data ) ) ) 293 293 irc_reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); 294 294 } … … 460 460 for( a = irc->accounts; a; a = a->next ) 461 461 { 462 struct gaim_connection *gc = a->gc;463 464 if( gc && gc->flags & OPT_LOGGED_IN )465 bim_set_away( gc, u->away );462 struct im_connection *ic = a->ic; 463 464 if( ic && ic->flags & OPT_LOGGED_IN ) 465 bim_set_away( ic, u->away ); 466 466 } 467 467 } … … 476 476 irc_reply( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname ); 477 477 478 if( u-> gc )479 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u-> gc->acc->user,480 u-> gc->acc->server && *u->gc->acc->server ? u->gc->acc->server : "",481 u-> gc->acc->prpl->name );478 if( u->ic ) 479 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user, 480 u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "", 481 u->ic->acc->prpl->name ); 482 482 else 483 483 irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); -
protocols/jabber/io.c
rfa29d093 r0da65d5 26 26 27 27 static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond ); 28 static gboolean jabber_write_queue( struct gaim_connection *gc );29 30 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node )28 static gboolean jabber_write_queue( struct im_connection *ic ); 29 30 int jabber_write_packet( struct im_connection *ic, struct xt_node *node ) 31 31 { 32 32 char *buf; … … 34 34 35 35 buf = xt_to_string( node ); 36 st = jabber_write( gc, buf, strlen( buf ) );36 st = jabber_write( ic, buf, strlen( buf ) ); 37 37 g_free( buf ); 38 38 … … 40 40 } 41 41 42 int jabber_write( struct gaim_connection *gc, char *buf, int len )43 { 44 struct jabber_data *jd = gc->proto_data;42 int jabber_write( struct im_connection *ic, char *buf, int len ) 43 { 44 struct jabber_data *jd = ic->proto_data; 45 45 gboolean ret; 46 46 … … 54 54 it via the event handler. If not, add the handler. (In 55 55 most cases it probably won't be necessary.) */ 56 if( ( ret = jabber_write_queue( gc ) ) && jd->tx_len > 0 )57 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, gc );56 if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 ) 57 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic ); 58 58 } 59 59 else … … 85 85 static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond ) 86 86 { 87 struct jabber_data *jd = ((struct gaim_connection *)data)->proto_data;87 struct jabber_data *jd = ((struct im_connection *)data)->proto_data; 88 88 89 89 return jd->fd != -1 && … … 92 92 } 93 93 94 static gboolean jabber_write_queue( struct gaim_connection *gc )95 { 96 struct jabber_data *jd = gc->proto_data;94 static gboolean jabber_write_queue( struct im_connection *ic ) 95 { 96 struct jabber_data *jd = ic->proto_data; 97 97 int st; 98 98 … … 117 117 jd->fd = -1; 118 118 119 hide_login_progress_error( gc, "Short write() to server" );120 signoff( gc );119 hide_login_progress_error( ic, "Short write() to server" ); 120 signoff( ic ); 121 121 return FALSE; 122 122 } … … 142 142 static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition cond ) 143 143 { 144 struct gaim_connection *gc = data;145 struct jabber_data *jd = gc->proto_data;144 struct im_connection *ic = data; 145 struct jabber_data *jd = ic->proto_data; 146 146 char buf[512]; 147 147 int st; … … 160 160 if( xt_feed( jd->xt, buf, st ) < 0 ) 161 161 { 162 hide_login_progress_error( gc, "XML stream error" );163 signoff( gc );162 hide_login_progress_error( ic, "XML stream error" ); 163 signoff( ic ); 164 164 return FALSE; 165 165 } … … 176 176 { 177 177 jd->flags &= ~JFLAG_STREAM_RESTART; 178 jabber_start_stream( gc );178 jabber_start_stream( ic ); 179 179 } 180 180 … … 196 196 this is an old server that can't do SASL 197 197 authentication. */ 198 if( !sasl_supported( gc ) )198 if( !sasl_supported( ic ) ) 199 199 { 200 200 /* If there's no version= tag, we suppose 201 201 this server does NOT implement: XMPP 1.0, 202 202 SASL and TLS. */ 203 if( set_getbool( & gc->acc->set, "tls" ) )203 if( set_getbool( &ic->acc->set, "tls" ) ) 204 204 { 205 hide_login_progress( gc, "TLS is turned on for this "205 hide_login_progress( ic, "TLS is turned on for this " 206 206 "account, but is not supported by this server" ); 207 signoff( gc );207 signoff( ic ); 208 208 return FALSE; 209 209 } 210 210 else 211 211 { 212 return jabber_init_iq_auth( gc );212 return jabber_init_iq_auth( ic ); 213 213 } 214 214 } … … 216 216 else 217 217 { 218 hide_login_progress( gc, "XML stream error" );219 signoff( gc );218 hide_login_progress( ic, "XML stream error" ); 219 signoff( ic ); 220 220 return FALSE; 221 221 } … … 227 227 jd->fd = -1; 228 228 229 hide_login_progress_error( gc, "Error while reading from server" );230 signoff( gc );229 hide_login_progress_error( ic, "Error while reading from server" ); 230 signoff( ic ); 231 231 return FALSE; 232 232 } … … 238 238 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond ) 239 239 { 240 struct gaim_connection *gc = data;240 struct im_connection *ic = data; 241 241 242 242 if( source == -1 ) 243 243 { 244 hide_login_progress( gc, "Could not connect to server" );245 signoff( gc );244 hide_login_progress( ic, "Could not connect to server" ); 245 signoff( ic ); 246 246 return FALSE; 247 247 } 248 248 249 set_login_progress( gc, 1, "Connected to server, logging in" );250 251 return jabber_start_stream( gc );249 set_login_progress( ic, 1, "Connected to server, logging in" ); 250 251 return jabber_start_stream( ic ); 252 252 } 253 253 254 254 gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond ) 255 255 { 256 struct gaim_connection *gc = data;257 struct jabber_data *jd = gc->proto_data;256 struct im_connection *ic = data; 257 struct jabber_data *jd = ic->proto_data; 258 258 259 259 if( source == NULL ) … … 263 263 jd->ssl = NULL; 264 264 265 hide_login_progress( gc, "Could not connect to server" );266 signoff( gc );265 hide_login_progress( ic, "Could not connect to server" ); 266 signoff( ic ); 267 267 return FALSE; 268 268 } 269 269 270 set_login_progress( gc, 1, "Connected to server, logging in" );271 272 return jabber_start_stream( gc );270 set_login_progress( ic, 1, "Connected to server, logging in" ); 271 272 return jabber_start_stream( ic ); 273 273 } 274 274 … … 281 281 static xt_status jabber_pkt_features( struct xt_node *node, gpointer data ) 282 282 { 283 struct gaim_connection *gc = data;284 struct jabber_data *jd = gc->proto_data;283 struct im_connection *ic = data; 284 struct jabber_data *jd = ic->proto_data; 285 285 struct xt_node *c, *reply; 286 286 int trytls; 287 287 288 trytls = g_strcasecmp( set_getstr( & gc->acc->set, "tls" ), "try" ) == 0;288 trytls = g_strcasecmp( set_getstr( &ic->acc->set, "tls" ), "try" ) == 0; 289 289 c = xt_find_node( node->children, "starttls" ); 290 290 if( c && !jd->ssl ) … … 295 295 c = xt_find_node( c->children, "required" ); 296 296 297 if( c && ( !trytls && !set_getbool( & gc->acc->set, "tls" ) ) )298 { 299 hide_login_progress( gc, "Server requires TLS connections, but TLS is turned off for this account" );300 signoff( gc );297 if( c && ( !trytls && !set_getbool( &ic->acc->set, "tls" ) ) ) 298 { 299 hide_login_progress( ic, "Server requires TLS connections, but TLS is turned off for this account" ); 300 signoff( ic ); 301 301 302 302 return XT_ABORT; … … 304 304 305 305 /* Only run this if the tls setting is set to true or try: */ 306 if( ( trytls || set_getbool( & gc->acc->set, "tls" ) ) )306 if( ( trytls || set_getbool( &ic->acc->set, "tls" ) ) ) 307 307 { 308 308 reply = xt_new_node( "starttls", NULL, NULL ); 309 309 xt_add_attr( reply, "xmlns", XMLNS_TLS ); 310 if( !jabber_write_packet( gc, reply ) )310 if( !jabber_write_packet( ic, reply ) ) 311 311 { 312 312 xt_free_node( reply ); … … 325 325 using SSL/TLS. */ 326 326 327 if( !trytls && set_getbool( & gc->acc->set, "tls" ) )328 { 329 hide_login_progress( gc, "TLS is turned on for this account, but is not supported by this server" );330 signoff( gc );327 if( !trytls && set_getbool( &ic->acc->set, "tls" ) ) 328 { 329 hide_login_progress( ic, "TLS is turned on for this account, but is not supported by this server" ); 330 signoff( ic ); 331 331 332 332 return XT_ABORT; … … 346 346 other way. jabber.com doesn't seem to do SASL while it pretends 347 347 to be XMPP 1.0 compliant! */ 348 else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( gc ) )349 { 350 if( !jabber_init_iq_auth( gc ) )348 else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( ic ) ) 349 { 350 if( !jabber_init_iq_auth( ic ) ) 351 351 return XT_ABORT; 352 352 } … … 354 354 if( ( c = xt_find_node( node->children, "bind" ) ) ) 355 355 { 356 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( & gc->acc->set, "resource" ), NULL ) );356 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); 357 357 xt_add_attr( reply, "xmlns", XMLNS_BIND ); 358 358 reply = jabber_make_packet( "iq", "set", NULL, reply ); 359 jabber_cache_add( gc, reply, jabber_pkt_bind_sess );360 361 if( !jabber_write_packet( gc, reply ) )359 jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); 360 361 if( !jabber_write_packet( ic, reply ) ) 362 362 return XT_ABORT; 363 363 … … 370 370 xt_add_attr( reply, "xmlns", XMLNS_SESSION ); 371 371 reply = jabber_make_packet( "iq", "set", NULL, reply ); 372 jabber_cache_add( gc, reply, jabber_pkt_bind_sess );373 374 if( !jabber_write_packet( gc, reply ) )372 jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); 373 374 if( !jabber_write_packet( ic, reply ) ) 375 375 return XT_ABORT; 376 376 … … 383 383 if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 384 384 { 385 if( !jabber_get_roster( gc ) )385 if( !jabber_get_roster( ic ) ) 386 386 return XT_ABORT; 387 387 } … … 392 392 static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data ) 393 393 { 394 struct gaim_connection *gc = data;395 struct jabber_data *jd = gc->proto_data;394 struct im_connection *ic = data; 395 struct jabber_data *jd = ic->proto_data; 396 396 char *xmlns; 397 397 … … 417 417 jd->w_inpa = jd->r_inpa = 0; 418 418 419 set_login_progress( gc, 1, "Converting stream to TLS" );420 421 jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, gc );419 set_login_progress( ic, 1, "Converting stream to TLS" ); 420 421 jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic ); 422 422 423 423 return XT_HANDLED; … … 426 426 static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data ) 427 427 { 428 struct gaim_connection *gc = data;428 struct im_connection *ic = data; 429 429 struct xt_node *c; 430 430 char *s, *type = NULL, *text = NULL; … … 452 452 if( type == NULL ) 453 453 { 454 hide_login_progress_error( gc, "Unknown stream error reported by server" );455 signoff( gc );454 hide_login_progress_error( ic, "Unknown stream error reported by server" ); 455 signoff( ic ); 456 456 return XT_ABORT; 457 457 } … … 462 462 if( strcmp( type, "conflict" ) == 0 ) 463 463 { 464 hide_login_progress( gc, "Account and resource used from a different location" );465 gc->wants_to_die = TRUE;464 hide_login_progress( ic, "Account and resource used from a different location" ); 465 ic->wants_to_die = TRUE; 466 466 } 467 467 else 468 468 { 469 469 s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" ); 470 hide_login_progress_error( gc, s );470 hide_login_progress_error( ic, s ); 471 471 g_free( s ); 472 472 } 473 473 474 signoff( gc );474 signoff( ic ); 475 475 476 476 return XT_ABORT; … … 500 500 }; 501 501 502 gboolean jabber_start_stream( struct gaim_connection *gc )503 { 504 struct jabber_data *jd = gc->proto_data;502 gboolean jabber_start_stream( struct im_connection *ic ) 503 { 504 struct jabber_data *jd = ic->proto_data; 505 505 int st; 506 506 char *greet; … … 509 509 from the server too. */ 510 510 xt_free( jd->xt ); /* In case we're RE-starting. */ 511 jd->xt = xt_new( gc );511 jd->xt = xt_new( ic ); 512 512 jd->xt->handlers = (struct xt_handler_entry*) jabber_handlers; 513 513 514 514 if( jd->r_inpa <= 0 ) 515 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, gc );515 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic ); 516 516 517 517 greet = g_strdup_printf( "<?xml version='1.0' ?>" … … 519 519 "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", jd->server ); 520 520 521 st = jabber_write( gc, greet, strlen( greet ) );521 st = jabber_write( ic, greet, strlen( greet ) ); 522 522 523 523 g_free( greet ); … … 526 526 } 527 527 528 void jabber_end_stream( struct gaim_connection *gc )529 { 530 struct jabber_data *jd = gc->proto_data;528 void jabber_end_stream( struct im_connection *ic ) 529 { 530 struct jabber_data *jd = ic->proto_data; 531 531 532 532 /* Let's only do this if the queue is currently empty, otherwise it'd … … 538 538 int st = 1; 539 539 540 if( gc->flags & OPT_LOGGED_IN )540 if( ic->flags & OPT_LOGGED_IN ) 541 541 { 542 542 node = jabber_make_packet( "presence", "unavailable", NULL, NULL ); 543 st = jabber_write_packet( gc, node );543 st = jabber_write_packet( ic, node ); 544 544 xt_free_node( node ); 545 545 } 546 546 547 547 if( st ) 548 jabber_write( gc, eos, strlen( eos ) );549 } 550 } 548 jabber_write( ic, eos, strlen( eos ) ); 549 } 550 } -
protocols/jabber/iq.c
rfa29d093 r0da65d5 24 24 #include "jabber.h" 25 25 26 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );27 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );26 static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 27 static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 28 28 29 29 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) 30 30 { 31 struct gaim_connection *gc = data;32 struct jabber_data *jd = gc->proto_data;31 struct im_connection *ic = data; 32 struct jabber_data *jd = ic->proto_data; 33 33 struct xt_node *c, *reply = NULL; 34 34 char *type, *s; … … 39 39 if( !type ) 40 40 { 41 hide_login_progress_error( gc, "Received IQ packet without type." );42 signoff( gc );41 hide_login_progress_error( ic, "Received IQ packet without type." ); 42 signoff( ic ); 43 43 return XT_ABORT; 44 44 } … … 60 60 61 61 if( entry == NULL ) 62 serv_got_crap( gc, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );62 serv_got_crap( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s ); 63 63 else if( entry->func ) 64 return entry->func( gc, node, entry->node );64 return entry->func( ic, node, entry->node ); 65 65 } 66 66 else if( strcmp( type, "get" ) == 0 ) … … 69 69 !( s = xt_find_attr( c, "xmlns" ) ) ) 70 70 { 71 serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );71 serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type ); 72 72 return XT_HANDLED; 73 73 } … … 132 132 !( s = xt_find_attr( c, "xmlns" ) ) ) 133 133 { 134 serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );134 serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type ); 135 135 return XT_HANDLED; 136 136 } … … 141 141 if( strcmp( s, XMLNS_ROSTER ) == 0 ) 142 142 { 143 int bare_len = strlen( gc->acc->user );143 int bare_len = strlen( ic->acc->user ); 144 144 145 145 if( ( s = xt_find_attr( node, "from" ) ) == NULL || 146 ( strncmp( s, gc->acc->user, bare_len ) == 0 &&146 ( strncmp( s, ic->acc->user, bare_len ) == 0 && 147 147 ( s[bare_len] == 0 || s[bare_len] == '/' ) ) ) 148 148 { 149 jabber_parse_roster( gc, node, NULL );149 jabber_parse_roster( ic, node, NULL ); 150 150 151 151 /* Should we generate a reply here? Don't think it's … … 154 154 else 155 155 { 156 serv_got_crap( gc, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );156 serv_got_crap( ic, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" ); 157 157 158 158 xt_free_node( reply ); … … 182 182 } 183 183 184 st = jabber_write_packet( gc, reply );184 st = jabber_write_packet( ic, reply ); 185 185 xt_free_node( reply ); 186 186 if( !st ) … … 191 191 } 192 192 193 static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );194 static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );195 196 int jabber_init_iq_auth( struct gaim_connection *gc )197 { 198 struct jabber_data *jd = gc->proto_data;193 static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 194 static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 195 196 int jabber_init_iq_auth( struct im_connection *ic ) 197 { 198 struct jabber_data *jd = ic->proto_data; 199 199 struct xt_node *node; 200 200 int st; … … 204 204 node = jabber_make_packet( "iq", "get", NULL, node ); 205 205 206 jabber_cache_add( gc, node, jabber_do_iq_auth );207 st = jabber_write_packet( gc, node );206 jabber_cache_add( ic, node, jabber_do_iq_auth ); 207 st = jabber_write_packet( ic, node ); 208 208 209 209 return st; 210 210 } 211 211 212 static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )213 { 214 struct jabber_data *jd = gc->proto_data;212 static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 213 { 214 struct jabber_data *jd = ic->proto_data; 215 215 struct xt_node *reply, *query; 216 216 xt_status st; … … 219 219 if( !( query = xt_find_node( node->children, "query" ) ) ) 220 220 { 221 serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );222 signoff( gc );221 serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" ); 222 signoff( ic ); 223 223 return XT_HANDLED; 224 224 } … … 228 228 xt_add_attr( reply, "xmlns", XMLNS_AUTH ); 229 229 xt_add_child( reply, xt_new_node( "username", jd->username, NULL ) ); 230 xt_add_child( reply, xt_new_node( "resource", set_getstr( & gc->acc->set, "resource" ), NULL ) );230 xt_add_child( reply, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); 231 231 232 232 if( xt_find_node( query->children, "digest" ) && ( s = xt_find_attr( jd->xt->root, "id" ) ) ) … … 241 241 shaInit( &sha ); 242 242 shaUpdate( &sha, (unsigned char*) s, strlen( s ) ); 243 shaUpdate( &sha, (unsigned char*) gc->acc->pass, strlen( gc->acc->pass ) );243 shaUpdate( &sha, (unsigned char*) ic->acc->pass, strlen( ic->acc->pass ) ); 244 244 shaFinal( &sha, hash ); 245 245 … … 252 252 { 253 253 /* We'll have to stick with plaintext. Let's hope we're using SSL/TLS... */ 254 xt_add_child( reply, xt_new_node( "password", gc->acc->pass, NULL ) );254 xt_add_child( reply, xt_new_node( "password", ic->acc->pass, NULL ) ); 255 255 } 256 256 else … … 258 258 xt_free_node( reply ); 259 259 260 hide_login_progress( gc, "Can't find suitable authentication method" );261 signoff( gc );260 hide_login_progress( ic, "Can't find suitable authentication method" ); 261 signoff( ic ); 262 262 return XT_ABORT; 263 263 } 264 264 265 265 reply = jabber_make_packet( "iq", "set", NULL, reply ); 266 jabber_cache_add( gc, reply, jabber_finish_iq_auth );267 st = jabber_write_packet( gc, reply );266 jabber_cache_add( ic, reply, jabber_finish_iq_auth ); 267 st = jabber_write_packet( ic, reply ); 268 268 269 269 return st ? XT_HANDLED : XT_ABORT; 270 270 } 271 271 272 static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )273 { 274 struct jabber_data *jd = gc->proto_data;272 static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 273 { 274 struct jabber_data *jd = ic->proto_data; 275 275 char *type; 276 276 277 277 if( !( type = xt_find_attr( node, "type" ) ) ) 278 278 { 279 serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );280 signoff( gc );279 serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" ); 280 signoff( ic ); 281 281 return XT_HANDLED; 282 282 } … … 284 284 if( strcmp( type, "error" ) == 0 ) 285 285 { 286 hide_login_progress( gc, "Authentication failure" );287 signoff( gc );286 hide_login_progress( ic, "Authentication failure" ); 287 signoff( ic ); 288 288 return XT_ABORT; 289 289 } … … 293 293 old (non-SASL) way. */ 294 294 jd->flags |= JFLAG_AUTHENTICATED; 295 if( !jabber_get_roster( gc ) )295 if( !jabber_get_roster( ic ) ) 296 296 return XT_ABORT; 297 297 } … … 300 300 } 301 301 302 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )303 { 304 struct jabber_data *jd = gc->proto_data;302 xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 303 { 304 struct jabber_data *jd = ic->proto_data; 305 305 struct xt_node *c; 306 306 char *s; … … 310 310 c = xt_find_node( c->children, "jid" ); 311 311 if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && 312 strcmp( s + 1, set_getstr( & gc->acc->set, "resource" ) ) != 0 )313 serv_got_crap( gc, "Server changed session resource string to `%s'", s + 1 );312 strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) 313 serv_got_crap( ic, "Server changed session resource string to `%s'", s + 1 ); 314 314 315 315 jd->flags &= ~JFLAG_WAIT_BIND; … … 322 322 if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 323 323 { 324 if( !jabber_get_roster( gc ) )324 if( !jabber_get_roster( ic ) ) 325 325 return XT_ABORT; 326 326 } … … 329 329 } 330 330 331 int jabber_get_roster( struct gaim_connection *gc )331 int jabber_get_roster( struct im_connection *ic ) 332 332 { 333 333 struct xt_node *node; 334 334 int st; 335 335 336 set_login_progress( gc, 1, "Authenticated, requesting buddy list" );336 set_login_progress( ic, 1, "Authenticated, requesting buddy list" ); 337 337 338 338 node = xt_new_node( "query", NULL, NULL ); … … 340 340 node = jabber_make_packet( "iq", "get", NULL, node ); 341 341 342 jabber_cache_add( gc, node, jabber_parse_roster );343 st = jabber_write_packet( gc, node );342 jabber_cache_add( ic, node, jabber_parse_roster ); 343 st = jabber_write_packet( ic, node ); 344 344 345 345 return st; 346 346 } 347 347 348 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )348 static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 349 349 { 350 350 struct xt_node *query, *c; … … 353 353 if( !( query = xt_find_node( node->children, "query" ) ) ) 354 354 { 355 serv_got_crap( gc, "WARNING: Received NULL roster packet" );355 serv_got_crap( ic, "WARNING: Received NULL roster packet" ); 356 356 return XT_HANDLED; 357 357 } … … 371 371 { 372 372 if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) 373 add_buddy( gc, NULL, jid, name );373 add_buddy( ic, NULL, jid, name ); 374 374 } 375 375 else … … 378 378 if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) 379 379 { 380 if( find_buddy( gc, jid ) == NULL )381 add_buddy( gc, NULL, jid, name );380 if( find_buddy( ic, jid ) == NULL ) 381 add_buddy( ic, NULL, jid, name ); 382 382 else if( name ) 383 serv_buddy_rename( gc, jid, name );383 serv_buddy_rename( ic, jid, name ); 384 384 } 385 385 else if( strcmp( sub, "remove" ) == 0 ) … … 387 387 /* Don't have any API call for this yet! So let's 388 388 just try to handle this as well as we can. */ 389 jabber_buddy_remove_bare( gc, jid );390 serv_got_update( gc, jid, 0, 0, 0, 0, 0, 0 );389 jabber_buddy_remove_bare( ic, jid ); 390 serv_got_update( ic, jid, 0, 0, 0, 0, 0, 0 ); 391 391 /* FIXME! */ 392 392 } … … 397 397 398 398 if( initial ) 399 account_online( gc );399 account_online( ic ); 400 400 401 401 return XT_HANDLED; 402 402 } 403 403 404 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )404 int jabber_get_vcard( struct im_connection *ic, char *bare_jid ) 405 405 { 406 406 struct xt_node *node; … … 413 413 node = jabber_make_packet( "iq", "get", bare_jid, node ); 414 414 415 jabber_cache_add( gc, node, jabber_iq_display_vcard );416 return jabber_write_packet( gc, node );417 } 418 419 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )420 { 421 struct xt_node *vc, *c, *sc; /* subchild, gc is already in use ;-) */415 jabber_cache_add( ic, node, jabber_iq_display_vcard ); 416 return jabber_write_packet( ic, node ); 417 } 418 419 static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 420 { 421 struct xt_node *vc, *c, *sc; /* subchild, ic is already in use ;-) */ 422 422 GString *reply; 423 423 char *s; … … 428 428 { 429 429 s = xt_find_attr( orig, "to" ); /* If this returns NULL something's wrong.. */ 430 serv_got_crap( gc, "Could not retrieve vCard of %s", s ? s : "(NULL)" );430 serv_got_crap( ic, "Could not retrieve vCard of %s", s ? s : "(NULL)" ); 431 431 return XT_HANDLED; 432 432 } … … 536 536 /* *sigh* */ 537 537 538 serv_got_crap( gc, reply->str );538 serv_got_crap( ic, reply->str ); 539 539 g_string_free( reply, TRUE ); 540 540 … … 542 542 } 543 543 544 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )544 int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ) 545 545 { 546 546 struct xt_node *node; … … 558 558 node = jabber_make_packet( "iq", "set", NULL, node ); 559 559 560 st = jabber_write_packet( gc, node );560 st = jabber_write_packet( ic, node ); 561 561 562 562 xt_free_node( node ); … … 564 564 } 565 565 566 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )566 int jabber_remove_from_roster( struct im_connection *ic, char *handle ) 567 567 { 568 568 struct xt_node *node; … … 579 579 node = jabber_make_packet( "iq", "set", NULL, node ); 580 580 581 st = jabber_write_packet( gc, node );581 st = jabber_write_packet( ic, node ); 582 582 583 583 xt_free_node( node ); -
protocols/jabber/jabber.c
rfa29d093 r0da65d5 33 33 #include "jabber.h" 34 34 35 static void jabber_ acc_init( account_t *acc )35 static void jabber_init( account_t *acc ) 36 36 { 37 37 set_t *s; … … 59 59 static void jabber_login( account_t *acc ) 60 60 { 61 struct gaim_connection *gc = new_gaim_conn( acc );61 struct im_connection *ic = new_gaim_conn( acc ); 62 62 struct jabber_data *jd = g_new0( struct jabber_data, 1 ); 63 63 struct ns_srv_reply *srv = NULL; 64 64 char *connect_to, *s; 65 65 66 jd-> gc = gc;67 gc->proto_data = jd;66 jd->ic = ic; 67 ic->proto_data = jd; 68 68 69 69 jd->username = g_strdup( acc->user ); … … 72 72 if( jd->server == NULL ) 73 73 { 74 hide_login_progress( gc, "Incomplete account name (format it like <username@jabberserver.name>)" );75 signoff( gc );74 hide_login_progress( ic, "Incomplete account name (format it like <username@jabberserver.name>)" ); 75 signoff( ic ); 76 76 return; 77 77 } … … 159 159 connect_to = jd->server; 160 160 161 set_login_progress( gc, 0, "Connecting" );161 set_login_progress( ic, 0, "Connecting" ); 162 162 163 163 if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN || 164 164 set_getint( &acc->set, "port" ) > JABBER_PORT_MAX ) 165 165 { 166 serv_got_crap( gc, "Incorrect port number, must be in the %d-%d range",166 serv_got_crap( ic, "Incorrect port number, must be in the %d-%d range", 167 167 JABBER_PORT_MIN, JABBER_PORT_MAX ); 168 signoff( gc );168 signoff( ic ); 169 169 return; 170 170 } … … 175 175 if( set_getbool( &acc->set, "ssl" ) ) 176 176 { 177 jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );177 jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, ic ); 178 178 jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1; 179 179 } 180 180 else 181 181 { 182 jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, gc );182 jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic ); 183 183 } 184 184 g_free( srv ); … … 186 186 if( jd->fd == -1 ) 187 187 { 188 hide_login_progress( gc, "Could not connect to server" );189 signoff( gc );190 } 191 } 192 193 static void jabber_ close( struct gaim_connection *gc )194 { 195 struct jabber_data *jd = gc->proto_data;196 197 jabber_end_stream( gc );188 hide_login_progress( ic, "Could not connect to server" ); 189 signoff( ic ); 190 } 191 } 192 193 static void jabber_logout( struct im_connection *ic ) 194 { 195 struct jabber_data *jd = ic->proto_data; 196 197 jabber_end_stream( ic ); 198 198 199 199 if( jd->r_inpa >= 0 ) … … 219 219 } 220 220 221 static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away)222 { 223 struct jabber_data *jd = gc->proto_data;221 static int jabber_send_im( struct im_connection *ic, char *who, char *message, int flags ) 222 { 223 struct jabber_data *jd = ic->proto_data; 224 224 struct jabber_buddy *bud; 225 225 struct xt_node *node; 226 226 int st; 227 227 228 bud = jabber_buddy_by_jid( gc, who, 0 );228 bud = jabber_buddy_by_jid( ic, who, 0 ); 229 229 230 230 node = xt_new_node( "body", message, NULL ); … … 251 251 } 252 252 253 st = jabber_write_packet( gc, node );253 st = jabber_write_packet( ic, node ); 254 254 xt_free_node( node ); 255 255 … … 257 257 } 258 258 259 static GList *jabber_away_states( struct gaim_connection *gc )259 static GList *jabber_away_states( struct im_connection *ic ) 260 260 { 261 261 static GList *l = NULL; … … 269 269 } 270 270 271 static void jabber_get_info( struct gaim_connection *gc, char *who )272 { 273 struct jabber_data *jd = gc->proto_data;271 static void jabber_get_info( struct im_connection *ic, char *who ) 272 { 273 struct jabber_data *jd = ic->proto_data; 274 274 struct jabber_buddy *bud; 275 275 276 276 if( strchr( who, '/' ) ) 277 bud = jabber_buddy_by_jid( gc, who, 0 );277 bud = jabber_buddy_by_jid( ic, who, 0 ); 278 278 else 279 279 { … … 285 285 while( bud ) 286 286 { 287 serv_got_crap( gc, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",287 serv_got_crap( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s", 288 288 bud->full_jid, bud->priority, 289 289 bud->away_state ? bud->away_state->full_name : "(none)", … … 292 292 } 293 293 294 jabber_get_vcard( gc, bud ? bud->full_jid : who );295 } 296 297 static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *message )298 { 299 struct jabber_data *jd = gc->proto_data;294 jabber_get_vcard( ic, bud ? bud->full_jid : who ); 295 } 296 297 static void jabber_set_away( struct im_connection *ic, char *state_txt, char *message ) 298 { 299 struct jabber_data *jd = ic->proto_data; 300 300 struct jabber_away_state *state; 301 301 … … 306 306 jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL; 307 307 308 presence_send_update( gc );309 } 310 311 static void jabber_add_buddy( struct gaim_connection *gc, char *who)312 { 313 if( jabber_add_to_roster( gc, who, NULL ) )314 presence_send_request( gc, who, "subscribe" );315 } 316 317 static void jabber_remove_buddy( struct gaim_connection *gc, char *who, char *group )308 presence_send_update( ic ); 309 } 310 311 static void jabber_add_buddy( struct im_connection *ic, char *who, char *group ) 312 { 313 if( jabber_add_to_roster( ic, who, NULL ) ) 314 presence_send_request( ic, who, "subscribe" ); 315 } 316 317 static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group ) 318 318 { 319 319 /* We should always do this part. Clean up our administration a little bit. */ 320 jabber_buddy_remove_bare( gc, who );321 322 if( jabber_remove_from_roster( gc, who ) )323 presence_send_request( gc, who, "unsubscribe" );324 } 325 326 static void jabber_keepalive( struct gaim_connection *gc )320 jabber_buddy_remove_bare( ic, who ); 321 322 if( jabber_remove_from_roster( ic, who ) ) 323 presence_send_request( ic, who, "unsubscribe" ); 324 } 325 326 static void jabber_keepalive( struct im_connection *ic ) 327 327 { 328 328 /* Just any whitespace character is enough as a keepalive for XMPP sessions. */ 329 jabber_write( gc, "\n", 1 );329 jabber_write( ic, "\n", 1 ); 330 330 331 331 /* This runs the garbage collection every minute, which means every packet 332 332 is in the cache for about a minute (which should be enough AFAIK). */ 333 jabber_cache_clean( gc );334 } 335 336 static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing )337 { 338 struct jabber_data *jd = gc->proto_data;333 jabber_cache_clean( ic ); 334 } 335 336 static int jabber_send_typing( struct im_connection *ic, char *who, int typing ) 337 { 338 struct jabber_data *jd = ic->proto_data; 339 339 struct jabber_buddy *bud; 340 340 … … 342 342 jd->flags |= JFLAG_WANT_TYPING; 343 343 344 if( ( bud = jabber_buddy_by_jid( gc, who, 0 ) ) == NULL )344 if( ( bud = jabber_buddy_by_jid( ic, who, 0 ) ) == NULL ) 345 345 { 346 346 /* Sending typing notifications to unknown buddies is … … 369 369 node = jabber_make_packet( "message", "chat", bud->full_jid, node ); 370 370 371 st = jabber_write_packet( gc, node );371 st = jabber_write_packet( ic, node ); 372 372 xt_free_node( node ); 373 373 … … 378 378 } 379 379 380 void jabber_init ()380 void jabber_initmodule() 381 381 { 382 382 struct prpl *ret = g_new0( struct prpl, 1 ); … … 384 384 ret->name = "jabber"; 385 385 ret->login = jabber_login; 386 ret-> acc_init = jabber_acc_init;387 ret-> close = jabber_close;386 ret->init = jabber_init; 387 ret->logout = jabber_logout; 388 388 ret->send_im = jabber_send_im; 389 389 ret->away_states = jabber_away_states; -
protocols/jabber/jabber.h
rfa29d093 r0da65d5 58 58 struct jabber_data 59 59 { 60 struct gaim_connection *gc;60 struct im_connection *ic; 61 61 62 62 int fd; … … 87 87 }; 88 88 89 typedef xt_status (*jabber_cache_event) ( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );89 typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 90 90 91 91 struct jabber_cache_entry … … 137 137 /* iq.c */ 138 138 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); 139 int jabber_init_iq_auth( struct gaim_connection *gc );140 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );141 int jabber_get_roster( struct gaim_connection *gc );142 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid );143 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );144 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );139 int jabber_init_iq_auth( struct im_connection *ic ); 140 xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 141 int jabber_get_roster( struct im_connection *ic ); 142 int jabber_get_vcard( struct im_connection *ic, char *bare_jid ); 143 int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ); 144 int jabber_remove_from_roster( struct im_connection *ic, char *handle ); 145 145 146 146 /* message.c */ … … 149 149 /* presence.c */ 150 150 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ); 151 int presence_send_update( struct gaim_connection *gc );152 int presence_send_request( struct gaim_connection *gc, char *handle, char *request );151 int presence_send_update( struct im_connection *ic ); 152 int presence_send_request( struct im_connection *ic, char *handle, char *request ); 153 153 154 154 /* jabber_util.c */ … … 157 157 struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children ); 158 158 struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type ); 159 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func );160 struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id );159 void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func ); 160 struct xt_node *jabber_cache_get( struct im_connection *ic, char *id ); 161 161 void jabber_cache_entry_free( gpointer entry ); 162 void jabber_cache_clean( struct gaim_connection *gc );162 void jabber_cache_clean( struct im_connection *ic ); 163 163 const struct jabber_away_state *jabber_away_state_by_code( char *code ); 164 164 const struct jabber_away_state *jabber_away_state_by_name( char *name ); 165 void jabber_buddy_ask( struct gaim_connection *gc, char *handle );165 void jabber_buddy_ask( struct im_connection *ic, char *handle ); 166 166 char *jabber_normalize( char *orig ); 167 167 … … 172 172 } get_buddy_flags_t; 173 173 174 struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid );175 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid, get_buddy_flags_t flags );176 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid );177 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid );174 struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid ); 175 struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags ); 176 int jabber_buddy_remove( struct im_connection *ic, char *full_jid ); 177 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ); 178 178 179 179 extern const struct jabber_away_state jabber_away_state_list[]; 180 180 181 181 /* io.c */ 182 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );183 int jabber_write( struct gaim_connection *gc, char *buf, int len );182 int jabber_write_packet( struct im_connection *ic, struct xt_node *node ); 183 int jabber_write( struct im_connection *ic, char *buf, int len ); 184 184 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond ); 185 185 gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond ); 186 gboolean jabber_start_stream( struct gaim_connection *gc );187 void jabber_end_stream( struct gaim_connection *gc );186 gboolean jabber_start_stream( struct im_connection *ic ); 187 void jabber_end_stream( struct im_connection *ic ); 188 188 189 189 /* sasl.c */ … … 191 191 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ); 192 192 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ); 193 gboolean sasl_supported( struct gaim_connection *gc );193 gboolean sasl_supported( struct im_connection *ic ); 194 194 195 195 #endif -
protocols/jabber/jabber_util.c
rfa29d093 r0da65d5 42 42 /* Only run this stuff if the account is online ATM, 43 43 and if the setting seems to be acceptable. */ 44 if( acc-> gc )44 if( acc->ic ) 45 45 { 46 46 /* Although set_eval functions usually are very nice and … … 58 58 /* (Yes, sorry, I prefer the hack. :-P) */ 59 59 60 presence_send_update( acc-> gc );60 presence_send_update( acc->ic ); 61 61 } 62 62 … … 130 130 them when you receive the response. Use this BEFORE sending the packet so 131 131 it'll get a new id= tag, and do NOT free() the packet after writing it! */ 132 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )133 { 134 struct jabber_data *jd = gc->proto_data;132 void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func ) 133 { 134 struct jabber_data *jd = ic->proto_data; 135 135 char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff ); 136 136 struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 ); … … 159 159 node should be available in the cache for at least a minute (assuming the 160 160 function is indeed called every minute). */ 161 void jabber_cache_clean( struct gaim_connection *gc )162 { 163 struct jabber_data *jd = gc->proto_data;161 void jabber_cache_clean( struct im_connection *ic ) 162 { 163 struct jabber_data *jd = ic->proto_data; 164 164 165 165 g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL ); … … 214 214 struct jabber_buddy_ask_data 215 215 { 216 struct gaim_connection *gc;216 struct im_connection *ic; 217 217 char *handle; 218 218 char *realname; … … 221 221 static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla ) 222 222 { 223 presence_send_request( bla-> gc, bla->handle, "subscribed" );224 225 if( find_buddy( bla-> gc, bla->handle ) == NULL )226 show_got_added( bla-> gc, bla->handle, NULL );223 presence_send_request( bla->ic, bla->handle, "subscribed" ); 224 225 if( find_buddy( bla->ic, bla->handle ) == NULL ) 226 show_got_added( bla->ic, bla->handle, NULL ); 227 227 228 228 g_free( bla->handle ); … … 232 232 static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla ) 233 233 { 234 presence_send_request( bla-> gc, bla->handle, "subscribed" );234 presence_send_request( bla->ic, bla->handle, "subscribed" ); 235 235 236 236 g_free( bla->handle ); … … 238 238 } 239 239 240 void jabber_buddy_ask( struct gaim_connection *gc, char *handle )240 void jabber_buddy_ask( struct im_connection *ic, char *handle ) 241 241 { 242 242 struct jabber_buddy_ask_data *bla = g_new0( struct jabber_buddy_ask_data, 1 ); 243 243 char *buf; 244 244 245 bla-> gc = gc;245 bla->ic = ic; 246 246 bla->handle = g_strdup( handle ); 247 247 248 248 buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list.", handle ); 249 do_ask_dialog( gc, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );249 do_ask_dialog( ic, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no ); 250 250 g_free( buf ); 251 251 } … … 271 271 to deal with that properly. Set their ->resource property to NULL. Do *NOT* 272 272 allow to mix this stuff, though... */ 273 struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid_ )274 { 275 struct jabber_data *jd = gc->proto_data;273 struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ ) 274 { 275 struct jabber_data *jd = ic->proto_data; 276 276 struct jabber_buddy *bud, *new, *bi; 277 277 char *s, *full_jid; … … 343 343 asked for a bare JID, it uses the "resource_select" setting to see which 344 344 resource to pick. */ 345 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_, get_buddy_flags_t flags )346 { 347 struct jabber_data *jd = gc->proto_data;345 struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, get_buddy_flags_t flags ) 346 { 347 struct jabber_data *jd = ic->proto_data; 348 348 struct jabber_buddy *bud; 349 349 char *s, *jid; … … 371 371 } 372 372 373 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid ) )373 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid ) ) 374 374 { 375 375 *s = '/'; 376 bud = jabber_buddy_add( gc, jid );376 bud = jabber_buddy_add( ic, jid ); 377 377 } 378 378 … … 391 391 if( bud == NULL ) 392 392 /* No match. Create it now? */ 393 return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid_ ) ) ?394 jabber_buddy_add( gc, jid_ ) : NULL;393 return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid_ ) ) ? 394 jabber_buddy_add( ic, jid_ ) : NULL; 395 395 else if( bud->resource && ( flags & GET_BUDDY_EXACT ) ) 396 396 /* We want an exact match, so in thise case there shouldn't be a /resource. */ … … 409 409 } 410 410 411 if( ( set = set_getstr( & gc->acc->set, "resource_select" ) ) == NULL )411 if( ( set = set_getstr( &ic->acc->set, "resource_select" ) ) == NULL ) 412 412 return NULL; 413 413 else if( strcmp( set, "activity" ) == 0 ) … … 421 421 off-line (because (s)he can still be online from a different location. 422 422 XXX: See above, we should accept bare JIDs too... */ 423 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid_ )424 { 425 struct jabber_data *jd = gc->proto_data;423 int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) 424 { 425 struct jabber_data *jd = ic->proto_data; 426 426 struct jabber_buddy *bud, *prev, *bi; 427 427 char *s, *full_jid; … … 495 495 specified bare JID. Use this when removing someone from the contact 496 496 list, for example. */ 497 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid_ )498 { 499 struct jabber_data *jd = gc->proto_data;497 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid_ ) 498 { 499 struct jabber_data *jd = ic->proto_data; 500 500 struct jabber_buddy *bud, *next; 501 501 char *bare_jid; -
protocols/jabber/message.c
rfa29d093 r0da65d5 26 26 xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) 27 27 { 28 struct gaim_connection *gc = data;28 struct im_connection *ic = data; 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); … … 47 47 if( ( s = strchr( from, '/' ) ) ) 48 48 { 49 if( ( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) ) )49 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) ) 50 50 bud->last_act = time( NULL ); 51 51 else … … 76 76 77 77 if( fullmsg->len > 0 ) 78 serv_got_im( gc, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );78 serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); 79 79 80 80 g_string_free( fullmsg, TRUE ); … … 84 84 { 85 85 bud->flags |= JBFLAG_DOES_XEP85; 86 serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 1 );86 serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 ); 87 87 } 88 88 /* No need to send a "stopped typing" signal when there's a message. */ … … 90 90 { 91 91 bud->flags |= JBFLAG_DOES_XEP85; 92 serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 0 );92 serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 ); 93 93 } 94 94 else if( xt_find_node( node->children, "paused" ) ) 95 95 { 96 96 bud->flags |= JBFLAG_DOES_XEP85; 97 serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 2 );97 serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 ); 98 98 } 99 99 -
protocols/jabber/presence.c
rfa29d093 r0da65d5 26 26 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) 27 27 { 28 struct gaim_connection *gc = data;28 struct im_connection *ic = data; 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ … … 38 38 if( type == NULL ) 39 39 { 40 if( !( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )40 if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) ) 41 41 { 42 if( set_getbool( & gc->irc->set, "debug" ) )43 serv_got_crap( gc, "WARNING: Could not handle presence information from JID: %s", from );42 if( set_getbool( &ic->irc->set, "debug" ) ) 43 serv_got_crap( ic, "WARNING: Could not handle presence information from JID: %s", from ); 44 44 return XT_HANDLED; 45 45 } … … 66 66 bud->priority = 0; 67 67 68 serv_got_update( gc, bud->bare_jid, 1, 0, 0, 0,68 serv_got_update( ic, bud->bare_jid, 1, 0, 0, 0, 69 69 bud->away_state ? UC_UNAVAILABLE : 0, 0 ); 70 70 } 71 71 else if( strcmp( type, "unavailable" ) == 0 ) 72 72 { 73 if( jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) == NULL )73 if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) == NULL ) 74 74 { 75 if( set_getbool( & gc->irc->set, "debug" ) )76 serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from );75 if( set_getbool( &ic->irc->set, "debug" ) ) 76 serv_got_crap( ic, "WARNING: Received presence information from unknown JID: %s", from ); 77 77 return XT_HANDLED; 78 78 } 79 79 80 jabber_buddy_remove( gc, from );80 jabber_buddy_remove( ic, from ); 81 81 82 82 if( ( s = strchr( from, '/' ) ) ) … … 86 86 /* Only count this as offline if there's no other resource 87 87 available anymore. */ 88 if( jabber_buddy_by_jid( gc, from, 0 ) == NULL )89 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );88 if( jabber_buddy_by_jid( ic, from, 0 ) == NULL ) 89 serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 ); 90 90 91 91 *s = '/'; … … 93 93 else 94 94 { 95 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );95 serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 ); 96 96 } 97 97 } 98 98 else if( strcmp( type, "subscribe" ) == 0 ) 99 99 { 100 jabber_buddy_ask( gc, from );100 jabber_buddy_ask( ic, from ); 101 101 } 102 102 else if( strcmp( type, "subscribed" ) == 0 ) 103 103 { 104 104 /* Not sure about this one, actually... */ 105 serv_got_crap( gc, "%s just accepted your authorization request", from );105 serv_got_crap( ic, "%s just accepted your authorization request", from ); 106 106 } 107 107 else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 ) … … 131 131 /* Whenever presence information is updated, call this function to inform the 132 132 server. */ 133 int presence_send_update( struct gaim_connection *gc )133 int presence_send_update( struct im_connection *ic ) 134 134 { 135 struct jabber_data *jd = gc->proto_data;135 struct jabber_data *jd = ic->proto_data; 136 136 struct xt_node *node; 137 137 char *show = jd->away_state->code; … … 140 140 141 141 node = jabber_make_packet( "presence", NULL, NULL, NULL ); 142 xt_add_child( node, xt_new_node( "priority", set_getstr( & gc->acc->set, "priority" ), NULL ) );142 xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) ); 143 143 if( show && *show ) 144 144 xt_add_child( node, xt_new_node( "show", show, NULL ) ); … … 146 146 xt_add_child( node, xt_new_node( "status", status, NULL ) ); 147 147 148 st = jabber_write_packet( gc, node );148 st = jabber_write_packet( ic, node ); 149 149 150 150 xt_free_node( node ); … … 153 153 154 154 /* Send a subscribe/unsubscribe request to a buddy. */ 155 int presence_send_request( struct gaim_connection *gc, char *handle, char *request )155 int presence_send_request( struct im_connection *ic, char *handle, char *request ) 156 156 { 157 157 struct xt_node *node; … … 162 162 xt_add_attr( node, "type", request ); 163 163 164 st = jabber_write_packet( gc, node );164 st = jabber_write_packet( ic, node ); 165 165 166 166 xt_free_node( node ); -
protocols/jabber/sasl.c
rfa29d093 r0da65d5 27 27 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ) 28 28 { 29 struct gaim_connection *gc = data;30 struct jabber_data *jd = gc->proto_data;29 struct im_connection *ic = data; 30 struct jabber_data *jd = ic->proto_data; 31 31 struct xt_node *c, *reply; 32 32 char *s; 33 33 int sup_plain = 0, sup_digest = 0; 34 34 35 if( !sasl_supported( gc ) )35 if( !sasl_supported( ic ) ) 36 36 { 37 37 /* Should abort this now, since we should already be doing 38 38 IQ authentication. Strange things happen when you try 39 39 to do both... */ 40 serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );40 serv_got_crap( ic, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" ); 41 41 return XT_HANDLED; 42 42 } … … 45 45 if( !s || strcmp( s, XMLNS_SASL ) != 0 ) 46 46 { 47 signoff( gc );47 signoff( ic ); 48 48 return XT_ABORT; 49 49 } … … 62 62 if( !sup_plain && !sup_digest ) 63 63 { 64 hide_login_progress( gc, "No known SASL authentication schemes supported" );65 signoff( gc );64 hide_login_progress( ic, "No known SASL authentication schemes supported" ); 65 signoff( ic ); 66 66 return XT_ABORT; 67 67 } … … 83 83 84 84 /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */ 85 len = strlen( jd->username ) + strlen( gc->acc->pass ) + 2;85 len = strlen( jd->username ) + strlen( ic->acc->pass ) + 2; 86 86 s = g_malloc( len + 1 ); 87 87 s[0] = 0; 88 88 strcpy( s + 1, jd->username ); 89 strcpy( s + 2 + strlen( jd->username ), gc->acc->pass );89 strcpy( s + 2 + strlen( jd->username ), ic->acc->pass ); 90 90 reply->text = base64_encode( s, len ); 91 91 reply->text_len = strlen( reply->text ); … … 93 93 } 94 94 95 if( !jabber_write_packet( gc, reply ) )95 if( !jabber_write_packet( ic, reply ) ) 96 96 { 97 97 xt_free_node( reply ); … … 181 181 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ) 182 182 { 183 struct gaim_connection *gc = data;184 struct jabber_data *jd = gc->proto_data;183 struct im_connection *ic = data; 184 struct jabber_data *jd = ic->proto_data; 185 185 struct xt_node *reply = NULL; 186 186 char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30]; … … 222 222 I decided to call it H. */ 223 223 md5_init( &H ); 224 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, gc->acc->pass );224 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, ic->acc->pass ); 225 225 md5_append( &H, (unsigned char *) s, strlen( s ) ); 226 226 g_free( s ); … … 272 272 xt_add_attr( reply, "xmlns", XMLNS_SASL ); 273 273 274 if( !jabber_write_packet( gc, reply ) )274 if( !jabber_write_packet( ic, reply ) ) 275 275 goto silent_error; 276 276 … … 279 279 280 280 error: 281 hide_login_progress( gc, "Incorrect SASL challenge received" );282 signoff( gc );281 hide_login_progress( ic, "Incorrect SASL challenge received" ); 282 signoff( ic ); 283 283 284 284 silent_error: … … 296 296 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ) 297 297 { 298 struct gaim_connection *gc = data;299 struct jabber_data *jd = gc->proto_data;298 struct im_connection *ic = data; 299 struct jabber_data *jd = ic->proto_data; 300 300 char *s; 301 301 … … 303 303 if( !s || strcmp( s, XMLNS_SASL ) != 0 ) 304 304 { 305 signoff( gc );305 signoff( ic ); 306 306 return XT_ABORT; 307 307 } … … 309 309 if( strcmp( node->name, "success" ) == 0 ) 310 310 { 311 set_login_progress( gc, 1, "Authentication finished" );311 set_login_progress( ic, 1, "Authentication finished" ); 312 312 jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART; 313 313 } 314 314 else if( strcmp( node->name, "failure" ) == 0 ) 315 315 { 316 hide_login_progress( gc, "Authentication failure" );317 signoff( gc );316 hide_login_progress( ic, "Authentication failure" ); 317 signoff( ic ); 318 318 return XT_ABORT; 319 319 } … … 325 325 It's done by checking if the <stream:stream> from the server has a 326 326 version attribute. I don't know if this is the right way though... */ 327 gboolean sasl_supported( struct gaim_connection *gc )328 { 329 struct jabber_data *jd = gc->proto_data;327 gboolean sasl_supported( struct im_connection *ic ) 328 { 329 struct jabber_data *jd = ic->proto_data; 330 330 331 331 return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL; -
protocols/msn/msn.c
rfa29d093 r0da65d5 29 29 static char *msn_set_display_name( set_t *set, char *value ); 30 30 31 static void msn_ acc_init( account_t *acc )31 static void msn_init( account_t *acc ) 32 32 { 33 33 set_t *s; … … 39 39 static void msn_login( account_t *acc ) 40 40 { 41 struct gaim_connection *gc = new_gaim_conn( acc );41 struct im_connection *ic = new_gaim_conn( acc ); 42 42 struct msn_data *md = g_new0( struct msn_data, 1 ); 43 43 44 gc->proto_data = md;44 ic->proto_data = md; 45 45 md->fd = -1; 46 46 47 47 if( strchr( acc->user, '@' ) == NULL ) 48 48 { 49 hide_login_progress( gc, "Invalid account name" );50 signoff( gc );49 hide_login_progress( ic, "Invalid account name" ); 50 signoff( ic ); 51 51 return; 52 52 } 53 53 54 set_login_progress( gc, 1, "Connecting" );55 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc );54 set_login_progress( ic, 1, "Connecting" ); 55 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic ); 57 57 if( md->fd < 0 ) 58 58 { 59 hide_login_progress( gc, "Could not connect to server" );60 signoff( gc );59 hide_login_progress( ic, "Could not connect to server" ); 60 signoff( ic ); 61 61 return; 62 62 } 63 63 64 md-> gc = gc;64 md->ic = ic; 65 65 md->away_state = msn_away_state_list; 66 66 67 msn_connections = g_slist_append( msn_connections, gc );68 } 69 70 static void msn_ close( struct gaim_connection *gc )71 { 72 struct msn_data *md = gc->proto_data;67 msn_connections = g_slist_append( msn_connections, ic ); 68 } 69 70 static void msn_logout( struct im_connection *ic ) 71 { 72 struct msn_data *md = ic->proto_data; 73 73 GSList *l; 74 74 … … 96 96 m = l->data; 97 97 98 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );98 serv_got_crap( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); 99 99 g_free( m->who ); 100 100 g_free( m->text ); … … 111 111 } 112 112 113 for( l = gc->permit; l; l = l->next )113 for( l = ic->permit; l; l = l->next ) 114 114 g_free( l->data ); 115 g_slist_free( gc->permit );116 117 for( l = gc->deny; l; l = l->next )115 g_slist_free( ic->permit ); 116 117 for( l = ic->deny; l; l = l->next ) 118 118 g_free( l->data ); 119 g_slist_free( gc->deny );120 121 msn_connections = g_slist_remove( msn_connections, gc );122 } 123 124 static int msn_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )119 g_slist_free( ic->deny ); 120 121 msn_connections = g_slist_remove( msn_connections, ic ); 122 } 123 124 static int msn_send_im( struct im_connection *ic, char *who, char *message, int away ) 125 125 { 126 126 struct msn_switchboard *sb; 127 struct msn_data *md = gc->proto_data;128 129 if( ( sb = msn_sb_by_handle( gc, who ) ) )127 struct msn_data *md = ic->proto_data; 128 129 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 130 130 { 131 131 return( msn_sb_sendmessage( sb, message ) ); … … 142 142 143 143 /* FIXME: *CHECK* the reliability of using spare sb's! */ 144 if( ( sb = msn_sb_spare( gc ) ) )144 if( ( sb = msn_sb_spare( ic ) ) ) 145 145 { 146 146 debug( "Trying to use a spare switchboard to message %s", who ); … … 160 160 /* If we reach this line, there was no spare switchboard, so let's make one. */ 161 161 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 162 if( !msn_write( gc, buf, strlen( buf ) ) )162 if( !msn_write( ic, buf, strlen( buf ) ) ) 163 163 { 164 164 g_free( m->who ); … … 180 180 } 181 181 182 static GList *msn_away_states( struct gaim_connection *gc )182 static GList *msn_away_states( struct im_connection *ic ) 183 183 { 184 184 static GList *l = NULL; … … 192 192 } 193 193 194 static char *msn_get_status_string( struct gaim_connection *gc, int number )194 static char *msn_get_status_string( struct im_connection *ic, int number ) 195 195 { 196 196 const struct msn_away_state *st = msn_away_state_by_number( number ); … … 202 202 } 203 203 204 static void msn_set_away( struct gaim_connection *gc, char *state, char *message )204 static void msn_set_away( struct im_connection *ic, char *state, char *message ) 205 205 { 206 206 char buf[1024]; 207 struct msn_data *md = gc->proto_data;207 struct msn_data *md = ic->proto_data; 208 208 const struct msn_away_state *st; 209 209 … … 217 217 218 218 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); 219 msn_write( gc, buf, strlen( buf ) );220 } 221 222 static void msn_set_ info( struct gaim_connection *gc, char *info )223 { 224 msn_set_display_name( set_find( & gc->acc->set, "display_name" ), info );225 } 226 227 static void msn_get_info(struct gaim_connection *gc, char *who)219 msn_write( ic, buf, strlen( buf ) ); 220 } 221 222 static void msn_set_my_name( struct im_connection *ic, char *info ) 223 { 224 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); 225 } 226 227 static void msn_get_info(struct im_connection *ic, char *who) 228 228 { 229 229 /* Just make an URL and let the user fetch the info */ 230 serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who );231 } 232 233 static void msn_add_buddy( struct gaim_connection *gc, char *who)234 { 235 msn_buddy_list_add( gc, "FL", who, who );236 } 237 238 static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group )239 { 240 msn_buddy_list_remove( gc, "FL", who );241 } 242 243 static int msn_chat_send( struct conversation *c, char *message)230 serv_got_crap( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); 231 } 232 233 static void msn_add_buddy( struct im_connection *ic, char *who, char *group ) 234 { 235 msn_buddy_list_add( ic, "FL", who, who ); 236 } 237 238 static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) 239 { 240 msn_buddy_list_remove( ic, "FL", who ); 241 } 242 243 static void msn_chat_send( struct groupchat *c, char *message, int flags ) 244 244 { 245 245 struct msn_switchboard *sb = msn_sb_by_chat( c ); 246 246 247 247 if( sb ) 248 return( msn_sb_sendmessage( sb, message ));249 else250 return( 0 );251 } 252 253 static void msn_chat_invite( struct conversation*c, char *msg, char *who )248 msn_sb_sendmessage( sb, message ); 249 /* FIXME: Error handling (although this can't happen unless something's 250 already severely broken) disappeared here! */ 251 } 252 253 static void msn_chat_invite( struct groupchat *c, char *msg, char *who ) 254 254 { 255 255 struct msn_switchboard *sb = msn_sb_by_chat( c ); … … 263 263 } 264 264 265 static void msn_chat_leave( struct conversation*c )265 static void msn_chat_leave( struct groupchat *c ) 266 266 { 267 267 struct msn_switchboard *sb = msn_sb_by_chat( c ); … … 271 271 } 272 272 273 static struct conversation *msn_chat_open( struct gaim_connection *gc, char *who )273 static struct groupchat *msn_chat_with( struct im_connection *ic, char *who ) 274 274 { 275 275 struct msn_switchboard *sb; 276 struct msn_data *md = gc->proto_data;276 struct msn_data *md = ic->proto_data; 277 277 char buf[1024]; 278 278 279 if( ( sb = msn_sb_by_handle( gc, who ) ) )279 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 280 280 { 281 281 debug( "Converting existing switchboard to %s to a groupchat", who ); … … 286 286 struct msn_message *m; 287 287 288 if( ( sb = msn_sb_spare( gc ) ) )288 if( ( sb = msn_sb_spare( ic ) ) ) 289 289 { 290 290 debug( "Trying to reuse an existing switchboard as a groupchat with %s", who ); … … 299 299 /* Request a new switchboard. */ 300 300 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 301 if( !msn_write( gc, buf, strlen( buf ) ) )301 if( !msn_write( ic, buf, strlen( buf ) ) ) 302 302 return( 0 ); 303 303 … … 317 317 } 318 318 319 static void msn_keepalive( struct gaim_connection *gc )320 { 321 msn_write( gc, "PNG\r\n", strlen( "PNG\r\n" ) );322 } 323 324 static void msn_add_permit( struct gaim_connection *gc, char *who )325 { 326 msn_buddy_list_add( gc, "AL", who, who );327 } 328 329 static void msn_rem_permit( struct gaim_connection *gc, char *who )330 { 331 msn_buddy_list_remove( gc, "AL", who );332 } 333 334 static void msn_add_deny( struct gaim_connection *gc, char *who )319 static void msn_keepalive( struct im_connection *ic ) 320 { 321 msn_write( ic, "PNG\r\n", strlen( "PNG\r\n" ) ); 322 } 323 324 static void msn_add_permit( struct im_connection *ic, char *who ) 325 { 326 msn_buddy_list_add( ic, "AL", who, who ); 327 } 328 329 static void msn_rem_permit( struct im_connection *ic, char *who ) 330 { 331 msn_buddy_list_remove( ic, "AL", who ); 332 } 333 334 static void msn_add_deny( struct im_connection *ic, char *who ) 335 335 { 336 336 struct msn_switchboard *sb; 337 337 338 msn_buddy_list_add( gc, "BL", who, who );338 msn_buddy_list_add( ic, "BL", who, who ); 339 339 340 340 /* If there's still a conversation with this person, close it. */ 341 if( ( sb = msn_sb_by_handle( gc, who ) ) )341 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 342 342 { 343 343 msn_sb_destroy( sb ); … … 345 345 } 346 346 347 static void msn_rem_deny( struct gaim_connection *gc, char *who )348 { 349 msn_buddy_list_remove( gc, "BL", who );350 } 351 352 static int msn_send_typing( struct gaim_connection *gc, char *who, int typing )347 static void msn_rem_deny( struct im_connection *ic, char *who ) 348 { 349 msn_buddy_list_remove( ic, "BL", who ); 350 } 351 352 static int msn_send_typing( struct im_connection *ic, char *who, int typing ) 353 353 { 354 354 if( typing ) 355 return( msn_send_im( gc, who, TYPING_NOTIFICATION_MESSAGE, strlen( TYPING_NOTIFICATION_MESSAGE ), 0 ) );355 return( msn_send_im( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) ); 356 356 else 357 357 return( 1 ); … … 361 361 { 362 362 account_t *acc = set->data; 363 struct gaim_connection *gc = acc->gc;363 struct im_connection *ic = acc->ic; 364 364 struct msn_data *md; 365 365 char buf[1024], *fn; 366 366 367 367 /* Double-check. */ 368 if( gc == NULL )368 if( ic == NULL ) 369 369 return NULL; 370 370 371 md = gc->proto_data;371 md = ic->proto_data; 372 372 373 373 if( strlen( value ) > 129 ) 374 374 { 375 serv_got_crap( gc, "Maximum name length exceeded" );375 serv_got_crap( ic, "Maximum name length exceeded" ); 376 376 return NULL; 377 377 } … … 379 379 fn = msn_http_encode( value ); 380 380 381 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );382 msn_write( gc, buf, strlen( buf ) );381 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->username, fn ); 382 msn_write( ic, buf, strlen( buf ) ); 383 383 g_free( fn ); 384 384 … … 389 389 } 390 390 391 void msn_init ()391 void msn_initmodule() 392 392 { 393 393 struct prpl *ret = g_new0(struct prpl, 1); … … 395 395 ret->name = "msn"; 396 396 ret->login = msn_login; 397 ret-> acc_init = msn_acc_init;398 ret-> close = msn_close;397 ret->init = msn_init; 398 ret->logout = msn_logout; 399 399 ret->send_im = msn_send_im; 400 400 ret->away_states = msn_away_states; 401 401 ret->get_status_string = msn_get_status_string; 402 402 ret->set_away = msn_set_away; 403 ret->set_info = msn_set_info;404 403 ret->get_info = msn_get_info; 404 ret->set_my_name = msn_set_my_name; 405 405 ret->add_buddy = msn_add_buddy; 406 406 ret->remove_buddy = msn_remove_buddy; … … 408 408 ret->chat_invite = msn_chat_invite; 409 409 ret->chat_leave = msn_chat_leave; 410 ret->chat_ open = msn_chat_open;410 ret->chat_with = msn_chat_with; 411 411 ret->keepalive = msn_keepalive; 412 412 ret->add_permit = msn_add_permit; -
protocols/msn/msn.h
rfa29d093 r0da65d5 57 57 struct msn_data 58 58 { 59 struct gaim_connection *gc;59 struct im_connection *ic; 60 60 61 61 int fd; … … 75 75 struct msn_switchboard 76 76 { 77 struct gaim_connection *gc;77 struct im_connection *ic; 78 78 79 79 int fd; … … 89 89 GSList *msgq; 90 90 char *who; 91 struct conversation*chat;91 struct groupchat *chat; 92 92 }; 93 93 … … 149 149 150 150 /* msn_util.c */ 151 int msn_write( struct gaim_connection *gc, char *s, int len );152 int msn_logged_in( struct gaim_connection *gc );153 int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname );154 int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who );155 void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname );151 int msn_write( struct im_connection *ic, char *s, int len ); 152 int msn_logged_in( struct im_connection *ic ); 153 int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname ); 154 int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ); 155 void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ); 156 156 char *msn_findheader( char *text, char *header, int len ); 157 157 char **msn_linesplit( char *line ); … … 167 167 /* sb.c */ 168 168 int msn_sb_write( struct msn_switchboard *sb, char *s, int len ); 169 struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session );170 struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle );171 struct msn_switchboard *msn_sb_by_chat( struct conversation*c );172 struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc );169 struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ); 170 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ); 171 struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ); 172 struct msn_switchboard *msn_sb_spare( struct im_connection *ic ); 173 173 int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); 174 struct conversation*msn_sb_to_chat( struct msn_switchboard *sb );174 struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ); 175 175 void msn_sb_destroy( struct msn_switchboard *sb ); 176 176 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); -
protocols/msn/msn_util.c
rfa29d093 r0da65d5 28 28 #include <ctype.h> 29 29 30 int msn_write( struct gaim_connection *gc, char *s, int len )31 { 32 struct msn_data *md = gc->proto_data;30 int msn_write( struct im_connection *ic, char *s, int len ) 31 { 32 struct msn_data *md = ic->proto_data; 33 33 int st; 34 34 … … 36 36 if( st != len ) 37 37 { 38 hide_login_progress_error( gc, "Short write() to main server" );39 signoff( gc );38 hide_login_progress_error( ic, "Short write() to main server" ); 39 signoff( ic ); 40 40 return( 0 ); 41 41 } … … 44 44 } 45 45 46 int msn_logged_in( struct gaim_connection *gc )47 { 48 account_online( gc );46 int msn_logged_in( struct im_connection *ic ) 47 { 48 account_online( ic ); 49 49 50 50 return( 0 ); 51 51 } 52 52 53 int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname_ )54 { 55 struct msn_data *md = gc->proto_data;53 int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname_ ) 54 { 55 struct msn_data *md = ic->proto_data; 56 56 char buf[1024], *realname; 57 57 … … 59 59 60 60 g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname ); 61 if( msn_write( gc, buf, strlen( buf ) ) )61 if( msn_write( ic, buf, strlen( buf ) ) ) 62 62 { 63 63 g_free( realname ); … … 71 71 } 72 72 73 int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who )74 { 75 struct msn_data *md = gc->proto_data;73 int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ) 74 { 75 struct msn_data *md = ic->proto_data; 76 76 char buf[1024]; 77 77 78 78 g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who ); 79 if( msn_write( gc, buf, strlen( buf ) ) )79 if( msn_write( ic, buf, strlen( buf ) ) ) 80 80 return( 1 ); 81 81 … … 85 85 struct msn_buddy_ask_data 86 86 { 87 struct gaim_connection *gc;87 struct im_connection *ic; 88 88 char *handle; 89 89 char *realname; … … 92 92 static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) 93 93 { 94 msn_buddy_list_add( bla-> gc, "AL", bla->handle, bla->realname );95 96 if( find_buddy( bla-> gc, bla->handle ) == NULL )97 show_got_added( bla-> gc, bla->handle, NULL );94 msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname ); 95 96 if( find_buddy( bla->ic, bla->handle ) == NULL ) 97 show_got_added( bla->ic, bla->handle, NULL ); 98 98 99 99 g_free( bla->handle ); … … 104 104 static void msn_buddy_ask_no( gpointer w, struct msn_buddy_ask_data *bla ) 105 105 { 106 msn_buddy_list_add( bla-> gc, "BL", bla->handle, bla->realname );106 msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname ); 107 107 108 108 g_free( bla->handle ); … … 111 111 } 112 112 113 void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname )113 void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ) 114 114 { 115 115 struct msn_buddy_ask_data *bla = g_new0( struct msn_buddy_ask_data, 1 ); 116 116 char buf[1024]; 117 117 118 bla-> gc = gc;118 bla->ic = ic; 119 119 bla->handle = g_strdup( handle ); 120 120 bla->realname = g_strdup( realname ); … … 123 123 "The user %s (%s) wants to add you to his/her buddy list.", 124 124 handle, realname ); 125 do_ask_dialog( gc, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no );125 do_ask_dialog( ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no ); 126 126 } 127 127 -
protocols/msn/ns.c
rfa29d093 r0da65d5 38 38 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) 39 39 { 40 struct gaim_connection *gc = data;40 struct im_connection *ic = data; 41 41 struct msn_data *md; 42 42 char s[1024]; 43 43 44 if( !g_slist_find( msn_connections, gc ) )44 if( !g_slist_find( msn_connections, ic ) ) 45 45 return FALSE; 46 46 47 47 if( source == -1 ) 48 48 { 49 hide_login_progress( gc, "Could not connect to server" );50 signoff( gc );49 hide_login_progress( ic, "Could not connect to server" ); 50 signoff( ic ); 51 51 return FALSE; 52 52 } 53 53 54 md = gc->proto_data;54 md = ic->proto_data; 55 55 56 56 if( !md->handler ) 57 57 { 58 58 md->handler = g_new0( struct msn_handler_data, 1 ); 59 md->handler->data = gc;59 md->handler->data = ic; 60 60 md->handler->exec_command = msn_ns_command; 61 61 md->handler->exec_message = msn_ns_message; … … 73 73 74 74 g_snprintf( s, sizeof( s ), "VER %d MSNP8 CVR0\r\n", ++md->trId ); 75 if( msn_write( gc, s, strlen( s ) ) )76 { 77 gc->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );78 set_login_progress( gc, 1, "Connected to server, waiting for reply" );75 if( msn_write( ic, s, strlen( s ) ) ) 76 { 77 ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic ); 78 set_login_progress( ic, 1, "Connected to server, waiting for reply" ); 79 79 } 80 80 … … 84 84 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ) 85 85 { 86 struct gaim_connection *gc = data;87 struct msn_data *md = gc->proto_data;86 struct im_connection *ic = data; 87 struct msn_data *md = ic->proto_data; 88 88 89 89 if( msn_handler( md->handler ) == -1 ) /* Don't do this on ret == 0, it's already done then. */ 90 90 { 91 hide_login_progress( gc, "Error while reading from server" );92 signoff( gc );91 hide_login_progress( ic, "Error while reading from server" ); 92 signoff( ic ); 93 93 94 94 return FALSE; … … 100 100 static int msn_ns_command( gpointer data, char **cmd, int num_parts ) 101 101 { 102 struct gaim_connection *gc = data;103 struct msn_data *md = gc->proto_data;102 struct im_connection *ic = data; 103 struct msn_data *md = ic->proto_data; 104 104 char buf[1024]; 105 105 … … 114 114 if( cmd[2] && strncmp( cmd[2], "MSNP8", 5 ) != 0 ) 115 115 { 116 hide_login_progress( gc, "Unsupported protocol" );117 signoff( gc );116 hide_login_progress( ic, "Unsupported protocol" ); 117 signoff( ic ); 118 118 return( 0 ); 119 119 } 120 120 121 121 g_snprintf( buf, sizeof( buf ), "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", 122 ++md->trId, gc->username );123 return( msn_write( gc, buf, strlen( buf ) ) );122 ++md->trId, ic->username ); 123 return( msn_write( ic, buf, strlen( buf ) ) ); 124 124 } 125 125 else if( strcmp( cmd[0], "CVR" ) == 0 ) 126 126 { 127 127 /* We don't give a damn about the information we just received */ 128 g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, gc->username );129 return( msn_write( gc, buf, strlen( buf ) ) );128 g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, ic->username ); 129 return( msn_write( ic, buf, strlen( buf ) ) ); 130 130 } 131 131 else if( strcmp( cmd[0], "XFR" ) == 0 ) … … 136 136 if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 ) 137 137 { 138 b_event_remove( gc->inpa );139 gc->inpa = 0;138 b_event_remove( ic->inpa ); 139 ic->inpa = 0; 140 140 closesocket( md->fd ); 141 141 … … 143 143 if( !server ) 144 144 { 145 hide_login_progress_error( gc, "Syntax error" );146 signoff( gc );145 hide_login_progress_error( ic, "Syntax error" ); 146 signoff( ic ); 147 147 return( 0 ); 148 148 } … … 151 151 server = cmd[3]; 152 152 153 set_login_progress( gc, 1, "Transferring to other server" );154 155 md->fd = proxy_connect( server, port, msn_ns_connected, gc );153 set_login_progress( ic, 1, "Transferring to other server" ); 154 155 md->fd = proxy_connect( server, port, msn_ns_connected, ic ); 156 156 } 157 157 else if( num_parts == 6 && strcmp( cmd[2], "SB" ) == 0 ) … … 162 162 if( !server ) 163 163 { 164 hide_login_progress_error( gc, "Syntax error" );165 signoff( gc );164 hide_login_progress_error( ic, "Syntax error" ); 165 signoff( ic ); 166 166 return( 0 ); 167 167 } … … 172 172 if( strcmp( cmd[4], "CKI" ) != 0 ) 173 173 { 174 hide_login_progress_error( gc, "Unknown authentication method for switchboard" );175 signoff( gc );174 hide_login_progress_error( ic, "Unknown authentication method for switchboard" ); 175 signoff( ic ); 176 176 return( 0 ); 177 177 } 178 178 179 179 debug( "Connecting to a new switchboard with key %s", cmd[5] ); 180 sb = msn_sb_create( gc, server, port, cmd[5], MSN_SB_NEW );180 sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ); 181 181 182 182 if( md->msgq ) … … 204 204 else 205 205 { 206 hide_login_progress_error( gc, "Syntax error" );207 signoff( gc );206 hide_login_progress_error( ic, "Syntax error" ); 207 signoff( ic ); 208 208 return( 0 ); 209 209 } … … 214 214 { 215 215 /* Time for some Passport black magic... */ 216 if( !passport_get_id( msn_auth_got_passport_id, gc, gc->username, gc->password, cmd[4] ) )217 { 218 hide_login_progress_error( gc, "Error while contacting Passport server" );219 signoff( gc );216 if( !passport_get_id( msn_auth_got_passport_id, ic, ic->username, ic->password, cmd[4] ) ) 217 { 218 hide_login_progress_error( ic, "Error while contacting Passport server" ); 219 signoff( ic ); 220 220 return( 0 ); 221 221 } … … 227 227 http_decode( cmd[4] ); 228 228 229 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );230 gc->displayname[sizeof(gc->displayname)-1] = 0;231 232 if( ( s = set_find( & gc->acc->set, "display_name" ) ) )229 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 230 ic->displayname[sizeof(ic->displayname)-1] = 0; 231 232 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 233 233 { 234 234 g_free( s->value ); … … 236 236 } 237 237 238 set_login_progress( gc, 1, "Authenticated, getting buddy list" );238 set_login_progress( ic, 1, "Authenticated, getting buddy list" ); 239 239 240 240 g_snprintf( buf, sizeof( buf ), "SYN %d 0\r\n", ++md->trId ); 241 return( msn_write( gc, buf, strlen( buf ) ) );241 return( msn_write( ic, buf, strlen( buf ) ) ); 242 242 } 243 243 else 244 244 { 245 hide_login_progress( gc, "Unknown authentication type" );246 signoff( gc );245 hide_login_progress( ic, "Unknown authentication type" ); 246 signoff( ic ); 247 247 return( 0 ); 248 248 } … … 252 252 if( num_parts != 4 ) 253 253 { 254 hide_login_progress_error( gc, "Syntax error" );255 signoff( gc );254 hide_login_progress_error( ic, "Syntax error" ); 255 signoff( ic ); 256 256 return( 0 ); 257 257 } … … 261 261 if( md->handler->msglen <= 0 ) 262 262 { 263 hide_login_progress_error( gc, "Syntax error" );264 signoff( gc );263 hide_login_progress_error( ic, "Syntax error" ); 264 signoff( ic ); 265 265 return( 0 ); 266 266 } … … 276 276 277 277 if( !*cmd[3] || md->buddycount == 0 ) 278 msn_logged_in( gc );278 msn_logged_in( ic ); 279 279 } 280 280 else … … 283 283 Let's assume everything is okay. */ 284 284 285 msn_logged_in( gc );285 msn_logged_in( ic ); 286 286 } 287 287 } … … 292 292 if( num_parts != 4 && num_parts != 5 ) 293 293 { 294 hide_login_progress( gc, "Syntax error" );295 signoff( gc );294 hide_login_progress( ic, "Syntax error" ); 295 signoff( ic ); 296 296 return( 0 ); 297 297 } … … 308 308 group = md->grouplist[num]; 309 309 310 add_buddy( gc, group, cmd[1], cmd[2] );310 add_buddy( ic, group, cmd[1], cmd[2] ); 311 311 } 312 312 if( list & 2 ) /* AL */ 313 313 { 314 gc->permit = g_slist_append( gc->permit, g_strdup( cmd[1] ) );314 ic->permit = g_slist_append( ic->permit, g_strdup( cmd[1] ) ); 315 315 } 316 316 if( list & 4 ) /* BL */ 317 317 { 318 gc->deny = g_slist_append( gc->deny, g_strdup( cmd[1] ) );318 ic->deny = g_slist_append( ic->deny, g_strdup( cmd[1] ) ); 319 319 } 320 320 if( list & 8 ) /* RL */ 321 321 { 322 322 if( ( list & 6 ) == 0 ) 323 msn_buddy_ask( gc, cmd[1], cmd[2] );323 msn_buddy_ask( ic, cmd[1], cmd[2] ); 324 324 } 325 325 326 326 if( --md->buddycount == 0 ) 327 327 { 328 if( gc->flags & OPT_LOGGED_IN )329 { 330 serv_got_crap( gc, "Successfully transferred to different server" );328 if( ic->flags & OPT_LOGGED_IN ) 329 { 330 serv_got_crap( ic, "Successfully transferred to different server" ); 331 331 g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); 332 return( msn_write( gc, buf, strlen( buf ) ) );332 return( msn_write( ic, buf, strlen( buf ) ) ); 333 333 } 334 334 else 335 335 { 336 msn_logged_in( gc );336 msn_logged_in( ic ); 337 337 } 338 338 } … … 344 344 if( num_parts != 4 ) 345 345 { 346 hide_login_progress_error( gc, "Syntax error" );347 signoff( gc );346 hide_login_progress_error( ic, "Syntax error" ); 347 signoff( ic ); 348 348 return( 0 ); 349 349 } … … 363 363 if( num_parts != 3 ) 364 364 { 365 hide_login_progress_error( gc, "Syntax error" );366 signoff( gc );365 hide_login_progress_error( ic, "Syntax error" ); 366 signoff( ic ); 367 367 return( 0 ); 368 368 } … … 377 377 g_snprintf( buf + strlen( buf ), 3, "%02x", digest[i] ); 378 378 379 return( msn_write( gc, buf, strlen( buf ) ) );379 return( msn_write( ic, buf, strlen( buf ) ) ); 380 380 } 381 381 else if( strcmp( cmd[0], "ILN" ) == 0 ) … … 385 385 if( num_parts != 6 ) 386 386 { 387 hide_login_progress_error( gc, "Syntax error" );388 signoff( gc );387 hide_login_progress_error( ic, "Syntax error" ); 388 signoff( ic ); 389 389 return( 0 ); 390 390 } 391 391 392 392 http_decode( cmd[4] ); 393 serv_buddy_rename( gc, cmd[3], cmd[4] );393 serv_buddy_rename( ic, cmd[3], cmd[4] ); 394 394 395 395 st = msn_away_state_by_code( cmd[2] ); … … 400 400 } 401 401 402 serv_got_update( gc, cmd[3], 1, 0, 0, 0, st->number, 0 );402 serv_got_update( ic, cmd[3], 1, 0, 0, 0, st->number, 0 ); 403 403 } 404 404 else if( strcmp( cmd[0], "FLN" ) == 0 ) 405 405 { 406 406 if( cmd[1] ) 407 serv_got_update( gc, cmd[1], 0, 0, 0, 0, 0, 0 );407 serv_got_update( ic, cmd[1], 0, 0, 0, 0, 0, 0 ); 408 408 } 409 409 else if( strcmp( cmd[0], "NLN" ) == 0 ) … … 413 413 if( num_parts != 5 ) 414 414 { 415 hide_login_progress_error( gc, "Syntax error" );416 signoff( gc );415 hide_login_progress_error( ic, "Syntax error" ); 416 signoff( ic ); 417 417 return( 0 ); 418 418 } 419 419 420 420 http_decode( cmd[3] ); 421 serv_buddy_rename( gc, cmd[2], cmd[3] );421 serv_buddy_rename( ic, cmd[2], cmd[3] ); 422 422 423 423 st = msn_away_state_by_code( cmd[1] ); … … 428 428 } 429 429 430 serv_got_update( gc, cmd[2], 1, 0, 0, 0, st->number, 0 );430 serv_got_update( ic, cmd[2], 1, 0, 0, 0, st->number, 0 ); 431 431 } 432 432 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 438 438 if( num_parts != 7 ) 439 439 { 440 hide_login_progress_error( gc, "Syntax error" );441 signoff( gc );440 hide_login_progress_error( ic, "Syntax error" ); 441 signoff( ic ); 442 442 return( 0 ); 443 443 } … … 448 448 if( !server ) 449 449 { 450 hide_login_progress_error( gc, "Syntax error" );451 signoff( gc );450 hide_login_progress_error( ic, "Syntax error" ); 451 signoff( ic ); 452 452 return( 0 ); 453 453 } … … 458 458 if( strcmp( cmd[3], "CKI" ) != 0 ) 459 459 { 460 hide_login_progress_error( gc, "Unknown authentication method for switchboard" );461 signoff( gc );460 hide_login_progress_error( ic, "Unknown authentication method for switchboard" ); 461 signoff( ic ); 462 462 return( 0 ); 463 463 } … … 465 465 debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] ); 466 466 467 sb = msn_sb_create( gc, server, port, cmd[4], session );467 sb = msn_sb_create( ic, server, port, cmd[4], session ); 468 468 sb->who = g_strdup( cmd[5] ); 469 469 } … … 478 478 if( strchr( cmd[4], '@' ) == NULL ) 479 479 { 480 hide_login_progress_error( gc, "Syntax error" );481 signoff( gc );480 hide_login_progress_error( ic, "Syntax error" ); 481 signoff( ic ); 482 482 return( 0 ); 483 483 } 484 484 485 485 /* We got added by someone. If we don't have this person in permit/deny yet, inform the user. */ 486 for( l = gc->permit; l; l = l->next )486 for( l = ic->permit; l; l = l->next ) 487 487 if( g_strcasecmp( l->data, cmd[4] ) == 0 ) 488 488 return( 1 ); 489 489 490 for( l = gc->deny; l; l = l->next )490 for( l = ic->deny; l; l = l->next ) 491 491 if( g_strcasecmp( l->data, cmd[4] ) == 0 ) 492 492 return( 1 ); 493 493 494 msn_buddy_ask( gc, cmd[4], cmd[5] );494 msn_buddy_ask( ic, cmd[4], cmd[5] ); 495 495 } 496 496 } … … 499 499 if( cmd[1] && strcmp( cmd[1], "OTH" ) == 0 ) 500 500 { 501 hide_login_progress_error( gc, "Someone else logged in with your account" );502 gc->wants_to_die = 1;501 hide_login_progress_error( ic, "Someone else logged in with your account" ); 502 ic->wants_to_die = 1; 503 503 } 504 504 else if( cmd[1] && strcmp( cmd[1], "SSD" ) == 0 ) 505 505 { 506 hide_login_progress_error( gc, "Terminating session because of server shutdown" );506 hide_login_progress_error( ic, "Terminating session because of server shutdown" ); 507 507 } 508 508 else 509 509 { 510 hide_login_progress_error( gc, "Session terminated by remote server (reason unknown)" );511 } 512 513 signoff( gc );510 hide_login_progress_error( ic, "Session terminated by remote server (reason unknown)" ); 511 } 512 513 signoff( ic ); 514 514 return( 0 ); 515 515 } … … 518 518 if( num_parts != 5 ) 519 519 { 520 hide_login_progress_error( gc, "Syntax error" );521 signoff( gc );522 return( 0 ); 523 } 524 525 if( g_strcasecmp( cmd[3], gc->username ) == 0 )520 hide_login_progress_error( ic, "Syntax error" ); 521 signoff( ic ); 522 return( 0 ); 523 } 524 525 if( g_strcasecmp( cmd[3], ic->username ) == 0 ) 526 526 { 527 527 set_t *s; 528 528 529 529 http_decode( cmd[4] ); 530 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );531 gc->displayname[sizeof(gc->displayname)-1] = 0;532 533 if( ( s = set_find( & gc->acc->set, "display_name" ) ) )530 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 531 ic->displayname[sizeof(ic->displayname)-1] = 0; 532 533 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 534 534 { 535 535 g_free( s->value ); … … 541 541 /* This is not supposed to happen, but let's handle it anyway... */ 542 542 http_decode( cmd[4] ); 543 serv_buddy_rename( gc, cmd[3], cmd[4] );543 serv_buddy_rename( ic, cmd[3], cmd[4] ); 544 544 } 545 545 } 546 546 else if( strcmp( cmd[0], "IPG" ) == 0 ) 547 547 { 548 do_error_dialog( gc, "Received IPG command, we don't handle them yet.", "MSN" );548 do_error_dialog( ic, "Received IPG command, we don't handle them yet.", "MSN" ); 549 549 550 550 md->handler->msglen = atoi( cmd[1] ); … … 552 552 if( md->handler->msglen <= 0 ) 553 553 { 554 hide_login_progress_error( gc, "Syntax error" );555 signoff( gc );554 hide_login_progress_error( ic, "Syntax error" ); 555 signoff( ic ); 556 556 return( 0 ); 557 557 } … … 563 563 564 564 g_snprintf( buf, sizeof( buf ), "Error reported by MSN server: %s", err->text ); 565 do_error_dialog( gc, buf, "MSN" );565 do_error_dialog( ic, buf, "MSN" ); 566 566 567 567 if( err->flags & STATUS_FATAL ) 568 568 { 569 signoff( gc );569 signoff( ic ); 570 570 return( 0 ); 571 571 } … … 581 581 static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ) 582 582 { 583 struct gaim_connection *gc = data;583 struct im_connection *ic = data; 584 584 char *body; 585 585 int blen = 0; … … 617 617 { 618 618 if( arg1 ) 619 serv_got_crap( gc, "The server is going down for maintenance in %s minutes.", arg1 );619 serv_got_crap( ic, "The server is going down for maintenance in %s minutes.", arg1 ); 620 620 } 621 621 … … 634 634 if( inbox && folders ) 635 635 { 636 serv_got_crap( gc, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );636 serv_got_crap( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 637 637 } 638 638 } … … 644 644 if( from && fromname ) 645 645 { 646 serv_got_crap( gc, "Received an e-mail message from %s <%s>.", fromname, from );646 serv_got_crap( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 647 647 } 648 648 } … … 665 665 static void msn_auth_got_passport_id( struct passport_reply *rep ) 666 666 { 667 struct gaim_connection *gc = rep->data;668 struct msn_data *md = gc->proto_data;667 struct im_connection *ic = rep->data; 668 struct msn_data *md = ic->proto_data; 669 669 char *key = rep->result; 670 670 char buf[1024]; … … 677 677 rep->error_string ? rep->error_string : "Unknown error" ); 678 678 679 hide_login_progress( gc, err );680 signoff( gc );679 hide_login_progress( ic, err ); 680 signoff( ic ); 681 681 682 682 g_free( err ); … … 685 685 { 686 686 g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, key ); 687 msn_write( gc, buf, strlen( buf ) );687 msn_write( ic, buf, strlen( buf ) ); 688 688 } 689 689 } -
protocols/msn/sb.c
rfa29d093 r0da65d5 48 48 } 49 49 50 struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session )51 { 52 struct msn_data *md = gc->proto_data;50 struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ) 51 { 52 struct msn_data *md = ic->proto_data; 53 53 struct msn_switchboard *sb = g_new0( struct msn_switchboard, 1 ); 54 54 … … 60 60 } 61 61 62 sb-> gc = gc;62 sb->ic = ic; 63 63 sb->key = g_strdup( key ); 64 64 sb->session = session; … … 70 70 } 71 71 72 struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle )73 { 74 struct msn_data *md = gc->proto_data;72 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ) 73 { 74 struct msn_data *md = ic->proto_data; 75 75 struct msn_switchboard *sb; 76 76 GSList *l; … … 86 86 } 87 87 88 struct msn_switchboard *msn_sb_by_chat( struct conversation*c )89 { 90 struct msn_data *md = c-> gc->proto_data;88 struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ) 89 { 90 struct msn_data *md = c->ic->proto_data; 91 91 struct msn_switchboard *sb; 92 92 GSList *l; … … 102 102 } 103 103 104 struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc )105 { 106 struct msn_data *md = gc->proto_data;104 struct msn_switchboard *msn_sb_spare( struct im_connection *ic ) 105 { 106 struct msn_data *md = ic->proto_data; 107 107 struct msn_switchboard *sb; 108 108 GSList *l; … … 142 142 else 143 143 { 144 i = strlen( MSN_TYPING_HEADERS ) + strlen( sb-> gc->username );144 i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->username ); 145 145 buf = g_new0( char, i ); 146 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb-> gc->username );146 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->username ); 147 147 } 148 148 … … 177 177 } 178 178 179 struct conversation*msn_sb_to_chat( struct msn_switchboard *sb )180 { 181 struct gaim_connection *gc = sb->gc;179 struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ) 180 { 181 struct im_connection *ic = sb->ic; 182 182 char buf[1024]; 183 183 184 184 /* Create the groupchat structure. */ 185 185 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 186 sb->chat = serv_got_joined_chat( gc, buf );186 sb->chat = serv_got_joined_chat( ic, buf ); 187 187 188 188 /* Populate the channel. */ 189 189 if( sb->who ) add_chat_buddy( sb->chat, sb->who ); 190 add_chat_buddy( sb->chat, gc->username );190 add_chat_buddy( sb->chat, ic->username ); 191 191 192 192 /* And make sure the switchboard doesn't look like a regular chat anymore. */ … … 202 202 void msn_sb_destroy( struct msn_switchboard *sb ) 203 203 { 204 struct gaim_connection *gc = sb->gc;205 struct msn_data *md = gc->proto_data;204 struct im_connection *ic = sb->ic; 205 struct msn_data *md = ic->proto_data; 206 206 207 207 debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); … … 222 222 g_slist_free( sb->msgq ); 223 223 224 serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with "224 serv_got_crap( ic, "Warning: Closing down MSN switchboard connection with " 225 225 "unsent message to %s, you'll have to resend it.", 226 226 sb->who ? sb->who : "(unknown)" ); … … 253 253 { 254 254 struct msn_switchboard *sb = data; 255 struct gaim_connection *gc;255 struct im_connection *ic; 256 256 struct msn_data *md; 257 257 char buf[1024]; … … 261 261 return FALSE; 262 262 263 gc = sb->gc;264 md = gc->proto_data;263 ic = sb->ic; 264 md = ic->proto_data; 265 265 266 266 if( source != sb->fd ) … … 280 280 281 281 if( sb->session == MSN_SB_NEW ) 282 g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, gc->username, sb->key );282 g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, ic->username, sb->key ); 283 283 else 284 g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, gc->username, sb->key, sb->session );284 g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, ic->username, sb->key, sb->session ); 285 285 286 286 if( msn_sb_write( sb, buf, strlen( buf ) ) ) … … 310 310 { 311 311 struct msn_switchboard *sb = data; 312 struct gaim_connection *gc = sb->gc;312 struct im_connection *ic = sb->ic; 313 313 char buf[1024]; 314 314 … … 321 321 if( strcmp( cmd[0], "XFR" ) == 0 ) 322 322 { 323 hide_login_progress_error( gc, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" );324 signoff( gc );323 hide_login_progress_error( ic, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); 324 signoff( ic ); 325 325 return( 0 ); 326 326 } … … 374 374 { 375 375 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 376 sb->chat = serv_got_joined_chat( gc, buf );376 sb->chat = serv_got_joined_chat( ic, buf ); 377 377 378 378 g_free( sb->who ); … … 384 384 if( num == tot ) 385 385 { 386 add_chat_buddy( sb->chat, gc->username );386 add_chat_buddy( sb->chat, ic->username ); 387 387 } 388 388 } … … 529 529 530 530 g_snprintf( buf, sizeof( buf ), "Error reported by switchboard server: %s", err->text ); 531 do_error_dialog( gc, buf, "MSN" );531 do_error_dialog( ic, buf, "MSN" ); 532 532 533 533 if( err->flags & STATUS_SB_FATAL ) … … 538 538 else if( err->flags & STATUS_FATAL ) 539 539 { 540 signoff( gc );540 signoff( ic ); 541 541 return 0; 542 542 } … … 579 579 { 580 580 struct msn_switchboard *sb = data; 581 struct gaim_connection *gc = sb->gc;581 struct im_connection *ic = sb->ic; 582 582 char *body; 583 583 int blen = 0; … … 608 608 if( sb->who ) 609 609 { 610 serv_got_im( gc, cmd[1], body, 0, 0, blen );610 serv_got_im( ic, cmd[1], body, 0, 0, blen ); 611 611 } 612 612 else if( sb->chat ) … … 667 667 if( sb->who ) 668 668 { 669 serv_got_im( gc, cmd[1], buf, 0, 0, strlen( buf ) );669 serv_got_im( ic, cmd[1], buf, 0, 0, strlen( buf ) ); 670 670 } 671 671 else if( sb->chat ) … … 684 684 if( who ) 685 685 { 686 serv_got_typing( gc, who, 5, 1 );686 serv_got_typing( ic, who, 5, 1 ); 687 687 g_free( who ); 688 688 } -
protocols/nogaim.c
rfa29d093 r0da65d5 36 36 #include <ctype.h> 37 37 38 static int remove_chat_buddy_silent( struct conversation*b, char *handle );38 static int remove_chat_buddy_silent( struct groupchat *b, char *handle ); 39 39 40 40 GSList *connections; … … 115 115 void nogaim_init() 116 116 { 117 extern void msn_init ();118 extern void oscar_init ();119 extern void byahoo_init ();120 extern void jabber_init ();117 extern void msn_initmodule(); 118 extern void oscar_initmodule(); 119 extern void byahoo_initmodule(); 120 extern void jabber_initmodule(); 121 121 122 122 #ifdef WITH_MSN 123 msn_init ();123 msn_initmodule(); 124 124 #endif 125 125 126 126 #ifdef WITH_OSCAR 127 oscar_init ();127 oscar_initmodule(); 128 128 #endif 129 129 130 130 #ifdef WITH_YAHOO 131 byahoo_init ();131 byahoo_initmodule(); 132 132 #endif 133 133 134 134 #ifdef WITH_JABBER 135 jabber_init ();135 jabber_initmodule(); 136 136 #endif 137 137 … … 145 145 /* multi.c */ 146 146 147 struct gaim_connection *new_gaim_conn( account_t *acc )148 { 149 struct gaim_connection *gc;150 151 gc = g_new0( struct gaim_connection, 1 );147 struct im_connection *new_gaim_conn( account_t *acc ) 148 { 149 struct im_connection *ic; 150 151 ic = g_new0( struct im_connection, 1 ); 152 152 153 153 /* Maybe we should get rid of this memory waste later. ;-) */ 154 g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user );155 g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass );156 157 gc->irc = acc->irc;158 gc->acc = acc;159 acc-> gc = gc;160 161 connections = g_slist_append( connections, gc );162 163 return( gc );164 } 165 166 void destroy_gaim_conn( struct gaim_connection *gc )154 g_snprintf( ic->username, sizeof( ic->username ), "%s", acc->user ); 155 g_snprintf( ic->password, sizeof( ic->password ), "%s", acc->pass ); 156 157 ic->irc = acc->irc; 158 ic->acc = acc; 159 acc->ic = ic; 160 161 connections = g_slist_append( connections, ic ); 162 163 return( ic ); 164 } 165 166 void destroy_gaim_conn( struct im_connection *ic ) 167 167 { 168 168 account_t *a; 169 169 170 170 /* Destroy the pointer to this connection from the account list */ 171 for( a = gc->irc->accounts; a; a = a->next )172 if( a-> gc == gc )173 { 174 a-> gc = NULL;171 for( a = ic->irc->accounts; a; a = a->next ) 172 if( a->ic == ic ) 173 { 174 a->ic = NULL; 175 175 break; 176 176 } 177 177 178 connections = g_slist_remove( connections, gc );179 g_free( gc );180 } 181 182 void set_login_progress( struct gaim_connection *gc, int step, char *msg )183 { 184 serv_got_crap( gc, "Logging in: %s", msg );178 connections = g_slist_remove( connections, ic ); 179 g_free( ic ); 180 } 181 182 void set_login_progress( struct im_connection *ic, int step, char *msg ) 183 { 184 serv_got_crap( ic, "Logging in: %s", msg ); 185 185 } 186 186 187 187 /* Errors *while* logging in */ 188 void hide_login_progress( struct gaim_connection *gc, char *msg )189 { 190 serv_got_crap( gc, "Login error: %s", msg );188 void hide_login_progress( struct im_connection *ic, char *msg ) 189 { 190 serv_got_crap( ic, "Login error: %s", msg ); 191 191 } 192 192 193 193 /* Errors *after* logging in */ 194 void hide_login_progress_error( struct gaim_connection *gc, char *msg )195 { 196 serv_got_crap( gc, "Logged out: %s", msg );197 } 198 199 void serv_got_crap( struct gaim_connection *gc, char *format, ... )194 void hide_login_progress_error( struct im_connection *ic, char *msg ) 195 { 196 serv_got_crap( ic, "Logged out: %s", msg ); 197 } 198 199 void serv_got_crap( struct im_connection *ic, char *format, ... ) 200 200 { 201 201 va_list params; … … 207 207 va_end( params ); 208 208 209 if( ( g_strcasecmp( set_getstr( & gc->irc->set, "strip_html" ), "always" ) == 0 ) ||210 ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )209 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 210 ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 211 211 strip_html( text ); 212 212 213 213 /* Try to find a different connection on the same protocol. */ 214 for( a = gc->irc->accounts; a; a = a->next )215 if( a->prpl == gc->acc->prpl && a->gc != gc )214 for( a = ic->irc->accounts; a; a = a->next ) 215 if( a->prpl == ic->acc->prpl && a->ic != ic ) 216 216 break; 217 217 218 218 /* If we found one, include the screenname in the message. */ 219 219 if( a ) 220 irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text );220 irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->username, text ); 221 221 else 222 irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text );222 irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text ); 223 223 224 224 g_free( text ); … … 227 227 static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) 228 228 { 229 struct gaim_connection *gc = d;230 231 if( gc->acc->prpl->keepalive )232 gc->acc->prpl->keepalive( gc );229 struct im_connection *ic = d; 230 231 if( ic->acc->prpl->keepalive ) 232 ic->acc->prpl->keepalive( ic ); 233 233 234 234 return TRUE; 235 235 } 236 236 237 void account_online( struct gaim_connection *gc )237 void account_online( struct im_connection *ic ) 238 238 { 239 239 user_t *u; … … 242 242 the whole login sequence again, so these "late" calls to this 243 243 function should be handled correctly. (IOW, ignored) */ 244 if( gc->flags & OPT_LOGGED_IN )244 if( ic->flags & OPT_LOGGED_IN ) 245 245 return; 246 246 247 u = user_find( gc->irc, gc->irc->nick );248 249 serv_got_crap( gc, "Logged in" );250 251 gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );252 gc->flags |= OPT_LOGGED_IN;247 u = user_find( ic->irc, ic->irc->nick ); 248 249 serv_got_crap( ic, "Logged in" ); 250 251 ic->keepalive = b_timeout_add( 60000, send_keepalive, ic ); 252 ic->flags |= OPT_LOGGED_IN; 253 253 254 254 /* Also necessary when we're not away, at least for some of the 255 255 protocols. */ 256 bim_set_away( gc, u->away );256 bim_set_away( ic, u->away ); 257 257 } 258 258 … … 274 274 } 275 275 276 void signoff( struct gaim_connection *gc )277 { 278 irc_t *irc = gc->irc;276 void signoff( struct im_connection *ic ) 277 { 278 irc_t *irc = ic->irc; 279 279 user_t *t, *u = irc->users; 280 280 account_t *a; … … 282 282 /* Nested calls might happen sometimes, this is probably the best 283 283 place to catch them. */ 284 if( gc->flags & OPT_LOGGING_OUT )284 if( ic->flags & OPT_LOGGING_OUT ) 285 285 return; 286 286 else 287 gc->flags |= OPT_LOGGING_OUT;288 289 serv_got_crap( gc, "Signing off.." );290 291 b_event_remove( gc->keepalive );292 gc->keepalive = 0;293 gc->acc->prpl->close( gc );294 b_event_remove( gc->inpa );287 ic->flags |= OPT_LOGGING_OUT; 288 289 serv_got_crap( ic, "Signing off.." ); 290 291 b_event_remove( ic->keepalive ); 292 ic->keepalive = 0; 293 ic->acc->prpl->logout( ic ); 294 b_event_remove( ic->inpa ); 295 295 296 296 while( u ) 297 297 { 298 if( u-> gc == gc )298 if( u->ic == ic ) 299 299 { 300 300 t = u->next; … … 306 306 } 307 307 308 query_del_by_ gc( gc->irc, gc );308 query_del_by_conn( ic->irc, ic ); 309 309 310 310 for( a = irc->accounts; a; a = a->next ) 311 if( a-> gc == gc )311 if( a->ic == ic ) 312 312 break; 313 313 … … 316 316 /* Uhm... This is very sick. */ 317 317 } 318 else if( ! gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&318 else if( !ic->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) && 319 319 set_getbool( &a->set, "auto_reconnect" ) ) 320 320 { 321 321 int delay = set_getint( &irc->set, "auto_reconnect_delay" ); 322 322 323 serv_got_crap( gc, "Reconnecting in %d seconds..", delay );323 serv_got_crap( ic, "Reconnecting in %d seconds..", delay ); 324 324 a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); 325 325 } 326 326 327 destroy_gaim_conn( gc );327 destroy_gaim_conn( ic ); 328 328 } 329 329 … … 331 331 /* dialogs.c */ 332 332 333 void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )333 void do_error_dialog( struct im_connection *ic, char *msg, char *title ) 334 334 { 335 335 if( msg && title ) 336 serv_got_crap( gc, "Error: %s: %s", title, msg );336 serv_got_crap( ic, "Error: %s: %s", title, msg ); 337 337 else if( msg ) 338 serv_got_crap( gc, "Error: %s", msg );338 serv_got_crap( ic, "Error: %s", msg ); 339 339 else if( title ) 340 serv_got_crap( gc, "Error: %s", title );340 serv_got_crap( ic, "Error: %s", title ); 341 341 else 342 serv_got_crap( gc, "Error" );343 } 344 345 void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont )346 { 347 query_add( gc->irc, gc, msg, doit, dont, data );342 serv_got_crap( ic, "Error" ); 343 } 344 345 void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) 346 { 347 query_add( ic->irc, ic, msg, doit, dont, data ); 348 348 } 349 349 … … 351 351 /* list.c */ 352 352 353 void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname )353 void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ) 354 354 { 355 355 user_t *u; 356 356 char nick[MAX_NICK_LENGTH+1]; 357 357 char *s; 358 irc_t *irc = gc->irc;358 irc_t *irc = ic->irc; 359 359 360 360 if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ 361 serv_got_crap( gc, "Receiving user add from handle: %s", handle );362 363 if( user_findhandle( gc, handle ) )361 serv_got_crap( ic, "Receiving user add from handle: %s", handle ); 362 363 if( user_findhandle( ic, handle ) ) 364 364 { 365 365 if( set_getbool( &irc->set, "debug" ) ) 366 serv_got_crap( gc, "User already exists, ignoring add request: %s", handle );366 serv_got_crap( ic, "User already exists, ignoring add request: %s", handle ); 367 367 368 368 return; … … 372 372 373 373 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 374 strcpy( nick, nick_get( gc->acc, handle, realname ) );375 376 u = user_add( gc->irc, nick );374 strcpy( nick, nick_get( ic->acc, handle, realname ) ); 375 376 u = user_add( ic->irc, nick ); 377 377 378 378 if( !realname || !*realname ) realname = nick; … … 384 384 u->user = g_strndup( handle, s - handle ); 385 385 } 386 else if( gc->acc->server )386 else if( ic->acc->server ) 387 387 { 388 388 char *colon; 389 389 390 if( ( colon = strchr( gc->acc->server, ':' ) ) )391 u->host = g_strndup( gc->acc->server,392 colon - gc->acc->server );390 if( ( colon = strchr( ic->acc->server, ':' ) ) ) 391 u->host = g_strndup( ic->acc->server, 392 colon - ic->acc->server ); 393 393 else 394 u->host = g_strdup( gc->acc->server );394 u->host = g_strdup( ic->acc->server ); 395 395 396 396 u->user = g_strdup( handle ); … … 403 403 else 404 404 { 405 u->host = g_strdup( gc->acc->prpl->name );405 u->host = g_strdup( ic->acc->prpl->name ); 406 406 u->user = g_strdup( handle ); 407 407 } 408 408 409 u-> gc = gc;409 u->ic = ic; 410 410 u->handle = g_strdup( handle ); 411 411 if( group ) u->group = g_strdup( group ); … … 414 414 } 415 415 416 struct buddy *find_buddy( struct gaim_connection *gc, char *handle )416 struct buddy *find_buddy( struct im_connection *ic, char *handle ) 417 417 { 418 418 static struct buddy b[1]; 419 419 user_t *u; 420 420 421 u = user_findhandle( gc, handle );421 u = user_findhandle( ic, handle ); 422 422 423 423 if( !u ) … … 428 428 strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); 429 429 b->present = u->online; 430 b-> gc = u->gc;430 b->ic = u->ic; 431 431 432 432 return( b ); 433 433 } 434 434 435 void signoff_blocked( struct gaim_connection *gc )435 void signoff_blocked( struct im_connection *ic ) 436 436 { 437 437 return; /* Make all blocked users look invisible (TODO?) */ … … 439 439 440 440 441 void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname )442 { 443 user_t *u = user_findhandle( gc, handle );441 void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) 442 { 443 user_t *u = user_findhandle( ic, handle ); 444 444 445 445 if( !u ) return; … … 451 451 u->realname = g_strdup( realname ); 452 452 453 if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) )454 serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname );453 if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) 454 serv_got_crap( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 455 455 } 456 456 } … … 461 461 struct show_got_added_data 462 462 { 463 struct gaim_connection *gc;463 struct im_connection *ic; 464 464 char *handle; 465 465 }; … … 473 473 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 474 474 { 475 data-> gc->acc->prpl->add_buddy( data->gc, data->handle);476 add_buddy( data-> gc, NULL, data->handle, data->handle );475 data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL ); 476 add_buddy( data->ic, NULL, data->handle, data->handle ); 477 477 478 478 return show_got_added_no( w, data ); 479 479 } 480 480 481 void show_got_added( struct gaim_connection *gc, char *handle, const char *realname )481 void show_got_added( struct im_connection *ic, char *handle, const char *realname ) 482 482 { 483 483 struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 ); … … 485 485 486 486 /* TODO: Make a setting for this! */ 487 if( user_findhandle( gc, handle ) != NULL )487 if( user_findhandle( ic, handle ) != NULL ) 488 488 return; 489 489 490 490 s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle ); 491 491 492 data-> gc = gc;492 data->ic = ic; 493 493 data->handle = g_strdup( handle ); 494 query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data );494 query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data ); 495 495 } 496 496 … … 498 498 /* server.c */ 499 499 500 void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )500 void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ) 501 501 { 502 502 user_t *u; 503 503 int oa, oo; 504 504 505 u = user_findhandle( gc, handle );505 u = user_findhandle( ic, handle ); 506 506 507 507 if( !u ) 508 508 { 509 if( g_strcasecmp( set_getstr( & gc->irc->set, "handle_unknown" ), "add" ) == 0 )510 { 511 add_buddy( gc, NULL, handle, NULL );512 u = user_findhandle( gc, handle );509 if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) 510 { 511 add_buddy( ic, NULL, handle, NULL ); 512 u = user_findhandle( ic, handle ); 513 513 } 514 514 else 515 515 { 516 if( set_getbool( & gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )516 if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) 517 517 { 518 serv_got_crap( gc, "serv_got_update() for handle %s:", handle );519 serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type );518 serv_got_crap( ic, "serv_got_update() for handle %s:", handle ); 519 serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type ); 520 520 } 521 521 … … 537 537 if( loggedin && !u->online ) 538 538 { 539 irc_spawn( gc->irc, u );539 irc_spawn( ic->irc, u ); 540 540 u->online = 1; 541 541 } 542 542 else if( !loggedin && u->online ) 543 543 { 544 struct conversation*c;545 546 irc_kill( gc->irc, u );544 struct groupchat *c; 545 546 irc_kill( ic->irc, u ); 547 547 u->online = 0; 548 548 549 549 /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ 550 for( c = gc->conversations; c; c = c->next )550 for( c = ic->conversations; c; c = c->next ) 551 551 remove_chat_buddy_silent( c, handle ); 552 552 } 553 553 554 if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) )554 if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) ) 555 555 { 556 556 u->away = g_strdup( "Away" ); 557 557 } 558 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) )558 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "jabber" ) == 0 ) ) 559 559 { 560 560 if( type & UC_DND ) … … 565 565 u->away = g_strdup( "Away" ); 566 566 } 567 else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string )568 { 569 u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) );567 else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string ) 568 { 569 u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) ); 570 570 } 571 571 else … … 573 573 574 574 /* LISPy... */ 575 if( ( set_getbool( & gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */575 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 576 576 ( u->online ) && /* Don't touch offline people */ 577 577 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 578 578 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 579 579 { 580 irc_write( gc->irc, ":%s MODE %s %cv %s", gc->irc->myhost,581 gc->irc->channel, u->away?'-':'+', u->nick );582 } 583 } 584 585 void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len )586 { 587 irc_t *irc = gc->irc;580 irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, 581 ic->irc->channel, u->away?'-':'+', u->nick ); 582 } 583 } 584 585 void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) 586 { 587 irc_t *irc = ic->irc; 588 588 user_t *u; 589 589 590 u = user_findhandle( gc, handle );590 u = user_findhandle( ic, handle ); 591 591 592 592 if( !u ) … … 597 597 { 598 598 if( set_getbool( &irc->set, "debug" ) ) 599 serv_got_crap( gc, "Ignoring message from unknown handle %s", handle );599 serv_got_crap( ic, "Ignoring message from unknown handle %s", handle ); 600 600 601 601 return; … … 613 613 } 614 614 615 add_buddy( gc, NULL, handle, NULL );616 u = user_findhandle( gc, handle );615 add_buddy( ic, NULL, handle, NULL ); 616 u = user_findhandle( ic, handle ); 617 617 u->is_private = private; 618 618 } 619 619 else 620 620 { 621 serv_got_crap( gc, "Message from unknown handle %s:", handle );621 serv_got_crap( ic, "Message from unknown handle %s:", handle ); 622 622 u = user_find( irc, irc->mynick ); 623 623 } 624 624 } 625 625 626 if( ( g_strcasecmp( set_getstr( & gc->irc->set, "strip_html" ), "always" ) == 0 ) ||627 ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )626 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 627 ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 628 628 strip_html( msg ); 629 629 … … 661 661 } 662 662 663 void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type )663 void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ) 664 664 { 665 665 user_t *u; 666 666 667 if( !set_getbool( & gc->irc->set, "typing_notice" ) )667 if( !set_getbool( &ic->irc->set, "typing_notice" ) ) 668 668 return; 669 669 670 if( ( u = user_findhandle( gc, handle ) ) ) {670 if( ( u = user_findhandle( ic, handle ) ) ) { 671 671 /* If type is: 672 672 * 0: user has stopped typing … … 677 677 char buf[256]; 678 678 g_snprintf(buf, 256, "\1TYPING %d\1", type); 679 irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf );680 } 681 } 682 } 683 684 void serv_got_chat_left( struct conversation*c )685 { 686 struct gaim_connection *gc = c->gc;687 struct conversation*l = NULL;679 irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); 680 } 681 } 682 } 683 684 void serv_got_chat_left( struct groupchat *c ) 685 { 686 struct im_connection *ic = c->ic; 687 struct groupchat *l = NULL; 688 688 GList *ir; 689 689 690 if( set_getbool( & gc->irc->set, "debug" ) )691 serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c );690 if( set_getbool( &ic->irc->set, "debug" ) ) 691 serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c ); 692 692 693 693 if( c ) … … 697 697 user_t *u, *r; 698 698 699 r = user_find( gc->irc, gc->irc->mynick );700 irc_privmsg( gc->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );699 r = user_find( ic->irc, ic->irc->mynick ); 700 irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" ); 701 701 702 u = user_find( gc->irc, gc->irc->nick );703 irc_kick( gc->irc, u, c->channel, r );704 /* irc_part( gc->irc, u, c->channel ); */702 u = user_find( ic->irc, ic->irc->nick ); 703 irc_kick( ic->irc, u, c->channel, r ); 704 /* irc_part( ic->irc, u, c->channel ); */ 705 705 } 706 706 … … 708 708 l->next = c->next; 709 709 else 710 gc->conversations = c->next;710 ic->conversations = c->next; 711 711 712 712 for( ir = c->in_room; ir; ir = ir->next ) … … 719 719 } 720 720 721 void serv_got_chat_in( struct conversation*c, char *who, int whisper, char *msg, time_t mtime )722 { 723 struct gaim_connection *gc = c->gc;721 void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ) 722 { 723 struct im_connection *ic = c->ic; 724 724 user_t *u; 725 725 726 726 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ 727 if( g_strcasecmp( who, gc->username ) == 0 )727 if( g_strcasecmp( who, ic->username ) == 0 ) 728 728 return; 729 729 730 u = user_findhandle( gc, who );731 732 if( ( g_strcasecmp( set_getstr( & gc->irc->set, "strip_html" ), "always" ) == 0 ) ||733 ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )730 u = user_findhandle( ic, who ); 731 732 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 733 ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 734 734 strip_html( msg ); 735 735 736 736 if( c && u ) 737 irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg );737 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); 738 738 else 739 serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );740 } 741 742 struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle )743 { 744 struct conversation*c;739 serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); 740 } 741 742 struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) 743 { 744 struct groupchat *c; 745 745 746 746 /* This one just creates the conversation structure, user won't see anything yet */ 747 747 748 if( gc->conversations )749 { 750 for( c = gc->conversations; c->next; c = c->next );751 c = c->next = g_new0( struct conversation, 1 );748 if( ic->conversations ) 749 { 750 for( c = ic->conversations; c->next; c = c->next ); 751 c = c->next = g_new0( struct groupchat, 1 ); 752 752 } 753 753 else 754 gc->conversations = c = g_new0( struct conversation, 1 );755 756 c-> gc = gc;754 ic->conversations = c = g_new0( struct groupchat, 1 ); 755 756 c->ic = ic; 757 757 c->title = g_strdup( handle ); 758 c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ );759 760 if( set_getbool( & gc->irc->set, "debug" ) )761 serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );758 c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); 759 760 if( set_getbool( &ic->irc->set, "debug" ) ) 761 serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); 762 762 763 763 return c; … … 767 767 /* buddy_chat.c */ 768 768 769 void add_chat_buddy( struct conversation*b, char *handle )770 { 771 user_t *u = user_findhandle( b-> gc, handle );769 void add_chat_buddy( struct groupchat *b, char *handle ) 770 { 771 user_t *u = user_findhandle( b->ic, handle ); 772 772 int me = 0; 773 773 774 if( set_getbool( &b-> gc->irc->set, "debug" ) )775 serv_got_crap( b-> gc, "User %s added to conversation 0x%x", handle, (int) b );774 if( set_getbool( &b->ic->irc->set, "debug" ) ) 775 serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); 776 776 777 777 /* It might be yourself! */ 778 if( b-> gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )779 { 780 u = user_find( b-> gc->irc, b->gc->irc->nick );778 if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 ) 779 { 780 u = user_find( b->ic->irc, b->ic->irc->nick ); 781 781 if( !b->joined ) 782 irc_join( b-> gc->irc, u, b->channel );782 irc_join( b->ic->irc, u, b->channel ); 783 783 b->joined = me = 1; 784 784 } … … 788 788 if( !u ) 789 789 { 790 add_buddy( b-> gc, NULL, handle, NULL );791 u = user_findhandle( b-> gc, handle );790 add_buddy( b->ic, NULL, handle, NULL ); 791 u = user_findhandle( b->ic, handle ); 792 792 } 793 793 … … 796 796 { 797 797 if( b->joined ) 798 irc_join( b-> gc->irc, u, b->channel );798 irc_join( b->ic->irc, u, b->channel ); 799 799 b->in_room = g_list_append( b->in_room, g_strdup( handle ) ); 800 800 } 801 801 } 802 802 803 void remove_chat_buddy( struct conversation*b, char *handle, char *reason )803 void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) 804 804 { 805 805 user_t *u; 806 806 int me = 0; 807 807 808 if( set_getbool( &b-> gc->irc->set, "debug" ) )809 serv_got_crap( b-> gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );808 if( set_getbool( &b->ic->irc->set, "debug" ) ) 809 serv_got_crap( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); 810 810 811 811 /* It might be yourself! */ 812 if( g_strcasecmp( handle, b-> gc->username ) == 0 )813 { 814 u = user_find( b-> gc->irc, b->gc->irc->nick );812 if( g_strcasecmp( handle, b->ic->username ) == 0 ) 813 { 814 u = user_find( b->ic->irc, b->ic->irc->nick ); 815 815 b->joined = 0; 816 816 me = 1; … … 818 818 else 819 819 { 820 u = user_findhandle( b-> gc, handle );820 u = user_findhandle( b->ic, handle ); 821 821 } 822 822 823 823 if( remove_chat_buddy_silent( b, handle ) ) 824 824 if( ( b->joined || me ) && u ) 825 irc_part( b-> gc->irc, u, b->channel );826 } 827 828 static int remove_chat_buddy_silent( struct conversation*b, char *handle )825 irc_part( b->ic->irc, u, b->channel ); 826 } 827 828 static int remove_chat_buddy_silent( struct groupchat *b, char *handle ) 829 829 { 830 830 GList *i; … … 850 850 /* Misc. BitlBee stuff which shouldn't really be here */ 851 851 852 struct conversation*chat_by_channel( char *channel )853 { 854 struct gaim_connection *gc;855 struct conversation*c;852 struct groupchat *chat_by_channel( char *channel ) 853 { 854 struct im_connection *ic; 855 struct groupchat *c; 856 856 GSList *l; 857 857 … … 859 859 for( l = connections; l; l = l->next ) 860 860 { 861 gc = l->data;862 for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );861 ic = l->data; 862 for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); 863 863 if( c ) 864 864 return c; … … 899 899 while( u ) 900 900 { 901 if( u-> gc && u->online && !u->away )901 if( u->ic && u->online && !u->away ) 902 902 { 903 903 if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) … … 933 933 them all from some wrappers. We'll start to define some down here: */ 934 934 935 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags )935 int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ) 936 936 { 937 937 char *buf = NULL; 938 938 int st; 939 939 940 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )940 if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 941 941 { 942 942 buf = escape_html( msg ); … … 944 944 } 945 945 946 st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );946 st = ic->acc->prpl->send_im( ic, handle, msg, flags ); 947 947 g_free( buf ); 948 948 … … 950 950 } 951 951 952 int bim_chat_msg( struct conversation *c, char *msg)952 int bim_chat_msg( struct groupchat *c, char *msg, int flags ) 953 953 { 954 954 char *buf = NULL; 955 955 int st; 956 956 957 if( ( c-> gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )957 if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 958 958 { 959 959 buf = escape_html( msg ); … … 961 961 } 962 962 963 st = c->gc->acc->prpl->chat_send( c, msg);963 c->ic->acc->prpl->chat_send( c, msg, flags ); 964 964 g_free( buf ); 965 965 966 return st;966 return 1; 967 967 } 968 968 969 969 static char *bim_away_alias_find( GList *gcm, char *away ); 970 970 971 int bim_set_away( struct gaim_connection *gc, char *away )971 int bim_set_away( struct im_connection *ic, char *away ) 972 972 { 973 973 GList *m, *ms; … … 975 975 976 976 if( !away ) away = ""; 977 ms = m = gc->acc->prpl->away_states( gc );977 ms = m = ic->acc->prpl->away_states( ic ); 978 978 979 979 while( m ) … … 996 996 if( m ) 997 997 { 998 gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL );998 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); 999 999 } 1000 1000 else … … 1003 1003 if( s ) 1004 1004 { 1005 gc->acc->prpl->set_away( gc, s, away );1006 if( set_getbool( & gc->irc->set, "debug" ) )1007 serv_got_crap( gc, "Setting away state to %s", s );1005 ic->acc->prpl->set_away( ic, s, away ); 1006 if( set_getbool( &ic->irc->set, "debug" ) ) 1007 serv_got_crap( ic, "Setting away state to %s", s ); 1008 1008 } 1009 1009 else 1010 gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );1010 ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); 1011 1011 } 1012 1012 … … 1056 1056 } 1057 1057 1058 void bim_add_allow( struct gaim_connection *gc, char *handle )1059 { 1060 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )1061 { 1062 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );1063 } 1064 1065 gc->acc->prpl->add_permit( gc, handle );1066 } 1067 1068 void bim_rem_allow( struct gaim_connection *gc, char *handle )1058 void bim_add_allow( struct im_connection *ic, char *handle ) 1059 { 1060 if( g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) 1061 { 1062 ic->permit = g_slist_prepend( ic->permit, g_strdup( handle ) ); 1063 } 1064 1065 ic->acc->prpl->add_permit( ic, handle ); 1066 } 1067 1068 void bim_rem_allow( struct im_connection *ic, char *handle ) 1069 1069 { 1070 1070 GSList *l; 1071 1071 1072 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )1072 if( ( l = g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) ) 1073 1073 { 1074 1074 g_free( l->data ); 1075 gc->permit = g_slist_delete_link( gc->permit, l );1076 } 1077 1078 gc->acc->prpl->rem_permit( gc, handle );1079 } 1080 1081 void bim_add_block( struct gaim_connection *gc, char *handle )1082 { 1083 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )1084 { 1085 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );1086 } 1087 1088 gc->acc->prpl->add_deny( gc, handle );1089 } 1090 1091 void bim_rem_block( struct gaim_connection *gc, char *handle )1075 ic->permit = g_slist_delete_link( ic->permit, l ); 1076 } 1077 1078 ic->acc->prpl->rem_permit( ic, handle ); 1079 } 1080 1081 void bim_add_block( struct im_connection *ic, char *handle ) 1082 { 1083 if( g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) 1084 { 1085 ic->deny = g_slist_prepend( ic->deny, g_strdup( handle ) ); 1086 } 1087 1088 ic->acc->prpl->add_deny( ic, handle ); 1089 } 1090 1091 void bim_rem_block( struct im_connection *ic, char *handle ) 1092 1092 { 1093 1093 GSList *l; 1094 1094 1095 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )1095 if( ( l = g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) ) 1096 1096 { 1097 1097 g_free( l->data ); 1098 gc->deny = g_slist_delete_link( gc->deny, l );1099 } 1100 1101 gc->acc->prpl->rem_deny( gc, handle );1102 } 1098 ic->deny = g_slist_delete_link( ic->deny, l ); 1099 } 1100 1101 ic->acc->prpl->rem_deny( ic, handle ); 1102 } -
protocols/nogaim.h
rfa29d093 r0da65d5 62 62 63 63 /* ok. now the fun begins. first we create a connection structure */ 64 struct gaim_connection64 struct im_connection 65 65 { 66 66 account_t *acc; … … 92 92 irc_t *irc; 93 93 94 struct conversation*conversations;94 struct groupchat *conversations; 95 95 }; 96 96 97 97 /* struct buddy_chat went away and got merged with this. */ 98 struct conversation{99 struct gaim_connection *gc;98 struct groupchat { 99 struct im_connection *ic; 100 100 101 101 /* stuff used just for chat */ … … 104 104 105 105 /* BitlBee */ 106 struct conversation*next;106 struct groupchat *next; 107 107 char *channel; 108 108 char *title; … … 121 121 guint caps; /* woohoo! */ 122 122 void *proto_data; /* what a hack */ 123 struct gaim_connection *gc; /* the connection it belongs to */123 struct im_connection *ic; /* the connection it belongs to */ 124 124 }; 125 125 … … 128 128 const char *name; 129 129 130 void (* acc_init) (account_t *); 130 /* Added this one to be able to add per-account settings, don't think 131 it should be used for anything else. */ 132 void (* init) (account_t *); 133 /* These should all be pretty obvious. */ 131 134 void (* login) (account_t *); 132 void (* keepalive) (struct gaim_connection *); 133 void (* close) (struct gaim_connection *); 134 135 int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); 136 void (* set_away) (struct gaim_connection *, char *state, char *message); 137 void (* get_away) (struct gaim_connection *, char *who); 138 int (* send_typing) (struct gaim_connection *, char *who, int typing); 139 140 void (* add_buddy) (struct gaim_connection *, char *name); 141 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 142 void (* remove_buddy) (struct gaim_connection *, char *name, char *group); 143 void (* add_permit) (struct gaim_connection *, char *name); 144 void (* add_deny) (struct gaim_connection *, char *name); 145 void (* rem_permit) (struct gaim_connection *, char *name); 146 void (* rem_deny) (struct gaim_connection *, char *name); 147 void (* set_permit_deny)(struct gaim_connection *); 148 149 void (* set_info) (struct gaim_connection *, char *info); 150 void (* get_info) (struct gaim_connection *, char *who); 151 void (* alias_buddy) (struct gaim_connection *, char *who); /* save/store buddy's alias on server list/roster */ 135 void (* keepalive) (struct im_connection *); 136 void (* logout) (struct im_connection *); 137 138 int (* send_im) (struct im_connection *, char *to, char *message, int flags); 139 void (* set_away) (struct im_connection *, char *state, char *message); 140 void (* get_away) (struct im_connection *, char *who); 141 int (* send_typing) (struct im_connection *, char *who, int typing); 142 143 /* For now BitlBee doesn't really handle groups, just set it to NULL. */ 144 void (* add_buddy) (struct im_connection *, char *name, char *group); 145 void (* remove_buddy) (struct im_connection *, char *name, char *group); 146 147 /* Block list stuff. */ 148 void (* add_permit) (struct im_connection *, char *who); 149 void (* add_deny) (struct im_connection *, char *who); 150 void (* rem_permit) (struct im_connection *, char *who); 151 void (* rem_deny) (struct im_connection *, char *who); 152 /* Doesn't actually have UI hooks. */ 153 void (* set_permit_deny)(struct im_connection *); 154 155 /* Request profile info. Free-formatted stuff, the IM module gives back 156 this info via imc_log(). */ 157 void (* get_info) (struct im_connection *, char *who); 158 void (* set_my_name) (struct im_connection *, char *name); 159 void (* set_name) (struct im_connection *, char *who, char *name); 152 160 153 161 /* Group chat stuff. */ 154 void (* chat_invite) (struct conversation*, char *who, char *message);155 void (* chat_leave) (struct conversation*);156 int (* chat_send) (struct conversation *, char *message);157 struct conversation*158 (* chat_ open) (struct gaim_connection *, char *who);159 struct conversation*160 (* chat_join) (struct gaim_connection *, char *chat, char *nick, char *password);162 void (* chat_invite) (struct groupchat *, char *who, char *message); 163 void (* chat_leave) (struct groupchat *); 164 void (* chat_send) (struct groupchat *, char *message, int flags); 165 struct groupchat * 166 (* chat_with) (struct im_connection *, char *who); 167 struct groupchat * 168 (* chat_join) (struct im_connection *, char *chat, char *nick, char *password); 161 169 162 170 /* DIE! */ 163 char *(* get_status_string) (struct gaim_connection *gc, int stat);164 165 GList *(* away_states)(struct gaim_connection *gc);171 char *(* get_status_string) (struct im_connection *ic, int stat); 172 173 GList *(* away_states)(struct im_connection *ic); 166 174 167 175 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ … … 182 190 183 191 /* nogaim.c */ 184 int bim_set_away( struct gaim_connection *gc, char *away );185 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags );186 int bim_chat_msg( struct conversation *c, char *msg);187 188 void bim_add_allow( struct gaim_connection *gc, char *handle );189 void bim_rem_allow( struct gaim_connection *gc, char *handle );190 void bim_add_block( struct gaim_connection *gc, char *handle );191 void bim_rem_block( struct gaim_connection *gc, char *handle );192 int bim_set_away( struct im_connection *ic, char *away ); 193 int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ); 194 int bim_chat_msg( struct groupchat *c, char *msg, int flags ); 195 196 void bim_add_allow( struct im_connection *ic, char *handle ); 197 void bim_rem_allow( struct im_connection *ic, char *handle ); 198 void bim_add_block( struct im_connection *ic, char *handle ); 199 void bim_rem_block( struct im_connection *ic, char *handle ); 192 200 193 201 void nogaim_init(); … … 198 206 199 207 /* multi.c */ 200 G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( account_t *acc );201 G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc );202 G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg );203 G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg );204 G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg );205 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );206 G_MODULE_EXPORT void account_online( struct gaim_connection *gc );207 G_MODULE_EXPORT void signoff( struct gaim_connection *gc );208 G_MODULE_EXPORT struct im_connection *new_gaim_conn( account_t *acc ); 209 G_MODULE_EXPORT void destroy_gaim_conn( struct im_connection *ic ); 210 G_MODULE_EXPORT void set_login_progress( struct im_connection *ic, int step, char *msg ); 211 G_MODULE_EXPORT void hide_login_progress( struct im_connection *ic, char *msg ); 212 G_MODULE_EXPORT void hide_login_progress_error( struct im_connection *ic, char *msg ); 213 G_MODULE_EXPORT void serv_got_crap( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 214 G_MODULE_EXPORT void account_online( struct im_connection *ic ); 215 G_MODULE_EXPORT void signoff( struct im_connection *ic ); 208 216 209 217 /* dialogs.c */ 210 G_MODULE_EXPORT void do_error_dialog( struct gaim_connection *gc, char *msg, char *title );211 G_MODULE_EXPORT void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont );218 G_MODULE_EXPORT void do_error_dialog( struct im_connection *ic, char *msg, char *title ); 219 G_MODULE_EXPORT void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ); 212 220 213 221 /* list.c */ 214 G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname );215 G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle );216 G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc );217 218 G_MODULE_EXPORT void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname );222 G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ); 223 G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle ); 224 G_MODULE_EXPORT void signoff_blocked( struct im_connection *ic ); 225 226 G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ); 219 227 220 228 /* buddy_chat.c */ 221 G_MODULE_EXPORT void add_chat_buddy( struct conversation*b, char *handle );222 G_MODULE_EXPORT void remove_chat_buddy( struct conversation*b, char *handle, char *reason );229 G_MODULE_EXPORT void add_chat_buddy( struct groupchat *b, char *handle ); 230 G_MODULE_EXPORT void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ); 223 231 224 232 /* prpl.c */ 225 G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname );233 G_MODULE_EXPORT void show_got_added( struct im_connection *ic, char *handle, const char *realname ); 226 234 227 235 /* server.c */ 228 G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );229 G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );230 G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type );231 G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data );232 G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle );233 G_MODULE_EXPORT void serv_got_chat_in( struct conversation*c, char *who, int whisper, char *msg, time_t mtime );234 G_MODULE_EXPORT void serv_got_chat_left( struct conversation*c );235 236 struct conversation*chat_by_channel( char *channel );237 struct conversation*chat_by_id( int id );236 G_MODULE_EXPORT void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ); 237 G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ); 238 G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ); 239 G_MODULE_EXPORT void serv_got_chat_invite( struct im_connection *ic, char *handle, char *who, char *msg, GList *data ); 240 G_MODULE_EXPORT struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ); 241 G_MODULE_EXPORT void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ); 242 G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c ); 243 244 struct groupchat *chat_by_channel( char *channel ); 245 struct groupchat *chat_by_id( int id ); 238 246 239 247 #endif -
protocols/oscar/aim.h
rfa29d093 r0da65d5 574 574 575 575 struct aim_chat_invitation { 576 struct gaim_connection * gc;576 struct im_connection * ic; 577 577 char * name; 578 578 guint8 exchange; -
protocols/oscar/im.c
rfa29d093 r0da65d5 1417 1417 guint8 *plugin; 1418 1418 int i = 0, tmp = 0; 1419 struct gaim_connection *gc = sess->aux_data;1419 struct im_connection *ic = sess->aux_data; 1420 1420 1421 1421 /* at the moment we just can deal with requests, not with cancel or accept */ … … 1469 1469 case 0x9c: /* ICQ 5 seems to send this */ 1470 1470 aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie, 1471 gc->away ? gc->away : "", sess->aim_icq_state, dc);1471 ic->away ? ic->away : "", sess->aim_icq_state, dc); 1472 1472 break; 1473 1473 -
protocols/oscar/oscar.c
rfa29d093 r0da65d5 116 116 int inpa; 117 117 int id; 118 struct gaim_connection *gc; /* i hate this. */119 struct conversation*cnv; /* bah. */118 struct im_connection *ic; /* i hate this. */ 119 struct groupchat *cnv; /* bah. */ 120 120 int maxlen; 121 121 int maxvis; … … 123 123 124 124 struct ask_direct { 125 struct gaim_connection *gc;125 struct im_connection *ic; 126 126 char *sn; 127 127 char ip[64]; … … 130 130 131 131 struct icq_auth { 132 struct gaim_connection *gc;132 struct im_connection *ic; 133 133 guint32 uin; 134 134 }; … … 158 158 } 159 159 160 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,160 static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic, 161 161 aim_conn_t *conn) { 162 GSList *g = ((struct oscar_data *) gc->proto_data)->oscar_chats;162 GSList *g = ((struct oscar_data *)ic->proto_data)->oscar_chats; 163 163 struct chat_connection *c = NULL; 164 164 … … 243 243 aim_conn_t *conn = (aim_conn_t *)data; 244 244 aim_session_t *sess = aim_conn_getsess(conn); 245 struct gaim_connection *gc = sess ? sess->aux_data : NULL;245 struct im_connection *ic = sess ? sess->aux_data : NULL; 246 246 struct oscar_data *odata; 247 247 248 if (! gc) {249 /* gc is null. we return, else we seg SIGSEG on next line. */248 if (!ic) { 249 /* ic is null. we return, else we seg SIGSEG on next line. */ 250 250 return FALSE; 251 251 } 252 252 253 if (!g_slist_find(get_connections(), gc)) {253 if (!g_slist_find(get_connections(), ic)) { 254 254 /* oh boy. this is probably bad. i guess the only thing we 255 255 * can really do is return? */ … … 257 257 } 258 258 259 odata = (struct oscar_data *) gc->proto_data;259 odata = (struct oscar_data *)ic->proto_data; 260 260 261 261 if (condition & GAIM_INPUT_READ) { … … 263 263 aim_rxdispatch(odata->sess); 264 264 if (odata->killme) 265 signoff( gc);265 signoff(ic); 266 266 } else { 267 267 if ((conn->type == AIM_CONN_TYPE_BOS) || 268 268 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { 269 hide_login_progress_error( gc, _("Disconnected."));270 signoff( gc);269 hide_login_progress_error(ic, _("Disconnected.")); 270 signoff(ic); 271 271 } else if (conn->type == AIM_CONN_TYPE_CHAT) { 272 struct chat_connection *c = find_oscar_chat_by_conn( gc, conn);272 struct chat_connection *c = find_oscar_chat_by_conn(ic, conn); 273 273 char buf[BUF_LONG]; 274 274 c->conn = NULL; … … 313 313 static gboolean oscar_login_connect(gpointer data, gint source, b_input_condition cond) 314 314 { 315 struct gaim_connection *gc = data;315 struct im_connection *ic = data; 316 316 struct oscar_data *odata; 317 317 aim_session_t *sess; 318 318 aim_conn_t *conn; 319 319 320 if (!g_slist_find(get_connections(), gc)) {320 if (!g_slist_find(get_connections(), ic)) { 321 321 closesocket(source); 322 322 return FALSE; 323 323 } 324 324 325 odata = gc->proto_data;325 odata = ic->proto_data; 326 326 sess = odata->sess; 327 327 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); 328 328 329 329 if (source < 0) { 330 hide_login_progress( gc, _("Couldn't connect to host"));331 signoff( gc);330 hide_login_progress(ic, _("Couldn't connect to host")); 331 signoff(ic); 332 332 return FALSE; 333 333 } 334 334 335 335 aim_conn_completeconnect(sess, conn); 336 gc->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,336 ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ, 337 337 oscar_callback, conn); 338 338 … … 340 340 } 341 341 342 static void oscar_ acc_init(account_t *acc)342 static void oscar_init(account_t *acc) 343 343 { 344 344 set_t *s; … … 357 357 aim_conn_t *conn; 358 358 char buf[256]; 359 struct gaim_connection *gc = new_gaim_conn(acc);360 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1);359 struct im_connection *ic = new_gaim_conn(acc); 360 struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); 361 361 362 362 if (isdigit(acc->user[0])) { … … 365 365 We don't do those anymore, but let's stick with it, just in case 366 366 it accidentally fixes something else too... </bitlbee> */ 367 gc->password[8] = 0;367 &