• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KIO

job_p.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00003                   2000-2009 David Faure <faure@kde.org>
00004                        Waldo Bastian <bastian@kde.org>
00005     Copyright (C) 2007 Thiago Macieira <thiago@kde.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef KIO_JOB_P_H
00024 #define KIO_JOB_P_H
00025 
00026 #include "job.h"
00027 #include "kcompositejob_p.h"
00028 #include "jobuidelegate.h"
00029 #include "kjobtrackerinterface.h"
00030 
00031 #define KIO_ARGS QByteArray packedArgs; QDataStream stream( &packedArgs, QIODevice::WriteOnly ); stream
00032 
00033 namespace KIO {
00034     class Slave;
00035 
00036     class JobPrivate: public KCompositeJobPrivate
00037     {
00038     public:
00039         JobPrivate()
00040             : m_parentJob( 0L ), m_extraFlags(0)
00041             {}
00042 
00047         enum { EF_TransferJobAsync    = (1 << 0),
00048                EF_TransferJobNeedData = (1 << 1),
00049                EF_TransferJobDataSent = (1 << 2),
00050                EF_ListJobUnrestricted = (1 << 3),
00051                EF_KillCalled          = (1 << 4) };
00052 
00053         // Maybe we could use the QObject parent/child mechanism instead
00054         // (requires a new ctor, and moving the ctor code to some init()).
00055         Job* m_parentJob;
00056         int m_extraFlags;
00057         MetaData m_incomingMetaData;
00058         MetaData m_internalMetaData;
00059         MetaData m_outgoingMetaData;
00060 
00061         inline KIO::JobUiDelegate *ui() const
00062             { return static_cast<KIO::JobUiDelegate *>(uiDelegate); }
00063 
00064         void slotSpeed( KJob *job, unsigned long speed );
00065 
00066         static void emitMoving(KIO::Job*, const KUrl &src, const KUrl &dest);
00067         static void emitCopying(KIO::Job*, const KUrl &src, const KUrl &dest);
00068         static void emitCreatingDir(KIO::Job*, const KUrl &dir);
00069         static void emitDeleting(KIO::Job*, const KUrl &url);
00070         static void emitStating(KIO::Job*, const KUrl &url);
00071         static void emitTransferring(KIO::Job*, const KUrl &url);
00072         static void emitMounting(KIO::Job*, const QString &dev, const QString &point);
00073         static void emitUnmounting(KIO::Job*, const QString &point);
00074 
00075         Q_DECLARE_PUBLIC(Job)
00076     };
00077 
00078     class SimpleJobPrivate: public JobPrivate
00079     {
00080     public:
00087         SimpleJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs)
00088             : m_slave(0), m_packedArgs(packedArgs), m_url(url), m_command(command),
00089               m_checkOnHold(false), m_schedSerial(0), m_redirectionHandlingEnabled(true)
00090         {
00091             if (m_url.hasSubUrl())
00092             {
00093                 KUrl::List list = KUrl::split(m_url);
00094                 list.removeLast();
00095                 m_subUrl = KUrl::join(list);
00096                 //kDebug(7007) << "New URL = "  << m_url.url();
00097                 //kDebug(7007) << "Sub URL = "  << m_subUrl.url();
00098             }
00099         }
00100 
00101         Slave * m_slave;
00102         QByteArray m_packedArgs;
00103         KUrl m_url;
00104         KUrl m_subUrl;
00105         int m_command;
00106 
00107         // for use in KIO::Scheduler
00108         //
00109         // There are two kinds of protocol:
00110         // (1) The protocol of the url
00111         // (2) The actual protocol that the io-slave uses.
00112         //
00113         // These two often match, but not necessarily. Most notably, they don't
00114         // match when doing ftp via a proxy.
00115         // In that case (1) is ftp, but (2) is http.
00116         //
00117         // JobData::protocol stores (2) while Job::url().protocol() returns (1).
00118         // The ProtocolInfoDict is indexed with (2).
00119         //
00120         // We schedule slaves based on (2) but tell the slave about (1) via
00121         // Slave::setProtocol().
00122         QString m_protocol;
00123         QString m_proxy;
00124         bool m_checkOnHold;
00125         int m_schedSerial;
00126         bool m_redirectionHandlingEnabled;
00127 
00128         void simpleJobInit();
00129 
00134         void slotConnected();
00140         void slotProcessedSize( KIO::filesize_t data_size );
00146         void slotSpeed( unsigned long speed );
00152         void slotTotalSize( KIO::filesize_t data_size );
00153 
00159         void _k_slotSlaveInfoMessage( const QString &s );
00160 
00166         virtual void start( KIO::Slave *slave );
00167 
00172         void slaveDone();
00173 
00179         void restartAfterRedirection(KUrl *redirectionUrl);
00180 
00181         Q_DECLARE_PUBLIC(SimpleJob)
00182 
00183         static inline SimpleJobPrivate *get(KIO::SimpleJob *job)
00184             { return job->d_func(); }
00185         static inline SimpleJob *newJobNoUi(const KUrl& url, int command, const QByteArray &packedArgs)
00186         {
00187             SimpleJob *job = new SimpleJob(*new SimpleJobPrivate(url, command, packedArgs));
00188             return job;
00189         }
00190         static inline SimpleJob *newJob(const KUrl& url, int command, const QByteArray &packedArgs,
00191                                         JobFlags flags = HideProgressInfo )
00192         {
00193             SimpleJob *job = new SimpleJob(*new SimpleJobPrivate(url, command, packedArgs));
00194             job->setUiDelegate(new JobUiDelegate);
00195             if (!(flags & HideProgressInfo))
00196                 KIO::getJobTracker()->registerJob(job);
00197             return job;
00198         }
00199     };
00200 
00201     class MkdirJobPrivate;
00206     class KIO_EXPORT MkdirJob : public SimpleJob {
00207 
00208     Q_OBJECT
00209 
00210     public:
00211         ~MkdirJob();
00212 
00213     Q_SIGNALS:
00221         void redirection( KIO::Job *job, const KUrl &url );
00222 
00230         void permanentRedirection( KIO::Job *job, const KUrl &fromUrl, const KUrl &toUrl );
00231 
00232     protected Q_SLOTS:
00233         virtual void slotFinished();
00234 
00235     public:
00236         MkdirJob(MkdirJobPrivate &dd);
00237 
00238     private:
00239         Q_PRIVATE_SLOT(d_func(), void slotRedirection( const KUrl &url))
00240         Q_DECLARE_PRIVATE(MkdirJob)
00241     };
00242 
00243     class TransferJobPrivate: public SimpleJobPrivate
00244     {
00245     public:
00246         inline TransferJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs,
00247                                   const QByteArray &_staticData)
00248             : SimpleJobPrivate(url, command, packedArgs),
00249               m_internalSuspended(false), m_errorPage(false),
00250               staticData(_staticData), m_isMimetypeEmitted(false), m_subJob(0)
00251             { }
00252 
00253 
00254         bool m_internalSuspended;
00255         bool m_errorPage;
00256         QByteArray staticData;
00257         KUrl m_redirectionURL;
00258         KUrl::List m_redirectionList;
00259         QString m_mimetype;
00260         bool m_isMimetypeEmitted;
00261         TransferJob *m_subJob;
00262 
00266         void internalSuspend();
00270         void internalResume();
00277         virtual void start( KIO::Slave *slave );
00278 
00279         void slotErrorPage();
00280         void slotCanResume( KIO::filesize_t offset );
00281         void slotPostRedirection();
00282         void slotNeedSubUrlData();
00283         void slotSubUrlData(KIO::Job*, const QByteArray &);
00284 
00285         Q_DECLARE_PUBLIC(TransferJob)
00286         static inline TransferJob *newJob(const KUrl& url, int command,
00287                                           const QByteArray &packedArgs,
00288                                           const QByteArray &_staticData,
00289                                           JobFlags flags)
00290         {
00291             TransferJob *job = new TransferJob(*new TransferJobPrivate(url, command, packedArgs, _staticData));
00292             job->setUiDelegate(new JobUiDelegate);
00293             if (!(flags & HideProgressInfo))
00294                 KIO::getJobTracker()->registerJob(job);
00295             return job;
00296         }
00297     };
00298 
00299     class DirectCopyJobPrivate;
00304     class DirectCopyJob : public SimpleJob
00305     {
00306         Q_OBJECT
00307 
00308     public:
00309         DirectCopyJob(const KUrl &url, const QByteArray &packedArgs);
00310         ~DirectCopyJob();
00311 
00312     public Q_SLOTS:
00313         void slotCanResume( KIO::filesize_t offset );
00314 
00315     Q_SIGNALS:
00321         void canResume( KIO::Job *job, KIO::filesize_t offset );
00322 
00323     private:
00324         Q_DECLARE_PRIVATE(DirectCopyJob)
00325     };
00326 }
00327 
00328 #endif

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal