telepathy-logger: Add TplLogIterPidgin skeleton

Nicolas Dufresne nicolasd at kemper.freedesktop.org
Tue Aug 28 13:01:04 PDT 2012


Module: telepathy-logger
Branch: master
Commit: 2a51d5e55c69e310a29c999525b7dce751a1012c
URL:    http://cgit.freedesktop.org/telepathy/telepathy-logger/commit/?id=2a51d5e55c69e310a29c999525b7dce751a1012c

Author: Debarshi Ray <debarshir at freedesktop.org>
Date:   Tue Jul  3 10:31:44 2012 +0200

Add TplLogIterPidgin skeleton

Fixes: https://bugs.freedesktop.org/41772

---

 telepathy-logger/Makefile.am                |    2 +
 telepathy-logger/log-iter-pidgin-internal.h |   81 +++++++++
 telepathy-logger/log-iter-pidgin.c          |  238 +++++++++++++++++++++++++++
 3 files changed, 321 insertions(+), 0 deletions(-)

diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am
index 1cb37d6..b875d70 100644
--- a/telepathy-logger/Makefile.am
+++ b/telepathy-logger/Makefile.am
@@ -69,6 +69,8 @@ libtelepathy_logger_la_SOURCES = \
 		event-internal.h		\
 		log-iter.c			\
 		log-iter-internal.h		\
+		log-iter-pidgin.c		\
+		log-iter-pidgin-internal.h	\
 		log-iter-xml.c			\
 		log-iter-xml-internal.h		\
 		log-manager.c			\
