File indexing completed on 2024-05-05 05:44:49
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 #ifndef KIOSVN_H 0021 #define KIOSVN_H 0022 0023 #include "kiobytestream.h" 0024 0025 #include <qstring.h> 0026 0027 #include <KIO/WorkerBase> 0028 0029 #include <sys/stat.h> 0030 0031 namespace svn 0032 { 0033 class DirEntry; 0034 class Path; 0035 } 0036 0037 namespace KIO 0038 { 0039 0040 class KioSvnData; 0041 0042 /** 0043 @author Rajko Albrecht 0044 */ 0045 class kio_svnProtocol : public KIO::WorkerBase, public StreamWrittenCb 0046 { 0047 public: 0048 kio_svnProtocol(const QByteArray &pool_socket, const QByteArray &app_socket); 0049 ~kio_svnProtocol() override; 0050 // KIO::WorkerBase 0051 KIO::WorkerResult listDir(const QUrl &url) override; 0052 KIO::WorkerResult stat(const QUrl &url) override; 0053 KIO::WorkerResult get(const QUrl &url) override; 0054 KIO::WorkerResult mkdir(const QUrl &url, int permissions) override; 0055 KIO::WorkerResult put(const QUrl &url, int permissions, KIO::JobFlags flags) override; 0056 KIO::WorkerResult rename(const QUrl &src, const QUrl &target, KIO::JobFlags flags) override; 0057 KIO::WorkerResult del(const QUrl &url, bool isfile) override; 0058 KIO::WorkerResult copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) override; 0059 KIO::WorkerResult special(const QByteArray &data) override; 0060 // StreamWrittenCb 0061 void streamWritten(const KIO::filesize_t current) override; 0062 void streamPushData(const QByteArray &streamData) override; 0063 void streamSendMime(const QMimeType &mt) override; 0064 0065 void contextProgress(long long int current, long long int max); 0066 void listSendDirEntry(const svn::DirEntry &); 0067 bool checkKioCancel() const; 0068 0069 protected: 0070 Q_REQUIRED_RESULT KIO::WorkerResult checkout(const QUrl &src, const QUrl &target, const int rev, const QString &revstring); 0071 Q_REQUIRED_RESULT KIO::WorkerResult update(const QUrl &url, int revnumber, const QString &revkind); 0072 Q_REQUIRED_RESULT KIO::WorkerResult commit(const QList<QUrl> &urls); 0073 Q_REQUIRED_RESULT KIO::WorkerResult svnlog(int revstart, const QString &revstringstart, int revend, const QString &revstringend, const QList<QUrl> &urls); 0074 Q_REQUIRED_RESULT KIO::WorkerResult import(const QUrl &repos, const QUrl &wc); 0075 Q_REQUIRED_RESULT KIO::WorkerResult add(const QUrl &wc); 0076 Q_REQUIRED_RESULT KIO::WorkerResult wc_delete(const QList<QUrl> &urls); 0077 Q_REQUIRED_RESULT KIO::WorkerResult revert(const QList<QUrl> &urls); 0078 Q_REQUIRED_RESULT KIO::WorkerResult status(const QUrl &wc, bool cR, bool rec); 0079 Q_REQUIRED_RESULT KIO::WorkerResult mkdir(const QList<QUrl> &urls, int permissions); 0080 Q_REQUIRED_RESULT KIO::WorkerResult wc_resolve(const QUrl &url, bool recurse); 0081 Q_REQUIRED_RESULT KIO::WorkerResult wc_switch(const QUrl &wc, const QUrl &target, bool rec, int rev, const QString &revstring); 0082 Q_REQUIRED_RESULT KIO::WorkerResult 0083 diff(const QUrl &uri1, const QUrl &uri2, int rnum1, const QString &rstring1, int rnum2, const QString &rstring2, bool rec); 0084 /* looked on kio::svn from kdesdk */ 0085 enum KSVN_METHOD { 0086 /* QUrl repository, QUrl target, int revnumber, QString revkind */ 0087 SVN_CHECKOUT = 1, 0088 /* QUrl wc, int revnumber, QString revkind */ 0089 /* refkind may empty or HEAD or START, will get parsed if revnumber is -1 */ 0090 SVN_UPDATE = 2, 0091 /* QList<QUrl> */ 0092 SVN_COMMIT = 3, 0093 /* int revstart, QString revstartstring, int revend, QString revendstring, QList<QUrl> */ 0094 SVN_LOG = 4, 0095 SVN_IMPORT = 5, 0096 /* QUrl */ 0097 SVN_ADD = 6, 0098 /* QList<QUrl> */ 0099 SVN_DEL = 7, 0100 /* QList<QUrl> */ 0101 SVN_REVERT = 8, 0102 /* QUrl wc,bool checkRepos, bool recurse */ 0103 SVN_STATUS = 9, 0104 /* QList<QUrl> */ 0105 SVN_MKDIR = 10, 0106 /* QUrl, bool */ 0107 SVN_RESOLVE = 11, 0108 /* QUrl working copy, QUrl new_repository_url, bool recurse, int rev, QString revstring */ 0109 SVN_SWITCH = 12, 0110 /* QUrl uri1, QUrl uri2, int r1, QString rstring1, int r2, QString rstring 2, bool recursive */ 0111 SVN_DIFF = 13 0112 }; 0113 0114 void notify(const QString &text); 0115 Q_REQUIRED_RESULT KIO::WorkerResult extraError(int _errid, const QString &text); 0116 0117 private: 0118 KioSvnData *m_pData; 0119 static KIO::UDSEntry createUDSEntry(const QString &filename, const QString &user, long long int size, bool isdir, const QDateTime &mtime); 0120 svn::Path makeSvnPath(const QUrl &url) const; 0121 bool checkWc(const svn::Path &localPath) const; 0122 bool getLogMsg(QString &); 0123 0124 void registerToDaemon(); 0125 void unregisterFromDaemon(); 0126 void startOp(qulonglong max, const QString &title); 0127 void stopOp(const QString &message); 0128 0129 protected: 0130 QString getDefaultLog(); 0131 bool supportOverwrite() const; 0132 bool useKioprogress() const; 0133 }; 0134 0135 } 0136 0137 #endif