aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-05-31 03:15:31 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-05-31 04:15:42 +0800
commit327b8e56ecbaca67d550802f2fac741a78d81eb8 (patch)
tree62b8a9f51ecdcbfeae7dcdef81c4420d65a7aedc /libempathy
parentf93b95e549591cc8302d894e44641f42751b7f67 (diff)
downloadgsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.gz
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.bz2
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.lz
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.xz
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.zst
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.zip
Remove usage of McPresence as much as possible
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-account-manager.c29
-rw-r--r--libempathy/empathy-contact-monitor.c13
-rw-r--r--libempathy/empathy-contact.c68
-rw-r--r--libempathy/empathy-contact.h4
-rw-r--r--libempathy/empathy-idle.c134
-rw-r--r--libempathy/empathy-idle.h10
-rw-r--r--libempathy/empathy-status-presets.c34
-rw-r--r--libempathy/empathy-status-presets.h12
-rw-r--r--libempathy/empathy-utils.c99
-rw-r--r--libempathy/empathy-utils.h6
10 files changed, 238 insertions, 171 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index ed8ee996f..dd0a72f59 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -44,7 +44,7 @@ typedef struct {
typedef struct {
TpConnection *connection;
- McPresence presence;
+ TpConnectionPresenceType presence;
TpConnectionStatus status;
gboolean is_enabled;
@@ -424,10 +424,35 @@ account_status_changed_cb (MissionControl *mc,
EmpathyAccountManager *manager)
{
ChangedSignalData *data;
+ TpConnectionPresenceType tp_presence;
+
+ switch (presence)
+ {
+ case MC_PRESENCE_OFFLINE:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+ break;
+ case MC_PRESENCE_AVAILABLE:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
+ break;
+ case MC_PRESENCE_AWAY:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_AWAY;
+ break;
+ case MC_PRESENCE_EXTENDED_AWAY:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY;
+ break;
+ case MC_PRESENCE_HIDDEN:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_HIDDEN;
+ break;
+ case MC_PRESENCE_DO_NOT_DISTURB:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_BUSY;
+ break;
+ default:
+ tp_presence = TP_CONNECTION_PRESENCE_TYPE_UNSET;
+ }
data = g_slice_new0 (ChangedSignalData);
data->status = status;
- data->presence = presence;
+ data->presence = tp_presence;
data->reason = reason;
data->unique_name = g_strdup (unique_name);
data->manager = g_object_ref (manager);
diff --git a/libempathy/empathy-contact-monitor.c b/libempathy/empathy-contact-monitor.c
index 5ec069fcd..f41b8bd5c 100644
--- a/libempathy/empathy-contact-monitor.c
+++ b/libempathy/empathy-contact-monitor.c
@@ -21,7 +21,6 @@
#include "config.h"
#include <glib-object.h>
-#include <libmissioncontrol/mc-enum-types.h>
#include "empathy-contact-monitor.h"
#include "empathy-contact-list.h"
@@ -61,9 +60,9 @@ G_DEFINE_TYPE (EmpathyContactMonitor, empathy_contact_monitor, G_TYPE_OBJECT);
static void
contact_monitor_presence_changed_cb (EmpathyContact *contact,
- McPresence current_presence,
- McPresence previous_presence,
- EmpathyContactMonitor *self)
+ TpConnectionPresenceType current_presence,
+ TpConnectionPresenceType previous_presence,
+ EmpathyContactMonitor *self)
{
g_signal_emit (self, signals[CONTACT_PRESENCE_CHANGED], 0, contact,
current_presence, previous_presence);
@@ -335,11 +334,11 @@ empathy_contact_monitor_class_init (EmpathyContactMonitorClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- _empathy_marshal_VOID__OBJECT_ENUM_ENUM,
+ _empathy_marshal_VOID__OBJECT_UINT_UINT,
G_TYPE_NONE,
3, EMPATHY_TYPE_CONTACT,
- MC_TYPE_PRESENCE,
- MC_TYPE_PRESENCE);
+ G_TYPE_UINT,
+ G_TYPE_UINT);
signals[CONTACT_PRESENCE_MESSAGE_CHANGED] =
g_signal_new ("contact-presence-message-changed",
G_TYPE_FROM_CLASS (klass),
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 9e8e2715b..eac087e2e 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -26,7 +26,6 @@
#include <glib/gi18n-lib.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-enum-types.h>
#include "empathy-contact.h"
#include "empathy-account-manager.h"
@@ -44,7 +43,7 @@ typedef struct {
gchar *id;
gchar *name;
EmpathyAvatar *avatar;
- McPresence presence;
+ TpConnectionPresenceType presence;
gchar *presence_message;
guint handle;
EmpathyCapabilities capabilities;
@@ -99,10 +98,11 @@ tp_contact_notify_cb (TpContact *tp_contact,
if (!tp_strdiff (param->name, "alias"))
g_object_notify (contact, "name");
else if (!tp_strdiff (param->name, "presence-type")) {
- McPresence presence;
+ TpConnectionPresenceType presence;
presence = empathy_contact_get_presence (EMPATHY_CONTACT (contact));
- g_signal_emit (contact, signals[PRESENCE_CHANGED], 0, presence, priv->presence);
+ g_signal_emit (contact, signals[PRESENCE_CHANGED], 0, presence,
+ priv->presence);
priv->presence = presence;
g_object_notify (contact, "presence");
}
@@ -191,9 +191,9 @@ empathy_contact_class_init (EmpathyContactClass *class)
g_param_spec_uint ("presence",
"Contact presence",
"Presence of contact",
- MC_PRESENCE_UNSET,
- LAST_MC_PRESENCE,
- MC_PRESENCE_UNSET,
+ TP_CONNECTION_PRESENCE_TYPE_UNSET,
+ NUM_TP_CONNECTION_PRESENCE_TYPES,
+ TP_CONNECTION_PRESENCE_TYPE_UNSET,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
@@ -246,10 +246,10 @@ empathy_contact_class_init (EmpathyContactClass *class)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- _empathy_marshal_VOID__ENUM_ENUM,
+ _empathy_marshal_VOID__UINT_UINT,
G_TYPE_NONE,
- 2, MC_TYPE_PRESENCE,
- MC_TYPE_PRESENCE);
+ 2, G_TYPE_UINT,
+ G_TYPE_UINT);
g_type_class_add_private (object_class, sizeof (EmpathyContactPriv));
}
@@ -594,54 +594,28 @@ empathy_contact_get_connection (EmpathyContact *contact)
return NULL;
}
-static McPresence
-presence_type_to_mc_presence (TpConnectionPresenceType type)
-{
- switch (type)
- {
- case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
- case TP_CONNECTION_PRESENCE_TYPE_ERROR:
- return MC_PRESENCE_UNSET;
- case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
- return MC_PRESENCE_OFFLINE;
- case TP_CONNECTION_PRESENCE_TYPE_UNSET:
- case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
- return MC_PRESENCE_AVAILABLE;
- case TP_CONNECTION_PRESENCE_TYPE_AWAY:
- return MC_PRESENCE_AWAY;
- case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
- return MC_PRESENCE_EXTENDED_AWAY;
- case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
- return MC_PRESENCE_HIDDEN;
- case TP_CONNECTION_PRESENCE_TYPE_BUSY:
- return MC_PRESENCE_DO_NOT_DISTURB;
- }
-
- return MC_PRESENCE_UNSET;
-}
-
-McPresence
+TpConnectionPresenceType
empathy_contact_get_presence (EmpathyContact *contact)
{
EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact),
+ TP_CONNECTION_PRESENCE_TYPE_UNSET);
priv = GET_PRIV (contact);
if (priv->tp_contact != NULL)
- return presence_type_to_mc_presence (tp_contact_get_presence_type (
- priv->tp_contact));
+ return tp_contact_get_presence_type (priv->tp_contact);
return priv->presence;
}
void
empathy_contact_set_presence (EmpathyContact *contact,
- McPresence presence)
+ TpConnectionPresenceType presence)
{
EmpathyContactPriv *priv;
- McPresence old_presence;
+ TpConnectionPresenceType old_presence;
g_return_if_fail (EMPATHY_IS_CONTACT (contact));
@@ -789,7 +763,15 @@ empathy_contact_is_online (EmpathyContact *contact)
{
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- return (empathy_contact_get_presence (contact) > MC_PRESENCE_OFFLINE);
+ switch (empathy_contact_get_presence(contact))
+ {
+ case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+ case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+ case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+ return FALSE;
+ default:
+ return TRUE;
+ }
}
const gchar *
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index fecb96648..0e6cfe251 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -80,9 +80,9 @@ void empathy_contact_set_avatar (EmpathyContact *contact,
EmpathyAvatar *avatar);
McAccount * empathy_contact_get_account (EmpathyContact *contact);
TpConnection * empathy_contact_get_connection (EmpathyContact *contact);
-McPresence empathy_contact_get_presence (EmpathyContact *contact);
+TpConnectionPresenceType empathy_contact_get_presence (EmpathyContact *contact);
void empathy_contact_set_presence (EmpathyContact *contact,
- McPresence presence);
+ TpConnectionPresenceType presence);
const gchar * empathy_contact_get_presence_message (EmpathyContact *contact);
void empathy_contact_set_presence_message (EmpathyContact *contact,
const gchar *message);
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index d52ac9df2..dbc1473e8 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -45,14 +45,14 @@ typedef struct {
DBusGProxy *gs_proxy;
DBusGProxy *nm_proxy;
- McPresence state;
+ TpConnectionPresenceType state;
gchar *status;
- McPresence flash_state;
+ TpConnectionPresenceType flash_state;
gboolean auto_away;
gboolean use_nm;
- McPresence away_saved_state;
- McPresence nm_saved_state;
+ TpConnectionPresenceType away_saved_state;
+ TpConnectionPresenceType nm_saved_state;
gchar *nm_saved_status;
gboolean is_idle;
@@ -83,7 +83,7 @@ static EmpathyIdle * idle_singleton = NULL;
static void
idle_presence_changed_cb (MissionControl *mc,
- McPresence state,
+ TpConnectionPresenceType state,
gchar *status,
EmpathyIdle *idle)
{
@@ -112,7 +112,7 @@ idle_ext_away_cb (EmpathyIdle *idle)
priv = GET_PRIV (idle);
DEBUG ("Going to extended autoaway");
- empathy_idle_set_state (idle, MC_PRESENCE_EXTENDED_AWAY);
+ empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY);
priv->ext_away_timeout = 0;
return FALSE;
@@ -160,9 +160,9 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
is_idle ? "yes" : "no");
if (!priv->auto_away ||
- (priv->nm_saved_state == MC_PRESENCE_UNSET &&
- (priv->state <= MC_PRESENCE_OFFLINE ||
- priv->state == MC_PRESENCE_HIDDEN))) {
+ (priv->nm_saved_state == TP_CONNECTION_PRESENCE_TYPE_UNSET &&
+ (priv->state <= TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
+ priv->state == TP_CONNECTION_PRESENCE_TYPE_HIDDEN))) {
/* We don't want to go auto away OR we explicitely asked to be
* offline, nothing to do here */
priv->is_idle = is_idle;
@@ -170,12 +170,12 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
}
if (is_idle && !priv->is_idle) {
- McPresence new_state;
+ TpConnectionPresenceType new_state;
/* We are now idle */
idle_ext_away_start (idle);
- if (priv->nm_saved_state != MC_PRESENCE_UNSET) {
+ if (priv->nm_saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
/* We are disconnected, when coming back from away
* we want to restore the presence before the
* disconnection. */
@@ -184,9 +184,9 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
priv->away_saved_state = priv->state;
}
- new_state = MC_PRESENCE_AWAY;
- if (priv->state == MC_PRESENCE_EXTENDED_AWAY) {
- new_state = MC_PRESENCE_EXTENDED_AWAY;
+ new_state = TP_CONNECTION_PRESENCE_TYPE_AWAY;
+ if (priv->state == TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY) {
+ new_state = TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY;
}
DEBUG ("Going to autoaway. Saved state=%d, new state=%d",
@@ -198,9 +198,9 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
idle_ext_away_stop (idle);
- if (priv->away_saved_state == MC_PRESENCE_AWAY ||
- priv->away_saved_state == MC_PRESENCE_EXTENDED_AWAY) {
- priv->away_saved_state = MC_PRESENCE_AVAILABLE;
+ if (priv->away_saved_state == TP_CONNECTION_PRESENCE_TYPE_AWAY ||
+ priv->away_saved_state == TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY) {
+ priv->away_saved_state = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
new_status = NULL;
} else {
new_status = priv->status;
@@ -213,7 +213,7 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
priv->away_saved_state,
new_status);
- priv->away_saved_state = MC_PRESENCE_UNSET;
+ priv->away_saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
}
priv->is_idle = is_idle;
@@ -248,7 +248,7 @@ idle_nm_state_change_cb (DBusGProxy *proxy,
priv->nm_saved_state = priv->state;
g_free (priv->nm_saved_status);
priv->nm_saved_status = g_strdup (priv->status);
- empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE);
+ empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
}
else if (!old_nm_connected && new_nm_connected) {
/* We are now connected */
@@ -257,7 +257,7 @@ idle_nm_state_change_cb (DBusGProxy *proxy,
empathy_idle_set_presence (idle,
priv->nm_saved_state,
priv->nm_saved_status);
- priv->nm_saved_state = MC_PRESENCE_UNSET;
+ priv->nm_saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
g_free (priv->nm_saved_status);
priv->nm_saved_status = NULL;
}
@@ -382,11 +382,11 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
g_object_class_install_property (object_class,
PROP_STATE,
- g_param_spec_enum ("state",
+ g_param_spec_uint ("state",
"state",
"state",
- MC_TYPE_PRESENCE,
- MC_PRESENCE_AVAILABLE,
+ 0, NUM_TP_CONNECTION_PRESENCE_TYPES,
+ TP_CONNECTION_PRESENCE_TYPE_UNSET,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_STATUS,
@@ -397,11 +397,11 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_FLASH_STATE,
- g_param_spec_enum ("flash-state",
+ g_param_spec_uint ("flash-state",
"flash-state",
"flash-state",
- MC_TYPE_PRESENCE,
- MC_PRESENCE_UNSET,
+ 0, NUM_TP_CONNECTION_PRESENCE_TYPES,
+ TP_CONNECTION_PRESENCE_TYPE_UNSET,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
@@ -423,6 +423,32 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
g_type_class_add_private (object_class, sizeof (EmpathyIdlePriv));
}
+static TpConnectionPresenceType
+empathy_idle_get_actual_presence (EmpathyIdle *idle, GError **error)
+{
+ McPresence presence;
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ presence = mission_control_get_presence_actual (priv->mc, error);
+
+ switch (presence) {
+ case MC_PRESENCE_OFFLINE:
+ return TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+ case MC_PRESENCE_AVAILABLE:
+ return TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
+ case MC_PRESENCE_AWAY:
+ return TP_CONNECTION_PRESENCE_TYPE_AWAY;
+ case MC_PRESENCE_EXTENDED_AWAY:
+ return TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY;
+ case MC_PRESENCE_HIDDEN:
+ return TP_CONNECTION_PRESENCE_TYPE_HIDDEN;
+ case MC_PRESENCE_DO_NOT_DISTURB:
+ return TP_CONNECTION_PRESENCE_TYPE_BUSY;
+ default:
+ return TP_CONNECTION_PRESENCE_TYPE_UNSET;
+ }
+}
+
static void
empathy_idle_init (EmpathyIdle *idle)
{
@@ -434,11 +460,11 @@ empathy_idle_init (EmpathyIdle *idle)
idle->priv = priv;
priv->is_idle = FALSE;
priv->mc = empathy_mission_control_dup_singleton ();
- priv->state = mission_control_get_presence_actual (priv->mc, &error);
+ priv->state = empathy_idle_get_actual_presence (idle, &error);
if (error) {
DEBUG ("Error getting actual presence: %s", error->message);
- priv->state = MC_PRESENCE_UNSET;
+ priv->state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
g_clear_error (&error);
}
priv->status = mission_control_get_presence_message_actual (priv->mc, &error);
@@ -502,7 +528,7 @@ empathy_idle_dup_singleton (void)
return g_object_new (EMPATHY_TYPE_IDLE, NULL);
}
-McPresence
+TpConnectionPresenceType
empathy_idle_get_state (EmpathyIdle *idle)
{
EmpathyIdlePriv *priv;
@@ -514,7 +540,7 @@ empathy_idle_get_state (EmpathyIdle *idle)
void
empathy_idle_set_state (EmpathyIdle *idle,
- McPresence state)
+ TpConnectionPresenceType state)
{
EmpathyIdlePriv *priv;
@@ -548,7 +574,7 @@ empathy_idle_set_status (EmpathyIdle *idle,
empathy_idle_set_presence (idle, priv->state, status);
}
-McPresence
+TpConnectionPresenceType
empathy_idle_get_flash_state (EmpathyIdle *idle)
{
EmpathyIdlePriv *priv;
@@ -560,7 +586,7 @@ empathy_idle_get_flash_state (EmpathyIdle *idle)
void
empathy_idle_set_flash_state (EmpathyIdle *idle,
- McPresence state)
+ TpConnectionPresenceType state)
{
EmpathyIdlePriv *priv;
@@ -568,15 +594,49 @@ empathy_idle_set_flash_state (EmpathyIdle *idle,
priv->flash_state = state;
- if (state == MC_PRESENCE_UNSET) {
+ if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET) {
}
g_object_notify (G_OBJECT (idle), "flash-state");
}
+static void
+empathy_idle_do_set_presence (EmpathyIdle *idle,
+ TpConnectionPresenceType state,
+ const gchar *status)
+{
+ McPresence mc_state = MC_PRESENCE_UNSET;
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ switch (state) {
+ case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+ mc_state = MC_PRESENCE_OFFLINE;
+ break;
+ case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
+ mc_state = MC_PRESENCE_AVAILABLE;
+ break;
+ case TP_CONNECTION_PRESENCE_TYPE_AWAY:
+ mc_state = MC_PRESENCE_AWAY;
+ break;
+ case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
+ mc_state = MC_PRESENCE_EXTENDED_AWAY;
+ break;
+ case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
+ mc_state = MC_PRESENCE_HIDDEN;
+ break;
+ case TP_CONNECTION_PRESENCE_TYPE_BUSY:
+ mc_state = MC_PRESENCE_DO_NOT_DISTURB;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ mission_control_set_presence (priv->mc, mc_state, status, NULL, NULL);
+}
+
void
empathy_idle_set_presence (EmpathyIdle *idle,
- McPresence state,
+ TpConnectionPresenceType state,
const gchar *status)
{
EmpathyIdlePriv *priv;
@@ -608,7 +668,7 @@ empathy_idle_set_presence (EmpathyIdle *idle,
return;
}
- mission_control_set_presence (priv->mc, state, status, NULL, NULL);
+ empathy_idle_do_set_presence (idle, state, status);
}
gboolean
@@ -669,10 +729,10 @@ empathy_idle_set_use_nm (EmpathyIdle *idle,
idle_nm_state_change_cb (priv->nm_proxy, nm_status, idle);
} else {
priv->nm_connected = TRUE;
- if (priv->nm_saved_state != MC_PRESENCE_UNSET) {
+ if (priv->nm_saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
empathy_idle_set_state (idle, priv->nm_saved_state);
}
- priv->nm_saved_state = MC_PRESENCE_UNSET;
+ priv->nm_saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
}
g_object_notify (G_OBJECT (idle), "use-nm");
diff --git a/libempathy/empathy-idle.h b/libempathy/empathy-idle.h
index 7296f7cd4..0f7f23deb 100644
--- a/libempathy/empathy-idle.h
+++ b/libempathy/empathy-idle.h
@@ -49,17 +49,17 @@ struct _EmpathyIdleClass {
GType empathy_idle_get_type (void) G_GNUC_CONST;
EmpathyIdle *empathy_idle_dup_singleton (void);
-McPresence empathy_idle_get_state (EmpathyIdle *idle);
+TpConnectionPresenceType empathy_idle_get_state (EmpathyIdle *idle);
void empathy_idle_set_state (EmpathyIdle *idle,
- McPresence state);
+ TpConnectionPresenceType state);
const gchar *empathy_idle_get_status (EmpathyIdle *idle);
void empathy_idle_set_status (EmpathyIdle *idle,
const gchar *status);
-McPresence empathy_idle_get_flash_state (EmpathyIdle *idle);
+TpConnectionPresenceType empathy_idle_get_flash_state (EmpathyIdle *idle);
void empathy_idle_set_flash_state (EmpathyIdle *idle,
- McPresence state);
+ TpConnectionPresenceType state);
void empathy_idle_set_presence (EmpathyIdle *idle,
- McPresence state,
+ TpConnectionPresenceType state,
const gchar *status);
gboolean empathy_idle_get_auto_away (EmpathyIdle *idle);
void empathy_idle_set_auto_away (EmpathyIdle *idle,
diff --git a/libempathy/empathy-status-presets.c b/libempathy/empathy-status-presets.c
index 315794070..9f9a2030b 100644
--- a/libempathy/empathy-status-presets.c
+++ b/libempathy/empathy-status-presets.c
@@ -46,23 +46,23 @@
typedef struct {
gchar *status;
- McPresence state;
+ TpConnectionPresenceType state;
} StatusPreset;
-static StatusPreset *status_preset_new (McPresence state,
+static StatusPreset *status_preset_new (TpConnectionPresenceType state,
const gchar *status);
static void status_preset_free (StatusPreset *status);
static void status_presets_file_parse (const gchar *filename);
-const gchar * status_presets_get_state_as_str (McPresence state);
+const gchar * status_presets_get_state_as_str (TpConnectionPresenceType state);
static gboolean status_presets_file_save (void);
-static void status_presets_set_default (McPresence state,
+static void status_presets_set_default (TpConnectionPresenceType state,
const gchar *status);
static GList *presets = NULL;
static StatusPreset *default_preset = NULL;
static StatusPreset *
-status_preset_new (McPresence state,
+status_preset_new (TpConnectionPresenceType state,
const gchar *status)
{
StatusPreset *preset;
@@ -116,7 +116,7 @@ status_presets_file_parse (const gchar *filename)
while (node) {
if (strcmp ((gchar *) node->name, "status") == 0 ||
strcmp ((gchar *) node->name, "default") == 0) {
- McPresence state;
+ TpConnectionPresenceType state;
gchar *status;
gchar *state_str;
StatusPreset *preset;
@@ -153,7 +153,7 @@ status_presets_file_parse (const gchar *filename)
/* Use the default if not set */
if (!default_preset) {
- status_presets_set_default (MC_PRESENCE_OFFLINE, NULL);
+ status_presets_set_default (TP_CONNECTION_PRESENCE_TYPE_OFFLINE, NULL);
}
DEBUG ("Parsed %d status presets", g_list_length (presets));
@@ -195,10 +195,10 @@ status_presets_file_save (void)
GList *l;
gchar *dir;
gchar *file;
- gint count[LAST_MC_PRESENCE];
+ gint count[NUM_TP_CONNECTION_PRESENCE_TYPES];
gint i;
- for (i = 0; i < LAST_MC_PRESENCE; i++) {
+ for (i = 0; i < NUM_TP_CONNECTION_PRESENCE_TYPES; i++) {
count[i] = 0;
}
@@ -253,7 +253,7 @@ status_presets_file_save (void)
}
GList *
-empathy_status_presets_get (McPresence state,
+empathy_status_presets_get (TpConnectionPresenceType state,
gint max_number)
{
GList *list = NULL;
@@ -282,7 +282,7 @@ empathy_status_presets_get (McPresence state,
}
void
-empathy_status_presets_set_last (McPresence state,
+empathy_status_presets_set_last (TpConnectionPresenceType state,
const gchar *status)
{
GList *l;
@@ -323,7 +323,7 @@ empathy_status_presets_set_last (McPresence state,
}
void
-empathy_status_presets_remove (McPresence state,
+empathy_status_presets_remove (TpConnectionPresenceType state,
const gchar *status)
{
StatusPreset *preset;
@@ -350,16 +350,16 @@ empathy_status_presets_reset (void)
presets = NULL;
- status_presets_set_default (MC_PRESENCE_AVAILABLE, NULL);
+ status_presets_set_default (TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, NULL);
status_presets_file_save ();
}
-McPresence
+TpConnectionPresenceType
empathy_status_presets_get_default_state (void)
{
if (!default_preset) {
- return MC_PRESENCE_OFFLINE;
+ return TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
}
return default_preset->state;
@@ -377,7 +377,7 @@ empathy_status_presets_get_default_status (void)
}
static void
-status_presets_set_default (McPresence state,
+status_presets_set_default (TpConnectionPresenceType state,
const gchar *status)
{
if (default_preset) {
@@ -388,7 +388,7 @@ status_presets_set_default (McPresence state,
}
void
-empathy_status_presets_set_default (McPresence state,
+empathy_status_presets_set_default (TpConnectionPresenceType state,
const gchar *status)
{
status_presets_set_default (state, status);
diff --git a/libempathy/empathy-status-presets.h b/libempathy/empathy-status-presets.h
index e562ada43..335dbcfcb 100644
--- a/libempathy/empathy-status-presets.h
+++ b/libempathy/empathy-status-presets.h
@@ -23,21 +23,21 @@
#ifndef __EMPATHY_STATUS_PRESETS_H__
#define __EMPATHY_STATUS_PRESETS_H__
-#include <libmissioncontrol/mission-control.h>
+#include <telepathy-glib/enums.h>
G_BEGIN_DECLS
void empathy_status_presets_get_all (void);
-GList * empathy_status_presets_get (McPresence state,
+GList * empathy_status_presets_get (TpConnectionPresenceType state,
gint max_number);
-void empathy_status_presets_set_last (McPresence state,
+void empathy_status_presets_set_last (TpConnectionPresenceType state,
const gchar *status);
-void empathy_status_presets_remove (McPresence state,
+void empathy_status_presets_remove (TpConnectionPresenceType state,
const gchar *status);
void empathy_status_presets_reset (void);
-McPresence empathy_status_presets_get_default_state (void);
+TpConnectionPresenceType empathy_status_presets_get_default_state (void);
const gchar * empathy_status_presets_get_default_status (void);
-void empathy_status_presets_set_default (McPresence state,
+void empathy_status_presets_set_default (TpConnectionPresenceType state,
const gchar *status);
void empathy_status_presets_clear_default (void);
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index c0d4f12e4..b5c3a0e7e 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -35,6 +35,7 @@
#include <telepathy-glib/connection.h>
#include <telepathy-glib/channel.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/util.h>
#include "empathy-utils.h"
#include "empathy-contact-manager.h"
@@ -48,6 +49,28 @@
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include "empathy-debug.h"
+/* Translation between presence types and string */
+static struct {
+ gchar *name;
+ TpConnectionPresenceType type;
+} presence_types[] = {
+ { "available", TP_CONNECTION_PRESENCE_TYPE_AVAILABLE },
+ { "busy", TP_CONNECTION_PRESENCE_TYPE_BUSY },
+ { "away", TP_CONNECTION_PRESENCE_TYPE_AWAY },
+ { "ext_away", TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY },
+ { "hidden", TP_CONNECTION_PRESENCE_TYPE_HIDDEN },
+ { "offline", TP_CONNECTION_PRESENCE_TYPE_OFFLINE },
+ { "unset", TP_CONNECTION_PRESENCE_TYPE_UNSET },
+ { "unknown", TP_CONNECTION_PRESENCE_TYPE_UNKNOWN },
+ { "error", TP_CONNECTION_PRESENCE_TYPE_ERROR },
+ /* alternative names */
+ { "dnd", TP_CONNECTION_PRESENCE_TYPE_BUSY },
+ { "brb", TP_CONNECTION_PRESENCE_TYPE_AWAY },
+ { "xa", TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY },
+ { NULL, },
+};
+
+
void
empathy_init (void)
@@ -244,73 +267,51 @@ empathy_mission_control_dup_singleton (void)
}
const gchar *
-empathy_presence_get_default_message (McPresence presence)
+empathy_presence_get_default_message (TpConnectionPresenceType presence)
{
switch (presence) {
- case MC_PRESENCE_AVAILABLE:
+ case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
return _("Available");
- case MC_PRESENCE_DO_NOT_DISTURB:
+ case TP_CONNECTION_PRESENCE_TYPE_BUSY:
return _("Busy");
- case MC_PRESENCE_AWAY:
- case MC_PRESENCE_EXTENDED_AWAY:
+ case TP_CONNECTION_PRESENCE_TYPE_AWAY:
+ case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
return _("Away");
- case MC_PRESENCE_HIDDEN:
+ case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
return _("Hidden");
- case MC_PRESENCE_OFFLINE:
- case MC_PRESENCE_UNSET:
+ case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
return _("Offline");
- default:
- g_assert_not_reached ();
+ case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+ case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+ case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+ return NULL;
}
return NULL;
}
const gchar *
-empathy_presence_to_str (McPresence presence)
+empathy_presence_to_str (TpConnectionPresenceType presence)
{
- switch (presence) {
- case MC_PRESENCE_AVAILABLE:
- return "available";
- case MC_PRESENCE_DO_NOT_DISTURB:
- return "busy";
- case MC_PRESENCE_AWAY:
- return "away";
- case MC_PRESENCE_EXTENDED_AWAY:
- return "ext_away";
- case MC_PRESENCE_HIDDEN:
- return "hidden";
- case MC_PRESENCE_OFFLINE:
- return "offline";
- case MC_PRESENCE_UNSET:
- return "unset";
- default:
- g_assert_not_reached ();
- }
+ int i;
+
+ for (i = 0 ; presence_types[i].name != NULL; i++)
+ if (presence == presence_types[i].type)
+ return presence_types[i].name;
return NULL;
}
-McPresence
+TpConnectionPresenceType
empathy_presence_from_str (const gchar *str)
{
- if (strcmp (str, "available") == 0) {
- return MC_PRESENCE_AVAILABLE;
- } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
- return MC_PRESENCE_DO_NOT_DISTURB;
- } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
- return MC_PRESENCE_AWAY;
- } else if ((strcmp (str, "xa") == 0) || (strcmp (str, "ext_away") == 0)) {
- return MC_PRESENCE_EXTENDED_AWAY;
- } else if (strcmp (str, "hidden") == 0) {
- return MC_PRESENCE_HIDDEN;
- } else if (strcmp (str, "offline") == 0) {
- return MC_PRESENCE_OFFLINE;
- } else if (strcmp (str, "unset") == 0) {
- return MC_PRESENCE_UNSET;
- }
+ int i;
+
+ for (i = 0 ; presence_types[i].name != NULL; i++)
+ if (!tp_strdiff (str, presence_types[i].name))
+ return presence_types[i].type;
- return MC_PRESENCE_UNSET;
+ return TP_CONNECTION_PRESENCE_TYPE_UNSET;
}
gchar *
@@ -364,15 +365,15 @@ empathy_proxy_equal (gconstpointer a,
gboolean
empathy_check_available_state (void)
{
- McPresence presence;
+ TpConnectionPresenceType presence;
EmpathyIdle *idle;
idle = empathy_idle_dup_singleton ();
presence = empathy_idle_get_state (idle);
g_object_unref (idle);
- if (presence != MC_PRESENCE_AVAILABLE &&
- presence != MC_PRESENCE_UNSET) {
+ if (presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
+ presence != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
return FALSE;
}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 0b056b942..d36503c7f 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -69,9 +69,9 @@ guint empathy_account_hash (gconstpointer key);
gboolean empathy_account_equal (gconstpointer a,
gconstpointer b);
MissionControl *empathy_mission_control_dup_singleton (void);
-const gchar * empathy_presence_get_default_message (McPresence presence);
-const gchar * empathy_presence_to_str (McPresence presence);
-McPresence empathy_presence_from_str (const gchar *str);
+const gchar * empathy_presence_get_default_message (TpConnectionPresenceType presence);
+const gchar * empathy_presence_to_str (TpConnectionPresenceType presence);
+TpConnectionPresenceType empathy_presence_from_str (const gchar *str);
gchar * empathy_file_lookup (const gchar *filename,
const gchar *subdir);
gboolean empathy_proxy_equal (gconstpointer a,