Q3UrlOperator Class Reference

#include <q3urloperator.h>

Inheritance diagram for Q3UrlOperator:

Inheritance graph
[legend]
Collaboration diagram for Q3UrlOperator:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3UrlOperator class provides common operations on URLs.

network

This class operates on hierarchical structures (such as filesystems) using URLs. Its API facilitates all the common operations: Operation Function List files listChildren() Make a directory mkdir() Remove a file remove() Rename a file rename() Get a file get() Put a file put() Copy a file copy()

You can obtain additional information about the URL with isDir() and info(). If a directory is to be traversed using listChildren(), a name filter can be set with setNameFilter().

A Q3UrlOperator can be used like this, for example to download a file (and assuming that the FTP protocol is registered):

    Q3UrlOperator *op = new Q3UrlOperator();
    op->copy( QString("ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz"),
       "file:///tmp" );

If you want to be notified about success/failure, progress, etc., you can connect to Q3UrlOperator's signals, e.g. to start(), newChildren(), createdDirectory(), removed(), data(), dataTransferProgress(), startedNextCopy(), connectionStateChanged(), finished(), etc. A network operation can be stopped with stop().

The class uses the functionality of registered network protocols to perform these operations. Depending of the protocol of the URL, it uses an appropriate network protocol class for the operations. Each of the operation functions of Q3UrlOperator creates a Q3NetworkOperation object that describes the operation and puts it into the operation queue for the network protocol used. If no suitable protocol could be found (because no implementation of the necessary network protocol is registered), the URL operator emits errors. Not every protocol supports every operation, but error handling deals with this problem.

To register the available network protocols, use the qInitNetworkProtocols() function. The protocols currently supported are: FTP, HTTP, local file system.

See also:
Q3NetworkProtocol, Q3NetworkOperation

Definition at line 43 of file q3urloperator.h.

Signals

void newChildren (const Q3ValueList< QUrlInfo > &, Q3NetworkOperation *res)
void finished (Q3NetworkOperation *res)
void start (Q3NetworkOperation *res)
void createdDirectory (const QUrlInfo &, Q3NetworkOperation *res)
void removed (Q3NetworkOperation *res)
void itemChanged (Q3NetworkOperation *res)
void data (const QByteArray &, Q3NetworkOperation *res)
void dataTransferProgress (int bytesDone, int bytesTotal, Q3NetworkOperation *res)
void startedNextCopy (const Q3PtrList< Q3NetworkOperation > &lst)
void connectionStateChanged (int state, const QString &data)

Public Member Functions

 Q3UrlOperator ()
 Q3UrlOperator (const QString &urL)
 Q3UrlOperator (const Q3UrlOperator &url)
 Q3UrlOperator (const Q3UrlOperator &url, const QString &relUrl, bool checkSlash=false)
virtual ~Q3UrlOperator ()
virtual void setPath (const QString &path)
virtual bool cdUp ()
virtual const Q3NetworkOperationlistChildren ()
virtual const Q3NetworkOperationmkdir (const QString &dirname)
virtual const Q3NetworkOperationremove (const QString &filename)
virtual const Q3NetworkOperationrename (const QString &oldname, const QString &newname)
virtual const Q3NetworkOperationget (const QString &location=QString())
virtual const Q3NetworkOperationput (const QByteArray &data, const QString &location=QString())
virtual Q3PtrList< Q3NetworkOperationcopy (const QString &from, const QString &to, bool move=false, bool toPath=true)
virtual void copy (const QStringList &files, const QString &dest, bool move=false)
virtual bool isDir (bool *ok=0)
virtual void setNameFilter (const QString &nameFilter)
QString nameFilter () const
virtual QUrlInfo info (const QString &entry) const
Q3UrlOperatoroperator= (const Q3UrlOperator &url)
Q3UrlOperatoroperator= (const QString &url)
virtual void stop ()

Protected Member Functions

void reset ()
bool parse (const QString &url)
virtual bool checkValid ()
virtual void clearEntries ()
void getNetworkProtocol ()
void deleteNetworkProtocol ()

Private Slots

const Q3NetworkOperationstartOperation (Q3NetworkOperation *op)
void copyGotData (const QByteArray &data, Q3NetworkOperation *op)
void continueCopy (Q3NetworkOperation *op)
void finishedCopy ()
void addEntry (const Q3ValueList< QUrlInfo > &i)
void slotItemChanged (Q3NetworkOperation *op)

Private Member Functions

void deleteOperation (Q3NetworkOperation *op)

Private Attributes

Q3UrlOperatorPrivated

Friends

class Q3NetworkProtocol

Related Functions

(Note that these are not member functions.)

void q3InitNetworkProtocols ()


Constructor & Destructor Documentation

Q3UrlOperator::Q3UrlOperator (  ) 

Constructs a Q3UrlOperator with an empty (i.e. invalid) URL.

Definition at line 267 of file q3urloperator.cpp.

References d, and qDebug().

Referenced by copy().

00268     : Q3Url()
00269 {
00270 #ifdef Q3URLOPERATOR_DEBUG
00271     qDebug( "Q3UrlOperator: cstr 1" );
00272 #endif
00273     d = new Q3UrlOperatorPrivate;
00274 }

Here is the call graph for this function:

Q3UrlOperator::Q3UrlOperator ( const QString url  ) 

Constructs a Q3UrlOperator using url and parses this string.

If you pass strings like "/home/qt" the "file" protocol is assumed.

Definition at line 283 of file q3urloperator.cpp.

References d, getNetworkProtocol(), and qDebug().

00284     : Q3Url( url )
00285 {
00286 #ifdef Q3URLOPERATOR_DEBUG
00287     qDebug( "Q3UrlOperator: cstr 2" );
00288 #endif
00289     d = new Q3UrlOperatorPrivate;
00290     getNetworkProtocol();
00291 }

Here is the call graph for this function:

Q3UrlOperator::Q3UrlOperator ( const Q3UrlOperator url  ) 

Constructs a copy of url.

Definition at line 297 of file q3urloperator.cpp.

References Q3UrlOperatorPrivate::currPut, d, getNetworkProtocol(), Q3UrlOperatorPrivate::nameFilter, Q3UrlOperatorPrivate::networkProtocol, and qDebug().

00298     : QObject(), Q3Url( url )
00299 {
00300 #ifdef Q3URLOPERATOR_DEBUG
00301     qDebug( "Q3UrlOperator: cstr 3" );
00302 #endif
00303     d = new Q3UrlOperatorPrivate;
00304     *d = *url.d;
00305 
00306     d->networkProtocol = 0;
00307     getNetworkProtocol();
00308     d->nameFilter = "*";
00309     d->currPut = 0;
00310 }

Here is the call graph for this function:

Q3UrlOperator::Q3UrlOperator ( const Q3UrlOperator url,
const QString relUrl,
bool  checkSlash = false 
)

