Skip to content

Commit

Permalink
更新readMe
Browse files Browse the repository at this point in the history
  • Loading branch information
渡世白玉 committed May 29, 2014
1 parent 641cc26 commit 2dfeedd
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 300 deletions.
61 changes: 29 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,53 @@

About QSsh
关于 QSsh
About QSsh(关于 QSsh)
==========

QSsh provides SSH and SFTP support for Qt applications. The aim of this project
is to provide a easy way to use these protocols in any Qt application.
This project is based on Qt Creator"s libQtcSsh.so. All the credits to
Qt Creator"s team!
QSsh provides SSH and SFTP support for Qt applications. The aim of this project
is to provide a easy way to use these protocols in any Qt application.
This project is based on Qt Creator"s libQtcSsh.so. All the credits to
Qt Creator"s team!

QSsh为qt提供SSH和SFTP支持,使你能方便快捷的使用SSH和SFTP。
这个项目是基于Qt Creator中的LibQtcSsh.so。十分感谢Qt Creator团队。
QSsh为qt提供SSH和SFTP支持,使你能方便快捷的使用SSH和SFTP。
这个项目是基于Qt Creator中的LibQtcSsh.so。十分感谢Qt Creator团队。
==========

Prerequisites:
编译环境
Prerequisites:(编译环境)
-------------
Qt 4.8+ (May work with older versions) Qt4.8向上版本

Qt 4.8+ (May work with older versions) Qt4.8向上版本
On Windows: MinGW 4.7 or later, Visual Studio 2010 or later

On Windows: MinGW 4.7 or later, Visual Studio 2010 or later

On Mac: XCode 2.5 or later, compiling on 10.4 requires setting the environment variable QTC_TIGER_COMPAT before running qmake
On Mac: XCode 2.5 or later, compiling on 10.4 requires setting the environment variable QTC_TIGER_COMPAT before running qmake

==========
Compiling QSsh
编译QSsh

mkdir $BUILD_DIRECTORY
Compiling QSsh(编译QSsh)
----------------------
mkdir $BUILD_DIRECTORY

cd $BUILD_DIRECTORY
cd $BUILD_DIRECTORY

qmake $SOURCE_DIRECTORY/qssh.pro
qmake $SOURCE_DIRECTORY/qssh.pro

make (or mingw32-make or nmake depending on your platform)
make (or mingw32-make or nmake depending on your platform)


Or
###Or

You can open "qssh.pro" used "Qt Creator".
You can open "qssh.pro" used "Qt Creator".

你也可以直接用Qt Creator打开qssh.pro。
你也可以直接用Qt Creator打开qssh.pro。

Examples
========
===========

- Directory examples/SecureUploader/ contains an example on how to upload a file using SFTP

- Directory examples/SecureUploader/ contains an example on how to upload
a file using SFTP

-Directory examples/qtsshshell/ 一个sshShell的例子
- Directory examples/qtsshshell/ 一个sshShell的例子

-Directory examples/BotanTest/ 一个botan类库AES256加密的封装例子。
- Directory examples/BotanTest/ 一个botan类库AES256加密的封装例子。

-Directory examples/ssh/ Qt-Creator下自带的例子。
- Directory examples/ssh/ Qt-Creator下自带的例子。

注:生成的库在 lib文件夹下就可以直接用的。
Qt-Creator3.0 版本与原来2.x 连接信息的验证方式有所变化,原来的需要更改部分接口
> 注:生成的库在 lib文件夹下就可以直接用的。
> > Qt-Creator3.0 版本与原来2.x 连接信息的验证方式有所变化,原来的需要更改部分接口
22 changes: 11 additions & 11 deletions examples/qtsshshell/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}
128 changes: 64 additions & 64 deletions examples/qtsshshell/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSocketNotifier>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
con = nullptr;
// term = nullptr;
par.port = 22;
par.userName = "dsby";
par.password = "123789";
par.timeout = 500;
par.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePassword;
this->ui->lineip->setText("192.168.56.102");
}

MainWindow::~MainWindow()
{
delete ui;
if (nullptr != con)
{
con->deleteLater();
}

}

void MainWindow::on_pushcon_clicked()
{
par.host = this->ui->lineip->text();
con = new QSsh::SshConnection(par);
connect(con,&QSsh::SshConnection::connected,this,&MainWindow::sshcon);
connect(con,&QSsh::SshConnection::dataAvailable,[this](const QString & mse){this->ui->textEdit->append(mse);});
connect(con,&QSsh::SshConnection::disconnected,[this](){this->ui->textEdit->append("SSH disconnect");});
con->connectToHost();
}

