#include <glib/gi18n.h>
+#include <telepathy-glib/util.h>
+
#include "empathy-contact.h"
#include "empathy-utils.h"
#include "empathy-debug.h"
gchar *name;
EmpathyAvatar *avatar;
McAccount *account;
- EmpathyPresence *presence;
+ McPresence presence;
+ gchar *presence_message;
guint handle;
EmpathyCapabilities capabilities;
gboolean is_user;
PROP_AVATAR,
PROP_ACCOUNT,
PROP_PRESENCE,
+ PROP_PRESENCE_MESSAGE,
PROP_GROUPS,
PROP_SUBSCRIPTION,
PROP_HANDLE,
g_object_class_install_property (object_class,
PROP_PRESENCE,
- g_param_spec_object ("presence",
- "Contact presence",
- "Presence of contact",
- EMPATHY_TYPE_PRESENCE,
- G_PARAM_READWRITE));
+ g_param_spec_uint ("presence",
+ "Contact presence",
+ "Presence of contact",
+ MC_PRESENCE_UNSET,
+ LAST_MC_PRESENCE,
+ MC_PRESENCE_UNSET,
+ G_PARAM_READWRITE));
+ 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));
g_object_class_install_property (object_class,
PROP_HANDLE,
g_param_spec_uint ("handle",
"Contact Capabilities",
"Capabilities of the contact",
EMPATHY_TYPE_CAPABILITIES,
- 0,
+ EMPATHY_CAPABILITIES_UNKNOWN,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
g_free (priv->name);
g_free (priv->id);
+ g_free (priv->presence_message);
if (priv->avatar) {
empathy_avatar_unref (priv->avatar);
}
- if (priv->presence) {
- g_object_unref (priv->presence);
- }
-
if (priv->account) {
g_object_unref (priv->account);
}
g_value_set_object (value, priv->account);
break;
case PROP_PRESENCE:
- g_value_set_object (value, priv->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_PRESENCE:
empathy_contact_set_presence (EMPATHY_CONTACT (object),
- EMPATHY_PRESENCE (g_value_get_object (value)));
+ g_value_get_uint (value));
+ 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),
g_object_notify (G_OBJECT (contact), "account");
}
-EmpathyPresence *
+McPresence
empathy_contact_get_presence (EmpathyContact *contact)
{
EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
priv = GET_PRIV (contact);
}
void
-empathy_contact_set_presence (EmpathyContact *contact,
- EmpathyPresence *presence)
+empathy_contact_set_presence (EmpathyContact *contact,
+ McPresence presence)
{
EmpathyContactPriv *priv;
return;
}
- if (priv->presence) {
- g_object_unref (priv->presence);
- priv->presence = NULL;
- }
+ priv->presence = presence;
+
+ g_object_notify (G_OBJECT (contact), "presence");
+}
+
+const gchar *
+empathy_contact_get_presence_message (EmpathyContact *contact)
+{
+ EmpathyContactPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ priv = GET_PRIV (contact);
+
+ return priv->presence_message;
+}
+
+void
+empathy_contact_set_presence_message (EmpathyContact *contact,
+ const gchar *message)
+{
+ EmpathyContactPriv *priv = GET_PRIV (contact);
- if (presence) {
- priv->presence = g_object_ref (presence);
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+ if (!tp_strdiff (message, priv->presence_message)) {
+ return;
}
- g_object_notify (G_OBJECT (contact), "presence");
+ g_free (priv->presence_message);
+ priv->presence_message = g_strdup (message);
+
+ g_object_notify (G_OBJECT (contact), "presence-message");
}
guint
priv = GET_PRIV (contact);
- if (!priv->presence) {
- return FALSE;
- }
-
- return (empathy_presence_get_state (priv->presence) > MC_PRESENCE_OFFLINE);
+ return (priv->presence > MC_PRESENCE_OFFLINE);
}
const gchar *
priv = GET_PRIV (contact);
- if (priv->presence) {
- const gchar *status;
+ if (priv->presence_message) {
+ return priv->presence_message;
+ }
- status = empathy_presence_get_status (priv->presence);
- if (!status) {
- McPresence state;
+ return empathy_presence_get_default_message (priv->presence);
+}
- state = empathy_presence_get_state (priv->presence);
- status = empathy_presence_state_get_default_status (state);
- }
+gboolean
+empathy_contact_can_voip (EmpathyContact *contact)
+{
+ EmpathyContactPriv *priv;
- return status;
- }
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+
+ priv = GET_PRIV (contact);
- return empathy_presence_state_get_default_status (MC_PRESENCE_OFFLINE);
+ return priv->capabilities & (EMPATHY_CAPABILITIES_AUDIO |
+ EMPATHY_CAPABILITIES_VIDEO);
}
gboolean