Constructs a Q3UrlOperator. The URL on which this Q3UrlOperator operates is constructed out of the arguments url, relUrl and checkSlash: see the corresponding Q3Url constructor for an explanation of these arguments.

Definition at line 319 of file q3urloperator.cpp.

References Q3UrlOperatorPrivate::currPut, d, getNetworkProtocol(), Q3UrlOperatorPrivate::networkProtocol, and qDebug().

00320     : Q3Url( url, relUrl, checkSlash )
00321 {
00322 #ifdef Q3URLOPERATOR_DEBUG
00323     qDebug( "Q3UrlOperator: cstr 4" );
00324 #endif
00325     d = new Q3UrlOperatorPrivate;
00326     if ( relUrl == "." )
00327   *d = *url.d;
00328 
00329     d->networkProtocol = 0;
00330     getNetworkProtocol();
00331     d->currPut = 0;
00332 }

Here is the call graph for this function:

Q3UrlOperator::~Q3UrlOperator (  )  [virtual]

Destructor.

Definition at line 338 of file q3urloperator.cpp.

References d, and qDebug().

00339 {
00340 #ifdef Q3URLOPERATOR_DEBUG
00341     qDebug( "Q3UrlOperator: dstr" );
00342 #endif
00343     delete d;
00344 }

Here is the call graph for this function:


Member Function Documentation

void Q3UrlOperator::setPath ( const QString path  )  [virtual]

Reimplemented from Q3Url.

Definition at line 933 of file q3urloperator.cpp.

References d, Q3UrlOperatorPrivate::networkProtocol, Q3Url::path(), Q3Url::setPath(), and Q3NetworkProtocol::setUrl().

Referenced by copy(), Q3FileDialog::setSelection(), and Q3FileDialog::setUrl().

00934 {
00935     Q3Url::setPath( path );
00936     if ( d->networkProtocol )
00937   d->networkProtocol->setUrl( this );
00938 }

Here is the call graph for this function:

bool Q3UrlOperator::cdUp (  )  [virtual]

Changes the directory to one directory up.

See also:
setPath()

Reimplemented from Q3Url.

Definition at line 1011 of file q3urloperator.cpp.

References b, Q3Url::cdUp(), d, Q3UrlOperatorPrivate::networkProtocol, and Q3NetworkProtocol::setUrl().

01012 {
01013     bool b = Q3Url::cdUp();
01014     if ( d->networkProtocol )
01015   d->networkProtocol->setUrl( this );
01016     return b;
01017 }

Here is the call graph for this function:

const Q3NetworkOperation * Q3UrlOperator::listChildren (  )  [virtual]

Starts listing the children of this URL (e.g. the files in the directory). The start() signal is emitted before the first entry is listed and finished() is emitted after the last one. The newChildren() signal is emitted for each list of new entries. If an error occurs, the signal finished() is emitted, so be sure to check the state of the network operation pointer.

Because the operation may not be executed immediately, a pointer to the Q3NetworkOperation object created by this function is returned. This object contains all the data about the operation and is used to refer to this operation later (e.g. in the signals that are emitted by the Q3UrlOperator). The return value can also be 0 if the operation object couldn't be created.

The path of this Q3UrlOperator must to point to a directory (because the children of this directory will be listed), not to a file.

Definition at line 422 of file q3urloperator.cpp.

References checkValid(), Q3NetworkProtocol::OpListChildren, and startOperation().

Referenced by Q3FileDialog::rereadDir().

00423 {
00424     if ( !checkValid() )
00425   return 0;
00426 
00427     Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpListChildren, QString(), QString(), QString() );
00428     return startOperation( res );
00429 }

Here is the call graph for this function:

const Q3NetworkOperation * Q3UrlOperator::mkdir ( const QString dirname  )  [virtual]

Tries to create a directory (child) with the name dirname. If it is successful, a newChildren() signal with the new child is emitted, and the createdDirectory() signal with the information about the new child is also emitted. The finished() signal (with success or failure) is emitted after the operation has been processed, so check the state of the network operation object to see whether or not the operation was successful.

Because the operation will not be executed immediately, a pointer to the Q3NetworkOperation object created by this function is returned. This object contains all the data about the operation and is used to refer to this operation later (e.g. in the signals that are emitted by the Q3UrlOperator). The return value can also be 0 if the operation object couldn't be created.

The path of this Q3UrlOperator must to point to a directory (not a file) because the new directory will be created in this path.

Definition at line 451 of file q3urloperator.cpp.

References checkValid(), Q3NetworkProtocol::OpMkDir, and startOperation().

Referenced by Q3FileDialog::newFolderClicked().

00452 {
00453     if ( !checkValid() )
00454   return 0;
00455 
00456     Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpMkDir, dirname, QString(), QString() );
00457     return startOperation( res );
00458 }

Here is the call graph for this function:

const Q3NetworkOperation * Q3UrlOperator::remove ( const QString filename  )  [virtual]

Tries to remove the file (child) filename. If it succeeds the removed() signal is emitted. finished() (with success or failure) is also emitted after the operation has been processed, so check the state of the network operation object to see whether or not the operation was successful.

Because the operation will not be executed immediately, a pointer to the Q3NetworkOperation object created by this function is returned. This object contains all the data about the operation and is used to refer to this operation later (e.g. in the signals that are emitted by the Q3UrlOperator). The return value can also be 0 if the operation object couldn't be created.

The path of this Q3UrlOperator must point to a directory; because if filename is relative, it will try to remove it in this directory.

Definition at line 479 of file q3urloperator.cpp.

References checkValid(), Q3NetworkProtocol::OpRemove, and startOperation().

Referenced by Q3FileDialog::deleteFile().

00480 {
00481     if ( !checkValid() )
00482   return 0;
00483 
00484     Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpRemove, filename, QString(), QString() );
00485     return startOperation( res );
00486 }

Here is the call graph for this function:

const Q3NetworkOperation * Q3UrlOperator::rename ( const QString oldname,
const QString newname 
) [virtual]

Tries to rename the file (child) called oldname to newname. If it succeeds, the itemChanged() signal is emitted. finished() (with success or failure) is also emitted after the operation has been processed, so check the state of the network operation object to see whether or not the operation was successful.

Because the operation may not be executed immediately, a pointer to the Q3NetworkOperation object created by this function is returned. This object contains all the data about the operation and is used to refer to this operation later (e.g. in the signals that are emitted by the Q3UrlOperator). The return value can also be 0 if the operation object couldn't be created.

This path of this Q3UrlOperator must to point to a directory because oldname and newname are handled relative to this directory.

Definition at line 507 of file q3urloperator.cpp.

References checkValid(), Q3NetworkProtocol::OpRename, and startOperation().

Referenced by QFileListBox::rename(), and Q3FileDialogQFileListView::rename().

00508 {
00509     if ( !checkValid() )
00510   return 0;
00511 
00512     Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpRename, oldname, newname, QString() );
00513     return startOperation( res );
00514 }

Here is the call graph for this function:

