static void status_icon_update_tooltip (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (priv->event) { gchar *tooltip = NULL; if (priv->event->message != NULL) tooltip = g_markup_printf_escaped ("<i>%s</i>\n%s", priv->event->header, priv->event->message); else tooltip = g_markup_printf_escaped ("<i>%s</i>", priv->event->header); gtk_status_icon_set_tooltip_markup (priv->icon, tooltip); g_free (tooltip); } else { TpConnectionPresenceType type; gchar *msg; type = tp_account_manager_get_most_available_presence ( priv->account_manager, NULL, &msg); if (!EMP_STR_EMPTY (msg)) { gtk_status_icon_set_tooltip_text (priv->icon, msg); } else { gtk_status_icon_set_tooltip_text (priv->icon, empathy_presence_get_default_message (type)); } g_free (msg); } }
static void status_icon_update_icon (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); const gchar *icon_name; if (priv->event && priv->showing_event_icon) { icon_name = priv->event->icon_name; } else { TpConnectionPresenceType state; state = tp_account_manager_get_most_available_presence ( priv->account_manager, NULL, NULL); /* An unset presence type here doesn't make sense. Force it * to be offline. */ if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET) { state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE; } icon_name = empathy_icon_name_for_presence (state); } if (icon_name != NULL) gtk_status_icon_set_from_icon_name (priv->icon, icon_name); }
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 _update_presence_message (MnbPeoplePanel *self) { MnbPeoplePanelPrivate *priv = GET_PRIVATE (self); gchar *message; tp_account_manager_get_most_available_presence (priv->am, NULL, &message); mx_label_set_text (MX_LABEL (priv->presence_message), message); g_free (message); }
static void account_manager_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { EmpathyIdle *idle = user_data; TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object); EmpathyIdlePriv *priv; TpConnectionPresenceType state; gchar *status, *status_message; GList *accounts, *l; GError *error = NULL; /* In case we've been finalized before reading this callback */ if (idle_singleton == NULL) return; priv = GET_PRIV (idle); priv->ready = TRUE; if (!tp_account_manager_prepare_finish (account_manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_error_free (error); return; } state = tp_account_manager_get_most_available_presence (priv->manager, &status, &status_message); idle_presence_changed_cb (account_manager, state, status, status_message, idle); accounts = tp_account_manager_get_valid_accounts (priv->manager); for (l = accounts; l != NULL; l = l->next) { empathy_signal_connect_weak (l->data, "status-changed", G_CALLBACK (account_status_changed_cb), G_OBJECT (idle)); } g_list_free (accounts); g_free (status); g_free (status_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); }
/* Change the RequestedPresence of a newly created account to ensure that it * is actually connected. */ void empathy_connect_new_account (TpAccount *account, TpAccountManager *account_manager) { TpConnectionPresenceType presence; gchar *status, *message; /* only force presence if presence was offline, unknown or unset */ presence = tp_account_get_requested_presence (account, NULL, NULL); switch (presence) { case TP_CONNECTION_PRESENCE_TYPE_OFFLINE: case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN: case TP_CONNECTION_PRESENCE_TYPE_UNSET: presence = tp_account_manager_get_most_available_presence ( account_manager, &status, &message); if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE) /* Global presence is offline; we force it so user doesn't have to * manually change the presence to connect his new account. */ presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE; tp_account_request_presence_async (account, presence, status, NULL, NULL, NULL); g_free (status); g_free (message); break; case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE: case TP_CONNECTION_PRESENCE_TYPE_AWAY: case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY: case TP_CONNECTION_PRESENCE_TYPE_HIDDEN: case TP_CONNECTION_PRESENCE_TYPE_BUSY: case TP_CONNECTION_PRESENCE_TYPE_ERROR: default: /* do nothing if the presence is not offline */ break; } }
gboolean empathy_notify_manager_notification_is_enabled (EmpathyNotifyManager *self) { EmpathyNotifyManagerPriv *priv = GET_PRIV (self); GSettings *gsettings = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA); TpConnectionPresenceType presence; gboolean ret = FALSE; if (!g_settings_get_boolean (gsettings, EMPATHY_PREFS_NOTIFICATIONS_ENABLED)) goto finally; if (!tp_account_manager_is_prepared (priv->account_manager, TP_ACCOUNT_MANAGER_FEATURE_CORE)) { DEBUG ("account manager is not ready yet; display the notification"); ret = TRUE; goto finally; } presence = tp_account_manager_get_most_available_presence ( priv->account_manager, NULL, NULL); if (presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE && presence != TP_CONNECTION_PRESENCE_TYPE_UNSET) { if (g_settings_get_boolean (gsettings, EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY)) goto finally; } ret = TRUE; finally: g_object_unref (gsettings); return ret; }
static void _account_manager_ready (TpAccountManager *am, GAsyncResult *res, gpointer user_data) { AnerleyPresenceChooser *self = user_data; AnerleyPresenceChooserPrivate *priv = GET_PRIVATE (self); 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; } priv->presence = tp_account_manager_get_most_available_presence (priv->am, NULL, NULL); update_combox_index (self); }