cpw.nader.asynclogging-3: 67bd5c47: Cleaned up long lines in commonlog.c and...
morshed.nader at gmail.com
morshed.nader at gmail.com
Sun Apr 24 20:20:53 EDT 2011
----------------------------------------------------------------------
Revision: 67bd5c477569ab3845ef15590489c067a6fc9044
Parent: f2afaea6474b27bf73f6f0e12c09ad50a001d265
Author: morshed.nader at gmail.com
Date: 03/30/11 20:52:33
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/67bd5c477569ab3845ef15590489c067a6fc9044
Changelog:
Cleaned up long lines in commonlog.c and txtlog.c
Changes against parent f2afaea6474b27bf73f6f0e12c09ad50a001d265
patched libpurple/commonlog.c
patched libpurple/txtlog.c
-------------- next part --------------
============================================================
--- libpurple/txtlog.c 536cc48eecf638af3c55f0bdd9325a2ada7fc048
+++ libpurple/txtlog.c 6aee8b0fc9cd651f0b93436f711b8866ebebfaab
@@ -30,11 +30,16 @@ static gboolean purple_txt_log_create(Pu
G_DEFINE_TYPE (PurpleTxtLog, purple_txt_log, PURPLE_TYPE_COMMON_LOG)
static gboolean purple_txt_log_create(PurpleLog *, GCancellable *, GError **);
-static gssize purple_txt_log_write(PurpleLog *, PurpleMessageFlags, const gchar *, time_t, const gchar *, GCancellable *, GError **);
-static GList *purple_txt_log_list(PurpleLog *, PurpleLogChatType, const gchar *, PurpleAccount *, GCancellable *, GError **);
-static gchar *purple_txt_log_read(PurpleLog *, PurpleLogReadFlags *, GCancellable *, GError **);
-static gssize purple_txt_log_total_size(PurpleLog *, PurpleLogChatType, const gchar *, PurpleAccount *, GCancellable *, GError **);
-static GList *purple_txt_log_list_syslog(PurpleLog *, PurpleAccount *, GCancellable *, GError **);
+static gssize purple_txt_log_write(PurpleLog *, PurpleMessageFlags,
+ const gchar *, time_t, const gchar *, GCancellable *, GError **);
+static GList *purple_txt_log_list(PurpleLog *, PurpleLogChatType, const gchar *,
+ PurpleAccount *, GCancellable *, GError **);
+static gchar *purple_txt_log_read(PurpleLog *, PurpleLogReadFlags *,
+ GCancellable *, GError **);
+static gssize purple_txt_log_total_size(PurpleLog *, PurpleLogChatType,
+ const gchar *, PurpleAccount *, GCancellable *, GError **);
+static GList *purple_txt_log_list_syslog(PurpleLog *, PurpleAccount *,
+ GCancellable *, GError **);
static void
purple_txt_log_class_init(PurpleTxtLogClass *class)
@@ -57,10 +62,12 @@ PurpleLog *
}
PurpleLog *
-purple_txt_log_new(PurpleLogChatType type, const gchar *name, PurpleAccount *account,
- PurpleConversation *conv, time_t time, const struct tm *tm)
+purple_txt_log_new(PurpleLogChatType type, const gchar *name,
+ PurpleAccount *account, PurpleConversation *conv, time_t time,
+ const struct tm *tm)
{
- return purple_common_log_new(PURPLE_TYPE_TXT_LOG, type, name, account, conv, time, tm);
+ return purple_common_log_new(PURPLE_TYPE_TXT_LOG, type, name, account, conv,
+ time, tm);
}
static gboolean
@@ -70,7 +77,9 @@ static gssize
}
static gssize
-purple_txt_log_write(PurpleLog *log, PurpleMessageFlags type, const gchar *from, time_t time, const gchar *message, GCancellable *cancellable, GError **error)
+purple_txt_log_write(PurpleLog *log, PurpleMessageFlags type, const gchar *from,
+ time_t time, const gchar *message, GCancellable *cancellable,
+ GError **error)
{
PurpleLogChatType chat_type = purple_log_get_chat_type(log);
PurpleCommonLog *common_log = PURPLE_COMMON_LOG(log);
@@ -133,7 +142,8 @@ purple_txt_log_write(PurpleLog *log, Pur
prpl = PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->list_icon(account, NULL);
if (chat_type == PURPLE_LOG_SYSTEM)
- line = g_strdup_printf("System log for account %s (%s) connected at %s\n",
+ line = g_strdup_printf("System log for account %s (%s) "
+ "connected at %s\n",
purple_account_get_username(account), prpl,
purple_date_format_full(localtime(&log_time)));
else
@@ -165,12 +175,15 @@ purple_txt_log_write(PurpleLog *log, Pur
type & PURPLE_MESSAGE_RECV)
{
if (type & PURPLE_MESSAGE_AUTO_RESP)
- line = g_strdup_printf(_("(%s) %s <AUTO-REPLY>: %s\n"), date, from, stripped);
+ line = g_strdup_printf(_("(%s) %s <AUTO-REPLY>: %s\n"), date,
+ from, stripped);
else {
if (purple_message_meify(stripped, -1))
- line = g_strdup_printf("(%s) ***%s %s\n", date, from, stripped);
+ line = g_strdup_printf("(%s) ***%s %s\n", date, from,
+ stripped);
else
- line = g_strdup_printf("(%s) %s: %s\n", date, from, stripped);
+ line = g_strdup_printf("(%s) %s: %s\n", date, from,
+ stripped);
}
} else if (type & PURPLE_MESSAGE_SYSTEM ||
type & PURPLE_MESSAGE_ERROR ||
@@ -200,19 +213,24 @@ static GList *
}
static GList *
-purple_txt_log_list(PurpleLog *log, PurpleLogChatType type, const gchar *sn, PurpleAccount *account, GCancellable *cancellable, GError **error)
+purple_txt_log_list(PurpleLog *log, PurpleLogChatType type, const gchar *sn,
+ PurpleAccount *account, GCancellable *cancellable, GError **error)
{
- return purple_log_common_lister(type, sn, account, ".txt", PURPLE_TYPE_TXT_LOG, cancellable, error);
+ return purple_log_common_lister(type, sn, account, ".txt",
+ PURPLE_TYPE_TXT_LOG, cancellable, error);
}
static GList *
-purple_txt_log_list_syslog(PurpleLog *log, PurpleAccount *account, GCancellable *cancellable, GError **error)
+purple_txt_log_list_syslog(PurpleLog *log, PurpleAccount *account,
+ GCancellable *cancellable, GError **error)
{
- return purple_log_common_lister(PURPLE_LOG_SYSTEM, ".system", account, ".txt", PURPLE_TYPE_TXT_LOG, cancellable, error);
+ return purple_log_common_lister(PURPLE_LOG_SYSTEM, ".system", account,
+ ".txt", PURPLE_TYPE_TXT_LOG, cancellable, error);
}
static gchar *
-purple_txt_log_read(PurpleLog *log, PurpleLogReadFlags *flags, GCancellable *cancellable, GError **error)
+purple_txt_log_read(PurpleLog *log, PurpleLogReadFlags *flags,
+ GCancellable *cancellable, GError **error)
{
PurpleCommonLog *common_log = PURPLE_COMMON_LOG(log);
GFile *file;
@@ -245,9 +263,12 @@ static gssize
}
static gssize
-purple_txt_log_total_size(PurpleLog *log, PurpleLogChatType type, const gchar *name, PurpleAccount *account, GCancellable *cancellable, GError **error)
+purple_txt_log_total_size(PurpleLog *log, PurpleLogChatType type,
+ const gchar *name, PurpleAccount *account, GCancellable *cancellable,
+ GError **error)
{
- return purple_log_common_total_sizer(type, name, account, ".txt", cancellable, error);
+ return purple_log_common_total_sizer(type, name, account, ".txt",
+ cancellable, error);
}
void
============================================================
--- libpurple/commonlog.c 63a51139fe74ce375ed7ea8880f4357b6a71dbd1
+++ libpurple/commonlog.c 11e5a5d7ff09bf9ca30b165c205c5ee81ee21096
@@ -28,8 +28,10 @@ G_DEFINE_TYPE (PurpleCommonLog, purple_c
#include "commonlog.h"
G_DEFINE_TYPE (PurpleCommonLog, purple_common_log, PURPLE_TYPE_LOG)
-static void purple_common_log_get_property(GObject *, guint, GValue *, GParamSpec *);
-static void purple_common_log_set_property(GObject *, guint, const GValue *, GParamSpec *);
+static void purple_common_log_get_property(GObject *, guint, GValue *,
+ GParamSpec *);
+static void purple_common_log_set_property(GObject *, guint, const GValue *,
+ GParamSpec *);
static void purple_common_log_finalize(GObject *);
enum {
@@ -61,7 +63,8 @@ static void common_thread_callback_data_
static void common_thread_callback_data_free(gpointer);
-static gboolean purple_log_common_remove(PurpleLog *, GCancellable *, GError **);
+static gboolean purple_log_common_remove(PurpleLog *, GCancellable *,
+ GError **);
static gssize purple_log_common_size(PurpleLog *, GCancellable *, GError **);
static void
@@ -131,14 +134,16 @@ PurpleLog *
}
PurpleLog *
-purple_common_log_new(GType log_type, PurpleLogChatType type, const gchar *name, PurpleAccount *account,
- PurpleConversation *conv, time_t time, const struct tm *tm)
+purple_common_log_new(GType log_type, PurpleLogChatType type, const gchar *name,
+ PurpleAccount *account, PurpleConversation *conv, time_t time,
+ const struct tm *tm)
{
return purple_log_new(log_type, type, name, account, conv, time, tm);
}
static void
-purple_common_log_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+purple_common_log_set_property(GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
{
PurpleCommonLog *common_log = PURPLE_COMMON_LOG(object);
@@ -159,7 +164,8 @@ static void
}
static void
-purple_common_log_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+purple_common_log_get_property(GObject *object, guint prop_id, GValue *value,
+ GParamSpec *pspec)
{
PurpleCommonLog *common_log = PURPLE_COMMON_LOG(object);
@@ -251,7 +257,8 @@ static gboolean
}
static gboolean
-purple_log_common_remove(PurpleLog *log, GCancellable *cancellable, GError **error)
+purple_log_common_remove(PurpleLog *log, GCancellable *cancellable,
+ GError **error)
{
PurpleCommonLogPrivate *priv = PURPLE_COMMON_LOG_GET_PRIVATE(log);
gboolean result;
@@ -273,7 +280,8 @@ gboolean
}
gboolean
-purple_log_common_writer(PurpleLog *log, const gchar *ext, GCancellable *cancellable, GError **error)
+purple_log_common_writer(PurpleLog *log, const gchar *ext,
+ GCancellable *cancellable, GError **error)
{
PurpleCommonLogPrivate *priv;
@@ -326,7 +334,8 @@ purple_log_common_writer(PurpleLog *log,
g_free(path);
/* Make sure the file is writeable */
- stream = g_file_append_to(priv->file, G_FILE_CREATE_PRIVATE, cancellable, error);
+ stream = g_file_append_to(priv->file, G_FILE_CREATE_PRIVATE,
+ cancellable, error);
if (stream == NULL) {
// PurpleConversation *conv = purple_log_get_conversation(log);
@@ -348,7 +357,8 @@ static void
}
static void
-writer_thread(GSimpleAsyncResult *simple, GObject *object, GCancellable *cancellable)
+writer_thread(GSimpleAsyncResult *simple, GObject *object,
+ GCancellable *cancellable)
{
PurpleLog *log = PURPLE_LOG(object);
GError *error = NULL;
@@ -366,22 +376,26 @@ void
}
void
-purple_log_common_writer_async(PurpleLog *log, const gchar *ext, gint io_priority,
- GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
+purple_log_common_writer_async(PurpleLog *log, const gchar *ext,
+ gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
+ gpointer userdata)
{
GSimpleAsyncResult *simple;
g_return_if_fail(PURPLE_IS_LOG(log));
- simple = g_simple_async_result_new(G_OBJECT(log), cb, userdata, purple_log_common_writer_async);
+ simple = g_simple_async_result_new(G_OBJECT(log), cb, userdata,
+ purple_log_common_writer_async);
g_simple_async_result_set_op_res_gpointer(simple, g_strdup(ext), g_free);
- g_simple_async_result_run_in_thread(simple, writer_thread, io_priority, cancellable);
+ g_simple_async_result_run_in_thread(simple, writer_thread, io_priority,
+ cancellable);
g_object_unref(simple);
}
gboolean
-purple_log_common_writer_finish(PurpleLog *log, GAsyncResult *res, GError **error)
+purple_log_common_writer_finish(PurpleLog *log, GAsyncResult *res,
+ GError **error)
{
GSimpleAsyncResult *simple;
@@ -409,7 +423,8 @@ purple_log_common_lister(PurpleLogChatTy
g_return_val_if_fail(name != NULL, NULL);
g_return_val_if_fail(account != NULL, NULL);
g_return_val_if_fail(ext != NULL, NULL);
- g_return_val_if_fail(log_type == G_TYPE_INVALID || g_type_is_a(log_type, PURPLE_TYPE_LOG), NULL);
+ g_return_val_if_fail(log_type == G_TYPE_INVALID || g_type_is_a(log_type, PURPLE_TYPE_LOG),
+ NULL);
path = purple_log_get_log_dir(chat_type, name, account);
@@ -450,26 +465,32 @@ purple_log_common_lister(PurpleLogChatTy
const gchar *rest, *end;
time_t stamp;
- stamp = purple_str_to_time(purple_unescape_filename(filename), FALSE, &tm, &tz_off, &rest);
+ stamp = purple_str_to_time(purple_unescape_filename(filename),
+ FALSE, &tm, &tz_off, &rest);
/* As zero is a valid offset, PURPLE_NO_TZ_OFF means no offset was
* provided. See util.h. Yes, it's kinda ugly. */
if (tz_off != PURPLE_NO_TZ_OFF)
tm.tm_gmtoff = tz_off - tm.tm_gmtoff;
- if (stamp == 0 || rest == NULL || (end = strchr(rest, '.')) == NULL ||
+ if (stamp == 0 || rest == NULL ||
+ (end = strchr(rest, '.')) == NULL ||
strchr(rest, ' ') != NULL)
- log = purple_log_new(log_type, chat_type, name, account, NULL, stamp, NULL);
- else {
+ {
+ log = purple_log_new(log_type, chat_type, name, account, NULL,
+ stamp, NULL);
+ } else {
gchar *tmp = g_strndup(rest, end - rest);
tm.tm_zone = tmp;
- log = purple_log_new(log_type, chat_type, name, account, NULL, stamp, &tm);
+ log = purple_log_new(log_type, chat_type, name, account, NULL,
+ stamp, &tm);
g_free(tmp);
}
#else
time_t stamp = purple_str_to_time(filename, FALSE, &tm, NULL, NULL);
- log = purple_log_new(log_type, chat_type, name, account, NULL, stamp, (stamp != 0) ? &tm : NULL);
+ log = purple_log_new(log_type, chat_type, name, account, NULL,
+ stamp, (stamp != 0) ? &tm : NULL);
#endif
tmp = g_build_filename(path, filename, NULL);
@@ -489,7 +510,8 @@ static void
}
static void
-common_lister_thread(GSimpleAsyncResult *simple, GObject *object, GCancellable *cancellable)
+common_lister_thread(GSimpleAsyncResult *simple, GObject *object,
+ GCancellable *cancellable)
{
_common_thread_callback_data *callback_data =
g_simple_async_result_get_op_res_gpointer(simple);
@@ -500,7 +522,8 @@ common_lister_thread(GSimpleAsyncResult
GList *list;
gchar *name = callback_data->name, *ext = callback_data->ext;
- list = purple_log_common_lister(chat_type, name, account, ext, log_type, cancellable, &error);
+ list = purple_log_common_lister(chat_type, name, account, ext, log_type,
+ cancellable, &error);
if (list == NULL)
g_simple_async_result_set_from_error(simple, error);
@@ -512,9 +535,9 @@ void
}
void
-purple_log_common_lister_async(PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account,
- const gchar *ext, GType log_type, gint io_priority, GCancellable *cancellable,
- GAsyncReadyCallback cb, gpointer userdata)
+purple_log_common_lister_async(PurpleLogChatType chat_type, const gchar *name,
+ PurpleAccount *account, const gchar *ext, GType log_type, gint io_priority,
+ GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
{
_common_thread_callback_data *callback_data;
GSimpleAsyncResult *simple;
@@ -530,12 +553,13 @@ purple_log_common_lister_async(PurpleLog
callback_data->ext = g_strdup(ext);
callback_data->log_type = log_type;
- simple = g_simple_async_result_new(NULL, cb, userdata, purple_log_common_lister_async);
+ simple = g_simple_async_result_new(NULL, cb, userdata,
+ purple_log_common_lister_async);
g_simple_async_result_set_op_res_gpointer(simple, callback_data,
common_thread_callback_data_free);
- g_simple_async_result_run_in_thread(simple, common_lister_thread, io_priority,
- cancellable);
+ g_simple_async_result_run_in_thread(simple, common_lister_thread,
+ io_priority, cancellable);
g_object_unref(simple);
}
@@ -550,7 +574,8 @@ purple_log_common_lister_finish(GAsyncRe
if (g_simple_async_result_propagate_error(simple, error))
return NULL;
- g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == purple_log_common_lister_async, NULL);
+ g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == purple_log_common_lister_async,
+ NULL);
return g_simple_async_result_get_op_res_gpointer(simple);
}
@@ -559,7 +584,9 @@ gssize
// 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, GError **error)
+purple_log_common_total_sizer(PurpleLogChatType chat_type, const gchar *name,
+ PurpleAccount *account, const gchar *ext, GCancellable *cancellable,
+ GError **error)
{
// _purple_logsize_user *lu;
GDir *dir;
@@ -644,7 +671,8 @@ static void
}
static void
-common_total_sizer_thread(GSimpleAsyncResult *simple, GObject *object, GCancellable *cancellable)
+common_total_sizer_thread(GSimpleAsyncResult *simple, GObject *object,
+ GCancellable *cancellable)
{
_common_thread_callback_data *callback_data =
g_simple_async_result_get_op_res_gpointer(simple);
@@ -654,7 +682,8 @@ common_total_sizer_thread(GSimpleAsyncRe
gchar *name = callback_data->name, *ext = callback_data->ext;
gssize size;
- size = purple_log_common_total_sizer(chat_type, name, account, ext, cancellable, &error);
+ size = purple_log_common_total_sizer(chat_type, name, account, ext,
+ cancellable, &error);
if (size < 0)
g_simple_async_result_set_from_error(simple, error);
@@ -665,9 +694,10 @@ void
}
void
-purple_log_common_total_sizer_async(PurpleLogChatType chat_type, const gchar *name,
- PurpleAccount *account, const gchar *ext, gint io_priority, GCancellable *cancellable,
- GAsyncReadyCallback cb, gpointer userdata)
+purple_log_common_total_sizer_async(PurpleLogChatType chat_type,
+ const gchar *name, PurpleAccount *account, const gchar *ext,
+ gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
+ gpointer userdata)
{
_common_thread_callback_data *callback_data;
GSimpleAsyncResult *simple;
@@ -682,11 +712,13 @@ purple_log_common_total_sizer_async(Purp
callback_data->account = account;
callback_data->ext = g_strdup(ext);
- simple = g_simple_async_result_new(NULL, cb, userdata, purple_log_common_total_sizer_async);
+ simple = g_simple_async_result_new(NULL, cb, userdata,
+ purple_log_common_total_sizer_async);
g_simple_async_result_set_op_res_gpointer(simple, callback_data,
common_thread_callback_data_free);
- g_simple_async_result_run_in_thread(simple, common_total_sizer_thread, io_priority, cancellable);
+ g_simple_async_result_run_in_thread(simple, common_total_sizer_thread,
+ io_priority, cancellable);
g_object_unref(simple);
}
@@ -701,13 +733,15 @@ purple_log_common_total_sizer_finish(GAs
if (g_simple_async_result_propagate_error(simple, error))
return -1;
- g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == purple_log_common_total_sizer_async, -1);
+ g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == purple_log_common_total_sizer_async,
+ -1);
return g_simple_async_result_get_op_res_gssize(simple);
}
static gssize
-purple_log_common_size(PurpleLog *log, GCancellable *cancellable, GError **error)
+purple_log_common_size(PurpleLog *log, GCancellable *cancellable,
+ GError **error)
{
PurpleCommonLogPrivate *priv = PURPLE_COMMON_LOG_GET_PRIVATE(log);
GFileInfo *info;
More information about the Commits
mailing list