Qyoto  4.0.7
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties
QtNetwork.QFtp Class Reference

The QFtp class provides an implementation of the client side of FTP protocol. More...

Inheritance diagram for QtNetwork.QFtp:
Collaboration diagram for QtNetwork.QFtp:

Public Types

enum  Command {
  Cd = 7, Close = 5, ConnectToHost = 3, Get = 8,
  List = 6, Login = 4, Mkdir = 11, None = 0,
  Put = 9, RawCommand = 14, Remove = 10, Rename = 13,
  Rmdir = 12, SetProxy = 2, SetTransferMode = 1
}
  More...
 
enum  Error {
  ConnectionRefused = 3, HostNotFound = 2, NoError = 0, NotConnected = 4,
  UnknownError = 1
}
  More...
 
enum  State {
  Closing = 5, Connected = 3, Connecting = 2, HostLookup = 1,
  LoggedIn = 4, Unconnected = 0
}
  More...
 
enum  TransferMode { Active = 0, Passive = 1 }
  More...
 
enum  TransferType { Ascii = 1, Binary = 0 }
  More...
 

Public Member Functions

 QFtp (QObject parent=null)
  More...
 
override void CreateProxy ()
 
new void Abort ()
  More...
 
new int Cd (string dir)
  More...
 
new void ClearPendingCommands ()
  More...
 
new int Close ()
  More...
 
new int ConnectToHost (string host, ushort port=21)
  More...
 
new int Get (string file, QIODevice dev=null, QFtp.TransferType type=QFtp.TransferType.Binary)
  More...
 
new int List (string dir="")
  More...
 
new int Login (string user="", string password="")
  More...
 
new int Mkdir (string dir)
  More...
 
new int Put (QByteArray data, string file, QFtp.TransferType type=QFtp.TransferType.Binary)
  More...
 
new int Put (QIODevice dev, string file, QFtp.TransferType type=QFtp.TransferType.Binary)
  More...
 
new int RawCommand (string command)
  More...
 
new long Read (Pointer< sbyte > data, long maxlen)
  More...
 
new QByteArray ReadAll ()
  More...
 
new int Remove (string file)
  More...
 
new int Rename (string oldname, string newname)
  More...
 
new int Rmdir (string dir)
  More...
 
new int SetProxy (string host, ushort port)
  More...
 
new int SetTransferMode (QFtp.TransferMode mode)
  More...
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.QObject
 QObject (QObject parent=null)
  More...
 
new bool BlockSignals (bool b)
  More...
 
new bool Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
  More...
 
new void DeleteLater ()
  More...
 
new bool Disconnect (QObject receiver, string member=null)
  More...
 
new bool Disconnect (string signal=null, QObject receiver=null, string member=null)
  More...
 
new void DumpObjectInfo ()
  More...
 
new void DumpObjectTree ()
  More...
 
virtual bool OnEvent (QEvent e)
  More...
 
virtual bool EventFilter (QObject watched, QEvent @event)
  More...
 
new bool Inherits (string classname)
  More...
 
new void InstallEventFilter (QObject filterObj)
  More...
 
new void KillTimer (int id)
  More...
 
new object Property (string name)
  More...
 
new void RemoveEventFilter (QObject obj)
  More...
 
new bool SetProperty (string name, object value)
  More...
 
new void SetUserData (uint id, QObjectUserData data)
 
new int StartTimer (int interval)
  More...
 
new QObjectUserData UserData (uint id)
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.Qt
delegate QTextStream FuncQTextStreamQTextStream (QTextStream qTextStream)
 
delegate void ActionQtMsgTypeString (QtMsgType qtMsgType, string @string)
 
delegate QObject FuncQObject ()
 
delegate string FuncStringQByteArray (QByteArray qByteArray)
 
delegate QByteArray FuncQByteArrayString (string @string)
 

Static Public Member Functions

static string Tr (string s, string c=null)
 
static string Tr (string s, string c, int n)
 
static string TrUtf8 (string s, string c=null)
 
static string TrUtf8 (string s, string c, int n)
 
- Static Public Member Functions inherited from QtCore.QObject
static bool Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
  More...
 
static bool Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
  More...
 
static bool Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member)
  More...
 
static bool Disconnect (QObject sender, string signal, QObject receiver, string member)
  More...
 
static string Tr (string s, string c=null)
  More...
 
static string Tr (string s, string c, int n)
  More...
 
static string TrUtf8 (string s, string c=null)
  More...
 