const Q3NetworkOperation * Q3UrlOperator::get ( const QString location = QString()  )  [virtual]

Tells the network protocol to get data from location or, if it is empty, to get data from the location to which this URL points (see Q3Url::fileName() and Q3Url::encodedPathAndQuery()). What happens then depends on the network protocol. The data() signal is emitted when data comes in. Because it's unlikely that all data will come in at once, it is common for multiple data() signals to be emitted. The dataTransferProgress() signal is emitted while processing the operation. At the end, finished() (with success or failure) is emitted, so check the state of the network operation object to see whether or not the operation was successful.

If location is empty, the path of this Q3UrlOperator should point to a file when you use this operation. If location is not empty, it can be a relative URL (a child of the path to which the Q3UrlOperator points) or an absolute URL.

For example, to get a web page you might do something like this:

    Q3UrlOperator op( "http://www.whatever.org/cgi-bin/search.pl?cmd=Hello" );
    op.get();

For most other operations, the path of the Q3UrlOperator must point to a directory. If you want to download a file you could do the following:

    Q3UrlOperator op( "ftp://ftp.whatever.org/pub" );
    // do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
    op.get( "a_file.txt" );

This will get the data of ftp://ftp.whatever.org/pub/a_file.txt.

Never do anything like this:

    Q3UrlOperator op( "http://www.whatever.org/cgi-bin" );
    op.get( "search.pl?cmd=Hello" ); // WRONG!

If location is not empty and relative it must not contain any queries or references, just the name of a child. So if you need to specify a query or reference, do it as shown in the first example or specify the full URL (such as http://www.whatever.org/cgi-bin/search.pl?cmd=Hello) as location.

See also:
copy()

Definition at line 752 of file q3urloperator.cpp.

References d, getNetworkProtocol(), location, Q3UrlOperatorPrivate::networkProtocol, Q3NetworkProtocol::OpGet, Q3Url::Q3Url(), Q3Url::setProtocol(), startOperation(), and u.

00753 {
00754     Q3Url u( *this );
00755     if ( !location.isEmpty() )
00756   u = Q3Url( *this, location );
00757 
00758     if ( !u.isValid() )
00759   return 0;
00760 
00761     if ( !d->networkProtocol ) {
00762   setProtocol( u.protocol() );
00763   getNetworkProtocol();
00764     }
00765 
00766     Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpGet, u, QString(), QString() );
00767     return startOperation( res );
00768 }

Here is the call graph for this function:

const Q3NetworkOperation * Q3UrlOperator::put ( const QByteArray data,
const QString location = QString() 
) [virtual]

This function tells the network protocol to put data in location. If location is empty, it puts the data in the location to which the URL points. What happens depends on the network protocol. Depending on the network protocol, some data might come back after putting data, in which case the data() signal is emitted. The dataTransferProgress() signal is emitted during processing of the operation. At the end, finished() (with success or failure) is emitted, so check the state of the network operation object to see whether or not the operation was successful.

If location is empty, the path of this Q3UrlOperator should point to a file when you use this operation. If location is not empty, it can be a relative (a child of the path to which the Q3UrlOperator points) or an absolute URL.

For putting some data to a file you can do the following:

    Q3UrlOperator op( "ftp://ftp.whatever.com/home/me/filename.dat" );
    op.put( data );

For most other operations, the path of the Q3UrlOperator must point to a directory. If you want to upload data to a file you could do the following:

    Q3UrlOperator op( "ftp://ftp.whatever.com/home/me" );
    // do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
    op.put( data, "filename.dat" );

This will upload the data to ftp://ftp.whatever.com/home/me/filename.dat.

See also:
copy()

Definition at line 809 of file q3urloperator.cpp.

References d, data(), getNetworkProtocol(), location, Q3UrlOperatorPrivate::networkProtocol, Q3NetworkProtocol::OpPut, Q3Url::Q3Url(), Q3Url::setProtocol(), Q3NetworkOperation::setRawArg(), startOperation(), and u.

Referenced by continueCopy(), and copyGotData().

00810 {
00811     Q3Url u( *this );
00812     if ( !location.isEmpty() )
00813   u = Q3Url( *this, location );
00814 
00815     if ( !u.isValid() )
00816   return 0;
00817 
00818     if ( !d->networkProtocol ) {
00819   setProtocol( u.protocol() );
00820   getNetworkProtocol();
00821     }
00822 
00823     Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpPut, u, QString(), QString() );
00824     res->setRawArg( 1, data );
00825     return startOperation( res );
00826 }

Here is the call graph for this function:

Q3PtrList< Q3NetworkOperation > Q3UrlOperator::copy ( const QString from,
const QString to,
bool  move = false,
bool  toPath = true 
) [virtual]

Copies the file from to to. If move is true, the file is moved (copied and removed). from must point to a file and to must point to a directory (into which from is copied) unless toPath is set to false. If toPath is set to false then the to variable is assumed to be the absolute file path (destination file path + file name). The copying is done using the get() and put() operations. If you want to be notified about the progress of the operation, connect to the dataTransferProgress() signal. Bear in mind that the get() and put() operations emit this signal through the Q3UrlOperator. The number of transferred bytes and the total bytes that you receive as arguments in this signal do not relate to the the whole copy operation; they relate first to the get() and then to the put() operation. Always check what type of operation the signal comes from; this is given in the signal's last argument.

At the end, finished() (with success or failure) is emitted, so check the state of the network operation object to see whether or not the operation was successful.

Because a move or copy operation consists of multiple operations (get(), put() and maybe remove()), this function doesn't return a single Q3NetworkOperation, but rather a list of them. They are in the order: get(), put() and (if applicable) remove().

See also:
get(), put()

Definition at line 545 of file q3urloperator.cpp.

References Q3NetworkProtocol::addOperation(), QString::arg(), QObject::connect(), connectionStateChanged(), continueCopy(), copyGotData(), d, data(), dataTransferProgress(), deleteOperation(), Q3Url::dirPath(), emit, Q3NetworkProtocol::ErrUnsupported, Q3Url::fileName(), finished(), finishedCopy(), getNetworkProtocol(), Q3UrlOperatorPrivate::getOpGetProtMap, Q3UrlOperatorPrivate::getOpPutOpMap, Q3UrlOperatorPrivate::getOpPutProtMap, Q3UrlOperatorPrivate::getOpRemoveOpMap, Q3PtrDict< type >::insert(), Q3UrlOperatorPrivate::networkProtocol, Q3NetworkProtocol::OpGet, Q3NetworkProtocol::OpPut, Q3NetworkProtocol::OpRemove, QString::prepend(), Q3Url::protocol(), Q3UrlOperator(), qDebug(), Q3NetworkProtocol::setAutoDelete(), Q3NetworkOperation::setErrorCode(), setPath(), Q3NetworkOperation::setProtocolDetail(), Q3NetworkOperation::setState(), SIGNAL, SLOT, Q3NetworkProtocol::StFailed, and Q3NetworkProtocol::supportedOperations().

Referenced by finishedCopy(), Q3FileDialogQFileListView::viewportDropEvent(), and QFileListBox::viewportDropEvent().

00546 {
00547 #ifdef Q3URLOPERATOR_DEBUG
00548     qDebug( "Q3UrlOperator: copy %s %s %d", from.latin1(), to.latin1(), move );
00549 #endif
00550 
00551     Q3PtrList<Q3NetworkOperation> ops;
00552     ops.setAutoDelete( false );
00553 
00554     Q3UrlOperator *uFrom = new Q3UrlOperator( *this, from );
00555     Q3UrlOperator *uTo = new Q3UrlOperator( to );
00556 
00557     // prepare some string for later usage
00558     QString frm = *uFrom;
00559     QString file = uFrom->fileName();
00560 
00561     if (frm == to + file)
00562          return ops;
00563     
00564     file.prepend( "/" );
00565 
00566     // uFrom and uTo are deleted when the Q3NetworkProtocol deletes itself via
00567     // autodelete
00568     uFrom->getNetworkProtocol();
00569     uTo->getNetworkProtocol();
00570     Q3NetworkProtocol *gProt = uFrom->d->networkProtocol;
00571     Q3NetworkProtocol *pProt = uTo->d->networkProtocol;
00572 
00573     uFrom->setPath( uFrom->dirPath() );
00574 
00575     if ( gProt && (gProt->supportedOperations()&Q3NetworkProtocol::OpGet) &&
00576    pProt && (pProt->supportedOperations()&Q3NetworkProtocol::OpPut) ) {
00577 
00578   connect( gProt, SIGNAL(data(QByteArray,Q3NetworkOperation*)),
00579      this, SLOT(copyGotData(QByteArray,Q3NetworkOperation*)) );
00580   connect( gProt, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)),
00581      this, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)) );
00582   connect( gProt, SIGNAL(finished(Q3NetworkOperation*)),
00583      this, SLOT(continueCopy(Q3NetworkOperation*)) );
00584   connect( gProt, SIGNAL(finished(Q3NetworkOperation*)),
00585      this, SIGNAL(finished(Q3NetworkOperation*)) );
00586   connect( gProt, SIGNAL(connectionStateChanged(int,QString)),
00587      this, SIGNAL(connectionStateChanged(int,QString)) );
00588 
00589   connect( pProt, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)),
00590      this, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)) );
00591   connect( pProt, SIGNAL(finished(Q3NetworkOperation*)),
00592      this, SIGNAL(finished(Q3NetworkOperation*)) );
00593   connect( pProt, SIGNAL(finished(Q3NetworkOperation*)),
00594      this, SLOT(finishedCopy()) );
00595 
00596   Q3NetworkOperation *opGet = new Q3NetworkOperation( Q3NetworkProtocol::OpGet, frm, QString(), QString() );
00597   ops.append( opGet );
00598   gProt->addOperation( opGet );
00599 
00600 
00601   QString toFile = to + file;
00602   if (!toPath)
00603       toFile = to;
00604 
00605   Q3NetworkOperation *opPut = new Q3NetworkOperation( Q3NetworkProtocol::OpPut, toFile, QString(), QString() );
00606   ops.append( opPut );
00607 
00608   d->getOpPutProtMap.insert( (void*)opGet, pProt );
00609   d->getOpGetProtMap.insert( (void*)opGet, gProt );
00610   d->getOpPutOpMap.insert( (void*)opGet, opPut );
00611 
00612   if ( move && (gProt->supportedOperations()&Q3NetworkProtocol::OpRemove) ) {
00613       gProt->setAutoDelete( false );
00614 
00615       Q3NetworkOperation *opRm = new Q3NetworkOperation( Q3NetworkProtocol::OpRemove, frm, QString(), QString() );
00616       ops.append( opRm );
00617       d->getOpRemoveOpMap.insert( (void*)opGet, opRm );
00618   } else {
00619       gProt->setAutoDelete( true );
00620   }
00621 #ifdef Q3URLOPERATOR_DEBUG
00622   qDebug( "Q3UrlOperator: copy operation should start now..." );
00623 #endif
00624   return ops;
00625     } else {
00626   QString msg;
00627   if ( !gProt ) {
00628       msg = tr( "The protocol `%1' is not supported" ).arg( uFrom->protocol() );
00629   } else if ( gProt->supportedOperations() & Q3NetworkProtocol::OpGet ) {
00630       msg = tr( "The protocol `%1' does not support copying or moving files or directories" ).arg( uFrom->protocol() );
00631   } else if ( !pProt ) {
00632       msg = tr( "The protocol `%1' is not supported" ).arg( uTo->protocol() );
00633   } else {
00634       msg = tr( "The protocol `%1' does not support copying or moving files or directories" ).arg( uTo->protocol() );
00635   }
00636   delete uFrom;
00637   delete uTo;
00638   Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpGet, frm, to, QString() );
00639   res->setState( Q3NetworkProtocol::StFailed );
00640   res->setProtocolDetail( msg );
00641   res->setErrorCode( (int)Q3NetworkProtocol::ErrUnsupported );
00642   emit finished( res );
00643   deleteOperation( res );
00644     }
00645 
00646     return ops;
00647 }

Here is the call graph for this function:

void Q3UrlOperator::copy ( const QStringList files,
const QString dest,
bool  move = false 
) [virtual]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Copies the files to the directory dest. If move is true the files are moved, not copied. dest must point to a directory.

This function calls copy() for each entry in files in turn. You don't get a result from this function; each time a new copy begins, startedNextCopy() is emitted, with a list of Q3NetworkOperations that describe the new copy operation.

Definition at line 662 of file q3urloperator.cpp.

References d, finishedCopy(), Q3UrlOperatorPrivate::waitingCopies, Q3UrlOperatorPrivate::waitingCopiesDest, and Q3UrlOperatorPrivate::waitingCopiesMove.

00664 {
00665     d->waitingCopies = files;
00666     d->waitingCopiesDest = dest;
00667     d->waitingCopiesMove = move;
00668 
00669     finishedCopy();
00670 }

bool Q3UrlOperator::isDir ( bool *  ok = 0  )  [virtual]

Returns true if the URL is a directory; otherwise returns false. This may not always work correctly, if the protocol of the URL is something other than file (local filesystem). If you pass a bool pointer as the ok argument, *ok is set to true if the result of this function is known to be correct, and to false otherwise.

Definition at line 680 of file q3urloperator.cpp.

References QMap< Key, T >::contains(), d, Q3UrlOperatorPrivate::entryMap, Q3Url::isLocalFile(), and Q3Url::path().

Referenced by Q3FileDialog::setSelection(), and Q3FileDialog::setUrl().