void MainWindow::on_pushsend_clicked()
{
if (nullptr != con)
{
if (con->state() == QSsh::SshConnection::Connected)
{
QString str(this->ui->lineEdit->text());
str += "\r\n";
m_shell.data()->write(str.toStdString().c_str());
}
}
}

void MainWindow::sshcon()
{
m_shell = con->createRemoteShell();
connect(m_shell.data(),&QSsh::SshRemoteProcess::started,[this](){this->ui->textEdit->append("SshRemoteProcess start succsess");});
connect(m_shell.data(),&QSsh::SshRemoteProcess::readyReadStandardOutput,[this](){this->ui->textEdit->append(QString(this->m_shell.data()->readAllStandardOutput()));
});
connect(m_shell.data(),&QSsh::SshRemoteProcess::readyRead,[this](){this->ui->textEdit->append(QString(this->m_shell.data()->readAllStandardOutput()));});
connect(m_shell.data(),&QSsh::SshRemoteProcess::readyReadStandardError,[this](){this->ui->textEdit->append(QString(this->m_shell.data()->readAll()));});
connect(m_shell.data(),&QSsh::SshRemoteProcess::closed,[this](){this->ui->textEdit->append("SshRemoteProcess stop");});
m_shell.data()->start();
}

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSocketNotifier>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
con = nullptr;
// term = nullptr;
par.port = 22;
par.userName = "dsby";
par.password = "123789";
par.timeout = 500;
par.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePassword;
this->ui->lineip->setText("192.168.56.102");
}

MainWindow::~MainWindow()
{
delete ui;
if (nullptr != con)
{
con->deleteLater();
}

}

void MainWindow::on_pushcon_clicked()
{
par.host = this->ui->lineip->text();
con = new QSsh::SshConnection(par);
connect(con,&QSsh::SshConnection::connected,this,&MainWindow::sshcon);
connect(con,&QSsh::SshConnection::dataAvailable,[this](const QString & mse){this->ui->textEdit->append(mse);});
connect(con,&QSsh::SshConnection::disconnected,[this](){this->ui->textEdit->append("SSH disconnect");});
con->connectToHost();
}

void MainWindow::on_pushsend_clicked()
{
if (nullptr != con)
{
if (con->state() == QSsh::SshConnection::Connected)
{
QString str(this->ui->lineEdit->text());
str += "\r\n";
m_shell.data()->write(str.toStdString().c_str());
}
}
}

void MainWindow::sshcon()
{
m_shell = con->createRemoteShell();
connect(m_shell.data(),&QSsh::SshRemoteProcess::started,[this](){this->ui->textEdit->append("SshRemoteProcess start succsess");});
connect(m_shell.data(),&QSsh::SshRemoteProcess::readyReadStandardOutput,[this](){this->ui->textEdit->append(QString(this->m_shell.data()->readAllStandardOutput()));
});
connect(m_shell.data(),&QSsh::SshRemoteProcess::readyRead,[this](){this->ui->textEdit->append(QString(this->m_shell.data()->readAllStandardOutput()));});
connect(m_shell.data(),&QSsh::SshRemoteProcess::readyReadStandardError,[this](){this->ui->textEdit->append(QString(this->m_shell.data()->readAll()));});
connect(m_shell.data(),&QSsh::SshRemoteProcess::closed,[this](){this->ui->textEdit->append("SshRemoteProcess stop");});
m_shell.data()->start();
}

68 changes: 34 additions & 34 deletions examples/qtsshshell/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <sshconnection.h>
#include <qsharedpointer.h>
#include <sshremoteprocess.h>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

public slots:
void on_pushcon_clicked();
void on_pushsend_clicked();
void sshcon();

private:
Ui::MainWindow *ui;
QSsh::SshConnectionParameters par;
QSsh::SshConnection * con;
QSharedPointer<QSsh::SshRemoteProcess> m_shell;

};

#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <sshconnection.h>
#include <qsharedpointer.h>
#include <sshremoteprocess.h>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

public slots:
void on_pushcon_clicked();
void on_pushsend_clicked();
void sshcon();

private:
Ui::MainWindow *ui;
QSsh::SshConnectionParameters par;
QSsh::SshConnection * con;
QSharedPointer<QSsh::SshRemoteProcess> m_shell;

};

#endif // MAINWINDOW_H
Loading

0 comments on commit 2dfeedd

Please sign in to comment.