diff options
author | Debarshi Ray <debarshir@freedesktop.org> | 2012-06-28 12:21:00 +0200 |
---|---|---|
committer | Debarshi Ray <debarshir@freedesktop.org> | 2012-08-28 19:30:18 +0200 |
commit | cfb39d2342ecb481d56e22345cb8fae314d4d972 (patch) | |
tree | d6f447d32a2c770cbb6aa7023931ec1ac5b53c5c | |
parent | 1d40ac8960befda413819fa1863e70326425ee18 (diff) | |
download | telepathy-logger-cfb39d2342ecb481d56e22345cb8fae314d4d972.tar.gz |
Add TplLogWalker skeleton
Fixes: https://bugs.freedesktop.org/41772
-rw-r--r-- | telepathy-logger/Makefile.am | 3 | ||||
-rw-r--r-- | telepathy-logger/log-walker-internal.h | 36 | ||||
-rw-r--r-- | telepathy-logger/log-walker.c | 110 | ||||
-rw-r--r-- | telepathy-logger/log-walker.h | 69 | ||||
-rw-r--r-- | telepathy-logger/telepathy-logger.h | 1 |
5 files changed, 219 insertions, 0 deletions
diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am index efc2713..9b6cc86 100644 --- a/telepathy-logger/Makefile.am +++ b/telepathy-logger/Makefile.am @@ -33,6 +33,7 @@ LIBTPL_HEADERS = \ entity.h \ event.h \ log-manager.h \ + log-walker.h \ telepathy-logger.h \ text-event.h \ call-event.h \ @@ -80,6 +81,8 @@ libtelepathy_logger_la_SOURCES = \ log-store-pidgin-internal.h \ log-store-factory.c \ log-store-factory-internal.h \ + log-walker.c \ + log-walker-internal.h \ observer.c \ observer-internal.h \ text-channel.c \ diff --git a/telepathy-logger/log-walker-internal.h b/telepathy-logger/log-walker-internal.h new file mode 100644 index 0000000..29cc816 --- /dev/null +++ b/telepathy-logger/log-walker-internal.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2012 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Debarshi Ray <debarshir@freedesktop.org> + */ + +#ifndef __TPL_LOG_WALKER_INTERNAL_H__ +#define __TPL_LOG_WALKER_INTERNAL_H__ + +#include "log-iter-internal.h" +#include "log-walker.h" + +G_BEGIN_DECLS + +TplLogWalker *tpl_log_walker_new (void); + +void tpl_log_walker_add_iter (TplLogWalker *walker, + TplLogIter *iter); + +G_END_DECLS + +#endif /* __TPL_LOG_WALKER_INTERNAL_H__ */ diff --git a/telepathy-logger/log-walker.c b/telepathy-logger/log-walker.c new file mode 100644 index 0000000..a22b614 --- /dev/null +++ b/telepathy-logger/log-walker.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2012 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Debarshi Ray <debarshir@freedesktop.org> + */ + +#include "config.h" + +#include "log-walker.h" +#include "log-walker-internal.h" + + +/** + * SECTION:log-walker + * @title: TplLogWalker + * @short_description: Iterate over the logs + * + * The #TplLogWalker object allows the user to sequentially iterate + * over the logs. + */ + +/** + * TplLogWalker: + * + * An object used to iterate over the logs + */ + +struct _TplLogWalkerPriv +{ + GList *iters; +}; + + +G_DEFINE_TYPE (TplLogWalker, tpl_log_walker, G_TYPE_OBJECT); + + +static void +tpl_log_walker_dispose (GObject *object) +{ + TplLogWalkerPriv *priv; + + priv = TPL_LOG_WALKER (object)->priv; + + g_list_free_full (priv->iters, g_object_unref); + priv->iters = NULL; + + G_OBJECT_CLASS (tpl_log_walker_parent_class)->dispose (object); +} + + +static void +tpl_log_walker_finalize (GObject *object) +{ + G_OBJECT_CLASS (tpl_log_walker_parent_class)->finalize (object); +} + + +static void +tpl_log_walker_init (TplLogWalker *walker) +{ + walker->priv = G_TYPE_INSTANCE_GET_PRIVATE (walker, TPL_TYPE_LOG_WALKER, + TplLogWalkerPriv); +} + + +static void +tpl_log_walker_class_init (TplLogWalkerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = tpl_log_walker_dispose; + object_class->finalize = tpl_log_walker_finalize; + + g_type_class_add_private (klass, sizeof (TplLogWalkerPriv)); +} + + +TplLogWalker * +tpl_log_walker_new (void) +{ + return g_object_new (TPL_TYPE_LOG_WALKER, NULL); +} + + +void +tpl_log_walker_add_iter (TplLogWalker *walker, TplLogIter *iter) +{ + TplLogWalkerPriv *priv; + + g_return_if_fail (TPL_IS_LOG_WALKER (walker)); + g_return_if_fail (TPL_IS_LOG_ITER (iter)); + + priv = walker->priv; + + priv->iters = g_list_prepend (priv->iters, g_object_ref (iter)); +} diff --git a/telepathy-logger/log-walker.h b/telepathy-logger/log-walker.h new file mode 100644 index 0000000..e10fdca --- /dev/null +++ b/telepathy-logger/log-walker.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Debarshi Ray <debarshir@freedesktop.org> + */ + +#ifndef __TPL_LOG_WALKER_H__ +#define __TPL_LOG_WALKER_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define TPL_TYPE_LOG_WALKER (tpl_log_walker_get_type ()) + +#define TPL_LOG_WALKER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + TPL_TYPE_LOG_WALKER, TplLogWalker)) + +#define TPL_LOG_WALKER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + TPL_TYPE_LOG_WALKER, TplLogWalkerClass)) + +#define TPL_IS_LOG_WALKER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + TPL_TYPE_LOG_WALKER)) + +#define TPL_IS_LOG_WALKER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + TPL_TYPE_LOG_WALKER)) + +#define TPL_LOG_WALKER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + TPL_TYPE_LOG_WALKER, TplLogWalkerClass)) + +typedef struct _TplLogWalker TplLogWalker; +typedef struct _TplLogWalkerClass TplLogWalkerClass; +typedef struct _TplLogWalkerPriv TplLogWalkerPriv; + +struct _TplLogWalker +{ + GObject parent_instance; + TplLogWalkerPriv *priv; +}; + +struct _TplLogWalkerClass +{ + GObjectClass parent_class; +}; + +GType tpl_log_walker_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __TPL_LOG_WALKER_H__ */ diff --git a/telepathy-logger/telepathy-logger.h b/telepathy-logger/telepathy-logger.h index 7cedaa6..54d42d8 100644 --- a/telepathy-logger/telepathy-logger.h +++ b/telepathy-logger/telepathy-logger.h @@ -26,5 +26,6 @@ #include <telepathy-logger/call-event.h> #include <telepathy-logger/event.h> #include <telepathy-logger/log-manager.h> +#include <telepathy-logger/log-walker.h> #endif |