00681 {
00682     if ( ok )
00683   *ok = true;
00684     if ( isLocalFile() ) {
00685   if ( QFileInfo( path() ).isDir() )
00686       return true;
00687   else
00688       return false;
00689     }
00690 
00691     if ( d->entryMap.contains( "." ) ) {
00692   return d->entryMap[ "." ].isDir();
00693     }
00694     // #### can assume that we are a directory?
00695     if ( ok )
00696   *ok = false;
00697     return true;
00698 }

Here is the call graph for this function:

void Q3UrlOperator::setNameFilter ( const QString nameFilter  )  [virtual]

Sets the name filter of the URL to nameFilter.

See also:
QDir::setNameFilter()

Definition at line 834 of file q3urloperator.cpp.

References d, Q3UrlOperatorPrivate::nameFilter, and nameFilter().

Referenced by Q3FileDialog::setDir(), Q3FileDialog::setFilter(), Q3FileDialog::setSelectedFilter(), Q3FileDialog::setSelection(), and Q3FileDialog::setUrl().

00835 {
00836     d->nameFilter = nameFilter;
00837 }

Here is the call graph for this function:

QString Q3UrlOperator::nameFilter (  )  const

Returns the name filter of the URL.

See also:
Q3UrlOperator::setNameFilter() QDir::nameFilter()

Definition at line 845 of file q3urloperator.cpp.

References d, and Q3UrlOperatorPrivate::nameFilter.

Referenced by Q3FileDialog::setDir(), setNameFilter(), Q3FileDialog::setSelection(), and Q3FileDialog::setUrl().

00846 {
00847     return d->nameFilter;
00848 }

QUrlInfo Q3UrlOperator::info ( const QString entry  )  const [virtual]

Returns the URL information for the child entry, or returns an empty QUrlInfo object if there is no information available about entry. Information about entry is only available after a successfully finished listChildren() operation.

Definition at line 877 of file q3urloperator.cpp.

References QMap< Key, T >::contains(), d, Q3UrlOperatorPrivate::entryMap, QUrlInfo::setDir(), QUrlInfo::setFile(), QUrlInfo::setGroup(), QUrlInfo::setName(), QUrlInfo::setOwner(), QUrlInfo::setReadable(), QUrlInfo::setSize(), QUrlInfo::setSymLink(), and QUrlInfo::setWritable().

Referenced by Q3FileDialogQFileListView::acceptDrop(), QFileListBox::acceptDrop(), Q3FileDialog::deleteFile(), Q3FileDialog::eventFilter(), Q3FileDialogPrivate::fileExists(), Q3FileDialog::fileNameEditDone(), Q3FileDialog::fileNameEditReturnPressed(), Q3FileDialog::keyPressEvent(), Q3FileDialog::okClicked(), Q3FileDialog::popupContextMenu(), Q3FileDialog::selectDirectoryOrFile(), Q3FileDialogQFileListView::setCurrentDropItem(), QFileListBox::setCurrentDropItem(), Q3FileDialog::setDir(), Q3FileDialog::setMode(), Q3FileDialog::urlFinished(), QFileListBox::viewportMousePressEvent(), and Q3FileDialogQFileListView::viewportMousePressEvent().

00878 {
00879     if ( d->entryMap.contains( entry.stripWhiteSpace() ) ) {
00880   return d->entryMap[ entry.stripWhiteSpace() ];
00881     } else if ( entry == "." || entry == ".." ) {
00882    // return a faked QUrlInfo
00883    QUrlInfo inf;
00884    inf.setName( entry );
00885    inf.setDir( true );
00886    inf.setFile( false );
00887    inf.setSymLink( false );
00888    inf.setOwner( tr( "(unknown)" ) );
00889    inf.setGroup( tr( "(unknown)" ) );
00890    inf.setSize( 0 );
00891    inf.setWritable( false );
00892    inf.setReadable( true );
00893    return inf;
00894     }
00895     return QUrlInfo();
00896 }

Here is the call graph for this function:

Q3UrlOperator & Q3UrlOperator::operator= ( const Q3UrlOperator url  ) 

Assigns url to this object.

Definition at line 971 of file q3urloperator.cpp.

References d, deleteNetworkProtocol(), getNetworkProtocol(), Q3UrlOperatorPrivate::getOpGetProtMap, Q3UrlOperatorPrivate::getOpPutOpMap, Q3UrlOperatorPrivate::getOpPutProtMap, Q3UrlOperatorPrivate::getOpRemoveOpMap, Q3UrlOperatorPrivate::networkProtocol, Q3UrlOperatorPrivate::oldOps, Q3Url::operator=(), and Q3PtrCollection::setAutoDelete().

00972 {
00973     deleteNetworkProtocol();
00974     Q3Url::operator=( url );
00975 
00976     Q3PtrDict<Q3NetworkOperation> getOpPutOpMap = d->getOpPutOpMap;
00977     Q3PtrDict<Q3NetworkProtocol> getOpPutProtMap = d->getOpPutProtMap;
00978     Q3PtrDict<Q3NetworkProtocol> getOpGetProtMap = d->getOpGetProtMap;
00979     Q3PtrDict<Q3NetworkOperation> getOpRemoveOpMap = d->getOpRemoveOpMap;
00980 
00981     *d = *url.d;
00982 
00983     d->oldOps.setAutoDelete( false );
00984     d->getOpPutOpMap = getOpPutOpMap;
00985     d->getOpPutProtMap = getOpPutProtMap;
00986     d->getOpGetProtMap = getOpGetProtMap;
00987     d->getOpRemoveOpMap = getOpRemoveOpMap;
00988 
00989     d->networkProtocol = 0;
00990     getNetworkProtocol();
00991     return *this;
00992 }

Here is the call graph for this function:

Q3UrlOperator & Q3UrlOperator::operator= ( const QString url  ) 

Assigns url to this object.

Reimplemented from Q3Url.

Definition at line 998 of file q3urloperator.cpp.

References d, deleteNetworkProtocol(), getNetworkProtocol(), Q3UrlOperatorPrivate::oldOps, Q3Url::operator=(), and Q3PtrCollection::setAutoDelete().

00999 {
01000     deleteNetworkProtocol();
01001     Q3Url::operator=( url );
01002     d->oldOps.setAutoDelete( false );
01003     getNetworkProtocol();
01004     return *this;
01005 }

Here is the call graph for this function:

void Q3UrlOperator::stop (  )  [virtual]

Stops the current network operation and removes all this Q3UrlOperator's waiting network operations.

Definition at line 1129 of file q3urloperator.cpp.

References Q3PtrDict< type >::clear(), QList< T >::clear(), Q3PtrDictIterator< type >::current(), Q3UrlOperatorPrivate::currPut, d, getNetworkProtocol(), Q3UrlOperatorPrivate::getOpGetProtMap, Q3UrlOperatorPrivate::getOpPutOpMap, Q3UrlOperatorPrivate::getOpPutProtMap, Q3UrlOperatorPrivate::getOpRemoveOpMap, Q3UrlOperatorPrivate::networkProtocol, Q3PtrCollection::setAutoDelete(), Q3NetworkProtocol::stop(), and Q3UrlOperatorPrivate::waitingCopies.

