2 * empathy-ft-factory.c - Source for EmpathyFTFactory
3 * Copyright (C) 2009 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
22 /* empathy-ft-factory.c */
24 #include "empathy-ft-factory.h"
25 #include "empathy-marshal.h"
26 #include "empathy-utils.h"
28 G_DEFINE_TYPE (EmpathyFTFactory, empathy_ft_factory, G_TYPE_OBJECT);
30 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyFTFactoryPriv)
39 } EmpathyFTFactoryPriv;
41 static EmpathyFTFactory *factory_singleton = NULL;
42 static guint signals[LAST_SIGNAL] = { 0 };
45 do_dispose (GObject *object)
47 EmpathyFTFactoryPriv *priv = GET_PRIV (object);
49 if (priv->dispose_run)
52 priv->dispose_run = TRUE;
54 G_OBJECT_CLASS (empathy_ft_factory_parent_class)->dispose (object);
58 do_finalize (GObject *object)
60 G_OBJECT_CLASS (empathy_ft_factory_parent_class)->finalize (object);
64 do_constructor (GType type,
66 GObjectConstructParam *props)
70 if (factory_singleton) {
71 retval = g_object_ref (factory_singleton);
73 retval = G_OBJECT_CLASS (empathy_ft_factory_parent_class)->constructor
74 (type, n_props, props);
76 factory_singleton = EMPATHY_FT_FACTORY (retval);
77 g_object_add_weak_pointer (retval, (gpointer *) &factory_singleton);
84 empathy_ft_factory_class_init (EmpathyFTFactoryClass *klass)
86 GObjectClass *object_class = G_OBJECT_CLASS (klass);
88 g_type_class_add_private (klass, sizeof (EmpathyFTFactoryPriv));
90 object_class->dispose = do_dispose;
91 object_class->finalize = do_finalize;
92 object_class->constructor = do_constructor;
94 signals[NEW_FT_HANDLER] =
95 g_signal_new ("new-ft-handler",
96 G_TYPE_FROM_CLASS (empathy_call_factory_class),
99 _empathy_marshal_VOID__OBJECT_BOOLEAN,
101 2, EMPATHY_TYPE_FT_HANDLER, G_TYPE_BOOLEAN);
105 empathy_ft_factory_init (EmpathyFTFactory *self)
107 EmpathyFTFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
108 EMPATHY_TYPE_FT_FACTORY, EmpathyFTFactoryPriv);
116 empathy_ft_factory_dup_singleton (void)
118 return g_object_new (EMPATHY_TYPE_FT_FACTORY, NULL);
122 empathy_ft_factory_new_transfer (EmpathyFTFactory *factory,
123 EmpathyContact *contact,
126 EmpathyFTHandler *handler;
128 g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory));
129 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
130 g_return_if_fail (G_IS_FILE (file));
132 handler = empathy_ft_handler_new (contact, file);
133 g_signal_emit (factory, signals[NEW_FT_HANDLER], 0, handler, TRUE);
135 g_object_unref (handler);
139 empathy_ft_factory_claim_channel (EmpathyFTFactory *factory,
140 EmpathyDispatchOperation *operation)
142 g_return_val_if_fail (EMPATHY_IS_FACTORY (factory));
143 g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation));