• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.11.5 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  Copyright (C) 2013 Dawit Alemayehu <adawit@kde.org>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #ifndef KIO_JOB_P_H
25 #define KIO_JOB_P_H
26 
27 #include "job.h"
28 #include "kcompositejob_p.h"
29 #include "jobuidelegate.h"
30 #include "kjobtrackerinterface.h"
31 
32 #define KIO_ARGS QByteArray packedArgs; QDataStream stream( &packedArgs, QIODevice::WriteOnly ); stream
33 
34 namespace KIO {
35  class Slave;
36 
37  class JobPrivate: public KCompositeJobPrivate
38  {
39  public:
40  JobPrivate()
41  : m_parentJob( 0L ), m_extraFlags(0)
42  {}
43 
48  enum { EF_TransferJobAsync = (1 << 0),
49  EF_TransferJobNeedData = (1 << 1),
50  EF_TransferJobDataSent = (1 << 2),
51  EF_ListJobUnrestricted = (1 << 3),
52  EF_KillCalled = (1 << 4) };
53 
54  // Maybe we could use the QObject parent/child mechanism instead
55  // (requires a new ctor, and moving the ctor code to some init()).
56  Job* m_parentJob;
57  int m_extraFlags;
58  MetaData m_incomingMetaData;
59  MetaData m_internalMetaData;
60  MetaData m_outgoingMetaData;
61 
62  inline KIO::JobUiDelegate *ui() const
63  { return static_cast<KIO::JobUiDelegate *>(uiDelegate); }
64 
65  void slotSpeed( KJob *job, unsigned long speed );
66 
67  static void emitMoving(KIO::Job*, const KUrl &src, const KUrl &dest);
68  static void emitCopying(KIO::Job*, const KUrl &src, const KUrl &dest);
69  static void emitCreatingDir(KIO::Job*, const KUrl &dir);
70  static void emitDeleting(KIO::Job*, const KUrl &url);
71  static void emitStating(KIO::Job*, const KUrl &url);
72  static void emitTransferring(KIO::Job*, const KUrl &url);
73  static void emitMounting(KIO::Job*, const QString &dev, const QString &point);
74  static void emitUnmounting(KIO::Job*, const QString &point);
75 
76  Q_DECLARE_PUBLIC(Job)
77  };
78 
79  class SimpleJobPrivate: public JobPrivate
80  {
81  public:
88  SimpleJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs)
89  : m_slave(0), m_packedArgs(packedArgs), m_url(url), m_command(command),
90  m_checkOnHold(false), m_schedSerial(0), m_redirectionHandlingEnabled(true)
91  {
92  if (m_url.hasSubUrl())
93  {
94  KUrl::List list = KUrl::split(m_url);
95  list.removeLast();
96  m_subUrl = KUrl::join(list);
97  //kDebug(7007) << "New URL = " << m_url.url();
98  //kDebug(7007) << "Sub URL = " << m_subUrl.url();
99  }
100  }
101 
102  Slave * m_slave;
103  QByteArray m_packedArgs;
104  KUrl m_url;
105  KUrl m_subUrl;
106  int m_command;
107 
108  // for use in KIO::Scheduler
109  //
110  // There are two kinds of protocol:
111  // (1) The protocol of the url
112  // (2) The actual protocol that the io-slave uses.
113  //
114  // These two often match, but not necessarily. Most notably, they don't
115  // match when doing ftp via a proxy.
116  // In that case (1) is ftp, but (2) is http.
117  //
118  // JobData::protocol stores (2) while Job::url().protocol() returns (1).
119  // The ProtocolInfoDict is indexed with (2).
120  //
121  // We schedule slaves based on (2) but tell the slave about (1) via
122  // Slave::setProtocol().
123  QString m_protocol;
124  QStringList m_proxyList;
125  bool m_checkOnHold;
126  int m_schedSerial;
127  bool m_redirectionHandlingEnabled;
128 
129  void simpleJobInit();
130 
135  void slotConnected();
141  void slotProcessedSize( KIO::filesize_t data_size );
147  void slotSpeed( unsigned long speed );
153  void slotTotalSize( KIO::filesize_t data_size );
154 
160  void _k_slotSlaveInfoMessage( const QString &s );
161 
167  virtual void start( KIO::Slave *slave );
168 
173  void slaveDone();
174 
180  void restartAfterRedirection(KUrl *redirectionUrl);
181 
186  int requestMessageBox(int type, const QString& text,
187  const QString& caption,
188  const QString& buttonYes,
189  const QString& buttonNo,
190  const QString& iconYes = QString(),
191  const QString& iconNo = QString(),
192  const QString& dontAskAgainName = QString(),
193  const KIO::MetaData& sslMetaData = KIO::MetaData());
194 
195  Q_DECLARE_PUBLIC(SimpleJob)
196 
197  static inline SimpleJobPrivate *get(KIO::SimpleJob *job)
198  { return job->d_func(); }
199  static inline SimpleJob *newJobNoUi(const KUrl& url, int command, const QByteArray &packedArgs)
200  {
201  SimpleJob *job = new SimpleJob(*new SimpleJobPrivate(url, command, packedArgs));
202  return job;
203  }
204  static inline SimpleJob *newJob(const KUrl& url, int command, const QByteArray &packedArgs,
205  JobFlags flags = HideProgressInfo )
206  {
207  SimpleJob *job = new SimpleJob(*new SimpleJobPrivate(url, command, packedArgs));
208  job->setUiDelegate(new JobUiDelegate);
209  if (!(flags & HideProgressInfo))
210  KIO::getJobTracker()->registerJob(job);
211  return job;
212  }
213  };
214 
215  class MkdirJobPrivate;
220  class KIO_EXPORT MkdirJob : public SimpleJob {
221 
222  Q_OBJECT
223 
224  public:
225  ~MkdirJob();
226 
227  Q_SIGNALS:
235  void redirection( KIO::Job *job, const KUrl &url );
236 
244  void permanentRedirection( KIO::Job *job, const KUrl &fromUrl, const KUrl &toUrl );
245 
246  protected Q_SLOTS:
247  virtual void slotFinished();
248 
249  public:
250  MkdirJob(MkdirJobPrivate &dd);
251 
252  private:
253  Q_PRIVATE_SLOT(d_func(), void slotRedirection( const KUrl &url))
254  Q_DECLARE_PRIVATE(MkdirJob)
255  };
256 
257  class TransferJobPrivate: public SimpleJobPrivate
258  {
259  public:
260  inline TransferJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs,
261  const QByteArray &_staticData)
262  : SimpleJobPrivate(url, command, packedArgs),
263  m_internalSuspended(false), m_errorPage(false),
264  staticData(_staticData), m_isMimetypeEmitted(false), m_subJob(0)
265  { }
266 
267  inline TransferJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs,
268  QIODevice* ioDevice)
269  : SimpleJobPrivate(url, command, packedArgs),
270  m_internalSuspended(false), m_errorPage(false),
271  m_isMimetypeEmitted(false), m_subJob(0),
272  m_outgoingDataSource(QWeakPointer<QIODevice>(ioDevice))
273  { }
274 
275  bool m_internalSuspended;
276  bool m_errorPage;
277  QByteArray staticData;
278  KUrl m_redirectionURL;
279  KUrl::List m_redirectionList;
280  QString m_mimetype;
281  bool m_isMimetypeEmitted;
282  TransferJob *m_subJob;
283  QWeakPointer<QIODevice> m_outgoingDataSource;
284 
288  void internalSuspend();
292  void internalResume();
299  virtual void start( KIO::Slave *slave );
306  virtual void slotDataReqFromDevice();
307 
308  void slotErrorPage();
309  void slotCanResume( KIO::filesize_t offset );
310  void slotPostRedirection();
311  void slotNeedSubUrlData();
312  void slotSubUrlData(KIO::Job*, const QByteArray &);
313 
314  Q_DECLARE_PUBLIC(TransferJob)
315  static inline TransferJob *newJob(const KUrl& url, int command,
316  const QByteArray &packedArgs,
317  const QByteArray &_staticData,
318  JobFlags flags)
319  {
320  TransferJob *job = new TransferJob(*new TransferJobPrivate(url, command, packedArgs, _staticData));
321  job->setUiDelegate(new JobUiDelegate);
322  if (!(flags & HideProgressInfo))
323  KIO::getJobTracker()->registerJob(job);
324  return job;
325  }
326 
327  static inline TransferJob *newJob(const KUrl& url, int command,
328  const QByteArray &packedArgs,
329  QIODevice* ioDevice,
330  JobFlags flags)
331  {
332  TransferJob *job = new TransferJob(*new TransferJobPrivate(url, command, packedArgs, ioDevice));
333  job->setUiDelegate(new JobUiDelegate);
334  if (!(flags & HideProgressInfo))
335  KIO::getJobTracker()->registerJob(job);
336  return job;
337  }
338  };
339 
340  class DirectCopyJobPrivate;
345  class DirectCopyJob : public SimpleJob
346  {
347  Q_OBJECT
348 
349  public:
350  DirectCopyJob(const KUrl &url, const QByteArray &packedArgs);
351  ~DirectCopyJob();
352 
353  public Q_SLOTS:
354  void slotCanResume( KIO::filesize_t offset );
355 
356  Q_SIGNALS:
362  void canResume( KIO::Job *job, KIO::filesize_t offset );
363 
364  private:
365  Q_DECLARE_PRIVATE(DirectCopyJob)
366  };
367 }
368 
369 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Thu Sep 25 2014 04:20:27 by doxygen 1.8.3.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.11.5 API Reference

Skip menu "kdelibs-4.11.5 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