Referenced by Q3FileDialog::stopCopy().

01130 {
01131     d->getOpPutOpMap.clear();
01132     d->getOpRemoveOpMap.clear();
01133     d->getOpGetProtMap.setAutoDelete( true );
01134     d->getOpPutProtMap.setAutoDelete( true );
01135     Q3PtrDictIterator<Q3NetworkProtocol> it( d->getOpPutProtMap );
01136     for ( ; it.current(); ++it )
01137   it.current()->stop();
01138     d->getOpPutProtMap.clear();
01139     it = Q3PtrDictIterator<Q3NetworkProtocol>( d->getOpGetProtMap );
01140     for ( ; it.current(); ++it )
01141   it.current()->stop();
01142     d->getOpGetProtMap.clear();
01143     if ( d->currPut ) {
01144   d->currPut->stop();
01145   delete (Q3NetworkProtocol *) d->currPut;
01146   d->currPut = 0;
01147     }
01148     d->waitingCopies.clear();
01149     if ( d->networkProtocol )
01150   d->networkProtocol->stop();
01151     getNetworkProtocol();
01152 }

Here is the call graph for this function:

void Q3UrlOperator::newChildren ( const Q3ValueList< QUrlInfo > &  i,
Q3NetworkOperation op 
) [signal]

This signal is emitted after listChildren() was called and new children (i.e. files) have been read from a list of files. i holds the information about the new files. op is a pointer to the operation object which contains all the information about the operation, including the state.

See also:
Q3NetworkOperation, Q3NetworkProtocol

void Q3UrlOperator::finished ( Q3NetworkOperation op  )  [signal]

This signal is emitted when an operation of some sort finishes, whether with success or failure. op is a pointer to the operation object, which contains all the information, including the state, of the operation which has been finished. Check the state and error code of the operation object to see whether or not the operation was successful.

See also:
Q3NetworkOperation, Q3NetworkProtocol

Referenced by continueCopy(), copy(), and startOperation().

void Q3UrlOperator::start ( Q3NetworkOperation op  )  [signal]

Some operations (such as listChildren()) emit this signal when they start processing the operation. op is a pointer to the operation object which contains all the information about the operation, including the state.

See also:
Q3NetworkOperation, Q3NetworkProtocol

void Q3UrlOperator::createdDirectory ( const QUrlInfo i,
Q3NetworkOperation op 
) [signal]

This signal is emitted when mkdir() succeeds and the directory has been created. i holds the information about the new directory.

op is a pointer to the operation object, which contains all the information about the operation, including the state. op->arg(0) holds the new directory's name.

See also:
Q3NetworkOperation, Q3NetworkProtocol

void Q3UrlOperator::removed ( Q3NetworkOperation op  )  [signal]

This signal is emitted when remove() has been successful and the file has been removed.

op is a pointer to the operation object which contains all the information about the operation, including the state. op->arg(0) holds the name of the file that was removed.

See also:
Q3NetworkOperation, Q3NetworkProtocol

void Q3UrlOperator::itemChanged ( Q3NetworkOperation op  )  [signal]

This signal is emitted whenever a file which is a child of the URL has been changed, for example by successfully calling rename(). op is a pointer to the operation object which contains all the information about the operation, including the state. op->arg(0) holds the original file name and op->arg(1) holds the new file name (if it was changed).

See also:
Q3NetworkOperation, Q3NetworkProtocol

Referenced by getNetworkProtocol().

void Q3UrlOperator::data ( const QByteArray data,
Q3NetworkOperation op 
) [signal]

This signal is emitted when new data has been received after calling get() or put(). op is a pointer to the operation object which contains all the information about the operation, including the state. op->arg(0) holds the name of the file whose data is retrieved and op->rawArg(1) holds the (raw) data.

See also:
Q3NetworkOperation, Q3NetworkProtocol

Referenced by continueCopy(), copy(), copyGotData(), and put().

void Q3UrlOperator::dataTransferProgress ( int  bytesDone,
int  bytesTotal,
Q3NetworkOperation op 
) [signal]

This signal is emitted during data transfer (using put() or get()). bytesDone specifies how many bytes of bytesTotal have been transferred. More information about the operation is stored in op, a pointer to the network operation that is processed. bytesTotal may be -1, which means that the total number of bytes is not known.

See also:
Q3NetworkOperation, Q3NetworkProtocol

Referenced by copy().

void Q3UrlOperator::startedNextCopy ( const Q3PtrList< Q3NetworkOperation > &  lst  )  [signal]

This signal is emitted if copy() starts a new copy operation. lst contains all Q3NetworkOperations related to this copy operation.

See also:
copy()

Referenced by finishedCopy().

void Q3UrlOperator::connectionStateChanged ( int  state,
const QString data 
) [signal]

This signal is emitted whenever the URL operator's connection state changes. state describes the new state, which is a {Q3NetworkProtocol::ConnectionState} value.

data is a string that describes the change of the connection. This can be used to display a message to the user.

Referenced by copy().

void Q3UrlOperator::reset (  )  [protected, virtual]

Reimplemented from Q3Url.

Definition at line 944 of file q3urloperator.cpp.

References d, deleteNetworkProtocol(), Q3UrlOperatorPrivate::nameFilter, and Q3Url::reset().

00945 {
00946     Q3Url::reset();
00947     deleteNetworkProtocol();
00948     d->nameFilter = "*";
00949 }

Here is the call graph for this function:

bool Q3UrlOperator::parse ( const QString url  )  [protected, virtual]

Reimplemented from Q3Url.

Definition at line 955 of file q3urloperator.cpp.

References b, getNetworkProtocol(), and Q3Url::parse().

00956 {
00957     bool b = Q3Url::parse( url );
00958     if ( !b ) {
00959   return b;
00960     }
00961 
00962     getNetworkProtocol();
00963 
00964     return b;
00965 }

Here is the call graph for this function:

bool Q3UrlOperator::checkValid (  )  [protected, virtual]

Definition at line 1023 of file q3urloperator.cpp.

References Q3Url::isValid().

Referenced by listChildren(), mkdir(), remove(), and rename().

01024 {
01025     // ######
01026     if ( !isValid() ) {
01027   //emit error( ErrValid, tr( "The entered URL is not valid!" ) );
01028   return false;
01029     } else
01030   return true;
01031 }

Here is the call graph for this function:

void Q3UrlOperator::clearEntries (  )  [protected, virtual]

Clears the cache of children.

Definition at line 854 of file q3urloperator.cpp.

References QMap< Key, T >::clear(), d, and Q3UrlOperatorPrivate::entryMap.

Referenced by startOperation().

00855 {
00856     d->entryMap.clear();
00857 }

Here is the call graph for this function:

void Q3UrlOperator::getNetworkProtocol (  )  [protected]

Finds a network protocol for the URL and deletes the old network protocol.

