cpw.nader.asynclogging-3: 1e3a691b: Cleaned up more of the '//'s
morshed.nader at gmail.com
morshed.nader at gmail.com
Tue May 17 01:12:15 EDT 2011
----------------------------------------------------------------------
Revision: 1e3a691b4d6e637f1247911ce0d075bc40f36c4e
Parent: bed508a308deb13a3395ba933bd488d96cd43c43
Author: morshed.nader at gmail.com
Date: 05/17/11 01:05:44
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/1e3a691b4d6e637f1247911ce0d075bc40f36c4e
Changelog:
Cleaned up more of the '//'s
Replaced g_output_stream_write with g_output_stream_write_all, fixing a potential issue with half-written log messages
Changes against parent bed508a308deb13a3395ba933bd488d96cd43c43
patched libpurple/commonlog.c
patched libpurple/htmllog.c
patched libpurple/oldlog.c
patched libpurple/txtlog.c
patched pidgin/gtklog.c
-------------- next part --------------
============================================================
--- pidgin/gtklog.c 865a0794fd6d9cb2e58c8f0dde3234fc1a67e1e5
+++ pidgin/gtklog.c 74516f85f54a0902eaf2570ffdb741aea62b5668
@@ -41,7 +41,7 @@
#if ! GLIB_CHECK_VERSION(2, 19, 8)
-//Fixes strict-aliasing warning
+/* Fixes strict-aliasing warning */
#undef g_static_mutex_get_mutex_impl_shortcut
#define g_static_mutex_get_mutex_impl_shortcut(mutex) \
@@ -780,7 +780,7 @@ pidgin_log_read_cb(GObject *object, GAsy
purple_signal_emit(pidgin_log_get_handle(), "log-displaying", lv, log);
- //gtk_imhtml_append_text is a time killer in loading logs, annoyingly
+ /* gtk_imhtml_append_text is a time killer in loading logs, annoyingly */
gtk_imhtml_append_text(imhtml, text,
GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL |
(flags & PURPLE_LOG_READ_NO_NEWLINE ? GTK_IMHTML_NO_NEWLINE : 0));
@@ -1564,7 +1564,7 @@ pidgin_log_viewer_add_logs(PidginLogView
priv = PIDGIN_LOG_VIEWER_GET_PRIVATE(lv);
logs = g_list_sort(logs, purple_log_compare);
- // faster if we reverse the list?
+ /* XXX: faster if we reverse the list? */
for (list = logs; list != NULL; list = g_list_next(list))
insert_log_viewer_log(lv, list->data);
@@ -2162,7 +2162,7 @@ pidgin_log_viewer_init(PidginLogViewer *
gtk_box_pack_start(GTK_BOX(content_area), priv->title_box, FALSE, FALSE, 0);
- //icon?
+ /* XXX: icon? */
/* Title Label */
priv->label = gtk_label_new(NULL);
@@ -2279,7 +2279,7 @@ pidgin_log_init(void)
void *handle = pidgin_log_get_handle();
G_LOCK(log_viewers);
- // Is the ht stuff leaking?
+ /* XXX: Is the ht stuff leaking? */
log_viewers = g_hash_table_new_full(log_viewer_hash, log_viewer_equal,
NULL, g_object_unref);
G_UNLOCK(log_viewers);
============================================================
--- libpurple/htmllog.c 0985d8b161d6f874fe8b00107c9346cf7dfe96ee
+++ libpurple/htmllog.c 254384830e78b4b5ad9fa6e8b2575b656962fdb4
@@ -182,8 +182,8 @@ purple_html_log_write(PurpleLog *log, Pu
GOutputStream *out_stream;
gchar *date, *escaped_from;
gchar *image_corrected_msg, *msg_fixed, *line;
- gssize written, size = 0;
- gboolean write_header;
+ gsize written, size = 0;
+ gboolean write_header, success;
file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
@@ -192,7 +192,7 @@ purple_html_log_write(PurpleLog *log, Pu
* creating a new file there would result in empty files in the case
* that you open a convo with someone, but don't say anything.
*/
- //Should we be doing this?
+ /* XXX: Should we be doing this? */
if (!purple_html_log_create(log, cancellable, error))
return -1;
@@ -253,11 +253,11 @@ purple_html_log_write(PurpleLog *log, Pu
g_free(header);
- written = g_output_stream_write(out_stream, line,
- strlen(line), cancellable, error);
+ success = g_output_stream_write_all(out_stream, line,
+ strlen(line), &written, cancellable, error);
g_free(line);
- if (written < 0) {
+ if (!success) {
g_object_unref(file);
g_object_unref(stream);
@@ -329,13 +329,13 @@ purple_html_log_write(PurpleLog *log, Pu
}
}
- written = g_output_stream_write(out_stream, line, strlen(line),
- cancellable, error);
+ success = g_output_stream_write_all(out_stream, line, strlen(line),
+ &written, cancellable, error);
- if (written < 0)
- size = -1;
+ if (success)
+ size += written;
else
- size += written;
+ size = -1;
g_free(date);
g_free(msg_fixed);
@@ -412,9 +412,11 @@ write_footer(PurpleCommonLog *common_log
static void
write_footer(PurpleCommonLog *common_log, const gchar *footer)
{
+ GError *error = NULL;
GFile *file;
GFileOutputStream *file_stream;
GOutputStream *stream;
+ gboolean success;
file = purple_common_log_get_file(common_log);
@@ -427,8 +429,15 @@ write_footer(PurpleCommonLog *common_log
return;
stream = G_OUTPUT_STREAM(file_stream);
- g_output_stream_write(stream, footer, strlen(footer), NULL, NULL);
+ success = g_output_stream_write_all(stream, footer, strlen(footer),
+ NULL, NULL, &error);
g_object_unref(file_stream);
+
+ if (!success)
+ purple_debug_warning("htmllog", "Error writing file footer: %s",
+ error->message);
+
+ g_clear_error(&error);
}
static void
============================================================
--- libpurple/oldlog.c 9034368587f4511a0741b6cfc7bb090ca397213d
+++ libpurple/oldlog.c ebdb68017f452903f287e9e801ed665479c0f799
@@ -72,7 +72,7 @@ purple_old_log_new(PurpleLogChatType typ
time, tm);
}
-// Needs testing!!!
+/* XXX: Needs testing!!! */
static GList *
purple_old_log_list(PurpleLog *log, PurpleLogChatType chat_type,
const gchar *sn, PurpleAccount *account, GCancellable *cancellable,
============================================================
--- libpurple/txtlog.c 6aee8b0fc9cd651f0b93436f711b8866ebebfaab
+++ libpurple/txtlog.c f4aebbe439e03d22587938810780d44e6fbaac5a
@@ -87,8 +87,8 @@ purple_txt_log_write(PurpleLog *log, Pur
GFileOutputStream *stream;
GOutputStream *out_stream;
gchar *stripped = NULL, *date, *line;
- gssize written, size = 0;
- gboolean write_header;
+ gsize written, size = 0;
+ gboolean success, write_header;
if (type & PURPLE_MESSAGE_NO_LOG) {
g_set_error_literal(error,
@@ -106,7 +106,7 @@ purple_txt_log_write(PurpleLog *log, Pur
* creating a new file there would result in empty files in the case
* that you open a convo with someone, but don't say anything.
*/
- //Should we be doing this?
+ /* XXX: Should we be doing this? */
if (!purple_txt_log_create(log, cancellable, error))
return -1;
@@ -152,11 +152,11 @@ purple_txt_log_write(PurpleLog *log, Pur
purple_date_format_full(localtime(&log_time)),
purple_account_get_username(account), prpl);
- written = g_output_stream_write(out_stream, line,
- strlen(line), cancellable, error);
+ success = g_output_stream_write_all(out_stream, line,
+ strlen(line), &written, cancellable, error);
g_free(line);
- if (written < 0) {
+ if (!success) {
g_object_unref(stream);
return -1;
@@ -196,13 +196,13 @@ purple_txt_log_write(PurpleLog *log, Pur
from ? ":" : "", stripped);
}
- written = g_output_stream_write(out_stream, line, strlen(line),
- cancellable, error);
+ success = g_output_stream_write_all(out_stream, line, strlen(line),
+ &written, cancellable, error);
- if (written < 0)
- size = -1;
+ if (success)
+ size += written;
else
- size += written;
+ size = -1;
g_free(line);
g_free(date);
============================================================
--- libpurple/commonlog.c 127a4ffd03707f5b36e49c273f0e29e1b54879ab
+++ libpurple/commonlog.c 3abdc7ce806a3422c3d52fe91778848f12f51068
@@ -560,7 +560,7 @@ purple_log_common_lister_async(PurpleLog
callback_data = g_new0(_common_thread_callback_data, 1);
callback_data->chat_type = chat_type;
callback_data->name = g_strdup(name);
- callback_data->account = account; // g_object_ref
+ callback_data->account = account; /* XXX: g_object_ref */
callback_data->ext = g_strdup(ext);
callback_data->log_type = log_type;
@@ -591,9 +591,11 @@ purple_log_common_lister_finish(GAsyncRe
return g_simple_async_result_get_op_res_gpointer(simple);
}
-// TODO: Rather than calling this multiple times with different extensions,
-// TODO: could we somehow store up all the extensions and do the loop just
-// TODO: once? This may be possible with the non-blocking stuff...
+/**
+ * TODO: Rather than calling this multiple times with different extensions,
+ * TODO: could we somehow store up all the extensions and do the loop just
+ * TODO: once? This may be possible with the non-blocking stuff...
+ */
gssize
purple_log_common_total_sizer(PurpleLogChatType chat_type, const gchar *name,
PurpleAccount *account, const gchar *ext, GCancellable *cancellable,
More information about the Commits
mailing list