empathy r2072 - trunk/libempathy



Author: xclaesse
Date: Tue Jan  6 16:48:28 2009
New Revision: 2072
URL: http://svn.gnome.org/viewvc/empathy?rev=2072&view=rev

Log:
Yet more style fixes.

Modified:
   trunk/libempathy/empathy-account-manager.c
   trunk/libempathy/empathy-contact-monitor.c

Modified: trunk/libempathy/empathy-account-manager.c
==============================================================================
--- trunk/libempathy/empathy-account-manager.c	(original)
+++ trunk/libempathy/empathy-account-manager.c	Tue Jan  6 16:48:28 2009
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
 /*
  * Copyright (C) 2008 Collabora Ltd.
  *
@@ -19,7 +18,7 @@
  * Authors: Cosimo Cecchi <cosimo cecchi collabora co uk>
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <libmissioncontrol/mc-account-monitor.h>
 
@@ -64,7 +63,8 @@
 G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT);
 
 static AccountData *
-account_data_new (McPresence presence, TpConnectionStatus connection,
+account_data_new (McPresence presence,
+                  TpConnectionStatus connection,
                   gboolean is_enabled)
 {
   AccountData *retval;
@@ -87,16 +87,16 @@
   GError *err = NULL;
 
   actual_p = mission_control_get_presence_actual (mc, &err);
-  if (err) {
-    actual_p = MC_PRESENCE_UNSET;
-    g_clear_error (&err);
-  }
-
-  actual_c = mission_control_get_connection_status (mc,
-                                                    account, &err);
-  if (err) {
+  if (err != NULL)
+    {
+      actual_p = MC_PRESENCE_UNSET;
+      g_clear_error (&err);
+    }
+
+  actual_c = mission_control_get_connection_status (mc, account, &err);
+
+  if (err != NULL)
     actual_c = TP_CONNECTION_STATUS_DISCONNECTED;
-  }
 
   return account_data_new (actual_p, actual_c, mc_account_is_enabled (account));
 }
@@ -104,10 +104,11 @@
 static void
 account_data_free (AccountData *data)
 {
-  if (data->source_id > 0) {
-    g_source_remove (data->source_id);
-    data->source_id = 0;
-  }
+  if (data->source_id > 0)
+    {
+      g_source_remove (data->source_id);
+      data->source_id = 0;
+    }
 
   g_slice_free (AccountData, data);
 }
@@ -122,15 +123,16 @@
 
   account = mc_account_lookup (account_name);
 
-  if (account) {
-    AccountData *data;
+  if (account)
+    {
+      AccountData *data;
 
-    data = account_data_new_default (priv->mc, account);
+      data = account_data_new_default (priv->mc, account);
 
-    g_hash_table_insert (priv->accounts, account, data);
+      g_hash_table_insert (priv->accounts, account, data);
 
-    g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account);
-  }
+      g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account);
+    }
 }
 
 static void
@@ -143,12 +145,13 @@
 
   account = mc_account_lookup (account_name);
 
-  if (account) {
-    g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
-    
-    g_hash_table_remove (priv->accounts, account);
-    g_object_unref (account);
-  }
+  if (account)
+    {
+      g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
+
+      g_hash_table_remove (priv->accounts, account);
+      g_object_unref (account);
+    }
 }
 
 static void
@@ -160,10 +163,11 @@
 
   account = mc_account_lookup (account_name);
 
-  if (account) {
-    g_signal_emit (manager, signals[ACCOUNT_CHANGED], 0, account);
-    g_object_unref (account);
-  }
+  if (account)
+    {
+      g_signal_emit (manager, signals[ACCOUNT_CHANGED], 0, account);
+      g_object_unref (account);
+    }
 }
 
 static void
@@ -177,13 +181,14 @@
 
   account = mc_account_lookup (account_name);
 
-  if (account) {
-    data = g_hash_table_lookup (priv->accounts, account);
-    g_assert (data);
-    data->is_enabled = FALSE;
+  if (account)
+    {
+      data = g_hash_table_lookup (priv->accounts, account);
+      g_assert (data);
+      data->is_enabled = FALSE;
 
-    g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account);
-  }
+      g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account);
+    }
 }
 
 static void
@@ -197,14 +202,15 @@
 
   account = mc_account_lookup (account_name);
 
-  if (account) {
-    data = g_hash_table_lookup (priv->accounts, account);
-    g_assert (data);
-    data->is_enabled = TRUE;
-
-    g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
-    g_object_unref (account);
-  }
+  if (account)
+    {
+      data = g_hash_table_lookup (priv->accounts, account);
+      g_assert (data);
+      data->is_enabled = TRUE;
+
+      g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
+      g_object_unref (account);
+    }
 }
 
 static void
@@ -214,28 +220,28 @@
 {
   EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
 
-  if (conn == TP_CONNECTION_STATUS_CONNECTED) {
-    priv->connected++;
-    if (old_c == TP_CONNECTION_STATUS_CONNECTING) {
-      priv->connecting--;
+  if (conn == TP_CONNECTION_STATUS_CONNECTED)
+    {
+      priv->connected++;
+      if (old_c == TP_CONNECTION_STATUS_CONNECTING)
+        priv->connecting--;
     }
-  }
 
-  if (conn == TP_CONNECTION_STATUS_CONNECTING) {
-    priv->connecting++;
-    if (old_c == TP_CONNECTION_STATUS_CONNECTED) {
-      priv->connected--;
+  if (conn == TP_CONNECTION_STATUS_CONNECTING)
+    {
+      priv->connecting++;
+      if (old_c == TP_CONNECTION_STATUS_CONNECTED)
+        priv->connected--;
     }
-  }
 
-  if (conn == TP_CONNECTION_STATUS_DISCONNECTED) {
-    if (old_c == TP_CONNECTION_STATUS_CONNECTED) {
-      priv->connected--;
-    }
-    if (old_c == TP_CONNECTION_STATUS_CONNECTING) {
-      priv->connecting--;
+  if (conn == TP_CONNECTION_STATUS_DISCONNECTED)
+    {
+      if (old_c == TP_CONNECTION_STATUS_CONNECTED)
+        priv->connected--;
+
+      if (old_c == TP_CONNECTION_STATUS_CONNECTING)
+        priv->connecting--;
     }
-  }
 }
 
 static gboolean
@@ -265,57 +271,58 @@
 
   account = mc_account_lookup (unique_name);
 
-  if (account) {
-    data = g_hash_table_lookup (priv->accounts, account);
-    g_assert (data);
-
-    old_p = data->presence;
-    old_c = data->connection;
-
-    if (old_p != presence) {
-      data->presence = presence;
-      emit_presence = TRUE;
-    }
-
-    if (old_c != connection) {
-      data->connection = connection;
-      update_connection_numbers (manager, connection, old_c);
-
-      if (old_c == TP_CONNECTION_STATUS_CONNECTING &&
-          connection == TP_CONNECTION_STATUS_CONNECTED) {
-            if (data->source_id > 0) {
-              g_source_remove (data->source_id);
-              data->source_id = 0;
+  if (account)
+    {
+      data = g_hash_table_lookup (priv->accounts, account);
+      g_assert (data);
+
+      old_p = data->presence;
+      old_c = data->connection;
+
+      if (old_p != presence)
+        {
+          data->presence = presence;
+          emit_presence = TRUE;
+        }
+
+      if (old_c != connection)
+        {
+          data->connection = connection;
+          update_connection_numbers (manager, connection, old_c);
+
+          if (old_c == TP_CONNECTION_STATUS_CONNECTING &&
+              connection == TP_CONNECTION_STATUS_CONNECTED)
+            {
+                if (data->source_id > 0) {
+                  g_source_remove (data->source_id);
+                  data->source_id = 0;
+                }
+
+                data->source_id = g_timeout_add_seconds (10,
+                                                         remove_data_timeout,
+                                                         data);
             }
+          emit_connection = TRUE;
+        }
 
-            data->source_id = g_timeout_add_seconds (10,
-                                                     remove_data_timeout,
-                                                     data);
-      }
-      emit_connection = TRUE;
-    }
-
-    if (emit_presence) {
-      g_signal_emit (manager, signals[ACCOUNT_PRESENCE_CHANGED], 0,
-                     account, presence, old_p);
-    }
-
-    if (emit_connection) {
-      g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
-                     account, reason, connection, old_c);
+      if (emit_presence)
+        g_signal_emit (manager, signals[ACCOUNT_PRESENCE_CHANGED], 0,
+                       account, presence, old_p);
+
+      if (emit_connection)
+        g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
+                       account, reason, connection, old_c);
 
+      g_object_unref (account);
     }
-
-    g_object_unref (account);
-  }
 }
 
 static void
 empathy_account_manager_init (EmpathyAccountManager *manager)
 {
   EmpathyAccountManagerPriv *priv =
-    G_TYPE_INSTANCE_GET_PRIVATE (manager,
-                                 EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
+      G_TYPE_INSTANCE_GET_PRIVATE (manager,
+                                   EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
   GList *mc_accounts, *l;
   AccountData *data;
 
@@ -332,14 +339,15 @@
 
   mc_accounts = mc_accounts_list ();
 
-  for (l = mc_accounts; l; l = l->next) {
-    data = account_data_new_default (priv->mc, l->data);
-
-    /* no need to g_object_ref () the account here, as mc_accounts_list ()
-     * already increases the refcount.
-     */
-    g_hash_table_insert (priv->accounts, l->data, data);
-  }
+  for (l = mc_accounts; l; l = l->next)
+    {
+      data = account_data_new_default (priv->mc, l->data);
+
+      /* no need to g_object_ref () the account here, as mc_accounts_list ()
+       * already increases the refcount.
+       */
+      g_hash_table_insert (priv->accounts, l->data, data);
+    }
 
   g_signal_connect (priv->monitor, "account-created",
                     G_CALLBACK (account_created_cb), manager);
@@ -392,9 +400,10 @@
   EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
   EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
 
-  if (priv->dispose_run) {
+  if (priv->dispose_run)
     return;
-  }
+
+  priv->dispose_run = TRUE;
 
   dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
                                   "AccountStatusChanged",
@@ -403,19 +412,17 @@
 
   disconnect_monitor_signals (priv->monitor, obj);
 
-  if (priv->monitor) {
-    g_object_unref (priv->monitor);
-    priv->monitor = NULL;
-  }
+  if (priv->monitor)
+    {
+      g_object_unref (priv->monitor);
+      priv->monitor = NULL;
+    }
 
-  if (priv->mc) {
+  if (priv->mc)
     g_object_unref (priv->mc);
-  }
 
   g_hash_table_remove_all (priv->accounts);
 
-  priv->dispose_run = TRUE;
-
   G_OBJECT_CLASS (empathy_account_manager_parent_class)->dispose (obj);
 }
 
@@ -426,14 +433,15 @@
 {
   GObject *retval;
 
-  if (!manager_singleton) {
-    retval = G_OBJECT_CLASS (empathy_account_manager_parent_class)->constructor (type,
-                                                                                 n_construct_params,
-                                                                                 construct_params);
-    manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
-  } else {
+  if (!manager_singleton)
+    {
+      retval = G_OBJECT_CLASS (empathy_account_manager_parent_class)->constructor (type,
+                                                                                   n_construct_params,
+                                                                                   construct_params);
+      manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
+    } 
+  else
     retval = g_object_ref (manager_singleton);
-  }
 
   return retval;
 }

