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

KIO

  • kio
  • kio
job_p.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
3  2000-2009 David Faure <faure@kde.org>
4  Waldo Bastian <bastian@kde.org>
5  Copyright (C) 2007 Thiago Macieira <thiago@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef KIO_JOB_P_H
24 #define KIO_JOB_P_H
25 
26 #include "job.h"
27 #include "kcompositejob_p.h"
28 #include "jobuidelegate.h"
29 #include "kjobtrackerinterface.h"
30 
31 #define KIO_ARGS QByteArray packedArgs; QDataStream stream( &packedArgs, QIODevice::WriteOnly ); stream
32 
33 namespace KIO {
34  class Slave;
35 
36  class JobPrivate: public KCompositeJobPrivate
37  {
38  public:
39  JobPrivate()
40  : m_parentJob( 0L ), m_extraFlags(0)
41  {}
42 
47  enum { EF_TransferJobAsync = (1 << 0),
48  EF_TransferJobNeedData = (1 << 1),
49  EF_TransferJobDataSent = (1 << 2),
50  EF_ListJobUnrestricted = (1 << 3),
51  EF_KillCalled = (1 << 4) };
52 
53  // Maybe we could use the QObject parent/child mechanism instead
54  // (requires a new ctor, and moving the ctor code to some init()).
55  Job* m_parentJob;
56  int m_extraFlags;
57  MetaData m_incomingMetaData;
58  MetaData m_internalMetaData;
59  MetaData m_outgoingMetaData;
60 
61  inline KIO::JobUiDelegate *ui() const
62  { return static_cast<KIO::JobUiDelegate *>(uiDelegate); }
63 
64  void slotSpeed( KJob *job, unsigned long speed );
65 
66  static void emitMoving(KIO::Job*, const KUrl &src, const KUrl &dest);
67  static void emitCopying(KIO::Job*, const KUrl &src, const KUrl &dest);
68  static void emitCreatingDir(KIO::Job*, const KUrl &dir);
69  static void emitDeleting(KIO::Job*, const KUrl &url);
70  static void emitStating(KIO::Job*, const KUrl &url);
71  static void emitTransferring(KIO::Job*, const KUrl &url);
72  static void emitMounting(KIO::Job*, const QString &dev, const QString &point);
73  static void emitUnmounting(KIO::Job*, const QString &point);
74 
75  Q_DECLARE_PUBLIC(Job)
76  };
77 
78  class SimpleJobPrivate: public JobPrivate
79  {
80  public:
87  SimpleJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs)
88  : m_slave(0), m_packedArgs(packedArgs), m_url(url), m_command(command),
89  m_checkOnHold(false), m_schedSerial(0), m_redirectionHandlingEnabled(true)
90  {
91  if (m_url.hasSubUrl())
92  {
93  KUrl::List list = KUrl::split(m_url);
94  list.removeLast();
95  m_subUrl = KUrl::join(list);
96  //kDebug(7007) << "New URL = " << m_url.url();
97  //kDebug(7007) << "Sub URL = " << m_subUrl.url();
98  }
99  }
100 
101  Slave * m_slave;
102  QByteArray m_packedArgs;
103  KUrl m_url;
104  KUrl m_subUrl;
105  int m_command;
106 
107  // for use in KIO::Scheduler
108  //
109  // There are two kinds of protocol:
110  // (1) The protocol of the url
111  // (2) The actual protocol that the io-slave uses.
112  //
113  // These two often match, but not necessarily. Most notably, they don't
114  // match when doing ftp via a proxy.
115  // In that case (1) is ftp, but (2) is http.
116  //
117  // JobData::protocol stores (2) while Job::url().protocol() returns (1).
118  // The ProtocolInfoDict is indexed with (2).
119  //
120  // We schedule slaves based on (2) but tell the slave about (1) via
121  // Slave::setProtocol().
122  QString m_protocol;
123  QStringList m_proxyList;
124  bool m_checkOnHold;
125  int m_schedSerial;
126  bool m_redirectionHandlingEnabled;
127 
128  void simpleJobInit();
129 
134  void slotConnected();
140  void slotProcessedSize( KIO::filesize_t data_size );
146  void slotSpeed( unsigned long speed );
152  void slotTotalSize( KIO::filesize_t data_size );
153 
159  void _k_slotSlaveInfoMessage( const QString &s );
160 
166  virtual void start( KIO::Slave *slave );
167 
172  void slaveDone();
173 
179  void restartAfterRedirection(KUrl *redirectionUrl);
180 
181  Q_DECLARE_PUBLIC(SimpleJob)
182 
183  static inline SimpleJobPrivate *get(KIO::SimpleJob *job)
184  { return job->d_func(); }
185  static inline SimpleJob *newJobNoUi(const KUrl& url, int command, const QByteArray &packedArgs)
186  {
187  SimpleJob *job = new SimpleJob(*new SimpleJobPrivate(url, command, packedArgs));
188  return job;
189  }
190  static inline SimpleJob *newJob(const KUrl& url, int command, const QByteArray &packedArgs,
191  JobFlags flags = HideProgressInfo )
192  {
193  SimpleJob *job = new SimpleJob(*new SimpleJobPrivate(url, command, packedArgs));
194  job->setUiDelegate(new JobUiDelegate);
195  if (!(flags & HideProgressInfo))
196  KIO::getJobTracker()->registerJob(job);
197  return job;
198  }
199  };
200 
201  class MkdirJobPrivate;
206  class KIO_EXPORT MkdirJob : public SimpleJob {
207 
208  Q_OBJECT
209 
210  public:
211  ~MkdirJob();
212 
213  Q_SIGNALS:
221  void redirection( KIO::Job *job, const KUrl &url );
222 
230  void permanentRedirection( KIO::Job *job, const KUrl &fromUrl, const KUrl &toUrl );
231 
232  protected Q_SLOTS:
233  virtual void slotFinished();
234 
235  public:
236  MkdirJob(MkdirJobPrivate &dd);
237 
238  private:
239  Q_PRIVATE_SLOT(d_func(), void slotRedirection( const KUrl &url))
240  Q_DECLARE_PRIVATE(MkdirJob)
241  };
242 
243  class TransferJobPrivate: public SimpleJobPrivate
244  {
245  public:
246  inline TransferJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs,
247  const QByteArray &_staticData)
248  : SimpleJobPrivate(url, command, packedArgs),
249  m_internalSuspended(false), m_errorPage(false),
250  staticData(_staticData), m_isMimetypeEmitted(false), m_subJob(0)
251  { }
252 
253  inline TransferJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs,
254  QIODevice* ioDevice)
255  : SimpleJobPrivate(url, command, packedArgs),
256  m_internalSuspended(false), m_errorPage(false),
257  m_isMimetypeEmitted(false), m_subJob(0),
258  m_outgoingDataSource(QWeakPointer<QIODevice>(ioDevice))
259  { }
260 
261  bool m_internalSuspended;
262  bool m_errorPage;
263  QByteArray staticData;
264  KUrl m_redirectionURL;
265  KUrl::List m_redirectionList;
266  QString m_mimetype;
267  bool m_isMimetypeEmitted;
268  TransferJob *m_subJob;
269  QWeakPointer<QIODevice> m_outgoingDataSource;
270 
274  void internalSuspend();
278  void internalResume();
285  virtual void start( KIO::Slave *slave );
292  virtual void slotDataReqFromDevice();
293 
294  void slotErrorPage();
295  void slotCanResume( KIO::filesize_t offset );
296  void slotPostRedirection();
297  void slotNeedSubUrlData();
298  void slotSubUrlData(KIO::Job*, const QByteArray &);
299 
300  Q_DECLARE_PUBLIC(TransferJob)
301  static inline TransferJob *newJob(const KUrl& url, int command,
302  const QByteArray &packedArgs,
303  const QByteArray &_staticData,
304  JobFlags flags)
305  {
306  TransferJob *job = new TransferJob(*new TransferJobPrivate(url, command, packedArgs, _staticData));
307  job->setUiDelegate(new JobUiDelegate);
308  if (!(flags & HideProgressInfo))
309  KIO::getJobTracker()->registerJob(job);
310  return job;
311  }
312 
313  static inline TransferJob *newJob(const KUrl& url, int command,
314  const QByteArray &packedArgs,
315  QIODevice* ioDevice,
316  JobFlags flags)
317  {
318  TransferJob *job = new TransferJob(*new TransferJobPrivate(url, command, packedArgs, ioDevice));
319  job->setUiDelegate(new JobUiDelegate);
320  if (!(flags & HideProgressInfo))
321  KIO::getJobTracker()->registerJob(job);
322  return job;
323  }
324  };
325 
326  class DirectCopyJobPrivate;
331  class DirectCopyJob : public SimpleJob
332  {
333  Q_OBJECT
334 
335  public:
336  DirectCopyJob(const KUrl &url, const QByteArray &packedArgs);
337  ~DirectCopyJob();
338 
339  public Q_SLOTS:
340  void slotCanResume( KIO::filesize_t offset );
341 
342  Q_SIGNALS:
348  void canResume( KIO::Job *job, KIO::filesize_t offset );
349 
350  private:
351  Q_DECLARE_PRIVATE(DirectCopyJob)
352  };
353 }
354 
355 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jun 1 2013 12:08:30 by doxygen 1.8.1.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

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

kdelibs-4.10.4 API Reference

Skip menu "kdelibs-4.10.4 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • 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
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal