File indexing completed on 2024-05-12 13:48:04

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 CCONTEXTLISTENER_H
0021 #define CCONTEXTLISTENER_H
0022 
0023 #include "svnqt/context_listener.h"
0024 
0025 #include <QObject>
0026 #include <QString>
0027 
0028 class CContextListenerData;
0029 
0030 /**
0031 @author Rajko Albrecht
0032 */
0033 class CContextListener : public QObject, public svn::ContextListener
0034 {
0035     Q_OBJECT
0036 public:
0037     explicit CContextListener(QObject *parent = nullptr);
0038     ~CContextListener() override;
0039 
0040     /* context-listener methods */
0041     bool contextGetLogin(const QString &realm, QString &username, QString &password, bool &maySave) override;
0042     bool contextGetSavedLogin(const QString &realm, QString &username, QString &password) override;
0043     bool contextGetCachedLogin(const QString &realm, QString &username, QString &password) override;
0044 
0045     void contextNotify(const char *path,
0046                        svn_wc_notify_action_t action,
0047                        svn_node_kind_t kind,
0048                        const char *mime_type,
0049                        svn_wc_notify_state_t content_state,
0050                        svn_wc_notify_state_t prop_state,
0051                        svn_revnum_t revision) override;
0052     void contextNotify(const svn_wc_notify_t *action) override;
0053     virtual void contextNotify(const QString &);
0054 
0055     virtual void sendTick();
0056 
0057     bool contextCancel() override;
0058     /*!
0059      * Get logmessage for checkin and so on...
0060      */
0061     bool contextGetLogMessage(QString &msg, const svn::CommitItemList &) override;
0062     SslServerTrustAnswer contextSslServerTrustPrompt(const SslServerTrustData &data, apr_uint32_t &acceptedFailures) override;
0063     bool contextSslClientCertPrompt(QString &certFile) override;
0064     bool contextSslClientCertPwPrompt(QString &password, const QString &realm, bool &maySave) override;
0065     bool contextLoadSslClientCertPw(QString &password, const QString &realm) override;
0066     QString translate(const QString &what) override;
0067 
0068     static QString NotifyAction(svn_wc_notify_action_t action);
0069     static QString NotifyState(svn_wc_notify_state_t);
0070 
0071     static QStringList failure2Strings(apr_uint32_t acceptedFailures);
0072     void contextProgress(long long int current, long long int max) override;
0073 
0074     void maySavePlaintext(svn_boolean_t *may_save_plaintext, const QString &realmstring) override;
0075 
0076     // used by SvnActions
0077     //! get list of updated items when svn update is called
0078     const QStringList &updatedItems() const;
0079     //! cleans list of updatedItems, should called before calling svn::Client::update
0080     void cleanUpdatedItems();
0081 
0082 public Q_SLOTS:
0083     virtual void setCanceled(bool);
0084 
0085 Q_SIGNALS:
0086     void sendNotify(const QString &);
0087     void tickProgress();
0088     void waitShow(bool);
0089     void netProgress(long long int, long long int);
0090 
0091 protected:
0092     static const int smax_actionstring;
0093     static const char *action_strings[];
0094     static const char *notify_state_strings[];
0095     CContextListenerData *m_Data;
0096 
0097 private:
0098     void extraNotify(const QString &path, svn_wc_notify_action_t action, svn_revnum_t revision);
0099 };
0100 
0101 #endif