aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-contact.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy/empathy-contact.c')
-rw-r--r--libempathy/empathy-contact.c778
1 files changed, 389 insertions, 389 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 84ab27c42..7a73b2bbb 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -40,17 +40,17 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
typedef struct {
- gchar *id;
- gchar *name;
- EmpathyAvatar *avatar;
- McAccount *account;
- McPresence presence;
- gchar *presence_message;
- guint handle;
- EmpathyCapabilities capabilities;
- gboolean is_user;
- guint hash;
- EmpathyContactReady ready;
+ gchar *id;
+ gchar *name;
+ EmpathyAvatar *avatar;
+ McAccount *account;
+ McPresence presence;
+ gchar *presence_message;
+ guint handle;
+ EmpathyCapabilities capabilities;
+ gboolean is_user;
+ guint hash;
+ EmpathyContactReady ready;
} EmpathyContactPriv;
static void contact_finalize (GObject *object);
@@ -63,31 +63,31 @@ G_DEFINE_TYPE (EmpathyContact, empathy_contact, G_TYPE_OBJECT);
enum
{
- PROP_0,
- PROP_ID,
- PROP_NAME,
- PROP_AVATAR,
- PROP_ACCOUNT,
- PROP_PRESENCE,
- PROP_PRESENCE_MESSAGE,
- PROP_HANDLE,
- PROP_CAPABILITIES,
- PROP_IS_USER,
- PROP_READY
+ PROP_0,
+ PROP_ID,
+ PROP_NAME,
+ PROP_AVATAR,
+ PROP_ACCOUNT,
+ PROP_PRESENCE,
+ PROP_PRESENCE_MESSAGE,
+ PROP_HANDLE,
+ PROP_CAPABILITIES,
+ PROP_IS_USER,
+ PROP_READY
};
static void
empathy_contact_class_init (EmpathyContactClass *class)
{
- GObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (class);
+ object_class = G_OBJECT_CLASS (class);
- object_class->finalize = contact_finalize;
- object_class->get_property = contact_get_property;
- object_class->set_property = contact_set_property;
+ object_class->finalize = contact_finalize;
+ object_class->get_property = contact_get_property;
+ object_class->set_property = contact_set_property;
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_string ("id",
"Contact id",
@@ -95,7 +95,7 @@ empathy_contact_class_init (EmpathyContactClass *class)
NULL,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
"Contact Name",
@@ -103,7 +103,7 @@ empathy_contact_class_init (EmpathyContactClass *class)
NULL,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_AVATAR,
g_param_spec_boxed ("avatar",
"Avatar image",
@@ -111,104 +111,104 @@ empathy_contact_class_init (EmpathyContactClass *class)
EMPATHY_TYPE_AVATAR,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_ACCOUNT,
g_param_spec_object ("account",
"Contact Account",
- "The account associated with the contact",
- MC_TYPE_ACCOUNT,
- G_PARAM_READWRITE));
+ "The account associated with the contact",
+ MC_TYPE_ACCOUNT,
+ G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_PRESENCE,
g_param_spec_uint ("presence",
"Contact presence",
- "Presence of contact",
- MC_PRESENCE_UNSET,
- LAST_MC_PRESENCE,
- MC_PRESENCE_UNSET,
- G_PARAM_READWRITE));
+ "Presence of contact",
+ MC_PRESENCE_UNSET,
+ LAST_MC_PRESENCE,
+ MC_PRESENCE_UNSET,
+ G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_PRESENCE_MESSAGE,
g_param_spec_string ("presence-message",
"Contact presence message",
- "Presence message of contact",
- NULL,
- G_PARAM_READWRITE));
+ "Presence message of contact",
+ NULL,
+ G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_HANDLE,
g_param_spec_uint ("handle",
"Contact Handle",
- "The handle of the contact",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READWRITE));
+ "The handle of the contact",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_CAPABILITIES,
- g_param_spec_flags ("capabilities",
+ g_param_spec_flags ("capabilities",
"Contact Capabilities",
- "Capabilities of the contact",
- EMPATHY_TYPE_CAPABILITIES,
- EMPATHY_CAPABILITIES_UNKNOWN,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
+ "Capabilities of the contact",
+ EMPATHY_TYPE_CAPABILITIES,
+ EMPATHY_CAPABILITIES_UNKNOWN,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_IS_USER,
g_param_spec_boolean ("is-user",
"Contact is-user",
- "Is contact the user",
- FALSE,
- G_PARAM_READWRITE));
+ "Is contact the user",
+ FALSE,
+ G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (object_class,
PROP_READY,
g_param_spec_flags ("ready",
"Contact ready flags",
- "Flags for ready properties",
- EMPATHY_TYPE_CONTACT_READY,
- EMPATHY_CONTACT_READY_NONE,
- G_PARAM_READABLE));
+ "Flags for ready properties",
+ EMPATHY_TYPE_CONTACT_READY,
+ EMPATHY_CONTACT_READY_NONE,
+ G_PARAM_READABLE));
- g_type_class_add_private (object_class, sizeof (EmpathyContactPriv));
+ g_type_class_add_private (object_class, sizeof (EmpathyContactPriv));
}
static void
empathy_contact_init (EmpathyContact *contact)
{
- EmpathyContactPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (contact,
- EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
+ EmpathyContactPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (contact,
+ EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
- contact->priv = priv;
+ contact->priv = priv;
}
static void
contact_finalize (GObject *object)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- priv = GET_PRIV (object);
+ priv = GET_PRIV (object);
- DEBUG ("finalize: %p", object);
+ DEBUG ("finalize: %p", object);
- g_free (priv->name);
- g_free (priv->id);
- g_free (priv->presence_message);
+ g_free (priv->name);
+ g_free (priv->id);
+ g_free (priv->presence_message);
- if (priv->avatar)
+ if (priv->avatar)
{
empathy_avatar_unref (priv->avatar);
}
- if (priv->account)
+ if (priv->account)
{
g_object_unref (priv->account);
}
- G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
+ G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
}
static void
@@ -217,46 +217,46 @@ contact_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- priv = GET_PRIV (object);
+ priv = GET_PRIV (object);
- switch (param_id) {
- case PROP_ID:
- g_value_set_string (value, priv->id);
- break;
- case PROP_NAME:
- g_value_set_string (value,
+ switch (param_id) {
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value,
empathy_contact_get_name (EMPATHY_CONTACT (object)));
- break;
- case PROP_AVATAR:
- g_value_set_boxed (value, priv->avatar);
- break;
- case PROP_ACCOUNT:
- g_value_set_object (value, priv->account);
- break;
- case PROP_PRESENCE:
- g_value_set_uint (value, priv->presence);
- break;
- case PROP_PRESENCE_MESSAGE:
- g_value_set_string (value, priv->presence_message);
- break;
- case PROP_HANDLE:
- g_value_set_uint (value, priv->handle);
- break;
- case PROP_CAPABILITIES:
- g_value_set_flags (value, priv->capabilities);
- break;
- case PROP_IS_USER:
- g_value_set_boolean (value, priv->is_user);
- break;
- case PROP_READY:
- g_value_set_flags (value, priv->ready);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
+ break;
+ case PROP_AVATAR:
+ g_value_set_boxed (value, priv->avatar);
+ break;
+ case PROP_ACCOUNT:
+ g_value_set_object (value, priv->account);
+ break;
+ case PROP_PRESENCE:
+ g_value_set_uint (value, priv->presence);
+ break;
+ case PROP_PRESENCE_MESSAGE:
+ g_value_set_string (value, priv->presence_message);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, priv->handle);
+ break;
+ case PROP_CAPABILITIES:
+ g_value_set_flags (value, priv->capabilities);
+ break;
+ case PROP_IS_USER:
+ g_value_set_boolean (value, priv->is_user);
+ break;
+ case PROP_READY:
+ g_value_set_flags (value, priv->ready);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
}
static void
@@ -265,60 +265,60 @@ contact_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- priv = GET_PRIV (object);
+ priv = GET_PRIV (object);
- switch (param_id) {
- case PROP_ID:
- empathy_contact_set_id (EMPATHY_CONTACT (object),
+ switch (param_id) {
+ case PROP_ID:
+ empathy_contact_set_id (EMPATHY_CONTACT (object),
g_value_get_string (value));
- break;
- case PROP_NAME:
- empathy_contact_set_name (EMPATHY_CONTACT (object),
+ break;
+ case PROP_NAME:
+ empathy_contact_set_name (EMPATHY_CONTACT (object),
g_value_get_string (value));
- break;
- case PROP_AVATAR:
- empathy_contact_set_avatar (EMPATHY_CONTACT (object),
+ break;
+ case PROP_AVATAR:
+ empathy_contact_set_avatar (EMPATHY_CONTACT (object),
g_value_get_boxed (value));
- break;
- case PROP_ACCOUNT:
- empathy_contact_set_account (EMPATHY_CONTACT (object),
+ break;
+ case PROP_ACCOUNT:
+ empathy_contact_set_account (EMPATHY_CONTACT (object),
MC_ACCOUNT (g_value_get_object (value)));
- break;
- case PROP_PRESENCE:
- empathy_contact_set_presence (EMPATHY_CONTACT (object),
+ break;
+ case PROP_PRESENCE:
+ empathy_contact_set_presence (EMPATHY_CONTACT (object),
g_value_get_uint (value));
- break;
- case PROP_PRESENCE_MESSAGE:
- empathy_contact_set_presence_message (EMPATHY_CONTACT (object),
+ break;
+ case PROP_PRESENCE_MESSAGE:
+ empathy_contact_set_presence_message (EMPATHY_CONTACT (object),
g_value_get_string (value));
- break;
- case PROP_HANDLE:
- empathy_contact_set_handle (EMPATHY_CONTACT (object),
+ break;
+ case PROP_HANDLE:
+ empathy_contact_set_handle (EMPATHY_CONTACT (object),
g_value_get_uint (value));
- break;
- case PROP_CAPABILITIES:
- empathy_contact_set_capabilities (EMPATHY_CONTACT (object),
+ break;
+ case PROP_CAPABILITIES:
+ empathy_contact_set_capabilities (EMPATHY_CONTACT (object),
g_value_get_flags (value));
- break;
- case PROP_IS_USER:
- empathy_contact_set_is_user (EMPATHY_CONTACT (object),
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
+ break;
+ case PROP_IS_USER:
+ empathy_contact_set_is_user (EMPATHY_CONTACT (object),
+ g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
}
static void
contact_set_ready_flag (EmpathyContact *contact,
EmpathyContactReady flag)
{
- EmpathyContactPriv *priv = GET_PRIV (contact);
+ EmpathyContactPriv *priv = GET_PRIV (contact);
- if (!(priv->ready & flag))
+ if (!(priv->ready & flag))
{
priv->ready |= flag;
g_object_notify (G_OBJECT (contact), "ready");
@@ -328,9 +328,9 @@ contact_set_ready_flag (EmpathyContact *contact,
EmpathyContact *
empathy_contact_new (McAccount *account)
{
- return g_object_new (EMPATHY_TYPE_CONTACT,
+ return g_object_new (EMPATHY_TYPE_CONTACT,
"account", account,
- NULL);
+ NULL);
}
EmpathyContact *
@@ -348,30 +348,30 @@ empathy_contact_new_full (McAccount *account,
const gchar *
empathy_contact_get_id (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->id;
+ return priv->id;
}
void
empathy_contact_set_id (EmpathyContact *contact,
- const gchar *id)
+ const gchar *id)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (id != NULL);
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (id != NULL);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- /* We temporally ref the contact because it could be destroyed
- * during the signal emition */
- g_object_ref (contact);
- if (tp_strdiff (id, priv->id))
+ /* We temporally ref the contact because it could be destroyed
+ * during the signal emition */
+ g_object_ref (contact);
+ if (tp_strdiff (id, priv->id))
{
g_free (priv->id);
priv->id = g_strdup (id);
@@ -382,382 +382,382 @@ empathy_contact_set_id (EmpathyContact *contact,
g_object_notify (G_OBJECT (contact), "name");
}
}
- contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_ID);
+ contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_ID);
- g_object_unref (contact);
+ g_object_unref (contact);
}
const gchar *
empathy_contact_get_name (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (G_STR_EMPTY (priv->name))
+ if (G_STR_EMPTY (priv->name))
{
return empathy_contact_get_id (contact);
}
- return priv->name;
+ return priv->name;
}
void
empathy_contact_set_name (EmpathyContact *contact,
const gchar *name)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- g_object_ref (contact);
- if (tp_strdiff (name, priv->name))
+ g_object_ref (contact);
+ if (tp_strdiff (name, priv->name))
{
g_free (priv->name);
priv->name = g_strdup (name);
g_object_notify (G_OBJECT (contact), "name");
}
- contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_NAME);
- g_object_unref (contact);
+ contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_NAME);
+ g_object_unref (contact);
}
EmpathyAvatar *
empathy_contact_get_avatar (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->avatar;
+ return priv->avatar;
}
void
empathy_contact_set_avatar (EmpathyContact *contact,
- EmpathyAvatar *avatar)
+ EmpathyAvatar *avatar)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (priv->avatar == avatar)
- return;
+ if (priv->avatar == avatar)
+ return;
- if (priv->avatar)
+ if (priv->avatar)
{
empathy_avatar_unref (priv->avatar);
priv->avatar = NULL;
}
- if (avatar)
+ if (avatar)
{
priv->avatar = empathy_avatar_ref (avatar);
}
- g_object_notify (G_OBJECT (contact), "avatar");
+ g_object_notify (G_OBJECT (contact), "avatar");
}
McAccount *
empathy_contact_get_account (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->account;
+ return priv->account;
}
void
empathy_contact_set_account (EmpathyContact *contact,
- McAccount *account)
+ McAccount *account)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (MC_IS_ACCOUNT (account));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (MC_IS_ACCOUNT (account));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (account == priv->account)
- return;
+ if (account == priv->account)
+ return;
- if (priv->account)
+ if (priv->account)
{
g_object_unref (priv->account);
}
- priv->account = g_object_ref (account);
+ priv->account = g_object_ref (account);
- g_object_notify (G_OBJECT (contact), "account");
+ g_object_notify (G_OBJECT (contact), "account");
}
McPresence
empathy_contact_get_presence (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->presence;
+ return priv->presence;
}
void
empathy_contact_set_presence (EmpathyContact *contact,
- McPresence presence)
+ McPresence presence)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (presence == priv->presence)
- return;
+ if (presence == priv->presence)
+ return;
- priv->presence = presence;
+ priv->presence = presence;
- g_object_notify (G_OBJECT (contact), "presence");
+ g_object_notify (G_OBJECT (contact), "presence");
}
const gchar *
empathy_contact_get_presence_message (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->presence_message;
+ return priv->presence_message;
}
void
empathy_contact_set_presence_message (EmpathyContact *contact,
- const gchar *message)
+ const gchar *message)
{
- EmpathyContactPriv *priv = GET_PRIV (contact);
+ EmpathyContactPriv *priv = GET_PRIV (contact);
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- if (!tp_strdiff (message, priv->presence_message))
- return;
+ if (!tp_strdiff (message, priv->presence_message))
+ return;
- g_free (priv->presence_message);
- priv->presence_message = g_strdup (message);
+ g_free (priv->presence_message);
+ priv->presence_message = g_strdup (message);
- g_object_notify (G_OBJECT (contact), "presence-message");
+ g_object_notify (G_OBJECT (contact), "presence-message");
}
guint
empathy_contact_get_handle (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->handle;
+ return priv->handle;
}
void
empathy_contact_set_handle (EmpathyContact *contact,
- guint handle)
+ guint handle)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- g_object_ref (contact);
- if (handle != priv->handle)
+ g_object_ref (contact);
+ if (handle != priv->handle)
{
priv->handle = handle;
g_object_notify (G_OBJECT (contact), "handle");
}
- contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_HANDLE);
- g_object_unref (contact);
+ contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_HANDLE);
+ g_object_unref (contact);
}
EmpathyCapabilities
empathy_contact_get_capabilities (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->capabilities;
+ return priv->capabilities;
}
void
empathy_contact_set_capabilities (EmpathyContact *contact,
EmpathyCapabilities capabilities)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (priv->capabilities == capabilities)
- return;
+ if (priv->capabilities == capabilities)
+ return;
- priv->capabilities = capabilities;
+ priv->capabilities = capabilities;
- g_object_notify (G_OBJECT (contact), "capabilities");
+ g_object_notify (G_OBJECT (contact), "capabilities");
}
gboolean
empathy_contact_is_user (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->is_user;
+ return priv->is_user;
}
void
empathy_contact_set_is_user (EmpathyContact *contact,
- gboolean is_user)
+ gboolean is_user)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (priv->is_user == is_user)
- return;
+ if (priv->is_user == is_user)
+ return;
- priv->is_user = is_user;
+ priv->is_user = is_user;
- g_object_notify (G_OBJECT (contact), "is-user");
+ g_object_notify (G_OBJECT (contact), "is-user");
}
gboolean
empathy_contact_is_online (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return (priv->presence > MC_PRESENCE_OFFLINE);
+ return (priv->presence > MC_PRESENCE_OFFLINE);
}
const gchar *
empathy_contact_get_status (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), "");
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), "");
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- if (priv->presence_message)
- return priv->presence_message;
+ if (priv->presence_message)
+ return priv->presence_message;
- return empathy_presence_get_default_message (priv->presence);
+ return empathy_presence_get_default_message (priv->presence);
}
gboolean
empathy_contact_can_voip (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->capabilities & (EMPATHY_CAPABILITIES_AUDIO |
- EMPATHY_CAPABILITIES_VIDEO);
+ return priv->capabilities & (EMPATHY_CAPABILITIES_AUDIO |
+ EMPATHY_CAPABILITIES_VIDEO);
}
EmpathyContactReady
empathy_contact_get_ready (EmpathyContact *contact)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- priv = GET_PRIV (contact);
+ priv = GET_PRIV (contact);
- return priv->ready;
+ return priv->ready;
}
gboolean
empathy_contact_equal (gconstpointer v1,
- gconstpointer v2)
+ gconstpointer v2)
{
- McAccount *account_a;
- McAccount *account_b;
- const gchar *id_a;
- const gchar *id_b;
+ McAccount *account_a;
+ McAccount *account_b;
+ const gchar *id_a;
+ const gchar *id_b;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (v1), FALSE);
- g_return_val_if_fail (EMPATHY_IS_CONTACT (v2), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (v1), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (v2), FALSE);
- account_a = empathy_contact_get_account (EMPATHY_CONTACT (v1));
- account_b = empathy_contact_get_account (EMPATHY_CONTACT (v2));
+ account_a = empathy_contact_get_account (EMPATHY_CONTACT (v1));
+ account_b = empathy_contact_get_account (EMPATHY_CONTACT (v2));
- id_a = empathy_contact_get_id (EMPATHY_CONTACT (v1));
- id_b = empathy_contact_get_id (EMPATHY_CONTACT (v2));
+ id_a = empathy_contact_get_id (EMPATHY_CONTACT (v1));
+ id_b = empathy_contact_get_id (EMPATHY_CONTACT (v2));
- return empathy_account_equal (account_a, account_b) &&
- !tp_strdiff (id_a, id_b);
+ return empathy_account_equal (account_a, account_b) &&
+ !tp_strdiff (id_a, id_b);
}
guint
empathy_contact_hash (gconstpointer key)
{
- EmpathyContactPriv *priv;
+ EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (key), +1);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (key), +1);
- priv = GET_PRIV (EMPATHY_CONTACT (key));
+ priv = GET_PRIV (EMPATHY_CONTACT (key));
- if (priv->hash == 0) {
- priv->hash = empathy_account_hash (priv->account) ^
- g_str_hash (priv->id);
- }
+ if (priv->hash == 0) {
+ priv->hash = empathy_account_hash (priv->account) ^
+ g_str_hash (priv->id);
+ }
- return priv->hash;
+ return priv->hash;
}
static gboolean
contact_is_ready_func (GObject *contact,
gpointer user_data)
{
- EmpathyContactPriv *priv = GET_PRIV (contact);
- EmpathyContactReady ready;
+ EmpathyContactPriv *priv = GET_PRIV (contact);
+ EmpathyContactReady ready;
- ready = GPOINTER_TO_UINT (user_data);
+ ready = GPOINTER_TO_UINT (user_data);
- /* When the name is NULL, empathy_contact_get_name() fallback to the id.
- * When the caller want to wait the name to be ready, it also want to wait
- * the id to be ready in case of fallback. */
- if ((ready & EMPATHY_CONTACT_READY_NAME) && G_STR_EMPTY (priv->name)) {
- ready |= EMPATHY_CONTACT_READY_ID;
- }
+ /* When the name is NULL, empathy_contact_get_name() fallback to the id.
+ * When the caller want to wait the name to be ready, it also want to wait
+ * the id to be ready in case of fallback. */
+ if ((ready & EMPATHY_CONTACT_READY_NAME) && G_STR_EMPTY (priv->name)) {
+ ready |= EMPATHY_CONTACT_READY_ID;
+ }
- return (priv->ready & ready) == ready;
+ return (priv->ready & ready) == ready;
}
void
@@ -765,7 +765,7 @@ empathy_contact_run_until_ready (EmpathyContact *contact,
EmpathyContactReady ready,
GMainLoop **loop)
{
- empathy_run_until_ready_full (contact, "notify::ready",
+ empathy_run_until_ready_full (contact, "notify::ready",
contact_is_ready_func, GUINT_TO_POINTER (ready),
loop);
}
@@ -774,61 +774,61 @@ static gchar *
contact_get_avatar_filename (EmpathyContact *contact,
const gchar *token)
{
- EmpathyContactPriv *priv = GET_PRIV (contact);
- gchar *avatar_path;
- gchar *avatar_file;
- gchar *token_escaped;
- gchar *contact_escaped;
+ EmpathyContactPriv *priv = GET_PRIV (contact);
+ gchar *avatar_path;
+ gchar *avatar_file;
+ gchar *token_escaped;
+ gchar *contact_escaped;
- if (G_STR_EMPTY (priv->id))
- return NULL;
+ if (G_STR_EMPTY (priv->id))
+ return NULL;
- contact_escaped = tp_escape_as_identifier (priv->id);
- token_escaped = tp_escape_as_identifier (token);
+ contact_escaped = tp_escape_as_identifier (priv->id);
+ token_escaped = tp_escape_as_identifier (token);
- avatar_path = g_build_filename (g_get_user_cache_dir (),
+ avatar_path = g_build_filename (g_get_user_cache_dir (),
PACKAGE_NAME,
"avatars",
mc_account_get_unique_name (priv->account),
contact_escaped,
NULL);
- g_mkdir_with_parents (avatar_path, 0700);
+ g_mkdir_with_parents (avatar_path, 0700);
- avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
+ avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
- g_free (contact_escaped);
- g_free (token_escaped);
- g_free (avatar_path);
+ g_free (contact_escaped);
+ g_free (token_escaped);
+ g_free (avatar_path);
- return avatar_file;
+ return avatar_file;
}
void
empathy_contact_load_avatar_data (EmpathyContact *contact,
const guchar *data,
- const gsize len,
- const gchar *format,
- const gchar *token)
-{
- EmpathyAvatar *avatar;
- gchar *filename;
- GError *error = NULL;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (data != NULL);
- g_return_if_fail (len > 0);
- g_return_if_fail (format != NULL);
- g_return_if_fail (!G_STR_EMPTY (token));
-
- /* Load and set the avatar */
- avatar = empathy_avatar_new (g_memdup (data, len), len, g_strdup (format),
+ const gsize len,
+ const gchar *format,
+ const gchar *token)
+{
+ EmpathyAvatar *avatar;
+ gchar *filename;
+ GError *error = NULL;
+
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (len > 0);
+ g_return_if_fail (format != NULL);
+ g_return_if_fail (!G_STR_EMPTY (token));
+
+ /* Load and set the avatar */
+ avatar = empathy_avatar_new (g_memdup (data, len), len, g_strdup (format),
g_strdup (token));
- empathy_contact_set_avatar (contact, avatar);
- empathy_avatar_unref (avatar);
+ empathy_contact_set_avatar (contact, avatar);
+ empathy_avatar_unref (avatar);
- /* Save to cache if not yet in it */
- filename = contact_get_avatar_filename (contact, token);
- if (filename && !g_file_test (filename, G_FILE_TEST_EXISTS))
+ /* Save to cache if not yet in it */
+ filename = contact_get_avatar_filename (contact, token);
+ if (filename && !g_file_test (filename, G_FILE_TEST_EXISTS))
{
if (!empathy_avatar_save_to_file (avatar, filename, &error))
{
@@ -841,25 +841,25 @@ empathy_contact_load_avatar_data (EmpathyContact *contact,
DEBUG ("Avatar saved to %s", filename);
}
}
- g_free (filename);
+ g_free (filename);
}
gboolean
empathy_contact_load_avatar_cache (EmpathyContact *contact,
- const gchar *token)
+ const gchar *token)
{
- EmpathyAvatar *avatar = NULL;
- gchar *filename;
- gchar *data = NULL;
- gsize len;
- GError *error = NULL;
+ EmpathyAvatar *avatar = NULL;
+ gchar *filename;
+ gchar *data = NULL;
+ gsize len;
+ GError *error = NULL;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- g_return_val_if_fail (!G_STR_EMPTY (token), FALSE);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+ g_return_val_if_fail (!G_STR_EMPTY (token), FALSE);
- /* Load the avatar from file if it exists */
- filename = contact_get_avatar_filename (contact, token);
- if (filename && g_file_test (filename, G_FILE_TEST_EXISTS))
+ /* Load the avatar from file if it exists */
+ filename = contact_get_avatar_filename (contact, token);
+ if (filename && g_file_test (filename, G_FILE_TEST_EXISTS))
{
if (!g_file_get_contents (filename, &data, &len, &error))
{
@@ -869,7 +869,7 @@ empathy_contact_load_avatar_cache (EmpathyContact *contact,
}
}
- if (data)
+ if (data)
{
DEBUG ("Avatar loaded from %s", filename);
avatar = empathy_avatar_new (data, len, NULL, g_strdup (token));
@@ -877,51 +877,51 @@ empathy_contact_load_avatar_cache (EmpathyContact *contact,
empathy_avatar_unref (avatar);
}
- g_free (filename);
+ g_free (filename);
- return data != NULL;
+ return data != NULL;
}
GType
empathy_avatar_get_type (void)
{
- static GType type_id = 0;
+ static GType type_id = 0;
- if (!type_id)
+ if (!type_id)
{
type_id = g_boxed_type_register_static ("EmpathyAvatar",
(GBoxedCopyFunc) empathy_avatar_ref,
(GBoxedFreeFunc) empathy_avatar_unref);
}
- return type_id;
+ return type_id;
}
EmpathyAvatar *
empathy_avatar_new (guchar *data,
gsize len,
- gchar *format,
- gchar *token)
+ gchar *format,
+ gchar *token)
{
- EmpathyAvatar *avatar;
+ EmpathyAvatar *avatar;
- avatar = g_slice_new0 (EmpathyAvatar);
- avatar->data = data;
- avatar->len = len;
- avatar->format = format;
- avatar->token = token;
- avatar->refcount = 1;
+ avatar = g_slice_new0 (EmpathyAvatar);
+ avatar->data = data;
+ avatar->len = len;
+ avatar->format = format;
+ avatar->token = token;
+ avatar->refcount = 1;
- return avatar;
+ return avatar;
}
void
empathy_avatar_unref (EmpathyAvatar *avatar)
{
- g_return_if_fail (avatar != NULL);
+ g_return_if_fail (avatar != NULL);
- avatar->refcount--;
- if (avatar->refcount == 0)
+ avatar->refcount--;
+ if (avatar->refcount == 0)
{
g_free (avatar->data);
g_free (avatar->format);
@@ -933,11 +933,11 @@ empathy_avatar_unref (EmpathyAvatar *avatar)
EmpathyAvatar *
empathy_avatar_ref (EmpathyAvatar *avatar)
{
- g_return_val_if_fail (avatar != NULL, NULL);
+ g_return_val_if_fail (avatar != NULL, NULL);
- avatar->refcount++;
+ avatar->refcount++;
- return avatar;
+ return avatar;
}
/**