00001 00002 // 00003 // Project: SMB kioslave for KDE2 00004 // 00005 // File: kio_smb.h 00006 // 00007 // Abstract: The main kio slave class declaration. For convenience, 00008 // in concurrent devlopment, the implementation for this class 00009 // is separated into several .cpp files -- the file containing 00010 // the implementation should be noted in the comments for each 00011 // member function. 00012 // 00013 // Author(s): Matthew Peterson <mpeterson@caldera.com> 00014 // 00015 //--------------------------------------------------------------------------- 00016 // 00017 // Copyright (c) 2000 Caldera Systems, Inc. 00018 // 00019 // This program is free software; you can redistribute it and/or modify it 00020 // under the terms of the GNU General Public License as published by the 00021 // Free Software Foundation; either version 2.1 of the License, or 00022 // (at your option) any later version. 00023 // 00024 // This program is distributed in the hope that it will be useful, 00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00027 // GNU Lesser General Public License for more details. 00028 // 00029 // You should have received a copy of the GNU General Public License 00030 // along with this program; see the file COPYING. If not, please obtain 00031 // a copy from http://www.gnu.org/copyleft/gpl.html 00032 // 00034 00035 00036 #ifndef KIO_SMB_H_INCLUDED 00037 #define KIO_SMB_H_INCLUDED 00038 00039 //------------- 00040 // QT includes 00041 //------------- 00042 #include <tqstring.h> 00043 #include <tqptrlist.h> 00044 #include <tqstringlist.h> 00045 #include <tqtextstream.h> 00046 #include <tqstrlist.h> 00047 00048 //-------------- 00049 // KDE includes 00050 //-------------- 00051 #include <kdebug.h> 00052 #include <kinstance.h> 00053 #include <kio/global.h> 00054 #include <kio/slavebase.h> 00055 #include <kurl.h> 00056 #include <klocale.h> 00057 00058 //----------------------------- 00059 // Standard C library includes 00060 //----------------------------- 00061 #include <stdlib.h> 00062 #include <sys/stat.h> 00063 #include <sys/ioctl.h> 00064 #include <sys/socket.h> 00065 #include <netinet/in.h> 00066 #include <net/if.h> 00067 #include <arpa/inet.h> 00068 #include <stdio.h> 00069 #include <errno.h> 00070 #include <time.h> 00071 #include <tqobject.h> 00072 00073 //------------------------------- 00074 // Samba client library includes 00075 //------------------------------- 00076 extern "C" 00077 { 00078 #include <libsmbclient.h> 00079 } 00080 00081 //--------------------------- 00082 // kio_smb internal includes 00083 //--------------------------- 00084 #include "kio_smb_internal.h" 00085 00086 #define MAX_XFER_BUF_SIZE 16348 00087 #define KIO_SMB 7106 00088 00089 using namespace KIO; 00090 class KProcess; 00091 00092 //=========================================================================== 00093 00094 00095 class SMBSlave : public TQObject, public KIO::SlaveBase 00096 { 00097 Q_OBJECT 00098 00099 private: 00100 //--------------------------------------------------------------------- 00101 // please make sure your private data does not duplicate existing data 00102 //--------------------------------------------------------------------- 00103 bool m_initialized_smbc; 00104 00108 TQString m_default_user; 00109 // TQString m_default_workgroup; //currently unused, Alex <neundorf@kde.org> 00110 TQString m_default_password; 00111 TQString m_default_encoding; 00112 00117 SMBUrl m_current_url; 00118 00122 // bool m_showHiddenShares; //currently unused, Alex <neundorf@kde.org> 00123 00129 struct stat st; 00130 protected: 00131 //--------------------------------------------- 00132 // Authentication functions (kio_smb_auth.cpp) 00133 //--------------------------------------------- 00134 // (please prefix functions with auth) 00135 00136 00141 bool auth_initialize_smbc(); 00142 00143 bool checkPassword(SMBUrl &url); 00144 00145 00146 //--------------------------------------------- 00147 // Cache functions (kio_smb_auth.cpp) 00148 //--------------------------------------------- 00149 00150 //Stat methods 00151 00152 //----------------------------------------- 00153 // Browsing functions (kio_smb_browse.cpp) 00154 //----------------------------------------- 00155 // (please prefix functions with browse) 00156 00164 bool browse_stat_path(const SMBUrl& url, UDSEntry& udsentry, bool ignore_errors); 00165 00175 int cache_stat( const SMBUrl& url, struct stat* st ); 00176 00177 //--------------------------------------------- 00178 // Configuration functions (kio_smb_config.cpp) 00179 //--------------------------------------------- 00180 // (please prefix functions with config) 00181 00182 00183 //--------------------------------------- 00184 // Directory functions (kio_smb_dir.cpp) 00185 //--------------------------------------- 00186 // (please prefix functions with dir) 00187 00188 00189 //-------------------------------------- 00190 // File IO functions (kio_smb_file.cpp) 00191 //-------------------------------------- 00192 // (please prefix functions with file) 00193 00194 //---------------------------- 00195 // Misc functions (this file) 00196 //---------------------------- 00197 00198 00215 KURL checkURL(const KURL& kurl) const; 00216 00217 void reportError(const SMBUrl &kurl); 00218 00219 public: 00220 00221 //----------------------------------------------------------------------- 00222 // smbclient authentication callback (note that this is called by the 00223 // global ::auth_smbc_get_data() call. 00224 void auth_smbc_get_data(const char *server,const char *share, 00225 char *workgroup, int wgmaxlen, 00226 char *username, int unmaxlen, 00227 char *password, int pwmaxlen); 00228 00229 00230 //----------------------------------------------------------------------- 00231 // Overwritten functions from the base class that define the operation of 00232 // this slave. (See the base class headerfile slavebase.h for more 00233 // details) 00234 //----------------------------------------------------------------------- 00235 00236 // Functions overwritten in kio_smb.cpp 00237 SMBSlave(const TQCString& pool, const TQCString& app); 00238 virtual ~SMBSlave(); 00239 00240 // Functions overwritten in kio_smb_browse.cpp 00241 virtual void listDir( const KURL& url ); 00242 virtual void stat( const KURL& url ); 00243 00244 // Functions overwritten in kio_smb_config.cpp 00245 virtual void reparseConfiguration(); 00246 00247 // Functions overwritten in kio_smb_dir.cpp 00248 virtual void copy( const KURL& src, const KURL &dest, int permissions, bool overwrite ); 00249 virtual void del( const KURL& kurl, bool isfile); 00250 virtual void mkdir( const KURL& kurl, int permissions ); 00251 virtual void rename( const KURL& src, const KURL& dest, bool overwrite ); 00252 00253 // Functions overwritten in kio_smb_file.cpp 00254 virtual void get( const KURL& kurl ); 00255 virtual void put( const KURL& kurl, int permissions, bool overwrite, bool resume ); 00256 00257 // Functions not implemented (yet) 00258 //virtual void setHost(const TQString& host, int port, const TQString& user, const TQString& pass); 00259 //virtual void openConnection(); 00260 //virtual void closeConnection(); 00261 //virtual void slave_status(); 00262 virtual void special( const TQByteArray & ); 00263 00264 private slots: 00265 void readOutput(KProcess *proc, char *buffer, int buflen); 00266 void readStdErr(KProcess *proc, char *buffer, int buflen); 00267 00268 private: 00269 TQString mybuf, mystderr; 00270 00271 }; 00272 00273 //=========================================================================== 00274 // pointer to the slave created in kdemain 00275 extern SMBSlave* G_TheSlave; 00276 00277 00278 //========================================================================== 00279 // the global libsmbclient authentication callback function 00280 extern "C" 00281 { 00282 00283 void auth_smbc_get_data(const char *server,const char *share, 00284 char *workgroup, int wgmaxlen, 00285 char *username, int unmaxlen, 00286 char *password, int pwmaxlen); 00287 00288 } 00289 00290 00291 //=========================================================================== 00292 // Main slave entrypoint (see kio_smb.cpp) 00293 extern "C" 00294 { 00295 00296 int kdemain( int argc, char **argv ); 00297 00298 } 00299 00300 00301 #endif //#endif KIO_SMB_H_INCLUDED
1.6.1