NNet Class Reference

NNet is the generic API for nvemFTP's protocol interface. More...

#include <nnet.h>

Inheritance diagram for NNet:

NFtp

Public Types

enum  logType {
  NERR = 0, NINFO, NREPLY, NCOMMAND,
  NCUSTOM, NOTHER
}
 Specifies the classification of the log(). More...

enum  errorType {
  ErrNo = 0, ErrHostInvalid, ErrHostNotFound, ErrConnectionRefused,
  ErrNotConnected, ErrConnected, ErrSocketBusy, ErrFileSeek,
  ErrUnknown
}
 Specifies the classification of the error returned. More...

enum  Operations {
  OpList = 0, OpGet, OpPut, OpCWD,
  OpFxp, OpRemove, OpRaw, OpIdle,
  OpConnecting, OpInvalid
}
 Specifies the classification of the current operation. More...


Public Slots

virtual int closeConnection ()=0
 Disconnect from remote system.


Signals

void log (int id, NNet::logType type, QString msg)
 Any commands sent, replies given, errors, warnings, or other info should emit a log signal with a NNet::logType classification and a human readable string.

void connectionClosed (int id, NHostInfo hInfo)
 Connection to the remote system was closed.

void changedDirectory (int id, const QString &dirname)
 Directory on remote system changed.

void connected (int id, NHostInfo hInfo)
 Connection opened.

void transferProgress (int id, unsigned int current, unsigned int total)
 Transfer Progress changed.

void transferComplete (int id, bool finished, uint bytes, int time, double rate)
 Transfer completed.

void directoryListing (int id, const QValueList< QUrlInfo > &dirList)
 Directory listing from remote system.

void loginComplete (int id)
 Login proccess completed.


Public Member Functions

 NNet (int id, QObject *parent=0, const char *name=0)
 Creates an NNet object.

virtual ~NNet ()
 Virtual destructor.

virtual const char * protocol () const=0
 Returns the url prefix for the protocol implemented.

virtual const char * name () const
 Returns the name the implementation refers to itself as.

virtual int connectToHost (NHostInfo hInfo, bool batch=false)=0
 Connects to the host specified.

virtual int sendRawCommand (QString command)=0
 Send a custom command to the server.

virtual int get (QString file, QString destfile, bool resume=false)=0
 Retrieves a single file.

virtual int put (QString file, QString sourcefile, bool resume=false)=0
 Uploads a single file.

virtual int list ()=0
 Request a directory listing.

virtual int cd (QString dir)=0
 Changes the current directory.

virtual int move (QString newname, QString oldname)=0
 Moves a file from one place to another.

virtual int remove (QString name, bool recursive=false)=0
 Removes a remote file/directory.

virtual int makedir (QString dir)=0
 Create a directory.

virtual int abort ()=0
 Abort current operation.

virtual const NHostInfo getHostInfo () const
 Returns the host information for the current connection.

virtual bool isConnected () const
 Returns a boolean affirmation that the object is connected and ready for commands.

virtual int currentOperation () const
 Returns the state of the object in the form of a NNet::Operations enum.


Protected Member Functions

virtual QCString findDirCache (QString dir, int timeout=-1) const
 Locate directory cache for the requested directory.

virtual void addDirCache (QString dir, QCString dirListing)
 Adds a directory listing to the cache.

virtual void clearDirCache ()
 Clears the directory cache.

QString getAppSetting (QString setName, QString defVal="") const
 Get a setting from the applications settings.

int getAppSetting (QString setName, int defVal) const
 Get a setting from the applications settings.

QString getProtSetting (QString setName, QString defVal="") const
 Get a setting that is specific to the protocol.

int getProtSetting (QString setName, int defVal) const
 Get a setting that is specific to the protocol.

QString getHostSetting (QString setName, QString defVal="") const
 Get a setting that is specific to the hostInfo.

int getHostSetting (QString setName, int defVal) const
 Get a setting that is specific to the hostInfo.


Protected Attributes

int _id
 ID of this object. Used for all signals.

QSocket * commandSock
 QSocket for use as the main communications socket.

QSocket * dataSock
 QSocket for the secondary socket if the protocol requires it.

NHostInfo hostInfo
 Holds the most up to date information regarding the connection.

bool commandDelayedClose
 Boolean state marker for if the command socket is performing a delayed close.

