cpw.nader.asynclogging-3: 5bae6254: Renamed purple_log_real_list_logs_finish...
morshed.nader at gmail.com
morshed.nader at gmail.com
Sun Jan 8 01:21:14 EST 2012
----------------------------------------------------------------------
Revision: 5bae6254b7800ba40ec7506037faff525339577a
Parent: 548fcbd9e2f584ea5fd548408b2c424f6b39e623
Author: morshed.nader at gmail.com
Date: 01/07/12 15:59:38
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/5bae6254b7800ba40ec7506037faff525339577a
Changelog:
Renamed purple_log_real_list_logs_finish to purple_log_real_list_finish
Removed some debugging statements
Fixed bugs in the search code, works now!
Made errors only be logged when they're not file not found
Made gtklog clear the log tree at the beginning of searches
Changes against parent 548fcbd9e2f584ea5fd548408b2c424f6b39e623
patched libpurple/commonlog.c
patched libpurple/log.c
patched pidgin/gtklog.c
-------------- next part --------------
============================================================
--- libpurple/log.c 12cd8559d11a399037040a7ea750d0c7ccfca762
+++ libpurple/log.c c40846f1fcb043249f391c0b71fe85f9f4bcf82a
@@ -172,7 +172,7 @@ static gssize purple_log_real_size_finis
static gssize purple_log_real_size_finish(PurpleLog *, GAsyncResult *,
GError **);
-static GList *purple_log_real_list_logs_finish(GAsyncResult *, GError **);
+static GList *purple_log_real_list_finish(GAsyncResult *, GError **);
static gssize purple_log_real_total_size_finish(GAsyncResult *, GError **);
static GHashTable *purple_log_real_get_log_sets_finish(GAsyncResult *,
GError **);
@@ -187,7 +187,6 @@ static void log_search_cb(GObject *, GAs
static void log_list_cb(GObject *, GAsyncResult *, gpointer);
static void log_total_size_cb(GObject *, GAsyncResult *, gpointer);
static void log_search_cb(GObject *, GAsyncResult *, gpointer);
-static void log_search_read_cb(GObject *, GAsyncResult *, gpointer);
static void log_search_list_cb(GObject *, GAsyncResult *, gpointer);
static void log_hash_cb(GObject *, GAsyncResult *, gpointer);
@@ -297,7 +296,7 @@ purple_log_class_init(PurpleLogClass *cl
class->size_finish = purple_log_real_size_finish;
class->total_size_finish = purple_log_real_total_size_finish;
- class->list_finish = purple_log_real_list_logs_finish;
+ class->list_finish = purple_log_real_list_finish;
class->get_log_sets_finish = purple_log_real_get_log_sets_finish;
class->remove_finish = purple_log_real_remove_finish;
@@ -825,7 +824,7 @@ static GList *
}
static GList *
-purple_log_real_list_logs_finish(GAsyncResult *res, GError **error)
+purple_log_real_list_finish(GAsyncResult *res, GError **error)
{
GSimpleAsyncResult *simple;
GList *list;
@@ -1118,6 +1117,7 @@ purple_logs_search_async(PurpleLogChatTy
search_callback_data *data;
GArray *array;
guint i;
+ gboolean default_search;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
@@ -1135,6 +1135,9 @@ purple_logs_search_async(PurpleLogChatTy
data->logs_with_string = NULL;
data->search_term = g_strdup(search_term);
+ /* Indicates if we're using the list_async + read_async commands at all */
+ default_search = FALSE;
+
for (i = 0; i < array->len; i++) {
PurpleLogClass *klass = g_array_index(array, PurpleLogClass *, i);
@@ -1144,15 +1147,19 @@ purple_logs_search_async(PurpleLogChatTy
continue;
data->lists++;
+ default_search = TRUE;
klass->list_async(type, name, account, io_priority, cancellable,
log_search_list_cb, data);
} else {
klass->search_async(type, name, account, search_term, io_priority,
cancellable, log_search_cb, data);
+
+ data->searches++;
}
+ }
+ if (default_search)
data->searches++;
- }
if (data->searches == 0)
log_search_cb(NULL, NULL, data);
@@ -2094,10 +2101,11 @@ log_total_size_cb(GObject *object, GAsyn
size = 0;
/* It's hard to pass all the errors up, so just log them :( */
- if (size < 0 && error != NULL)
- purple_debug_error("log", "Error getting total size for logs: %s\n",
- error->message);
- else
+ if (size < 0) {
+ if (error != NULL)
+ purple_debug_error("log", "Error getting total size for logs: %s\n",
+ error->message);
+ } else
data->total += size;
g_clear_error(&error);
@@ -2128,7 +2136,7 @@ log_search_cb(GObject *object, GAsyncRes
if (logs == NULL) {
if (error != NULL)
- purple_debug_error("log", "Error searchin logs: %s\n",
+ purple_debug_error("log", "Error searching logs: %s\n",
error->message);
} else
data->logs_with_string = g_list_concat(logs,
@@ -2157,28 +2165,29 @@ log_search_read_cb(GObject *object, GAsy
gchar *text;
search_callback_data *data = userdata;
- data->reads--;
- text = purple_log_read_finish(log, res, NULL, &error);
+ if (res != NULL) {
+ data->reads--;
+ text = purple_log_read_finish(log, res, NULL, &error);
- if (text == NULL) {
- purple_debug_error("log", "Error reading log: %s\n",
- error->message);
- } else if (*text && purple_strcasestr(text, data->search_term))
- data->logs_with_string = g_list_prepend(g_object_ref(log),
- data->logs_with_string);
+ if (text == NULL) {
+ purple_debug_error("log", "Error reading log: %s\n",
+ error->message);
+ } else if (*text && purple_strcasestr(text, data->search_term))
+ data->logs_with_string = g_list_prepend(data->logs_with_string,
+ g_object_ref(log));
- g_free(text);
+ g_free(text);
+ }
if (data->reads == 0) {
if (data->logs != NULL) {
- GList *logs;
guint i;
- for (i = 0, logs = data->logs;
- i < FILES_PER_SEARCH && logs != NULL;
- i++, logs = g_list_delete_link(logs, logs))
+ for (i = 0;
+ i < FILES_PER_SEARCH && data->logs != NULL;
+ i++, data->logs = g_list_delete_link(data->logs, data->logs))
{
- PurpleLog *log = logs->data;
+ PurpleLog *log = data->logs->data;
data->reads++;
purple_log_read_async(log, data->io_priority, data->cancel,
@@ -2207,7 +2216,7 @@ log_search_list_cb(GObject *object, GAsy
data->lists--;
- if (data->lists) {
+ if (data->lists < 1) {
guint i;
if (data->logs == NULL) {
@@ -2215,11 +2224,11 @@ log_search_list_cb(GObject *object, GAsy
return;
}
- for (i = 0, logs = data->logs;
- i < FILES_PER_SEARCH && logs != NULL;
- i++, logs = g_list_delete_link(logs, logs))
+ for (i = 0;
+ i < FILES_PER_SEARCH && data->logs != NULL;
+ i++, data->logs = g_list_delete_link(data->logs, data->logs))
{
- PurpleLog *log = logs->data;
+ PurpleLog *log = data->logs->data;
data->reads++;
purple_log_read_async(log, data->io_priority, data->cancel,
============================================================
--- pidgin/gtklog.c ef5e414def1a25e1e3225b3a9e6dcfb1e13bd996
+++ pidgin/gtklog.c e8b0fed683fdb6a189909a6f5b1edcb0585927b6
@@ -396,6 +396,7 @@ search_cb(GtkWidget *button, PidginLogVi
return;
pidgin_log_viewer_set_search_string(lv, search_term);
+ gtk_tree_store_clear(priv->treestore);
webkit_web_view_open(wv, "about:blank"); /* clear the view */
pidgin_log_viewer_set_selected(lv, FALSE);
@@ -407,9 +408,9 @@ search_cb(GtkWidget *button, PidginLogVi
data->destroy_handler_id = g_signal_connect_swapped(lv,
"destroy", G_CALLBACK(pidgin_window_destroy_cb), data);
- bar = pidgin_log_viewer_get_search_bar(lv);
+/* bar = pidgin_log_viewer_get_search_bar(lv);
gtk_widget_show(bar);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar), 0.0);
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar), 0.0);*/
cancel = g_cancellable_new();
pidgin_log_viewer_set_search_cancel(lv, cancel);
============================================================
--- libpurple/commonlog.c 636bebfb1f12e5739a23dc430452f1bd6ec73c53
+++ libpurple/commonlog.c ff32c1229b31bf64efcee4d6a437124a4b09807e
@@ -605,8 +605,6 @@ purple_common_log_read_async_3(GIOChanne
status = g_io_channel_read_chars(chan, buffer, sizeof(buffer), &bytes, &err);
- printf("Read %d bytes\n", bytes);
-
switch (status) {
case G_IO_STATUS_NORMAL:
/* Successful read */
@@ -1070,14 +1068,22 @@ purple_common_log_list_async_2(GObject *
purple_common_log_list_async_2(GObject *object, GAsyncResult *res,
gpointer userdata)
{
- GError *err = NULL;
+ GError *error = NULL;
GFileEnumerator *enumerator;
list_callback_data *data = userdata;
- enumerator = g_file_enumerate_children_finish(data->dir, res, &err);
+ enumerator = g_file_enumerate_children_finish(data->dir, res, &error);
if (enumerator == NULL) {
- SIMPLE_ASYNC_RESULT_FROM_ERROR(data->dir, data->cb, data->userdata, err);
+ if (error->code != G_IO_ERROR_NOT_FOUND)
+ SIMPLE_ASYNC_RESULT_FROM_ERROR(NULL, data->cb, data->userdata,
+ error);
+ else
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ g_simple_async_result_set_op_res_gpointer,
+ NULL,
+ NULL);
+
list_callback_data_free(data);
return;
@@ -1324,15 +1330,23 @@ purple_common_log_total_size_async_2(GOb
purple_common_log_total_size_async_2(GObject *object, GAsyncResult *res,
gpointer userdata)
{
- GError *err = NULL;
+ GError *error = NULL;
GFile *dir = G_FILE(object);
GFileEnumerator *enumerator;
total_size_callback_data *data = userdata;
- enumerator = g_file_enumerate_children_finish(dir, res, &err);
+ enumerator = g_file_enumerate_children_finish(dir, res, &error);
if (enumerator == NULL) {
- SIMPLE_ASYNC_RESULT_FROM_ERROR(dir, data->cb, data->userdata, err);
+ if (error->code != G_IO_ERROR_NOT_FOUND)
+ SIMPLE_ASYNC_RESULT_FROM_ERROR(NULL, data->cb, data->userdata,
+ error);
+ else
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ g_simple_async_result_set_op_res_gpointer,
+ NULL,
+ NULL);
+
total_size_callback_data_free(data);
return;
More information about the Commits
mailing list