static string TrUtf8 (string s, string c, int n)
  More...
 
- Static Public Member Functions inherited from QtCore.Qt
static QDataStream Write (QDataStream s, object p)
 
static QDataStream Write (QDataStream stream, QSizeF size)
  More...
 
static QDataStream Write (QDataStream stream, QPoint point)
  More...
 
static QTextStream Write (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Write (QDataStream stream, QLineF line)
  More...
 
static QDataStream Write (QDataStream stream, QPointF point)
  More...
 
static QDataStream Write (QDataStream @out, QChar chr)
  More...
 
static QDataStream Write (QDataStream @out, QByteArray ba)
  More...
 
static QDataStream Write (QDataStream stream, QEasingCurve easing)
  More...
 
static QDataStream Write (QDataStream stream, QRectF rectangle)
  More...
 
static QDataStream Write (QDataStream @out, QDateTime dateTime)
  More...
 
static QDataStream Write (QDataStream @out, QUrl url)
  More...
 
static QDataStream Write (QDataStream @out, QTime time)
  More...
 
static QDataStream Write (QDataStream arg1, QLocale arg2)
 
static QDataStream Write (QDataStream @out, QBitArray ba)
  More...
 
static QDataStream Write (QDataStream s, QUuid id)
  More...
 
static QDataStream Write (QDataStream stream, QLine line)
  More...
 
static QDataStream Write (QDataStream @out, QDate date)
  More...
 
static QDataStream Write (QDataStream @out, QRegExp regExp)
  More...
 
static QDataStream Write (QDataStream stream, QRect rectangle)
  More...
 
static QDataStream Write (QDataStream stream, QSize size)
  More...
 
static QDataStream Write (QDataStream s, QVariant.Type p)
 
static QDataStream Write (QDataStream arg1, string arg2)
 
static QDataStream Write (QDataStream @out, System.Collections.Generic.List< string > list)
  More...
 
static QDataStream Read (QDataStream @in, QChar chr)
  More...
 
static QDataStream Read (QDataStream arg1, QLocale arg2)
 
static QDataStream Read (QDataStream stream, QRect rectangle)
  More...
 
static QDataStream Read (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Read (QDataStream @in, QDate date)
  More...
 
static QDataStream Read (QDataStream @in, QUrl url)
  More...
 
static QDataStream Read (QDataStream s, QUuid id)
  More...
 
static QTextStream Read (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Read (QDataStream stream, QLineF line)
  More...
 
static QDataStream Read (QDataStream stream, QRectF rectangle)
  More...
 
static QDataStream Read (QDataStream stream, QPointF point)
  More...
 
static QDataStream Read (QDataStream stream, QLine line)
  More...
 
static QDataStream Read (QDataStream @in, QBitArray ba)
  More...
 
static QDataStream Read (QDataStream stream, QSize size)
  More...
 
static QDataStream Read (QDataStream @in, QDateTime dateTime)
  More...
 
static QDataStream Read (QDataStream @in, QTime time)
  More...
 
static QDataStream Read (QDataStream stream, QPoint point)
  More...
 
static QDataStream Read (QDataStream @in, QRegExp regExp)
  More...
 
static QDataStream Read (QDataStream s, object p)
 
static QDataStream Read (QDataStream @in, QByteArray ba)
  More...
 
static QDataStream Read (QDataStream stream, QSizeF size)
  More...
 
static QDataStream Read (QDataStream arg1, string arg2)
 
static QDataStream Read (QDataStream s, QVariant.Type p)
 
static QDataStream Read (QDataStream @in, System.Collections.Generic.List< string > list)
  More...
 
static double QAcos (double v)
  More...
 
static void QAddPostRoutine (System.Action ptr)
  More...
 
static double QAsin (double v)
  More...
 
static double QAtan (double v)
  More...
 
static double QAtan2 (double x, double y)
  More...
 
static void QBadAlloc ()
 
static int QCeil (double v)
  More...
 
static ushort QChecksum (string s, uint len)
  More...
 
static QByteArray QCompress (QByteArray data, int compressionLevel=-1)
  More...
 
static QByteArray QCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1)
  More...
 
static double QCos (double v)
  More...
 
static double QExp (double v)
  More...
 
static double QFabs (double v)
 
static double QFastCos (double x)
 
static double QFastSin (double x)
 
static string QFlagLocation (string method)
 
static int QFloor (double v)
  More...
 
static bool QFuzzyCompare (double p1, double p2)
  More...
 
static bool QFuzzyCompare (float p1, float p2)
  More...
 
static bool QFuzzyIsNull (double d)
 
static bool QFuzzyIsNull (float f)
 
static uint QHash (QBitArray key)
  More...
 
static uint QHash (QChar key)
  More...
 
static uint QHash (QStringRef key)
 
static uint QHash (QUrl url)
  More...
 
static uint QHash (QPersistentModelIndex index)
 
static uint QHash (QByteArray key)
  More...
 
static uint QHash (QModelIndex index)
 
static uint QHash (uint key)
  More...
 
static uint QHash (char key)
  More...
 
static uint QHash (byte key)
  More...
 
static uint QHash (short key)
  More...
 
static uint QHash (NativeLong key)
  More...
 
static uint QHash (ushort key)
  More...
 
static uint QHash (long key)
  More...
 
static uint QHash (ulong key)
  More...
 
static uint QHash (int key)
  More...
 
static uint QHash (string key)
  More...
 
static uint QHash (NativeULong key)
  More...
 
static Qt.ActionQtMsgTypeString QInstallMsgHandler (Qt.ActionQtMsgTypeString handler)
  More...
 
static int QIntCast (float f)
 
static int QIntCast (double f)
 
static bool QIsFinite (double d)
 
static bool QIsFinite (float f)
 
static bool QIsInf (float f)
 
static bool QIsInf (double d)
 
static bool QIsNaN (float f)
 
static bool QIsNaN (double d)
 
static bool QIsNull (float f)
 
static bool QIsNull (double d)
 
static double QLn (double v)
  More...
 
static double QPow (double x, double y)
  More...
 
static void QRegisterStaticPluginInstanceFunction (Qt.FuncQObject function)
  More...
 
static void QRemovePostRoutine (System.Action arg1)
 
static int QRound (double d)
  More...
 
static long QRound64 (double d)
  More...
 
static double QSin (double v)
  More...
 
static double QSqrt (double v)
  More...
 
static bool QStringComparisonHelper (QStringRef s1, string s2)
 
static double QTan (double v)
  More...
 
static QByteArray QUncompress (QByteArray data)
  More...
 
static QByteArray QUncompress (Pointer< byte > data, int nbytes)
  More...
 
static void Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size)
 
static QByteArray Qgetenv (string varName)
  More...
 
static bool Qputenv (string varName, QByteArray value)
  More...
 
static void Qsrand (uint seed)
  More...
 
static int Qstrcmp (QByteArray str1, QByteArray str2)
 
static int Qstrcmp (QByteArray str1, string str2)
 
static int Qstrcmp (string str1, QByteArray str2)
 
static int Qstrcmp (string str1, string str2)
  More...
 
static Pointer< sbyte > Qstrcpy (Pointer< sbyte > dst, string src)
  More...
 
static Pointer< sbyte > Qstrdup (string src)
  More...
 
static int Qstricmp (string str1, string str2)
  More...
 
static uint Qstrlen (string str)
  More...
 
static int Qstrncmp (string str1, string str2, uint len)
  More...
 
static Pointer< sbyte > Qstrncpy (Pointer< sbyte > dst, string src, uint len)
  More...
 
static int Qstrnicmp (string str1, string str2, uint len)
  More...
 
static uint Qstrnlen (string str, uint maxlen)
  More...
 

Protected Member Functions

 QFtp (System.Type dummy)
 
new void OnCommandFinished (int id, bool error)
  More...
 
new void OnCommandStarted (int id)
  More...
 
new void OnDataTransferProgress (long done, long total)
  More...
 
new void OnDone (bool error)
  More...
 
new void OnListInfo (QUrlInfo i)
  More...
 
new void OnRawCommandReply (int replyCode, string detail)
  More...
 
new void OnReadyRead ()
  More...
 
new void OnStateChanged (int state)
  More...
 
- Protected Member Functions inherited from QtCore.QObject
 QObject (System.Type dummy)
 
virtual void OnChildEvent (QChildEvent @event)
  More...
 
virtual void ConnectNotify (string signal)
  More...
 
virtual void OnCustomEvent (QEvent @event)
  More...
 
new void OnDestroyed (QObject obj=null)
  More...
 
virtual void DisconnectNotify (string signal)
  More...
 
new int Receivers (string signal)
  More...
 
virtual void OnTimerEvent (QTimerEvent @event)
  More...
 

Properties

Slot< System.Int32 > StateChanged
  More...
 
Slot< QUrlInfoListInfo
  More...
 
Slot ReadyRead
  More...
 
Slot< System.Int64, System.Int64 > DataTransferProgress
  More...
 
Slot< System.Int32, System.String > RawCommandReply
  More...
 
Slot< System.Int32 > CommandStarted
  More...
 
Slot< System.Int32,
System.Boolean > 
CommandFinished
  More...
 
Slot< System.Boolean > Done
  More...
 
long BytesAvailable [get]
  More...
 
QFtp.Command CurrentCommand [get]
  More...
 
QIODevice CurrentDevice [get]
  More...
 
int CurrentId [get]
  More...
 
QFtp.Error error [get]
  More...
 
string ErrorString [get]
  More...
 
bool HasPendingCommands [get]
  More...
 
QFtp.State state [get]
  More...
 
static new QMetaObject StaticMetaObject [get]
 
new IQFtpSignals Emit [get]
 
- Properties inherited from QtCore.QObject
virtual EventHandler
< QEventArgs< QChildEvent > > 
ChildEvent
  More...
 
virtual EventHandler
< QEventArgs< QEvent > > 
CustomEvent
  More...
 
virtual EventHandler
< QEventArgs< QEvent > > 
Event
  More...
 
virtual EventHandler
< QEventArgs< QTimerEvent > > 
TimerEvent
  More...
 
Slot< QObjectDestroyedObj
  More...
 
Slot Destroyed
  More...
 
QObject Parent [get, set]
  More...
 
System.Collections.Generic.List
< QObject
Children [get]
  More...
 
System.Collections.Generic.List
< QByteArray
DynamicPropertyNames [get]
  More...
 
bool IsWidgetType [get]
  More...
 
static uint RegisterUserData [get]
 
QObject Sender [get]
  More...
 
int SenderSignalIndex [get]
  More...
 
bool SignalsBlocked [get]
  More...
 
virtual System.IntPtr SmokeObject [get, set]
 
new string ObjectName [get, set]
  More...
 
static new QMetaObject StaticMetaObject [get]
  More...
 
static new QMetaObject StaticQtMetaObject [get]
 
new IQObjectSignals Emit [get]
 
- Properties inherited from QtCore.Qt
static string QAppName [get]
 
static double QInf [get]
 
static double QQNaN [get]
 
static double QSNaN [get]
 
static bool QSharedBuild [get]
 
static string QVersion [get]
  More...
 
static int Qrand [get]
  More...
 

Additional Inherited Members

- Static Public Attributes inherited from QtCore.Qt
</para > *< para > Creating QM
files suitable for use with
this[SmokeMethod("qtTrId(const
char*, int)")] static strin 
QtTrId )(string id, int n=-1)
 
- Protected Attributes inherited from QtCore.QObject
object Q_EMIT = null
 
SmokeInvocation interceptor
 
readonly List< QEventHandler > eventFilters = new List<QEventHandler>()
 

Detailed Description

The QFtp class provides an implementation of the client side of FTP protocol.

This class provides a direct interface to FTP that allows you to have more control over the requests. However, for new applications, it is recommended to use QNetworkAccessManager and QNetworkReply, as those classes possess a simpler, yet more powerful API.

The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.

The operations that can be scheduled (they are called "commands" in the rest of the documentation) are the following: connectToHost(), login(), close(), list(), cd(), get(), put(), remove(), mkdir(), rmdir(), rename() and rawCommand().

All of these commands return a unique identifier that allows you to keep track of the command that is currently being executed. When the execution of a command starts, the commandStarted() signal with the command's identifier is emitted. When the command is finished, the commandFinished() signal is emitted with the command's identifier and a bool that indicates whether the command finished with an error.

In some cases, you might want to execute a sequence of commands, e.g. if you want to connect and login to a FTP server. This is simply achieved:

QFtp *ftp = new QFtp(parent);

ftp->connectToHost("ftp.qt.nokia.com");

ftp->login();

In this case two FTP commands have been scheduled. When the last scheduled command has finished, a done() signal is emitted with a bool argument that tells you whether the sequence finished with an error.

If an error occurs during the execution of one of the commands in a sequence of commands, all the pending commands (i.e. scheduled, but not yet executed commands) are cleared and no signals are emitted for them.

Some commands, e.g. list(), emit additional signals to report their results.

Example: If you want to download the INSTALL file from the Qt FTP server, you would write this:

ftp->connectToHost("ftp.qt.nokia.com"); // id == 1

ftp->login(); // id == 2

ftp->cd("qt"); // id == 3

ftp->get("INSTALL"); // id == 4

ftp->close(); // id == 5

For this example the following sequence of signals is emitted (with small variations, depending on network traffic, etc.):

start(1)

stateChanged(HostLookup)

stateChanged(Connecting)

stateChanged(Connected)

finished(1, false)

start(2)

stateChanged(LoggedIn)

finished(2, false)

start(3)

finished(3, false)

start(4)

dataTransferProgress(0, 3798)

dataTransferProgress(2896, 3798)

readyRead()

dataTransferProgress(3798, 3798)

readyRead()

finished(4, false)

start(5)

stateChanged(Closing)

stateChanged(Unconnected)

finished(5, false)

done(false)

The dataTransferProgress() signal in the above example is useful if you want to show a progress bar to inform the user about the progress of the download. The readyRead() signal tells you that there is data ready to be read. The amount of data can be queried then with the bytesAvailable() function and it can be read with the read() or readAll() function.

If the login fails for the above example, the signals would look like this:

start(1)

stateChanged(HostLookup)

stateChanged(Connecting)

stateChanged(Connected)

finished(1, false)

start(2)

finished(2, true)

done(true)

You can then get details about the error with the error() and errorString() functions.

For file transfer, QFtp can use both active or passive mode, and it uses passive file transfer mode by default; see the documentation for setTransferMode() for more details about this.

Call setProxy() to make QFtp connect via an FTP proxy server.

The functions currentId() and currentCommand() provide more information about the currently executing command.

The functions hasPendingCommands() and clearPendingCommands() allow you to query and clear the list of pending commands.

If you are an experienced network programmer and want to have complete control you can use rawCommand() to execute arbitrary FTP commands.

Warning: The current version of QFtp doesn't fully support non-Unix FTP servers.

See also QNetworkAccessManager, QNetworkRequest, QNetworkReply, and FTP Example.

Member Enumeration Documentation

This enum is used as the return value for the currentCommand() function. This allows you to perform specific actions for particular commands, e.g. in a FTP client, you might want to clear the directory view when a list() command is started; in this case you can simply check in the slot connected to the start() signal if the currentCommand() is List.

See also currentCommand().

Enumerator
Cd 

Cd() is being executed.

Close 

Close() is being executed.

ConnectToHost 

ConnectToHost() is being executed.

Get 

Get() is being executed.

List 

List() is being executed.

Login 

Login() is being executed.

Mkdir 

Mkdir() is being executed.

None 

No command is being executed.

Put 

Put() is being executed.

RawCommand 

RawCommand() is being executed.

Remove 

Remove() is being executed.

Rename 

Rename() is being executed.

Rmdir 

Rmdir() is being executed.

SetProxy 

Switch proxying on or off.

SetTransferMode 

Set the transfer mode.

This enum identifies the error that occurred.

See also error().

Enumerator
ConnectionRefused 

The server refused the connection.

HostNotFound 

The host name lookup failed.

NoError 

No error occurred.

NotConnected 

Tried to send a command, but there is no connection to a server.

UnknownError 

An error other than those specified above occurred.

This enum defines the connection state:

See also stateChanged() and state().

Enumerator
Closing 

The connection is closing down, but it is not yet closed. (The state will be Unconnected when the connection is closed.)

Connected 

Connection to the host has been achieved.

Connecting 

An attempt to connect to the host is in progress.

HostLookup 

A host name lookup is in progress.

LoggedIn 

Connection and user login have been achieved.

Unconnected 

There is no connection to the host.

FTP works with two socket connections; one for commands and another for transmitting data. While the command connection is always initiated by the client, the second connection can be initiated by either the client or the server.

This enum defines whether the client (Passive mode) or the server (Active mode) should set up the data connection.

Enumerator
Active 

The server connects to the client to transmit its data.

Passive 

The client connects to the server to transmit its data.

This enum identifies the data transfer type used with get and put commands.

Enumerator
Ascii 

The data will be transferred in Ascii mode and new line characters will be converted to the local format.

Binary 

The data will be transferred in Binary mode.

Constructor & Destructor Documentation

QtNetwork.QFtp.QFtp ( System.Type  dummy)
protected
QtNetwork.QFtp.QFtp ( QObject  parent = null)

Constructs a QFtp object with the given parent.

Here is the call graph for this function:

Member Function Documentation

new void QtNetwork.QFtp.Abort ( )

Aborts the current command and deletes all scheduled commands.

If there is an unfinished command (i.e. a command for which the commandStarted() signal has been emitted, but for which the commandFinished() signal has not been emitted), this function sends an ABORT command to the server. When the server replies that the command is aborted, the commandFinished() signal with the error argument set to true is emitted for the command. Due to timing issues, it is possible that the command had already finished before the abort request reached the server, in which case, the commandFinished() signal is emitted with the error argument set to false.

For all other commands that are affected by the abort(), no signals are emitted.

If you don't start further FTP commands directly after the abort(), there won't be any scheduled commands and the done() signal is emitted.

Warning: Some FTP servers, for example the BSD FTP daemon (version 0.3), wrongly return a positive reply even when an abort has occurred. For these servers the commandFinished() signal has its error flag set to false, even though the command did not complete successfully.

See also clearPendingCommands().

new int QtNetwork.QFtp.Cd ( string  dir)

Changes the working directory of the server to dir.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also commandStarted() and commandFinished().

new void QtNetwork.QFtp.ClearPendingCommands ( )

Deletes all pending commands from the list of scheduled commands. This does not affect the command that is being executed. If you want to stop this as well, use abort().

See also hasPendingCommands() and abort().

new int QtNetwork.QFtp.Close ( )

Closes the connection to the FTP server.

The stateChanged() signal is emitted when the state of the connecting process changes, e.g. to Closing, then Unconnected.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also stateChanged(), commandStarted(), and commandFinished().

new int QtNetwork.QFtp.ConnectToHost ( string  host,
ushort  port = 21 
)

Connects to the FTP server host using port port.

The stateChanged() signal is emitted when the state of the connecting process changes, e.g. to HostLookup, then Connecting, then Connected.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also stateChanged(), commandStarted(), and commandFinished().

override void QtNetwork.QFtp.CreateProxy ( )
virtual

Reimplemented from QtCore.QObject.

Here is the caller graph for this function:

new void QtNetwork.QFtp.Dispose ( )
new int QtNetwork.QFtp.Get ( string  file,
QIODevice  dev = null,
QFtp.TransferType  type = QFtp.TransferType.Binary 
)

Downloads the file file from the server.

If dev is 0, then the readyRead() signal is emitted when there is data available to read. You can then read the data with the read() or readAll() functions.

If dev is not 0, the data is written directly to the device dev. Make sure that the dev pointer is valid for the duration of the operation (it is safe to delete it when the commandFinished() signal is emitted). In this case the readyRead() signal is not emitted and you cannot read data with the read() or readAll() functions.

If you don't read the data immediately it becomes available, i.e. when the readyRead() signal is emitted, it is still available until the next command is started.

For example, if you want to present the data to the user as soon as there is something available, connect to the readyRead() signal and read the data immediately. On the other hand, if you only want to work with the complete data, you can connect to the commandFinished() signal and read the data when the get() command is finished.

The data is transferred as Binary or Ascii depending on the value of type.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

commandFinished()

See also readyRead(), dataTransferProgress(), and commandStarted().

new int QtNetwork.QFtp.List ( string  dir = "")

Lists the contents of directory dir on the FTP server. If dir is empty, it lists the contents of the current directory.

The listInfo() signal is emitted for each directory entry found.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also listInfo(), commandStarted(), and commandFinished().

new int QtNetwork.QFtp.Login ( string  user = "",
string  password = "" 
)

Logs in to the FTP server with the username user and the password password.

The stateChanged() signal is emitted when the state of the connecting process changes, e.g. to LoggedIn.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also commandStarted() and commandFinished().

new int QtNetwork.QFtp.Mkdir ( string  dir)

Creates a directory called dir on the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also commandStarted() and commandFinished().

new void QtNetwork.QFtp.OnCommandFinished ( int  id,
bool  error 
)
protected

This signal is emitted when processing the command identified by id has finished. error is true if an error occurred during the processing; otherwise error is false.

See also commandStarted(), done(), error(), and errorString().

new void QtNetwork.QFtp.OnCommandStarted ( int  id)
protected

This signal is emitted when processing the command identified by id starts.

See also commandFinished() and done().

new void QtNetwork.QFtp.OnDataTransferProgress ( long  done,
long  total 
)
protected

This signal is emitted in response to a get() or put() request to indicate the current progress of the download or upload.

done is the amount of data that has already been transferred and total is the total amount of data to be read or written. It is possible that the QFtp class is not able to determine the total amount of data that should be transferred, in which case total is 0. (If you connect this signal to a QProgressBar, the progress bar shows a busy indicator if the total is 0).

Warning: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.

See also get(), put(), and QProgressBar.

new void QtNetwork.QFtp.OnDone ( bool  error)
protected

This signal is emitted when the last pending command has finished; (it is emitted after the last command's commandFinished() signal). error is true if an error occurred during the processing; otherwise error is false.

See also commandFinished(), error(), and errorString().

new void QtNetwork.QFtp.OnListInfo ( QUrlInfo  i)
protected

This signal is emitted for each directory entry the list() command finds. The details of the entry are stored in i.

See also list().

new void QtNetwork.QFtp.OnRawCommandReply ( int  replyCode,
string  detail 
)
protected

This signal is emitted in response to the rawCommand() function. replyCode is the 3 digit reply code and detail is the text that follows the reply code.

See also rawCommand().

new void QtNetwork.QFtp.OnReadyRead ( )
protected

This signal is emitted in response to a get() command when there is new data to read.

If you specify a device as the second argument in the get() command, this signal is not emitted; instead the data is written directly to the device.

You can read the data with the readAll() or read() functions.

This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the commandFinished() signal and read the data then instead.

See also get(), read(), readAll(), and bytesAvailable().

new void QtNetwork.QFtp.OnStateChanged ( int  state)
protected

This signal is emitted when the state of the connection changes. The argument state is the new state of the connection; it is one of the State values.

It is usually emitted in response to a connectToHost() or close() command, but it can also be emitted "spontaneously", e.g. when the server closes the connection unexpectedly.

See also connectToHost(), close(), state(), and State.

new int QtNetwork.QFtp.Put ( QByteArray  data,
string  file,
QFtp.TransferType  type = QFtp.TransferType.Binary 
)

This is an overloaded function.

Writes a copy of the given data to the file called file on the server. The progress of the upload is reported by the dataTransferProgress() signal.

The data is transferred as Binary or Ascii depending on the value of type.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Since this function takes a copy of the data, you can discard your own copy when this function returns.

See also dataTransferProgress(), commandStarted(), and commandFinished().

new int QtNetwork.QFtp.Put ( QIODevice  dev,
string  file,
QFtp.TransferType  type = QFtp.TransferType.Binary 
)

Reads the data from the IO device dev, and writes it to the file called file on the server. The data is read in chunks from the IO device, so this overload allows you to transmit large amounts of data without the need to read all the data into memory at once.

The data is transferred as Binary or Ascii depending on the value of type.

Make sure that the dev pointer is valid for the duration of the operation (it is safe to delete it when the commandFinished() is emitted).

new int QtNetwork.QFtp.RawCommand ( string  command)

Sends the raw FTP command command to the FTP server. This is useful for low-level FTP access. If the operation you wish to perform has an equivalent QFtp function, we recommend using the function instead of raw FTP commands since the functions are easier and safer.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also rawCommandReply(), commandStarted(), and commandFinished().

new long QtNetwork.QFtp.Read ( Pointer< sbyte >  data,
long  maxlen 
)

Reads maxlen bytes from the data socket into data and returns the number of bytes read. Returns -1 if an error occurred.

See also get(), readyRead(), bytesAvailable(), and readAll().

new QByteArray QtNetwork.QFtp.ReadAll ( )

Reads all the bytes available from the data socket and returns them.

See also get(), readyRead(), bytesAvailable(), and read().

new int QtNetwork.QFtp.Remove ( string  file)

Deletes the file called file from the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also commandStarted() and commandFinished().

new int QtNetwork.QFtp.Rename ( string  oldname,
string  newname 
)

Renames the file called oldname to newname on the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also commandStarted() and commandFinished().

new int QtNetwork.QFtp.Rmdir ( string  dir)

Removes the directory called dir from the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

See also commandStarted() and commandFinished().

new int QtNetwork.QFtp.SetProxy ( string  host,
ushort  port 
)

Enables use of the FTP proxy on host host and port port. Calling this function with host empty disables proxying.

QFtp does not support FTP-over-HTTP proxy servers. Use QNetworkAccessManager for this.

new int QtNetwork.QFtp.SetTransferMode ( QFtp.TransferMode  mode)

Sets the current FTP transfer mode to mode. The default is QFtp::Passive.

See also QFtp::TransferMode.

static string QtNetwork.QFtp.Tr ( string  s,
string  c = null 
)
static
static string QtNetwork.QFtp.Tr ( string  s,
string  c,
int  n 
)
static
static string QtNetwork.QFtp.TrUtf8 ( string  s,
string  c = null 
)
static
static string QtNetwork.QFtp.TrUtf8 ( string  s,
string  c,
int  n 
)
static

Property Documentation

long QtNetwork.QFtp.BytesAvailable
get

Returns the number of bytes that can be read from the data socket at the moment.

See also get(), readyRead(), read(), and readAll().

Slot<System.Int32,System.Boolean> QtNetwork.QFtp.CommandFinished
addremove

This signal is emitted when processing the command identified by id has finished. error is true if an error occurred during the processing; otherwise error is false.

See also commandStarted(), done(), error(), and errorString().

Slot<System.Int32> QtNetwork.QFtp.CommandStarted
addremove

This signal is emitted when processing the command identified by id starts.

See also commandFinished() and done().

QFtp.Command QtNetwork.QFtp.CurrentCommand
get

Returns the command type of the FTP command being executed or None if there is no command being executed.

See also currentId().

QIODevice QtNetwork.QFtp.CurrentDevice
get

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 if the command does not use an IO device, this function returns 0.

This function can be used to delete the QIODevice in the slot connected to the commandFinished() signal.

See also get() and put().

int QtNetwork.QFtp.CurrentId
get

Returns the identifier of the FTP command that is being executed or 0 if there is no command being executed.

See also currentCommand().

Slot<System.Int64,System.Int64> QtNetwork.QFtp.DataTransferProgress
addremove

This signal is emitted in response to a get() or put() request to indicate the current progress of the download or upload.

done is the amount of data that has already been transferred and total is the total amount of data to be read or written. It is possible that the QFtp class is not able to determine the total amount of data that should be transferred, in which case total is 0. (If you connect this signal to a QProgressBar, the progress bar shows a busy indicator if the total is 0).

Warning: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.

See also get(), put(), and QProgressBar.

Slot<System.Boolean> QtNetwork.QFtp.Done
addremove

This signal is emitted when the last pending command has finished; (it is emitted after the last command's commandFinished() signal). error is true if an error occurred during the processing; otherwise error is false.

See also commandFinished(), error(), and errorString().

new IQFtpSignals QtNetwork.QFtp.Emit
getprotected
QFtp.Error QtNetwork.QFtp.error
get

Returns the last error that occurred. This is useful to find out what went wrong when receiving a commandFinished() or a done() signal with the error argument set to true.

If you start a new command, the error status is reset to NoError.

string QtNetwork.QFtp.ErrorString
get

Returns a human-readable description of the last error that occurred. This is useful for presenting a error message to the user when receiving a commandFinished() or a done() signal with the error argument set to true.

The error string is often (but not always) the reply from the server, so it is not always possible to translate the string. If the message comes from Qt, the string has already passed through tr().

bool QtNetwork.QFtp.HasPendingCommands
get

Returns true if there are any commands scheduled that have not yet been executed; otherwise returns false.

The command that is being executed is not considered as a scheduled command.

See also clearPendingCommands(), currentId(), and currentCommand().

Slot<QUrlInfo> QtNetwork.QFtp.ListInfo
addremove

This signal is emitted for each directory entry the list() command finds. The details of the entry are stored in i.

See also list().

Slot<System.Int32,System.String> QtNetwork.QFtp.RawCommandReply
addremove

This signal is emitted in response to the rawCommand() function. replyCode is the 3 digit reply code and detail is the text that follows the reply code.

See also rawCommand().

Slot QtNetwork.QFtp.ReadyRead
addremove

This signal is emitted in response to a get() command when there is new data to read.

If you specify a device as the second argument in the get() command, this signal is not emitted; instead the data is written directly to the device.

You can read the data with the readAll() or read() functions.

This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the commandFinished() signal and read the data then instead.

See also get(), read(), readAll(), and bytesAvailable().

QFtp.State QtNetwork.QFtp.state
get

Returns the current state of the object. When the state changes, the stateChanged() signal is emitted.

See also State and stateChanged().

Slot<System.Int32> QtNetwork.QFtp.StateChanged
addremove

This signal is emitted when the state of the connection changes. The argument state is the new state of the connection; it is one of the State values.

It is usually emitted in response to a connectToHost() or close() command, but it can also be emitted "spontaneously", e.g. when the server closes the connection unexpectedly.

See also connectToHost(), close(), state(), and State.

new QMetaObject QtNetwork.QFtp.StaticMetaObject
staticget