cpw.nader.asynclogging-3: 37471838: Removed the create_fn and all the associ...

morshed.nader at gmail.com morshed.nader at gmail.com
Fri Jan 14 17:01:02 EST 2011


----------------------------------------------------------------------
Revision: 37471838b011f3071671651a94bc05f429ec6b9a
Parent:   111f3d1b6c3d71752734f01d53d6169a67572d6d
Author:   morshed.nader at gmail.com
Date:     01/14/11 16:16:24
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/37471838b011f3071671651a94bc05f429ec6b9a

Changelog: 

Removed the create_fn and all the associated code from PurpleLog
Updated gntlog.c to get it to set all its members on creation

Changes against parent 111f3d1b6c3d71752734f01d53d6169a67572d6d

  patched  finch/gntlog.c
  patched  libpurple/commonlog.c
  patched  libpurple/htmllog.c
  patched  libpurple/log.c
  patched  libpurple/log.h
  patched  libpurple/txtlog.c
  patched  pidgin/gtklog.c

-------------- next part --------------
============================================================
--- libpurple/log.c	99d1e0458398c220f97c6c8a2d932361f16534fc
+++ libpurple/log.c	b3de711414b7d83ffd8e3fc08180b01b88ff51e3
@@ -149,10 +149,6 @@ static void log_get_log_sets_common_asyn
 static void log_get_log_sets_common_thread(GSimpleAsyncResult *, GObject *, GCancellable *);
 static void log_get_log_sets_common_async(gint, GCancellable *, GAsyncReadyCallback, gpointer);
 
-static void create_thread(GSimpleAsyncResult *, GObject *, GCancellable *);
-static void purple_log_real_create_async(PurpleLog *, gint, GCancellable *, GAsyncReadyCallback, gpointer);
-static gboolean purple_log_real_create_finish(PurpleLog *, GAsyncResult *, GError **);
-
 static void log_read_res_free(gpointer);
 static void read_thread(GSimpleAsyncResult *, GObject *, GCancellable *);
 static void purple_log_real_read_async(PurpleLog *, gint, GCancellable *, GAsyncReadyCallback, gpointer);
