empathy r2426 - trunk/libempathy



Author: xclaesse
Date: Wed Feb  4 21:07:04 2009
New Revision: 2426
URL: http://svn.gnome.org/viewvc/empathy?rev=2426&view=rev

Log:
Cleanup for GObject related functions in EmpathyCallFactory and EmpathyCallHandler.

From: Cosimo Cecchi <cosimo cecchi collabora co uk>

Modified:
   trunk/libempathy/empathy-call-factory.c
   trunk/libempathy/empathy-call-factory.h
   trunk/libempathy/empathy-call-handler.c
   trunk/libempathy/empathy-call-handler.h

Modified: trunk/libempathy/empathy-call-factory.c
==============================================================================
--- trunk/libempathy/empathy-call-factory.c	(original)
+++ trunk/libempathy/empathy-call-factory.c	Wed Feb  4 21:07:04 2009
@@ -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 @@
 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 @@
 }
 
 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 @@
     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 @@
 
   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_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);

Modified: trunk/libempathy/empathy-call-factory.h
==============================================================================
--- trunk/libempathy/empathy-call-factory.h	(original)
+++ trunk/libempathy/empathy-call-factory.h	Wed Feb  4 21:07:04 2009
@@ -37,6 +37,7 @@
 
 struct _EmpathyCallFactory {
     GObject parent;
+    gpointer priv;
 };
 
 GType empathy_call_factory_get_type (void);

Modified: trunk/libempathy/empathy-call-handler.c
==============================================================================
--- trunk/libempathy/empathy-call-handler.c	(original)
+++ trunk/libempathy/empathy-call-handler.c	Wed Feb  4 21:07:04 2009
@@ -30,12 +30,12 @@
 #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 @@
 };
 
 /* 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 @@
       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)
 {

Modified: trunk/libempathy/empathy-call-handler.h
==============================================================================
--- trunk/libempathy/empathy-call-handler.h	(original)
+++ trunk/libempathy/empathy-call-handler.h	Wed Feb  4 21:07:04 2009
@@ -39,6 +39,7 @@
 
 struct _EmpathyCallHandler {
     GObject parent;
+    gpointer priv;
 };
 
 GType empathy_call_handler_get_type (void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]