cpw.nader.asynclogging-3: 720e73fa: Made the finch and pidgin system/contact..
morshed.nader at gmail.com
morshed.nader at gmail.com
Mon Mar 21 01:36:53 EDT 2011
----------------------------------------------------------------------
Revision: 720e73faab68d9ae355ae5cf39e0188ad78af896
Parent: 9d5b168c1b5b9259111a5816f50e835e34a8a40e
Author: morshed.nader at gmail.com
Date: 03/21/11 01:30:51
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/720e73faab68d9ae355ae5cf39e0188ad78af896
Changelog:
Made the finch and pidgin system/contact log windows properly handle when no conversations are available
Changes against parent 9d5b168c1b5b9259111a5816f50e835e34a8a40e
patched finch/gntlog.c
patched libpurple/log.c
patched pidgin/gtklog.c
-------------- next part --------------
============================================================
--- libpurple/log.c 5c684cf6dde4880773e29da674aab764613cb94d
+++ libpurple/log.c 388304937e945a6f024771ef729635b5ceabea20
@@ -2076,7 +2076,7 @@ purple_log_get_log_dir(PurpleLogChatType
prpl = purple_find_prpl(purple_account_get_protocol_id(account));
- if (!prpl)
+ if (prpl == NULL)
return NULL;
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
@@ -2089,14 +2089,14 @@ purple_log_get_log_dir(PurpleLogChatType
temp = g_strdup_printf("%s.chat", purple_normalize(account, name));
target = purple_escape_filename(temp);
g_free(temp);
- } else if (chat_type == PURPLE_LOG_SYSTEM) {
+ } else if (chat_type == PURPLE_LOG_SYSTEM)
target = ".system";
- } else {
+ else
target = purple_escape_filename(purple_normalize(account, name));
- }
if (strlen(target) > 0)
- dir = g_build_filename(purple_user_dir(), "logs", prpl_name, acct_name, target, NULL);
+ dir = g_build_filename(purple_user_dir(), "logs", prpl_name,
+ acct_name, target, NULL);
else
dir = NULL;
============================================================
--- pidgin/gtklog.c b48b243eb1152297eaa83baddbf5dfe76274a217
+++ pidgin/gtklog.c cd591708b1fc189b3c93641de72f2e032aa02729
@@ -918,10 +918,13 @@ insert_log_viewer_log(PidginLogViewer *l
static void
insert_log_viewer_log(PidginLogViewer *lv, PurpleLog *log)
{
- /* It runs about twice as quick to insert the logs, rather than re-populate the entire tree
-
- This is also a trade-off though, as it means having to update both this function and
- populate_log_tree if the tree format is to ever be changed
+ /**
+ * It runs about twice as quick to insert the logs, rather than
+ * re-populate the entire tree.
+ *
+ * This is also a trade-off though, as it means having to update both
+ * this function and populate_log_tree if the tree format is to ever
+ * be changed.
*/
PurpleLog *child_log;
GtkTreeStore *store = pidgin_log_viewer_get_tree_store(lv);
@@ -932,12 +935,14 @@ insert_log_viewer_log(PidginLogViewer *l
struct tm *tm;
time_t log_time = purple_log_get_time(log);
- month = purple_utf8_strftime(_("%B %Y"), log_tm != NULL ? log_tm : localtime(&log_time));
+ month = purple_utf8_strftime(_("%B %Y"),
+ log_tm != NULL ? log_tm : localtime(&log_time));
if (!gtk_tree_model_get_iter_first(model, &month_iter)) {
/* Appending the month */
gtk_tree_store_append(store, &inserted_month, NULL);
- gtk_tree_store_set(store, &inserted_month, 0, month, 1, NULL, 2, log_tm, -1);
+ gtk_tree_store_set(store, &inserted_month, 0, month, 1, NULL,
+ 2, log_tm, -1);
gtk_tree_store_append(store, &insertion, &inserted_month);
gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log, -1);
@@ -948,11 +953,14 @@ insert_log_viewer_log(PidginLogViewer *l
do {
gtk_tree_model_get(model, &month_iter, 2, &tm, -1);
- if (tm != NULL && tm->tm_mon == log_tm->tm_mon && tm->tm_year == log_tm->tm_year) {
+ if (tm != NULL && tm->tm_mon == log_tm->tm_mon &&
+ tm->tm_year == log_tm->tm_year)
+ {
if (!gtk_tree_model_iter_children(model, &child, &month_iter)) {
/* Appending the log to the currently selected month */
gtk_tree_store_append(store, &insertion, &month_iter);
- gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log, -1);
+ gtk_tree_store_set(store, &insertion, 0, log_get_date(log),
+ 1, log, -1);
return;
}
@@ -962,8 +970,10 @@ insert_log_viewer_log(PidginLogViewer *l
if (log_time > purple_log_get_time(child_log)) {
/* Prepending the log to the currently selected month */
- gtk_tree_store_insert_before(store, &insertion, &month_iter, &child);
- gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log, -1);
+ gtk_tree_store_insert_before(store, &insertion,
+ &month_iter, &child);
+ gtk_tree_store_set(store, &insertion, 0, log_get_date(log),
+ 1, log, -1);
return;
}
@@ -972,18 +982,22 @@ insert_log_viewer_log(PidginLogViewer *l
/* Appending the log to the currently selected month */
gtk_tree_store_append(store, &insertion, &month_iter);
- gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log, -1);
+ gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log,
+ -1);
return;
} else if (tm->tm_year < log_tm->tm_year ||
(tm->tm_year == log_tm->tm_year && tm->tm_mon < log_tm->tm_mon))
{
/* Prepending the month */
- gtk_tree_store_insert_before(store, &inserted_month, NULL, &month_iter);
- gtk_tree_store_set(store, &inserted_month, 0, month, 1, NULL, 2, log_tm, -1);
+ gtk_tree_store_insert_before(store, &inserted_month, NULL,
+ &month_iter);
+ gtk_tree_store_set(store, &inserted_month, 0, month, 1, NULL,
+ 2, log_tm, -1);
gtk_tree_store_append(store, &insertion, &inserted_month);
- gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log, -1);
+ gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log,
+ -1);
return;
}
@@ -992,7 +1006,8 @@ insert_log_viewer_log(PidginLogViewer *l
/* Appending the month */
gtk_tree_store_append(store, &inserted_month, NULL);
- gtk_tree_store_set(store, &inserted_month, 0, month, 1, NULL, 2, log_tm, -1);
+ gtk_tree_store_set(store, &inserted_month, 0, month, 1, NULL, 2, log_tm,
+ -1);
gtk_tree_store_append(store, &insertion, &inserted_month);
gtk_tree_store_set(store, &insertion, 0, log_get_date(log), 1, log, -1);
@@ -1101,7 +1116,6 @@ pidgin_log_list_cb(GObject *object, GAsy
_pidgin_log_data *pidgin_log_data = userdata;
GError *error = NULL;
GList *list;
- pidgin_make_scrollable(lv->treeview, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS, GTK_SHADOW_IN, -1, -1));
list = purple_logs_get_logs_finish(res, &error);
pidgin_log_data->count--;
@@ -1206,7 +1220,8 @@ pidgin_log_show(PurpleLogChatType chat_t
prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM);
image = gtk_image_new_from_pixbuf(prpl_icon);
- lv = pidgin_log_data->log_viewer = pidgin_log_viewer_new(ht, title, image, TRUE);
+ lv = pidgin_log_data->log_viewer = pidgin_log_viewer_new(ht, title, image,
+ TRUE);
g_free(title);
gtk_widget_show(GTK_WIDGET(lv));
@@ -1219,10 +1234,10 @@ pidgin_log_show(PurpleLogChatType chat_t
cancel = g_cancellable_new();
pidgin_log_viewer_set_list_cancel(lv, cancel);
- purple_logs_get_logs_async(chat_type, buddyname, account, G_PRIORITY_DEFAULT,
- cancel, pidgin_log_list_cb, pidgin_log_data);
- purple_logs_get_total_size_async(chat_type, buddyname, account, G_PRIORITY_DEFAULT,
- cancel, pidgin_log_size_cb, pidgin_log_data);
+ purple_logs_get_logs_async(chat_type, buddyname, account,
+ G_PRIORITY_DEFAULT, cancel, pidgin_log_list_cb, pidgin_log_data);
+ purple_logs_get_total_size_async(chat_type, buddyname, account,
+ G_PRIORITY_DEFAULT, cancel, pidgin_log_size_cb, pidgin_log_data);
g_object_unref(cancel);
}
@@ -1239,6 +1254,7 @@ pidgin_log_show_contact(PurpleContact *c
GtkWidget *image;
const gchar *name = NULL;
gchar *title;
+ gboolean found_account = FALSE;
g_return_if_fail(contact != NULL);
@@ -1309,6 +1325,7 @@ pidgin_log_show_contact(PurpleContact *c
if (!PURPLE_BLIST_NODE_IS_BUDDY(child))
continue;
+ found_account = TRUE;
pidgin_log_data->count = (pidgin_log_data->total += 2);
name = purple_buddy_get_name(PURPLE_BUDDY(child));
@@ -1321,6 +1338,9 @@ pidgin_log_show_contact(PurpleContact *c
}
g_object_unref(cancel);
+
+ if (!found_account)
+ pidgin_log_done_cb(pidgin_log_data);
}
void
@@ -1330,6 +1350,7 @@ pidgin_syslog_show(void)
PidginLogViewer *lv;
GCancellable *cancel;
GList *accounts;
+ gboolean found_account = FALSE;
G_LOCK(syslog_viewer);
lv = syslog_viewer;
@@ -1362,6 +1383,7 @@ pidgin_syslog_show(void)
if (purple_find_prpl(purple_account_get_protocol_id(account)) == NULL)
continue;
+ found_account = TRUE;
pidgin_log_data->count++;
pidgin_log_data->total++;
@@ -1371,9 +1393,12 @@ pidgin_syslog_show(void)
g_object_unref(cancel);
- G_LOCK(syslog_viewer);
- syslog_viewer = lv;
- G_UNLOCK(syslog_viewer);
+ if (found_account) {
+ G_LOCK(syslog_viewer);
+ syslog_viewer = lv;
+ G_UNLOCK(syslog_viewer);
+ } else
+ pidgin_log_done_cb(pidgin_log_data);
}
GList *
============================================================
--- finch/gntlog.c 4083dcb1dff8535f8e2f764c90e71ccef41b6cf0
+++ finch/gntlog.c 0b659385420022274bdad45cc5050c704e8ea5f1
@@ -812,6 +812,7 @@ finch_log_show_contact(PurpleContact *co
GCancellable *cancel;
const gchar *name = NULL;
gchar *title;
+ gboolean found_account = FALSE;
g_return_if_fail(contact != NULL);
@@ -870,6 +871,7 @@ finch_log_show_contact(PurpleContact *co
if (!PURPLE_BLIST_NODE_IS_BUDDY(child))
continue;
+ found_account = TRUE;
finch_log_data->count = (finch_log_data->total += 2);
name = purple_buddy_get_name(PURPLE_BUDDY(child));
@@ -882,6 +884,9 @@ finch_log_show_contact(PurpleContact *co
}
g_object_unref(cancel);
+
+ if (!found_account)
+ pidgin_log_done_cb(pidgin_log_data);
}
void
@@ -891,6 +896,7 @@ finch_syslog_show(void)
FinchLogViewer *lv;
GCancellable *cancel;
GList *accounts = NULL;
+ gboolean found_account = FALSE;
G_LOCK(syslog_viewer);
lv = syslog_viewer;
@@ -923,7 +929,9 @@ finch_syslog_show(void)
if (purple_find_prpl(purple_account_get_protocol_id(account)) == NULL)
continue;
- finch_log_data->count = finch_log_data->total++;
+ found_account = TRUE;
+ finch_log_data->count++;
+ finch_log_data->total++;
purple_logs_get_system_logs_async(account, G_PRIORITY_DEFAULT,
cancel, finch_log_system_list_cb, finch_log_data);
@@ -931,9 +939,12 @@ finch_syslog_show(void)
g_object_unref(cancel);
- G_LOCK(syslog_viewer);
- syslog_viewer = lv;
- G_UNLOCK(syslog_viewer);
+ if (found_account) {
+ G_LOCK(syslog_viewer);
+ syslog_viewer = lv;
+ G_UNLOCK(syslog_viewer);
+ } else
+ finch_log_done_cb(finch_log_data);
}
GList *
More information about the Commits
mailing list