File indexing completed on 2024-05-05 04:41:02

0001 /*
0002     SPDX-FileCopyrightText: 2007 Dukju Ahn <dukjuahn@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_PLUGIN_SVNJOBBASE_H
0008 #define KDEVPLATFORM_PLUGIN_SVNJOBBASE_H
0009 
0010 #include <vcs/vcsjob.h>
0011 
0012 #include "kdevsvncpp/context_listener.hpp"
0013 #include "kdevsvnplugin.h"
0014 #include "debug.h"
0015 
0016 #include <ThreadWeaver/Queueing>
0017 #include <QSharedPointer>
0018 
0019 extern "C"
0020 {
0021 #include <svn_wc.h>
0022 }
0023 
0024 class SvnInternalJobBase;
0025 using SvnInternalJobBasePtr = QSharedPointer<SvnInternalJobBase>;
0026 
0027 namespace ThreadWeaver
0028 {
0029     class Job;
0030 }
0031 
0032 class KDevSvnPlugin;
0033 
0034 class SvnJobBase : public KDevelop::VcsJob
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit SvnJobBase( KDevSvnPlugin*, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose );
0039     ~SvnJobBase() override;
0040     virtual SvnInternalJobBasePtr internalJob() const = 0;
0041     KDevelop::VcsJob::JobStatus status() const override;
0042     KDevelop::IPlugin* vcsPlugin() const override;
0043 
0044 public Q_SLOTS:
0045     void askForLogin( const QString& );
0046     void showNotification( const QString&, const QString& );
0047     void askForCommitMessage();
0048     void askForSslServerTrust( const QStringList&, const QString&, const QString&,
0049                                const QString&, const QString&, const QString&,
0050                                const QString& );
0051     void askForSslClientCert( const QString& );
0052     void askForSslClientCertPassword( const QString& );
0053 
0054 protected Q_SLOTS:
0055     void internalJobStarted();
0056     void internalJobDone();
0057     void internalJobFailed();
0058 
0059 protected:
0060     void startInternalJob();
0061     bool doKill() override;
0062     KDevSvnPlugin* m_part;
0063 private:
0064     void outputMessage(const QString &message);
0065     KDevelop::VcsJob::JobStatus m_status;
0066 };
0067 
0068 template<typename InternalJobClass>
0069 class SvnJobBaseImpl : public SvnJobBase
0070 {
0071 public:
0072     explicit SvnJobBaseImpl(KDevSvnPlugin* plugin,
0073                    KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose)
0074         : SvnJobBase(plugin, verbosity)
0075         , m_job(new InternalJobClass(this))
0076     {
0077     }
0078 
0079     SvnInternalJobBasePtr internalJob() const override
0080     {
0081         return m_job;
0082     }
0083 
0084 protected:
0085     QSharedPointer<InternalJobClass> m_job;
0086 };
0087 
0088 #endif