Qt 4.8
Public Functions | Public Variables | List of all members
QFtpPrivate Class Reference
Inheritance diagram for QFtpPrivate:
QObjectPrivate QObjectData

Public Functions

void _q_piConnectState (int)
 
void _q_piError (int, const QString &)
 
void _q_piFinished (const QString &)
 
void _q_piFtpReply (int, const QString &)
 
void _q_startNextCommand ()
 
int addCommand (QFtpCommand *cmd)
 
 QFtpPrivate ()
 
 ~QFtpPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

bool close_waitForStateChange
 
QFtp::Error error
 
QString errorString
 
QString host
 
QList< QFtpCommand * > pending
 
QFtpPI pi
 
quint16 port
 
QString proxyHost
 
quint16 proxyPort
 
QFtp::State state
 
QFtp::TransferMode transferMode
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 1302 of file qftp.cpp.

Constructors and Destructors

◆ QFtpPrivate()

QFtpPrivate::QFtpPrivate ( )
inline

Definition at line 1307 of file qftp.cpp.

1309  { }
QFtp::TransferMode transferMode
Definition: qftp.cpp:1326
bool close_waitForStateChange
Definition: qftp.cpp:1324
QFtp::Error error
Definition: qftp.cpp:1327
QFtp::State state
Definition: qftp.cpp:1325

◆ ~QFtpPrivate()

QFtpPrivate::~QFtpPrivate ( )
inline

Definition at line 1311 of file qftp.cpp.

1311 { while (!pending.isEmpty()) delete pending.takeFirst(); }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
QList< QFtpCommand * > pending
Definition: qftp.cpp:1323

Functions

◆ _q_piConnectState()

void QFtpPrivate::_q_piConnectState ( int  connectState)
Warning
This function is not part of the public interface.

Definition at line 2491 of file qftp.cpp.

2492 {
2493  state = QFtp::State(connectState);
2494  emit q_func()->stateChanged(state);
2496  close_waitForStateChange = false;
2497  _q_piFinished(QLatin1String(QT_TRANSLATE_NOOP("QFtp", "Connection closed")));
2498  }
2499 }
void _q_piFinished(const QString &)
Definition: qftp.cpp:2385
State
This enum defines the connection state:
Definition: qftp.h:67
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define emit
Definition: qobjectdefs.h:76
bool close_waitForStateChange
Definition: qftp.cpp:1324
QFtp::State state
Definition: qftp.cpp:1325

◆ _q_piError()