Modified: trunk/libempathy/empathy-contact-monitor.c
==============================================================================
--- trunk/libempathy/empathy-contact-monitor.c	(original)
+++ trunk/libempathy/empathy-contact-monitor.c	Tue Jan  6 16:48:28 2009
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
 /*
  * Copyright (C) 2008 Collabora Ltd.
  *
@@ -19,8 +18,9 @@
  * Authors: Cosimo Cecchi <cosimo cecchi collabora co uk>
  */
 
-#include <glib-object.h>
+#include "config.h"
 
+#include <glib-object.h>
 #include <libmissioncontrol/mc-enum-types.h>
 
 #include "empathy-contact-monitor.h"
@@ -56,14 +56,10 @@
 };
 
 static void  contact_remove_foreach (EmpathyContact *contact,
-                                     EmpathyContactMonitor *monitor);
+    EmpathyContactMonitor *monitor);
 static void  cl_members_changed_cb  (EmpathyContactList    *cl,
-                                     EmpathyContact        *contact,
-                                     EmpathyContact        *actor,
-                                     guint                  reason,
-                                     gchar                 *message,
-                                     gboolean               is_member,
-                                     EmpathyContactMonitor *monitor);
+    EmpathyContact *contact, EmpathyContact *actor, guint reason,
+    gchar *message, gboolean is_member, EmpathyContactMonitor *monitor);
 
 static guint signals[LAST_SIGNAL];
 
