cpw.nader.asynclogging-3: ab9f19cc: Updated the other log classes to use the...
morshed.nader at gmail.com
morshed.nader at gmail.com
Tue Jan 3 00:02:29 EST 2012
----------------------------------------------------------------------
Revision: ab9f19cc43132b5d20d58838c6316f6f69bcc35f
Parent: 7ed239bff5689de50495f7082e6ac7a9538c363f
Author: morshed.nader at gmail.com
Date: 01/02/12 23:57:01
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/ab9f19cc43132b5d20d58838c6316f6f69bcc35f
Changelog:
Updated the other log classes to use the new function names from purple_common_log
Changes against parent 7ed239bff5689de50495f7082e6ac7a9538c363f
patched libpurple/htmllog.c
patched libpurple/oldlog.c
patched libpurple/txtlog.c
-------------- next part --------------
============================================================
--- libpurple/htmllog.c ba0f5c5b13a3fc73a9989f92ec83922a04c66c53
+++ libpurple/htmllog.c 32d1e251fdee18e770c2fffe9bf53a8693773431
@@ -57,21 +57,21 @@ purple_html_log_create(PurpleLog *log, G
purple_html_log_create(PurpleLog *log, GCancellable *cancellable,
GError **error)
{
- return purple_log_common_writer(log, ".html", cancellable, error);
+ return purple_log_common_create(log, ".html", cancellable, error);
}
static void
purple_html_log_create_async(PurpleLog *log, gint io_priority,
GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
{
- purple_log_common_writer_async(log, ".html", io_priority, cancellable, cb,
+ purple_log_common_create_async(log, ".html", io_priority, cancellable, cb,
userdata);
}
static gboolean
purple_html_log_create_finish(PurpleLog *log, GAsyncResult *res, GError **error)
{
- return purple_log_common_writer_finish(log, res, error);
+ return purple_log_common_create_finish(log, res, error);
}
/* NOTE: This can return msg (which you may or may not want to g_free())
@@ -172,14 +172,15 @@ purple_html_log_write(PurpleLog *log, Pu
GFile *file;
GFileOutputStream *stream;
GOutputStream *out_stream;
+ const gchar *path;
gchar *date, *escaped_from;
gchar *image_corrected_msg, *msg_fixed, *line;
gsize written, size = 0;
gboolean write_header, success;
- file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
- if (file == NULL) {
+ if (path == NULL) {
/* This log is new. We could use the loggers 'new' function, but
* 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.
@@ -188,13 +189,13 @@ purple_html_log_write(PurpleLog *log, Pu
if (!purple_html_log_create(log, cancellable, error))
return -1;
- file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
write_header = TRUE;
} else
write_header = FALSE;
/* If we can't write to the file, give up before we hurt ourselves */
- if (file == NULL) {
+ if (path == NULL) {
g_set_error_literal(error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
@@ -203,7 +204,9 @@ purple_html_log_write(PurpleLog *log, Pu
return -1;
}
+ file = g_file_new_for_path(path);
stream = g_file_append_to(file, G_FILE_CREATE_NONE, cancellable, error);
+ g_object_unref(file);
if (stream == NULL)
return -1;
@@ -374,7 +377,7 @@ purple_html_log_write_async(PurpleLog *l
callback_data->write_header = FALSE;
callback_data->out_stream = NULL;
- if (purple_common_log_get_file(PURPLE_COMMON_LOG(log)) == NULL)
+ if (purple_common_log_get_path(PURPLE_COMMON_LOG(log)) == NULL)
/* This log is new. We could use a logger 'new' function, but
* 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.
@@ -392,6 +395,7 @@ purple_html_log_write_async_2(PurpleLog
{
GFile *file;
GSimpleAsyncResult *simple;
+ const gchar *path;
if (res != NULL) {
GError *error = NULL;
@@ -411,10 +415,10 @@ purple_html_log_write_async_2(PurpleLog
data->write_header = TRUE;
}
- file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
/* If we can't write to the file, give up before we hurt ourselves */
- if (file == NULL) {
+ if (path == NULL) {
simple = g_simple_async_result_new_error(G_OBJECT(log), data->cb,
data->userdata,
G_IO_ERROR,
@@ -427,9 +431,11 @@ purple_html_log_write_async_2(PurpleLog
return;
}
+ file = g_file_new_for_path(path);
g_file_append_to_async(file, G_FILE_CREATE_NONE,
data->io_priority, data->cancellable,
(GAsyncReadyCallback) purple_html_log_write_async_3, data);
+ g_object_unref(file);
}
/* Create the header and write it to the file */
@@ -595,7 +601,7 @@ purple_html_log_list(PurpleLog *log, Pur
purple_html_log_list(PurpleLog *log, PurpleLogChatType type, const gchar *sn,
PurpleAccount *account, GCancellable *cancellable, GError **error)
{
- return purple_log_common_lister(type, sn, account, ".html",
+ return purple_log_common_list(type, sn, account, ".html",
PURPLE_TYPE_HTML_LOG, cancellable, error);
}
@@ -604,7 +610,7 @@ purple_html_log_list_async(PurpleLog *lo
const gchar *sn, PurpleAccount *account, gint io_priority,
GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
{
- purple_log_common_lister_async(type, sn, account, ".html",
+ purple_log_common_list_async(type, sn, account, ".html",
PURPLE_TYPE_HTML_LOG, io_priority, cancellable, cb, userdata);
}
@@ -612,7 +618,7 @@ purple_html_log_list_syslog(PurpleLog *l
purple_html_log_list_syslog(PurpleLog *log, PurpleAccount *account,
GCancellable *cancellable, GError **error)
{
- return purple_log_common_lister(PURPLE_LOG_SYSTEM, ".system", account,
+ return purple_log_common_list(PURPLE_LOG_SYSTEM, ".system", account,
".html", PURPLE_TYPE_HTML_LOG, cancellable, error);
}
@@ -621,7 +627,7 @@ purple_html_log_list_syslog_async(Purple
gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
gpointer userdata)
{
- purple_log_common_lister_async(PURPLE_LOG_SYSTEM, ".system", account,
+ purple_log_common_list_async(PURPLE_LOG_SYSTEM, ".system", account,
".html", PURPLE_TYPE_HTML_LOG, io_priority, cancellable, cb, userdata);
}
@@ -630,14 +636,16 @@ purple_html_log_read(PurpleLog *log, Pur
GCancellable *cancellable, GError **error)
{
GFile *file;
+ const gchar *path;
gchar *read, *minus_header;
+ gboolean result;
if (flags != NULL)
*flags = PURPLE_LOG_READ_NO_NEWLINE;
- file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
- if (file == NULL) {
+ if (path == NULL) {
g_set_error_literal(error,
G_FILE_ERROR,
G_IO_ERROR_NOT_FOUND,
@@ -646,7 +654,11 @@ purple_html_log_read(PurpleLog *log, Pur
return NULL;
}
- if (!g_file_load_contents(file, cancellable, &read, NULL, NULL, error))
+ file = g_file_new_for_path(path);
+ result = g_file_load_contents(file, cancellable, &read, NULL, NULL, error);
+ g_object_unref(file);
+
+ if (!result)
return NULL;
minus_header = strchr(read, '\n');
@@ -676,7 +688,7 @@ purple_html_log_total_size(PurpleLog *lo
const gchar *name, PurpleAccount *account, GCancellable *cancellable,
GError **error)
{
- return purple_log_common_total_sizer(type, name, account, ".html",
+ return purple_log_common_total_size(type, name, account, ".html",
cancellable, error);
}
@@ -685,7 +697,7 @@ purple_html_log_total_size_async(PurpleL
const gchar *name, PurpleAccount *account, gint io_priority,
GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
{
- purple_log_common_total_sizer_async(type, name, account, ".html",
+ purple_log_common_total_size_async(type, name, account, ".html",
io_priority, cancellable, cb, userdata);
}
@@ -696,14 +708,17 @@ write_footer(PurpleCommonLog *common_log
GFile *file;
GFileOutputStream *file_stream;
GOutputStream *stream;
+ const gchar *path;
gboolean success;
- file = purple_common_log_get_file(common_log);
+ path = purple_common_log_get_path(common_log);
- if (file == NULL)
+ if (path == NULL)
return;
+ file = g_file_new_for_path(path);
file_stream = g_file_append_to(file, G_FILE_CREATE_PRIVATE, NULL, NULL);
+ g_object_unref(file);
if (file_stream == NULL)
return;
============================================================
--- libpurple/oldlog.c 1a6f067668c9f88e2ca0808b3bd7c7fdc4b07d5d
+++ libpurple/oldlog.c 81c37bbece596d99bfd27b97d6db287ece3fb624
@@ -167,7 +167,8 @@ purple_old_log_list(PurpleLog *log, Purp
log = purple_log_new(PURPLE_TYPE_OLD_LOG, PURPLE_LOG_IM,
sn, account, NULL, idx_time, NULL);
- purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
+ purple_common_log_set_path(PURPLE_COMMON_LOG(log),
+ g_file_get_path(file));
purple_common_log_set_offset(PURPLE_COMMON_LOG(log),
lastoff);
purple_common_log_set_length(PURPLE_COMMON_LOG(log),
@@ -272,7 +273,8 @@ purple_old_log_list(PurpleLog *log, Purp
PurpleLog *log = purple_log_new(PURPLE_TYPE_OLD_LOG,
PURPLE_LOG_IM, sn, account, NULL, lasttime, NULL);
- purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
+ purple_common_log_set_path(PURPLE_COMMON_LOG(log),
+ g_file_get_path(file));
purple_common_log_set_offset(PURPLE_COMMON_LOG(log),
lastoff);
purple_common_log_set_length(PURPLE_COMMON_LOG(log),
@@ -332,7 +334,8 @@ purple_old_log_list(PurpleLog *log, Purp
PurpleLog *log = purple_log_new(PURPLE_TYPE_OLD_LOG, PURPLE_LOG_IM,
sn, account, NULL, lasttime, NULL);
- purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
+ purple_common_log_set_path(PURPLE_COMMON_LOG(log),
+ g_file_get_path(file));
purple_common_log_set_offset(PURPLE_COMMON_LOG(log), lastoff);
purple_common_log_set_length(PURPLE_COMMON_LOG(log), newlen);
@@ -421,11 +424,14 @@ purple_old_log_read(PurpleLog *log, Purp
GFile *file;
GFileInputStream *file_stream;
GInputStream *stream;
+ const gchar *path;
gchar *read;
gssize length, offset, result;
- file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
+ file = g_file_new_for_path(path);
file_stream = g_file_read(file, cancellable, error);
+ g_object_unref(file);
if (file_stream == NULL)
return NULL;
============================================================
--- libpurple/txtlog.c 92f09c5d2985e480f688b345afcc9c8dd0b10f66
+++ libpurple/txtlog.c b690ad0b19aec67a60cc6dfd930ef45dffa541c5
@@ -64,7 +64,7 @@ purple_txt_log_create(PurpleLog *log, GC
static gboolean
purple_txt_log_create(PurpleLog *log, GCancellable *cancellable, GError **error)
{
- return purple_log_common_writer(log, ".txt", cancellable, error);
+ return purple_log_common_create(log, ".txt", cancellable, error);
}
static gssize
@@ -77,6 +77,7 @@ purple_txt_log_write(PurpleLog *log, Pur
GFile *file;
GFileOutputStream *stream;
GOutputStream *out_stream;
+ const gchar *path;
gchar *stripped = NULL, *date, *line;
gsize written, size = 0;
gboolean success, write_header;
@@ -90,9 +91,9 @@ purple_txt_log_write(PurpleLog *log, Pur
return -1;
}
- file = purple_common_log_get_file(common_log);
+ path = purple_common_log_get_path(common_log);
- if (file == NULL) {
+ if (path == NULL) {
/* This log is new. We could use the loggers 'new' function, but
* 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.
@@ -101,13 +102,13 @@ purple_txt_log_write(PurpleLog *log, Pur
if (!purple_txt_log_create(log, cancellable, error))
return -1;
- file = purple_common_log_get_file(common_log);
+ path = purple_common_log_get_path(common_log);
write_header = TRUE;
} else
write_header = FALSE;
/* If we can't write to the file, give up before we hurt ourselves */
- if (file == NULL) {
+ if (path == NULL) {
g_set_error_literal(error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
@@ -116,7 +117,9 @@ purple_txt_log_write(PurpleLog *log, Pur
return -1;
}
+ file = g_file_new_for_path(path);
stream = g_file_append_to(file, G_FILE_CREATE_NONE, cancellable, error);
+ g_object_unref(file);
if (stream == NULL)
return -1;
@@ -207,7 +210,7 @@ purple_txt_log_list(PurpleLog *log, Purp
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",
+ return purple_log_common_list(type, sn, account, ".txt",
PURPLE_TYPE_TXT_LOG, cancellable, error);
}
@@ -215,7 +218,7 @@ purple_txt_log_list_syslog(PurpleLog *lo
purple_txt_log_list_syslog(PurpleLog *log, PurpleAccount *account,
GCancellable *cancellable, GError **error)
{
- return purple_log_common_lister(PURPLE_LOG_SYSTEM, ".system", account,
+ return purple_log_common_list(PURPLE_LOG_SYSTEM, ".system", account,
".txt", PURPLE_TYPE_TXT_LOG, cancellable, error);
}
@@ -225,14 +228,16 @@ purple_txt_log_read(PurpleLog *log, Purp
{
PurpleCommonLog *common_log = PURPLE_COMMON_LOG(log);
GFile *file;
+ const gchar *path;
gchar *read, *minus_header;
+ gboolean result;
if (flags != NULL)
*flags = 0;
- file = purple_common_log_get_file(common_log);
+ path = purple_common_log_get_path(common_log);
- if (file == NULL) {
+ if (path == NULL) {
g_set_error_literal(error,
G_FILE_ERROR,
G_IO_ERROR_NOT_FOUND,
@@ -241,7 +246,11 @@ purple_txt_log_read(PurpleLog *log, Purp
return NULL;
}
- if (!g_file_load_contents(file, cancellable, &read, NULL, NULL, error))
+ file = g_file_new_for_path(path);
+ result = g_file_load_contents(file, cancellable, &read, NULL, NULL, error);
+ g_object_unref(file);
+
+ if (!result)
return NULL;
purple_str_strip_char(read, '\r');
@@ -258,7 +267,7 @@ purple_txt_log_total_size(PurpleLog *log
const gchar *name, PurpleAccount *account, GCancellable *cancellable,
GError **error)
{
- return purple_log_common_total_sizer(type, name, account, ".txt",
+ return purple_log_common_total_size(type, name, account, ".txt",
cancellable, error);
}
More information about the Commits
mailing list