bool dataDelayedClose
 Boolean state marker for if the data socket is performing a delayed close.

bool commandReady
 Boolean state marker signifying that the connection is ready to accept operations.

bool expectedClose
 Boolean state marker signifying that a connection close is expected.

bool _batch
 Marks if this object is meant to be used for batch operations, or user interaction.

QCString currentDirListing
 Holds the raw directory listing of the current directory, if available.

Operations currentOp
 Holds the current operation.


Detailed Description

NNet is the generic API for nvemFTP's protocol interface.

This only provides the specifications for interface, with few exceptions: directory caching logic, connection/operation state variables and a pair of QSockets.


Member Enumeration Documentation

enum NNet::errorType
 

Specifies the classification of the error returned.

Enumeration values:
ErrNo  No error, requested operation succeeded.
ErrHostInvalid  URL given is invalid.
ErrHostNotFound  Hostname failed to resolve.
ErrConnectionRefused  Host refused connection attempt.
ErrNotConnected  Object not connected, Invalid request.
ErrConnected  Already connected.
ErrSocketBusy  Socket already busy, operation unable to proceed.
ErrFileSeek  File read error.
ErrUnknown  Unknown error, unable to proceed.

enum NNet::logType
 

Specifies the classification of the log().

Enumeration values:
NERR  Errors.
NINFO  Informational.
NREPLY  Replies from the remote system.
NCOMMAND  Commands sent from the client.
NCUSTOM  Replies from the remote system that originated due to a sendRawCommand().
NOTHER  Anything else that doesn't fit the above classifications.

enum NNet::Operations
 

Specifies the classification of the current operation.

Enumeration values:
OpList  Listing directory.
OpGet  Retrieving a file from the remote system.
OpPut  Uploading a file to the remote system.
OpCWD  Changing directories.
OpFxp  FXP operation.
OpRemove  Removing files from remote system, likely recursively.
OpRaw  Performing a custom command as given by sendRawCommand().
OpIdle  Idle, no operation in progress.
OpConnecting  Connecting to remote system.
OpInvalid  Not connected.


Constructor & Destructor Documentation

NNet::NNet int  id,
QObject *  parent = 0,
const char *  name = 0
 

Creates an NNet object.

This should never be called directly. Instantiate only from derivatives.
Prepares the directory cache for the object, everything else is left to derivatives.

NNet::~NNet  )  [virtual]
 

Virtual destructor.

Clears directory cache, all else is left to derivative.


Member Function Documentation

virtual int NNet::abort  )  [pure virtual]
 

Abort current operation.

Request an abortion of the current operation from the remote system. The abort should attempt to recover the session into a reusable state.

Returns:
ErrNotConnected if no remote system is connected.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

void NNet::addDirCache QString  dir,
QCString  dirListing
[protected, virtual]
 

Adds a directory listing to the cache.

Parameters:
dir Absolute path of the directory listing to store.
dirListing Raw directory listing to store.

virtual int NNet::cd QString  dir  )  [pure virtual]
 

Changes the current directory.

Changes the directory on the remote system. If the protocol does not support persistent sessions, the protocol implementation should still remember the "current" directory as known to the object.

Returns:
ErrNotConnected if no remote system is connected.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

void NNet::changedDirectory int  id,
const QString &  dirname
[signal]
 

Directory on remote system changed.

Parameters:
id ID of this object (_id)
dirname Absolute path (on remote system) of new current directory.

void NNet::clearDirCache  )  [protected, virtual]
 

Clears the directory cache.

virtual int NNet::closeConnection  )  [pure virtual, slot]
 

Disconnect from remote system.

Disconnect object from any remote connections and return it to a usable, unconnected, state.

Returns:
ErrNo if the disconnect was successful.

Implemented in NFtp.

void NNet::connected int  id,
NHostInfo  hInfo
[signal]
 

Connection opened.

Parameters:
id ID of this object (_id)
hInfo URL of the remote system newly connected.

void NNet::connectionClosed int  id,
NHostInfo  hInfo
[signal]
 

Connection to the remote system was closed.

Parameters:
id ID of this object (_id)
hInfo Last valid URL for the connection, including protocol, host, port, username, and password.

virtual int NNet::connectToHost NHostInfo  hInfo,
bool  batch = false
[pure virtual]
 

Connects to the host specified.

