Mercurial > pidgin
comparison src/browser.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 | 1bf59e3ac4ff |
| children | a2f26666de42 |
comparison
equal
deleted
inserted
replaced
| 5212:740303e8425b | 5213:1cf4eb75e3ee |
|---|---|
| 259 gdk_window_destroy(remote_window); | 259 gdk_window_destroy(remote_window); |
| 260 remote_window = NULL; | 260 remote_window = NULL; |
| 261 } | 261 } |
| 262 | 262 |
| 263 if (!XQueryTree(gdk_display, root, &root2, &parent, &kids, &nkids)) { | 263 if (!XQueryTree(gdk_display, root, &root2, &parent, &kids, &nkids)) { |
| 264 debug_printf("%s: XQueryTree failed on display %s\n", progname, | 264 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 265 DisplayString(gdk_display)); | 265 "%s: XQueryTree failed on display %s\n", |
| 266 progname, DisplayString(gdk_display)); | |
| 266 return NULL; | 267 return NULL; |
| 267 } | 268 } |
| 268 | 269 |
| 269 /* root != root2 is possible with virtual root WMs. */ | 270 /* root != root2 is possible with virtual root WMs. */ |
| 270 | 271 |
| 271 if (!(kids && nkids)) { | 272 if (!(kids && nkids)) { |
| 272 debug_printf("%s: root window has no children on display %s\n", | 273 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 273 progname, DisplayString(gdk_display)); | 274 "%s: root window has no children on display %s\n", |
| 275 progname, DisplayString(gdk_display)); | |
| 274 return NULL; | 276 return NULL; |
| 275 } | 277 } |
| 276 | 278 |
| 277 for (i = nkids - 1; i >= 0; i--) { | 279 for (i = nkids - 1; i >= 0; i--) { |
| 278 Window w = GClientWindow(gdk_display, kids[i]); | 280 Window w = GClientWindow(gdk_display, kids[i]); |
| 296 } | 298 } |
| 297 | 299 |
| 298 XFree(kids); | 300 XFree(kids); |
| 299 | 301 |
| 300 if (result && tenative) { | 302 if (result && tenative) { |
| 301 debug_printf("%s: warning: both version %s (0x%x) and version\n" | 303 gaim_debug(GAIM_DEBUG_WARNING, "browser", |
| 302 "\t%s (0x%x) are running. Using version %s.\n", | 304 "%s: both version %s (0x%x) and version %s (%0x%x) " |
| 303 progname, tenative_version, (unsigned int)tenative, | 305 "are running. Using version %s.\n", |
| 304 expected_mozilla_version, (unsigned int)result, expected_mozilla_version); | 306 progname, tenative_version, (unsigned int)tenative, |
| 307 expected_mozilla_version, (unsigned int)result, | |
| 308 expected_mozilla_version); | |
| 305 XFree(tenative_version); | 309 XFree(tenative_version); |
| 306 return gdk_window_foreign_new(result); | 310 return gdk_window_foreign_new(result); |
| 307 } else if (tenative) { | 311 } else if (tenative) { |
| 308 debug_printf("%s: warning: expected version %s but found version\n" | 312 gaim_debug(GAIM_DEBUG_WARNING, "browser", |
| 309 "\t%s (0x%x) instead.\n", | 313 "%s: expected version %s but found version %s (0x%x) " |
| 310 progname, expected_mozilla_version, | 314 "instead.\n", |
| 311 tenative_version, (unsigned int)tenative); | 315 progname, expected_mozilla_version, |
| 316 tenative_version, (unsigned int)tenative); | |
| 312 XFree(tenative_version); | 317 XFree(tenative_version); |
| 313 return gdk_window_foreign_new(tenative); | 318 return gdk_window_foreign_new(tenative); |
| 314 } else if (result) { | 319 } else if (result) { |
| 315 return gdk_window_foreign_new(result); | 320 return gdk_window_foreign_new(result); |
| 316 } else { | 321 } else { |
| 317 debug_printf("%s: not running on display %s\n", progname, DisplayString(gdk_display)); | 322 gaim_debug(GAIM_DEBUG_ERROR, "%s: not running on display %s\n", |
| 323 progname, DisplayString(gdk_display)); | |
| 318 return NULL; | 324 return NULL; |
| 319 } | 325 } |
| 320 } | 326 } |
| 321 | 327 |
| 322 | 328 |
| 350 gdk_x11_xatom_to_atom (XA_STRING), 0, | 356 gdk_x11_xatom_to_atom (XA_STRING), 0, |
| 351 (65536 / sizeof(long)), 0, | 357 (65536 / sizeof(long)), 0, |
| 352 &actual_type, &actual_format, &nitems, &data)) { | 358 &actual_type, &actual_format, &nitems, &data)) { |
| 353 | 359 |
| 354 /* It's not now locked - lock it. */ | 360 /* It's not now locked - lock it. */ |
| 355 debug_printf("%s: (writing " MOZILLA_LOCK_PROP " \"%s\" to 0x%x)\n", | 361 gaim_debug(GAIM_DEBUG_MISC, "browser", |
| 356 progname, lock_data, (unsigned int) window); | 362 "%s: writing " MOZILLA_LOCK_PROP " \"%s\" to 0x%x\n", |
| 357 | 363 progname, lock_data, (unsigned int)window); |
| 358 gdk_property_change(window, GDKA_MOZILLA_LOCK, | 364 |
| 359 gdk_x11_xatom_to_atom (XA_STRING), | 365 gdk_property_change(window, GDKA_MOZILLA_LOCK, |
| 360 8, PropModeReplace, | 366 gdk_x11_xatom_to_atom (XA_STRING), |
| 361 (unsigned char *)lock_data, strlen(lock_data)); | 367 8, PropModeReplace, |
| 362 locked = True; | 368 (unsigned char *)lock_data, strlen(lock_data)); |
| 363 } | 369 locked = True; |
| 364 | 370 } |
| 365 if (data) | 371 |
| 366 g_free(data); | 372 if (data) |
| 373 g_free(data); | |
| 374 | |
| 367 gdk_x11_ungrab_server(); | 375 gdk_x11_ungrab_server(); |
| 368 } | 376 } |
| 369 | 377 |
| 370 | 378 |
| 371 static void mozilla_remote_free_lock(GdkWindow * window) | 379 static void mozilla_remote_free_lock(GdkWindow * window) |
| 375 gint actual_format; | 383 gint actual_format; |
| 376 gint nitems; | 384 gint nitems; |
| 377 unsigned char *data = 0; | 385 unsigned char *data = 0; |
| 378 const char *lock_data = get_lock_data(); | 386 const char *lock_data = get_lock_data(); |
| 379 | 387 |
| 380 debug_printf("%s: (deleting " MOZILLA_LOCK_PROP | 388 gaim_debug(GAIM_DEBUG_MISC, "browser", |
| 381 " \"%s\" from 0x%x)\n", progname, lock_data, (unsigned int)window); | 389 "%s: deleting " MOZILLA_LOCK_PROP " \"%s\" from 0x%x\n", |
| 390 progname, lock_data, (unsigned int)window); | |
| 382 | 391 |
| 383 result = gdk_property_get(window, GDKA_MOZILLA_LOCK, | 392 result = gdk_property_get(window, GDKA_MOZILLA_LOCK, |
| 384 gdk_x11_xatom_to_atom (XA_STRING), | 393 gdk_x11_xatom_to_atom (XA_STRING), |
| 385 0, (65536 / sizeof(long)), | 394 0, (65536 / sizeof(long)), |
| 386 1, &actual_type, &actual_format, &nitems, &data); | 395 1, &actual_type, &actual_format, &nitems, &data); |
| 387 | 396 |
| 388 if (result != TRUE) { | 397 if (result != TRUE) { |
| 389 debug_printf("%s: unable to read and delete " MOZILLA_LOCK_PROP " property\n", progname); | 398 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 399 "%s: Unable to read and delete " MOZILLA_LOCK_PROP | |
| 400 " property\n", progname); | |
| 390 return; | 401 return; |
| 391 } else if (!data || !*data) { | 402 } else if (!data || !*data) { |
| 392 debug_printf("%s: invalid data on " MOZILLA_LOCK_PROP | 403 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 393 " of window 0x%x.\n", progname, (unsigned int)window); | 404 "%s: Invalid data on " MOZILLA_LOCK_PROP |
| 405 " of wnidow 0x%x\n", progname, (unsigned int)window); | |
| 394 return; | 406 return; |
| 395 } else if (strcmp((char *)data, lock_data)) { | 407 } else if (strcmp((char *)data, lock_data)) { |
| 396 debug_printf("%s: " MOZILLA_LOCK_PROP | 408 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 397 " was stolen! Expected \"%s\", saw \"%s\"!\n", progname, lock_data, data); | 409 "%s: " MOZILLA_LOCK_PROP " was stolen! Expected \"%s\", " |
| 410 "saw \"%s\"!\n", progname, lock_data, data); | |
| 398 return; | 411 return; |
| 399 } | 412 } |
| 400 | 413 |
| 401 XFree(data); | 414 XFree(data); |
| 402 } | 415 } |
| 410 unsigned char *data = 0; | 423 unsigned char *data = 0; |
| 411 | 424 |
| 412 if (window == NULL || GDK_WINDOW_OBJECT(window)->destroyed) { | 425 if (window == NULL || GDK_WINDOW_OBJECT(window)->destroyed) { |
| 413 do_error_dialog(_("Communication with the browser failed. Please close all " | 426 do_error_dialog(_("Communication with the browser failed. Please close all " |
| 414 "windows and try again."), NULL, GAIM_ERROR); | 427 "windows and try again."), NULL, GAIM_ERROR); |
| 415 debug_printf("netscape_response_cb called with NULL window.\n"); | 428 gaim_debug(GAIM_DEBUG_WARNING, "browser", |
| 429 "netscape_response_cb called with NULL window.\n"); | |
| 416 return GDK_FILTER_CONTINUE; | 430 return GDK_FILTER_CONTINUE; |
| 417 } | 431 } |
| 418 | 432 |
| 419 mozilla_response = gdk_x11_atom_to_xatom(GDKA_MOZILLA_RESPONSE); | 433 mozilla_response = gdk_x11_atom_to_xatom(GDKA_MOZILLA_RESPONSE); |
| 420 xid = GDK_WINDOW_XID(window); | 434 xid = GDK_WINDOW_XID(window); |
| 440 "windows and try again."), NULL, GAIM_ERROR); | 454 "windows and try again."), NULL, GAIM_ERROR); |
| 441 } | 455 } |
| 442 | 456 |
| 443 if (data[0] == '1') { | 457 if (data[0] == '1') { |
| 444 /* Netscape isn't ready yet */ | 458 /* Netscape isn't ready yet */ |
| 445 debug_printf("Remote Netscape window isn't ready yet.\n"); | 459 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 460 "Remote Netscape window isn't ready yet.\n"); | |
| 446 return GDK_FILTER_REMOVE; | 461 return GDK_FILTER_REMOVE; |
| 447 } | 462 } |
| 448 | 463 |
| 449 if (data[0] == '2') { | 464 if (data[0] == '2') { |
| 450 /* Yay! It worked */ | 465 /* Yay! It worked */ |
| 451 debug_printf("Successfully sent command to remote Netscape window.\n"); | 466 gaim_debug(GAIM_DEBUG_INFO, "browser", |
| 467 "Successfully sent command to remote Netscape window.\n"); | |
| 452 } | 468 } |
| 453 | 469 |
| 454 gdk_window_remove_filter(window, (GdkFilterFunc) netscape_response_cb, window); | 470 gdk_window_remove_filter(window, (GdkFilterFunc) netscape_response_cb, window); |
| 455 mozilla_remote_free_lock(window); | 471 mozilla_remote_free_lock(window); |
| 456 netscape_lock = 0; | 472 netscape_lock = 0; |
| 474 else | 490 else |
| 475 strcat(new_command, "(noraise)"); | 491 strcat(new_command, "(noraise)"); |
| 476 command = new_command; | 492 command = new_command; |
| 477 } | 493 } |
| 478 | 494 |
| 479 debug_printf("%s: (writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n", | 495 gaim_debug(GAIM_DEBUG_MISC, "browser", |
| 480 progname, command, (unsigned int)window); | 496 "%s: Writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x\n", |
| 497 progname, command, (unsigned int)window); | |
| 481 | 498 |
| 482 gdk_property_change(window, GDKA_MOZILLA_COMMAND, | 499 gdk_property_change(window, GDKA_MOZILLA_COMMAND, |
| 483 gdk_x11_xatom_to_atom (XA_STRING), | 500 gdk_x11_xatom_to_atom (XA_STRING), |
| 484 8, GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command)); | 501 8, GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command)); |
| 485 | 502 |
| 489 static gboolean netscape_command(const char *command) | 506 static gboolean netscape_command(const char *command) |
| 490 { | 507 { |
| 491 GdkWindow *window = NULL; | 508 GdkWindow *window = NULL; |
| 492 | 509 |
| 493 if (netscape_lock) { | 510 if (netscape_lock) { |
| 494 debug_printf("netscape_command() is currently in use.\n"); | 511 gaim_debug(GAIM_DEBUG_WARNING, "browser", |
| 512 "netscape_command() is currently in use.\n"); | |
| 495 return FALSE; | 513 return FALSE; |
| 496 } | 514 } |
| 497 | 515 |
| 498 netscape_lock = 1; | 516 netscape_lock = 1; |
| 499 | 517 |
| 500 mozilla_remote_init_atoms(); | 518 mozilla_remote_init_atoms(); |
| 501 window = mozilla_remote_find_window(); | 519 window = mozilla_remote_find_window(); |
| 502 | 520 |
| 503 if (window == NULL || (GDK_WINDOW_OBJECT(window)->destroyed == TRUE)) { | 521 if (window == NULL || (GDK_WINDOW_OBJECT(window)->destroyed == TRUE)) { |
| 504 debug_printf("Remote window absent or unsuitable.\n"); | 522 gaim_debug(GAIM_DEBUG_ERROR, "browser", |
| 523 "Remote window absent or unsuitable.\n"); | |
| 505 netscape_lock = 0; | 524 netscape_lock = 0; |
| 506 return FALSE; | 525 return FALSE; |
| 507 } | 526 } |
| 508 | 527 |
| 509 mozilla_remote_command(window, command, False); | 528 mozilla_remote_command(window, command, False); |