diff --git a/telepathy-logger/log-iter-pidgin-internal.h b/telepathy-logger/log-iter-pidgin-internal.h
new file mode 100644
index 0000000..89777bc
--- /dev/null
+++ b/telepathy-logger/log-iter-pidgin-internal.h
@@ -0,0 +1,81 @@
+/*
+ * 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 at freedesktop.org>
+ */
+
+#ifndef __TPL_LOG_ITER_PIDGIN_H__
+#define __TPL_LOG_ITER_PIDGIN_H__
+
+#include <telepathy-glib/telepathy-glib.h>
+
+#include <telepathy-logger/entity.h>
+#include <telepathy-logger/log-iter-internal.h>
+#include <telepathy-logger/log-manager.h>
+#include <telepathy-logger/log-store-internal.h>
+
+G_BEGIN_DECLS
+
+#define TPL_TYPE_LOG_ITER_PIDGIN (tpl_log_iter_pidgin_get_type ())
+
+#define TPL_LOG_ITER_PIDGIN(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   TPL_TYPE_LOG_ITER_PIDGIN, TplLogIterPidgin))
+
+#define TPL_LOG_ITER_PIDGIN_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   TPL_TYPE_LOG_ITER_PIDGIN, TplLogIterPidginClass))
+
+#define TPL_IS_LOG_ITER_PIDGIN(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   TPL_TYPE_LOG_ITER_PIDGIN))
+
+#define TPL_IS_LOG_ITER_PIDGIN_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   TPL_TYPE_LOG_ITER_PIDGIN))
+
+#define TPL_LOG_ITER_PIDGIN_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   TPL_TYPE_LOG_ITER_PIDGIN, TplLogIterPidginClass))
+
+typedef struct _TplLogIterPidgin        TplLogIterPidgin;
+typedef struct _TplLogIterPidginClass   TplLogIterPidginClass;
+typedef struct _TplLogIterPidginPriv    TplLogIterPidginPriv;
+
+struct _TplLogIterPidgin
+{
+  TplLogIter parent_instance;
+  TplLogIterPidginPriv *priv;
+};
+
+struct _TplLogIterPidginClass
+{
+  TplLogIterClass parent_class;
+};
+
+GType tpl_log_iter_pidgin_get_type (void) G_GNUC_CONST;
+
+TplLogIter *tpl_log_iter_pidgin_new (TplLogStore *store,
+    TpAccount *account,
+    TplEntity *target,
+    gint type_mask,
+    TplLogEventFilter filter,
+    gpointer filter_data);
+
+G_END_DECLS
+
+#endif /* __TPL_LOG_ITER_PIDGIN_H__ */
diff --git a/telepathy-logger/log-iter-pidgin.c b/telepathy-logger/log-iter-pidgin.c
new file mode 100644
index 0000000..bc5678e
--- /dev/null
+++ b/telepathy-logger/log-iter-pidgin.c
@@ -0,0 +1,238 @@
+/*
+ * 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 at freedesktop.org>
+ */
+
+#include "config.h"
+#include "log-iter-pidgin-internal.h"
+
+
+struct _TplLogIterPidginPriv
+{
+  TpAccount *account;
+  TplEntity *target;
+  TplLogEventFilter filter;
+  TplLogStore *store;
+  gint type_mask;
+  gpointer filter_data;
+};
+
+enum
+{
+  PROP_ACCOUNT = 1,
+  PROP_FILTER,
+  PROP_FILTER_DATA,
+  PROP_STORE,
+  PROP_TARGET,
+  PROP_TYPE_MASK
+};
+
+
+G_DEFINE_TYPE (TplLogIterPidgin, tpl_log_iter_pidgin, TPL_TYPE_LOG_ITER);
+
+
+static void
+tpl_log_iter_pidgin_dispose (GObject *object)
+{
+  TplLogIterPidginPriv *priv;
+
+  priv = TPL_LOG_ITER_PIDGIN (object)->priv;
+
+  g_clear_object (&priv->account);
+  g_clear_object (&priv->store);
+  g_clear_object (&priv->target);
+
+  G_OBJECT_CLASS (tpl_log_iter_pidgin_parent_class)->dispose (object);
+}
+
+
+static void
+tpl_log_iter_pidgin_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (tpl_log_iter_pidgin_parent_class)->finalize (object);
+}
+
+
+static void
+tpl_log_iter_pidgin_get_property (GObject *object,
+    guint param_id,
+    GValue *value,
+    GParamSpec *pspec)
+{
+  TplLogIterPidginPriv *priv;
+
+  priv = TPL_LOG_ITER_PIDGIN (object)->priv;
+
+  switch (param_id)
+    {
+    case PROP_ACCOUNT:
+      g_value_set_object (value, priv->account);
+      break;
+
+    case PROP_FILTER:
+      g_value_set_pointer (value, priv->filter);
+      break;
+
+    case PROP_FILTER_DATA:
+      g_value_set_pointer (value, priv->filter_data);
+      break;
+
+    case PROP_STORE:
+      g_value_set_object (value, priv->store);
+      break;
+
+    case PROP_TARGET:
+      g_value_set_object (value, priv->target);
+      break;
+
+    case PROP_TYPE_MASK:
+      g_value_set_int (value, priv->type_mask);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+      break;
+    }
+}
+
+
+static void
+tpl_log_iter_pidgin_set_property (GObject *object,
+    guint param_id,
+    const GValue *value,
+    GParamSpec *pspec)
+{
+  TplLogIterPidginPriv *priv;
+
+  priv = TPL_LOG_ITER_PIDGIN (object)->priv;
+
+  switch (param_id)
+    {
+    case PROP_ACCOUNT:
+      priv->account = g_value_dup_object (value);
+      break;
+
+    case PROP_FILTER:
+      priv->filter = g_value_get_pointer (value);
+      break;
+
+    case PROP_FILTER_DATA:
+      priv->filter_data = g_value_get_pointer (value);
+      break;
+
+    case PROP_STORE:
+      priv->store = g_value_dup_object (value);
+      break;
+
+    case PROP_TARGET:
+      priv->target = g_value_dup_object (value);
+      break;
+
+    case PROP_TYPE_MASK:
+      priv->type_mask = g_value_get_int (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+      break;
+    }
+}
+
+
+static void
+tpl_log_iter_pidgin_init (TplLogIterPidgin *iter)
+{
+  iter->priv = G_TYPE_INSTANCE_GET_PRIVATE (iter, TPL_TYPE_LOG_ITER_PIDGIN,
+      TplLogIterPidginPriv);
+}
+
+
+static void
+tpl_log_iter_pidgin_class_init (TplLogIterPidginClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GParamSpec *param_spec;
+
+  object_class->dispose = tpl_log_iter_pidgin_dispose;
+  object_class->finalize = tpl_log_iter_pidgin_finalize;
+  object_class->get_property = tpl_log_iter_pidgin_get_property;
+  object_class->set_property = tpl_log_iter_pidgin_set_property;
+
+  param_spec = g_param_spec_object ("account",
+      "Account",
+      "The account whose logs are to be traversed",
+      TP_TYPE_ACCOUNT,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec);
+
+  param_spec = g_param_spec_pointer ("filter",
+      "Filter",
+      "An optional filter function",
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_FILTER, param_spec);
+
+  param_spec = g_param_spec_pointer ("filter-data",
+      "Filter Data",
+      "User data to pass to the filter function",
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_FILTER_DATA, param_spec);
+
+  param_spec = g_param_spec_object ("store",
+      "Store",
+      "The storage backend from which the logs are to be retrieved",
+      TPL_TYPE_LOG_STORE,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_STORE, param_spec);
+
+  param_spec = g_param_spec_object ("target",
+      "Target",
+      "The target entity with which the account interacted",
+      TPL_TYPE_ENTITY,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_TARGET, param_spec);
+
+  param_spec = g_param_spec_int ("type-mask",
+      "Type Mask",
+      "A bitmask to filter the events to be retrieved",
+      1,
+      0xffff,
+      TPL_EVENT_MASK_ANY,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_TYPE_MASK, param_spec);
+
+  g_type_class_add_private (klass, sizeof (TplLogIterPidginPriv));
+}
+
+
+TplLogIter *
+tpl_log_iter_pidgin_new (TplLogStore *store,
+    TpAccount *account,
+    TplEntity *target,
+    gint type_mask,
+    TplLogEventFilter filter,
+    gpointer filter_data)
+{
+  return g_object_new (TPL_TYPE_LOG_ITER_PIDGIN,
+      "store", store,
+      "account", account,
+      "target", target,
+      "type-mask", type_mask,
+      "filter", filter,
+      "filter-data", filter_data,
+      NULL);
+}



More information about the telepathy-commits mailing list