static void update_join_button_sensitivity (EmpathyNewChatroomDialog *dialog) { const gchar *room; const gchar *protocol; gboolean sensitive = FALSE; room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room)); protocol = tp_account_get_protocol (dialog->account); if (EMP_STR_EMPTY (room)) goto out; if (!tp_strdiff (protocol, "irc") && (!tp_strdiff (room, "#") || !tp_strdiff (room, "&"))) { goto out; } if (dialog->account == NULL) goto out; if (tp_account_get_connection_status (dialog->account, NULL) != TP_CONNECTION_STATUS_CONNECTED) goto out; sensitive = TRUE; out: gtk_widget_set_sensitive (dialog->button_join, sensitive); }
const gchar * empathy_account_get_error_message (TpAccount *account, gboolean *user_requested) { const gchar *dbus_error; const gchar *message; const GHashTable *details = NULL; TpConnectionStatusReason reason; dbus_error = tp_account_get_detailed_error (account, &details); if (user_requested != NULL) { if (tp_asv_get_boolean (details, "user-requested", NULL)) *user_requested = TRUE; else *user_requested = FALSE; } message = empathy_dbus_error_name_get_default_message (dbus_error); if (message != NULL) return message; tp_account_get_connection_status (account, &reason); DEBUG ("Don't understand error '%s'; fallback to the status reason (%u)", dbus_error, reason); return empathy_status_reason_get_default_message (reason); }
static void new_chatroom_dialog_select_last_account (GSettings *gsettings, EmpathyAccountChooser *account_chooser) { const gchar *account_path; TpAccountManager *manager; TpSimpleClientFactory *factory; TpAccount *account; TpConnectionStatus status; account_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT); DEBUG ("Selecting account path '%s'", account_path); manager = tp_account_manager_dup (); factory = tp_proxy_get_factory (manager); account = tp_simple_client_factory_ensure_account (factory, account_path, NULL, NULL); if (account != NULL) { status = tp_account_get_connection_status (account, NULL); if (status == TP_CONNECTION_STATUS_CONNECTED) { empathy_account_chooser_set_account (account_chooser, account); } g_object_unref (account); } g_object_unref (manager); }
/** * empathy_account_chooser_filter_supports_multichat: * @account: a #TpAccount * @user_data: user data or %NULL * * An #EmpathyAccountChooserFilterFunc that returns accounts that both * support multiuser text chat and are connected. * * Return value: TRUE if @account both supports muc and is connected */ static gboolean empathy_account_chooser_filter_supports_multichat (TpAccount *account, gpointer user_data) { TpConnection *connection; EmpathyDispatcher *dispatcher; GList *classes; if (tp_account_get_connection_status (account, NULL) != TP_CONNECTION_STATUS_CONNECTED) return FALSE; /* check if CM supports multiuser text chat */ connection = tp_account_get_connection (account); if (connection == NULL) return FALSE; dispatcher = empathy_dispatcher_dup_singleton (); classes = empathy_dispatcher_find_requestable_channel_classes (dispatcher, connection, TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_ROOM, NULL); g_object_unref (dispatcher); if (classes == NULL) return FALSE; g_list_free (classes); return TRUE; }
/* This function returns %TRUE if EmpathyIdle considers the account * @account as having just connected recently. Otherwise, it returns * %FALSE. In doubt, %FALSE is returned. */ gboolean empathy_idle_account_is_just_connected (EmpathyIdle *idle, TpAccount *account) { EmpathyIdlePriv *priv = GET_PRIV (idle); GTimeVal val; gpointer ptr; glong t; if (tp_account_get_connection_status (account, NULL) != TP_CONNECTION_STATUS_CONNECTED) { return FALSE; } ptr = g_hash_table_lookup (priv->connect_times, account); if (ptr == NULL) { return FALSE; } t = GPOINTER_TO_INT (ptr); g_get_current_time (&val); return (val.tv_sec - t) < ACCOUNT_IS_JUST_CONNECTED_SECONDS; }
/** * empathy_account_chooser_filter_supports_multichat: * @account: a #TpAccount * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result * @callback_data: data passed to the @callback * @user_data: user data or %NULL * * An #EmpathyAccountChooserFilterFunc that returns accounts that both * support multiuser text chat and are connected. * * Returns (via the callback) TRUE if @account both supports muc and is connected */ void empathy_account_chooser_filter_supports_chatrooms ( TpAccount *account, EmpathyAccountChooserFilterResultCallback callback, gpointer callback_data, gpointer user_data) { TpConnection *connection; FilterCallbackData *cb_data; GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 }; if (tp_account_get_connection_status (account, NULL) != TP_CONNECTION_STATUS_CONNECTED) { callback (FALSE, callback_data); return; } /* check if CM supports multiuser text chat */ connection = tp_account_get_connection (account); if (connection == NULL) { callback (FALSE, callback_data); return; } cb_data = g_slice_new0 (FilterCallbackData); cb_data->callback = callback; cb_data->user_data = callback_data; tp_proxy_prepare_async (connection, features, conn_prepared_cb, cb_data); }
static void presence_chooser_constructed (GObject *self) { PresenceChooserPrivate *priv = GET_PRIVATE (self); g_signal_connect_swapped (priv->account, "status-changed", G_CALLBACK (_status_changed), self); _status_changed (PRESENCE_CHOOSER (self), 0, tp_account_get_connection_status (priv->account, NULL), 0, priv->account); }
/** * empathy_account_chooser_filter_is_connected: * @account: a #TpAccount * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result * @callback_data: data passed to the @callback * @user_data: user data or %NULL * * A useful #EmpathyAccountChooserFilterFunc that one could pass into * empathy_account_chooser_set_filter() and only show connected accounts. * * Returns (via the callback) TRUE is @account is connected */ void empathy_account_chooser_filter_is_connected (TpAccount *account, EmpathyAccountChooserFilterResultCallback callback, gpointer callback_data, gpointer user_data) { gboolean is_connected = tp_account_get_connection_status (account, NULL) == TP_CONNECTION_STATUS_CONNECTED; callback (is_connected, callback_data); }
gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting) { TpAccountManager *manager; GList *accounts, *l; gboolean out_connecting = FALSE; gboolean out_connected = FALSE; manager = tp_account_manager_dup (); if (G_UNLIKELY (!tp_proxy_is_prepared (manager, TP_ACCOUNT_MANAGER_FEATURE_CORE))) g_critical (G_STRLOC ": %s called before AccountManager ready", G_STRFUNC); accounts = tp_account_manager_dup_valid_accounts (manager); for (l = accounts; l != NULL; l = l->next) { TpConnectionStatus s = tp_account_get_connection_status ( TP_ACCOUNT (l->data), NULL); if (s == TP_CONNECTION_STATUS_CONNECTING) out_connecting = TRUE; else if (s == TP_CONNECTION_STATUS_CONNECTED) out_connected = TRUE; if (out_connecting && out_connected) break; } g_list_free_full (accounts, g_object_unref); g_object_unref (manager); if (connecting != NULL) *connecting = out_connecting; return out_connected; }
static void update_join_button_sensitivity (EmpathyNewChatroomDialog *dialog) { const gchar *room; gboolean sensitive = FALSE; room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room)); if (EMP_STR_EMPTY (room)) goto out; if (dialog->account == NULL) goto out; if (tp_account_get_connection_status (dialog->account, NULL) != TP_CONNECTION_STATUS_CONNECTED) goto out; sensitive = TRUE; out: gtk_widget_set_sensitive (dialog->button_join, sensitive); }
/* This function returns %TRUE if EmpathyPresenceManager considers the account * @account as having just connected recently. Otherwise, it returns * %FALSE. In doubt, %FALSE is returned. */ gboolean empathy_presence_manager_account_is_just_connected ( EmpathyPresenceManager *self, TpAccount *account) { GTimeVal val; gpointer ptr; glong t; if (tp_account_get_connection_status (account, NULL) != TP_CONNECTION_STATUS_CONNECTED) return FALSE; ptr = g_hash_table_lookup (self->priv->connect_times, account); if (ptr == NULL) return FALSE; t = GPOINTER_TO_INT (ptr); g_get_current_time (&val); return (val.tv_sec - t) < ACCOUNT_IS_JUST_CONNECTED_SECONDS; }
static void _update_placeholder_state (MnbPeoplePanel *self) { MnbPeoplePanelPrivate *priv = GET_PRIVATE (self); gint accounts_available = 0; gint accounts_online = 0; GList *accounts; for (accounts = tp_account_manager_get_valid_accounts (priv->am); accounts != NULL; accounts = g_list_delete_link (accounts, accounts)) { TpAccount *account = accounts->data; if (!tp_account_is_enabled (account)) continue; accounts_available++; if (tp_account_get_connection_status (account, NULL) == TP_CONNECTION_STATUS_CONNECTED) accounts_online++; } /* There is something in the model, hide all placeholders */ if (clutter_model_get_first_iter (CLUTTER_MODEL (priv->model))) { clutter_actor_hide (priv->no_people_tile); clutter_actor_hide (priv->everybody_offline_tile); /* Ensure content stuff is visible */ clutter_actor_show (priv->main_scroll_view); if (accounts_available > 0 && accounts_online == 0) { clutter_actor_show (priv->offline_banner); } else { clutter_actor_hide (priv->offline_banner); } } else { /* Hide real content stuff */ clutter_actor_hide (priv->main_scroll_view); if (accounts_online == 0) { if (accounts_available == 0) { clutter_actor_show (priv->no_people_tile); clutter_actor_hide (priv->everybody_offline_tile); clutter_actor_hide (priv->offline_banner); } else { clutter_actor_show (priv->offline_banner); clutter_actor_hide (priv->no_people_tile); clutter_actor_hide (priv->everybody_offline_tile); } } else { clutter_actor_show (priv->everybody_offline_tile); clutter_actor_hide (priv->no_people_tile); clutter_actor_hide (priv->offline_banner); } } }