Make QFtp private.
All references to QFtp in documentation have been removed, QFtp's documentaiton was marked internal. The QFtp example was removed. Task-number: QTBUG-23199 Change-Id: Ifff83cac069fb350e8ebeae63e605850e65c0c30 Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
This commit is contained in:
parent
ad28d83f6d
commit
1453f74cc5
3
dist/changes-5.0.0
vendored
3
dist/changes-5.0.0
vendored
@ -146,6 +146,9 @@ information about a particular change.
|
|||||||
- The QHttp, QHttpHeader, QHttpResponseHeader and QHttpRequestHeader classes have
|
- The QHttp, QHttpHeader, QHttpResponseHeader and QHttpRequestHeader classes have
|
||||||
been removed, QNetworkAccessManager should be used instead.
|
been removed, QNetworkAccessManager should be used instead.
|
||||||
|
|
||||||
|
- The QFtp class is no longer exported, QNetworkAccessManager should be used
|
||||||
|
instead.
|
||||||
|
|
||||||
- QProcess
|
- QProcess
|
||||||
|
|
||||||
* On Windows, QProcess::ForwardedChannels will not forward the output of GUI
|
* On Windows, QProcess::ForwardedChannels will not forward the output of GUI
|
||||||
|
@ -338,7 +338,7 @@
|
|||||||
\section1 QObject Reentrancy
|
\section1 QObject Reentrancy
|
||||||
|
|
||||||
QObject is reentrant. Most of its non-GUI subclasses, such as
|
QObject is reentrant. Most of its non-GUI subclasses, such as
|
||||||
QTimer, QTcpSocket, QUdpSocket, QFtp, and QProcess, are also
|
QTimer, QTcpSocket, QUdpSocket and QProcess, are also
|
||||||
reentrant, making it possible to use these classes from multiple
|
reentrant, making it possible to use these classes from multiple
|
||||||
threads simultaneously. Note that these classes are designed to be
|
threads simultaneously. Note that these classes are designed to be
|
||||||
created and used from within a single thread; creating an object
|
created and used from within a single thread; creating an object
|
||||||
|
@ -40,8 +40,7 @@
|
|||||||
\brief An Introduction to Network Programming with Qt
|
\brief An Introduction to Network Programming with Qt
|
||||||
|
|
||||||
The QtNetwork module offers classes that allow you to write TCP/IP clients
|
The QtNetwork module offers classes that allow you to write TCP/IP clients
|
||||||
and servers. It offers classes such as QFtp that implement specific
|
and servers. It offers lower-level classes such as QTcpSocket,
|
||||||
application-level protocols, lower-level classes such as QTcpSocket,
|
|
||||||
QTcpServer and QUdpSocket that represent low level network concepts,
|
QTcpServer and QUdpSocket that represent low level network concepts,
|
||||||
and high level classes such as QNetworkRequest, QNetworkReply and
|
and high level classes such as QNetworkRequest, QNetworkReply and
|
||||||
QNetworkAccessManager to perform network operations using common protocols.
|
QNetworkAccessManager to perform network operations using common protocols.
|
||||||
@ -92,64 +91,6 @@
|
|||||||
Each application or library can create one or more instances of
|
Each application or library can create one or more instances of
|
||||||
QNetworkAccessManager to handle network communication.
|
QNetworkAccessManager to handle network communication.
|
||||||
|
|
||||||
\section1 Writing FTP Clients with QFtp
|
|
||||||
|
|
||||||
FTP (File Transfer Protocol) is a protocol used almost exclusively
|
|
||||||
for browsing remote directories and for transferring files.
|
|
||||||
|
|
||||||
\image httpstack.png FTP Client and Server
|
|
||||||
|
|
||||||
FTP uses two network connections, one for sending
|
|
||||||
commands and one for transferring data. The
|
|
||||||
FTP protocol has a state and requires the client to send several
|
|
||||||
commands before a file transfer takes place.
|
|
||||||
FTP clients establish a connection
|
|
||||||
and keeps it open throughout the session. In each session, multiple
|
|
||||||
transfers can occur.
|
|
||||||
|
|
||||||
The QFtp class provides client-side support for FTP.
|
|
||||||
It has the following characteristics:
|
|
||||||
\list
|
|
||||||
|
|
||||||
\o \e{Non-blocking behavior.} QFtp is asynchronous.
|
|
||||||
You can schedule a series of commands which are executed later,
|
|
||||||
when control returns to Qt's event loop.
|
|
||||||
|
|
||||||
\o \e{Command IDs.} Each command has a unique ID number that you
|
|
||||||
can use to follow the execution of the command. For example, QFtp
|
|
||||||
emits the \l{QFtp::commandStarted()}{commandStarted()} and
|
|
||||||
\l{QFtp::commandFinished()}{commandFinished()} signal with the
|
|
||||||
command ID for each command that is executed.
|
|
||||||
|
|
||||||
\o \e{Data transfer progress indicators.} QFtp emits signals
|
|
||||||
whenever data is transferred (QFtp::dataTransferProgress(),
|
|
||||||
QNetworkReply::downloadProgress(), and
|
|
||||||
QNetworkReply::uploadProgress()). You could connect these signals
|
|
||||||
to QProgressBar::setProgress() or QProgressDialog::setProgress(),
|
|
||||||
for example.
|
|
||||||
|
|
||||||
\o \e{QIODevice support.} The class supports convenient
|
|
||||||
uploading from and downloading to \l{QIODevice}s, in addition to a
|
|
||||||
QByteArray-based API.
|
|
||||||
|
|
||||||
\endlist
|
|
||||||
|
|
||||||
There are two main ways of using QFtp. The most common
|
|
||||||
approach is to keep track of the command IDs and follow the
|
|
||||||
execution of every command by connecting to the appropriate
|
|
||||||
signals. The other approach is to schedule all commands at once
|
|
||||||
and only connect to the done() signal, which is emitted when all
|
|
||||||
scheduled commands have been executed. The first approach
|
|
||||||
requires more work, but it gives you more control over the
|
|
||||||
execution of individual commands and allows you to initiate new
|
|
||||||
commands based on the result of a previous command. It also
|
|
||||||
enables you to provide detailed feedback to the user.
|
|
||||||
|
|
||||||
The \l{network/qftp}{FTP} example
|
|
||||||
illustrates how to write an FTP client.
|
|
||||||
Writing your own FTP (or HTTP) server is possible using the
|
|
||||||
lower-level classes QTcpSocket and QTcpServer.
|
|
||||||
|
|
||||||
\section1 Using TCP with QTcpSocket and QTcpServer
|
\section1 Using TCP with QTcpSocket and QTcpServer
|
||||||
|
|
||||||
TCP (Transmission Control Protocol) is a low-level network
|
TCP (Transmission Control Protocol) is a low-level network
|
||||||
@ -172,7 +113,7 @@
|
|||||||
will then stop immediately.
|
will then stop immediately.
|
||||||
|
|
||||||
QTcpSocket works asynchronously and emits signals to report status
|
QTcpSocket works asynchronously and emits signals to report status
|
||||||
changes and errors, just like QNetworkAccessManager and QFtp. It
|
changes and errors, just like QNetworkAccessManager. It
|
||||||
relies on the event loop to detect incoming data and to
|
relies on the event loop to detect incoming data and to
|
||||||
automatically flush outgoing data. You can write data to the
|
automatically flush outgoing data. You can write data to the
|
||||||
socket using QTcpSocket::write(), and read data using
|
socket using QTcpSocket::write(), and read data using
|
||||||
|
@ -62,8 +62,8 @@ bool checkUrl(const QUrl &url) {
|
|||||||
|
|
||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
QFtp ftp;
|
QTcpSocket sock;
|
||||||
ftp.connectToHost(url.host(), url.port(21));
|
sock.connectToHost(url.host(), url.port(80));
|
||||||
//! [3]
|
//! [3]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ SUBDIRS = \
|
|||||||
broadcastsender \
|
broadcastsender \
|
||||||
fortuneclient \
|
fortuneclient \
|
||||||
fortuneserver \
|
fortuneserver \
|
||||||
qftp \
|
|
||||||
http \
|
http \
|
||||||
loopback \
|
loopback \
|
||||||
threadedfortuneserver \
|
threadedfortuneserver \
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<!DOCTYPE RCC><RCC version="1.0">
|
|
||||||
<qresource>
|
|
||||||
<file>images/cdtoparent.png</file>
|
|
||||||
<file>images/dir.png</file>
|
|
||||||
<file>images/file.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
@ -1,406 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** All rights reserved.
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
|
||||||
** the names of its contributors may be used to endorse or promote
|
|
||||||
** products derived from this software without specific prior written
|
|
||||||
** permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include <QtNetwork>
|
|
||||||
|
|
||||||
#include "ftpwindow.h"
|
|
||||||
|
|
||||||
FtpWindow::FtpWindow(QWidget *parent)
|
|
||||||
: QDialog(parent), ftp(0), networkSession(0)
|
|
||||||
{
|
|
||||||
ftpServerLabel = new QLabel(tr("Ftp &server:"));
|
|
||||||
ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com");
|
|
||||||
ftpServerLabel->setBuddy(ftpServerLineEdit);
|
|
||||||
|
|
||||||
statusLabel = new QLabel(tr("Please enter the name of an FTP server."));
|
|
||||||
|
|
||||||
fileList = new QTreeWidget;
|
|
||||||
fileList->setEnabled(false);
|
|
||||||
fileList->setRootIsDecorated(false);
|
|
||||||
fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
|
|
||||||
fileList->header()->setStretchLastSection(false);
|
|
||||||
|
|
||||||
connectButton = new QPushButton(tr("Connect"));
|
|
||||||
connectButton->setDefault(true);
|
|
||||||
|
|
||||||
cdToParentButton = new QPushButton;
|
|
||||||
cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png"));
|
|
||||||
cdToParentButton->setEnabled(false);
|
|
||||||
|
|
||||||
downloadButton = new QPushButton(tr("Download"));
|
|
||||||
downloadButton->setEnabled(false);
|
|
||||||
|
|
||||||
quitButton = new QPushButton(tr("Quit"));
|
|
||||||
|
|
||||||
buttonBox = new QDialogButtonBox;
|
|
||||||
buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole);
|
|
||||||
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
|
|
||||||
|
|
||||||
progressDialog = new QProgressDialog(this);
|
|
||||||
|
|
||||||
connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
|
|
||||||
this, SLOT(processItem(QTreeWidgetItem*,int)));
|
|
||||||
connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
|
||||||
this, SLOT(enableDownloadButton()));
|
|
||||||
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));
|
|
||||||
connect(connectButton, SIGNAL(clicked()), this, SLOT(connectOrDisconnect()));
|
|
||||||
connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent()));
|
|
||||||
connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile()));
|
|
||||||
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
|
|
||||||
|
|
||||||
QHBoxLayout *topLayout = new QHBoxLayout;
|
|
||||||
topLayout->addWidget(ftpServerLabel);
|
|
||||||
topLayout->addWidget(ftpServerLineEdit);
|
|
||||||
topLayout->addWidget(cdToParentButton);
|
|
||||||
topLayout->addWidget(connectButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
||||||
mainLayout->addLayout(topLayout);
|
|
||||||
mainLayout->addWidget(fileList);
|
|
||||||
mainLayout->addWidget(statusLabel);
|
|
||||||
mainLayout->addWidget(buttonBox);
|
|
||||||
setLayout(mainLayout);
|
|
||||||
|
|
||||||
setWindowTitle(tr("FTP"));
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize FtpWindow::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(500, 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
//![0]
|
|
||||||
void FtpWindow::connectOrDisconnect()
|
|
||||||
{
|
|
||||||
if (ftp) {
|
|
||||||
ftp->abort();
|
|
||||||
ftp->deleteLater();
|
|
||||||
ftp = 0;
|
|
||||||
//![0]
|
|
||||||
fileList->setEnabled(false);
|
|
||||||
cdToParentButton->setEnabled(false);
|
|
||||||
downloadButton->setEnabled(false);
|
|
||||||
connectButton->setEnabled(true);
|
|
||||||
connectButton->setText(tr("Connect"));
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
setCursor(Qt::ArrowCursor);
|
|
||||||
#endif
|
|
||||||
statusLabel->setText(tr("Please enter the name of an FTP server."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
setCursor(Qt::WaitCursor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!networkSession || !networkSession->isOpen()) {
|
|
||||||
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
|
|
||||||
if (!networkSession) {
|
|
||||||
// Get saved network configuration
|
|
||||||
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
|
|
||||||
settings.beginGroup(QLatin1String("QtNetwork"));
|
|
||||||
const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
// If the saved network configuration is not currently discovered use the system default
|
|
||||||
QNetworkConfiguration config = manager.configurationFromIdentifier(id);
|
|
||||||
if ((config.state() & QNetworkConfiguration::Discovered) !=
|
|
||||||
QNetworkConfiguration::Discovered) {
|
|
||||||
config = manager.defaultConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
networkSession = new QNetworkSession(config, this);
|
|
||||||
connect(networkSession, SIGNAL(opened()), this, SLOT(connectToFtp()));
|
|
||||||
connect(networkSession, SIGNAL(error(QNetworkSession::SessionError)), this, SLOT(enableConnectButton()));
|
|
||||||
}
|
|
||||||
connectButton->setEnabled(false);
|
|
||||||
statusLabel->setText(tr("Opening network session."));
|
|
||||||
networkSession->open();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
connectToFtp();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FtpWindow::connectToFtp()
|
|
||||||
{
|
|
||||||
//![1]
|
|
||||||
ftp = new QFtp(this);
|
|
||||||
connect(ftp, SIGNAL(commandFinished(int,bool)),
|
|
||||||
this, SLOT(ftpCommandFinished(int,bool)));
|
|
||||||
connect(ftp, SIGNAL(listInfo(QUrlInfo)),
|
|
||||||
this, SLOT(addToList(QUrlInfo)));
|
|
||||||
connect(ftp, SIGNAL(dataTransferProgress(qint64,qint64)),
|
|
||||||
this, SLOT(updateDataTransferProgress(qint64,qint64)));
|
|
||||||
|
|
||||||
fileList->clear();
|
|
||||||
currentPath.clear();
|
|
||||||
isDirectory.clear();
|
|
||||||
//![1]
|
|
||||||
|
|
||||||
//![2]
|
|
||||||
QUrl url(ftpServerLineEdit->text());
|
|
||||||
if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp")) {
|
|
||||||
ftp->connectToHost(ftpServerLineEdit->text(), 21);
|
|
||||||
ftp->login();
|
|
||||||
} else {
|
|
||||||
ftp->connectToHost(url.host(), url.port(21));
|
|
||||||
|
|
||||||
if (!url.userName().isEmpty())
|
|
||||||
ftp->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
|
|
||||||
else
|
|
||||||
ftp->login();
|
|
||||||
if (!url.path().isEmpty())
|
|
||||||
ftp->cd(url.path());
|
|
||||||
}
|
|
||||||
//![2]
|
|
||||||
|
|
||||||
fileList->setEnabled(true);
|
|
||||||
connectButton->setEnabled(false);
|
|
||||||
connectButton->setText(tr("Disconnect"));
|
|
||||||
statusLabel->setText(tr("Connecting to FTP server %1...")
|
|
||||||
.arg(ftpServerLineEdit->text()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//![3]
|
|
||||||
void FtpWindow::downloadFile()
|
|
||||||
{
|
|
||||||
QString fileName = fileList->currentItem()->text(0);
|
|
||||||
//![3]
|
|
||||||
//
|
|
||||||
if (QFile::exists(fileName)) {
|
|
||||||
QMessageBox::information(this, tr("FTP"),
|
|
||||||
tr("There already exists a file called %1 in "
|
|
||||||
"the current directory.")
|
|
||||||
.arg(fileName));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//![4]
|
|
||||||
file = new QFile(fileName);
|
|
||||||
if (!file->open(QIODevice::WriteOnly)) {
|
|
||||||
QMessageBox::information(this, tr("FTP"),
|
|
||||||
tr("Unable to save the file %1: %2.")
|
|
||||||
.arg(fileName).arg(file->errorString()));
|
|
||||||
delete file;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ftp->get(fileList->currentItem()->text(0), file);
|
|
||||||
|
|
||||||
progressDialog->setLabelText(tr("Downloading %1...").arg(fileName));
|
|
||||||
downloadButton->setEnabled(false);
|
|
||||||
progressDialog->exec();
|
|
||||||
}
|
|
||||||
//![4]
|
|
||||||
|
|
||||||
//![5]
|
|
||||||
void FtpWindow::cancelDownload()
|
|
||||||
{
|
|
||||||
ftp->abort();
|
|
||||||
|
|
||||||
if (file->exists()) {
|
|
||||||
file->close();
|
|
||||||
file->remove();
|
|
||||||
}
|
|
||||||
delete file;
|
|
||||||
}
|
|
||||||
//![5]
|
|
||||||
|
|
||||||
//![6]
|
|
||||||
void FtpWindow::ftpCommandFinished(int, bool error)
|
|
||||||
{
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
setCursor(Qt::ArrowCursor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ftp->currentCommand() == QFtp::ConnectToHost) {
|
|
||||||
if (error) {
|
|
||||||
QMessageBox::information(this, tr("FTP"),
|
|
||||||
tr("Unable to connect to the FTP server "
|
|
||||||
"at %1. Please check that the host "
|
|
||||||
"name is correct.")
|
|
||||||
.arg(ftpServerLineEdit->text()));
|
|
||||||
connectOrDisconnect();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusLabel->setText(tr("Logged onto %1.")
|
|
||||||
.arg(ftpServerLineEdit->text()));
|
|
||||||
fileList->setFocus();
|
|
||||||
downloadButton->setDefault(true);
|
|
||||||
connectButton->setEnabled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//![6]
|
|
||||||
|
|
||||||
//![7]
|
|
||||||
if (ftp->currentCommand() == QFtp::Login)
|
|
||||||
ftp->list();
|
|
||||||
//![7]
|
|
||||||
|
|
||||||
//![8]
|
|
||||||
if (ftp->currentCommand() == QFtp::Get) {
|
|
||||||
if (error) {
|
|
||||||
statusLabel->setText(tr("Canceled download of %1.")
|
|
||||||
.arg(file->fileName()));
|
|
||||||
file->close();
|
|
||||||
file->remove();
|
|
||||||
} else {
|
|
||||||
statusLabel->setText(tr("Downloaded %1 to current directory.")
|
|
||||||
.arg(file->fileName()));
|
|
||||||
file->close();
|
|
||||||
}
|
|
||||||
delete file;
|
|
||||||
enableDownloadButton();
|
|
||||||
progressDialog->hide();
|
|
||||||
//![8]
|
|
||||||
//![9]
|
|
||||||
} else if (ftp->currentCommand() == QFtp::List) {
|
|
||||||
if (isDirectory.isEmpty()) {
|
|
||||||
fileList->addTopLevelItem(new QTreeWidgetItem(QStringList() << tr("<empty>")));
|
|
||||||
fileList->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![9]
|
|
||||||
}
|
|
||||||
|
|
||||||
//![10]
|
|
||||||
void FtpWindow::addToList(const QUrlInfo &urlInfo)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
|
||||||
item->setText(0, urlInfo.name());
|
|
||||||
item->setText(1, QString::number(urlInfo.size()));
|
|
||||||
item->setText(2, urlInfo.owner());
|
|
||||||
item->setText(3, urlInfo.group());
|
|
||||||
item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));
|
|
||||||
|
|
||||||
QPixmap pixmap(urlInfo.isDir() ? ":/images/dir.png" : ":/images/file.png");
|
|
||||||
item->setIcon(0, pixmap);
|
|
||||||
|
|
||||||
isDirectory[urlInfo.name()] = urlInfo.isDir();
|
|
||||||
fileList->addTopLevelItem(item);
|
|
||||||
if (!fileList->currentItem()) {
|
|
||||||
fileList->setCurrentItem(fileList->topLevelItem(0));
|
|
||||||
fileList->setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![10]
|
|
||||||
|
|
||||||
//![11]
|
|
||||||
void FtpWindow::processItem(QTreeWidgetItem *item, int /*column*/)
|
|
||||||
{
|
|
||||||
QString name = item->text(0);
|
|
||||||
if (isDirectory.value(name)) {
|
|
||||||
fileList->clear();
|
|
||||||
isDirectory.clear();
|
|
||||||
currentPath += '/';
|
|
||||||
currentPath += name;
|
|
||||||
ftp->cd(name);
|
|
||||||
ftp->list();
|
|
||||||
cdToParentButton->setEnabled(true);
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
setCursor(Qt::WaitCursor);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![11]
|
|
||||||
|
|
||||||
//![12]
|
|
||||||
void FtpWindow::cdToParent()
|
|
||||||
{
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
setCursor(Qt::WaitCursor);
|
|
||||||
#endif
|
|
||||||
fileList->clear();
|
|
||||||
isDirectory.clear();
|
|
||||||
currentPath = currentPath.left(currentPath.lastIndexOf('/'));
|
|
||||||
if (currentPath.isEmpty()) {
|
|
||||||
cdToParentButton->setEnabled(false);
|
|
||||||
ftp->cd("/");
|
|
||||||
} else {
|
|
||||||
ftp->cd(currentPath);
|
|
||||||
}
|
|
||||||
ftp->list();
|
|
||||||
}
|
|
||||||
//![12]
|
|
||||||
|
|
||||||
//![13]
|
|
||||||
void FtpWindow::updateDataTransferProgress(qint64 readBytes,
|
|
||||||
qint64 totalBytes)
|
|
||||||
{
|
|
||||||
progressDialog->setMaximum(totalBytes);
|
|
||||||
progressDialog->setValue(readBytes);
|
|
||||||
}
|
|
||||||
//![13]
|
|
||||||
|
|
||||||
//![14]
|
|
||||||
void FtpWindow::enableDownloadButton()
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *current = fileList->currentItem();
|
|
||||||
if (current) {
|
|
||||||
QString currentFile = current->text(0);
|
|
||||||
downloadButton->setEnabled(!isDirectory.value(currentFile));
|
|
||||||
} else {
|
|
||||||
downloadButton->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![14]
|
|
||||||
|
|
||||||
void FtpWindow::enableConnectButton()
|
|
||||||
{
|
|
||||||
// Save the used configuration
|
|
||||||
QNetworkConfiguration config = networkSession->configuration();
|
|
||||||
QString id;
|
|
||||||
if (config.type() == QNetworkConfiguration::UserChoice)
|
|
||||||
id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
|
|
||||||
else
|
|
||||||
id = config.identifier();
|
|
||||||
|
|
||||||
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
|
|
||||||
settings.beginGroup(QLatin1String("QtNetwork"));
|
|
||||||
settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
connectButton->setEnabled(true);
|
|
||||||
statusLabel->setText(tr("Please enter the name of an FTP server."));
|
|
||||||
}
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** All rights reserved.
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
|
||||||
** the names of its contributors may be used to endorse or promote
|
|
||||||
** products derived from this software without specific prior written
|
|
||||||
** permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef FTPWINDOW_H
|
|
||||||
#define FTPWINDOW_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QNetworkConfigurationManager>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QDialogButtonBox;
|
|
||||||
class QFile;
|
|
||||||
class QFtp;
|
|
||||||
class QLabel;
|
|
||||||
class QLineEdit;
|
|
||||||
class QTreeWidget;
|
|
||||||
class QTreeWidgetItem;
|
|
||||||
class QProgressDialog;
|
|
||||||
class QPushButton;
|
|
||||||
class QUrlInfo;
|
|
||||||
class QNetworkSession;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class FtpWindow : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
FtpWindow(QWidget *parent = 0);
|
|
||||||
QSize sizeHint() const;
|
|
||||||
|
|
||||||
//![0]
|
|
||||||
private slots:
|
|
||||||
void connectOrDisconnect();
|
|
||||||
void downloadFile();
|
|
||||||
void cancelDownload();
|
|
||||||
void connectToFtp();
|
|
||||||
|
|
||||||
void ftpCommandFinished(int commandId, bool error);
|
|
||||||
void addToList(const QUrlInfo &urlInfo);
|
|
||||||
void processItem(QTreeWidgetItem *item, int column);
|
|
||||||
void cdToParent();
|
|
||||||
void updateDataTransferProgress(qint64 readBytes,
|
|
||||||
qint64 totalBytes);
|
|
||||||
void enableDownloadButton();
|
|
||||||
void enableConnectButton();
|
|
||||||
//![0]
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLabel *ftpServerLabel;
|
|
||||||
QLineEdit *ftpServerLineEdit;
|
|
||||||
QLabel *statusLabel;
|
|
||||||
QTreeWidget *fileList;
|
|
||||||
QPushButton *cdToParentButton;
|
|
||||||
QPushButton *connectButton;
|
|
||||||
QPushButton *downloadButton;
|
|
||||||
QPushButton *quitButton;
|
|
||||||
QDialogButtonBox *buttonBox;
|
|
||||||
QProgressDialog *progressDialog;
|
|
||||||
|
|
||||||
//![1]
|
|
||||||
QHash<QString, bool> isDirectory;
|
|
||||||
QString currentPath;
|
|
||||||
QFtp *ftp;
|
|
||||||
QFile *file;
|
|
||||||
|
|
||||||
QNetworkSession *networkSession;
|
|
||||||
QNetworkConfigurationManager manager;
|
|
||||||
//![1]
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
Before Width: | Height: | Size: 139 B |
Binary file not shown.
Before Width: | Height: | Size: 154 B |
Binary file not shown.
Before Width: | Height: | Size: 129 B |
@ -1,52 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** All rights reserved.
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
|
||||||
** the names of its contributors may be used to endorse or promote
|
|
||||||
** products derived from this software without specific prior written
|
|
||||||
** permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include "ftpwindow.h"
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
Q_INIT_RESOURCE(ftp);
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
FtpWindow ftpWin;
|
|
||||||
ftpWin.show();
|
|
||||||
return ftpWin.exec();
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Encoding=UTF-8
|
|
||||||
Version=1.0
|
|
||||||
Type=Application
|
|
||||||
Terminal=false
|
|
||||||
Name=FTP
|
|
||||||
Exec=/opt/usr/bin/qftp
|
|
||||||
Icon=qftp
|
|
||||||
X-Window-Icon=
|
|
||||||
X-HildonDesk-ShowInToolbar=true
|
|
||||||
X-Osso-Type=application/x-executable
|
|
@ -1,13 +0,0 @@
|
|||||||
QT += widgets
|
|
||||||
|
|
||||||
HEADERS = ftpwindow.h
|
|
||||||
SOURCES = ftpwindow.cpp \
|
|
||||||
main.cpp
|
|
||||||
RESOURCES += ftp.qrc
|
|
||||||
QT += network
|
|
||||||
|
|
||||||
# install
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/qftp
|
|
||||||
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro images
|
|
||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/qftp
|
|
||||||
INSTALLS += target sources
|
|
@ -143,12 +143,8 @@ QByteArray QBufferPrivate::peek(qint64 maxSize)
|
|||||||
|
|
||||||
QBuffer emits readyRead() when new data has arrived in the
|
QBuffer emits readyRead() when new data has arrived in the
|
||||||
buffer. By connecting to this signal, you can use QBuffer to
|
buffer. By connecting to this signal, you can use QBuffer to
|
||||||
store temporary data before processing it. For example, you can
|
store temporary data before processing it. QBuffer also emits
|
||||||
pass the buffer to QFtp when downloading a file from an FTP
|
bytesWritten() every time new data has been written to the buffer.
|
||||||
server. Whenever a new payload of data has been downloaded,
|
|
||||||
readyRead() is emitted, and you can process the data that just
|
|
||||||
arrived. QBuffer also emits bytesWritten() every time new data
|
|
||||||
has been written to the buffer.
|
|
||||||
|
|
||||||
\sa QFile, QDataStream, QTextStream, QByteArray
|
\sa QFile, QDataStream, QTextStream, QByteArray
|
||||||
*/
|
*/
|
||||||
|
@ -471,7 +471,7 @@ void QProcessPrivate::Channel::clear()
|
|||||||
read the standard output by calling read(), readLine(), and
|
read the standard output by calling read(), readLine(), and
|
||||||
getChar(). Because it inherits QIODevice, QProcess can also be
|
getChar(). Because it inherits QIODevice, QProcess can also be
|
||||||
used as an input source for QXmlReader, or for generating data to
|
used as an input source for QXmlReader, or for generating data to
|
||||||
be uploaded using QFtp.
|
be uploaded using QNetworkAccessManager.
|
||||||
|
|
||||||
\note On Windows CE and Symbian, reading and writing to a process
|
\note On Windows CE and Symbian, reading and writing to a process
|
||||||
is not supported.
|
is not supported.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Qt network access module
|
# Qt network access module
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
access/qftp.h \
|
access/qftp_p.h \
|
||||||
access/qhttpheader_p.h \
|
access/qhttpheader_p.h \
|
||||||
access/qhttpnetworkheader_p.h \
|
access/qhttpnetworkheader_p.h \
|
||||||
access/qhttpnetworkrequest_p.h \
|
access/qhttpnetworkrequest_p.h \
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
//#define QFTPPI_DEBUG
|
//#define QFTPPI_DEBUG
|
||||||
//#define QFTPDTP_DEBUG
|
//#define QFTPDTP_DEBUG
|
||||||
|
|
||||||
#include "qftp.h"
|
#include "private/qftp_p.h"
|
||||||
#include "qabstractsocket.h"
|
#include "qabstractsocket.h"
|
||||||
|
|
||||||
#ifndef QT_NO_FTP
|
#ifndef QT_NO_FTP
|
||||||
@ -825,6 +825,8 @@ void QFtpPI::connectToHost(const QString &host, quint16 port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
\internal
|
||||||
|
|
||||||
Sends the sequence of commands \a cmds to the FTP server. When the commands
|
Sends the sequence of commands \a cmds to the FTP server. When the commands
|
||||||
are all done the finished() signal is emitted. When an error occurs, the
|
are all done the finished() signal is emitted. When an error occurs, the
|
||||||
error() signal is emitted.
|
error() signal is emitted.
|
||||||
@ -970,6 +972,8 @@ void QFtpPI::readyRead()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
\internal
|
||||||
|
|
||||||
Process a reply from the FTP server.
|
Process a reply from the FTP server.
|
||||||
|
|
||||||
Returns true if the reply was processed or false if the reply has to be
|
Returns true if the reply was processed or false if the reply has to be
|
||||||
@ -1150,6 +1154,8 @@ bool QFtpPI::processReply()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
\internal
|
||||||
|
|
||||||
Starts next pending command. Returns false if there are no pending commands,
|
Starts next pending command. Returns false if there are no pending commands,
|
||||||
otherwise it returns true.
|
otherwise it returns true.
|
||||||
*/
|
*/
|
||||||
@ -1306,6 +1312,7 @@ int QFtpPrivate::addCommand(QFtpCommand *cmd)
|
|||||||
*
|
*
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\class QFtp
|
\class QFtp
|
||||||
\brief The QFtp class provides an implementation of the client side of FTP protocol.
|
\brief The QFtp class provides an implementation of the client side of FTP protocol.
|
||||||
|
|
||||||
@ -1409,6 +1416,7 @@ int QFtpPrivate::addCommand(QFtpCommand *cmd)
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Constructs a QFtp object with the given \a parent.
|
Constructs a QFtp object with the given \a parent.
|
||||||
*/
|
*/
|
||||||
QFtp::QFtp(QObject *parent)
|
QFtp::QFtp(QObject *parent)
|
||||||
@ -1435,6 +1443,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\enum QFtp::State
|
\enum QFtp::State
|
||||||
|
|
||||||
This enum defines the connection state:
|
This enum defines the connection state:
|
||||||
@ -1451,6 +1460,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
\sa stateChanged() state()
|
\sa stateChanged() state()
|
||||||
*/
|
*/
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\enum QFtp::TransferMode
|
\enum QFtp::TransferMode
|
||||||
|
|
||||||
FTP works with two socket connections; one for commands and
|
FTP works with two socket connections; one for commands and
|
||||||
@ -1468,6 +1478,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
data.
|
data.
|
||||||
*/
|
*/
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\enum QFtp::TransferType
|
\enum QFtp::TransferType
|
||||||
|
|
||||||
This enum identifies the data transfer type used with get and
|
This enum identifies the data transfer type used with get and
|
||||||
@ -1479,6 +1490,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
characters will be converted to the local format.
|
characters will be converted to the local format.
|
||||||
*/
|
*/
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\enum QFtp::Error
|
\enum QFtp::Error
|
||||||
|
|
||||||
This enum identifies the error that occurred.
|
This enum identifies the error that occurred.
|
||||||
@ -1495,6 +1507,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\enum QFtp::Command
|
\enum QFtp::Command
|
||||||
|
|
||||||
This enum is used as the return value for the currentCommand() function.
|
This enum is used as the return value for the currentCommand() function.
|
||||||
@ -1524,6 +1537,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::stateChanged(int state)
|
\fn void QFtp::stateChanged(int state)
|
||||||
|
|
||||||
This signal is emitted when the state of the connection changes.
|
This signal is emitted when the state of the connection changes.
|
||||||
@ -1538,6 +1552,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::listInfo(const QUrlInfo &i);
|
\fn void QFtp::listInfo(const QUrlInfo &i);
|
||||||
|
|
||||||
This signal is emitted for each directory entry the list() command
|
This signal is emitted for each directory entry the list() command
|
||||||
@ -1547,6 +1562,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::commandStarted(int id)
|
\fn void QFtp::commandStarted(int id)
|
||||||
|
|
||||||
This signal is emitted when processing the command identified by
|
This signal is emitted when processing the command identified by
|
||||||
@ -1556,6 +1572,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::commandFinished(int id, bool error)
|
\fn void QFtp::commandFinished(int id, bool error)
|
||||||
|
|
||||||
This signal is emitted when processing the command identified by
|
This signal is emitted when processing the command identified by
|
||||||
@ -1566,6 +1583,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::done(bool error)
|
\fn void QFtp::done(bool error)
|
||||||
|
|
||||||
This signal is emitted when the last pending command has finished;
|
This signal is emitted when the last pending command has finished;
|
||||||
@ -1577,6 +1595,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::readyRead()
|
\fn void QFtp::readyRead()
|
||||||
|
|
||||||
This signal is emitted in response to a get() command when there
|
This signal is emitted in response to a get() command when there
|
||||||
@ -1597,6 +1616,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::dataTransferProgress(qint64 done, qint64 total)
|
\fn void QFtp::dataTransferProgress(qint64 done, qint64 total)
|
||||||
|
|
||||||
This signal is emitted in response to a get() or put() request to
|
This signal is emitted in response to a get() or put() request to
|
||||||
@ -1617,6 +1637,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\fn void QFtp::rawCommandReply(int replyCode, const QString &detail);
|
\fn void QFtp::rawCommandReply(int replyCode, const QString &detail);
|
||||||
|
|
||||||
This signal is emitted in response to the rawCommand() function.
|
This signal is emitted in response to the rawCommand() function.
|
||||||
@ -1627,6 +1648,7 @@ QFtp::QFtp(QObject *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Connects to the FTP server \a host using port \a port.
|
Connects to the FTP server \a host using port \a port.
|
||||||
|
|
||||||
The stateChanged() signal is emitted when the state of the
|
The stateChanged() signal is emitted when the state of the
|
||||||
@ -1655,6 +1677,7 @@ int QFtp::connectToHost(const QString &host, quint16 port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Logs in to the FTP server with the username \a user and the
|
Logs in to the FTP server with the username \a user and the
|
||||||
password \a password.
|
password \a password.
|
||||||
|
|
||||||
@ -1681,6 +1704,7 @@ int QFtp::login(const QString &user, const QString &password)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Closes the connection to the FTP server.
|
Closes the connection to the FTP server.
|
||||||
|
|
||||||
The stateChanged() signal is emitted when the state of the
|
The stateChanged() signal is emitted when the state of the
|
||||||
@ -1704,6 +1728,7 @@ int QFtp::close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Sets the current FTP transfer mode to \a mode. The default is QFtp::Passive.
|
Sets the current FTP transfer mode to \a mode. The default is QFtp::Passive.
|
||||||
|
|
||||||
\sa QFtp::TransferMode
|
\sa QFtp::TransferMode
|
||||||
@ -1717,6 +1742,7 @@ int QFtp::setTransferMode(TransferMode mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Enables use of the FTP proxy on host \a host and port \a
|
Enables use of the FTP proxy on host \a host and port \a
|
||||||
port. Calling this function with \a host empty disables proxying.
|
port. Calling this function with \a host empty disables proxying.
|
||||||
|
|
||||||
@ -1731,6 +1757,7 @@ int QFtp::setProxy(const QString &host, quint16 port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Lists the contents of directory \a dir on the FTP server. If \a
|
Lists the contents of directory \a dir on the FTP server. If \a
|
||||||
dir is empty, it lists the contents of the current directory.
|
dir is empty, it lists the contents of the current directory.
|
||||||
|
|
||||||
@ -1760,6 +1787,7 @@ int QFtp::list(const QString &dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Changes the working directory of the server to \a dir.
|
Changes the working directory of the server to \a dir.
|
||||||
|
|
||||||
The function does not block and returns immediately. The command
|
The function does not block and returns immediately. The command
|
||||||
@ -1779,6 +1807,7 @@ int QFtp::cd(const QString &dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Downloads the file \a file from the server.
|
Downloads the file \a file from the server.
|
||||||
|
|
||||||
If \a dev is 0, then the readyRead() signal is emitted when there
|
If \a dev is 0, then the readyRead() signal is emitted when there
|
||||||
@ -1832,6 +1861,7 @@ int QFtp::get(const QString &file, QIODevice *dev, TransferType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
\overload
|
\overload
|
||||||
|
|
||||||
Writes a copy of the given \a data to the file called \a file on
|
Writes a copy of the given \a data to the file called \a file on
|
||||||
@ -1869,6 +1899,7 @@ int QFtp::put(const QByteArray &data, const QString &file, TransferType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Reads the data from the IO device \a dev, and writes it to the
|
Reads the data from the IO device \a dev, and writes it to the
|
||||||
file called \a file on the server. The data is read in chunks from
|
file called \a file on the server. The data is read in chunks from
|
||||||
the IO device, so this overload allows you to transmit large
|
the IO device, so this overload allows you to transmit large
|
||||||
@ -1897,6 +1928,7 @@ int QFtp::put(QIODevice *dev, const QString &file, TransferType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Deletes the file called \a file from the server.
|
Deletes the file called \a file from the server.
|
||||||
|
|
||||||
The function does not block and returns immediately. The command
|
The function does not block and returns immediately. The command
|
||||||
@ -1916,6 +1948,7 @@ int QFtp::remove(const QString &file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Creates a directory called \a dir on the server.
|
Creates a directory called \a dir on the server.
|
||||||
|
|
||||||
The function does not block and returns immediately. The command
|
The function does not block and returns immediately. The command
|
||||||
@ -1935,6 +1968,7 @@ int QFtp::mkdir(const QString &dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Removes the directory called \a dir from the server.
|
Removes the directory called \a dir from the server.
|
||||||
|
|
||||||
The function does not block and returns immediately. The command
|
The function does not block and returns immediately. The command
|
||||||
@ -1954,6 +1988,7 @@ int QFtp::rmdir(const QString &dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Renames the file called \a oldname to \a newname on the server.
|
Renames the file called \a oldname to \a newname on the server.
|
||||||
|
|
||||||
The function does not block and returns immediately. The command
|
The function does not block and returns immediately. The command
|
||||||
@ -1976,6 +2011,7 @@ int QFtp::rename(const QString &oldname, const QString &newname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Sends the raw FTP command \a command to the FTP server. This is
|
Sends the raw FTP command \a command to the FTP server. This is
|
||||||
useful for low-level FTP access. If the operation you wish to
|
useful for low-level FTP access. If the operation you wish to
|
||||||
perform has an equivalent QFtp function, we recommend using the
|
perform has an equivalent QFtp function, we recommend using the
|
||||||
@ -2000,6 +2036,7 @@ int QFtp::rawCommand(const QString &command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns the number of bytes that can be read from the data socket
|
Returns the number of bytes that can be read from the data socket
|
||||||
at the moment.
|
at the moment.
|
||||||
|
|
||||||
@ -2011,6 +2048,7 @@ qint64 QFtp::bytesAvailable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Reads \a maxlen bytes from the data socket into \a data and
|
Reads \a maxlen bytes from the data socket into \a data and
|
||||||
returns the number of bytes read. Returns -1 if an error occurred.
|
returns the number of bytes read. Returns -1 if an error occurred.
|
||||||
|
|
||||||
@ -2022,6 +2060,7 @@ qint64 QFtp::read(char *data, qint64 maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Reads all the bytes available from the data socket and returns
|
Reads all the bytes available from the data socket and returns
|
||||||
them.
|
them.
|
||||||
|
|
||||||
@ -2033,6 +2072,7 @@ QByteArray QFtp::readAll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Aborts the current command and deletes all scheduled commands.
|
Aborts the current command and deletes all scheduled commands.
|
||||||
|
|
||||||
If there is an unfinished command (i.e. a command for which the
|
If there is an unfinished command (i.e. a command for which the
|
||||||
@ -2071,6 +2111,7 @@ void QFtp::abort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns the identifier of the FTP command that is being executed
|
Returns the identifier of the FTP command that is being executed
|
||||||
or 0 if there is no command being executed.
|
or 0 if there is no command being executed.
|
||||||
|
|
||||||
@ -2084,6 +2125,7 @@ int QFtp::currentId() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns the command type of the FTP command being executed or \c
|
Returns the command type of the FTP command being executed or \c
|
||||||
None if there is no command being executed.
|
None if there is no command being executed.
|
||||||
|
|
||||||
@ -2097,6 +2139,7 @@ QFtp::Command QFtp::currentCommand() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns the QIODevice pointer that is used by the FTP command to read data
|
Returns the QIODevice pointer that is used by the FTP command to read data
|
||||||
from or store data to. If there is no current FTP command being executed or
|
from or store data to. If there is no current FTP command being executed or
|
||||||
if the command does not use an IO device, this function returns 0.
|
if the command does not use an IO device, this function returns 0.
|
||||||
@ -2117,6 +2160,7 @@ QIODevice* QFtp::currentDevice() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns true if there are any commands scheduled that have not yet
|
Returns true if there are any commands scheduled that have not yet
|
||||||
been executed; otherwise returns false.
|
been executed; otherwise returns false.
|
||||||
|
|
||||||
@ -2131,6 +2175,7 @@ bool QFtp::hasPendingCommands() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Deletes all pending commands from the list of scheduled commands.
|
Deletes all pending commands from the list of scheduled commands.
|
||||||
This does not affect the command that is being executed. If you
|
This does not affect the command that is being executed. If you
|
||||||
want to stop this as well, use abort().
|
want to stop this as well, use abort().
|
||||||
@ -2145,6 +2190,7 @@ void QFtp::clearPendingCommands()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns the current state of the object. When the state changes,
|
Returns the current state of the object. When the state changes,
|
||||||
the stateChanged() signal is emitted.
|
the stateChanged() signal is emitted.
|
||||||
|
|
||||||
@ -2156,6 +2202,7 @@ QFtp::State QFtp::state() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns the last error that occurred. This is useful to find out
|
Returns the last error that occurred. This is useful to find out
|
||||||
what went wrong when receiving a commandFinished() or a done()
|
what went wrong when receiving a commandFinished() or a done()
|
||||||
signal with the \c error argument set to \c true.
|
signal with the \c error argument set to \c true.
|
||||||
@ -2168,6 +2215,7 @@ QFtp::Error QFtp::error() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Returns a human-readable description of the last error that
|
Returns a human-readable description of the last error that
|
||||||
occurred. This is useful for presenting a error message to the
|
occurred. This is useful for presenting a error message to the
|
||||||
user when receiving a commandFinished() or a done() signal with
|
user when receiving a commandFinished() or a done() signal with
|
||||||
@ -2385,6 +2433,7 @@ void QFtpPrivate::_q_piFtpReply(int code, const QString &text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\internal
|
||||||
Destructor.
|
Destructor.
|
||||||
*/
|
*/
|
||||||
QFtp::~QFtp()
|
QFtp::~QFtp()
|
||||||
@ -2397,6 +2446,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
#include "qftp.moc"
|
#include "qftp.moc"
|
||||||
|
|
||||||
#include "moc_qftp.cpp"
|
#include "moc_qftp_p.cpp"
|
||||||
|
|
||||||
#endif // QT_NO_FTP
|
#endif // QT_NO_FTP
|
||||||
|
@ -39,6 +39,17 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G
|
||||||
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is not part of the Qt API. It exists for the convenience
|
||||||
|
// of the Network Access API. This header file may change from
|
||||||
|
// version to version without notice, or even be removed.
|
||||||
|
//
|
||||||
|
// We mean it.
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef QFTP_H
|
#ifndef QFTP_H
|
||||||
#define QFTP_H
|
#define QFTP_H
|
||||||
|
|
||||||
@ -56,7 +67,7 @@ QT_MODULE(Network)
|
|||||||
|
|
||||||
class QFtpPrivate;
|
class QFtpPrivate;
|
||||||
|
|
||||||
class Q_NETWORK_EXPORT QFtp : public QObject
|
class Q_AUTOTEST_EXPORT QFtp : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -57,7 +57,7 @@
|
|||||||
#include "qnetworkaccesscache_p.h"
|
#include "qnetworkaccesscache_p.h"
|
||||||
#include "qnetworkrequest.h"
|
#include "qnetworkrequest.h"
|
||||||
#include "qnetworkreply.h"
|
#include "qnetworkreply.h"
|
||||||
#include "QtNetwork/qftp.h"
|
#include "private/qftp_p.h"
|
||||||
|
|
||||||
#include "QtCore/qpointer.h"
|
#include "QtCore/qpointer.h"
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@
|
|||||||
|
|
||||||
QNetworkProxy provides the method for configuring network layer
|
QNetworkProxy provides the method for configuring network layer
|
||||||
proxy support to the Qt network classes. The currently supported
|
proxy support to the Qt network classes. The currently supported
|
||||||
classes are QAbstractSocket, QTcpSocket, QUdpSocket, QTcpServer,
|
classes are QAbstractSocket, QTcpSocket, QUdpSocket, QTcpServer
|
||||||
QNetworkAccessManager and QFtp. The proxy support is designed to
|
and QNetworkAccessManager. The proxy support is designed to
|
||||||
be as transparent as possible. This means that existing
|
be as transparent as possible. This means that existing
|
||||||
network-enabled applications that you have written should
|
network-enabled applications that you have written should
|
||||||
automatically support network proxy using the following code.
|
automatically support network proxy using the following code.
|
||||||
@ -166,8 +166,7 @@
|
|||||||
\row
|
\row
|
||||||
\o Caching FTP
|
\o Caching FTP
|
||||||
\o Implemented using an FTP proxy, it is useful only in the
|
\o Implemented using an FTP proxy, it is useful only in the
|
||||||
context of FTP requests (see QFtp,
|
context of FTP requests (see QNetworkAccessManager)
|
||||||
QNetworkAccessManager)
|
|
||||||
\o CachingCapability, HostNameLookupCapability
|
\o CachingCapability, HostNameLookupCapability
|
||||||
|
|
||||||
\endtable
|
\endtable
|
||||||
|
@ -163,7 +163,7 @@
|
|||||||
issue to be aware of, though: You must make sure that enough data
|
issue to be aware of, though: You must make sure that enough data
|
||||||
is available before attempting to read it using operator>>().
|
is available before attempting to read it using operator>>().
|
||||||
|
|
||||||
\sa QFtp, QNetworkAccessManager, QTcpServer
|
\sa QNetworkAccessManager, QTcpServer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
\bold{Note:} TCP sockets cannot be opened in QIODevice::Unbuffered mode.
|
\bold{Note:} TCP sockets cannot be opened in QIODevice::Unbuffered mode.
|
||||||
|
|
||||||
\sa QTcpServer, QUdpSocket, QFtp, QNetworkAccessManager,
|
\sa QTcpServer, QUdpSocket, QNetworkAccessManager,
|
||||||
{Fortune Server Example}, {Fortune Client Example},
|
{Fortune Server Example}, {Fortune Client Example},
|
||||||
{Threaded Fortune Server Example}, {Blocking Fortune Client Example},
|
{Threaded Fortune Server Example}, {Blocking Fortune Client Example},
|
||||||
{Loopback Example}, {Torrent Example}
|
{Loopback Example}, {Torrent Example}
|
||||||
|
@ -397,7 +397,6 @@ QT_CLASS_LIB(QXmlStreamStringRef, QtXml, qxmlstream.h)
|
|||||||
QT_CLASS_LIB(QXmlStreamWriter, QtXml, qxmlstream.h)
|
QT_CLASS_LIB(QXmlStreamWriter, QtXml, qxmlstream.h)
|
||||||
QT_CLASS_LIB(QNetworkCacheMetaData, QtNetwork, qabstractnetworkcache.h)
|
QT_CLASS_LIB(QNetworkCacheMetaData, QtNetwork, qabstractnetworkcache.h)
|
||||||
QT_CLASS_LIB(QAbstractNetworkCache, QtNetwork, qabstractnetworkcache.h)
|
QT_CLASS_LIB(QAbstractNetworkCache, QtNetwork, qabstractnetworkcache.h)
|
||||||
QT_CLASS_LIB(QFtp, QtNetwork, qftp.h)
|
|
||||||
QT_CLASS_LIB(QHttpHeader, QtNetwork, qhttpheader_p.h)
|
QT_CLASS_LIB(QHttpHeader, QtNetwork, qhttpheader_p.h)
|
||||||
QT_CLASS_LIB(QHttpResponseHeader, QtNetwork, qhttpheader_p.h)
|
QT_CLASS_LIB(QHttpResponseHeader, QtNetwork, qhttpheader_p.h)
|
||||||
QT_CLASS_LIB(QNetworkAccessManager, QtNetwork, qnetworkaccessmanager.h)
|
QT_CLASS_LIB(QNetworkAccessManager, QtNetwork, qnetworkaccessmanager.h)
|
||||||
|
@ -192,9 +192,8 @@ bool QProgressBarPrivate::repaintRequired() const
|
|||||||
|
|
||||||
If minimum and maximum both are set to 0, the bar shows a busy
|
If minimum and maximum both are set to 0, the bar shows a busy
|
||||||
indicator instead of a percentage of steps. This is useful, for
|
indicator instead of a percentage of steps. This is useful, for
|
||||||
example, when using QFtp or QNetworkAccessManager to download
|
example, when using QNetworkAccessManager to download items when
|
||||||
items when they are unable to determine the size of the item being
|
they are unable to determine the size of the item being downloaded.
|
||||||
downloaded.
|
|
||||||
|
|
||||||
\table
|
\table
|
||||||
\row \o \inlineimage macintosh-progressbar.png Screenshot of a Macintosh style progress bar
|
\row \o \inlineimage macintosh-progressbar.png Screenshot of a Macintosh style progress bar
|
||||||
|
@ -8,12 +8,11 @@ SUBDIRS=\
|
|||||||
qhttpnetworkconnection \
|
qhttpnetworkconnection \
|
||||||
qnetworkreply \
|
qnetworkreply \
|
||||||
qnetworkcachemetadata \
|
qnetworkcachemetadata \
|
||||||
qftp \
|
|
||||||
qhttpnetworkreply \
|
qhttpnetworkreply \
|
||||||
qabstractnetworkcache \
|
qabstractnetworkcache \
|
||||||
|
|
||||||
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
|
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
|
||||||
qhttpnetworkconnection \
|
qhttpnetworkconnection \
|
||||||
qhttpnetworkreply \
|
qhttpnetworkreply \
|
||||||
|
qftp \
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include <qcoreapplication.h>
|
#include <qcoreapplication.h>
|
||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
#include <qbuffer.h>
|
#include <qbuffer.h>
|
||||||
#include "qftp.h"
|
#include "private/qftp_p.h"
|
||||||
#include <qmap.h>
|
#include <qmap.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -54,7 +54,9 @@
|
|||||||
#include <QtNetwork/QLocalSocket>
|
#include <QtNetwork/QLocalSocket>
|
||||||
#include <QtNetwork/QLocalServer>
|
#include <QtNetwork/QLocalServer>
|
||||||
#include <QtNetwork/QHostInfo>
|
#include <QtNetwork/QHostInfo>
|
||||||
#include <QtNetwork/QFtp>
|
#include <QtNetwork/QNetworkAccessManager>
|
||||||
|
#include <QtNetwork/QNetworkRequest>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <QtNetwork/QAbstractNetworkCache>
|
#include <QtNetwork/QAbstractNetworkCache>
|
||||||
#include <QtNetwork/qauthenticator.h>
|
#include <QtNetwork/qauthenticator.h>
|
||||||
#include <QtNetwork/qnetworkaccessmanager.h>
|
#include <QtNetwork/qnetworkaccessmanager.h>
|
||||||
@ -1849,23 +1851,22 @@ void tst_QNetworkReply::putToFtp()
|
|||||||
|
|
||||||
// download the file again from FTP to make sure it was uploaded
|
// download the file again from FTP to make sure it was uploaded
|
||||||
// correctly
|
// correctly
|
||||||
QFtp ftp;
|
QNetworkAccessManager qnam;
|
||||||
ftp.connectToHost(url.host());
|
QNetworkRequest req(url);
|
||||||
ftp.login();
|
QNetworkReply *r = qnam.get(req);
|
||||||
ftp.get(url.path());
|
|
||||||
|
|
||||||
QObject::connect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::connect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
QTestEventLoop::instance().enterLoop(10);
|
QTestEventLoop::instance().enterLoop(10);
|
||||||
QObject::disconnect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::disconnect(r, SIGNAL(finished(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
|
|
||||||
QByteArray uploaded = ftp.readAll();
|
QByteArray uploaded = r->readAll();
|
||||||
QCOMPARE(uploaded.size(), data.size());
|
QCOMPARE(uploaded.size(), data.size());
|
||||||
QCOMPARE(uploaded, data);
|
QCOMPARE(uploaded, data);
|
||||||
|
|
||||||
ftp.close();
|
r->close();
|
||||||
QObject::connect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::connect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
QTestEventLoop::instance().enterLoop(10);
|
QTestEventLoop::instance().enterLoop(10);
|
||||||
QObject::disconnect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::disconnect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QNetworkReply::putToHttp_data()
|
void tst_QNetworkReply::putToHttp_data()
|
||||||
@ -3901,23 +3902,22 @@ void tst_QNetworkReply::ioPutToFtpFromFile()
|
|||||||
|
|
||||||
// download the file again from FTP to make sure it was uploaded
|
// download the file again from FTP to make sure it was uploaded
|
||||||
// correctly
|
// correctly
|
||||||
QFtp ftp;
|
QNetworkAccessManager qnam;
|
||||||
ftp.connectToHost(url.host());
|
QNetworkRequest req(url);
|
||||||
ftp.login();
|
QNetworkReply *r = qnam.get(req);
|
||||||
ftp.get(url.path());
|
|
||||||
|
|
||||||
QObject::connect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::connect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
QTestEventLoop::instance().enterLoop(3);
|
QTestEventLoop::instance().enterLoop(3);
|
||||||
QObject::disconnect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::disconnect(r, SIGNAL(finished(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
|
|
||||||
QByteArray uploaded = ftp.readAll();
|
QByteArray uploaded = r->readAll();
|
||||||
QCOMPARE(qint64(uploaded.size()), sourceFile.size());
|
QCOMPARE(qint64(uploaded.size()), sourceFile.size());
|
||||||
QCOMPARE(uploaded, sourceFile.readAll());
|
QCOMPARE(uploaded, sourceFile.readAll());
|
||||||
|
|
||||||
ftp.close();
|
r->close();
|
||||||
QObject::connect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::connect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
QTestEventLoop::instance().enterLoop(10);
|
QTestEventLoop::instance().enterLoop(10);
|
||||||
QObject::disconnect(&ftp, SIGNAL(done(bool)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
QObject::disconnect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QNetworkReply::ioPutToHttpFromFile_data()
|
void tst_QNetworkReply::ioPutToHttpFromFile_data()
|
||||||
|
Loading…
Reference in New Issue
Block a user