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

KIOSlave

ftp.h
Go to the documentation of this file.
00001 // -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*-
00002 /*  This file is part of the KDE libraries
00003     Copyright (C) 2000 David Faure <faure@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KDELIBS_FTP_H
00022 #define KDELIBS_FTP_H
00023 
00024 #include <config.h>
00025 
00026 #include <sys/types.h>
00027 #include <sys/socket.h>
00028 
00029 #include <kurl.h>
00030 #include <kio/slavebase.h>
00031 
00032 class QTcpServer;
00033 class QTcpSocket;
00034 class QNetworkProxy;
00035 class QAuthenticator;
00036 
00037 struct FtpEntry
00038 {
00039   QString name;
00040   QString owner;
00041   QString group;
00042   QString link;
00043 
00044   KIO::filesize_t size;
00045   mode_t type;
00046   mode_t access;
00047   time_t date;
00048 };
00049 
00050 //===============================================================================
00051 // Ftp
00052 //===============================================================================
00053 class Ftp : public QObject, public KIO::SlaveBase
00054 {
00055   Q_OBJECT
00056 
00057 public:
00058   Ftp( const QByteArray &pool, const QByteArray &app );
00059   virtual ~Ftp();
00060 
00061   virtual void setHost( const QString& host, quint16 port, const QString& user, const QString& pass );
00062 
00069   virtual void openConnection();
00070 
00074   virtual void closeConnection();
00075 
00076   virtual void stat( const KUrl &url );
00077 
00078   virtual void listDir( const KUrl & url );
00079   virtual void mkdir( const KUrl & url, int permissions );
00080   virtual void rename( const KUrl & src, const KUrl & dst, KIO::JobFlags flags );
00081   virtual void del( const KUrl & url, bool isfile );
00082   virtual void chmod( const KUrl & url, int permissions );
00083 
00084   virtual void get( const KUrl& url );
00085   virtual void put( const KUrl& url, int permissions, KIO::JobFlags flags );
00086   //virtual void mimetype( const KUrl& url );
00087 
00088   virtual void slave_status();
00089 
00093   virtual void copy( const KUrl &src, const KUrl &dest, int permissions, KIO::JobFlags flags );
00094 
00095 private:
00096   // ------------------------------------------------------------------------
00097   // All the methods named ftpXyz are lowlevel methods that are not exported.
00098   // The implement functionality used by the public high-level methods. Some
00099   // low-level methods still use error() to emit errors. This behaviour is not
00100   // recommended - please return a boolean status or an error code instead!
00101   // ------------------------------------------------------------------------
00102 
00107   typedef enum {
00108     statusSuccess,
00109     statusClientError,
00110     statusServerError
00111   } StatusCode;
00112 
00116   typedef enum {
00117     loginDefered,
00118     loginExplicit,
00119     loginImplicit
00120   } LoginMode;
00121 
00132   bool ftpOpenConnection (LoginMode loginMode);
00133 
00137   void ftpAutoLoginMacro ();
00138 
00148   bool ftpLogin(bool* userChanged = 0);
00149 
00159   bool ftpSendCmd( const QByteArray& cmd, int maxretries = 1 );
00160 
00167   bool ftpSize( const QString & path, char mode );
00168 
00173   bool ftpFileExists(const QString& path);
00174 
00178   bool ftpFolder(const QString& path, bool bReportError);
00179 
00191   bool ftpOpenCommand( const char *command, const QString & path, char mode,
00192                        int errorcode, KIO::fileoffset_t offset = 0 );
00193 
00200   bool ftpCloseCommand();
00201 
00208   bool ftpDataMode(char cMode);
00209 
00210   //void ftpAbortTransfer();
00211 
00215   int ftpOpenDataConnection();
00216 
00220   void ftpCloseDataConnection();
00221 
00225   int ftpOpenPASVDataConnection();
00229   int ftpOpenEPSVDataConnection();
00233   int ftpOpenPortDataConnection();
00234 
00235   bool ftpChmod( const QString & path, int permissions );
00236 
00237   // used by listDir
00238   bool ftpOpenDir( const QString & path );
00242   bool ftpReadDir(FtpEntry& ftpEnt);
00243 
00247   void ftpCreateUDSEntry( const QString & filename, FtpEntry& ftpEnt, KIO::UDSEntry& entry, bool isDir );
00248 
00249   void ftpShortStatAnswer( const QString& filename, bool isDir );
00250 
00251   void ftpStatAnswerNotFound( const QString & path, const QString & filename );
00252 
00258   bool ftpRename( const QString & src, const QString & dst, KIO::JobFlags flags );
00259 
00265   bool ftpOpenControlConnection();
00266   bool ftpOpenControlConnection( const QString & host, int port );
00267 
00271   void ftpCloseControlConnection();
00272 
00281   const char* ftpResponse(int iOffset);
00282 
00294   StatusCode ftpGet(int& iError, int iCopyFile, const KUrl& url, KIO::fileoffset_t hCopyOffset);
00295 
00306   StatusCode ftpPut(int& iError, int iCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00307 
00316   StatusCode ftpCopyPut(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00317 
00326   StatusCode ftpCopyGet(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00327 
00334   StatusCode ftpSendMimeType(int& iError, const KUrl& url);
00335 
00336 private Q_SLOTS:
00337   void proxyAuthentication(const QNetworkProxy&, QAuthenticator*);
00338   void saveProxyAuthentication();
00339 
00340 private: // data members
00341 
00342   QString m_host;
00343   int m_port;
00344   QString m_user;
00345   QString m_pass;
00349   QString m_initialPath;
00350   KUrl m_proxyURL;
00351   QStringList m_proxyUrls;
00352 
00356   QString m_currentPath;
00357 
00361   int  m_iRespCode;
00362 
00366   int  m_iRespType;
00367 
00372   char m_cDataMode;
00373 
00377   bool m_bLoggedOn;
00378 
00383   bool m_bTextMode;
00384 
00395   bool m_bBusy;
00396 
00397   bool m_bPasv;
00398 
00399   KIO::filesize_t m_size;
00400   static KIO::filesize_t UnknownSize;
00401 
00402   enum
00403   {
00404     epsvUnknown = 0x01,
00405     epsvAllUnknown = 0x02,
00406     eprtUnknown = 0x04,
00407     epsvAllSent = 0x10,
00408     pasvUnknown = 0x20,
00409     chmodUnknown = 0x100
00410   };
00411   int m_extControl;
00412 
00416   QTcpSocket  *m_control;
00417   QByteArray m_lastControlLine;
00418 
00422   QTcpSocket  *m_data;
00423 
00427   QTcpServer *m_server;
00428 
00432   QAuthenticator* m_socketProxyAuth;
00433 };
00434 
00435 #endif // KDELIBS_FTP_H
00436 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed May 2 2012 18:44:23 by doxygen 1.8.0 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.8.3 API Reference

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