]> git.0d.be Git - empathy.git/commitdiff
Cleanup for GObject related functions in EmpathyCallFactory and EmpathyCallHandler.
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>
Wed, 4 Feb 2009 21:07:04 +0000 (21:07 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Wed, 4 Feb 2009 21:07:04 +0000 (21:07 +0000)
From: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>

svn path=/trunk/; revision=2426

libempathy/empathy-call-factory.c
libempathy/empathy-call-factory.h
libempathy/empathy-call-handler.c
libempathy/empathy-call-handler.h

index 565f1d03fbc052e5f77dc373276c9a529cb73d43..08d35f0c2ebf1a7a893c2e42c18b696f333836cc 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "empathy-marshal.h"
 #include "empathy-call-factory.h"
+#include "empathy-utils.h"
 
 G_DEFINE_TYPE(EmpathyCallFactory, empathy_call_factory, G_TYPE_OBJECT)
 
@@ -37,30 +38,23 @@ enum
 static guint signals[LAST_SIGNAL] = {0};
 
 /* private structure */
-typedef struct _EmpathyCallFactoryPrivate EmpathyCallFactoryPrivate;
-
-struct _EmpathyCallFactoryPrivate
-{
+typedef struct {
   gboolean dispose_has_run;
-};
+} EmpathyCallFactoryPriv;
 
-#define EMPATHY_CALL_FACTORY_GET_PRIVATE(o)  \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
-  EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPrivate))
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallFactory)
+
+static GObject *call_factory = NULL;
 
 static void
 empathy_call_factory_init (EmpathyCallFactory *obj)
 {
-  //EmpathyCallFactoryPrivate *priv = EMPATHY_CALL_FACTORY_GET_PRIVATE (obj);
+  EmpathyCallFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
+    EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPriv);
 
-  /* allocate any data required by the object here */
+  obj->priv = priv;
 }
 
-static void empathy_call_factory_dispose (GObject *object);
-static void empathy_call_factory_finalize (GObject *object);
-
-static GObject *call_factory = NULL;
-
 static GObject *
 empathy_call_factory_constructor (GType type, guint n_construct_params,
   GObjectConstructParam *construct_params)
@@ -75,33 +69,18 @@ empathy_call_factory_constructor (GType type, guint n_construct_params,
 }
 
 static void
-empathy_call_factory_class_init (
-  EmpathyCallFactoryClass *empathy_call_factory_class)
+empathy_call_factory_finalize (GObject *object)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_factory_class);
-
-  g_type_class_add_private (empathy_call_factory_class,
-    sizeof (EmpathyCallFactoryPrivate));
-
-  object_class->constructor = empathy_call_factory_constructor;
-  object_class->dispose = empathy_call_factory_dispose;
-  object_class->finalize = empathy_call_factory_finalize;
+  /* free any data held directly by the object here */
 
-  signals[NEW_CALL_HANDLER] =
-    g_signal_new ("new-call-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_CALL_HANDLER, G_TYPE_BOOLEAN);
+  if (G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize)
+    G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize (object);
 }
 
-void
+static void
 empathy_call_factory_dispose (GObject *object)
 {
-  EmpathyCallFactory *self = EMPATHY_CALL_FACTORY (object);
-  EmpathyCallFactoryPrivate *priv = EMPATHY_CALL_FACTORY_GET_PRIVATE (self);
+  EmpathyCallFactoryPriv *priv = GET_PRIV (object);
 
   if (priv->dispose_has_run)
     return;
@@ -114,15 +93,27 @@ empathy_call_factory_dispose (GObject *object)
     G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose (object);
 }
 
-void
-empathy_call_factory_finalize (GObject *object)
+static void
+empathy_call_factory_class_init (
+  EmpathyCallFactoryClass *empathy_call_factory_class)
 {
-  //EmpathyCallFactory *self = EMPATHY_CALL_FACTORY (object);
-  //EmpathyCallFactoryPrivate *priv = EMPATHY_CALL_FACTORY_GET_PRIVATE (self);
+  GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_factory_class);
 
-  /* free any data held directly by the object here */
+  g_type_class_add_private (empathy_call_factory_class,
+    sizeof (EmpathyCallFactoryPriv));
 
-  G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize (object);
+  object_class->constructor = empathy_call_factory_constructor;
+  object_class->dispose = empathy_call_factory_dispose;
+  object_class->finalize = empathy_call_factory_finalize;  
+
+  signals[NEW_CALL_HANDLER] =
+    g_signal_new ("new-call-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_CALL_HANDLER, G_TYPE_BOOLEAN);
 }
 
 EmpathyCallFactory *
