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

KIO

  • kio
  • kio
slavebase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2000 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef SLAVEBASE_H
21#define SLAVEBASE_H
22
23#include <kio/global.h>
24#include <kio/udsentry.h>
25#include <kio/authinfo.h>
26#include <kio/jobclasses.h> // for KIO::JobFlags
27#include <klocale.h>
28
29#include <QtCore/QByteArray>
30#include <QtNetwork/QHostInfo>
31
32class KConfigGroup;
33class KRemoteEncoding;
34class KUrl;
35
36namespace KIO {
37
38class Connection;
39class SlaveBasePrivate;
40
50class KIO_EXPORT SlaveBase
51{
52public:
53 SlaveBase( const QByteArray &protocol, const QByteArray &pool_socket, const QByteArray &app_socket);
54 virtual ~SlaveBase();
55
60 void exit();
61
65 void dispatchLoop();
66
68 // Message Signals to send to the job
70
79 void data( const QByteArray &data );
80
85 void dataReq( );
86
91 void opened();
92
121 void error( int _errid, const QString &_text );
122
126 void connected();
127
133 void finished();
134
138 void needSubUrlData();
139
146 void slaveStatus(const QString &host, bool connected);
147
154 void statEntry( const UDSEntry& _entry );
155
161 void listEntries( const UDSEntryList& _entry );
162
170 bool canResume( KIO::filesize_t offset );
171
176 void canResume();
177
179 // Info Signals to send to the job
181
186 void totalSize( KIO::filesize_t _bytes );
192 void processedSize( KIO::filesize_t _bytes );
193
194 void position( KIO::filesize_t _pos );
195
196 void written( KIO::filesize_t _bytes );
197
209 void processedPercent( float percent );
210
216 void speed( unsigned long _bytes_per_second );
217
222 void redirection( const KUrl &_url );
223
229 void errorPage();
230
235 void mimeType( const QString &_type );
236
240 void warning( const QString &msg );
241
246 void infoMessage( const QString &msg );
247
248 enum MessageBoxType { QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4, Information = 5, SSLMessageBox = 6 };
249
263 int messageBox( MessageBoxType type, const QString &text,
264 const QString &caption = QString(),
265 const QString &buttonYes = i18n("&Yes"),
266 const QString &buttonNo = i18n("&No"));
267
283 int messageBox( const QString &text, MessageBoxType type,
284 const QString &caption = QString(),
285 const QString &buttonYes = i18n("&Yes"),
286 const QString &buttonNo = i18n("&No"),
287 const QString &dontAskAgainName = QString() );
288
293 void setMetaData(const QString &key, const QString &value);
294
299 bool hasMetaData(const QString &key) const;
300
304 QString metaData(const QString &key) const;
305
306
311 MetaData allMetaData() const;
312
320 KConfigGroup* config();
321
326 KRemoteEncoding* remoteEncoding();
327
328
330 // Commands sent by the job, the slave has to
331 // override what it wants to implement
333
345 virtual void setHost(const QString& host, quint16 port, const QString& user, const QString& pass);
346
350 virtual void setSubUrl(const KUrl&url);
351
361 virtual void openConnection();
362
371 virtual void closeConnection();
372
392 virtual void get( const KUrl& url );
393
400 virtual void open( const KUrl &url, QIODevice::OpenMode mode );
401
402 virtual void read( KIO::filesize_t size );
403 virtual void write( const QByteArray &data );
404 virtual void seek( KIO::filesize_t offset );
405 virtual void close();
406
422 virtual void put( const KUrl& url, int permissions, JobFlags flags );
423
439 virtual void stat( const KUrl& url );
440
453 virtual void mimetype( const KUrl& url );
454
464 virtual void listDir( const KUrl& url );
465
473 virtual void mkdir( const KUrl&url, int permissions );
474
501 virtual void rename( const KUrl& src, const KUrl& dest, JobFlags flags );
502
510 virtual void symlink( const QString& target, const KUrl& dest, JobFlags flags );
511
516 virtual void chmod( const KUrl& url, int permissions );
517
522 virtual void chown( const KUrl& url, const QString& owner, const QString& group );
523
531 virtual void setModificationTime( const KUrl& url, const QDateTime& mtime );
532
557 virtual void copy( const KUrl &src, const KUrl &dest, int permissions, JobFlags flags );
558
569 virtual void del( const KUrl &url, bool isfile);
570
576 virtual void setLinkDest( const KUrl& url, const QString& target );
577
586 virtual void special( const QByteArray & data );
587
595 virtual void multiGet( const QByteArray & data );
596
601 virtual void slave_status();
602
607 virtual void reparseConfiguration();
608
609
613 int connectTimeout();
614
618 int proxyConnectTimeout();
619
624 int responseTimeout();
625
630 int readTimeout();
631
645 void setTimeoutSpecialCommand(int timeout, const QByteArray &data=QByteArray());
646
648 // Dispatching (internal)
650
654 virtual void dispatch( int command, const QByteArray &data );
655
659 virtual void dispatchOpenCommand( int command, const QByteArray &data );
660
669 int readData( QByteArray &buffer );
670
682 void listEntry( const UDSEntry& _entry, bool ready);
683
688 void connectSlave(const QString& path);
689 void disconnectSlave();
690
743 bool openPasswordDialog( KIO::AuthInfo& info, const QString &errorMsg = QString() );
744
772 bool checkCachedAuthentication( AuthInfo& info );
773
800 bool cacheAuthentication( const AuthInfo& info );
801
820 bool requestNetwork(const QString& host = QString());
821
835 void dropNetwork(const QString& host = QString());
836
841 int waitForAnswer( int expected1, int expected2, QByteArray & data, int * pCmd = 0 );
842
855 void sendMetaData();
856
863 void sendAndKeepMetaData();
864
870 bool wasKilled() const;
871
875 void setKillFlag();
876
880 void lookupHost(const QString& host);
881
885 int waitForHostInfo(QHostInfo& info);
886
887protected:
891 QByteArray mProtocol;
892 //Often used by TcpSlaveBase and unlikely to change
893 MetaData mOutgoingMetaData;
894 MetaData mIncomingMetaData;
895
896 enum VirtualFunctionId {
897 AppConnectionMade = 0
898 };
899 virtual void virtual_hook( int id, void* data );
900
901private:
902#if 0 // TODO KDE5: enable
903 // This helps catching missing tr() calls in error().
904 void error( int _errid, const QByteArray &_text );
905#endif
906 void send(int cmd, const QByteArray& arr = QByteArray());
907 SlaveBasePrivate* const d;
908 friend class SlaveBasePrivate;
909};
910
911}
912
913#endif
authinfo.h
KConfigGroup
KIO::AuthInfo
This class is intended to make it easier to prompt for, cache and retrieve authorization information.
Definition authinfo.h:58
KIO::MetaData
MetaData is a simple map of key/value strings.
Definition global.h:397
KIO::SlaveBase::mimeType
void mimeType(const QString &_type)
Call this in mimetype() and in get(), when you know the mimetype.
Definition slavebase.cpp:588
KIO::SlaveBase::VirtualFunctionId
VirtualFunctionId
Definition slavebase.h:896
KIO::SlaveBase::AppConnectionMade
@ AppConnectionMade
Definition slavebase.h:897
KIO::SlaveBase::speed
void speed(unsigned long _bytes_per_second)
Call this in get and copy, to give the current transfer speed, but only if it can't be calculated out...
Definition slavebase.cpp:559
KIO::SlaveBase::infoMessage
void infoMessage(const QString &msg)
Call to signal a message, to be displayed if the application wants to, for instance in a status bar.
Definition slavebase.cpp:644
KIO::SlaveBase::processedSize
void processedSize(KIO::filesize_t _bytes)
Call this during get and copy, once in a while, to give some info about the current state.
Definition slavebase.cpp:507
KIO::SlaveBase::errorPage
void errorPage()
Tell that we will only get an error page here.
Definition slavebase.cpp:571
KIO::SlaveBase::warning
void warning(const QString &msg)
Call to signal a warning, to be displayed in a dialog box.
Definition slavebase.cpp:638
KIO::SlaveBase::finished
void finished()
Call to signal successful completion of any command besides openConnection and closeConnection.
Definition slavebase.cpp:447
KIO::SlaveBase::slaveStatus
void slaveStatus(const QString &host, bool connected)
Used to report the status of the slave.
Definition slavebase.cpp:482
KIO::SlaveBase::mOutgoingMetaData
MetaData mOutgoingMetaData
Definition slavebase.h:893
KIO::SlaveBase::dataReq
void dataReq()
Asks for data from the job.
Definition slavebase.cpp:404
KIO::SlaveBase::written
void written(KIO::filesize_t _bytes)
Definition slavebase.cpp:541
KIO::SlaveBase::redirection
void redirection(const KUrl &_url)
Call this to signal a redirection The job will take care of going to that url.
Definition slavebase.cpp:565
KIO::SlaveBase::error
void error(int _errid, const QString &_text)
Call to signal an error.
Definition slavebase.cpp:419
KIO::SlaveBase::mProtocol
QByteArray mProtocol
Name of the protocol supported by this slave.
Definition slavebase.h:891
KIO::SlaveBase::SlaveBase
SlaveBase(const QByteArray &protocol, const QByteArray &pool_socket, const QByteArray &app_socket)
Definition slavebase.cpp:179
KIO::SlaveBase::statEntry
void statEntry(const UDSEntry &_entry)
Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms...
Definition slavebase.cpp:671
KIO::SlaveBase::connected
void connected()
Call in openConnection, if you reimplement it, when you're done.
Definition slavebase.cpp:442
KIO::SlaveBase::position
void position(KIO::filesize_t _pos)
Definition slavebase.cpp:547
KIO::SlaveBase::dispatchLoop
void dispatchLoop()
Definition slavebase.cpp:262
KIO::SlaveBase::MessageBoxType
MessageBoxType
Definition slavebase.h:248
KIO::SlaveBase::WarningYesNoCancel
@ WarningYesNoCancel
Definition slavebase.h:248
KIO::SlaveBase::QuestionYesNo
@ QuestionYesNo
Definition slavebase.h:248
KIO::SlaveBase::Information
@ Information
Definition slavebase.h:248
KIO::SlaveBase::SSLMessageBox
@ SSLMessageBox
Definition slavebase.h:248
KIO::SlaveBase::WarningContinueCancel
@ WarningContinueCancel
Definition slavebase.h:248
KIO::SlaveBase::WarningYesNo
@ WarningYesNo
Definition slavebase.h:248
KIO::SlaveBase::processedPercent
void processedPercent(float percent)
Only use this if you can't know in advance the size of the copied data.
Definition slavebase.cpp:553
KIO::SlaveBase::data
void data(const QByteArray &data)
Sends data in the slave to the job (i.e.
Definition slavebase.cpp:398
KIO::SlaveBase::listEntries
void listEntries(const UDSEntryList &_entry)
Call this in listDir, each time you have a bunch of entries to report.
Definition slavebase.cpp:704
KIO::SlaveBase::totalSize
void totalSize(KIO::filesize_t _bytes)
Call this in get and copy, to give the total size of the file.
Definition slavebase.cpp:497
KIO::SlaveBase::mIncomingMetaData
MetaData mIncomingMetaData
Definition slavebase.h:894
KIO::SlaveBase::SlaveBasePrivate
friend class SlaveBasePrivate
Definition slavebase.h:908
KIO::SlaveBase::canResume
bool canResume(KIO::filesize_t offset)
Call this at the beginning of put(), to give the size of the existing partial file,...
Definition slavebase.cpp:875
KIO::SlaveBase::needSubUrlData
void needSubUrlData()
Call to signal that data from the sub-URL is needed.
Definition slavebase.cpp:469
KIO::SlaveBase::opened
void opened()
open succedes
Definition slavebase.cpp:412
KIO::SlaveBase::exit
void exit()
Definition slavebase.cpp:628
KIO::UDSEntry
Universal Directory Service.
Definition udsentry.h:59
KRemoteEncoding
Allows encoding and decoding properly remote filenames into Unicode.
Definition kremoteencoding.h:45
KUrl
global.h
jobclasses.h
timeout
int timeout
klocale.h
i18n
QString i18n(const char *text)
KIO
A namespace for KIO globals.
Definition kbookmarkmenu.h:55
KIO::del
DeleteJob * del(const KUrl &src, JobFlags flags=DefaultFlags)
Delete a file or directory.
Definition deletejob.cpp:492
KIO::chmod
ChmodJob * chmod(const KFileItemList &lstItems, int permissions, int mask, const QString &newOwner, const QString &newGroup, bool recursive, JobFlags flags=DefaultFlags)
Creates a job that changes permissions/ownership on several files or directories, optionally recursiv...
Definition chmodjob.cpp:268
KIO::chown
SimpleJob * chown(const KUrl &url, const QString &owner, const QString &group)
Changes ownership and group of a file or directory.
Definition job.cpp:718
KIO::setModificationTime
SimpleJob * setModificationTime(const KUrl &url, const QDateTime &mtime)
Changes the modification time on a file or directory.
Definition job.cpp:724
KIO::open
FileJob * open(const KUrl &url, QIODevice::OpenMode mode)
Open ( random access I/O )
Definition filejob.cpp:211
KIO::stat
StatJob * stat(const KUrl &url, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
Definition job.cpp:924
KIO::put
TransferJob * put(const KUrl &url, int permissions, JobFlags flags=DefaultFlags)
Put (a.k.a.
Definition job.cpp:1700
KIO::listDir
ListJob * listDir(const KUrl &url, JobFlags flags=DefaultFlags, bool includeHidden=true)
List the contents of url, which is assumed to be a directory.
Definition job.cpp:2735
KIO::get
TransferJob * get(const KUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
Get (a.k.a.
Definition job.cpp:1369
KIO::copy
CopyJob * copy(const KUrl &src, const KUrl &dest, JobFlags flags=DefaultFlags)
Copy a file or directory src into the destination dest, which can be a file (including the final file...
Definition copyjob.cpp:2164
KIO::special
SimpleJob * special(const KUrl &url, const QByteArray &data, JobFlags flags=DefaultFlags)
Execute any command that is specific to one slave (protocol).
Definition job.cpp:745
KIO::mkdir
SimpleJob * mkdir(const KUrl &url, int permissions=-1)
Creates a single directory.
Definition job.cpp:697
KIO::mimetype
MimetypeJob * mimetype(const KUrl &url, JobFlags flags=DefaultFlags)
Find mimetype for one file or directory.
Definition job.cpp:1856
KIO::UDSEntryList
QList< UDSEntry > UDSEntryList
A directory listing is a list of UDSEntry instances.
Definition udsentry.h:294
KIO::rename
SimpleJob * rename(const KUrl &src, const KUrl &dest, JobFlags flags=DefaultFlags)
Rename a file or directory.
Definition job.cpp:731
KIO::filesize_t
qulonglong filesize_t
64-bit file size
Definition global.h:57
KIO::symlink
SimpleJob * symlink(const QString &target, const KUrl &dest, JobFlags flags=DefaultFlags)
Create or move a symlink.
Definition job.cpp:738
udsentry.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 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.14.38 API Reference

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