@@ -75,16 +71,16 @@
                  const GValue *value,
                  GParamSpec   *pspec)
 {
-  switch (param_id) {
-    case PROP_PROXY:
-      empathy_contact_monitor_set_proxy
-        (EMPATHY_CONTACT_MONITOR (object),
-         g_value_get_object (value));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-      break;
-  };
+  switch (param_id)
+    {
+      case PROP_PROXY:
+        empathy_contact_monitor_set_proxy (EMPATHY_CONTACT_MONITOR (object),
+                                           g_value_get_object (value));
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+        break;
+    };
 }
 
 static void
@@ -95,14 +91,15 @@
 {
   EmpathyContactMonitorPriv *priv = GET_PRIV (object);
 
-  switch (param_id) {
-    case PROP_PROXY:
-      g_value_set_object (value, priv->proxy);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-      break;
-  };
+  switch (param_id)
+    {
+      case PROP_PROXY:
+        g_value_set_object (value, priv->proxy);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+        break;
+    };
 }
 
 static void
@@ -112,15 +109,15 @@
 
   priv = GET_PRIV (obj);
 
-  if (priv->contacts) {
-    g_ptr_array_free (priv->contacts, TRUE);
-    priv->contacts = NULL;
-  }
+  if (priv->contacts)
+    {
+      g_ptr_array_free (priv->contacts, TRUE);
+      priv->contacts = NULL;
+    }
 
-  if (priv->proxy) {
+  if (priv->proxy)
     g_signal_handlers_disconnect_by_func (priv->proxy,
                                           cl_members_changed_cb, obj);
-  }
 
   G_OBJECT_CLASS (empathy_contact_monitor_parent_class)->finalize (obj);
 }
@@ -132,21 +129,18 @@
 
   priv = GET_PRIV (obj);
 
-  if (priv->dispose_run) {
+  if (priv->dispose_run)
     return;
-  }
 
-  if (priv->contacts) {
+  priv->dispose_run = TRUE;
+
+  if (priv->contacts)
     g_ptr_array_foreach (priv->contacts,
                          (GFunc) contact_remove_foreach, obj);
-  }
 
-  if (priv->proxy) {
+  if (priv->proxy)
     g_signal_handlers_disconnect_by_func (priv->proxy,
                                           cl_members_changed_cb, obj);
-  }
-
-  priv->dispose_run = TRUE;
 
   G_OBJECT_CLASS (empathy_contact_monitor_parent_class)->dispose (obj);
 }
@@ -246,8 +240,8 @@
 empathy_contact_monitor_init (EmpathyContactMonitor *self)
 {
   EmpathyContactMonitorPriv *priv =
-    G_TYPE_INSTANCE_GET_PRIVATE (self,
-                                 EMPATHY_TYPE_CONTACT_MONITOR, EmpathyContactMonitorPriv);
+      G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_CONTACT_MONITOR,
+                                   EmpathyContactMonitorPriv);
 
   self->priv = priv;
   priv->contacts = NULL;
@@ -383,11 +377,10 @@
                        gboolean               is_member,
                        EmpathyContactMonitor *monitor)
 {
-  if (is_member) {
+  if (is_member)
     contact_add (monitor, contact);
-  } else {
+  else
     contact_remove (monitor, contact);
-  }
 }
 
 /* public methods */
@@ -403,12 +396,13 @@
 
   priv = GET_PRIV (self);
 
-  if (priv->contacts != NULL) {
-    g_ptr_array_foreach (priv->contacts,
-                         (GFunc) contact_remove_foreach, self);
-    g_ptr_array_free (priv->contacts, TRUE);
-    priv->contacts = NULL;
-  }
+  if (priv->contacts != NULL)
+    {
+      g_ptr_array_foreach (priv->contacts,
+                           (GFunc) contact_remove_foreach, self);
+      g_ptr_array_free (priv->contacts, TRUE);
+      priv->contacts = NULL;
+    }
 
   priv->proxy = proxy;
   priv->contacts = g_ptr_array_new ();



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