void tpaw_keyring_set_account_password_async (TpAccount *account, const gchar *password, gboolean remember, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; const gchar *account_id; gchar *name; g_return_if_fail (TP_IS_ACCOUNT (account)); g_return_if_fail (password != NULL); simple = g_simple_async_result_new (G_OBJECT (account), callback, user_data, tpaw_keyring_set_account_password_async); account_id = tp_proxy_get_object_path (account) + strlen (TP_ACCOUNT_OBJECT_PATH_BASE); DEBUG ("Remembering password for %s", account_id); #ifdef HAVE_UOA { const gchar *provider; provider = tp_account_get_storage_provider (account); if (!tp_strdiff (provider, TPAW_UOA_PROVIDER)) { uoa_set_account_password (account, password, remember, simple); g_object_unref (simple); return; } } #endif name = g_strdup_printf (_("IM account password for %s (%s)"), tp_account_get_display_name (account), account_id); secret_password_store (&account_keyring_schema, remember ? NULL : SECRET_COLLECTION_SESSION, name, password, NULL, store_password_cb, simple, "account-id", account_id, "param-name", "password", NULL); g_free (name); }
static void new_chatroom_dialog_store_last_account (GSettings *gsettings, EmpathyAccountChooser *account_chooser) { TpAccount *account; const char *account_path; account = empathy_account_chooser_get_account (account_chooser); if (account == NULL) return; account_path = tp_proxy_get_object_path (account); DEBUG ("Storing account path '%s'", account_path); g_settings_set (gsettings, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT, "o", account_path); }
static void contact_manager_status_changed_cb (TpAccount *account, guint old_status, guint new_status, guint reason, gchar *dbus_error_name, GHashTable *details, EmpathyContactManager *self) { EmpathyContactManagerPriv *priv = GET_PRIV (self); EmpathyTpContactList *list; TpConnection *connection; if (new_status == TP_CONNECTION_STATUS_DISCONNECTED) /* No point to start tracking a connection which is about to die */ return; connection = tp_account_get_connection (account); if (connection == NULL || g_hash_table_lookup (priv->lists, connection)) { return; } DEBUG ("Adding new connection: %s", tp_proxy_get_object_path (TP_PROXY (connection))); list = empathy_tp_contact_list_new (connection); g_hash_table_insert (priv->lists, g_object_ref (connection), list); g_signal_connect (connection, "invalidated", G_CALLBACK (contact_manager_invalidated_cb), self); /* Connect signals */ g_signal_connect (list, "members-changed", G_CALLBACK (contact_manager_members_changed_cb), self); g_signal_connect (list, "pendings-changed", G_CALLBACK (contact_manager_pendings_changed_cb), self); g_signal_connect (list, "groups-changed", G_CALLBACK (contact_manager_groups_changed_cb), self); }
static void _empathy_account_set_connection (EmpathyAccount *account, const gchar *path) { EmpathyAccountPriv *priv = GET_PRIV (account); if (priv->connection != NULL) { const gchar *current; current = tp_proxy_get_object_path (priv->connection); if (!tp_strdiff (current, path)) return; } empathy_account_free_connection (account); if (tp_strdiff ("/", path)) { GError *error = NULL; priv->connection = tp_connection_new (priv->dbus, NULL, path, &error); if (priv->connection == NULL) { DEBUG ("Failed to create a new TpConnection: %s", error->message); g_error_free (error); } else { priv->connection_invalidated_id = g_signal_connect (priv->connection, "invalidated", G_CALLBACK (_empathy_account_connection_invalidated_cb), account); DEBUG ("Readying connection for %s", priv->unique_name); /* notify a change in the connection property when it's ready */ tp_connection_call_when_ready (priv->connection, empathy_account_connection_ready_cb, account); } } g_object_notify (G_OBJECT (account), "connection"); }
static void contact_manager_invalidated_cb (TpProxy *connection, guint domain, gint code, gchar *message, EmpathyContactManager *manager) { EmpathyContactManagerPriv *priv = GET_PRIV (manager); EmpathyTpContactList *list; DEBUG ("Removing connection: %s (%s)", tp_proxy_get_object_path (TP_PROXY (connection)), message); list = g_hash_table_lookup (priv->lists, connection); if (list) { empathy_tp_contact_list_remove_all (list); g_hash_table_remove (priv->lists, connection); } }
static TpAccount * find_account (TpAccountManager *mgr, const gchar *path) { GList *accounts, *l; TpAccount *found = NULL; accounts = tp_account_manager_dup_valid_accounts (mgr); for (l = accounts; l != NULL; l = g_list_next (l)) { if (!tp_strdiff (tp_proxy_get_object_path (l->data), path)) { found = l->data; break; } } g_list_free_full (accounts, g_object_unref); return found; }
static void contact_manager_remove_favourite (EmpathyContactList *manager, EmpathyContact *contact) { EmpathyContactManagerPriv *priv; TpAccount *account; const gchar *account_name; g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager)); g_return_if_fail (EMPATHY_IS_CONTACT (contact)); priv = GET_PRIV (manager); account = empathy_contact_get_account (contact); account_name = tp_proxy_get_object_path (TP_PROXY (account)); emp_cli_logger_call_remove_favourite_contact (priv->logger, -1, account_name, empathy_contact_get_id (contact), remove_favourite_contact_cb, NULL, NULL, G_OBJECT (manager)); }
void tpaw_keyring_delete_account_password_async (TpAccount *account, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; const gchar *account_id; g_return_if_fail (TP_IS_ACCOUNT (account)); simple = g_simple_async_result_new (G_OBJECT (account), callback, user_data, tpaw_keyring_delete_account_password_async); account_id = tp_proxy_get_object_path (account) + strlen (TP_ACCOUNT_OBJECT_PATH_BASE); DEBUG ("Deleting password for %s", account_id); #ifdef HAVE_UOA { const gchar *provider; provider = tp_account_get_storage_provider (account); if (!tp_strdiff (provider, TPAW_UOA_PROVIDER)) { /* I see no other way to forget the stored password than overwriting * with an empty one. */ uoa_set_account_password (account, "", FALSE, simple); g_object_unref (simple); return; } } #endif secret_password_clear (&account_keyring_schema, NULL, items_delete_cb, simple, "account-id", account_id, "param-name", "password", NULL); }
static void auth_cb (GObject *source, GAsyncResult *result, gpointer user_data) { TpChannel *channel = (TpChannel *) source; AuthContext *ctx = user_data; GError *error = NULL; if (!empathy_sasl_auth_finish (channel, result, &error)) { DEBUG ("SASL Mechanism error: %s", error->message); g_clear_error (&error); request_password (ctx); } else { DEBUG ("Auth on %s suceeded", tp_proxy_get_object_path (channel)); auth_context_done (ctx); } }
void tpaw_keyring_get_account_password_async (TpAccount *account, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; const gchar *account_id; g_return_if_fail (TP_IS_ACCOUNT (account)); g_return_if_fail (callback != NULL); simple = g_simple_async_result_new (G_OBJECT (account), callback, user_data, tpaw_keyring_get_account_password_async); account_id = tp_proxy_get_object_path (account) + strlen (TP_ACCOUNT_OBJECT_PATH_BASE); DEBUG ("Trying to get password for: %s", account_id); #ifdef HAVE_UOA { const gchar *provider; provider = tp_account_get_storage_provider (account); if (!tp_strdiff (provider, TPAW_UOA_PROVIDER)) { uoa_get_account_password (account, simple); g_object_unref (simple); return; } } #endif secret_password_lookup (&account_keyring_schema, NULL, lookup_item_cb, simple, "account-id", account_id, "param-name", "password", NULL); }
static void add_dispatch_operation_cb (TpSimpleApprover *self, TpAccount *account, TpConnection *connection, GList *channels, TpChannelDispatchOperation *cdo, TpAddDispatchOperationContext *context, gpointer user_data) { TpContact *target = NULL; GList *l; (void)account; /* suppress unused-parameter warning */ (void)connection; /* suppress unused-parameter warning */ (void)user_data; /* suppress unused-parameter warning */ g_print ("Approving this batch of channels:\n"); for (l = channels; l != NULL; l = g_list_next (l)) { TpChannel *channel = l->data; if (TP_IS_DBUS_TUBE_CHANNEL (channel)) { target = tp_channel_get_target_contact (channel); break; } } if (target == NULL) { g_critical ("Hmm. No 1-1 D-Bus tube in cdo %s, so why did we get it?", tp_proxy_get_object_path (cdo)); g_return_if_reached (); } tp_add_dispatch_operation_context_accept (context); show_dialog (self, cdo, target); }
static void process_tp_chat (EmpathyChatManager *self, EmpathyTpChat *tp_chat, TpAccount *account, gint64 user_action_time) { EmpathyChatManagerPriv *priv = GET_PRIV (self); EmpathyChat *chat = NULL; const gchar *id; EmpathyChatWindow *window; id = empathy_tp_chat_get_id (tp_chat); if (!tp_str_empty (id)) { chat = empathy_chat_window_find_chat (account, id, tp_text_channel_is_sms_channel ((TpTextChannel *) tp_chat)); } if (chat != NULL) { empathy_chat_set_tp_chat (chat, tp_chat); } else { GHashTable *chats = NULL; chat = empathy_chat_new (tp_chat); /* empathy_chat_new returns a floating reference as EmpathyChat is * a GtkWidget. This reference will be taken by a container * (a GtkNotebook) when we'll call empathy_chat_window_present_chat */ priv->num_displayed_chat++; DEBUG ("Chat displayed; we are now displaying %u chat", priv->num_displayed_chat); g_signal_emit (self, signals[DISPLAYED_CHATS_CHANGED], 0, priv->num_displayed_chat); /* Set the saved message in the channel if we have one. */ chats = g_hash_table_lookup (priv->messages, tp_proxy_get_object_path (account)); if (chats != NULL) { const gchar *msg = g_hash_table_lookup (chats, id); if (msg != NULL) empathy_chat_set_text (chat, msg); } g_object_weak_ref ((GObject *) chat, chat_destroyed_cb, self); } window = empathy_chat_window_present_chat (chat, user_action_time); if (priv->individual_mgr == NULL) { /* We want to cache it as soon it's created */ tp_g_signal_connect_object (window, "notify::individual-manager", G_CALLBACK (individual_mgr_cb), self, 0); } if (empathy_tp_chat_is_invited (tp_chat, NULL)) { /* We have been invited to the room. Add ourself as member as this * channel has been approved. */ tp_channel_join_async (TP_CHANNEL (tp_chat), "", join_cb, self); } }
static const char * get_pretty_conn_name (TpConnection *conn) { return tp_proxy_get_object_path (conn) + strlen (TP_CONN_OBJECT_PATH_BASE); }
static void log_manager_got_chats_cb (GObject *manager, GAsyncResult *result, gpointer user_data) { EmpathyLogWindow *window = user_data; GList *chats; GList *l; GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; GtkTreeIter iter; GError *error = NULL; gboolean select_account = FALSE; if (log_window == NULL) return; if (!tpl_log_manager_get_chats_finish (TPL_LOG_MANAGER (manager), result, &chats, &error)) { DEBUG ("%s. Aborting", error->message); g_error_free (error); return; } view = GTK_TREE_VIEW (window->treeview_chats); model = gtk_tree_view_get_model (view); selection = gtk_tree_view_get_selection (view); store = GTK_LIST_STORE (model); for (l = chats; l; l = l->next) { TplLogSearchHit *hit; hit = l->data; if (hit->account == NULL) continue; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_CHAT_ICON, "empathy-available", /* FIXME */ COL_CHAT_NAME, hit->chat_id, COL_CHAT_ACCOUNT, hit->account, COL_CHAT_ID, hit->chat_id, COL_CHAT_IS_CHATROOM, hit->is_chatroom, -1); if (window->selected_account != NULL && !tp_strdiff (tp_proxy_get_object_path (hit->account), tp_proxy_get_object_path (window->selected_account))) select_account = TRUE; /* FIXME: Update COL_CHAT_ICON/NAME */ if (hit->is_chatroom) { } else { } } tpl_log_manager_search_free (chats); /* Unblock signals */ g_signal_handlers_unblock_by_func (selection, log_window_chats_changed_cb, window); /* We display the selected account if we populate the model with chats from * this account. */ if (select_account) log_window_chats_set_selected (window); }
void empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self, EmpathyContact *contact) { EmpathyIndividualManagerPriv *priv; FolksBackendStore *backend_store; FolksBackend *backend; FolksPersonaStore *persona_store; GHashTable* details; GeeMap *persona_stores; TpAccount *account; const gchar *store_id; g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self)); g_return_if_fail (EMPATHY_IS_CONTACT (contact)); priv = GET_PRIV (self); /* We need to ref the contact since otherwise its linked TpHandle will be * destroyed. */ g_object_ref (contact); DEBUG ("adding individual from contact %s (%s)", empathy_contact_get_id (contact), empathy_contact_get_alias (contact)); account = empathy_contact_get_account (contact); store_id = tp_proxy_get_object_path (TP_PROXY (account)); /* Get the persona store to use */ backend_store = folks_backend_store_dup (); backend = folks_backend_store_dup_backend_by_name (backend_store, "telepathy"); if (backend == NULL) { g_warning ("Failed to add individual from contact: couldn't get " "'telepathy' backend"); goto finish; } persona_stores = folks_backend_get_persona_stores (backend); persona_store = gee_map_get (persona_stores, store_id); if (persona_store == NULL) { g_warning ("Failed to add individual from contact: couldn't get persona " "store '%s'", store_id); goto finish; } details = tp_asv_new ( "contact", G_TYPE_STRING, empathy_contact_get_id (contact), NULL); folks_individual_aggregator_add_persona_from_details ( priv->aggregator, NULL, persona_store, details, aggregator_add_persona_from_details_cb, contact); g_hash_table_unref (details); g_object_unref (persona_store); finish: tp_clear_object (&backend); tp_clear_object (&backend_store); }