Definition at line 902 of file q3urloperator.cpp.

References QObject::connect(), d, Q3NetworkProtocol::getNetworkProtocol(), itemChanged(), Q3UrlOperatorPrivate::networkProtocol, p, Q3Url::protocol(), Q3NetworkProtocol::setUrl(), SIGNAL, SLOT, and slotItemChanged().

Referenced by copy(), get(), operator=(), parse(), put(), Q3UrlOperator(), startOperation(), and stop().

00903 {
00904     delete d->networkProtocol;
00905     Q3NetworkProtocol *p = Q3NetworkProtocol::getNetworkProtocol( protocol() );
00906     if ( !p ) {
00907   d->networkProtocol = 0;
00908   return;
00909     }
00910 
00911     d->networkProtocol = (Q3NetworkProtocol *)p;
00912     d->networkProtocol->setUrl( this );
00913     connect( d->networkProtocol, SIGNAL(itemChanged(Q3NetworkOperation*)),
00914        this, SLOT(slotItemChanged(Q3NetworkOperation*)) );
00915 }

Here is the call graph for this function:

void Q3UrlOperator::deleteNetworkProtocol (  )  [protected]

Deletes the currently used network protocol.

Definition at line 921 of file q3urloperator.cpp.

References d, QObject::deleteLater(), and Q3UrlOperatorPrivate::networkProtocol.

Referenced by operator=(), and reset().

00922 {
00923     if (d->networkProtocol) {
00924         d->networkProtocol->deleteLater();
00925         d->networkProtocol = 0;
00926     }
00927 }

const Q3NetworkOperation * Q3UrlOperator::startOperation ( Q3NetworkOperation op  )  [private, slot]

This private function is used by the simple operation functions, i.e. listChildren(), mkdir(), remove(), rename(), get() and put(), to really start the operation. op is a pointer to the network operation that should be started. Returns op on success; otherwise returns 0.

Definition at line 353 of file q3urloperator.cpp.

References Q3NetworkProtocol::addOperation(), QString::arg(), clearEntries(), d, deleteOperation(), emit, Q3NetworkProtocol::ErrUnsupported, finished(), getNetworkProtocol(), Q3UrlOperatorPrivate::networkProtocol, Q3NetworkOperation::operation(), Q3NetworkProtocol::OpGet, Q3NetworkProtocol::OpListChildren, Q3NetworkProtocol::OpMkDir, Q3NetworkProtocol::OpPut, Q3NetworkProtocol::OpRemove, Q3NetworkProtocol::OpRename, Q3Url::protocol(), Q3NetworkOperation::setErrorCode(), Q3NetworkOperation::setProtocolDetail(), Q3NetworkOperation::setState(), Q3NetworkProtocol::StFailed, and Q3NetworkProtocol::supportedOperations().

Referenced by get(), listChildren(), mkdir(), put(), remove(), and rename().

00354 {
00355     if ( !d->networkProtocol )
00356         getNetworkProtocol();
00357     
00358     if ( d->networkProtocol && (d->networkProtocol->supportedOperations()&op->operation()) ) {
00359   d->networkProtocol->addOperation( op );
00360   if ( op->operation() == Q3NetworkProtocol::OpListChildren )
00361       clearEntries();
00362         return op;
00363     }
00364 
00365     // error
00366     QString msg;
00367     if ( !d->networkProtocol ) {
00368   msg = tr( "The protocol `%1' is not supported" ).arg( protocol() );
00369     } else {
00370   switch ( op->operation() ) {
00371   case Q3NetworkProtocol::OpListChildren:
00372       msg = tr( "The protocol `%1' does not support listing directories" ).arg( protocol() );
00373       break;
00374   case Q3NetworkProtocol::OpMkDir:
00375       msg = tr( "The protocol `%1' does not support creating new directories" ).arg( protocol() );
00376       break;
00377   case Q3NetworkProtocol::OpRemove:
00378       msg = tr( "The protocol `%1' does not support removing files or directories" ).arg( protocol() );
00379       break;
00380   case Q3NetworkProtocol::OpRename:
00381       msg = tr( "The protocol `%1' does not support renaming files or directories" ).arg( protocol() );
00382       break;
00383   case Q3NetworkProtocol::OpGet:
00384       msg = tr( "The protocol `%1' does not support getting files" ).arg( protocol() );
00385       break;
00386   case Q3NetworkProtocol::OpPut:
00387       msg = tr( "The protocol `%1' does not support putting files" ).arg( protocol() );
00388       break;
00389   default:
00390       // this should never happen
00391       break;
00392   }
00393     }
00394     op->setState( Q3NetworkProtocol::StFailed );
00395     op->setProtocolDetail( msg );
00396     op->setErrorCode( (int)Q3NetworkProtocol::ErrUnsupported );
00397     emit finished( op );
00398     deleteOperation( op );
00399     return 0;
00400 }

void Q3UrlOperator::copyGotData ( const QByteArray data,
Q3NetworkOperation op 
) [private, slot]

Definition at line 1038 of file q3urloperator.cpp.

References d, data(), QByteArray::data(), emit, Q3UrlOperatorPrivate::getOpPutOpMap, put(), qDebug(), s, QByteArray::size(), and size.

Referenced by continueCopy(), and copy().

01039 {
01040 #ifdef Q3URLOPERATOR_DEBUG
01041     qDebug( "Q3UrlOperator: copyGotData: %d new bytes", data_.size() );
01042 #endif
01043     Q3NetworkOperation *put = d->getOpPutOpMap[ (void*)op ];
01044     if ( put ) {
01045   QByteArray &s = put->raw( 1 );
01046   int size = s.size();
01047   s.resize( size + data_.size() );
01048   memcpy( s.data() + size, data_.data(), data_.size() );
01049     }
01050     emit data( data_, op );
01051 }

void Q3UrlOperator::continueCopy ( Q3NetworkOperation op  )  [private, slot]

Definition at line 1057 of file q3urloperator.cpp.

References Q3NetworkProtocol::addOperation(), copyGotData(), Q3UrlOperatorPrivate::currPut, d, data(), deleteOperation(), QObject::disconnect(), finished(), Q3UrlOperatorPrivate::getOpGetProtMap, Q3UrlOperatorPrivate::getOpPutOpMap, Q3UrlOperatorPrivate::getOpPutProtMap, Q3UrlOperatorPrivate::getOpRemoveOpMap, Q3NetworkOperation::operation(), Q3NetworkProtocol::OpGet, put(), qDebug(), Q3NetworkProtocol::setAutoDelete(), SIGNAL, SLOT, Q3NetworkOperation::state(), Q3NetworkProtocol::StDone, Q3NetworkProtocol::StFailed, and Q3PtrDict< type >::take().

Referenced by copy().

