Пример #1
0
GtkWidget* remmina_init_dialog_new(const gchar *title_format, ...)
{
	RemminaInitDialog *dialog;
	va_list args;

	dialog = REMMINA_INIT_DIALOG (g_object_new (REMMINA_TYPE_INIT_DIALOG, NULL));

	va_start (args, title_format);
	dialog->title = g_strdup_vprintf (title_format, args);
	va_end (args);
	gtk_window_set_title (GTK_WINDOW(dialog), dialog->title);

	remmina_init_dialog_connecting (dialog);

	return GTK_WIDGET (dialog);
}
Пример #2
0
static gpointer
remmina_plugin_sftp_main_thread (gpointer data)
{
	RemminaProtocolWidget *gp = (RemminaProtocolWidget*) data;
	RemminaPluginSftpData *gpdata;
	RemminaFile *remminafile;
	RemminaSSH *ssh;
	RemminaSFTP *sftp = NULL;
	gboolean cont = FALSE;
	gint ret;
	const gchar *cs;

	pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
	CANCEL_ASYNC

	gpdata = (RemminaPluginSftpData*) g_object_get_data (G_OBJECT(gp), "plugin-data");

	ssh = g_object_get_data (G_OBJECT(gp), "user-data");
	if (ssh)
	{
		/* Create SFTP connection based on existing SSH session */
		sftp = remmina_sftp_new_from_ssh (ssh);
		if (remmina_ssh_init_session (REMMINA_SSH (sftp)) &&
				remmina_ssh_auth (REMMINA_SSH (sftp), NULL) > 0 &&
				remmina_sftp_open (sftp))
		{
			cont = TRUE;
		}
	}
	else
	{
		/* New SFTP connection */
		remminafile = remmina_plugin_service->protocol_plugin_get_file (gp);
		remmina_plugin_service->file_set_string (remminafile, "ssh_server",
				remmina_plugin_service->file_get_string (remminafile, "server"));

		sftp = remmina_sftp_new_from_file (remminafile);
		while (1)
		{
			if (!remmina_ssh_init_session (REMMINA_SSH (sftp)))
			{
				remmina_plugin_service->protocol_plugin_set_error (gp, "%s", REMMINA_SSH (sftp)->error);
				break;
			}

			ret = remmina_ssh_auth_gui (REMMINA_SSH (sftp),
					REMMINA_INIT_DIALOG (remmina_protocol_widget_get_init_dialog (gp)), TRUE);
			if (ret == 0)
			{
				remmina_plugin_service->protocol_plugin_set_error (gp, "%s", REMMINA_SSH (sftp)->error);
			}
			if (ret <= 0) break;

			if (!remmina_sftp_open (sftp))
			{
				remmina_plugin_service->protocol_plugin_set_error (gp, "%s", REMMINA_SSH (sftp)->error);
				break;
			}

			cs = remmina_plugin_service->file_get_string (remminafile, "execpath");
			if (cs && cs[0])
			{
				remmina_ftp_client_set_dir (REMMINA_FTP_CLIENT (gpdata->client), cs);
			}

			cont = TRUE;
			break;
		}
	}
	if (!cont)
	{
		if (sftp) remmina_sftp_free (sftp);
		IDLE_ADD ((GSourceFunc) remmina_plugin_service->protocol_plugin_close_connection, gp);
		return NULL;
	}

	remmina_sftp_client_open (REMMINA_SFTP_CLIENT (gpdata->client), sftp);
	/* RemminaSFTPClient owns the object, we just take the reference */
	gpdata->sftp = sftp;

	remmina_plugin_service->protocol_plugin_emit_signal (gp, "connect");

	gpdata->thread = 0;
	return NULL;
}