cpw.nader.asynclogging-3: 2e217460: Renamed all purple_log_common_* to purpl...
morshed.nader at gmail.com
morshed.nader at gmail.com
Tue Jan 3 05:00:48 EST 2012
----------------------------------------------------------------------
Revision: 2e2174601c1907619e975758861eb6fc7d6cfb57
Parent: e967351b0a13202f1ba310d524d8d01cadf5ac63
Author: morshed.nader at gmail.com
Date: 01/03/12 04:55:11
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/2e2174601c1907619e975758861eb6fc7d6cfb57
Changelog:
Renamed all purple_log_common_* to purple_common_log_* (Was inconsistent before)
Cleared up commonlog.c of all references to threads
Added read and read_async to commonlog
Removed purple_log_real_read_finish from log.c as no other files had access to the internal structure required
Changes against parent e967351b0a13202f1ba310d524d8d01cadf5ac63
patched libpurple/commonlog.c
patched libpurple/commonlog.h
patched libpurple/log.c
patched libpurple/txtlog.c
-------------- next part --------------
============================================================
--- libpurple/log.c 62e02e05dad71da04f2ee11b3953145f5ebd6a60
+++ libpurple/log.c 1571b9f7d76e188aeb558770ec49645073607bbc
@@ -90,11 +90,6 @@ typedef struct {
} _purple_logsize_user;
typedef struct {
- PurpleLogReadFlags flags;
- gchar *text;
-} _purple_log_read_res_callback_data;
-
-typedef struct {
GAsyncReadyCallback cb;
gpointer userdata;
guint counter;
@@ -130,21 +125,14 @@ typedef struct {
guint counter;
} _purple_log_sets_callback_data;
-static gchar *purple_log_real_read_finish(PurpleLog *, GAsyncResult *,
- PurpleLogReadFlags *, GError **);
-
static gssize purple_log_real_size_finish(PurpleLog *, GAsyncResult *,
GError **);
-
static GList *purple_log_real_list_logs_finish(PurpleLog *, GAsyncResult *,
GError **);
-
static GList *purple_log_real_list_syslog_finish(PurpleLog *, GAsyncResult *,
GError **);
-
static gssize purple_log_real_total_size_finish(PurpleLog *, GAsyncResult *,
GError **);
-
static GHashTable *purple_log_real_get_log_sets_finish(PurpleLog *,
GAsyncResult *, GError **);
@@ -250,7 +238,6 @@ purple_log_class_init(PurpleLogClass *cl
class->logger_name = "";
class->logger_id = "";
- class->read_finish = purple_log_real_read_finish;
class->size_finish = purple_log_real_size_finish;
class->total_size_finish = purple_log_real_total_size_finish;
class->list_finish = purple_log_real_list_logs_finish;
@@ -681,11 +668,12 @@ purple_log_read_async(PurpleLog *log, gi
io_priority, cancellable, cb, userdata);
}
+#if 0
static gchar *
purple_log_real_read_finish(PurpleLog *log, GAsyncResult *res,
PurpleLogReadFlags *flags, GError **error)
{
- _purple_log_read_res_callback_data *res_data;
+ read_res_callback_data *res_data;
GSimpleAsyncResult *simple;
simple = G_SIMPLE_ASYNC_RESULT(res);
@@ -696,6 +684,7 @@ purple_log_real_read_finish(PurpleLog *l
return res_data->text;
}
+#endif
gchar *
purple_log_read_finish(PurpleLog *log, GAsyncResult *res,
============================================================
--- libpurple/txtlog.c b690ad0b19aec67a60cc6dfd930ef45dffa541c5
+++ libpurple/txtlog.c 636b875d61ef75f5dc7b96711860cfb9f31ddac6
@@ -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_create(log, ".txt", cancellable, error);
+ return purple_common_log_create(log, ".txt", cancellable, error);
}
static gssize
@@ -210,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_list(type, sn, account, ".txt",
+ return purple_common_log_list(type, sn, account, ".txt",
PURPLE_TYPE_TXT_LOG, cancellable, error);
}
@@ -218,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_list(PURPLE_LOG_SYSTEM, ".system", account,
+ return purple_common_log_list(PURPLE_LOG_SYSTEM, ".system", account,
".txt", PURPLE_TYPE_TXT_LOG, cancellable, error);
}
@@ -267,7 +267,7 @@ purple_txt_log_total_size(PurpleLog *log
const gchar *name, PurpleAccount *account, GCancellable *cancellable,
GError **error)
{
- return purple_log_common_total_size(type, name, account, ".txt",
+ return purple_common_log_total_size(type, name, account, ".txt",
cancellable, error);
}
============================================================
--- libpurple/commonlog.c c45e29d47b6e34e6bf88ed98c5587a24fce164e3
+++ libpurple/commonlog.c d10fbd0b2483725a7f9e683ccb166ae46d65b88f
@@ -101,14 +101,6 @@ typedef struct {
};
typedef struct {
- PurpleAccount *account;
- PurpleLogChatType chat_type;
- GType log_type;
- gchar *name;
- gchar *ext;
-} _common_thread_callback_data;
-
-typedef struct {
PurpleCommonLog *log;
GCancellable *cancel;
GAsyncReadyCallback cb;
@@ -117,6 +109,16 @@ typedef struct {
} create_callback_data;
typedef struct {
+ PurpleLog *log;
+ GCancellable *cancel;
+ GAsyncReadyCallback cb;
+ gpointer userdata;
+ gchar *contents;
+ gsize size;
+ gsize allocated;
+} read_callback_data;
+
+typedef struct {
PurpleLogChatType chat_type;
gchar *name;
PurpleAccount *account;
@@ -143,16 +145,18 @@ typedef struct {
/* Prototypes */
-static gboolean purple_log_common_remove(PurpleLog *, GCancellable *,
+static gboolean purple_common_log_remove(PurpleLog *, GCancellable *,
GError **);
-static gssize purple_log_common_size(PurpleLog *, GCancellable *, GError **);
-static gboolean purple_log_common_create_async_2(gpointer);
-static void purple_log_common_list_async_2(GObject *, GAsyncResult *, gpointer);
-static void purple_log_common_list_async_3(GObject *, GAsyncResult *, gpointer);
-static void purple_log_common_list_async_4(GObject *, GAsyncResult *, gpointer);
-static void purple_log_common_total_size_async_2(GObject *, GAsyncResult *, gpointer);
-static void purple_log_common_total_size_async_3(GObject *, GAsyncResult *, gpointer);
-static void purple_log_common_total_size_async_4(GObject *, GAsyncResult *, gpointer);
+static gssize purple_common_log_size(PurpleLog *, GCancellable *, GError **);
+static gboolean purple_common_log_create_async_2(gpointer);
+static gboolean purple_common_log_read_async_2(GIOChannel *, GIOCondition,
+ gpointer);
+static void purple_common_log_list_async_2(GObject *, GAsyncResult *, gpointer);
+static void purple_common_log_list_async_3(GObject *, GAsyncResult *, gpointer);
+static void purple_common_log_list_async_4(GObject *, GAsyncResult *, gpointer);
+static void purple_common_log_total_size_async_2(GObject *, GAsyncResult *, gpointer);
+static void purple_common_log_total_size_async_3(GObject *, GAsyncResult *, gpointer);
+static void purple_common_log_total_size_async_4(GObject *, GAsyncResult *, gpointer);
/* Main functions */
@@ -160,6 +164,7 @@ create_callback_data_free(gpointer userd
create_callback_data_free(gpointer userdata)
{
create_callback_data *data = userdata;
+
g_object_unref(data->log);
g_object_unref(data->cancel);
g_free(data->path);
@@ -167,9 +172,30 @@ static void
}
static void
+read_callback_data_free(gpointer userdata)
+{
+ read_callback_data *data = userdata;
+
+ g_object_unref(data->log);
+ g_object_unref(data->cancel);
+ g_free(data->contents);
+ g_free(data);
+};
+
+void
+_read_res_callback_data_free(gpointer userdata)
+{
+ _read_res_callback_data *data = userdata;
+
+ g_free(data->text);
+ g_free(data);
+};
+
+static void
list_callback_data_free(gpointer userdata)
{
list_callback_data *data = userdata;
+
g_free(data->name);
g_free(data->ext);
g_object_unref(data->cancel);
@@ -180,6 +206,7 @@ total_size_callback_data_free(gpointer u
total_size_callback_data_free(gpointer userdata)
{
total_size_callback_data *data = userdata;
+
g_free(data->name);
g_free(data->ext);
g_object_unref(data->cancel);
@@ -199,8 +226,9 @@ purple_common_log_class_init(PurpleCommo
log_class->logger_name = _("Common Logger");
log_class->logger_id = "common";
- log_class->remove_fn = purple_log_common_remove;
- log_class->size_fn = purple_log_common_size;
+ log_class->read_finish = purple_common_log_read_finish;
+ log_class->remove_fn = purple_common_log_remove;
+ log_class->size_fn = purple_common_log_size;
properties[PROP_COMMON_LOG_PATH] =
g_param_spec_string("path",
@@ -406,7 +434,7 @@ static gboolean
}
static gboolean
-purple_log_common_remove(PurpleLog *log, GCancellable *cancellable,
+purple_common_log_remove(PurpleLog *log, GCancellable *cancellable,
GError **error)
{
const gchar *path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
@@ -455,7 +483,7 @@ gboolean
}
gboolean
-purple_log_common_create(PurpleLog *log, const gchar *ext,
+purple_common_log_create(PurpleLog *log, const gchar *ext,
GCancellable *cancellable, GError **error)
{
PurpleConversation *conv;
@@ -529,7 +557,7 @@ void
}
void
-purple_log_common_create_async(PurpleLog *log, const gchar *ext,
+purple_common_log_create_async(PurpleLog *log, const gchar *ext,
gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
gpointer userdata)
{
@@ -574,16 +602,16 @@ purple_log_common_create_async(PurpleLog
callback_data->userdata = userdata;
callback_data->path = new_path;
- g_idle_add_full(io_priority, purple_log_common_create_async_2,
+ g_idle_add_full(io_priority, purple_common_log_create_async_2,
callback_data, create_callback_data_free);
} else
SIMPLE_ASYNC_RESULT_NEW_GOOD(log, cb, userdata,
- purple_log_common_create_async,
+ purple_common_log_create_async,
g_simple_async_result_set_op_res_gboolean(simple, TRUE));
}
static gboolean
-purple_log_common_create_async_2(gpointer userdata)
+purple_common_log_create_async_2(gpointer userdata)
{
/* Loop creation until we stop getting EWOULDBLOCK */
GError *err = NULL;
@@ -617,14 +645,14 @@ purple_log_common_create_async_2(gpointe
purple_common_log_set_path(callback_data->log, callback_data->path);
SIMPLE_ASYNC_RESULT_NEW_GOOD(callback_data->log, callback_data->cb,
- callback_data->userdata, purple_log_common_create_async,
+ callback_data->userdata, purple_common_log_create_async,
g_simple_async_result_set_op_res_gboolean(simple, TRUE));
return FALSE;
}
gboolean
-purple_log_common_create_finish(PurpleLog *log, GAsyncResult *res,
+purple_common_log_create_finish(PurpleLog *log, GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple;
@@ -640,6 +668,164 @@ purple_log_common_create_finish(PurpleLo
return g_simple_async_result_get_op_res_gboolean(G_SIMPLE_ASYNC_RESULT(res));
}
+gchar *
+purple_common_log_read(PurpleLog *log, PurpleLogReadFlags *flags,
+ GCancellable *cancellable, GError **error)
+{
+ const gchar *path;
+ gchar *contents;
+ gboolean result;
+
+ if (flags != NULL)
+ *flags = 0;
+
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
+ result = g_file_get_contents(path, &contents, NULL, error);
+
+ if (result)
+ return contents;
+ else
+ return NULL;
+}
+
+void
+purple_common_log_read_async(PurpleLog *log, gint io_priority,
+ GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
+{
+ GError *err = NULL;
+ GIOChannel *chan;
+ const gchar *path;
+ read_callback_data *data;
+
+ path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
+ chan = g_io_channel_new_file(path, "r", &err);
+
+ if (chan == NULL) {
+ SIMPLE_ASYNC_RESULT_FROM_ERROR(log, cb, userdata, err);
+ return;
+ }
+
+ data = g_new(read_callback_data, 1);
+ data->log = g_object_ref(log);
+ data->cancel = cancellable;
+ data->cb = cb;
+ data->userdata = userdata;
+ data->contents = NULL;
+ data->size = 0;
+ data->allocated = 0;
+
+ g_io_add_watch_full(chan, io_priority,
+ G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR,
+ purple_common_log_read_async_2, data, read_callback_data_free);
+
+ g_io_channel_unref(chan);
+}
+
+static gboolean
+purple_common_log_read_async_2(GIOChannel *chan, GIOCondition cond,
+ gpointer userdata)
+{
+ GError *err = NULL;
+ GIOStatus status;
+ gchar buffer[4096], *tmp;
+ gsize bytes;
+ read_callback_data *data = userdata;
+ _read_res_callback_data *res_data;
+
+ if (g_cancellable_set_error_if_cancelled(data->cancel, &err)) {
+ SIMPLE_ASYNC_RESULT_FROM_ERROR(data->log, data->cb, data->userdata, err);
+ return FALSE;
+ }
+
+ status = g_io_channel_read_chars(chan, buffer, sizeof(buffer), &bytes, &err);
+
+ switch (status) {
+ case G_IO_STATUS_NORMAL:
+ if (data->size + bytes < data->size) {
+ SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR(data->log, data->cb,
+ data->userdata,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ _("Log file is too large to read"));
+
+ return FALSE;
+ }
+
+ while (data->size + bytes + 1 > data->allocated)
+ if (data->allocated == 0)
+ data->allocated = bytes + 1;
+ else
+ data->allocated *= 2;
+
+ tmp = g_try_realloc(data->contents, data->allocated);
+
+ if (tmp == NULL) {
+ SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR(data->log, data->cb,
+ data->userdata,
+ G_IO_ERROR,
+ g_file_error_from_errno(errno),
+ g_strerror(errno));
+
+ return FALSE;
+ }
+
+ memcpy(data->contents + data->size, buffer, bytes);
+ data->size += bytes;
+
+ return TRUE;
+
+ case G_IO_STATUS_EOF:
+ if (data->size == 0)
+ data->contents = g_new(gchar, 1);
+
+ data->contents[data->size] = '\0';
+
+ res_data = g_new(_read_res_callback_data, 1);
+ res_data->flags = 0;
+ res_data->text = data->contents;
+ /* Don't want this getting freed by read_callback_data_free() */
+ data->contents = NULL;
+
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(data->log, data->cb, data->userdata,
+ purple_common_log_read_async,
+ g_simple_async_result_set_op_res_gpointer(simple, res_data,
+ _read_res_callback_data_free));
+
+ return FALSE;
+
+ case G_IO_STATUS_AGAIN:
+ return TRUE;
+
+ case G_IO_STATUS_ERROR:
+ default:
+ SIMPLE_ASYNC_RESULT_FROM_ERROR(data->log, data->cb, data->userdata, err);
+ return FALSE;
+ }
+}
+
+gchar *
+purple_common_log_read_finish(PurpleLog *log, GAsyncResult *res,
+ PurpleLogReadFlags *flags, GError **error)
+{
+ GSimpleAsyncResult *simple;
+ _read_res_callback_data *res_data;
+
+ g_return_val_if_fail(PURPLE_IS_COMMON_LOG(log), NULL);
+
+ simple = G_SIMPLE_ASYNC_RESULT(res);
+
+ if (g_simple_async_result_propagate_error(simple, error))
+ return NULL;
+
+ res_data = g_simple_async_result_get_op_res_gpointer(simple);
+
+ if (flags != NULL)
+ *flags = res_data->flags;
+
+ return res_data->text;
+}
+
+/* XXX: Poorly named */
static PurpleLog *
create_log(const gchar *dir, const gchar *filename, PurpleLogChatType chat_type,
const gchar *name, PurpleAccount *account, GType log_type)
@@ -690,7 +876,7 @@ GList *
}
GList *
-purple_log_common_list(PurpleLogChatType chat_type, const gchar *name,
+purple_common_log_list(PurpleLogChatType chat_type, const gchar *name,
PurpleAccount *account, const gchar *ext, GType log_type,
GCancellable *cancellable, GError **error)
{
@@ -758,7 +944,7 @@ void
}
void
-purple_log_common_list_async(PurpleLogChatType chat_type, const gchar *name,
+purple_common_log_list_async(PurpleLogChatType chat_type, const gchar *name,
PurpleAccount *account, const gchar *ext, GType log_type, gint io_priority,
GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata)
{
@@ -782,14 +968,14 @@ purple_log_common_list_async(PurpleLogCh
g_file_enumerate_children_async(dir, G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE, io_priority, cancellable,
- purple_log_common_list_async_2, data);
+ purple_common_log_list_async_2, data);
g_free(path);
g_object_unref(dir);
}
static void
-purple_log_common_list_async_2(GObject *object, GAsyncResult *res,
+purple_common_log_list_async_2(GObject *object, GAsyncResult *res,
gpointer userdata)
{
GError *err = NULL;
@@ -807,11 +993,11 @@ purple_log_common_list_async_2(GObject *
}
g_file_enumerator_next_files_async(enumerator, 20, data->io_priority,
- data->cancel, purple_log_common_list_async_3, data);
+ data->cancel, purple_common_log_list_async_3, data);
}
static void
-purple_log_common_list_async_3(GObject *object, GAsyncResult *res,
+purple_common_log_list_async_3(GObject *object, GAsyncResult *res,
gpointer userdata)
{
GError *err = NULL;
@@ -834,7 +1020,7 @@ purple_log_common_list_async_3(GObject *
/* Out of files! Close shop */
g_file_enumerator_close_async(enumerator, data->io_priority,
- data->cancel, purple_log_common_list_async_4, data);
+ data->cancel, purple_common_log_list_async_4, data);
}
dir = g_file_get_path(g_file_enumerator_get_container(enumerator));
@@ -860,11 +1046,11 @@ purple_log_common_list_async_3(GObject *
g_list_free(files);
g_file_enumerator_next_files_async(enumerator, 20, data->io_priority,
- data->cancel, purple_log_common_list_async_3, data);
+ data->cancel, purple_common_log_list_async_3, data);
}
static void
-purple_log_common_list_async_4(GObject *object, GAsyncResult *res,
+purple_common_log_list_async_4(GObject *object, GAsyncResult *res,
gpointer userdata)
{
GError *err = NULL;
@@ -881,7 +1067,7 @@ purple_log_common_list_async_4(GObject *
purple_log_list_free(data->logs);
} else
SIMPLE_ASYNC_RESULT_NEW_GOOD(enumerator, data->cb, data->userdata,
- purple_log_common_list_async,
+ purple_common_log_list_async,
g_simple_async_result_set_op_res_gpointer(simple, data->logs,
(GDestroyNotify) purple_log_list_free));
@@ -889,7 +1075,7 @@ GList *
}
GList *
-purple_log_common_list_finish(GAsyncResult *res, GError **error)
+purple_common_log_list_finish(GAsyncResult *res, GError **error)
{
GSimpleAsyncResult *simple;
@@ -899,7 +1085,7 @@ purple_log_common_list_finish(GAsyncResu
return NULL;
g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) ==
- purple_log_common_list_async,
+ purple_common_log_list_async,
NULL);
return g_simple_async_result_get_op_res_gpointer(simple);
@@ -911,7 +1097,7 @@ gssize
* TODO: once? This may be possible with the non-blocking stuff...
*/
gssize
-purple_log_common_total_size(PurpleLogChatType chat_type, const gchar *name,
+purple_common_log_total_size(PurpleLogChatType chat_type, const gchar *name,
PurpleAccount *account, const gchar *ext, GCancellable *cancellable,
GError **error)
{
@@ -1000,7 +1186,7 @@ void
}
void
-purple_log_common_total_size_async(PurpleLogChatType chat_type,
+purple_common_log_total_size_async(PurpleLogChatType chat_type,
const gchar *name, PurpleAccount *account, const gchar *ext,
gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
gpointer userdata)
@@ -1025,14 +1211,14 @@ purple_log_common_total_size_async(Purpl
g_file_enumerate_children_async(dir, G_FILE_ATTRIBUTE_STANDARD_SIZE,
G_FILE_QUERY_INFO_NONE, io_priority, cancellable,
- purple_log_common_total_size_async_2, data);
+ purple_common_log_total_size_async_2, data);
g_free(path);
g_object_unref(dir);
}
static void
-purple_log_common_total_size_async_2(GObject *object, GAsyncResult *res,
+purple_common_log_total_size_async_2(GObject *object, GAsyncResult *res,
gpointer userdata)
{
GError *err = NULL;
@@ -1050,11 +1236,11 @@ purple_log_common_total_size_async_2(GOb
}
g_file_enumerator_next_files_async(enumerator, 20, data->io_priority,
- data->cancel, purple_log_common_total_size_async_3, data);
+ data->cancel, purple_common_log_total_size_async_3, data);
}
static void
-purple_log_common_total_size_async_3(GObject *object, GAsyncResult *res,
+purple_common_log_total_size_async_3(GObject *object, GAsyncResult *res,
gpointer userdata)
{
GError *err = NULL;
@@ -1075,7 +1261,7 @@ purple_log_common_total_size_async_3(GOb
/* Out of files! Close shop */
g_file_enumerator_close_async(enumerator, data->io_priority,
- data->cancel, purple_log_common_total_size_async_4, data);
+ data->cancel, purple_common_log_total_size_async_4, data);
}
for (file = files; file != NULL; file = file->next) {
@@ -1099,11 +1285,11 @@ purple_log_common_total_size_async_3(GOb
g_list_free(files);
g_file_enumerator_next_files_async(enumerator, 20, data->io_priority,
- data->cancel, purple_log_common_total_size_async_3, data);
+ data->cancel, purple_common_log_total_size_async_3, data);
}
static void
-purple_log_common_total_size_async_4(GObject *object, GAsyncResult *res,
+purple_common_log_total_size_async_4(GObject *object, GAsyncResult *res,
gpointer userdata)
{
GError *err = NULL;
@@ -1118,14 +1304,14 @@ purple_log_common_total_size_async_4(GOb
err);
} else
SIMPLE_ASYNC_RESULT_NEW_GOOD(enumerator, data->cb, data->userdata,
- purple_log_common_list_async,
+ purple_common_log_list_async,
g_simple_async_result_set_op_res_gssize(simple, data->total));
total_size_callback_data_free(data);
}
gssize
-purple_log_common_total_size_finish(GAsyncResult *res, GError **error)
+purple_common_log_total_size_finish(GAsyncResult *res, GError **error)
{
GSimpleAsyncResult *simple;
@@ -1135,14 +1321,14 @@ purple_log_common_total_size_finish(GAsy
return -1;
g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) ==
- purple_log_common_total_size_async,
+ purple_common_log_total_size_async,
-1);
return g_simple_async_result_get_op_res_gssize(simple);
}
static gssize
-purple_log_common_size(PurpleLog *log, GCancellable *cancellable,
+purple_common_log_size(PurpleLog *log, GCancellable *cancellable,
GError **error)
{
PurpleCommonLog *common_log = PURPLE_COMMON_LOG(log);
============================================================
--- libpurple/commonlog.h a6741ced2f8f65f70d3296778540c065c0f77630
+++ libpurple/commonlog.h 85004b453fd72a95b01a140e99fd26f73b3d5c91
@@ -57,7 +57,15 @@ struct _PurpleCommonLogClass {
void (*_purple_reserved4)(void);
};
+/* XXX: Proper location for these? */
+typedef struct {
+ gchar *text;
+ PurpleLogReadFlags flags;
+} _read_res_callback_data;
+void _read_res_callback_data_free(gpointer userdata);
+/* XXX */
+
GType purple_common_log_get_type(void);
/******************************************/
@@ -169,13 +177,13 @@ gssize purple_common_log_get_length(Purp
* @param cancellable (allow-none): GCancellable object
* @param error (out) (allow-none): a GError location to store the error
*/
-gboolean purple_log_common_create(PurpleLog *log, const gchar *ext,
+gboolean purple_common_log_create(PurpleLog *log, const gchar *ext,
GCancellable *cancellable, GError **error);
/**
* Asynchronously create a new log in the standard log location
*
- * For more details, see purple_log_common_create() which is
+ * For more details, see purple_common_log_create() which is
* the synchronous version of this call.
*
* @param log The log to write to
@@ -187,13 +195,13 @@ gboolean purple_log_common_create(Purple
*
* @since 3.0.0
*/
-void purple_log_common_create_async(PurpleLog *log, const gchar *ext,
+void purple_common_log_create_async(PurpleLog *log, const gchar *ext,
gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
gpointer userdata);
/**
* Finishes asyncronously creating a new log in the standard log location
- * See purple_log_common_create() for more details.
+ * See purple_common_log_create() for more details.
*
* @param log The log to write to
* @param res A GAsyncResult
@@ -203,14 +211,21 @@ void purple_log_common_create_async(Purp
*
* @since 3.0.0
*/
-gboolean purple_log_common_create_finish(PurpleLog *log, GAsyncResult *res,
+gboolean purple_common_log_create_finish(PurpleLog *log, GAsyncResult *res,
GError **error);
+gchar *purple_common_log_read(PurpleLog *log, PurpleLogReadFlags *flags,
+ GCancellable *cancellable, GError **error);
+void purple_common_log_read_async(PurpleLog *log, gint io_priority,
+ GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata);
+gchar *purple_common_log_read_finish(PurpleLog *log, GAsyncResult *res,
+ PurpleLogReadFlags *flags, GError **error);
+
/**
* Returns a sorted list of logs of the requested type
*
* This function should only be used with logs that are written
- * with purple_log_common_writer(). It's intended to be used as
+ * with purple_common_log_writer(). It's intended to be used as
* a "common" implementation of a logger's @c list function.
* It should only be passed to purple_log_logger_new() and never
* called directly.
@@ -226,13 +241,13 @@ gboolean purple_log_common_create_finish
*
* @return The sorted list of logs matching the parameters
*/
-GList *purple_log_common_list(PurpleLogChatType chat_type, const gchar *name,
+GList *purple_common_log_list(PurpleLogChatType chat_type, const gchar *name,
PurpleAccount *account, const gchar *ext, GType log_type,
GCancellable *cancellable, GError **error);
/**
* Asynchronously gets a sorted list of log of the requested type.
- * See purple_log_common_list() for more details.
+ * See purple_common_log_list() for more details.
*
* @param type The type of the logs being listed
* @param name The name of the log
@@ -248,7 +263,7 @@ GList *purple_log_common_list(PurpleLogC
*
* @since 3.0.0
*/
-void purple_log_common_list_async(PurpleLogChatType type, const gchar *name,
+void purple_common_log_list_async(PurpleLogChatType type, const gchar *name,
PurpleAccount *account, const gchar *ext, GType log_type, gint io_priority,
GCancellable *cancellable, GAsyncReadyCallback cb, gpointer userdata);
@@ -266,14 +281,14 @@ void purple_log_common_list_async(Purple
*
* @since 3.0.0
*/
-GList *purple_log_common_list_finish(GAsyncResult *res, GError **error);
+GList *purple_common_log_list_finish(GAsyncResult *res, GError **error);
/**
* Returns the total size of all the logs for a given user, with
* a given extension.
*
* This function should only be used with logs that are written
- * with purple_log_common_writer(). It's intended to be used as
+ * with purple_common_log_writer(). It's intended to be used as
* a "common" implementation of a logger's @c total_size function.
* It should only be passed to purple_log_logger_new() and never
* called directly.
@@ -289,14 +304,14 @@ GList *purple_log_common_list_finish(GAs
* @return The size of all the logs with the specified extension
* for the specified user
*/
-gssize purple_log_common_total_size(PurpleLogChatType chat_type,
+gssize purple_common_log_total_size(PurpleLogChatType chat_type,
const gchar *name, PurpleAccount *account, const gchar *ext,
GCancellable *cancellable, GError **error);
/**
* Asychronously gets the total size of all the logs for a given user, with
* a given extension.
- * See purple_log_common_total_size() for more details.
+ * See purple_common_log_total_size() for more details.
*
* @param chat_type The type of the logs being sized
* @param name The name of the logs to size (e.g. the username or chat name)
@@ -310,7 +325,7 @@ gssize purple_log_common_total_size(Purp
*
* @since 3.0.0
*/
-void purple_log_common_total_size_async(PurpleLogChatType chat_type,
+void purple_common_log_total_size_async(PurpleLogChatType chat_type,
const gchar *name, PurpleAccount *account, const gchar *ext,
gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
gpointer userdata);
@@ -325,7 +340,7 @@ void purple_log_common_total_size_async(
*
* @since 3.0.0
*/
-gssize purple_log_common_total_size_finish(GAsyncResult *res, GError **error);
+gssize purple_common_log_total_size_finish(GAsyncResult *res, GError **error);
/*@}*/
More information about the Commits
mailing list