cpw.nader.asynclogging-3: 7f9799a0: Searching logs works now!
morshed.nader at gmail.com
morshed.nader at gmail.com
Sun Jan 8 01:21:27 EST 2012
----------------------------------------------------------------------
Revision: 7f9799a0c2b1ce68b6066487a8ac6985ac6ddb67
Parent: 5bae6254b7800ba40ec7506037faff525339577a
Author: morshed.nader at gmail.com
Date: 01/07/12 17:01:56
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/7f9799a0c2b1ce68b6066487a8ac6985ac6ddb67
Changelog:
Searching logs works now!
Fixed reads leaking file descriptors
Fixed how the search progress bar displays to be a little more active...
Changes against parent 5bae6254b7800ba40ec7506037faff525339577a
patched finch/gntlog.c
patched libpurple/commonlog.c
patched libpurple/log.c
patched pidgin/gtklog.c
-------------- next part --------------
============================================================
--- libpurple/log.c c40846f1fcb043249f391c0b71fe85f9f4bcf82a
+++ libpurple/log.c f323cbda89e0f0653a8fff89baba94117ac3783f
@@ -40,7 +40,7 @@
/* Helpful macros */
-#define FILES_PER_SEARCH 100
+#define FILES_PER_SEARCH 20
#define PURPLE_IS_ACCOUNT(account) (account != NULL)
#define PURPLE_IS_CONVERSATION(conv) (conv != NULL)
@@ -160,7 +160,6 @@ typedef struct {
guint reads;
gchar *search_term;
GList *logs;
- GList *logs_with_string;
} search_callback_data;
typedef struct {
@@ -1132,7 +1131,6 @@ purple_logs_search_async(PurpleLogChatTy
data->lists = 0;
data->reads = 0;
data->logs = NULL;
- 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 */
@@ -2138,9 +2136,13 @@ log_search_cb(GObject *object, GAsyncRes
if (error != NULL)
purple_debug_error("log", "Error searching logs: %s\n",
error->message);
- } else
- data->logs_with_string = g_list_concat(logs,
- data->logs_with_string);
+ } else {
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ purple_logs_search_async,
+ g_simple_async_result_set_op_res_gpointer,
+ logs,
+ (GDestroyNotify) purple_log_list_free);
+ }
g_clear_error(&error);
}
@@ -2149,10 +2151,9 @@ log_search_cb(GObject *object, GAsyncRes
SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
purple_logs_search_async,
g_simple_async_result_set_op_res_gpointer,
- data->logs_with_string,
- (GDestroyNotify) purple_log_list_free);
+ NULL,
+ NULL);
- data->logs_with_string = NULL;
search_callback_data_free(data);
}
}
@@ -2172,9 +2173,13 @@ log_search_read_cb(GObject *object, GAsy
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));
+ } else if (*text && purple_strcasestr(text, data->search_term)) {
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ purple_logs_search_async,
+ g_simple_async_result_set_op_res_gpointer,
+ g_list_prepend(NULL, g_object_ref(log)),
+ (GDestroyNotify) purple_log_list_free);
+ }
g_free(text);
}
============================================================
--- pidgin/gtklog.c e8b0fed683fdb6a189909a6f5b1edcb0585927b6
+++ pidgin/gtklog.c 5e107b7ca8200423d1dada8bec531efb0bec7f19
@@ -193,7 +193,6 @@ static void pidgin_log_viewer_update_lis
static void insert_log_viewer_log(PidginLogViewer *, PurpleLog *);
static void pidgin_log_done_cb(pidgin_log_data *);
static void pidgin_log_viewer_update_list_bar(pidgin_log_data *);
-static void pidgin_log_viewer_update_search_bar(pidgin_log_data *);
static void pidgin_log_size_cb(GObject *, GAsyncResult *, gpointer);
static void pidgin_log_list_cb(GObject *, GAsyncResult *, gpointer);
static void pidgin_log_system_list_cb(GObject *, GAsyncResult *, gpointer);
@@ -336,19 +335,16 @@ pidgin_log_search_cb(GObject *object, GA
}
data->count--;
- } else if (data->is_window_open)
+ } else if (data->is_window_open) {
+ GtkWidget *bar;
+
pidgin_log_viewer_add_logs(data->log_viewer, logs);
+ bar = pidgin_log_viewer_get_search_bar(data->log_viewer);
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(bar));
+ }
g_clear_error(&error);
- // if (data->is_window_open) {
- // const gchar *cur_search =
- // pidgin_log_viewer_get_search_string(data->log_viewer);
-
- // if (purple_strequal(data->string, cur_search))
- // pidgin_log_viewer_update_search_bar(data);
- // }
-
if (data->count < 1)
pidgin_log_search_done_cb(data);
}
@@ -363,7 +359,6 @@ search_cb(GtkWidget *button, PidginLogVi
GCancellable *cancel;
GList *logs, *name, *account;
const gchar *search_term, *old_search;
- guint length;
search_term = gtk_entry_get_text(GTK_ENTRY(priv->entry));
@@ -390,9 +385,8 @@ search_cb(GtkWidget *button, PidginLogVi
}
logs = pidgin_log_viewer_get_logs(lv);
- length = g_list_length(logs);
- if (length < 1)
+ if (g_list_length(logs) < 1)
return;
pidgin_log_viewer_set_search_string(lv, search_term);
@@ -404,13 +398,13 @@ search_cb(GtkWidget *button, PidginLogVi
data->is_window_open = TRUE;
data->log_viewer = lv;
data->string = g_strdup(search_term);
- data->count = data->total = length;
+ data->total = data->count = 0;
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_pulse(GTK_PROGRESS_BAR(bar));
cancel = g_cancellable_new();
pidgin_log_viewer_set_search_cancel(lv, cancel);
@@ -426,6 +420,7 @@ search_cb(GtkWidget *button, PidginLogVi
name = g_list_next(name);
}
+ data->count = (data->total += 1);
purple_logs_search_async(priv->chat_type, name_str, account->data,
search_term, G_PRIORITY_DEFAULT_IDLE, cancel, pidgin_log_search_cb,
data);
@@ -1123,18 +1118,6 @@ static void
}
static void
-pidgin_log_viewer_update_search_bar(pidgin_log_data *data)
-{
- PidginLogViewer *lv = data->log_viewer;
- GtkWidget *bar = pidgin_log_viewer_get_search_bar(lv);
- gdouble fraction;
-
- fraction = (gdouble) data->count /
- (gdouble) data->total;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar), 1.0 - fraction);
-}
-
-static void
pidgin_log_size_cb(GObject *object, GAsyncResult *res, gpointer userdata)
{
pidgin_log_data *data = userdata;
============================================================
--- finch/gntlog.c 1641f54566dfd19bc4fab7d7b17eb19810bc70e4
+++ finch/gntlog.c ca7b49a6e5f4df646926ac57f44f8b449117252e
@@ -255,14 +255,6 @@ finch_log_search_cb(GObject *object, GAs
g_clear_error(&error);
- // if (data->is_window_open) {
- // const gchar *cur_search =
- // finch_log_viewer_get_search_string(data->log_viewer);
-
- // if (purple_strequal(data->string, cur_search))
- // finch_log_viewer_update_search_bar(data);
- // }
-
if (data->count < 1)
finch_log_search_done_cb(data);
}
@@ -319,7 +311,6 @@ search_cb(GntWidget *button, FinchLogVie
bar = finch_log_viewer_get_search_bar(lv);
gnt_widget_show(bar);
- gnt_progress_bar_set_fraction(GNT_PROGRESS_BAR(bar), 0.0);
cancel = g_cancellable_new();
finch_log_viewer_set_search_cancel(lv, cancel);
@@ -586,18 +577,6 @@ static void
}
static void
-finch_log_viewer_update_search_bar(finch_log_data *data)
-{
- FinchLogViewer *lv = data->log_viewer;
- GntWidget *bar = finch_log_viewer_get_search_bar(lv);
- gdouble fraction;
-
- fraction = (gdouble) data->count /
- (gdouble) data->total;
- gnt_progress_bar_set_fraction(GNT_PROGRESS_BAR(bar), 1.0 - fraction);
-}
-
-static void
finch_log_size_cb(GObject *object, GAsyncResult *res, gpointer userdata)
{
finch_log_data *data = userdata;
@@ -1632,7 +1611,7 @@ finch_log_viewer_init(FinchLogViewer *lv
priv->list_bar = gnt_progress_bar_new();
priv->search_bar = gnt_progress_bar_new();
- gnt_progress_bar_set_fraction(GNT_PROGRESS_BAR(priv->search_bar), 1.0);
+ gnt_progress_bar_set_show_progress(GNT_PROGRESS_BAR(priv->search_bar), FALSE);
gnt_box_add_widget(GNT_BOX(vbox), priv->list_bar);
gnt_box_add_widget(GNT_BOX(vbox), priv->search_bar);
============================================================
--- libpurple/commonlog.c ff32c1229b31bf64efcee4d6a437124a4b09807e
+++ libpurple/commonlog.c fcd95d1a7cb53da0038ad97b39c5d104c6a4e8cd
@@ -31,7 +31,7 @@
/* Helpful macros */
-#define FILES_PER_ENUM 100
+#define FILES_PER_ENUM 200
#define PURPLE_IS_ACCOUNT(account) (account != NULL)
@@ -684,7 +684,10 @@ purple_common_log_read_async_2(GObject *
socket = purple_common_log_create_finish(common_log, res, &err);
if (socket < 0) {
- /* XXX: Signal error */
+ SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR(common_log, data->cb, data->userdata,
+ G_IO_ERROR,
+ g_file_error_from_errno(errno),
+ "%s", g_strerror(errno));
read_callback_data_free(data);
return;
@@ -703,8 +706,12 @@ purple_common_log_read_async_2(GObject *
chan = g_io_channel_unix_new(socket);
#endif
+ g_io_channel_set_close_on_unref(chan, TRUE);
+
g_io_add_watch_full(chan, data->io_priority, G_IO_IN | G_IO_HUP | G_IO_ERR,
purple_common_log_read_async_3, data, read_callback_data_free);
+
+ g_io_channel_unref(chan);
}
void
@@ -1075,14 +1082,16 @@ purple_common_log_list_async_2(GObject *
enumerator = g_file_enumerate_children_finish(data->dir, res, &error);
if (enumerator == NULL) {
- if (error->code != G_IO_ERROR_NOT_FOUND)
+ if (error->code != G_IO_ERROR_NOT_FOUND) {
SIMPLE_ASYNC_RESULT_FROM_ERROR(NULL, data->cb, data->userdata,
error);
- else
+ } else {
SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ purple_common_log_list_async,
g_simple_async_result_set_op_res_gpointer,
NULL,
NULL);
+ }
list_callback_data_free(data);
@@ -1338,14 +1347,16 @@ purple_common_log_total_size_async_2(GOb
enumerator = g_file_enumerate_children_finish(dir, res, &error);
if (enumerator == NULL) {
- if (error->code != G_IO_ERROR_NOT_FOUND)
+ if (error->code != G_IO_ERROR_NOT_FOUND) {
SIMPLE_ASYNC_RESULT_FROM_ERROR(NULL, data->cb, data->userdata,
error);
- else
+ } else {
SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ purple_common_log_list_async,
g_simple_async_result_set_op_res_gpointer,
NULL,
NULL);
+ }
total_size_callback_data_free(data);
More information about the Commits
mailing list