aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-ft-factory.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>2009-02-05 03:06:30 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-06-01 23:46:03 +0800
commit36e014c3d2ea4bd2c863182c817e146a5e069662 (patch)
tree77656583fe6b1f333538d3bb451a5ab5cd7e47e1 /libempathy/empathy-ft-factory.c
parenteb8b217e20baaa817371266abf43f32de24bd906 (diff)
downloadgsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.tar
gsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.tar.gz
gsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.tar.bz2
gsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.tar.lz
gsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.tar.xz
gsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.tar.zst
gsoc2013-empathy-36e014c3d2ea4bd2c863182c817e146a5e069662.zip
Initial commit for EmpathyFTFactory and EmpathyFTHandler.
Diffstat (limited to 'libempathy/empathy-ft-factory.c')
-rw-r--r--libempathy/empathy-ft-factory.c147
1 files changed, 147 insertions, 0 deletions
diff --git a/libempathy/empathy-ft-factory.c b/libempathy/empathy-ft-factory.c
new file mode 100644
index 000000000..0356c32b6
--- /dev/null
+++ b/libempathy/empathy-ft-factory.c
@@ -0,0 +1,147 @@
+/*
+ * empathy-ft-factory.c - Source for EmpathyFTFactory
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * 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: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
+ */
+
+/* empathy-ft-factory.c */
+
+#include "empathy-ft-factory.h"
+#include "empathy-marshal.h"
+#include "empathy-utils.h"
+
+G_DEFINE_TYPE (EmpathyFTFactory, empathy_ft_factory, G_TYPE_OBJECT);
+
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyFTFactoryPriv)
+
+enum {
+ NEW_FT_HANDLER,
+ LAST_SIGNAL
+}
+
+typedef struct {
+ gboolean dispose_run;
+} EmpathyFTFactoryPriv;
+
+static EmpathyFTFactory *factory_singleton = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void
+do_dispose (GObject *object)
+{
+ EmpathyFTFactoryPriv *priv = GET_PRIV (object);
+
+ if (priv->dispose_run)
+ return;
+
+ priv->dispose_run = TRUE;
+
+ G_OBJECT_CLASS (empathy_ft_factory_parent_class)->dispose (object);
+}
+
+static void
+do_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (empathy_ft_factory_parent_class)->finalize (object);
+}
+
+static GObject *
+do_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *retval;
+
+ if (factory_singleton) {
+ retval = g_object_ref (factory_singleton);
+ } else {
+ retval = G_OBJECT_CLASS (empathy_ft_factory_parent_class)->constructor
+ (type, n_props, props);
+
+ factory_singleton = EMPATHY_FT_FACTORY (retval);
+ g_object_add_weak_pointer (retval, (gpointer *) &factory_singleton);
+ }
+
+ return retval;
+}
+
+static void
+empathy_ft_factory_class_init (EmpathyFTFactoryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EmpathyFTFactoryPriv));
+
+ object_class->dispose = do_dispose;
+ object_class->finalize = do_finalize;
+ object_class->constructor = do_constructor;
+
+ signals[NEW_FT_HANDLER] =
+ g_signal_new ("new-ft-handler",
+ G_TYPE_FROM_CLASS (empathy_call_factory_class),
+ G_SIGNAL_RUN_LAST, 0,
+ NULL, NULL,
+ _empathy_marshal_VOID__OBJECT_BOOLEAN,
+ G_TYPE_NONE,
+ 2, EMPATHY_TYPE_FT_HANDLER, G_TYPE_BOOLEAN);
+}
+
+static void
+empathy_ft_factory_init (EmpathyFTFactory *self)
+{
+ EmpathyFTFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ EMPATHY_TYPE_FT_FACTORY, EmpathyFTFactoryPriv);
+
+ self->priv = priv;
+}
+
+/* public methods */
+
+EmpathyFTFactory*
+empathy_ft_factory_dup_singleton (void)
+{
+ return g_object_new (EMPATHY_TYPE_FT_FACTORY, NULL);
+}
+
+void
+empathy_ft_factory_new_transfer (EmpathyFTFactory *factory,
+ EmpathyContact *contact,
+ GFile *file)
+{
+ EmpathyFTHandler *handler;
+
+ g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (G_IS_FILE (file));
+
+ handler = empathy_ft_handler_new (contact, file);
+ g_signal_emit (factory, signals[NEW_FT_HANDLER], 0, handler, TRUE);
+
+ g_object_unref (handler);
+}
+
+void
+empathy_ft_factory_claim_channel (EmpathyFTFactory *factory,
+ EmpathyDispatchOperation *operation)
+{
+ g_return_val_if_fail (EMPATHY_IS_FACTORY (factory));
+ g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation));
+
+ /* TODO */
+}
+