comparison libpurple/util.c @ 19566:57d350900136

Tooltips can be for the buddylist or for conversation windows. A more appropriate fix for #2723.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 01 Sep 2007 23:50:22 +0000
parents 47a2d00ab060
children b99a158ea85e
comparison
equal deleted inserted replaced
19565:4691b5f80ac8 19566:57d350900136
28 #include "debug.h" 28 #include "debug.h"
29 #include "notify.h" 29 #include "notify.h"
30 #include "prpl.h" 30 #include "prpl.h"
31 #include "prefs.h" 31 #include "prefs.h"
32 #include "util.h" 32 #include "util.h"
33
34 #ifdef HAVE_DBUS
35 # define DBUS_API_SUBJECT_TO_CHANGE
36 # include <dbus/dbus.h>
37 # include "dbus-purple.h"
38 # include "dbus-server.h"
39 # include "dbus-bindings.h"
40 #endif
33 41
34 struct _PurpleUtilFetchUrlData 42 struct _PurpleUtilFetchUrlData
35 { 43 {
36 PurpleUtilFetchUrlCallback callback; 44 PurpleUtilFetchUrlCallback callback;
37 void *user_data; 45 void *user_data;
2531 g_free(dir); 2539 g_free(dir);
2532 return 0; 2540 return 0;
2533 #endif 2541 #endif
2534 } 2542 }
2535 2543
2544 static gboolean
2545 write_dbus_file(const char *filename, const char *data, size_t size)
2546 {
2547 DBusConnection *dbus_connection = NULL;
2548 DBusMessage *msg = NULL;
2549 if ((dbus_connection = purple_dbus_get_connection()) == NULL)
2550 return FALSE;
2551 msg = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE,
2552 DBUS_INTERFACE_PURPLE, "PurpleUtilWriteDataToFile");
2553 if (msg == NULL)
2554 return NULL;
2555
2556 dbus_message_append_args(msg, DBUS_TYPE_STRING, filename, DBUS_TYPE_STRING, data,
2557 DBUS_TYPE_UINT32, size, DBUS_TYPE_INVALID);
2558 dbus_connection_send(dbus_connection, msg, NULL);
2559 return TRUE;
2560 }
2561
2536 /* 2562 /*
2537 * This function is long and beautiful, like my--um, yeah. Anyway, 2563 * This function is long and beautiful, like my--um, yeah. Anyway,
2538 * it includes lots of error checking so as we don't overwrite 2564 * it includes lots of error checking so as we don't overwrite
2539 * people's settings if there is a problem writing the new values. 2565 * people's settings if there is a problem writing the new values.
2540 */ 2566 */
2544 const char *user_dir = purple_user_dir(); 2570 const char *user_dir = purple_user_dir();
2545 gchar *filename_full; 2571 gchar *filename_full;
2546 gboolean ret = FALSE; 2572 gboolean ret = FALSE;
2547 2573
2548 g_return_val_if_fail(user_dir != NULL, FALSE); 2574 g_return_val_if_fail(user_dir != NULL, FALSE);
2549 2575 #if 0
2576 if (!purple_dbus_is_owner()) {
2577 if (write_dbus_file(filename, data, size))
2578 return TRUE;
2579 }
2580 #endif
2550 purple_debug_info("util", "Writing file %s to directory %s\n", 2581 purple_debug_info("util", "Writing file %s to directory %s\n",
2551 filename, user_dir); 2582 filename, user_dir);
2552 2583
2553 /* Ensure the user directory exists */ 2584 /* Ensure the user directory exists */
2554 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR)) 2585 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR))
2582 filename_full); 2613 filename_full);
2583 2614
2584 filename_temp = g_strdup_printf("%s.save", filename_full); 2615 filename_temp = g_strdup_printf("%s.save", filename_full);
2585 2616
2586 /* Remove an old temporary file, if one exists */ 2617 /* Remove an old temporary file, if one exists */
2587 if (g_file_test(filename_temp, G_FILE_TEST_EXISTS)) 2618 if (g_file_test(filename_temp, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
2588 { 2619 {
2589 if (g_unlink(filename_temp) == -1) 2620 if (g_unlink(filename_temp) == -1)
2590 { 2621 {
2591 purple_debug_error("util", "Error removing old file " 2622 purple_debug_error("util", "Error removing old file "
2592 "%s: %s\n", 2623 "%s: %s\n",