aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-07 00:48:28 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-07 00:48:28 +0800
commitff0179fadaeca6877b04b12959594e6c88708bda (patch)
tree50699a4d33934926340c0672973951b43f9aba70 /libempathy
parentcea4cc62cdb35a1674ad8d3d418150e564b0cf33 (diff)
downloadgsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.tar
gsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.tar.gz
gsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.tar.bz2
gsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.tar.lz
gsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.tar.xz
gsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.tar.zst
gsoc2013-empathy-ff0179fadaeca6877b04b12959594e6c88708bda.zip
Yet more style fixes.
svn path=/trunk/; revision=2072
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-account-manager.c260
-rw-r--r--libempathy/empathy-contact-monitor.c98
2 files changed, 180 insertions, 178 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index 0d50cd9c7..b8fae1965 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -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 @@ static EmpathyAccountManager *manager_singleton = NULL;
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 @@ account_data_new_default (MissionControl *mc,
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 @@ account_data_new_default (MissionControl *mc,
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_created_cb (McAccountMonitor *mon,
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_deleted_cb (McAccountMonitor *mon,
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_changed_cb (McAccountMonitor *mon,
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_disabled_cb (McAccountMonitor *mon,
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_enabled_cb (McAccountMonitor *mon,
account = mc_account_lookup (account_name);
- if (account) {
- data = g_hash_table_lookup (priv->accounts, account);
- g_assert (data);
- data->is_enabled = TRUE;
+ 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);
- }
+ g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
+ g_object_unref (account);
+ }
}
static void
@@ -214,28 +220,28 @@ update_connection_numbers (EmpathyAccountManager *manager,
{
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_status_changed_cb (MissionControl *mc,
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_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_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 @@ empathy_account_manager_init (EmpathyAccountManager *manager)
mc_accounts = mc_accounts_list ();
- for (l = mc_accounts; l; l = l->next) {
- data = account_data_new_default (priv->mc, l->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);
- }
+ /* 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 @@ do_dispose (GObject *obj)
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 @@ do_dispose (GObject *obj)
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 @@ do_constructor (GType type,
{
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;
}
diff --git a/libempathy/empathy-contact-monitor.c b/libempathy/empathy-contact-monitor.c
index d1cd724b7..525c1d427 100644
--- a/libempathy/empathy-contact-monitor.c
+++ b/libempathy/empathy-contact-monitor.c
@@ -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 @@ enum {
};
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 @@ do_set_property (GObject *object,
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 @@ do_get_property (GObject *object,
{
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 @@ do_finalize (GObject *obj)
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 @@ do_dispose (GObject *obj)
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 @@ static void
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 @@ cl_members_changed_cb (EmpathyContactList *cl,
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 @@ empathy_contact_monitor_set_proxy (EmpathyContactMonitor *self,
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 ();