File indexing completed on 2024-05-05 05:44:48

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 KIOLISTENER_H
0021 #define KIOLISTENER_H
0022 
0023 #include "ksvnwidgets/pwstorage.h"
0024 #include "svnqt/context_listener.h"
0025 
0026 namespace KIO
0027 {
0028 class kio_svnProtocol;
0029 
0030 /**
0031 @author Rajko Albrecht
0032 */
0033 class KioListener : public svn::ContextListener
0034 {
0035 public:
0036     explicit KioListener(KIO::kio_svnProtocol *_par);
0037     ~KioListener() override;
0038 
0039     /* context-listener methods */
0040     bool contextGetLogin(const QString &realm, QString &username, QString &password, bool &maySave) override;
0041     bool contextGetSavedLogin(const QString &realm, QString &username, QString &password) override;
0042     bool contextGetCachedLogin(const QString &realm, QString &username, QString &password) override;
0043 
0044     void contextNotify(const char *path,
0045                        svn_wc_notify_action_t action,
0046                        svn_node_kind_t kind,
0047                        const char *mime_type,
0048                        svn_wc_notify_state_t content_state,
0049                        svn_wc_notify_state_t prop_state,
0050                        svn_revnum_t revision) override;
0051     void contextNotify(const svn_wc_notify_t *action) override;
0052 
0053     bool contextCancel() override;
0054     bool contextGetLogMessage(QString &msg, const svn::CommitItemList &) override;
0055     SslServerTrustAnswer contextSslServerTrustPrompt(const SslServerTrustData &data, apr_uint32_t &acceptedFailures) override;
0056     bool contextSslClientCertPrompt(QString &certFile) override;
0057     bool contextSslClientCertPwPrompt(QString &password, const QString &realm, bool &maySave) override;
0058     bool contextLoadSslClientCertPw(QString &password, const QString &realm) override;
0059     /* context listener virtuals end */
0060     unsigned int counter() const
0061     {
0062         return m_notifyCounter;
0063     }
0064     void incCounter()
0065     {
0066         ++m_notifyCounter;
0067     }
0068     void contextProgress(long long int current, long long int max) override;
0069 
0070     void setCancel(bool value)
0071     {
0072         m_Canceld = value;
0073     }
0074 
0075     /** Callback for generating list entries
0076      * This implementation sends items to the protocol, @a entries will ignored.
0077      * @param entries default target list - ignored
0078      * @param dirent entry to add (send by subversion)
0079      * @param lock accociated lock (may be null!)
0080      * @param path the path of the item
0081      * @return true if inserted/displayd, false if dirent or entries aren't valid.
0082      */
0083     bool contextAddListItem(svn::DirEntries *entries, const svn_dirent_t *dirent, const svn_lock_t *lock, const QString &path) override;
0084 
0085     void uncancel()
0086     {
0087         m_Canceld = false;
0088     }
0089 
0090 private:
0091     KIO::kio_svnProtocol *par;
0092 
0093 protected:
0094     unsigned int m_notifyCounter;
0095     bool m_External;
0096     bool m_HasChanges;
0097     bool m_FirstTxDelta;
0098     bool m_Canceld;
0099 };
0100 }
0101 
0102 #endif