static void _combo_index_changed (AnerleyPresenceChooser *self, GParamSpec *pspec, gpointer user_data) { AnerleyPresenceChooserPrivate *priv = GET_PRIVATE (self); MxComboBox *combo = MX_COMBO_BOX (self); gint index = mx_combo_box_get_index (combo); ComboEntry *entry; gchar *message; if (index >= 0) entry = &g_array_index (priv->combo_entries, ComboEntry, index); else return; priv->presence = entry->presence; /* Get current message to not modify it */ tp_account_manager_get_most_available_presence (priv->am, NULL, &message); tp_account_manager_set_all_requested_presences (priv->am, entry->presence, presences[entry->presence].status, message); g_free (message); }
static void panel_menu_item_activate_presence (GtkWidget *menuitem, TpAccountManager *account_manager) { PanelSessionManagerPresenceType presence_type; TpConnectionPresenceType tp_presence_type; const char *status; char *message; presence_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "panel-menu-presence")); panel_session_manager_set_presence (panel_session_manager_get (), presence_type); tp_presence_type = tp_account_manager_get_most_available_presence (account_manager, NULL, &message); if (tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_UNSET || tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE || tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_UNKNOWN || tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_ERROR) goto free_message; if (presence_type == PANEL_SESSION_MANAGER_PRESENCE_AVAILABLE) { tp_presence_type = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE; status = "available"; } else if (presence_type == PANEL_SESSION_MANAGER_PRESENCE_BUSY) { tp_presence_type = TP_CONNECTION_PRESENCE_TYPE_BUSY; status = "busy"; } else goto free_message; tp_account_manager_set_all_requested_presences (account_manager, tp_presence_type, status, message); free_message: g_free (message); }
static void _account_manager_ready_cb (TpAccountManager *am, GAsyncResult *res, gpointer userdata) { TpConnectionPresenceType type = (TpConnectionPresenceType)GPOINTER_TO_INT (userdata); GError *error = NULL; if (!tp_proxy_prepare_finish (TP_PROXY (am), res, &error)) { g_warning (G_STRLOC ": Error preparing account manager: %s", error->message); g_error_free (error); return; } tp_account_manager_set_all_requested_presences (am, type, NULL, NULL); }
static void empathy_presence_manager_do_set_presence (EmpathyPresenceManager *self, TpConnectionPresenceType status_type, const gchar *status_message) { const gchar *status; g_assert (status_type > 0 && status_type < NUM_TP_CONNECTION_PRESENCE_TYPES); status = presence_type_to_status[status_type]; g_return_if_fail (status != NULL); /* We possibly should be sure that the account manager is prepared, but * sometimes this isn't possible, like when exiting. In other words, * we need a callback to empathy_presence_manager_set_presence to be sure the * presence is set on all accounts successfully. * However, in practice, this is fine as we've already prepared the * account manager here in _init. */ tp_account_manager_set_all_requested_presences (self->priv->manager, status_type, status, status_message); }