cpw.nader.asynclogging-3: 3e6316f6: Improved error handling in log_get_log_s...
morshed.nader at gmail.com
morshed.nader at gmail.com
Tue May 17 14:36:12 EDT 2011
----------------------------------------------------------------------
Revision: 3e6316f6fba71092ddc0bf37aa2ae997c924c5dc
Parent: b67f3d498442fcbfad0d252944205ef742637f42
Author: morshed.nader at gmail.com
Date: 05/17/11 05:37:30
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/3e6316f6fba71092ddc0bf37aa2ae997c924c5dc
Changelog:
Improved error handling in log_get_log_sets_common
Changed array referencing/dereferencing to just use pointer arithmetic
Still haven't figured out what's causing the problem of NULL accounts...
Changes against parent b67f3d498442fcbfad0d252944205ef742637f42
patched libpurple/log.c
-------------- next part --------------
============================================================
--- libpurple/log.c 7d92e3a461ffc04f55d764845742233ac4c2a94c
+++ libpurple/log.c 6441be0b8e4d3b7df080574e6f9cca25ecbfd91f
@@ -1844,7 +1844,7 @@ purple_log_get_log_sets_async(PurpleLog
cb, userdata);
}
-static GHashTable *
+static GHashTable *
purple_log_real_get_log_sets_finish(PurpleLog *log, GAsyncResult *res,
GError **error)
{
@@ -2475,6 +2475,7 @@ purple_log_set_free(PurpleLogSet *set)
g_return_if_fail(set != NULL);
g_free(set->name);
+ /* XXX: g_object_unref(set->account) */
if (set->normalized_name != set->name)
g_free(set->normalized_name);
@@ -2629,18 +2630,27 @@ log_get_log_sets_common(GCancellable *ca
log_get_log_sets_common(GCancellable *cancel, GError **error)
{
GDir *log_dir, *username_dir;
+ GError *err = NULL;
GHashTable *sets;
const gchar *protocol;
gchar *log_path;
log_path = g_build_filename(purple_user_dir(), "logs", NULL);
- log_dir = g_dir_open(log_path, 0, error);
+ log_dir = g_dir_open(log_path, 0, &err);
if (log_dir == NULL) {
+ if (err->code == G_FILE_ERROR_NOENT)
+ g_clear_error(&err);
+ else
+ g_propagate_error(error, err);
+
g_free(log_path);
+
return NULL;
}
+ g_clear_error(&err);
+
sets = g_hash_table_new_full(_purple_log_set_hash, _purple_log_set_equal,
(GDestroyNotify) purple_log_set_free, NULL);
@@ -2651,13 +2661,26 @@ log_get_log_sets_common(GCancellable *ca
gchar *protocol_path = g_build_filename(log_path, protocol, NULL);
gchar *protocol_unescaped;
- protocol_dir = g_dir_open(protocol_path, 0, NULL);
+ protocol_dir = g_dir_open(protocol_path, 0, &err);
if (protocol_dir == NULL) {
g_free(protocol_path);
+
+ if (err->code != G_FILE_ERROR_NOENT) {
+ g_propagate_error(error, err);
+ g_hash_table_destroy(sets);
+ g_free(log_path);
+ g_dir_close(log_dir);
+
+ return NULL;
+ }
+
+ g_clear_error(&err);
continue;
}
+ g_clear_error(&err);
+
/* Using g_strdup() to cover the one-in-a-million chance that a
* prpl's list_icon function uses purple_unescape_filename(). */
protocol_unescaped = g_strdup(purple_unescape_filename(protocol));
@@ -2703,6 +2726,7 @@ log_get_log_sets_common(GCancellable *ca
account_iter != NULL;
account_iter = g_list_next(account_iter))
{
+ /* XXX: PURPLE_ACCOUNT(...)->username */
if (purple_strequal(((PurpleAccount *) account_iter->data)->username,
username_unescaped))
{
@@ -2726,13 +2750,14 @@ log_get_log_sets_common(GCancellable *ca
set->type = PURPLE_LOG_IM;
set->name = name;
- set->account = account;
+ set->account = account; /* XXX: g_object_ref */
+ purple_debug_info("log", "account: %p\n", account);
/* set->buddy is always set below */
set->normalized_name = g_strdup(purple_normalize(account, name));
/* Check for .chat or .system at the end of the name to determine the type. */
if (len >= 7) {
- tmp = &name[len - 7];
+ tmp = name + (len - 7);
if (purple_strequal(tmp, ".system")) {
set->type = PURPLE_LOG_SYSTEM;
@@ -2741,7 +2766,7 @@ log_get_log_sets_common(GCancellable *ca
}
if (len > 5) {
- tmp = &name[len - 5];
+ tmp = name + (len - 5);
if (purple_strequal(tmp, ".chat")) {
set->type = PURPLE_LOG_CHAT;
More information about the Commits
mailing list