2 * empathy-call-factory.c - Source for EmpathyCallFactory
3 * Copyright (C) 2008 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "empathy-marshal.h"
26 #include "empathy-call-factory.h"
28 G_DEFINE_TYPE(EmpathyCallFactory, empathy_call_factory, G_TYPE_OBJECT)
37 static guint signals[LAST_SIGNAL] = {0};
39 /* private structure */
40 typedef struct _EmpathyCallFactoryPrivate EmpathyCallFactoryPrivate;
42 struct _EmpathyCallFactoryPrivate
44 gboolean dispose_has_run;
47 #define EMPATHY_CALL_FACTORY_GET_PRIVATE(o) \
48 (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
49 EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPrivate))
52 empathy_call_factory_init (EmpathyCallFactory *obj)
54 //EmpathyCallFactoryPrivate *priv = EMPATHY_CALL_FACTORY_GET_PRIVATE (obj);
56 /* allocate any data required by the object here */
59 static void empathy_call_factory_dispose (GObject *object);
60 static void empathy_call_factory_finalize (GObject *object);
62 static GObject *call_factory = NULL;
65 empathy_call_factory_constructor (GType type, guint n_construct_params,
66 GObjectConstructParam *construct_params)
68 g_return_val_if_fail (call_factory == NULL, NULL);
70 call_factory = G_OBJECT_CLASS (empathy_call_factory_parent_class)->constructor
71 (type, n_construct_params, construct_params);
72 g_object_add_weak_pointer (call_factory, (gpointer *)&call_factory);
78 empathy_call_factory_class_init (
79 EmpathyCallFactoryClass *empathy_call_factory_class)
81 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_factory_class);
83 g_type_class_add_private (empathy_call_factory_class,
84 sizeof (EmpathyCallFactoryPrivate));
86 object_class->constructor = empathy_call_factory_constructor;
87 object_class->dispose = empathy_call_factory_dispose;
88 object_class->finalize = empathy_call_factory_finalize;
90 signals[NEW_CALL_HANDLER] =
91 g_signal_new ("new-call-handler",
92 G_TYPE_FROM_CLASS (empathy_call_factory_class),
95 _empathy_marshal_VOID__OBJECT_BOOLEAN,
97 2, EMPATHY_TYPE_CALL_HANDLER, G_TYPE_BOOLEAN);
101 empathy_call_factory_dispose (GObject *object)
103 EmpathyCallFactory *self = EMPATHY_CALL_FACTORY (object);
104 EmpathyCallFactoryPrivate *priv = EMPATHY_CALL_FACTORY_GET_PRIVATE (self);
106 if (priv->dispose_has_run)
109 priv->dispose_has_run = TRUE;
111 /* release any references held by the object here */
113 if (G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose)
114 G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose (object);
118 empathy_call_factory_finalize (GObject *object)
120 //EmpathyCallFactory *self = EMPATHY_CALL_FACTORY (object);
121 //EmpathyCallFactoryPrivate *priv = EMPATHY_CALL_FACTORY_GET_PRIVATE (self);
123 /* free any data held directly by the object here */
125 G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize (object);
129 empathy_call_factory_initialise (void)
131 g_return_val_if_fail (call_factory == NULL, NULL);
133 return EMPATHY_CALL_FACTORY (g_object_new (EMPATHY_TYPE_CALL_FACTORY, NULL));
137 empathy_call_factory_get (void)
139 g_return_val_if_fail (call_factory != NULL, NULL);
141 return EMPATHY_CALL_FACTORY (call_factory);
145 empathy_call_factory_new_call (EmpathyCallFactory *factory,
146 EmpathyContact *contact)
148 EmpathyCallHandler *handler;
150 g_return_val_if_fail (factory != NULL, NULL);
151 g_return_val_if_fail (contact != NULL, NULL);
153 handler = empathy_call_handler_new_for_contact (contact);
155 g_signal_emit (G_OBJECT (factory), signals[NEW_CALL_HANDLER], 0,
162 empathy_call_factory_claim_channel (EmpathyCallFactory *factory,
163 EmpathyDispatchOperation *operation)
165 EmpathyCallHandler *handler;
168 g_return_val_if_fail (factory != NULL, NULL);
169 g_return_val_if_fail (operation != NULL, NULL);
171 call = EMPATHY_TP_CALL (
172 empathy_dispatch_operation_get_channel_wrapper (operation));
174 handler = empathy_call_handler_new_for_channel (call);
175 empathy_dispatch_operation_claim (operation);
177 /* FIXME should actually look at the channel */
178 g_signal_emit (G_OBJECT (factory), signals[NEW_CALL_HANDLER], 0,