• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.2 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 
32 class QTcpServer;
33 class QTcpSocket;
34 class QNetworkProxy;
35 class QAuthenticator;
36 
37 struct 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 //===============================================================================
53 class Ftp : public QObject, public KIO::SlaveBase
54 {
55  Q_OBJECT
56 
57 public:
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 
95 private:
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 
173  bool ftpFileExists(const QString& path);
174 
178  bool ftpFolder(const QString& path, bool bReportError);
179 
191  bool ftpOpenCommand( const char *command, const QString & path, char mode,
192  int errorcode, KIO::fileoffset_t offset = 0 );
193 
200  bool ftpCloseCommand();
201 
208  bool ftpDataMode(char cMode);
209 
210  //void ftpAbortTransfer();
211 
215  int ftpOpenDataConnection();
216 
220  void ftpCloseDataConnection();
221 
225  int ftpOpenPASVDataConnection();
229  int ftpOpenEPSVDataConnection();
233  int ftpOpenPortDataConnection();
234 
235  bool ftpChmod( const QString & path, int permissions );
236 
237  // used by listDir
238  bool ftpOpenDir( const QString & path );
242  bool ftpReadDir(FtpEntry& ftpEnt);
243 
247  void ftpCreateUDSEntry( const QString & filename, const FtpEntry& ftpEnt, KIO::UDSEntry& entry, bool isDir );
248 
249  void ftpShortStatAnswer( const QString& filename, bool isDir );
250 
251  void ftpStatAnswerNotFound( const QString & path, const QString & filename );
252 
258  bool ftpRename( const QString & src, const QString & dst, KIO::JobFlags flags );
259 
265  bool ftpOpenControlConnection();
266  bool ftpOpenControlConnection( const QString & host, int port );
267 
271  void ftpCloseControlConnection();
272 
281  const char* ftpResponse(int iOffset);
282 
294  StatusCode ftpGet(int& iError, int iCopyFile, const KUrl& url, KIO::fileoffset_t hCopyOffset);
295 
306  StatusCode ftpPut(int& iError, int iCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
307 
316  StatusCode ftpCopyPut(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
317 
326  StatusCode ftpCopyGet(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
327 
334  StatusCode ftpSendMimeType(int& iError, const KUrl& url);
335 
340  void fixupEntryName(FtpEntry* ftpEnt);
341 
345  bool maybeEmitStatEntry(FtpEntry& ftpEnt, const QString& search, const QString& filename, bool isDir);
346 
347 private Q_SLOTS:
348  void proxyAuthentication(const QNetworkProxy&, QAuthenticator*);
349  void saveProxyAuthentication();
350 
351 private: // data members
352 
353  QString m_host;
354  int m_port;
355  QString m_user;
356  QString m_pass;
360  QString m_initialPath;
361  KUrl m_proxyURL;
362  QStringList m_proxyUrls;
363 
367  QString m_currentPath;
368 
372  int m_iRespCode;
373 
377  int m_iRespType;
378 
383  char m_cDataMode;
384 
388  bool m_bLoggedOn;
389 
394  bool m_bTextMode;
395 
406  bool m_bBusy;
407 
408  bool m_bPasv;
409 
410  KIO::filesize_t m_size;
411  static KIO::filesize_t UnknownSize;
412 
413  enum
414  {
415  epsvUnknown = 0x01,
416  epsvAllUnknown = 0x02,
417  eprtUnknown = 0x04,
418  epsvAllSent = 0x10,
419  pasvUnknown = 0x20,
420  chmodUnknown = 0x100
421  };
422  int m_extControl;
423 
427  QTcpSocket *m_control;
428  QByteArray m_lastControlLine;
429 
433  QTcpSocket *m_data;
434 
438  QTcpServer *m_server;
439 
443  QAuthenticator* m_socketProxyAuth;
444 };
445 
446 #endif // KDELIBS_FTP_H
447 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Apr 20 2013 06:04:46 by doxygen 1.8.3.1 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.10.2 API Reference

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