@@ -272,8 +268,6 @@ purple_log_class_init(PurpleLogClass *cl
 
 	class->logger_name = "";
 	class->logger_id = "";
-	class->create_async = purple_log_real_create_async;
-	class->create_finish = purple_log_real_create_finish;
 	class->write_async = purple_log_real_write_async;
 	class->write_finish = purple_log_real_write_finish;
 	class->list_async = purple_log_real_get_logs_async;
@@ -639,10 +633,6 @@ purple_log_new(GType log_type, PurpleLog
 
 	PURPLE_DBUS_REGISTER_POINTER(log, PurpleLog);
 
-	// TODO: Non-blocking create?
-	// if (log->logger->create)
-		// (log->logger->create_fn)(log);
-
 	return log;
 }
 
@@ -798,85 +788,6 @@ purple_log_write_finish(PurpleLog *log, 
 	return PURPLE_LOG_GET_CLASS(log)->write_finish(log, res, error);
 }
 
-gboolean
-purple_log_create(PurpleLog *log, GCancellable *cancellable, GError **error)
-{
-	PurpleLogClass *class;
-
-	g_return_val_if_fail(PURPLE_IS_LOG(log), FALSE);
-
-	class = PURPLE_LOG_GET_CLASS(log);
-
-	if (class->create_fn == NULL) {
-		g_set_error_literal(error,
-			G_IO_ERROR,
-			G_IO_ERROR_NOT_SUPPORTED,
-			_("Operation not supported"));
-
-		return FALSE;
-	}
-
-	return class->create_fn(log, cancellable, error);
-}
-
-static void
-create_thread(GSimpleAsyncResult *simple, GObject *object, GCancellable *cancellable)
-{
-	PurpleLog *log = PURPLE_LOG(object);
-	GError *error = NULL;
-	gboolean result;
-
-	result = purple_log_create(log, cancellable, &error);
-
-	if (!result)
-		g_simple_async_result_set_from_error(simple, error);
-	else
-		g_simple_async_result_set_op_res_gboolean(simple, TRUE);
-
-	g_clear_error(&error);
-}
-
-static void
-purple_log_real_create_async(PurpleLog *log, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
-{
-	GSimpleAsyncResult *simple;
-
-	simple = g_simple_async_result_new(G_OBJECT(log), cb, userdata, purple_log_real_create_async);
-
-	g_simple_async_result_run_in_thread(simple, create_thread, io_priority, cancellable);
-	g_object_unref(simple);
-}
-
-void
-purple_log_create_async(PurpleLog *log, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
-{
-	g_return_if_fail(PURPLE_IS_LOG(log));
-
-	PURPLE_LOG_GET_CLASS(log)->create_async(log, io_priority, cancellable, cb, userdata);
-}
-
-static gboolean
-purple_log_real_create_finish(PurpleLog *log, GAsyncResult *res, GError **error)
-{
-	return g_simple_async_result_get_op_res_gboolean(G_SIMPLE_ASYNC_RESULT(res));
-}
-
-gboolean
-purple_log_create_finish(PurpleLog *log, GAsyncResult *res, GError **error)
-{
-	g_return_val_if_fail(PURPLE_IS_LOG(log), FALSE);
-	g_return_val_if_fail(G_IS_ASYNC_RESULT(res), FALSE);
-
-	if (G_IS_SIMPLE_ASYNC_RESULT(res)) {
-		GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res);
-
-		if (g_simple_async_result_propagate_error(simple, error))
-			return FALSE;
-	}
-
-	return PURPLE_LOG_GET_CLASS(log)->create_finish(log, res, error);
-}
-
 gchar *
 purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags, GCancellable *cancellable, GError **error)
 {
============================================================
--- libpurple/log.h	97098cd5c1809b7b04b22e6e8de3cf3a5d265276
+++ libpurple/log.h	320d87df0fb2a91df0c5cebbf722aeac6d13c3a5
@@ -107,13 +107,6 @@ struct _PurpleLogClass {
 	/** An identifier to refer to this logger */
 	const gchar *logger_id;
 
-	/** This gets called when the log is first created, likely not actually needed */
-	gboolean (* create_fn) (PurpleLog *log, GCancellable *cancellable, GError **error);
-
-	void (* create_async) (PurpleLog *log, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
-
-	gboolean (* create_finish) (PurpleLog *log, GAsyncResult *res, GError **error);
-
 	/** This is used to write to the log file */
 	gssize (* write_fn) (PurpleLog *log, PurpleMessageFlags type, const gchar *from, time_t time, const gchar *message, GCancellable *cancellable, GError **error);
 
@@ -249,8 +242,6 @@ PurpleLog *purple_log_new(GType log_type
  */
 PurpleLog *purple_log_new(GType log_type, PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account, PurpleConversation *conv, time_t time, const struct tm *tm);
 
-//void purple_log_create?
-
 //
 void purple_log_set_logger_data(PurpleLog *log, gpointer logger_data);
 //
@@ -273,14 +264,6 @@ gchar *_process_txt_log(gchar *, gchar *
 gchar *_process_txt_log(gchar *, gchar *);
 
 
-//
-gboolean purple_log_create(PurpleLog *log, GCancellable *cancellable, GError **error);
-//
-void purple_log_create_async(PurpleLog *log, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata);
-//
-gboolean purple_log_create_finish(PurpleLog *log, GAsyncResult *res, GError **error);
-
-
 /**
  * Writes to a log file. Assumes you have checked preferences already.
  *
============================================================
--- pidgin/gtklog.c	e3a213ac451e1daae75111303754f1ba1b67cfdc
+++ pidgin/gtklog.c	805610db9515885d1af9aa535a671ceb2ad57bf2
@@ -1710,7 +1710,6 @@ pidgin_log_viewer_constructed(GObject *o
 	GtkDialog *dialog = GTK_DIALOG(lv);
 	GtkWidget *content_area = gtk_dialog_get_content_area(dialog);
 	GtkWidget *icon;
-	gchar *text;
 	gboolean need_log_size;
 
 	/* Icon */
@@ -1727,6 +1726,8 @@ pidgin_log_viewer_constructed(GObject *o
 	need_log_size = pidgin_log_viewer_get_need_log_size(lv);
 
 	if (need_log_size) {
+		gchar *text;
+
 		priv->size_label = gtk_label_new(NULL);
 		gtk_misc_set_alignment(GTK_MISC(priv->size_label), 0, 0);
 		gtk_box_pack_start(GTK_BOX(content_area), priv->size_label, FALSE, FALSE, 0);
============================================================
--- finch/gntlog.c	af70ae08aec62a6375f93b09edc4ee9a4e5f6c57
+++ finch/gntlog.c	861da496d43dd436b01f1939316a6951086425ad
@@ -125,8 +125,6 @@ static void populate_log_tree(FinchLogVi
 static void finch_log_read_cb(GObject *, GAsyncResult *, gpointer);
 static void log_select_cb(GntWidget *, gpointer, gpointer, FinchLogViewer *);
 static void populate_log_tree(FinchLogViewer *);
-static FinchLogViewer *finch_log_viewer_new(log_viewer_hash_t *,
-	const gchar *, gboolean);
 static void finch_log_done_cb(_finch_log_data *);
 static void finch_log_viewer_update_list_bar(_finch_log_data *);
 static void finch_log_viewer_update_search_bar(_finch_log_data *);
@@ -503,6 +501,8 @@ finch_log_viewer_new(log_viewer_hash_t *
 	FinchLogViewer *lv;
 
 	lv = g_object_new(FINCH_TYPE_LOG_VIEWER,
+		"vertical", TRUE,
+		"homogeneous", FALSE,
 		"viewer-title", title,
 		"viewer-type", ht != NULL ? ht->chat_type : PURPLE_LOG_SYSTEM,
 		"need-log-size", need_log_size,
@@ -519,94 +519,7 @@ finch_log_viewer_new(log_viewer_hash_t *
 
 	return lv;
 }
-#if 0
-	FinchLogViewer *lv_ex;
-	FinchLogViewer *lv;
-	GntWidget *vbox, *hbox;
-	gchar *text;
 
-	lv_ex = g_new0(FinchLogViewer, 1);
-	lv = g_new0(FinchLogViewer, 1);
-	lv->logs = NULL;
-	lv_ex->lv = lv;
-
-	if (ht != NULL) {
-		lv_ex->chat_type = ht->chat_type;
-		g_hash_table_insert(log_viewers, ht, lv_ex);
-	} else
-		lv_ex->chat_type = PURPLE_LOG_SYSTEM;
-
-	/* Window ***********/
-	lv->window = gnt_vwindow_new(FALSE);
-	gnt_box_set_title(GNT_BOX(lv->window), title);
-	gnt_box_set_toplevel(GNT_BOX(lv->window), TRUE);
-	gnt_box_set_pad(GNT_BOX(lv->window), 0);
-	g_signal_connect(lv->window, "destroy", G_CALLBACK(destroy_cb), ht);
-
-	vbox = gnt_vbox_new(FALSE);
-	gnt_box_add_widget(GNT_BOX(lv->window), vbox);
-
-	/* Label ************/
-	lv->label = gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD);
-	gnt_box_add_widget(GNT_BOX(vbox), lv->label);
-
-	hbox = gnt_hbox_new(FALSE);
-	gnt_box_add_widget(GNT_BOX(vbox), hbox);
-
-	/* List *************/
-	lv->tree = gnt_tree_new();
-	gnt_widget_set_size(lv->tree, 30, 0);
-	g_signal_connect(lv->tree, "selection-changed",
-		G_CALLBACK(log_select_cb), lv);
-	gnt_box_add_widget(GNT_BOX(hbox), lv->tree);
-
-	/* Viewer ************/
-	lv->text = gnt_text_view_new();
-	gnt_box_add_widget(GNT_BOX(hbox), lv->text);
-	gnt_text_view_set_flag(GNT_TEXT_VIEW(lv->text), GNT_TEXT_VIEW_TOP_ALIGN);
-
-	hbox = gnt_hbox_new(FALSE);
-	gnt_box_add_widget(GNT_BOX(vbox), hbox);
-
-	/* Log size ************/
-	if (need_log_size) {
-		priv->size = 0;
-		text = g_strdup_printf("%s %s", _("Total log size:"), _("calculating..."));
-
-		priv->size_label = gnt_label_new(text);
-		gnt_box_add_widget(GNT_BOX(hbox), priv->size_label);
-
-		g_free(text);
-	}
-
-	/* Search box **********/
-	gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Scroll/Search: ")));
-	lv->entry = gnt_entry_new("");
-	gnt_box_add_widget(GNT_BOX(hbox), lv->entry);
-	g_signal_connect(lv->entry, "activate", G_CALLBACK(search_cb), lv_ex);
-
-	gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(lv->text), lv->entry);
-	gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(lv->text), lv->entry);
-
-	/* Progress bars **********/
-	lv_ex->list_bar = gnt_progress_bar_new();
-	lv_ex->search_bar = gnt_progress_bar_new();
-
-	gnt_progress_bar_set_fraction(GNT_PROGRESS_BAR(lv_ex->search_bar), 1.0);
-
-	gnt_box_add_widget(GNT_BOX(vbox), lv_ex->list_bar);
-	gnt_box_add_widget(GNT_BOX(vbox), lv_ex->search_bar);
-
-	gnt_widget_show(lv->window);
-//	gnt_widget_hide(lv_ex->search_bar);
-
-	lv_ex->read_cancel = NULL;
-	lv_ex->search_cancel = NULL;
-	lv_ex->list_cancel = NULL;
-
-	return lv_ex;
-#endif
-
 static void
 finch_log_done_cb(_finch_log_data *finch_log_data)
 {
@@ -1305,6 +1218,29 @@ finch_log_viewer_constructed(GObject *ob
 static void
 finch_log_viewer_constructed(GObject *object)
 {
+	FinchLogViewer *lv = FINCH_LOG_VIEWER(object);
+	PidginLogViewerPrivate *priv = PIDGIN_LOG_VIEWER_GET_PRIVATE(lv);
+
+	/* Log size */
+	need_log_size = finch_log_viewer_get_need_log_size(lv);
+
+	if (need_log_size) {
+		gchar *text;
+
+		/* Strange things associated with the log size being set on
+		   construction that need to be worked out */
+		text = g_strdup_printf("%s %s", _("Total log size:"), _("calculating..."));
+
+		priv->size_label = gnt_label_new(text);
+		gnt_box_add_widget(GNT_BOX(hbox), priv->size_label);
+
+		g_free(text);
+	}
+
+	/* Hook up all the signals */
+	g_signal_connect(lv, "destroy", G_CALLBACK(destroy_cb), ht);
+	g_signal_connect(priv->tree, "selection-changed", G_CALLBACK(log_select_cb), lv);
+	g_signal_connect(priv->entry, "activate", G_CALLBACK(search_cb), lv);
 }
 
 static void
@@ -1588,6 +1524,69 @@ finch_log_viewer_init(FinchLogViewer *lv
 static void
 finch_log_viewer_init(FinchLogViewer *lv)
 {
+	GntBox *box = GNT_BOX(lv);
+	GntWidget *vbox, *hbox;
+
+	priv->logs = NULL;
+
+	/* Window */
+	gnt_box_set_toplevel(box, TRUE);
+	gnt_box_set_pad(box, 0);
+
+	vbox = gnt_vbox_new(FALSE);
+	gnt_box_add_widget(box, vbox);
+
+	/* Label */
+	/* Fixme: get the title for this here or move it to constructed */
+	priv->label = gnt_label_new_with_format(NULL, GNT_TEXT_FLAG_BOLD);
+	gnt_box_add_widget(GNT_BOX(vbox), priv->label);
+
+	/* Box for tree and text view */
+	hbox = gnt_hbox_new(FALSE);
+	gnt_box_add_widget(GNT_BOX(vbox), hbox);
+
+	/* List */
+	priv->tree = gnt_tree_new();
+	gnt_widget_set_size(priv->tree, 30, 0);
+	gnt_box_add_widget(GNT_BOX(hbox), priv->tree);
+
+	/* Viewer */
+	priv->text = gnt_text_view_new();
+	gnt_box_add_widget(GNT_BOX(hbox), priv->text);
+	gnt_text_view_set_flag(GNT_TEXT_VIEW(priv->text), GNT_TEXT_VIEW_TOP_ALIGN);
+
+	/* Box for search entry */
+	hbox = gnt_hbox_new(FALSE);
+	gnt_box_add_widget(GNT_BOX(vbox), hbox);
+
+	/* Search box */
+	gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Scroll/Search: ")));
+	priv->entry = gnt_entry_new("");
+	gnt_box_add_widget(GNT_BOX(hbox), priv->entry);
+
+	gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(priv->text), priv->entry);
+	gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(priv->text), priv->entry);
+
+	/* Progress bars */
+	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_box_add_widget(GNT_BOX(vbox), priv->list_bar);
+	gnt_box_add_widget(GNT_BOX(vbox), priv->search_bar);
+
+	gnt_widget_show(lv);
+/*	gnt_widget_show_all(lv);
+	gnt_widget_hide(lv);
+	gnt_widget_hide(priv->search_bar);*/
+
+	priv->logs = NULL;
+	priv->search = NULL;
+	priv->size = 0;
+	priv->read_cancel = NULL;
+	priv->search_cancel = NULL;
+	priv->list_cancel = NULL;
 }
 
 /****************************************************************************
============================================================
--- libpurple/htmllog.c	4dc2cb45e8a1be41f3c9b35e37623a9e3a18505d
+++ libpurple/htmllog.c	3c6b4cea5ab5ea309d4c045dfc82de9ff1a6e917
@@ -46,7 +46,6 @@ purple_html_log_class_init(PurpleHtmlLog
 	log_class->logger_name = _("HTML");
 	log_class->logger_id = "html";
 
-	log_class->create_fn = purple_html_log_create;
 	log_class->write_fn = purple_html_log_write;
 	log_class->list_fn = purple_html_log_list;
 	log_class->read_fn = purple_html_log_read;
============================================================
--- libpurple/txtlog.c	c1ffa5bcf9c3f0a5cc14a78fa1132d13060b1a34
+++ libpurple/txtlog.c	f07b77c2103b30628aa489b5786166d464b5b69b
@@ -44,7 +44,6 @@ purple_txt_log_class_init(PurpleTxtLogCl
 	log_class->logger_name = _("TXT");
 	log_class->logger_id = "txt";
 
-	log_class->create_fn = purple_txt_log_create;
 	log_class->write_fn = purple_txt_log_write;
 	log_class->list_fn = purple_txt_log_list;
 	log_class->read_fn = purple_txt_log_read;
============================================================
--- libpurple/commonlog.c	6e74339ca37dfd791ff6362042bfed42c62871c4
+++ libpurple/commonlog.c	a2aac71630152dfdf5e12271795e544c4b2d5721
@@ -61,7 +61,6 @@ static void common_thread_callback_data_
 
 static void common_thread_callback_data_free(gpointer);
 
-// static gboolean purple_log_common_create(PurpleLog *, GCancellable *, GError **);
 static gboolean purple_log_common_remove(PurpleLog *, GCancellable *, GError **);
 static gboolean purple_log_common_is_removable(PurpleLog *, GCancellable *, GError **);
 static gssize purple_log_common_size(PurpleLog *, GCancellable *, GError **);


More information about the Commits mailing list