Q3NetworkOperation Class Reference

#include <q3networkprotocol.h>

Inheritance diagram for Q3NetworkOperation:

Inheritance graph
[legend]
Collaboration diagram for Q3NetworkOperation:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3NetworkOperation class provides common operations for network protocols.

An object is created to describe the operation and the current state for each operation that a network protocol should process.

See also:
Q3NetworkProtocol

Definition at line 181 of file q3networkprotocol.h.

Public Member Functions

 Q3NetworkOperation (Q3NetworkProtocol::Operation operation, const QString &arg0, const QString &arg1, const QString &arg2)
 Q3NetworkOperation (Q3NetworkProtocol::Operation operation, const QByteArray &arg0, const QByteArray &arg1, const QByteArray &arg2)
 ~Q3NetworkOperation ()
void setState (Q3NetworkProtocol::State state)
void setProtocolDetail (const QString &detail)
void setErrorCode (int ec)
void setArg (int num, const QString &arg)
void setRawArg (int num, const QByteArray &arg)
Q3NetworkProtocol::Operation operation () const
Q3NetworkProtocol::State state () const
QString arg (int num) const
QByteArray rawArg (int num) const
QString protocolDetail () const
int errorCode () const
void free ()

Private Slots

void deleteMe ()

Private Member Functions

QByteArrayraw (int num) const

Private Attributes

Q3NetworkOperationPrivated

Friends

class Q3UrlOperator


Constructor & Destructor Documentation

Q3NetworkOperation::Q3NetworkOperation ( Q3NetworkProtocol::Operation  operation,
const QString arg0,
const QString arg1,
const QString arg2 
)

Constructs a network operation object. operation is the type of the operation, and arg0, arg1 and arg2 are the first three arguments of the operation. The state is initialized to Q3NetworkProtocol::StWaiting.

See also:
Q3NetworkProtocol::Operation Q3NetworkProtocol::State

Definition at line 929 of file q3networkprotocol.cpp.

References Q3NetworkOperationPrivate::args, QString::clear(), QObject::connect(), d, deleteMe(), Q3NetworkOperationPrivate::deleteTimer, Q3NetworkOperationPrivate::errorCode, int, Q3NetworkProtocol::NoError, Q3NetworkOperationPrivate::operation, Q3NetworkOperationPrivate::protocolDetail, Q3NetworkOperationPrivate::rawArgs, SIGNAL, SLOT, Q3NetworkOperationPrivate::state, and Q3NetworkProtocol::StWaiting.

00932 {
00933     d = new Q3NetworkOperationPrivate;
00934     d->deleteTimer = new QTimer( this );
00935     connect( d->deleteTimer, SIGNAL(timeout()),
00936        this, SLOT(deleteMe()) );
00937     d->operation = operation;
00938     d->state = Q3NetworkProtocol::StWaiting;
00939     d->args[ 0 ] = arg0;
00940     d->args[ 1 ] = arg1;
00941     d->args[ 2 ] = arg2;
00942     d->rawArgs[ 0 ] = QByteArray( 0 );
00943     d->rawArgs[ 1 ] = QByteArray( 0 );
00944     d->rawArgs[ 2 ] = QByteArray( 0 );
00945     d->protocolDetail.clear();
00946     d->errorCode = (int)Q3NetworkProtocol::NoError;
00947 }

Here is the call graph for this function:

Q3NetworkOperation::Q3NetworkOperation ( Q3NetworkProtocol::Operation  operation,
const QByteArray arg0,
const QByteArray arg1,
const QByteArray arg2 
)

Constructs a network operation object. operation is the type of the operation, and arg0, arg1 and arg2 are the first three raw data arguments of the operation. The state is initialized to Q3NetworkProtocol::StWaiting.

See also:
Q3NetworkProtocol::Operation Q3NetworkProtocol::State

Definition at line 958 of file q3networkprotocol.cpp.

References Q3NetworkOperationPrivate::args, QMap< Key, T >::clear(), QString::clear(), QObject::connect(), d, deleteMe(), Q3NetworkOperationPrivate::deleteTimer, Q3NetworkOperationPrivate::errorCode, int, Q3NetworkProtocol::NoError, Q3NetworkOperationPrivate::operation, Q3NetworkOperationPrivate::protocolDetail, Q3NetworkOperationPrivate::rawArgs, SIGNAL, SLOT, Q3NetworkOperationPrivate::state, and Q3NetworkProtocol::StWaiting.

