TEMPLATE = app
QT += qml quick widgets
#LIBS += -lPocoFoundation -lPocoXML -lPocoNet
SOURCES += main.cpp
tnet.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
INCLUDEPATH += $$(PocoPath)
android{
LIBS += -L$$(PocoPath)/So -lPocoFoundation -lPocoXML -lPocoNet
}else:unix
{
LIBS += -lPocoFoundation -lPocoXML -lPocoNet
}
HEADERS +=
tnet.h
#include "tnet.h"
#include <QJsonObject>
#include <QString>
#include <QFile>
TNet::TNet(QObject *parent) : QObject(parent)
{
// QJsonObject value;
// value.insert("op","upload");
// value.insert("token","dsa")
// value["cid"] = cid;
// value["name"] = name;
// value["catalog"] = catalog;
// value["notes"] = notes;
// value["tags"] = tags;
// value["public"] = ispublic ? 1 : 0;
// value["huodong"] = activity;
// value["jiedan"] = compete;
// Poco::URI purl("http://api.yiqibian.com");
// HTTPRequest req(Poco::Net::HTTPRequest::HTTP_POST);
// Poco::Net::HTTPClientSession session(purl.getHost(), purl.getPort());
// Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_POST, purl.getPath(), Poco::Net::HTTPMessage::HTTP_1_1);
// std::cout<<session.sendRequest(req);
// try
// {
// session.sendRequest(req);
// }
// catch(Poco::Net::NetException& ex)
// {
// std::cout<<"have err"<<std::endl;
// std::cout<<"post wrong: "<<ex.displayText()<<std::endl;
// };
}
void TNet::VisitDic(QString path)
{
// cd"/lk/os/movdo/a1"
QString curFtpPath="/";
QStringList pathlist;
pathlist=path.split("/");
FTPClientSession client;
client.open("192.168.7.254",21,"xprins","xprins");
client.setWorkingDirectory("/");
foreach(QString curpath,pathlist)
{
if(curpath==""||curpath=="lk")
continue;
try
{
if(curFtpPath=="/")
{
client.setWorkingDirectory((curFtpPath+curpath).toStdString().c_str());
curFtpPath=(curFtpPath+curpath);
}
else
{
client.setWorkingDirectory((curFtpPath+"/"+curpath).toStdString().c_str());
curFtpPath=(curFtpPath+"/"+curpath);
}
}
catch(...)
{
client.setWorkingDirectory(curFtpPath.toStdString().c_str());
client.createDirectory(curpath.toStdString().c_str());
if(curFtpPath=="/")
{
curFtpPath=(curFtpPath+curpath);
}
else
{
client.setWorkingDirectory((curFtpPath+"/"+curpath).toStdString().c_str());
curFtpPath=(curFtpPath+"/"+curpath);
}
client.setWorkingDirectory(curFtpPath.toStdString().c_str());
}
}
QFile file("/home/jixiang/图片/13062621267520.jpg");
if (!file.open(QIODevice::WriteOnly))
return;
//begin upload
std::ostream& os=client.beginUpload("13062621267520.jpg");
client.endUpload();
client.close();
}
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import TNet 1.0
ApplicationWindow {
title: qsTr("Hello World")
640
height: 480
visible: true
TNet
{
id:tnet;
}
Rectangle
{
anchors.fill: parent;
color:"black";
MouseArea
{
anchors.fill: parent;
onClicked: tnet.VisitDic("/hoho/sobey/MoVdo");
}
}
}