static gboolean chat_conversations_list_accounts_key_equal_func (gconstpointer a, gconstpointer b) { TpAccount *account_a = TP_ACCOUNT (a); TpAccount *account_b = TP_ACCOUNT (b); const gchar *path_suffix_a; const gchar *path_suffix_b; path_suffix_a = tp_account_get_path_suffix (account_a); path_suffix_b = tp_account_get_path_suffix (account_b); return g_strcmp0 (path_suffix_a, path_suffix_b) == 0; }
static void empathy_server_sasl_handler_get_password_async_cb (GObject *source, GAsyncResult *result, gpointer user_data) { EmpathyServerSASLHandlerPriv *priv; const gchar *password; GError *error = NULL; priv = EMPATHY_SERVER_SASL_HANDLER (user_data)->priv; password = empathy_keyring_get_account_password_finish (TP_ACCOUNT (source), result, &error); if (password != NULL) { priv->password = g_strdup (password); /* Do this in an idle so the async result will get there * first. */ g_idle_add (empathy_server_sasl_handler_give_password, user_data); } g_simple_async_result_complete (priv->async_init_res); tp_clear_object (&priv->async_init_res); }
static void hev_impathy_server_sasl_handler_get_password_async_handler(GObject *source, GAsyncResult *res, gpointer user_data) { HevImpathyServerSASLHandler *self = HEV_IMPATHY_SERVER_SASL_HANDLER(user_data); HevImpathyServerSASLHandlerPrivate *priv = HEV_IMPATHY_SERVER_SASL_HANDLER_GET_PRIVATE(self); const gchar *password = NULL; GError *error = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); password = hev_impathy_keyring_get_account_password_finish(TP_ACCOUNT(source), res, &error); if(NULL != password) { priv->password = g_strdup(password); /* Do this in an idle so the async result will get there * first. */ g_idle_add(hev_impathy_server_sasl_handler_give_password, user_data); } g_simple_async_result_complete(priv->async_init_res); tp_clear_object(&priv->async_init_res); }
static void on_account_notify_changing_presence (GObject *object, GParamSpec *pspec, gpointer user_data) { TpAccount *account = TP_ACCOUNT (object); ChangingPresenceData *data = user_data; TpConnection *connection; if (tp_account_get_changing_presence (account)) { g_source_remove (data->source_id); g_signal_handler_disconnect (data->account, data->handler_id); connection = tp_account_get_connection (account); if (connection == NULL) { /* now just wait for the connection */ tp_g_signal_connect_object (account, "notify::connection", G_CALLBACK (on_account_notify_connection), data->res, 0); } else { /* TODO: this should be given the cancellable when it's used. */ _tp_yts_connection_future_ensure_sidecar_async (connection, TP_YTS_IFACE_STATUS, NULL, on_connection_future_ensure_sidecar_returned, data->res); } g_slice_free (ChangingPresenceData, data); } }
static EmpathyLogSearchHit * log_store_empathy_search_hit_new (EmpathyLogStore *self, const gchar *filename) { EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self); EmpathyLogSearchHit *hit; gchar *account_name; const gchar *end; gchar **strv; guint len; GList *accounts, *l; if (!g_str_has_suffix (filename, LOG_FILENAME_SUFFIX)) return NULL; strv = g_strsplit (filename, G_DIR_SEPARATOR_S, -1); len = g_strv_length (strv); hit = g_slice_new0 (EmpathyLogSearchHit); end = strstr (strv[len-1], LOG_FILENAME_SUFFIX); hit->date = g_strndup (strv[len-1], end - strv[len-1]); hit->chat_id = g_strdup (strv[len-2]); hit->is_chatroom = (strcmp (strv[len-3], LOG_DIR_CHATROOMS) == 0); if (hit->is_chatroom) account_name = strv[len-4]; else account_name = strv[len-3]; /* FIXME: This assumes the account manager is prepared, but the * synchronous API forces this. See bug #599189. */ accounts = tp_account_manager_get_valid_accounts (priv->account_manager); for (l = accounts; l != NULL; l = g_list_next (l)) { TpAccount *account = TP_ACCOUNT (l->data); gchar *name; name = log_store_account_to_dirname (account); if (!tp_strdiff (name, account_name)) { g_assert (hit->account == NULL); hit->account = account; g_object_ref (account); } g_object_unref (account); g_free (name); } g_list_free (accounts); hit->filename = g_strdup (filename); g_strfreev (strv); return hit; }
static void account_manager_chatroom_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object); EmpathyChatroomManager *chatroom_manager = user_data; GList *accounts, *l; GError *error = NULL; if (!tp_account_manager_prepare_finish (account_manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_error_free (error); return; } accounts = tp_account_manager_get_valid_accounts (account_manager); for (l = accounts; l != NULL; l = g_list_next (l)) { TpAccount *account = TP_ACCOUNT (l->data); TpConnection *conn; GList *chatrooms, *p; conn = tp_account_get_connection (account); chatrooms = empathy_chatroom_manager_get_chatrooms ( chatroom_manager, account); for (p = chatrooms; p != NULL; p = p->next) { EmpathyChatroom *room = EMPATHY_CHATROOM (p->data); if (!empathy_chatroom_get_auto_connect (room)) continue; if (conn == NULL) { g_signal_connect (G_OBJECT (account), "status-changed", G_CALLBACK (account_status_changed_cb), room); } else { empathy_dispatcher_join_muc (conn, empathy_chatroom_get_room (room), NULL, NULL); } } g_list_free (chatrooms); } g_list_free (accounts); }
static void set_avatar_cb (GObject *source, GAsyncResult *res, gpointer user_data) { GError *error = NULL; if (!tp_account_set_avatar_finish (TP_ACCOUNT (source), res, &error)) { DEBUG ("Failed to set Account.Avatar: %s", error->message); g_error_free (error); } }
static void hev_impathy_server_sasl_handler_set_password_handler(GObject *source, GAsyncResult *res, gpointer user_data) { GError *error = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); if(!hev_impathy_keyring_set_account_password_finish(TP_ACCOUNT(source), res, &error)) { g_clear_error(&error); } }
static void migration_account_manager_prepared_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *am = TP_ACCOUNT_MANAGER (source_object); GError *error = NULL; GList *accounts, *l; GSettings *gsettings; if (!tp_proxy_prepare_finish (am, result, &error)) { DEBUG ("Failed to prepare the account manager: %s", error->message); g_error_free (error); return; } accounts = tp_account_manager_get_valid_accounts (am); for (l = accounts; l != NULL; l = l->next) { TpAccount *account = TP_ACCOUNT (l->data); gchar *dir, *cm; tp_account_parse_object_path (tp_proxy_get_object_path (account), &cm, NULL, NULL, NULL); if (tp_strdiff (cm, "butterfly")) { g_free (cm); continue; } dir = get_log_dir_for_account (account); DEBUG ("Migrating all logs from dir: %s", dir); migrate_log_files_in_dir (dir); g_free (cm); g_free (dir); } DEBUG ("Finished all migrating"); gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA); g_settings_set_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED, TRUE); g_object_unref (gsettings); g_list_free (accounts); }
static void empathy_server_sasl_handler_set_password_cb (GObject *source, GAsyncResult *result, gpointer user_data) { GError *error = NULL; if (!empathy_keyring_set_account_password_finish (TP_ACCOUNT (source), result, &error)) { DEBUG ("Failed to set password: %s", error->message); g_clear_error (&error); } else { DEBUG ("Password set successfully."); } }
static void account_prepared_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccount *account = TP_ACCOUNT (source_object); GError *error = NULL; if (!tp_proxy_prepare_finish (account, result, &error)) { g_print ("failed to prepare account: %s\n", error->message); g_clear_error (&error); getoutofhere (); return; } got_account (account); }
static void on_account_notify_connection (GObject *object, GParamSpec *pspec, gpointer user_data) { TpAccount *account = TP_ACCOUNT (object); GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); TpConnection *connection; connection = tp_account_get_connection (account); if (connection != NULL) { /* TODO: this should be given the cancellable when it's used. */ _tp_yts_connection_future_ensure_sidecar_async (connection, TP_YTS_IFACE_STATUS, NULL, on_connection_future_ensure_sidecar_returned, res); } }
/* Salut account creation. The TpAccountManager first argument * must already be prepared when calling this function. */ static gboolean should_create_salut_account (TpAccountManager *manager) { gboolean salut_created = FALSE; GList *accounts, *l; /* Check if we already created a salut account */ empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, &salut_created); if (salut_created) { DEBUG ("Gconf says we already created a salut account once"); return FALSE; } accounts = tp_account_manager_get_valid_accounts (manager); for (l = accounts; l != NULL; l = g_list_next (l)) { TpAccount *account = TP_ACCOUNT (l->data); if (!tp_strdiff (tp_account_get_protocol (account), "local-xmpp")) { salut_created = TRUE; break; } } g_list_free (accounts); if (salut_created) { DEBUG ("Existing salut account already exists, flagging so in gconf"); empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, TRUE); } return !salut_created; }
static void account_prepare_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *manager = TP_ACCOUNT_MANAGER (user_data); TpAccount *account = TP_ACCOUNT (source_object); GError *error = NULL; if (!tp_proxy_prepare_finish (account, result, &error)) { DEBUG ("Failed to prepare account: %s", error->message); g_error_free (error); account = NULL; } empathy_accounts_show_accounts_ui (manager, account, G_CALLBACK (gtk_main_quit)); }
static void remmina_tp_channel_handler_account_ready(GObject *account, GAsyncResult *res, gpointer user_data) { RemminaTpChannelHandler *chandler = (RemminaTpChannelHandler *) user_data; GError *error = NULL; if (!tp_account_prepare_finish(TP_ACCOUNT(account), res, &error)) { g_print("tp_account_prepare_finish: %s\n", error->message); remmina_tp_channel_handler_free(chandler); return; } chandler->connection = tp_connection_new(chandler->bus, NULL, chandler->connection_path, &error); if (chandler->connection == NULL) { g_print("tp_connection_new: %s\n", error->message); remmina_tp_channel_handler_free(chandler); return; } tp_connection_call_when_ready(chandler->connection, remmina_tp_channel_handler_connection_ready, chandler); }
static void account_manager_prepared_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { GList *accounts, *j; TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); EmpathyMainWindow *window = user_data; GError *error = NULL; if (!tp_account_manager_prepare_finish (manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_error_free (error); return; } accounts = tp_account_manager_get_valid_accounts (window->account_manager); for (j = accounts; j != NULL; j = j->next) { TpAccount *account = TP_ACCOUNT (j->data); gulong handler_id; handler_id = g_signal_connect (account, "status-changed", G_CALLBACK (main_window_connection_changed_cb), window); g_hash_table_insert (window->status_changed_handlers, account, GUINT_TO_POINTER (handler_id)); } g_signal_connect (manager, "account-validity-changed", G_CALLBACK (main_window_account_validity_changed_cb), window); main_window_update_status (window); /* Disable the "Previous Conversations" menu entry if there is no account */ gtk_action_set_sensitive (window->view_history, g_list_length (accounts) > 0); g_list_free (accounts); }
static void chat_conversations_list_account_manager_prepare (GObject *source_object, GAsyncResult *res, gpointer user_data) { ChatConversationsList *self = CHAT_CONVERSATIONS_LIST (user_data); ChatConversationsListPrivate *priv = self->priv; GError *error; GList *accounts = NULL; GList *l; error = NULL; if (!tp_proxy_prepare_finish (source_object, res, &error)) { g_warning ("Unable to prepare the account manager: %s", error->message); g_error_free (error); goto out; } accounts = tp_account_manager_dup_valid_accounts (priv->am); for (l = accounts; l != NULL; l = l->next) { TpAccount *account = TP_ACCOUNT (l->data); TpConnection *conn; const gchar *cm_name; cm_name = tp_account_get_cm_name (account); if (g_strcmp0 (cm_name, "idle") == 0) continue; conn = tp_account_get_connection (account); if (conn == NULL) continue; tp_proxy_prepare_async (conn, NULL, chat_conversations_list_connection_prepare, g_object_ref (self)); g_hash_table_insert (priv->accounts, g_object_ref (account), NULL); } out: g_list_free_full (accounts, g_object_unref); g_object_unref (self); }
static void account_enabled_cb (GObject *source, GAsyncResult *result, gpointer user_data) { TpAccount *account = TP_ACCOUNT (source); GError *error = NULL; TpAccountManager *account_mgr; if (!tp_account_set_enabled_finish (account, result, &error)) { DEBUG ("Failed to enable account: %s", error->message); g_error_free (error); return; } account_mgr = tp_account_manager_dup (); tpaw_connect_new_account (account, account_mgr); g_object_unref (account_mgr); }
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 account_widget_account_enabled_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GError *error = NULL; TpAccount *account = TP_ACCOUNT (source_object); EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data); EmpathyAccountWidgetPriv *priv = GET_PRIV (widget); tp_account_set_enabled_finish (account, res, &error); if (error != NULL) { DEBUG ("Could not automatically enable new account: %s", error->message); g_error_free (error); } else { priv->account_created = TRUE; g_signal_emit (widget, signals[ACCOUNT_CREATED], 0); } }
static void status_ensured_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccount *account = user_data; TpYtsStatus *status; GError *error = NULL; status = tp_yts_status_ensure_finish ( TP_ACCOUNT (source_object), result, &error); if (status == NULL) { g_printerr ("Failed to ensure status: %s\n", error->message); getoutofhere (); } else { client = tp_yts_client_new ("passing.status", account); tp_yts_client_register (client, NULL); /* We need the XML here otherwise the activity attribute won't * be present and it'll think we'll be trying to remove the * status. */ tp_yts_status_advertise_status_async (status, "urn:ytstenut:capabilities:yts-caps-cats", "passing.status", /* this should be the same as the client name */ "<status xmlns='urn:ytstenut:status' from-service='service.name' " "capability='urn:ytstenut:capabilities:yts-caps-cats' " "activity='looking-at-cats-ooooooh'><look>at how cute they " "are!</look></status>", NULL, advertise_status_cb, NULL); } g_clear_error (&error); }
gboolean empathy_local_xmpp_assistant_widget_should_create_account ( TpAccountManager *manager) { gboolean salut_created = FALSE; GList *accounts, *l; accounts = tp_account_manager_dup_valid_accounts (manager); for (l = accounts; l != NULL; l = g_list_next (l)) { TpAccount *account = TP_ACCOUNT (l->data); if (!tp_strdiff (tp_account_get_protocol_name (account), "local-xmpp")) { salut_created = TRUE; break; } } g_list_free_full (accounts, g_object_unref); return !salut_created; }
static void main_window_destroy_cb (GtkWidget *widget, EmpathyMainWindow *window) { GHashTableIter iter; gpointer key, value; /* Save user-defined accelerators. */ main_window_accels_save (); g_list_free (window->actions_connected); g_object_unref (window->account_manager); g_object_unref (window->list_store); g_hash_table_destroy (window->errors); /* disconnect all handlers of status-changed signal */ g_hash_table_iter_init (&iter, window->status_changed_handlers); while (g_hash_table_iter_next (&iter, &key, &value)) g_signal_handler_disconnect (TP_ACCOUNT (key), GPOINTER_TO_UINT (value)); g_hash_table_destroy (window->status_changed_handlers); g_signal_handlers_disconnect_by_func (window->event_manager, main_window_event_added_cb, window); g_signal_handlers_disconnect_by_func (window->event_manager, main_window_event_removed_cb, window); g_object_unref (window->event_manager); g_object_unref (window->ui_manager); g_object_unref (window->chatroom_manager); g_free (window); }
bool TelepathyAccountHandler::startSession(PD_Document* pDoc, const std::vector<std::string>& vAcl, AbiCollab** pSession) { UT_DEBUGMSG(("TelepathyAccountHandler::startSession()\n")); UT_return_val_if_fail(pDoc, false); AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, false); // generate a unique session id to use UT_UTF8String sSessionId; UT_UUID* pUUID = XAP_App::getApp()->getUUIDGenerator()->createUUID(); pUUID->toString(sSessionId); DELETEP(pUUID); // start the session already, while we'll continue to setup a // MUC asynchronously below // TODO: we should fill in the in the master buddy descriptor so we can do // proper author coloring and session takeover; we can't do that however, since // the following bugs needs to be fixed first: // // https://bugs.freedesktop.org/show_bug.cgi?id=37631 *pSession = pManager->startSession(pDoc, sSessionId, this, true, NULL, ""); // create a chatroom to hold the session information TelepathyChatroomPtr pChatroom = boost::shared_ptr<TelepathyChatroom>(new TelepathyChatroom(this, NULL, pDoc, sSessionId)); m_chatrooms.push_back(pChatroom); // add the buddies in the acl list to the room invitee list /* std::vector<TelepathyBuddyPtr> buddies = _getBuddies(vAcl); gchar** invitee_ids = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * vAcl.size()+1)); int i = 0; for (std::vector<TelepathyBuddyPtr>::iterator it = buddies.begin(); it != buddies.end(); it++) { UT_continue_if_fail(*it); invitee_ids[i] = strdup(tp_contact_get_identifier((*it)->getContact())); UT_DEBUGMSG(("Added %s to the invite list\n", invitee_ids[i])); } invitee_ids[vAcl.size()] = NULL; */ _inviteBuddies(pChatroom, vAcl); // use the above code when TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS is usable // a quick hack to determine the account to offer the request on TpAccountManager* manager = tp_account_manager_dup(); UT_return_val_if_fail(manager, false); GList* accounts = tp_account_manager_get_valid_accounts(manager); UT_return_val_if_fail(accounts, false); // TODO: make sure the accounts are ready TpAccount* selected_account = NULL; for (GList* account = accounts; account; account = account->next) { selected_account = TP_ACCOUNT(account->data); break; } UT_return_val_if_fail(selected_account, false); g_list_free(accounts); // determine the room target id std::string target_id = sSessionId.utf8_str(); std::string conference_server = getProperty("conference_server"); if (conference_server != "") target_id += "@" + conference_server; UT_DEBUGMSG(("Using room target ID: %s\n", target_id.c_str())); // create a anonymous MUC channel request GHashTable* props = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, TP_TYPE_HANDLE, TP_HANDLE_TYPE_ROOM, TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, target_id.c_str(), TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, INTERFACE, /* * Enable TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS if you want to use * anonymous MUCs. We can't use it right now, anonymous DBUS_TUBE MUCs are not implemented yet. * Remove the HANDLE_TYPE and TARGET_ID when you enable this. * * See https://bugs.freedesktop.org/show_bug.cgi?id=37630 for details. * * TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS, G_TYPE_STRV, invitee_ids, */ NULL); TpAccountChannelRequest * channel_request = tp_account_channel_request_new(selected_account, props, TP_USER_ACTION_TIME_NOT_USER_ACTION); UT_return_val_if_fail(channel_request, false); g_hash_table_destroy (props); // TODO: free invitee_ids tp_account_channel_request_create_and_handle_channel_async(channel_request, NULL, muc_channel_ready_cb, pChatroom.get()); return true; }