00961 {
00962     d = new Q3NetworkOperationPrivate;
00963     d->deleteTimer = new QTimer( this );
00964     connect( d->deleteTimer, SIGNAL(timeout()),
00965        this, SLOT(deleteMe()) );
00966     d->operation = operation;
00967     d->state = Q3NetworkProtocol::StWaiting;
00968     d->args[ 0 ].clear();
00969     d->args[ 1 ].clear();
00970     d->args[ 2 ].clear();
00971     d->rawArgs[ 0 ] = arg0;
00972     d->rawArgs[ 1 ] = arg1;
00973     d->rawArgs[ 2 ] = arg2;
00974     d->protocolDetail.clear();
00975     d->errorCode = (int)Q3NetworkProtocol::NoError;
00976 }

Here is the call graph for this function:

Q3NetworkOperation::~Q3NetworkOperation (  ) 

Destructor.

Definition at line 982 of file q3networkprotocol.cpp.

References d.

00983 {
00984     delete d;
00985 }


Member Function Documentation

void Q3NetworkOperation::setState ( Q3NetworkProtocol::State  state  ) 

Sets the state of the operation object. This should be done by the network protocol during processing; at the end it should be set to Q3NetworkProtocol::StDone or Q3NetworkProtocol::StFailed, depending on success or failure.

See also:
Q3NetworkProtocol::State

Definition at line 996 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, QTimer::start(), Q3NetworkOperationPrivate::state, and QTimer::stop().

Referenced by Q3Http::clientDone(), Q3Http::clientReply(), Q3UrlOperator::copy(), Q3Ftp::npDone(), Q3LocalFs::operationGet(), Q3Http::operationGet(), Q3Ftp::operationGet(), Q3Ftp::operationListChildren(), Q3LocalFs::operationListChildren(), Q3LocalFs::operationMkDir(), Q3Ftp::operationMkDir(), Q3Http::operationPut(), Q3Ftp::operationPut(), Q3LocalFs::operationPut(), Q3Ftp::operationRemove(), Q3LocalFs::operationRemove(), Q3Ftp::operationRename(), Q3LocalFs::operationRename(), Q3UrlOperator::startOperation(), and Q3NetworkProtocol::stop().

00997 {
00998     if ( d->deleteTimer->isActive() ) {
00999   d->deleteTimer->stop();
01000   d->deleteTimer->start( NETWORK_OP_DELAY );
01001     }
01002     d->state = state;
01003 }

Here is the call graph for this function:

void Q3NetworkOperation::setProtocolDetail ( const QString detail  ) 

If the operation failed, the error message can be specified as detail.

Definition at line 1010 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, Q3NetworkOperationPrivate::protocolDetail, QTimer::start(), and QTimer::stop().

Referenced by Q3Http::clientDone(), Q3Http::clientReply(), Q3UrlOperator::copy(), Q3Ftp::npDone(), Q3LocalFs::operationGet(), Q3LocalFs::operationListChildren(), Q3LocalFs::operationMkDir(), Q3LocalFs::operationPut(), Q3LocalFs::operationRemove(), Q3LocalFs::operationRename(), Q3UrlOperator::startOperation(), and Q3NetworkProtocol::stop().

01011 {
01012     if ( d->deleteTimer->isActive() ) {
01013   d->deleteTimer->stop();
01014   d->deleteTimer->start( NETWORK_OP_DELAY );
01015     }
01016     d->protocolDetail = detail;
01017 }

Here is the call graph for this function:

void Q3NetworkOperation::setErrorCode ( int  ec  ) 

Sets the error code to ec.

If the operation failed, the protocol should set an error code to describe the error in more detail. If possible, one of the error codes defined in Q3NetworkProtocol should be used.

See also:
setProtocolDetail() Q3NetworkProtocol::Error

Definition at line 1029 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, Q3NetworkOperationPrivate::errorCode, QTimer::isActive(), NETWORK_OP_DELAY, QTimer::start(), and QTimer::stop().

Referenced by Q3Http::clientDone(), Q3Http::clientReply(), Q3UrlOperator::copy(), Q3Ftp::npDone(), Q3LocalFs::operationGet(), Q3LocalFs::operationListChildren(), Q3LocalFs::operationMkDir(), Q3LocalFs::operationPut(), Q3LocalFs::operationRemove(), Q3LocalFs::operationRename(), and Q3UrlOperator::startOperation().

