comparison src/core.c @ 5213:1cf4eb75e3ee

[gaim-migrate @ 5583] More debug_printf -> gaim_debug. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 26 Apr 2003 07:15:59 +0000
parents fefad67de2c7
children a2f26666de42
comparison
equal deleted inserted replaced
5212:740303e8425b 5213:1cf4eb75e3ee
176 p = cui_packet_new(CUI_TYPE_META, CUI_META_ACK); 176 p = cui_packet_new(CUI_TYPE_META, CUI_META_ACK);
177 cui_send_packet(g_io_channel_unix_get_fd(ui->channel), p); 177 cui_send_packet(g_io_channel_unix_get_fd(ui->channel), p);
178 cui_packet_free(p); 178 cui_packet_free(p);
179 break; 179 break;
180 default: 180 default:
181 debug_printf("unhandled meta subtype %d\n", subtype); 181 gaim_debug(GAIM_DEBUG_WARNING, "cui",
182 "Unhandled meta subtype %d\n", subtype);
182 break; 183 break;
183 } 184 }
184 185
185 if(error) 186 if(error)
186 g_error_free(error); 187 g_error_free(error);
206 if (p) { 207 if (p) {
207 gaim_plugin_unload(p); 208 gaim_plugin_unload(p);
208 } 209 }
209 break; 210 break;
210 default: 211 default:
211 debug_printf("unhandled plugin subtype %d\n", subtype); 212 gaim_debug(GAIM_DEBUG_WARNING, "cui",
213 "Unhandled plugin subtype %d\n", subtype);
212 break; 214 break;
213 } 215 }
214 #endif 216 #endif
215 } 217 }
216 218
238 if (account) 240 if (account)
239 serv_login(account); 241 serv_login(account);
240 /* don't need to do anything here because the UI will get updates from other handlers */ 242 /* don't need to do anything here because the UI will get updates from other handlers */
241 break; 243 break;
242 default: 244 default:
243 debug_printf("unhandled user subtype %d\n", subtype); 245 gaim_debug(GAIM_DEBUG_WARNING, "cui",
246 "Unhandled user subtype %d\n", subtype);
244 break; 247 break;
245 } 248 }
246 } 249 }
247 250
248 static void message_handler(struct UI *ui, guchar subtype, guchar *data) 251 static void message_handler(struct UI *ui, guchar subtype, guchar *data)
285 } 288 }
286 break; 289 break;
287 case CUI_MESSAGE_RECV: 290 case CUI_MESSAGE_RECV:
288 break; 291 break;
289 default: 292 default:
290 debug_printf("unhandled message subtype %d\n", subtype); 293 gaim_debug(GAIM_DEBUG_WARNING, "cui",
294 "Unhandled message subtype %d\n", subtype);
291 break; 295 break;
292 } 296 }
293 } 297 }
294 298
295 static gint gaim_recv(GIOChannel *source, guchar *buf, gint len) 299 static gint gaim_recv(GIOChannel *source, guchar *buf, gint len)
327 resp = handle_uri(send); 331 resp = handle_uri(send);
328 g_free(send); 332 g_free(send);
329 /* report error */ 333 /* report error */
330 break; 334 break;
331 default: 335 default:
332 debug_printf("Unhandled remote subtype %d\n", subtype); 336 gaim_debug(GAIM_DEBUG_WARNING, "cui",
337 "Unhandled remote subtype %d\n", subtype);
333 break; 338 break;
334 } 339 }
335 } 340 }
336 341
337 static gboolean UI_readable(GIOChannel *source, GIOCondition cond, gpointer data) 342 static gboolean UI_readable(GIOChannel *source, GIOCondition cond, gpointer data)
346 351
347 guchar *in; 352 guchar *in;
348 353
349 /* no byte order worries! this'll change if we go to TCP */ 354 /* no byte order worries! this'll change if we go to TCP */
350 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { 355 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) {
351 debug_printf("UI has abandoned us!\n"); 356 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n");
352 uis = g_slist_remove(uis, ui); 357 uis = g_slist_remove(uis, ui);
353 g_io_channel_shutdown(ui->channel, TRUE, &error); 358 g_io_channel_shutdown(ui->channel, TRUE, &error);
354 if(error) { 359 if(error) {
355 g_error_free(error); 360 g_error_free(error);
356 error = NULL; 361 error = NULL;
359 g_free(ui); 364 g_free(ui);
360 return FALSE; 365 return FALSE;
361 } 366 }
362 367
363 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { 368 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) {
364 debug_printf("UI has abandoned us!\n"); 369 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n");
365 uis = g_slist_remove(uis, ui); 370 uis = g_slist_remove(uis, ui);
366 g_io_channel_shutdown(ui->channel, TRUE, &error); 371 g_io_channel_shutdown(ui->channel, TRUE, &error);
367 if(error) { 372 if(error) {
368 g_error_free(error); 373 g_error_free(error);
369 error = NULL; 374 error = NULL;
372 g_free(ui); 377 g_free(ui);
373 return FALSE; 378 return FALSE;
374 } 379 }
375 380
376 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) { 381 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) {
377 debug_printf("UI has abandoned us!\n"); 382 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n");
378 uis = g_slist_remove(uis, ui); 383 uis = g_slist_remove(uis, ui);
379 g_io_channel_shutdown(ui->channel, TRUE, &error); 384 g_io_channel_shutdown(ui->channel, TRUE, &error);
380 if(error) { 385 if(error) {
381 g_error_free(error); 386 g_error_free(error);
382 error = NULL; 387 error = NULL;
387 } 392 }
388 393
389 if (len) { 394 if (len) {
390 in = g_new0(guchar, len); 395 in = g_new0(guchar, len);
391 if (gaim_recv(source, in, len) != len) { 396 if (gaim_recv(source, in, len) != len) {
392 debug_printf("UI has abandoned us!\n"); 397 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n");
393 uis = g_slist_remove(uis, ui); 398 uis = g_slist_remove(uis, ui);
394 g_io_channel_shutdown(ui->channel, TRUE, &error); 399 g_io_channel_shutdown(ui->channel, TRUE, &error);
395 if(error) { 400 if(error) {
396 g_error_free(error); 401 g_error_free(error);
397 error = NULL; 402 error = NULL;
430 break; 435 break;
431 */ 436 */
432 case CUI_TYPE_REMOTE: 437 case CUI_TYPE_REMOTE:
433 remote_handler(ui, subtype, in, len); 438 remote_handler(ui, subtype, in, len);
434 break; 439 break;
435 default: 440 default:
436 debug_printf("unhandled type %d\n", type); 441 gaim_debug(GAIM_DEBUG_WARNING, "cui",
442 "Unhandled type %d\n", type);
437 break; 443 break;
438 } 444 }
439 445
440 if (in) 446 if (in)
441 g_free(in); 447 g_free(in);
458 464
459 ui->channel = g_io_channel_unix_new(fd); 465 ui->channel = g_io_channel_unix_new(fd);
460 ui->inpa = g_io_add_watch(ui->channel, G_IO_IN | G_IO_HUP | G_IO_ERR, UI_readable, ui); 466 ui->inpa = g_io_add_watch(ui->channel, G_IO_IN | G_IO_HUP | G_IO_ERR, UI_readable, ui);
461 g_io_channel_unref(ui->channel); 467 g_io_channel_unref(ui->channel);
462 468
463 debug_printf("got one\n"); 469 gaim_debug(GAIM_DEBUG_MISC, "cui", "Got one\n");
464 return TRUE; 470 return TRUE;
465 } 471 }
466 472
467 static gint open_socket() 473 static gint open_socket()
468 { 474 {
470 gint fd; 476 gint fd;
471 477
472 while (gaim_session_exists(gaim_session)) 478 while (gaim_session_exists(gaim_session))
473 gaim_session++; 479 gaim_session++;
474 480
475 debug_printf("session: %d\n", gaim_session); 481 gaim_debug(GAIM_DEBUG_MISC, "cui", "Session: %d\n", gaim_session);
476 482
477 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { 483 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) {
478 mode_t m = umask(0177); 484 mode_t m = umask(0177);
479 saddr.sun_family = AF_UNIX; 485 saddr.sun_family = AF_UNIX;
480 486
528 534
529 void core_quit() 535 void core_quit()
530 { 536 {
531 /* don't save prefs after plugins are gone... */ 537 /* don't save prefs after plugins are gone... */
532 #ifndef _WIN32 538 #ifndef _WIN32
533 {
534 char buf[1024]; 539 char buf[1024];
535 close(UI_fd); 540 close(UI_fd);
536 sprintf(buf, "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session); 541 sprintf(buf, "%s" G_DIR_SEPARATOR_S "gaim_%s.%d",
542 g_get_tmp_dir(), g_get_user_name(), gaim_session);
543
537 unlink(buf); 544 unlink(buf);
538 debug_printf("Removed core\n"); 545
539 } 546 gaim_debug(GAIM_DEBUG_MISC, "core", "Removed core\n");
540 #endif 547 #endif
541 } 548 }