Parameters:
hInfo URL of host to connect to, including username, password, port, and initial directory.
batch Specifies if the connection should perform an initial directory listing.
Returns:
ErrConnected if the object is already connected.

ErrHostInvalid if the given URL is invalid.

ErrUnknown if the URL requests a protocol that we don't handle.

ErrNo if the operation was started successfully.

Implemented in NFtp.

virtual int NNet::currentOperation  )  const [inline, virtual]
 

Returns the state of the object in the form of a NNet::Operations enum.

Returns:
currentOp

void NNet::directoryListing int  id,
const QValueList< QUrlInfo > &  dirList
[signal]
 

Directory listing from remote system.

Parameters:
id ID of this object (_id)
dirList A pre-parsed QValueList containing QUrlInfo objects for each directory entry.

QCString NNet::findDirCache QString  dir,
int  timeout = -1
const [protected, virtual]
 

Locate directory cache for the requested directory.

Parameters:
dir Absolute path of the requested directory listing.
timeout Time in seconds that the cache entry must be newer than. Default will look up the application's setting for it.
Returns:
QCString of the raw directory listing, or an empty string if not found or expired.

virtual int NNet::get QString  file,
QString  destfile,
bool  resume = false
[pure virtual]
 

Retrieves a single file.

Requests file from the remote system, and save it to destfile on the local system. Protocol implementation is responsible for file creation. Resume should be attempted if protocol supports it, and resume is true; or if the protocol's AutoResume option is set to on.

Returns:
ErrNotConnected if no remote system is connected.

ErrSocketBusy if the current operation is not OpIdle.

ErrFileSeek if local file creation fails.

ErrUnknown if the operation is unhandled. This makes the implementation fairly useless, though.

ErrNo if the operation was started successfully.

Implemented in NFtp.

int NNet::getAppSetting QString  setName,
int  defVal
const [protected]
 

Get a setting from the applications settings.

Overloaded version of above.

Parameters:
setName Name of the setting to retrieve.
defVal Default value to return if the setting does not exist.

QString NNet::getAppSetting QString  setName,
QString  defVal = ""
const [protected]
 

Get a setting from the applications settings.

Parameters:
setName Name of the setting to retrieve.
defVal Default value to return if the setting does not exist.

virtual const NHostInfo NNet::getHostInfo  )  const [inline, virtual]
 

Returns the host information for the current connection.

Though virtual, the default implementation should be valid for most protocols.

Returns:
hostInfo

int NNet::getHostSetting QString  setName,
int  defVal
const [protected]
 

Get a setting that is specific to the hostInfo.

Overloaded version of the above. If the hostInfo does not contain a setting with that name, it will return the getProtSetting() for the same setName.

Parameters:
setName Name of the setting to retrieve.
defVal Default value to return if the setting does not exist.

QString NNet::getHostSetting QString  setName,
QString  defVal = ""
const [protected]
 

Get a setting that is specific to the hostInfo.

If the hostInfo does not contain a setting with that name, it will return the getProtSetting() for the same setName.

Parameters:
setName Name of the setting to retrieve.
defVal Default value to return if the setting does not exist.

int NNet::getProtSetting QString  setName,
int  defVal
const [protected]
 

Get a setting that is specific to the protocol.

Overloaded version of the above.

Parameters:
setName Name of the setting to retrieve.
defVal Default value to return if the setting does not exist.

QString NNet::getProtSetting QString  setName,
QString  defVal = ""
const [protected]
 

Get a setting that is specific to the protocol.

Parameters:
setName Name of the setting to retrieve.
defVal Default value to return if the setting does not exist.

virtual bool NNet::isConnected  )  const [inline, virtual]
 

Returns a boolean affirmation that the object is connected and ready for commands.

Returns:
commandReady

virtual int NNet::list  )  [pure virtual]
 

Request a directory listing.

Requests a directory listing from the remote system for the current directory. This function should not read from directory cache, but the result should be entered into it.

Returns:
ErrNotConnected if no remote system is connected.

ErrSocketBusy if the current operation is not OpIdle.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

void NNet::log int  id,
NNet::logType  type,
QString  msg
[signal]
 

Any commands sent, replies given, errors, warnings, or other info should emit a log signal with a NNet::logType classification and a human readable string.

Parameters:
id ID of this object (_id)
type Classification of this message.
msg Human readable string containing message.

