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

KIOSlave

  • kioslave
  • ftp
ftp.h
Go to the documentation of this file.
1// -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*-
2/* This file is part of the KDE libraries
3 Copyright (C) 2000 David Faure <faure@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KDELIBS_FTP_H
22#define KDELIBS_FTP_H
23
24#include <config.h>
25
26#include <sys/types.h>
27#include <sys/socket.h>
28
29#include <kurl.h>
30#include <kio/slavebase.h>
31
32class QTcpServer;
33class QTcpSocket;
34class QNetworkProxy;
35class QAuthenticator;
36
37struct FtpEntry
38{
39 QString name;
40 QString owner;
41 QString group;
42 QString link;
43
44 KIO::filesize_t size;
45 mode_t type;
46 mode_t access;
47 time_t date;
48};
49
50//===============================================================================
51// Ftp
52//===============================================================================
53class Ftp : public QObject, public KIO::SlaveBase
54{
55 Q_OBJECT
56
57public:
58 Ftp( const QByteArray &pool, const QByteArray &app );
59 virtual ~Ftp();
60
61 virtual void setHost( const QString& host, quint16 port, const QString& user, const QString& pass );
62
69 virtual void openConnection();
70
74 virtual void closeConnection();
75
76 virtual void stat( const KUrl &url );
77
78 virtual void listDir( const KUrl & url );
79 virtual void mkdir( const KUrl & url, int permissions );
80 virtual void rename( const KUrl & src, const KUrl & dst, KIO::JobFlags flags );
81 virtual void del( const KUrl & url, bool isfile );
82 virtual void chmod( const KUrl & url, int permissions );
83
84 virtual void get( const KUrl& url );
85 virtual void put( const KUrl& url, int permissions, KIO::JobFlags flags );
86 //virtual void mimetype( const KUrl& url );
87
88 virtual void slave_status();
89
93 virtual void copy( const KUrl &src, const KUrl &dest, int permissions, KIO::JobFlags flags );
94
95private:
96 // ------------------------------------------------------------------------
97 // All the methods named ftpXyz are lowlevel methods that are not exported.
98 // The implement functionality used by the public high-level methods. Some
99 // low-level methods still use error() to emit errors. This behaviour is not
100 // recommended - please return a boolean status or an error code instead!
101 // ------------------------------------------------------------------------
102
107 typedef enum {
108 statusSuccess,
109 statusClientError,
110 statusServerError
111 } StatusCode;
112
116 typedef enum {
117 loginDefered,
118 loginExplicit,
119 loginImplicit
120 } LoginMode;
121
132 bool ftpOpenConnection (LoginMode loginMode);
133
137 void ftpAutoLoginMacro ();
138
148 bool ftpLogin(bool* userChanged = 0);
149
159 bool ftpSendCmd( const QByteArray& cmd, int maxretries = 1 );
160
167 bool ftpSize( const QString & path, char mode );
168
174 const char* ftpSendSizeCmd(const QString& path);
175
180 bool ftpFileExists(const QString& path);
181
185 bool ftpFolder(const QString& path, bool bReportError);
186
198 bool ftpOpenCommand( const char *command, const QString & path, char mode,
199 int errorcode, KIO::fileoffset_t offset = 0 );
200
207 bool ftpCloseCommand();
208
215 bool ftpDataMode(char cMode);
216
217 //void ftpAbortTransfer();
218
222 int ftpOpenDataConnection();
223
227 void ftpCloseDataConnection();
228
232 int ftpOpenPASVDataConnection();
236 int ftpOpenEPSVDataConnection();
240 int ftpOpenPortDataConnection();
241
242 bool ftpChmod( const QString & path, int permissions );
243
244 // used by listDir
245 bool ftpOpenDir( const QString & path );
249 bool ftpReadDir(FtpEntry& ftpEnt);
250
254 void ftpCreateUDSEntry( const QString & filename, const FtpEntry& ftpEnt, KIO::UDSEntry& entry, bool isDir );
255
256 void ftpShortStatAnswer( const QString& filename, bool isDir );
257
258 void ftpStatAnswerNotFound( const QString & path, const QString & filename );
259
265 bool ftpRename( const QString & src, const QString & dst, KIO::JobFlags flags );
266
272 bool ftpOpenControlConnection();
273 bool ftpOpenControlConnection( const QString & host, int port );
274
278 void ftpCloseControlConnection();
279
288 const char* ftpResponse(int iOffset);
289
301 StatusCode ftpGet(int& iError, int iCopyFile, const KUrl& url, KIO::fileoffset_t hCopyOffset);
302
313 StatusCode ftpPut(int& iError, int iCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
314
323 StatusCode ftpCopyPut(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
324
333 StatusCode ftpCopyGet(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
334
341 StatusCode ftpSendMimeType(int& iError, const KUrl& url);
342
347 void fixupEntryName(FtpEntry* ftpEnt);
348
352 bool maybeEmitStatEntry(FtpEntry& ftpEnt, const QString& search, const QString& filename, bool isDir);
353
354private Q_SLOTS:
355 void proxyAuthentication(const QNetworkProxy&, QAuthenticator*);
356 void saveProxyAuthentication();
357
358private: // data members
359
360 QString m_host;
361 int m_port;
362 QString m_user;
363 QString m_pass;
367 QString m_initialPath;
368 KUrl m_proxyURL;
369 QStringList m_proxyUrls;
370
374 QString m_currentPath;
375
379 int m_iRespCode;
380
384 int m_iRespType;
385
390 char m_cDataMode;
391
395 bool m_bLoggedOn;
396
401 bool m_bTextMode;
402
413 bool m_bBusy;
414
415 bool m_bPasv;
416
417 KIO::filesize_t m_size;
418 static KIO::filesize_t UnknownSize;
419
420 enum
421 {
422 epsvUnknown = 0x01,
423 epsvAllUnknown = 0x02,
424 eprtUnknown = 0x04,
425 epsvAllSent = 0x10,
426 pasvUnknown = 0x20,
427 chmodUnknown = 0x100
428 };
429 int m_extControl;
430
434 QTcpSocket *m_control;
435 QByteArray m_lastControlLine;
436
440 QTcpSocket *m_data;
441
445 QTcpServer *m_server;
446
450 QAuthenticator* m_socketProxyAuth;
451};
452
453#endif // KDELIBS_FTP_H
454
Ftp
Definition: ftp.h:54
Ftp::rename
virtual void rename(const KUrl &src, const KUrl &dst, KIO::JobFlags flags)
Definition: ftp.cpp:1191
Ftp::del
virtual void del(const KUrl &url, bool isfile)
Definition: ftp.cpp:1242
Ftp::~Ftp
virtual ~Ftp()
Definition: ftp.cpp:210
Ftp::chmod
virtual void chmod(const KUrl &url, int permissions)
Definition: ftp.cpp:1285
Ftp::put
virtual void put(const KUrl &url, int permissions, KIO::JobFlags flags)
Definition: ftp.cpp:2055
Ftp::setHost
virtual void setHost(const QString &host, quint16 port, const QString &user, const QString &pass)
Definition: ftp.cpp:321
Ftp::mkdir
virtual void mkdir(const KUrl &url, int permissions)
Definition: ftp.cpp:1156
Ftp::listDir
virtual void listDir(const KUrl &url)
Definition: ftp.cpp:1524
Ftp::closeConnection
virtual void closeConnection()
Closes the connection.
Definition: ftp.cpp:299
Ftp::copy
virtual void copy(const KUrl &src, const KUrl &dest, int permissions, KIO::JobFlags flags)
Handles the case that one side of the job is a local file.
Definition: ftp.cpp:2370
Ftp::openConnection
virtual void openConnection()
Connects to a ftp server and logs us in m_bLoggedOn is set to true if logging on was successful.
Definition: ftp.cpp:340
Ftp::get
virtual void get(const KUrl &url)
Definition: ftp.cpp:1847
Ftp::stat
virtual void stat(const KUrl &url)
Definition: ftp.cpp:1373
Ftp::slave_status
virtual void slave_status()
Definition: ftp.cpp:1599
KIO::SlaveBase
KIO::UDSEntry
KUrl
QObject
QTcpSocket
kurl.h
KIO::fileoffset_t
qlonglong fileoffset_t
KIO::filesize_t
qulonglong filesize_t
slavebase.h
FtpEntry
Definition: ftp.h:38
FtpEntry::owner
QString owner
Definition: ftp.h:40
FtpEntry::group
QString group
Definition: ftp.h:41
FtpEntry::name
QString name
Definition: ftp.h:39
FtpEntry::date
time_t date
Definition: ftp.h:47
FtpEntry::access
mode_t access
Definition: ftp.h:46
FtpEntry::link
QString link
Definition: ftp.h:42
FtpEntry::type
mode_t type
Definition: ftp.h:45
FtpEntry::size
KIO::filesize_t size
Definition: ftp.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIOSlave

Skip menu "KIOSlave"
  • Main Page
  • 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