int main(int argc, char* argv[])
{
qDebug() << "### start main ";
PutSender
*job
= new PutSender
(QUrl("http://www.qtcentre.org/"),
"a.zip");
return app.exec();
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
qDebug() << "### start main ";
PutSender *job = new PutSender(QUrl("http://www.qtcentre.org/"),"a.zip");
return app.exec();
}
To copy to clipboard, switch view to plain text mode
#ifndef BASE_BUTTON_H
#define BASE_BUTTON_H
#include <QString>
#include <QDebug>
#include <QObject>
#include <QHttp>
#include <QAbstractSocket>
#include <QFileInfo>
#include <QHttp>
#include <QUrl>
#include <QtGui>
#include <QTimer>
#if defined Q_WS_MAC
#define WEBAGENTNAME "Mac QT4 / PPK_W @ciz.ch"
#endif
#if defined Q_WS_WIN
#define WEBAGENTNAME "Windows QT4 / PPK_W @ciz.ch"
#endif
#if defined Q_WS_X11
#define WEBAGENTNAME "Unix QT4 / PPK_W @ciz.ch"
#endif
typedef QMap<int, QStringList> cookiepam; /* cookie */
typedef QMap<QString, QString> ParamVar; /* xml params store */
{
Q_OBJECT
/* #####################url#############uploadfiel#######*/
{
BeamUp
= new QFile(locfile
);
/* upload file */
if (BeamUp->exists()) {
//////byteArray.clear();
//////BeamLog = new QBuffer(); /* buffer */
//////BeamLog->setBuffer(&byteArray);
////////BeamLog->open(QIODevice::ReadWrite);
logFile
= new QFile("log.txt");
BeamUp
= new QFile(locfile
);
header.setValue("Host",urigoup.host());
header.setValue("User-Agent", WEBAGENTNAME );
header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
header.setValue("Accept-Language", "it,de-de;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
header.setValue("Connection", "keep-alive");
david = davinfo->request(header,BeamUp,logFile);
qDebug() << "### david " << david;
connect(davinfo, SIGNAL(dataSendProgress(int, int)), this, SLOT(SendStatus(int, int)));
connect(davinfo, SIGNAL(stateChanged(int)), this, SLOT(State(int)));
connect(davinfo, SIGNAL(requestStarted(int)), this, SLOT(Started(int)));
Debugme();
} else {
ErrorMSG("File upload not found!");
}
}
protected:
int david;
private:
signals:
public slots:
void State( int a1 )
{
qDebug() << "### state " << a1;
}
void Started( int a1 )
{
qDebug() << "### strted " << a1;
}
void Debugme()
{
qDebug() << "### debug state 0/6 scala " << davinfo->state();
qDebug() << "### error " << davinfo->error();
QTimer::singleShot(1000,
this,
SLOT(Debugme
()));
}
void SendStatus( int tot , int stats )
{
qDebug() << "### status " << tot << "-" << stats;
}
void ErrorMSG
( const QString message
) {
qDebug() << "### message " << message;
}
};
#endif // BASE_BUTTON_H
#ifndef BASE_BUTTON_H
#define BASE_BUTTON_H
#include <QString>
#include <QDebug>
#include <QObject>
#include <QHttp>
#include <QAbstractSocket>
#include <QFileInfo>
#include <QHttp>
#include <QUrl>
#include <QtGui>
#include <QTimer>
#if defined Q_WS_MAC
#define WEBAGENTNAME "Mac QT4 / PPK_W @ciz.ch"
#endif
#if defined Q_WS_WIN
#define WEBAGENTNAME "Windows QT4 / PPK_W @ciz.ch"
#endif
#if defined Q_WS_X11
#define WEBAGENTNAME "Unix QT4 / PPK_W @ciz.ch"
#endif
typedef QMap<int, QStringList> cookiepam; /* cookie */
typedef QMap<QString, QString> ParamVar; /* xml params store */
class PutSender : public QObject
{
Q_OBJECT
/* #####################url#############uploadfiel#######*/
public: PutSender( QUrl urigo , QString locfile )
{
urigoup = QUrl(urigo);
davinfo = new QHttp();
BeamUp = new QFile(locfile); /* upload file */
if (BeamUp->exists()) {
//////byteArray.clear();
//////BeamLog = new QBuffer(); /* buffer */
//////BeamLog->setBuffer(&byteArray);
////////BeamLog->open(QIODevice::ReadWrite);
logFile = new QFile("log.txt");
logFile->open(QIODevice::ReadWrite);
BeamUp = new QFile(locfile);
BeamUp->open(QIODevice::ReadOnly);
QHttpRequestHeader header("PUT", urigoup.path() ,1,1); /* header */
header.setValue("Host",urigoup.host());
header.setValue("User-Agent", WEBAGENTNAME );
header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
header.setValue("Accept-Language", "it,de-de;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
header.setValue("Connection", "keep-alive");
david = davinfo->request(header,BeamUp,logFile);
qDebug() << "### david " << david;
connect(davinfo, SIGNAL(dataSendProgress(int, int)), this, SLOT(SendStatus(int, int)));
connect(davinfo, SIGNAL(stateChanged(int)), this, SLOT(State(int)));
connect(davinfo, SIGNAL(requestStarted(int)), this, SLOT(Started(int)));
Debugme();
} else {
ErrorMSG("File upload not found!");
}
}
protected:
int david;
QUrl urigoup;
QHttp *davinfo;
QFile *BeamUp;
QFile *logFile;
QBuffer *BeamLog;
QByteArray byteArray;
private:
signals:
public slots:
void State( int a1 )
{
qDebug() << "### state " << a1;
}
void Started( int a1 )
{
qDebug() << "### strted " << a1;
}
void Debugme()
{
qDebug() << "### debug state 0/6 scala " << davinfo->state();
qDebug() << "### error " << davinfo->error();
QTimer::singleShot(1000, this, SLOT(Debugme()));
}
void SendStatus( int tot , int stats )
{
qDebug() << "### status " << tot << "-" << stats;
}
void ErrorMSG( const QString message )
{
qDebug() << "### message " << message;
}
};
#endif // BASE_BUTTON_H
To copy to clipboard, switch view to plain text mode
Bookmarks