01058 {
01059     if ( op->operation() != Q3NetworkProtocol::OpGet )
01060   return;
01061     if ( op->state()!=Q3NetworkProtocol::StDone &&  op->state()!=Q3NetworkProtocol::StFailed ) {
01062   return;
01063     }
01064 
01065 #ifdef Q3URLOPERATOR_DEBUG
01066     if ( op->state() != Q3NetworkProtocol::StFailed ) {
01067   qDebug( "Q3UrlOperator: continue copy (get finished, put will start)" );
01068     }
01069 #endif
01070 
01071     Q3NetworkOperation *put = d->getOpPutOpMap[ (void*)op ];
01072     Q3NetworkProtocol *gProt = d->getOpGetProtMap[ (void*)op ];
01073     Q3NetworkProtocol *pProt = d->getOpPutProtMap[ (void*)op ];
01074     Q3NetworkOperation *rm = d->getOpRemoveOpMap[ (void*)op ];
01075     d->getOpPutOpMap.take( op );
01076     d->getOpGetProtMap.take( op );
01077     d->getOpPutProtMap.take( op );
01078     d->getOpRemoveOpMap.take( op );
01079     if ( pProt )
01080   pProt->setAutoDelete( true );
01081     if ( put && pProt ) {
01082   if ( op->state() != Q3NetworkProtocol::StFailed ) {
01083       pProt->addOperation( put );
01084       d->currPut = pProt;
01085   } else {
01086       deleteOperation( put );
01087   }
01088     }
01089     if ( gProt ) {
01090   gProt->setAutoDelete( true );
01091     }
01092     if ( rm && gProt ) {
01093   if ( op->state() != Q3NetworkProtocol::StFailed ) {
01094       gProt->addOperation( rm );
01095   } else {
01096       deleteOperation( rm );
01097   }
01098     }
01099     disconnect( gProt, SIGNAL(data(QByteArray,Q3NetworkOperation*)),
01100     this, SLOT(copyGotData(QByteArray,Q3NetworkOperation*)) );
01101     disconnect( gProt, SIGNAL(finished(Q3NetworkOperation*)),
01102     this, SLOT(continueCopy(Q3NetworkOperation*)) );
01103 }

void Q3UrlOperator::finishedCopy (  )  [private, slot]

Definition at line 1109 of file q3urloperator.cpp.

References copy(), d, emit, QList< T >::first(), QList< T >::isEmpty(), qDebug(), startedNextCopy(), Q3UrlOperatorPrivate::waitingCopies, Q3UrlOperatorPrivate::waitingCopiesDest, and Q3UrlOperatorPrivate::waitingCopiesMove.

Referenced by copy().

01110 {
01111 #ifdef Q3URLOPERATOR_DEBUG
01112     qDebug( "Q3UrlOperator: finished copy (finished putting)" );
01113 #endif
01114 
01115     if ( d->waitingCopies.isEmpty() )
01116   return;
01117 
01118     QString cp = d->waitingCopies.first();
01119     d->waitingCopies.remove( cp );
01120     Q3PtrList<Q3NetworkOperation> lst = copy( cp, d->waitingCopiesDest, d->waitingCopiesMove );
01121     emit startedNextCopy( lst );
01122 }

void Q3UrlOperator::addEntry ( const Q3ValueList< QUrlInfo > &  i  )  [private, slot]

Adds an entry to the cache of children.

Definition at line 863 of file q3urloperator.cpp.

References d, Q3UrlOperatorPrivate::entryMap, and i.

00864 {
00865     Q3ValueList<QUrlInfo>::ConstIterator it = i.begin();
00866     for ( ; it != i.end(); ++it )
00867   d->entryMap[ ( *it ).name().stripWhiteSpace() ] = *it;
00868 }

void Q3UrlOperator::slotItemChanged ( Q3NetworkOperation op  )  [private, slot]

Definition at line 1169 of file q3urloperator.cpp.

References Q3NetworkOperation::arg(), d, QMap< Key, T >::end(), Q3UrlOperatorPrivate::entryMap, QMap< Key, T >::erase(), QMap< Key, T >::find(), Q3NetworkOperation::operation(), Q3NetworkProtocol::OpRemove, and Q3NetworkProtocol::OpRename.

Referenced by getNetworkProtocol().

01170 {
01171     if ( !op )
01172   return;
01173 
01174     switch ( op->operation() ) {
01175     case Q3NetworkProtocol::OpRename :
01176     {
01177   if ( op->arg( 0 ) == op->arg( 1 ) )
01178       return;
01179 
01180   QMap<QString, QUrlInfo>::iterator mi = d->entryMap.find( op->arg( 0 ) );
01181   if ( mi != d->entryMap.end() ) {
01182       mi.data().setName( op->arg( 1 ) );
01183       d->entryMap[ op->arg( 1 ) ] = mi.data();
01184       d->entryMap.erase( mi );
01185   }
01186   break;
01187     }
01188     case Q3NetworkProtocol::OpRemove :
01189     {
01190   QMap<QString, QUrlInfo>::iterator mi = d->entryMap.find( op->arg( 0 ) );
01191   if ( mi != d->entryMap.end() )
01192       d->entryMap.erase( mi );
01193   break;
01194     }
01195     default:
01196   break;
01197     }
01198 }

void Q3UrlOperator::deleteOperation ( Q3NetworkOperation op  )  [private]

Definition at line 1158 of file q3urloperator.cpp.

References Q3PtrList< type >::append(), d, and Q3UrlOperatorPrivate::oldOps.

Referenced by continueCopy(), copy(), and startOperation().

01159 {
01160     if ( op )
01161   d->oldOps.append( op );
01162 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Q3NetworkProtocol [friend]

Definition at line 46 of file q3urloperator.h.

void q3InitNetworkProtocols (  )  [related]

This function registers the network protocols for FTP and HTTP. You must call this function before you use QUrlOperator for these protocols.

Definition at line 41 of file q3network.cpp.

References Q3NetworkProtocol::registerNetworkProtocol().

00042 {
00043 #ifndef QT_NO_NETWORKPROTOCOL_FTP
00044     Q3NetworkProtocol::registerNetworkProtocol( "ftp", new Q3NetworkProtocolFactory< Q3Ftp > );
00045 #endif
00046 #ifndef QT_NO_NETWORKPROTOCOL_HTTP
00047     Q3NetworkProtocol::registerNetworkProtocol( "http", new Q3NetworkProtocolFactory< Q3Http > );
00048 #endif
00049 }

Here is the call graph for this function:


Member Data Documentation

Q3UrlOperatorPrivate* Q3UrlOperator::d [private]

Reimplemented from Q3Url.

Definition at line 109 of file q3urloperator.h.

Referenced by addEntry(), cdUp(), clearEntries(), continueCopy(), copy(), copyGotData(), deleteNetworkProtocol(), deleteOperation(), finishedCopy(), get(), getNetworkProtocol(), info(), isDir(), nameFilter(), operator=(), put(), Q3UrlOperator(), reset(), setNameFilter(), setPath(), slotItemChanged(), startOperation(), stop(), and ~Q3UrlOperator().


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