#include "gui_upload.h"
//
/* Save file as gui_upload.cpp */
/* Class Gui_Upload Created on Wed Jun 7 10:17:12 CEST 2006 */
//
#include <QCloseEvent>
//
QPointer<Gui_Upload> Gui_Upload::_self = 0L;
//
Gui_Upload
* Gui_Upload
::self( QWidget* parent
){
if ( !_self )
_self = new Gui_Upload( parent );
return _self;
}
Gui_Upload
::Gui_Upload( QWidget* parent
){
setupUi( this );
qDebug() << "### class init ";
connect(pushButton , SIGNAL(clicked()), this , SLOT(BeginnJob()));
}
void Gui_Upload::FinishStream()
{
QMessageBox::information(this, tr
("HTTP"),tr
("Signal finisch!"));
}
void Gui_Upload::BeginnJob()
{
if (us.size() < 1 or pa.size() < 1) {
QMessageBox::information(this, tr
("HTTP"),tr
("User Name or Pass not set!"));
return;
}
qDebug() << "### user " << us;
qDebug() << "### pass " << pa;
qDebug() << "### openFilesPath " << openFilesPath;
QString fileName
= QFileDialog::getOpenFileName(this,tr
("OpenFile"),openFilesPath,tr
("All Files (*);;Text Files (*.txt)"));
if (!fileName.isEmpty()) {
openFilesPath = fileName;
qDebug() << "### openFilesPath " << openFilesPath;
QString fileName1
= path.
fileName();
userfile
= new QFile(openFilesPath
);
if ( !userfile
->open
(QIODevice::ReadOnly) ) { QMessageBox::information(this, tr
("HTTP"),tr
("Unable to open the file %1: %2.").
arg(openFilesPath
).
arg(userfile
->errorString
()));
return;
}
pushButton->setEnabled(false);
/* dear qt set and splitt the url self */
QUrl url
("http://ppk.go/qt/tools.php");
header.setValue("Host", url.host());
header.setValue("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.12) Gecko/20050919 Firefox/1.0.7");
header.setValue("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
header.setValue("Accept-Language", "de-de,it;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
header.setValue("Accept-Encoding", "gzip,deflate");
header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
header.setValue("Keep-Alive", "300");
header.setValue("Connection", "keep-alive");
header.setValue("Referer", "http://ppk.go/");
header.setValue("Content-Type", "application/x-www-form-urlencoded");
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"onlyclient\" username=\""+us+"\" password=\""+pa+"\" action=\"beamup\" \r\n");
bytes.append("\r\n");
bytes.append("0\r\n");
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"qtfile\"; filename=\"" + byt+ "\"\r\n");
bytes.append("Content-Transfer-Encoding: binary\r\n");
bytes.append("\r\n");
bytes.append(userfile->readAll());
userfile->close();
bytes.append("\r\n");
bytes.append("--AaB03x--");
int contentLength = bytes.length();
header.setContentLength(contentLength);
qDebug() << "### stream " << bytes;
/* real post */
int httpGetId = http->request(header, bytes);
qDebug() << "### httpGetId " << httpGetId;
/* real post */
connect(http, SIGNAL(done(bool)), this, SLOT(FinishStream()));
}
}
{
e->accept();
}
#include "gui_upload.h"
//
/* Save file as gui_upload.cpp */
/* Class Gui_Upload Created on Wed Jun 7 10:17:12 CEST 2006 */
//
#include <QCloseEvent>
//
QPointer<Gui_Upload> Gui_Upload::_self = 0L;
//
Gui_Upload* Gui_Upload::self( QWidget* parent )
{
if ( !_self )
_self = new Gui_Upload( parent );
return _self;
}
Gui_Upload::Gui_Upload( QWidget* parent )
: QDialog( parent )
{
setupUi( this );
qDebug() << "### class init ";
connect(pushButton , SIGNAL(clicked()), this , SLOT(BeginnJob()));
}
void Gui_Upload::FinishStream()
{
QMessageBox::information(this, tr("HTTP"),tr("Signal finisch!"));
}
void Gui_Upload::BeginnJob()
{
QString us = username->text();
QString pa = pass->text();
QString openFilesPath = "/";
if (us.size() < 1 or pa.size() < 1) {
QMessageBox::information(this, tr("HTTP"),tr("User Name or Pass not set!"));
return;
}
qDebug() << "### user " << us;
qDebug() << "### pass " << pa;
qDebug() << "### openFilesPath " << openFilesPath;
QString fileName = QFileDialog::getOpenFileName(this,tr("OpenFile"),openFilesPath,tr("All Files (*);;Text Files (*.txt)"));
if (!fileName.isEmpty()) {
openFilesPath = fileName;
qDebug() << "### openFilesPath " << openFilesPath;
QFileInfo path(openFilesPath);
QString fileName1 = path.fileName();
userfile = new QFile(openFilesPath);
if ( !userfile->open(QIODevice::ReadOnly) ) {
QMessageBox::information(this, tr("HTTP"),tr("Unable to open the file %1: %2.").arg(openFilesPath).arg(userfile->errorString()));
return;
}
pushButton->setEnabled(false);
/* dear qt set and splitt the url self */
QUrl url("http://ppk.go/qt/tools.php");
QHttpRequestHeader header("POST", url.path());
header.setValue("Host", url.host());
header.setValue("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.12) Gecko/20050919 Firefox/1.0.7");
header.setValue("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
header.setValue("Accept-Language", "de-de,it;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
header.setValue("Accept-Encoding", "gzip,deflate");
header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
header.setValue("Keep-Alive", "300");
header.setValue("Connection", "keep-alive");
header.setValue("Referer", "http://ppk.go/");
header.setValue("Content-Type", "application/x-www-form-urlencoded");
QByteArray byt(openFilesPath.toUtf8());
QByteArray bytes;
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"onlyclient\" username=\""+us+"\" password=\""+pa+"\" action=\"beamup\" \r\n");
bytes.append("\r\n");
bytes.append("0\r\n");
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"qtfile\"; filename=\"" + byt+ "\"\r\n");
bytes.append("Content-Transfer-Encoding: binary\r\n");
bytes.append("\r\n");
bytes.append(userfile->readAll());
userfile->close();
bytes.append("\r\n");
bytes.append("--AaB03x--");
int contentLength = bytes.length();
header.setContentLength(contentLength);
qDebug() << "### stream " << bytes;
/* real post */
http = new QHttp(this);
int httpGetId = http->request(header, bytes);
qDebug() << "### httpGetId " << httpGetId;
/* real post */
connect(http, SIGNAL(done(bool)), this, SLOT(FinishStream()));
}
}
void Gui_Upload::closeEvent( QCloseEvent* e )
{
e->accept();
}
To copy to clipboard, switch view to plain text mode
Bookmarks