Changeset 0da65d5 for protocols/jabber/jabber.c
- Timestamp:
- 2007-03-31T05:40:45Z (17 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.