当前位置: 首页 > news >正文

网站有哪些功能如何制作餐馆网站

网站有哪些功能,如何制作餐馆网站,长沙市建设厅官方网站,seo需要掌握哪些技术到官网下载qssh的源码QSsh-botan-1#xff0c;使用qtcreator打开后#xff0c;直接编译#xff0c;即可得到qssh的库 头文件将QSsh-botan-1\src\libs\ssh目录下的.h文件拷到include文件夹下#xff0c;即为库头文件。 qssh有个问题#xff0c;如果你将qssh的类放在子线程…到官网下载qssh的源码QSsh-botan-1使用qtcreator打开后直接编译即可得到qssh的库 头文件将QSsh-botan-1\src\libs\ssh目录下的.h文件拷到include文件夹下即为库头文件。 qssh有个问题如果你将qssh的类放在子线程中调用将获取不到服务器发送回来的数据。故只能放在主线程调用。如有需要从子线程调用的话可通过在子线程发送信号来调用主线程的槽从而调用到qssh的功能使得qssh在主线程调用即能正常使用。 封装如下 // .h #ifndef SSHCLIENT_H #define SSHCLIENT_H #include qobject.h #include sshconnection.h #include sshremoteprocess.hclass SshClient : public QObject {Q_OBJECT public:SshClient();~SshClient();void ConnectToHost(const QString host, const QString user, const QString pwd);void DisConnectFromHost();void SendCmd(const QByteArray data);signals:void SendDataRecv(const QByteArray data);void SendConnected(bool bConned);void SendShellStarted(bool bStarted);void SendRetMsg(const QString msg);private slots:void OnConnected();void onConnectionError(QSsh::SshError);void OnShellStarted();void OnShellDataRecieved();void OnShellError();private:QString mIp;QString mUserName;QString mPwd;QSsh::SshConnection *mpConnection Q_NULLPTR; // 连接ssh服务器QSharedPointerQSsh::SshRemoteProcess mpShell; // ssh的shell用于发送与回显消息 };#endif // SSHCLIENT_H// .cpp #include qcoreapplication.h #include sshclient.h #include log.hSshClient::SshClient() {}SshClient::~SshClient() {DisConnectFromHost(); }void SshClient::ConnectToHost(const QString host, const QString username, const QString pwd) {QSsh::SshConnectionParameters params;params.setHost(host);params.setUserName(username);params.setPassword(pwd);params.authenticationType QSsh::SshConnectionParameters::AuthenticationTypePassword;params.timeout 10;//30;params.setPort(22);if(mpConnection Q_NULLPTR){mpConnection new QSsh::SshConnection(params, this); // TODO free this pointer!}connect(mpConnection, SIGNAL(connected()), SLOT(OnConnected()));connect(mpConnection, SIGNAL(error(QSsh::SshError)), SLOT(onConnectionError(QSsh::SshError)));mpConnection-disconnectFromHost();mpConnection-connectToHost();LOG_INFO(conneting to host:%s user:%s pwd:%s,qPrintable(host),qPrintable(username),qPrintable(pwd)); }void SshClient::DisConnectFromHost() {if(mpShell){emit SendShellStarted(false);mpShell-close();mpShell.reset();}if(mpConnection ! Q_NULLPTR){emit SendConnected(false);mpConnection-disconnectFromHost();delete mpConnection;mpConnection Q_NULLPTR;} }void SshClient::OnConnected() {emit SendConnected(true);LOG_INFO(ssh is connected);mpShell mpConnection-createRemoteShell();connect(mpShell.get(), SIGNAL(started()), SLOT(OnShellStarted()));connect(mpShell.get(), SIGNAL(readyReadStandardOutput()), SLOT(OnShellDataRecieved()));connect(mpShell.get(), SIGNAL(readyReadStandardError()), SLOT(OnShellError()));mpShell-start(); }void SshClient::onConnectionError(QSsh::SshError) {QString errStr mpConnection-errorString();emit SendRetMsg(QString::fromLocal8Bit(连接出错:%1).arg(errStr));LOG_ERROR(ssh connected err:%s,mpConnection-errorString().toLocal8Bit().data());//mpConnection-disconnectFromHost();// mpConnection-connectToHost(); }void SshClient::OnShellStarted() {LOG_INFO(shell is started);SendShellStarted(true); }void SshClient::OnShellDataRecieved() {QByteArray data mpShell-readAll();if (data.isEmpty())return;emit SendDataRecv(data);LOG_DEBUG(recv from shell data:%s,data.data()); }void SshClient::OnShellError() {emit SendRetMsg(QString::fromLocal8Bit(错误:%1).arg(mpShell-errorString()));LOG_ERROR(recv from shell err:%s,mpShell-errorString().toLocal8Bit().data()); }// 发送了命令后shell会回复两条同样的命令用于回显 void SshClient::SendCmd(const QByteArray data) {if(!mpShell){LOG_ERROR(shell is not start, cant sendmsg:%s,data.data());return;}qint64 n mpShell-write(data);LOG_DEBUG(write shell data, len:%d, data:%s,n,data.data());static const int timeoutMs 3000;int index 0;bool bsucc mpShell-waitForReadyRead(10);while(!bsucc index timeoutMs){ index 10;QCoreApplication::processEvents();if (!mpShell) break;bsucc mpShell-waitForReadyRead(10);} /*if (bsucc){QByteArray data mpShell-readAll();if (data.isEmpty())return;emit SendDataRecv(data);LOG_DEBUG(recv from shell data:%s, data.data());}*/ }
http://www.yutouwan.com/news/366883/

相关文章:

  • html5 学习网站自适应 WordPress 主题
  • 做笑话网站ps软件网站有哪些功能
  • 代理公司代理注册流程seo排名点击器曝光行者seo
  • 学习网站 现状桂林网络推广外包
  • 通州区住房和城乡建设部网站dede单本小说网站源码
  • 浙江省建设注册管理中心网站首页wordpress移除工具栏
  • 建设银行东航龙卡登录东航网站一般家庭装修照片
  • 云网站7china网络公关公司
  • 济南seo排名优化推广seo推广薪资
  • 潜江市建设工程合同备案网站营销网站做推广公司
  • 自己做的影视会员网站违法么wordpress 4.6.1 漏洞
  • 物流公司网站 源码网站编辑做的准备
  • 北京网站建设咨询公司wordpress自动更新页面
  • 中企建网站阿里巴巴国际站特点
  • 品牌网站设计制作哪家好一站式服务的优点
  • 免费网站提供菏泽手机网站建设
  • 手机做推广比较好的网站有哪些房屋装修设计师培训
  • 做网站客户需要提供的资料719y你会回来感谢我的
  • 网站等比例缩放wordpress 上一篇 下一篇
  • 长春公司网站模板建站合肥网站制作价格
  • 深圳企业网站制作公司怎样网页源代码修改后怎么保存
  • 如何采集网站文章网站建设 起飞
  • 常平网站仿做蓝色网站建设
  • 无锡网站推广公司排名HTML5移动端手机网站开发
  • 网站建设客户调查需求表陶哲轩wordpress
  • 郑州网站制作服务apmserv配置多个网站
  • 正规的h5网站在家做的打字兼职的网站
  • 手机手机网站建设网站模糊背景
  • 广西住房与城乡建设厅网站电话黄图网站有哪些 推荐
  • 网站关键词调整 收录wordpress 生成静态页面