@@ -152,7 +143,7 @@ empathy_call_factory_new_call (EmpathyCallFactory *factory,
 
   handler = empathy_call_handler_new_for_contact (contact);
 
-  g_signal_emit (G_OBJECT (factory), signals[NEW_CALL_HANDLER], 0,
+  g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
     handler, TRUE);
 
   g_object_unref (handler);
@@ -175,7 +166,7 @@ empathy_call_factory_claim_channel (EmpathyCallFactory *factory,
   empathy_dispatch_operation_claim (operation);
 
   /* FIXME should actually look at the channel */
-  g_signal_emit (G_OBJECT (factory), signals[NEW_CALL_HANDLER], 0,
+  g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
     handler, FALSE);
 
   g_object_unref (handler);
index 181a51496a4b1057b9ce79d2887028e8fafb7211..13b16b6921d112ccd36c26b2ee9a3d86de155aef 100644 (file)
@@ -37,6 +37,7 @@ struct _EmpathyCallFactoryClass {
 
 struct _EmpathyCallFactory {
     GObject parent;
+    gpointer priv;
 };
 
 GType empathy_call_factory_get_type (void);
index a6117cd1930976f552943abe81767132bfda7fc4..40abf0d60259dfb40724bc08e1bb6b6997bbc3fe 100644 (file)
 #include "empathy-call-handler.h"
 #include "empathy-dispatcher.h"
 #include "empathy-marshal.h"
+#include "empathy-utils.h"
 
 G_DEFINE_TYPE(EmpathyCallHandler, empathy_call_handler, G_TYPE_OBJECT)
 
 /* signal enum */
-enum
-{
+enum {
   CONFERENCE_ADDED,
   SRC_PAD_ADDED,
   SINK_PAD_ADDED,
@@ -51,31 +51,66 @@ enum {
 };
 
 /* private structure */
-typedef struct _EmpathyCallHandlerPriv EmpathyCallHandlerPriv;
 
-struct _EmpathyCallHandlerPriv
-{
+typedef struct {
   gboolean dispose_has_run;
   EmpathyTpCall *call;
   EmpathyContact *contact;
   TfChannel *tfchannel;
   GstBus *bus;
-};
+} EmpathyCallHandlerPriv;
 
-#define GET_PRIV(o) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_CALL_HANDLER,\
-    EmpathyCallHandlerPriv))
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallHandler)
 
 static void
-empathy_call_handler_init (EmpathyCallHandler *obj)
+empathy_call_handler_dispose (GObject *object)
 {
-  //EmpathyCallHandlerPriv *priv = GET_PRIV (obj);
+  EmpathyCallHandlerPriv *priv = GET_PRIV (object);
+
+  if (priv->dispose_has_run)
+    return;
+
+  priv->dispose_has_run = TRUE;
+
+  if (priv->contact != NULL)
+    g_object_unref (priv->contact);
+
+  priv->contact = NULL;
+
+  if (priv->tfchannel != NULL)
+    g_object_unref (priv->tfchannel);
+
+  priv->tfchannel = NULL;
 
-  /* allocate any data required by the object here */
+  if (priv->call != NULL)
+    {
+      empathy_tp_call_close (priv->call);
+      g_object_unref (priv->call);
+    }
+
+  priv->call = NULL;
+
+  /* release any references held by the object here */
+  if (G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose)
+    G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose (object);
 }
 
-static void empathy_call_handler_dispose (GObject *object);
-static void empathy_call_handler_finalize (GObject *object);
+static void
+empathy_call_handler_finalize (GObject *object)
+{
+  /* free any data held directly by the object here */
+  if (G_OBJECT_CLASS (empathy_call_handler_parent_class)->finalize)
+    G_OBJECT_CLASS (empathy_call_handler_parent_class)->finalize (object);
+}
+
+static void
+empathy_call_handler_init (EmpathyCallHandler *obj)
+{
+  EmpathyCallHandlerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
+    EMPATHY_TYPE_CALL_HANDLER, EmpathyCallHandlerPriv);
+
+  obj->priv = priv;
+}
 
 static void
 empathy_call_handler_set_property (GObject *object,
@@ -175,51 +210,6 @@ empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
       2, GST_TYPE_PAD, G_TYPE_UINT);
 }
 
-void
-empathy_call_handler_dispose (GObject *object)
-{
-  EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (object);
-  EmpathyCallHandlerPriv *priv = GET_PRIV (self);
-
-  if (priv->dispose_has_run)
-    return;
-
-  priv->dispose_has_run = TRUE;
-
-  if (priv->contact != NULL)
-    g_object_unref (priv->contact);
-
-  priv->contact = NULL;
-
-  if (priv->tfchannel != NULL)
-    g_object_unref (priv->tfchannel);
-
-  priv->tfchannel = NULL;
-
-  if (priv->call != NULL)
-    {
-      empathy_tp_call_close (priv->call);
-      g_object_unref (priv->call);
-    }
-
-  priv->call = NULL;
-
-  /* release any references held by the object here */
-  if (G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose)
-    G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose (object);
-}
-
-void
-empathy_call_handler_finalize (GObject *object)
-{
-  //EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (object);
-  //EmpathyCallHandlerPriv *priv = GET_PRIV (self);
-
-  /* free any data held directly by the object here */
-
-  G_OBJECT_CLASS (empathy_call_handler_parent_class)->finalize (object);
-}
-
 EmpathyCallHandler *
 empathy_call_handler_new_for_contact (EmpathyContact *contact)
 {
index 1986b8b878a590ca2f44c14234170d58a481cb17..4bea0037cbf55eef848c20950a341780e9e2d607 100644 (file)
@@ -39,6 +39,7 @@ struct _EmpathyCallHandlerClass {
 
 struct _EmpathyCallHandler {
     GObject parent;
+    gpointer priv;
 };
 
 GType empathy_call_handler_get_type (void);