void NNet::loginComplete int  id  )  [signal]
 

Login proccess completed.

Implies that the connection sequence is completed and that the object is ready for further usage.

Parameters:
id ID of this object (_id)

virtual int NNet::makedir QString  dir  )  [pure virtual]
 

Create a directory.

Create a new directory named dir on the remote system. dir can be relative or absolute, and both should be accepted as valid.

Returns:
ErrNotConnected if no remote system is connected.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

virtual int NNet::move QString  newname,
QString  oldname
[pure virtual]
 

Moves a file from one place to another.

Performs a move/rename operation on the remote system, moving oldname to newname.

Returns:
ErrNotConnected if no remote system is connected.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

virtual const char* NNet::name  )  const [inline, virtual]
 

Returns the name the implementation refers to itself as.

Defaults to whatever protocol() returns.

Reimplemented in NFtp.

virtual const char* NNet::protocol  )  const [pure virtual]
 

Returns the url prefix for the protocol implemented.

Implemented in NFtp.

virtual int NNet::put QString  file,
QString  sourcefile,
bool  resume = false
[pure virtual]
 

Uploads a single file.

Attempts to upload file from the remote system, reading it from local file sourcefile. Protocol implementation is responsible for making sure that the sourcefile exists and is readable. Resume should be attempted if the protocol supports it, and resume is true; or if the protocol's AutoResume option is set to on.

Returns:
ErrNotConnected if no remote system is connected.

ErrSocketBusy if the current operation is not OpIdle.

ErrFileSeek if local file is unreadable.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

virtual int NNet::remove QString  name,
bool  recursive = false
[pure virtual]
 

Removes a remote file/directory.

Performs a file deletion on the remote system, of file name. If recursive is true, assume that name is a directory, and delete it and its contents recursively.

Returns:
ErrNotConnected if no remote system is connected.

ErrSocketBusy if the current operation is not OpIdle.

ErrUnknown if the operation is unhandled. Use this if recursivity is impossible, but requested.

ErrNo if the operation was started successfully.

Implemented in NFtp.

virtual int NNet::sendRawCommand QString  command  )  [pure virtual]
 

Send a custom command to the server.

Bypassing any internal command manipulation, and reply parsing, send a single command to the remote system and expects replies from this command to come from log() with the NCUSTOM classification.

Returns:
ErrNotConnected if no remote system is connected.

ErrSocketBusy if the current operation is not OpIdle.

ErrUnknown if the operation is unhandled.

ErrNo if the operation was started successfully.

Implemented in NFtp.

void NNet::transferComplete int  id,
bool  finished,
uint  bytes,
int  time,
double  rate
[signal]
 

Transfer completed.

Parameters:
id ID of this object (_id)
finished True if transfer was successful, False if it failed or was incomplete.
bytes Number of bytes transferred.
time Time elapsed in milliseconds.
rate Average transfer rate in kilobytes.

void NNet::transferProgress int  id,
unsigned int  current,
unsigned int  total
[signal]
 

Transfer Progress changed.

Parameters:
id ID of this object (_id)
current Number of bytes transferred so far.
total Total number of bytes in transfer. Use 0 if unknown.


Field Documentation

bool NNet::_batch [protected]
 

Marks if this object is meant to be used for batch operations, or user interaction.

int NNet::_id [protected]
 

ID of this object. Used for all signals.

bool NNet::commandDelayedClose [protected]
 

Boolean state marker for if the command socket is performing a delayed close.

bool NNet::commandReady [protected]
 

Boolean state marker signifying that the connection is ready to accept operations.

QSocket* NNet::commandSock [protected]
 

QSocket for use as the main communications socket.

QCString NNet::currentDirListing [protected]
 

Holds the raw directory listing of the current directory, if available.

Operations NNet::currentOp [protected]
 

Holds the current operation.

bool NNet::dataDelayedClose [protected]
 

Boolean state marker for if the data socket is performing a delayed close.

QSocket* NNet::dataSock [protected]
 

QSocket for the secondary socket if the protocol requires it.

bool NNet::expectedClose [protected]
 

Boolean state marker signifying that a connection close is expected.

NHostInfo NNet::hostInfo [protected]
 

Holds the most up to date information regarding the connection.


The documentation for this class was generated from the following files:
Generated on Wed Oct 22 20:32:05 2003 for nvemftp by doxygen1.3