01030 {
01031     if ( d->deleteTimer->isActive() ) {
01032   d->deleteTimer->stop();
01033   d->deleteTimer->start( NETWORK_OP_DELAY );
01034     }
01035     d->errorCode = ec;
01036 }

Here is the call graph for this function:

void Q3NetworkOperation::setArg ( int  num,
const QString arg 
)

Sets the network operation's {num}-th argument to arg.

Definition at line 1042 of file q3networkprotocol.cpp.

References arg(), Q3NetworkOperationPrivate::args, d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, QTimer::start(), and QTimer::stop().

01043 {
01044     if ( d->deleteTimer->isActive() ) {
01045   d->deleteTimer->stop();
01046   d->deleteTimer->start( NETWORK_OP_DELAY );
01047     }
01048     d->args[ num ] = arg;
01049 }

Here is the call graph for this function:

void Q3NetworkOperation::setRawArg ( int  num,
const QByteArray arg 
)

Sets the network operation's {num}-th raw data argument to arg.

Definition at line 1055 of file q3networkprotocol.cpp.

References arg(), d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, Q3NetworkOperationPrivate::rawArgs, QTimer::start(), and QTimer::stop().

Referenced by Q3UrlOperator::put().

01056 {
01057     if ( d->deleteTimer->isActive() ) {
01058   d->deleteTimer->stop();
01059   d->deleteTimer->start( NETWORK_OP_DELAY );
01060     }
01061     d->rawArgs[ num ] = arg;
01062 }

Here is the call graph for this function:

Q3NetworkProtocol::Operation Q3NetworkOperation::operation (  )  const

Returns the type of the operation.

Definition at line 1068 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, Q3NetworkOperationPrivate::operation, QTimer::start(), and QTimer::stop().

Referenced by Q3NetworkProtocol::addOperation(), Q3Ftp::checkConnection(), Q3Http::clientDone(), Q3Http::clientReply(), Q3UrlOperator::continueCopy(), Q3FileDialog::dataTransferProgress(), Q3FileDialog::insertEntry(), Q3Ftp::npDone(), Q3NetworkProtocol::processOperation(), Q3UrlOperator::slotItemChanged(), Q3UrlOperator::startOperation(), Q3FileDialog::urlFinished(), and Q3FileDialog::urlStart().

01069 {
01070     if ( d->deleteTimer->isActive() ) {
01071   d->deleteTimer->stop();
01072   d->deleteTimer->start( NETWORK_OP_DELAY );
01073     }
01074     return d->operation;
01075 }

Here is the call graph for this function:

Q3NetworkProtocol::State Q3NetworkOperation::state (  )  const

Returns the state of the operation. You can determine whether an operation is still waiting to be processed, is being processed, has been processed successfully, or failed.

Definition at line 1083 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, QTimer::start(), Q3NetworkOperationPrivate::state, and QTimer::stop().

Referenced by Q3Http::clientDone(), Q3UrlOperator::continueCopy(), Q3NetworkProtocol::processNextOperation(), and Q3FileDialog::urlFinished().

01084 {
01085     if ( d->deleteTimer->isActive() ) {
01086   d->deleteTimer->stop();
01087   d->deleteTimer->start( NETWORK_OP_DELAY );
01088     }
01089     return d->state;
01090 }

Here is the call graph for this function:

QString Q3NetworkOperation::arg ( int  num  )  const

Returns the operation's {num}-th argument. If this argument was not already set, an empty string is returned.

Definition at line 1097 of file q3networkprotocol.cpp.

References Q3NetworkOperationPrivate::args, d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, QTimer::start(), and QTimer::stop().

Referenced by Q3Ftp::checkConnection(), Q3FileDialog::dataTransferProgress(), Q3FileDialog::itemChanged(), Q3LocalFs::operationGet(), Q3Ftp::operationGet(), Q3LocalFs::operationMkDir(), Q3Ftp::operationMkDir(), Q3Ftp::operationPut(), Q3LocalFs::operationPut(), Q3Ftp::operationRemove(), Q3LocalFs::operationRemove(), Q3Ftp::operationRename(), Q3LocalFs::operationRename(), Q3FileDialog::removeEntry(), setArg(), setRawArg(), and Q3UrlOperator::slotItemChanged().

