comparison libpurple/protocols/msn/directconn.c @ 19797:60bc06498746

Committing khc's msnp14 changes from Trac Ticket #148. --rlaager committer: Richard Laager <rlaager@wiktel.com>
author Ka-Hing Cheung <khc@hxbc.us>
date Sun, 15 Apr 2007 04:12:27 +0000
parents 32c366eeeb99
children 5048651671e1
comparison
equal deleted inserted replaced
16121:6167ee79ecd0 19797:60bc06498746
74 74
75 /************************************************************************** 75 /**************************************************************************
76 * Connection Functions 76 * Connection Functions
77 **************************************************************************/ 77 **************************************************************************/
78 78
79 #if 0
80 static int 79 static int
81 create_listener(int port) 80 create_listener(int port)
82 { 81 {
83 int fd; 82 int fd;
84 const int on = 1; 83 const int on = 1;
158 157
159 fcntl(fd, F_SETFL, O_NONBLOCK); 158 fcntl(fd, F_SETFL, O_NONBLOCK);
160 159
161 return fd; 160 return fd;
162 } 161 }
163 #endif
164 162
165 static size_t 163 static size_t
166 msn_directconn_write(MsnDirectConn *directconn, 164 msn_directconn_write(MsnDirectConn *directconn,
167 const char *data, size_t len) 165 const char *data, size_t len)
168 { 166 {
286 if (len <= 0) 284 if (len <= 0)
287 { 285 {
288 /* ERROR */ 286 /* ERROR */
289 purple_debug_error("msn", "error reading\n"); 287 purple_debug_error("msn", "error reading\n");
290 288
289 if (directconn->inpa)
290 purple_input_remove(directconn->inpa);
291
292 close(directconn->fd);
293
291 msn_directconn_destroy(directconn); 294 msn_directconn_destroy(directconn);
292 295
293 return; 296 return;
294 } 297 }
295 298
299 302
300 if (body_len <= 0) 303 if (body_len <= 0)
301 { 304 {
302 /* ERROR */ 305 /* ERROR */
303 purple_debug_error("msn", "error reading\n"); 306 purple_debug_error("msn", "error reading\n");
307
308 if (directconn->inpa)
309 purple_input_remove(directconn->inpa);
310
311 close(directconn->fd);
304 312
305 msn_directconn_destroy(directconn); 313 msn_directconn_destroy(directconn);
306 314
307 return; 315 return;
308 } 316 }
346 else 354 else
347 { 355 {
348 /* ERROR */ 356 /* ERROR */
349 purple_debug_error("msn", "error reading\n"); 357 purple_debug_error("msn", "error reading\n");
350 358
359 if (directconn->inpa)
360 purple_input_remove(directconn->inpa);
361
362 close(directconn->fd);
363
351 msn_directconn_destroy(directconn); 364 msn_directconn_destroy(directconn);
352 } 365 }
353 } 366 }
354 367
355 static void 368 static void
356 connect_cb(gpointer data, gint source, const gchar *error_message) 369 connect_cb(gpointer data, gint source, PurpleInputCondition cond)
357 { 370 {
358 MsnDirectConn* directconn; 371 MsnDirectConn* directconn;
359 int fd; 372 int fd;
360 373
361 purple_debug_misc("msn", "directconn: connect_cb: %d\n", source); 374 purple_debug_misc("msn", "directconn: connect_cb: %d, %d.\n", source, cond);
362 375
363 directconn = data; 376 directconn = data;
364 directconn->connect_data = NULL; 377 directconn->connect_data = NULL;
365 378
366 if (TRUE) 379 if (TRUE)
432 } 445 }
433 else 446 else
434 return FALSE; 447 return FALSE;
435 } 448 }
436 449
437 #if 0
438 void 450 void
439 msn_directconn_listen(MsnDirectConn *directconn) 451 msn_directconn_listen(MsnDirectConn *directconn)
440 { 452 {
441 int port; 453 int port;
442 int fd; 454 int fd;
452 directconn); 464 directconn);
453 465
454 directconn->port = port; 466 directconn->port = port;
455 directconn->c = 0; 467 directconn->c = 0;
456 } 468 }
457 #endif
458 469
459 MsnDirectConn* 470 MsnDirectConn*
460 msn_directconn_new(MsnSlpLink *slplink) 471 msn_directconn_new(MsnSlpLink *slplink)
461 { 472 {
462 MsnDirectConn *directconn; 473 MsnDirectConn *directconn;
474 } 485 }
475 486
476 void 487 void
477 msn_directconn_destroy(MsnDirectConn *directconn) 488 msn_directconn_destroy(MsnDirectConn *directconn)
478 { 489 {
490
479 if (directconn->connect_data != NULL) 491 if (directconn->connect_data != NULL)
480 purple_proxy_connect_cancel(directconn->connect_data); 492 purple_proxy_connect_cancel(directconn->connect_data);
481 493
482 if (directconn->inpa != 0) 494 if (directconn->inpa != 0)
483 purple_input_remove(directconn->inpa); 495 purple_input_remove(directconn->inpa);