void QFtpPrivate::_q_piError ( int  errorCode,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 2415 of file qftp.cpp.

2416 {
2417  Q_Q(QFtp);
2418 
2419  if (pending.isEmpty()) {
2420  qWarning("QFtpPrivate::_q_piError was called without pending command!");
2421  return;
2422  }
2423 
2424  QFtpCommand *c = pending.first();
2425 
2426  // non-fatal errors
2427  if (c->command == QFtp::Get && pi.currentCommand().startsWith(QLatin1String("SIZE "))) {
2428  pi.dtp.setBytesTotal(0);
2429  return;
2430  } else if (c->command==QFtp::Put && pi.currentCommand().startsWith(QLatin1String("ALLO "))) {
2431  return;
2432  }
2433 
2434  error = QFtp::Error(errorCode);
2435  switch (q->currentCommand()) {
2436  case QFtp::ConnectToHost:
2437  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Connecting to host failed:\n%1"))
2438  .arg(text);
2439  break;
2440  case QFtp::Login:
2441  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Login failed:\n%1"))
2442  .arg(text);
2443  break;
2444  case QFtp::List:
2445  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Listing directory failed:\n%1"))
2446  .arg(text);
2447  break;
2448  case QFtp::Cd:
2449  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Changing directory failed:\n%1"))
2450  .arg(text);
2451  break;
2452  case QFtp::Get:
2453  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Downloading file failed:\n%1"))
2454  .arg(text);
2455  break;
2456  case QFtp::Put:
2457  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Uploading file failed:\n%1"))
2458  .arg(text);
2459  break;
2460  case QFtp::Remove:
2461  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Removing file failed:\n%1"))
2462  .arg(text);
2463  break;
2464  case QFtp::Mkdir:
2465  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Creating directory failed:\n%1"))
2466  .arg(text);
2467  break;
2468  case QFtp::Rmdir:
2469  errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Removing directory failed:\n%1"))
2470  .arg(text);
2471  break;
2472  default:
2473  errorString = text;
2474  break;
2475  }
2476 
2478  q->clearPendingCommands();
2479  emit q->commandFinished(c->id, true);
2480 
2481  pending.removeFirst();
2482  delete c;
2483  if (pending.isEmpty())
2484  emit q->done(true);
2485  else
2487 }
QFtp::Command command
Definition: qftp.cpp:241
unsigned char c[8]
Definition: qnumeric_p.h:62
int id
Definition: qftp.cpp:240
QString errorString
Definition: qftp.cpp:1328
QFtpPI pi
Definition: qftp.cpp:1322
Definition: qftp.h:90
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QFtp class provides an implementation of the client side of FTP protocol.
Definition: qftp.h:59
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define Q_Q(Class)
Definition: qglobal.h:2483
Error
This enum identifies the error that occurred.
Definition: qftp.h:75
QString currentCommand() const
Definition: qftp.cpp:168
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
void removeFirst()
Removes the first item in the list.
Definition: qlist.h:286
void setBytesTotal(qint64 bytes)
Definition: qftp.cpp:306
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QList< QFtpCommand * > pending
Definition: qftp.cpp:1323
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void _q_startNextCommand()
Definition: qftp.cpp:2312
Definition: qftp.h:91
QFtp::Error error
Definition: qftp.cpp:1327
void clearPendingCommands()
Definition: qftp.cpp:883
QFtpDTP dtp
Definition: qftp.cpp:174
#define text
Definition: qobjectdefs.h:80
Definition: qftp.h:92

◆ _q_piFinished()

void QFtpPrivate::_q_piFinished ( const QString )
Warning
This function is not part of the public interface.

Definition at line 2385 of file qftp.cpp.

2386 {
2387  if (pending.isEmpty())
2388  return;
2389  QFtpCommand *c = pending.first();
2390 
2391  if (c->command == QFtp::Close) {
2392  // The order of in which the slots are called is arbitrary, so
2393  // disconnect the SIGNAL-SIGNAL temporary to make sure that we
2394  // don't get the commandFinished() signal before the stateChanged()
2395  // signal.
2396  if (state != QFtp::Unconnected) {
2397  close_waitForStateChange = true;
2398  return;
2399  }
2400  }
2401  emit q_func()->commandFinished(c->id, false);
2402  pending.removeFirst();
2403 
2404  delete c;
2405 
2406  if (pending.isEmpty()) {
2407  emit q_func()->done(false);
2408  } else {
2410  }
2411 }
QFtp::Command command
Definition: qftp.cpp:241
unsigned char c[8]
Definition: qnumeric_p.h:62
int id
Definition: qftp.cpp:240
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define emit
Definition: qobjectdefs.h:76
void removeFirst()
Removes the first item in the list.
Definition: qlist.h:286
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QList< QFtpCommand * > pending
Definition: qftp.cpp:1323
void _q_startNextCommand()
Definition: qftp.cpp:2312
bool close_waitForStateChange
Definition: qftp.cpp:1324
QFtp::State state
Definition: qftp.cpp:1325

◆ _q_piFtpReply()

void QFtpPrivate::_q_piFtpReply ( int  code,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 2503 of file qftp.cpp.

2504 {
2505  if (q_func()->currentCommand() == QFtp::RawCommand) {
2506  pi.rawCommand = true;
2507  emit q_func()->rawCommandReply(code, text);
2508  }
2509 }
QFtpPI pi
Definition: qftp.cpp:1322
#define emit
Definition: qobjectdefs.h:76
bool rawCommand
Definition: qftp.cpp:171

◆ _q_startNextCommand()

void QFtpPrivate::_q_startNextCommand ( )
Warning
This function is not part of the public interface.

Definition at line 2312 of file qftp.cpp.

2313 {
2314  Q_Q(QFtp);
2315  if (pending.isEmpty())
2316  return;
2317  QFtpCommand *c = pending.first();
2318 
2319  error = QFtp::NoError;
2320  errorString = QT_TRANSLATE_NOOP(QFtp, QLatin1String("Unknown error"));
2321 
2322  if (q->bytesAvailable())
2323  q->readAll(); // clear the data
2324  emit q->commandStarted(c->id);
2325 
2326  // Proxy support, replace the Login argument in place, then fall
2327  // through.
2328  if (c->command == QFtp::Login && !proxyHost.isEmpty()) {
2329  QString loginString = c->rawCmds.first().trimmed();
2330  loginString += QLatin1Char('@') + host;
2331  if (port && port != 21)
2332  loginString += QLatin1Char(':') + QString::number(port);
2333  loginString += QLatin1String("\r\n");
2334  c->rawCmds[0] = loginString;
2335  }
2336 
2337  if (c->command == QFtp::SetTransferMode) {
2338  _q_piFinished(QLatin1String("Transfer mode set"));
2339  } else if (c->command == QFtp::SetProxy) {
2340  proxyHost = c->rawCmds[0];
2341  proxyPort = c->rawCmds[1].toUInt();
2342  c->rawCmds.clear();
2344  } else if (c->command == QFtp::ConnectToHost) {
2345 #ifndef QT_NO_BEARERMANAGEMENT
2346  //copy network session down to the PI
2347  pi.setProperty("_q_networksession", q->property("_q_networksession"));
2348 #endif
2349  if (!proxyHost.isEmpty()) {
2350  host = c->rawCmds[0];
2351  port = c->rawCmds[1].toUInt();
2353  } else {
2354  pi.connectToHost(c->rawCmds[0], c->rawCmds[1].toUInt());
2355  }
2356  } else {
2357  if (c->command == QFtp::Put) {
2358  if (c->is_ba) {
2359  pi.dtp.setData(c->data.ba);
2360  pi.dtp.setBytesTotal(c->data.ba->size());
2361  } else if (c->data.dev && (c->data.dev->isOpen() || c->data.dev->open(QIODevice::ReadOnly))) {
2362  pi.dtp.setDevice(c->data.dev);
2363  if (c->data.dev->isSequential()) {
2364  pi.dtp.setBytesTotal(0);
2365  pi.dtp.connect(c->data.dev, SIGNAL(readyRead()), SLOT(dataReadyRead()));
2366  pi.dtp.connect(c->data.dev, SIGNAL(readChannelFinished()), SLOT(dataReadyRead()));
2367  } else {
2368  pi.dtp.setBytesTotal(c->data.dev->size());
2369  }
2370  }
2371  } else if (c->command == QFtp::Get) {
2372  if (!c->is_ba && c->data.dev) {
2373  pi.dtp.setDevice(c->data.dev);
2374  }
2375  } else if (c->command == QFtp::Close) {
2376  state = QFtp::Closing;
2377  emit q->stateChanged(state);
2378  }
2379  pi.sendCommands(c->rawCmds);
2380  }
2381 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
Definition: qiodevice.cpp:642
QFtp::Command command
Definition: qftp.cpp:241
unsigned char c[8]
Definition: qnumeric_p.h:62
int id
Definition: qftp.cpp:240
QString errorString
Definition: qftp.cpp:1328
QFtpPI pi
Definition: qftp.cpp:1322
void _q_piFinished(const QString &)
Definition: qftp.cpp:2385
#define SLOT(a)
Definition: qobjectdefs.h:226
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setData(QByteArray *)
Definition: qftp.cpp:294
The QFtp class provides an implementation of the client side of FTP protocol.
Definition: qftp.h:59
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define Q_Q(Class)
Definition: qglobal.h:2483
bool is_ba
Definition: qftp.cpp:250
#define SIGNAL(a)
Definition: qobjectdefs.h:227
bool isOpen() const
Returns true if the device is open; otherwise returns false.
Definition: qiodevice.cpp:530
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
QString proxyHost
Definition: qftp.cpp:1332
QIODevice * dev
Definition: qftp.cpp:248
void connectToHost(const QString &host, quint16 port)
Definition: qftp.cpp:849
void clear()
Removes all items from the list.
Definition: qlist.h:764
void setBytesTotal(qint64 bytes)
Definition: qftp.cpp:306
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
Definition: qiodevice.cpp:454
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
bool sendCommands(const QStringList &cmds)
Definition: qftp.cpp:868
QList< QFtpCommand * > pending
Definition: qftp.cpp:1323
QStringList rawCmds
Definition: qftp.cpp:242
Definition: qftp.h:91
QByteArray * ba
Definition: qftp.cpp:247
quint16 proxyPort
Definition: qftp.cpp:1333
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
Definition: qiodevice.cpp:570
union QFtpCommand::@311 data
QFtp::Error error
Definition: qftp.cpp:1327
quint16 port
Definition: qftp.cpp:1331
void setDevice(QIODevice *)
Definition: qftp.cpp:300
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QFtpDTP dtp
Definition: qftp.cpp:174
QString host
Definition: qftp.cpp:1330
Definition: qftp.h:92
QFtp::State state
Definition: qftp.cpp:1325

◆ addCommand()

int QFtpPrivate::addCommand ( QFtpCommand cmd)

Definition at line 1336 of file qftp.cpp.

1337 {
1338  pending.append(cmd);
1339 
1340  if (pending.count() == 1) {
1341  // don't emit the commandStarted() signal before the ID is returned
1342  QTimer::singleShot(0, q_func(), SLOT(_q_startNextCommand()));
1343  }
1344  return cmd->id;
1345 }
int id
Definition: qftp.cpp:240
#define SLOT(a)
Definition: qobjectdefs.h:226
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QFtpCommand * > pending
Definition: qftp.cpp:1323
void _q_startNextCommand()
Definition: qftp.cpp:2312
bool singleShot
This static function calls a slot after a given time interval.
Definition: qtimer.h:59

Properties

◆ close_waitForStateChange

bool QFtpPrivate::close_waitForStateChange

Definition at line 1324 of file qftp.cpp.

◆ error

QFtp::Error QFtpPrivate::error

Definition at line 1327 of file qftp.cpp.

◆ errorString

QString QFtpPrivate::errorString

Definition at line 1328 of file qftp.cpp.

◆ host

QString QFtpPrivate::host

Definition at line 1330 of file qftp.cpp.

◆ pending

QList<QFtpCommand *> QFtpPrivate::pending

Definition at line 1323 of file qftp.cpp.

◆ pi

QFtpPI QFtpPrivate::pi

Definition at line 1322 of file qftp.cpp.

◆ port

quint16 QFtpPrivate::port

Definition at line 1331 of file qftp.cpp.

◆ proxyHost

QString QFtpPrivate::proxyHost

Definition at line 1332 of file qftp.cpp.

◆ proxyPort

quint16 QFtpPrivate::proxyPort

Definition at line 1333 of file qftp.cpp.

◆ state

QFtp::State QFtpPrivate::state

Definition at line 1325 of file qftp.cpp.

◆ transferMode

QFtp::TransferMode QFtpPrivate::transferMode

Definition at line 1326 of file qftp.cpp.


The documentation for this class was generated from the following file: