diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-05-31 03:15:31 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-05-31 04:15:42 +0800 |
commit | 327b8e56ecbaca67d550802f2fac741a78d81eb8 (patch) | |
tree | 62b8a9f51ecdcbfeae7dcdef81c4420d65a7aedc | |
parent | f93b95e549591cc8302d894e44641f42751b7f67 (diff) | |
download | gsoc2013-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
-rw-r--r-- | libempathy-gtk/empathy-contact-list-store.c | 36 | ||||
-rw-r--r-- | libempathy-gtk/empathy-presence-chooser.c | 95 | ||||
-rw-r--r-- | libempathy-gtk/empathy-status-preset-dialog.c | 20 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 23 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 2 | ||||
-rw-r--r-- | libempathy/empathy-account-manager.c | 29 | ||||
-rw-r--r-- | libempathy/empathy-contact-monitor.c | 13 | ||||
-rw-r--r-- | libempathy/empathy-contact.c | 68 | ||||
-rw-r--r-- | libempathy/empathy-contact.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-idle.c | 134 | ||||
-rw-r--r-- | libempathy/empathy-idle.h | 10 | ||||
-rw-r--r-- | libempathy/empathy-status-presets.c | 34 | ||||
-rw-r--r-- | libempathy/empathy-status-presets.h | 12 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 99 | ||||
-rw-r--r-- | libempathy/empathy-utils.h | 6 | ||||
-rw-r--r-- | python/pyempathy/pyempathy.defs | 38 | ||||
-rw-r--r-- | python/pyempathygtk/pyempathygtk.defs | 12 | ||||
-rw-r--r-- | src/empathy-main-window.c | 35 | ||||
-rw-r--r-- | src/empathy-status-icon.c | 2 | ||||
-rw-r--r-- | src/empathy.c | 5 |
20 files changed, 370 insertions, 307 deletions
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c index a264d9ff7..8e3b7b34c 100644 --- a/libempathy-gtk/empathy-contact-list-store.c +++ b/libempathy-gtk/empathy-contact-list-store.c @@ -1309,28 +1309,6 @@ contact_list_store_get_group (EmpathyContactListStore *store, } } -static guint -contact_list_store_ordered_presence (McPresence state) -{ - switch (state) { - case MC_PRESENCE_UNSET: - case MC_PRESENCE_OFFLINE: - return 5; - case MC_PRESENCE_AVAILABLE: - return 0; - case MC_PRESENCE_AWAY: - return 2; - case MC_PRESENCE_EXTENDED_AWAY: - return 3; - case MC_PRESENCE_HIDDEN: - return 4; - case MC_PRESENCE_DO_NOT_DISTURB: - return 1; - default: - g_return_val_if_reached (6); - } -} - static gint contact_list_store_state_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, @@ -1341,7 +1319,6 @@ contact_list_store_state_sort_func (GtkTreeModel *model, gchar *name_a, *name_b; gboolean is_separator_a, is_separator_b; EmpathyContact *contact_a, *contact_b; - guint presence_a, presence_b; gtk_tree_model_get (model, iter_a, EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a, @@ -1377,16 +1354,11 @@ contact_list_store_state_sort_func (GtkTreeModel *model, /* If we managed to get this far, we can start looking at * the presences. */ - presence_a = empathy_contact_get_presence (EMPATHY_CONTACT (contact_a)); - presence_a = contact_list_store_ordered_presence (presence_a); - presence_b = empathy_contact_get_presence (EMPATHY_CONTACT (contact_b)); - presence_b = contact_list_store_ordered_presence (presence_b); + ret_val = tp_connection_presence_type_cmp_availability ( + empathy_contact_get_presence (EMPATHY_CONTACT (contact_a)), + empathy_contact_get_presence (EMPATHY_CONTACT (contact_b))); - if (presence_a < presence_b) { - ret_val = -1; - } else if (presence_a > presence_b) { - ret_val = 1; - } else { + if (ret_val == 0) { /* Fallback: compare by name */ ret_val = g_utf8_collate (name_a, name_b); } diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 17b39c07f..4fd524e64 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -34,7 +34,6 @@ #include <gdk/gdkkeysyms.h> #include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-enum-types.h> #include <libempathy/empathy-idle.h> #include <libempathy/empathy-utils.h> @@ -105,36 +104,40 @@ typedef struct { int block_changed; guint focus_out_idle_source; - McPresence state; + TpConnectionPresenceType state; PresenceChooserEntryType previous_type; - McPresence flash_state_1; - McPresence flash_state_2; + TpConnectionPresenceType flash_state_1; + TpConnectionPresenceType flash_state_2; guint flash_timeout_id; } EmpathyPresenceChooserPriv; /* States to be listed in the menu. * Each state has a boolean telling if it can have custom message */ -static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE, - MC_PRESENCE_DO_NOT_DISTURB, TRUE, - MC_PRESENCE_AWAY, TRUE, - MC_PRESENCE_HIDDEN, FALSE, - MC_PRESENCE_OFFLINE, FALSE}; +static struct { TpConnectionPresenceType state; + gboolean customisable; +} states[] = { { TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, TRUE } , + { TP_CONNECTION_PRESENCE_TYPE_BUSY, TRUE }, + { TP_CONNECTION_PRESENCE_TYPE_AWAY, TRUE }, + { TP_CONNECTION_PRESENCE_TYPE_HIDDEN, FALSE }, + { TP_CONNECTION_PRESENCE_TYPE_OFFLINE, FALSE}, + { TP_CONNECTION_PRESENCE_TYPE_UNSET, }, + }; static void presence_chooser_finalize (GObject *object); static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser); static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser); static void presence_chooser_flash_start (EmpathyPresenceChooser *chooser, - McPresence state_1, - McPresence state_2); + TpConnectionPresenceType state_1, + TpConnectionPresenceType state_2); static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, - McPresence state); + TpConnectionPresenceType state); static void presence_chooser_menu_add_item (GtkWidget *menu, const gchar *str, - McPresence state); + TpConnectionPresenceType state); static void presence_chooser_noncustom_activate_cb (GtkWidget *item, gpointer user_data); -static void presence_chooser_set_state (McPresence state, +static void presence_chooser_set_state (TpConnectionPresenceType state, const gchar *status); static void presence_chooser_custom_activate_cb (GtkWidget *item, gpointer user_data); @@ -160,7 +163,7 @@ presence_chooser_create_model (EmpathyPresenceChooser *self) store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, /* COL_STATE_ICON_NAME */ - MC_TYPE_PRESENCE, /* COL_STATE */ + G_TYPE_UINT, /* COL_STATE */ G_TYPE_STRING, /* COL_STATUS_TEXT */ G_TYPE_STRING, /* COL_DISPLAY_MARKUP */ G_TYPE_BOOLEAN, /* COL_STATUS_CUSTOMISABLE */ @@ -168,26 +171,25 @@ presence_chooser_create_model (EmpathyPresenceChooser *self) custom_message = g_strdup_printf ("<i>%s</i>", _("Custom Message...")); - for (i = 0; i < G_N_ELEMENTS (states); i += 2) { + for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) { GList *list, *l; const char *status, *icon_name; - status = empathy_presence_get_default_message (states[i]); - icon_name = empathy_icon_name_for_presence (states[i]); + status = empathy_presence_get_default_message (states[i].state); + icon_name = empathy_icon_name_for_presence (states[i].state); gtk_list_store_insert_with_values (store, NULL, -1, COL_STATE_ICON_NAME, icon_name, - COL_STATE, states[i], + COL_STATE, states[i].state, COL_STATUS_TEXT, status, COL_DISPLAY_MARKUP, status, - COL_STATUS_CUSTOMISABLE, states[i+1], + COL_STATUS_CUSTOMISABLE, states[i].customisable, COL_TYPE, ENTRY_TYPE_BUILTIN, -1); - if (states[i+1]) { - + if (states[i].customisable) { /* Set custom messages if wanted */ - list = empathy_status_presets_get (states[i], -1); + list = empathy_status_presets_get (states[i].state, -1); list = g_list_sort (list, (GCompareFunc) g_utf8_collate); for (l = list; l; l = l->next) { gtk_list_store_insert_with_values (store, @@ -279,7 +281,7 @@ static gboolean presence_chooser_is_preset (EmpathyPresenceChooser *self) { EmpathyPresenceChooserPriv *priv = GET_PRIV (self); - McPresence state; + TpConnectionPresenceType state; const char *status; GList *presets, *l; gboolean match = FALSE; @@ -407,17 +409,14 @@ mc_set_custom_state (EmpathyPresenceChooser *self) /* update the status with MC */ status = gtk_entry_get_text (GTK_ENTRY (entry)); - DEBUG ("Sending state to MC-> %s (%s)\n", - g_enum_get_value (g_type_class_peek (MC_TYPE_PRESENCE), - priv->state)->value_name, - status); + DEBUG ("Sending state to MC-> %d (%s)\n", priv->state, status); empathy_idle_set_presence (priv->idle, priv->state, status); } static void ui_set_custom_state (EmpathyPresenceChooser *self, - McPresence state, + TpConnectionPresenceType state, const char *status) { EmpathyPresenceChooserPriv *priv = GET_PRIV (self); @@ -462,7 +461,7 @@ presence_chooser_entry_icon_release_cb (EmpathyPresenceChooser *self, } else { PresenceChooserEntryType type; - McPresence state; + TpConnectionPresenceType state; const char *status; type = presence_chooser_get_entry_type (self); @@ -554,7 +553,7 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data) EmpathyPresenceChooserPriv *priv = GET_PRIV (self); GtkTreeIter iter; char *icon_name; - McPresence new_state; + TpConnectionPresenceType new_state; gboolean customisable = TRUE; PresenceChooserEntryType type = -1; GtkWidget *entry; @@ -823,8 +822,8 @@ static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser) { EmpathyPresenceChooserPriv *priv; - McPresence state; - McPresence flash_state; + TpConnectionPresenceType state; + TpConnectionPresenceType flash_state; const gchar *status; GtkTreeModel *model; GtkTreeIter iter; @@ -846,7 +845,7 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser) valid; valid = gtk_tree_model_iter_next (model, &iter)) { int m_type; - McPresence m_state; + TpConnectionPresenceType m_state; char *m_status; gtk_tree_model_get (model, &iter, @@ -892,7 +891,7 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser) ui_set_custom_state (chooser, state, status); } - if (flash_state != MC_PRESENCE_UNSET) { + if (flash_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) { presence_chooser_flash_start (chooser, state, flash_state); } else { @@ -904,7 +903,7 @@ static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) { EmpathyPresenceChooserPriv *priv; - McPresence state; + TpConnectionPresenceType state; static gboolean on = FALSE; GtkWidget *entry; @@ -929,8 +928,8 @@ presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) static void presence_chooser_flash_start (EmpathyPresenceChooser *chooser, - McPresence state_1, - McPresence state_2) + TpConnectionPresenceType state_1, + TpConnectionPresenceType state_2) { EmpathyPresenceChooserPriv *priv; @@ -950,7 +949,7 @@ presence_chooser_flash_start (EmpathyPresenceChooser *chooser, static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, - McPresence state) + TpConnectionPresenceType state) { EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser); GtkWidget *entry; @@ -984,21 +983,21 @@ empathy_presence_chooser_create_menu (void) menu = gtk_menu_new (); - for (i = 0; i < G_N_ELEMENTS (states); i += 2) { + for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) { GList *list, *l; - status = empathy_presence_get_default_message (states[i]); + status = empathy_presence_get_default_message (states[i].state); presence_chooser_menu_add_item (menu, status, - states[i]); + states[i].state); - if (states[i+1]) { + if (states[i].customisable) { /* Set custom messages if wanted */ - list = empathy_status_presets_get (states[i], 5); + list = empathy_status_presets_get (states[i].state, 5); for (l = list; l; l = l->next) { presence_chooser_menu_add_item (menu, l->data, - states[i]); + states[i].state); } g_list_free (list); } @@ -1029,7 +1028,7 @@ empathy_presence_chooser_create_menu (void) static void presence_chooser_menu_add_item (GtkWidget *menu, const gchar *str, - McPresence state) + TpConnectionPresenceType state) { GtkWidget *item; GtkWidget *image; @@ -1061,7 +1060,7 @@ static void presence_chooser_noncustom_activate_cb (GtkWidget *item, gpointer user_data) { - McPresence state; + TpConnectionPresenceType state; const gchar *status; status = g_object_get_data (G_OBJECT (item), "status"); @@ -1071,7 +1070,7 @@ presence_chooser_noncustom_activate_cb (GtkWidget *item, } static void -presence_chooser_set_state (McPresence state, +presence_chooser_set_state (TpConnectionPresenceType state, const gchar *status) { EmpathyIdle *idle; diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index b011b5db3..7ac13ad38 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -39,8 +39,6 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-enum-types.h> - #include <libempathy/empathy-utils.h> #include <libempathy/empathy-status-presets.h> @@ -54,10 +52,10 @@ G_DEFINE_TYPE (EmpathyStatusPresetDialog, empathy_status_preset_dialog, GTK_TYPE_DIALOG); -static McPresence states[] = { - MC_PRESENCE_AVAILABLE, - MC_PRESENCE_DO_NOT_DISTURB, - MC_PRESENCE_AWAY +static TpConnectionPresenceType states[] = { + TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, + TP_CONNECTION_PRESENCE_TYPE_BUSY, + TP_CONNECTION_PRESENCE_TYPE_AWAY, }; typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv; @@ -172,7 +170,7 @@ status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self) int i; store = gtk_list_store_new (ADD_COMBO_N_COLS, - MC_TYPE_PRESENCE, /* ADD_COMBO_STATE */ + G_TYPE_UINT, /* ADD_COMBO_STATE */ G_TYPE_STRING, /* ADD_COMBO_ICON_NAME */ G_TYPE_STRING, /* ADD_COMBO_STATUS */ G_TYPE_STRING); /* ADD_COMBO_DEFAULT_TEXT */ @@ -222,7 +220,7 @@ status_preset_dialog_status_edited (GtkCellRendererText *renderer, GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; - McPresence state; + TpConnectionPresenceType state; char *old_status; gboolean valid; @@ -269,7 +267,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) GtkCellRenderer *renderer; store = gtk_list_store_new (PRESETS_STORE_N_COLS, - MC_TYPE_PRESENCE, /* PRESETS_STORE_STATE */ + G_TYPE_UINT, /* PRESETS_STORE_STATE */ G_TYPE_STRING, /* PRESETS_STORE_ICON_NAME */ G_TYPE_STRING); /* PRESETS_STORE_STATUS */ @@ -315,7 +313,7 @@ status_preset_dialog_preset_remove (GtkButton *button, GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; - McPresence state; + TpConnectionPresenceType state; char *status; selection = gtk_tree_view_get_selection ( @@ -418,7 +416,7 @@ status_preset_dialog_add_preset (GtkWidget *widget, GtkTreeModel *model; GtkTreeIter iter; GtkWidget *entry; - McPresence state, cstate; + TpConnectionPresenceType state, cstate; const char *status; char *cstatus; gboolean valid, match = FALSE; diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index d9f4ae0dd..3f3961fea 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -194,24 +194,25 @@ empathy_icon_name_from_account (McAccount *account) } const gchar * -empathy_icon_name_for_presence (McPresence presence) +empathy_icon_name_for_presence (TpConnectionPresenceType presence) { switch (presence) { - case MC_PRESENCE_AVAILABLE: + case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE: return EMPATHY_IMAGE_AVAILABLE; - case MC_PRESENCE_DO_NOT_DISTURB: + case TP_CONNECTION_PRESENCE_TYPE_BUSY: return EMPATHY_IMAGE_BUSY; - case MC_PRESENCE_AWAY: + case TP_CONNECTION_PRESENCE_TYPE_AWAY: return EMPATHY_IMAGE_AWAY; - case MC_PRESENCE_EXTENDED_AWAY: + case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY: return EMPATHY_IMAGE_EXT_AWAY; - case MC_PRESENCE_HIDDEN: + case TP_CONNECTION_PRESENCE_TYPE_HIDDEN: return EMPATHY_IMAGE_HIDDEN; - case MC_PRESENCE_OFFLINE: - case MC_PRESENCE_UNSET: + case TP_CONNECTION_PRESENCE_TYPE_OFFLINE: + case TP_CONNECTION_PRESENCE_TYPE_ERROR: + case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN: return EMPATHY_IMAGE_OFFLINE; - default: - g_assert_not_reached (); + case TP_CONNECTION_PRESENCE_TYPE_UNSET: + return NULL; } return NULL; @@ -220,7 +221,7 @@ empathy_icon_name_for_presence (McPresence presence) const gchar * empathy_icon_name_for_contact (EmpathyContact *contact) { - McPresence presence; + TpConnectionPresenceType presence; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), EMPATHY_IMAGE_OFFLINE); diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index c80c79e8c..0b5b17f28 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -77,7 +77,7 @@ GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui, /* Pixbufs */ const gchar * empathy_icon_name_from_account (McAccount *account); -const gchar * empathy_icon_name_for_presence (McPresence presence); +const gchar * empathy_icon_name_for_presence (TpConnectionPresenceType presence); const gchar * empathy_icon_name_for_contact (EmpathyContact *contact); GdkPixbuf * empathy_pixbuf_from_data (gchar *data, gsize data_size); 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, diff --git a/python/pyempathy/pyempathy.defs b/python/pyempathy/pyempathy.defs index f438882d9..2b56496ed 100644 --- a/python/pyempathy/pyempathy.defs +++ b/python/pyempathy/pyempathy.defs @@ -765,7 +765,7 @@ (define-method get_presence (of-object "EmpathyContact") (c-name "empathy_contact_get_presence") - (return-type "McPresence") + (return-type "TpConnectionPresenceType") ) (define-method set_presence @@ -773,7 +773,7 @@ (c-name "empathy_contact_set_presence") (return-type "none") (parameters - '("McPresence" "presence") + '("TpConnectionPresenceType" "presence") ) ) @@ -1358,7 +1358,7 @@ (define-method get_state (of-object "EmpathyIdle") (c-name "empathy_idle_get_state") - (return-type "McPresence") + (return-type "TpConnectionPresenceType") ) (define-method set_state @@ -1366,7 +1366,7 @@ (c-name "empathy_idle_set_state") (return-type "none") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") ) ) @@ -1388,7 +1388,7 @@ (define-method get_flash_state (of-object "EmpathyIdle") (c-name "empathy_idle_get_flash_state") - (return-type "McPresence") + (return-type "TpConnectionPresenceType") ) (define-method set_flash_state @@ -1396,7 +1396,7 @@ (c-name "empathy_idle_set_flash_state") (return-type "none") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") ) ) @@ -1405,7 +1405,7 @@ (c-name "empathy_idle_set_presence") (return-type "none") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") '("const-gchar*" "status") ) ) @@ -1965,7 +1965,7 @@ (c-name "empathy_status_presets_get") (return-type "GList*") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") '("gint" "max_number") ) ) @@ -1974,7 +1974,7 @@ (c-name "empathy_status_presets_set_last") (return-type "none") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") '("const-gchar*" "status") ) ) @@ -1983,7 +1983,7 @@ (c-name "empathy_status_presets_remove") (return-type "none") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") '("const-gchar*" "status") ) ) @@ -1995,7 +1995,7 @@ (define-function status_presets_get_default_state (c-name "empathy_status_presets_get_default_state") - (return-type "McPresence") + (return-type "TpConnectionPresenceType") ) (define-function status_presets_get_default_status @@ -2007,7 +2007,7 @@ (c-name "empathy_status_presets_set_default") (return-type "none") (parameters - '("McPresence" "state") + '("TpConnectionPresenceType" "state") '("const-gchar*" "status") ) ) @@ -2060,6 +2060,14 @@ ) ) +(define-function time_to_string_relative + (c-name "empathy_time_to_string_relative") + (return-type "gchar*") + (parameters + '("time_t" "t") + ) +) + ;; From empathy-tp-call.h @@ -2720,7 +2728,7 @@ (c-name "empathy_presence_get_default_message") (return-type "const-gchar*") (parameters - '("McPresence" "presence") + '("TpConnectionPresenceType" "presence") ) ) @@ -2728,13 +2736,13 @@ (c-name "empathy_presence_to_str") (return-type "const-gchar*") (parameters - '("McPresence" "presence") + '("TpConnectionPresenceType" "presence") ) ) (define-function presence_from_str (c-name "empathy_presence_from_str") - (return-type "McPresence") + (return-type "TpConnectionPresenceType") (parameters '("const-gchar*" "str") ) diff --git a/python/pyempathygtk/pyempathygtk.defs b/python/pyempathygtk/pyempathygtk.defs index b0ce54ae3..c519e8643 100644 --- a/python/pyempathygtk/pyempathygtk.defs +++ b/python/pyempathygtk/pyempathygtk.defs @@ -231,6 +231,7 @@ '("edit-id" "EMPATHY_CONTACT_WIDGET_EDIT_ID") '("edit-groups" "EMPATHY_CONTACT_WIDGET_EDIT_GROUPS") '("for-tooltip" "EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP") + '("show-location" "EMPATHY_CONTACT_WIDGET_SHOW_LOCATION") ) ) @@ -360,6 +361,15 @@ ) ) +(define-function account_widget_set_default_focus + (c-name "empathy_account_widget_set_default_focus") + (return-type "none") + (parameters + '("GtkBuilder*" "gui") + '("const-gchar*" "entry") + ) +) + (define-function account_widget_generic_new (c-name "empathy_account_widget_generic_new") (is-constructor-of "EmpathyAccountWidgetGeneric") @@ -1808,7 +1818,7 @@ (c-name "empathy_icon_name_for_presence") (return-type "const-gchar*") (parameters - '("McPresence" "presence") + '("TpConnectionPresenceType" "presence") ) ) diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index d2cb832f2..e53807236 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -563,8 +563,8 @@ main_window_connection_changed_cb (EmpathyAccountManager *manager, static void main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor, EmpathyContact *contact, - McPresence current, - McPresence previous, + TpConnectionPresenceType current, + TpConnectionPresenceType previous, EmpathyMainWindow *window) { McAccount *account; @@ -577,18 +577,25 @@ main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor, return; } - if (previous < MC_PRESENCE_AVAILABLE && current > MC_PRESENCE_OFFLINE) { - /* someone is logging in */ - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_CONTACT_CONNECTED); - return; - } - - if (previous > MC_PRESENCE_OFFLINE && current < MC_PRESENCE_AVAILABLE) { - /* someone is logging off */ - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_CONTACT_DISCONNECTED); - } + if (tp_connection_presence_type_cmp_availability (previous, + TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) + { + /* contact was online */ + if (tp_connection_presence_type_cmp_availability (current, + TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) + /* someone is logging off */ + empathy_sound_play (GTK_WIDGET (window->window), + EMPATHY_SOUND_CONTACT_DISCONNECTED); + } + else + { + /* contact was offline */ + if (tp_connection_presence_type_cmp_availability (current, + TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) + /* someone is logging in */ + empathy_sound_play (GTK_WIDGET (window->window), + EMPATHY_SOUND_CONTACT_CONNECTED); + } } static void diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index 5d45e83f3..cca2557a8 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -195,7 +195,7 @@ status_icon_update_icon (EmpathyStatusIcon *icon) if (priv->event && priv->showing_event_icon) { icon_name = priv->event->icon_name; } else { - McPresence state; + TpConnectionPresenceType state; state = empathy_idle_get_state (priv->idle); icon_name = empathy_icon_name_for_presence (state); diff --git a/src/empathy.c b/src/empathy.c index 91d77a5e6..72cccb55e 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -545,7 +545,8 @@ main (int argc, char *argv[]) EMPATHY_PREFS_AUTOCONNECT, &autoconnect); if (autoconnect && ! no_connect && - empathy_idle_get_state (idle) <= MC_PRESENCE_OFFLINE) { + tp_connection_presence_type_cmp_availability (empathy_idle_get_state + (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) { empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE); } @@ -583,7 +584,7 @@ main (int argc, char *argv[]) gtk_main (); - empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE); + empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE); g_object_unref (mc); g_object_unref (idle); |