01098 {
01099     if ( d->deleteTimer->isActive() ) {
01100   d->deleteTimer->stop();
01101   d->deleteTimer->start( NETWORK_OP_DELAY );
01102     }
01103     return d->args[ num ];
01104 }

Here is the call graph for this function:

QByteArray Q3NetworkOperation::rawArg ( int  num  )  const

Returns the operation's {num}-th raw data argument. If this argument was not already set, an empty bytearray is returned.

Definition at line 1111 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, Q3NetworkOperationPrivate::rawArgs, QTimer::start(), and QTimer::stop().

Referenced by Q3Http::operationPut(), Q3Ftp::operationPut(), and Q3LocalFs::operationPut().

01112 {
01113     if ( d->deleteTimer->isActive() ) {
01114   d->deleteTimer->stop();
01115   d->deleteTimer->start( NETWORK_OP_DELAY );
01116     }
01117     return d->rawArgs[ num ];
01118 }

Here is the call graph for this function:

QString Q3NetworkOperation::protocolDetail (  )  const

Returns a detailed error message for the last error. This must have been set using setProtocolDetail().

Definition at line 1125 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, Q3NetworkOperationPrivate::protocolDetail, QTimer::start(), and QTimer::stop().

Referenced by Q3FileDialog::urlFinished().

01126 {
01127     if ( d->deleteTimer->isActive() ) {
01128   d->deleteTimer->stop();
01129   d->deleteTimer->start( NETWORK_OP_DELAY );
01130     }
01131     return d->protocolDetail;
01132 }

Here is the call graph for this function:

int Q3NetworkOperation::errorCode (  )  const

Returns the error code for the last error that occurred.

Definition at line 1138 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, Q3NetworkOperationPrivate::errorCode, QTimer::isActive(), NETWORK_OP_DELAY, QTimer::start(), and QTimer::stop().

Referenced by Q3FileDialog::urlFinished().

01139 {
01140     if ( d->deleteTimer->isActive() ) {
01141   d->deleteTimer->stop();
01142   d->deleteTimer->start( NETWORK_OP_DELAY );
01143     }
01144     return d->errorCode;
01145 }

Here is the call graph for this function:

void Q3NetworkOperation::free (  ) 

Sets this object to delete itself when it hasn't been used for one second.

Because Q3NetworkOperation pointers are passed around a lot the Q3NetworkProtocol generally does not have enough knowledge to delete these at the correct time. If a Q3NetworkProtocol doesn't need an operation any more it will call this function instead.

Note: you should never need to call the method yourself.

Definition at line 1172 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, NETWORK_OP_DELAY, and QTimer::start().

Referenced by Q3NetworkProtocol::stop(), Q3NetworkProtocolPrivate::~Q3NetworkProtocolPrivate(), and Q3UrlOperatorPrivate::~Q3UrlOperatorPrivate().

01173 {
01174     d->deleteTimer->start( NETWORK_OP_DELAY );
01175 }

void Q3NetworkOperation::deleteMe (  )  [private, slot]

Definition at line 1182 of file q3networkprotocol.cpp.

Referenced by Q3NetworkOperation().

01183 {
01184     delete this;
01185 }

QByteArray & Q3NetworkOperation::raw ( int  num  )  const [private]

Definition at line 1151 of file q3networkprotocol.cpp.

References d, Q3NetworkOperationPrivate::deleteTimer, QTimer::isActive(), NETWORK_OP_DELAY, Q3NetworkOperationPrivate::rawArgs, QTimer::start(), and QTimer::stop().

01152 {
01153     if ( d->deleteTimer->isActive() ) {
01154   d->deleteTimer->stop();
01155   d->deleteTimer->start( NETWORK_OP_DELAY );
01156     }
01157     return d->rawArgs[ num ];
01158 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Q3UrlOperator [friend]

Definition at line 184 of file q3networkprotocol.h.


Member Data Documentation

Q3NetworkOperationPrivate* Q3NetworkOperation::d [private]

Definition at line 215 of file q3networkprotocol.h.

Referenced by arg(), errorCode(), free(), operation(), protocolDetail(), Q3NetworkOperation(), raw(), rawArg(), setArg(), setErrorCode(), setProtocolDetail(), setRawArg(), setState(), state(), and ~Q3NetworkOperation().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 16:12:22 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1