Qt Toolkit - QNetworkOperation Class

| Classes - Annotated - Tree - Functions - Home - Structure

# QNetworkOperation Class Reference

This class is used to define operations for network protocols and return the state, arguments, etc. More...

`#include <qnetworkprotocol.h>`

Inherits QObject.

List of all member functions.

## Public Members

- QNetworkOperation ( QNetworkProtocol::Operation operation, const QString & arg0, const QString & arg1, const QString & arg2 )
- QNetworkOperation ( QNetworkProtocol::Operation operation, const QByteArray & arg0, const QByteArray & arg1, const QByteArray & arg2 )
- ~QNetworkOperation ()
- void setState ( QNetworkProtocol::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 )
- QNetworkProtocol::Operation operation () const
- QNetworkProtocol::State state () const
- QString arg ( int num ) const
- QByteArray rawArg ( int num ) const
- QString protocolDetail () const
- int errorCode () const
- void free ()

## Detailed Description

This class is used to define operations for network protocols and return the state, arguments, etc.

For each operation, which a network protocol should process such an object is created to describe the operation and the current state.

For a detailed description about the Qt Network Architecture, and also how to implement and use network protocols in Qt, look at the Qt Network Documentation.

See also QNetworkProtocol.

## Member Function Documentation

### QNetworkOperation::QNetworkOperation ( QNetworkProtocol::Operation operation, const QByteArray & arg0, const QByteArray & arg1, const QByteArray & arg2 )

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

### QNetworkOperation::QNetworkOperation ( QNetworkProtocol::Operation operation, const QString & arg0, const QString & arg1, const QString & arg2 )

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

### QNetworkOperation::~QNetworkOperation ()

Destructor.

### QString QNetworkOperation::arg ( int num ) const

Returns the argument num of the operation. If this argument was not set already, an empty string is returned.

### int QNetworkOperation::errorCode () const

If an operation failed, you get the error code using this methode.

### void QNetworkOperation::free ()

If this method is called the QNetworkOperation deletes itself after it has been 1 second unused, which means for 1 second no method of the QNetworkOperation has been accessed.

Because QNetworkOperation pointers are passed around a lot the QNetworkProtocol can't delete these at the correct time. So, if a QNetworkProtocol doesn't need an operation anymore and calls this method, so that it gets deleted correctly.

You should never need to call the method yourself!.

### QNetworkProtocol::Operation QNetworkOperation::operation() const

Returns the type of the operation.

### QString QNetworkOperation::protocolDetail () const

If the operation failed, using this method you may get a more detailed error message.

### QByteArray QNetworkOperation::rawArg ( int num ) const

Returns the raw data argument num of the operation. If this argument was not set already, an empty bytearray is returned.

### void QNetworkOperation::setArg ( int num, const QString & arg )

Sets the argument num of the network operation to arg.

### void QNetworkOperation::setErrorCode ( int ec )

If the operation failed, the protocol should set an error code to describe the error more detailed. Preferable one of the error codes defined in QNetworkProtocol should be used.

### void QNetworkOperation::setProtocolDetail ( const QString & detail )

If the operation failed a detailed error message can be set.

### void QNetworkOperation::setRawArg ( int num, const QByteArray & arg )

Sets the raw data argument num of the network operation to arg.

### void QNetworkOperation::setState ( QNetworkProtocol::State state )

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

### QNetworkProtocol::State QNetworkOperation::state() const

Returns the state of the operation. Using that you can find out if an operation is still waiting to get processed, if it is in process or if has been done successfully or if it failed.

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.