File indexing completed on 2024-05-12 05:44:24

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 TCONTEXTLISTENER_H
0021 #define TCONTEXTLISTENER_H
0022 
0023 #include "svnfrontend/ccontextlistener.h"
0024 
0025 struct ThreadContextListenerData;
0026 
0027 /**
0028   @author Rajko Albrecht
0029   Same as CContextListener but make sure the user actions are executed in the main thread
0030   Therefore all events have to be passed through the Qt signal/slot system to make sure
0031   a context switch to the main thread occurs.
0032   This is done by a signal 'signalFoo()' which is executed and caught inside this class.
0033   The slot is then passed to CContextListener::foo()
0034 
0035   This Listener *must* be instanciated in the main thread!
0036 */
0037 class ThreadContextListener : public CContextListener
0038 {
0039     Q_OBJECT
0040 public:
0041     explicit ThreadContextListener(QObject *parent);
0042 
0043     ~ThreadContextListener() override;
0044 
0045     // called from a thread != main thread
0046     bool contextGetLogin(const QString &realm, QString &username, QString &password, bool &maySave) override;
0047     bool contextGetSavedLogin(const QString &realm, QString &username, QString &password) override;
0048     bool contextGetLogMessage(QString &msg, const svn::CommitItemList &) override;
0049     bool contextSslClientCertPrompt(QString &certFile) override;
0050     bool contextSslClientCertPwPrompt(QString &password, const QString &realm, bool &maySave) override;
0051     svn::ContextListener::SslServerTrustAnswer contextSslServerTrustPrompt(const SslServerTrustData &data, apr_uint32_t &acceptedFailures) override;
0052     void sendTick() override;
0053     void contextProgress(long long int current, long long int max) override;
0054 
0055     using CContextListener::contextNotify;
0056     void contextNotify(const QString &) override;
0057 
0058 Q_SIGNALS:
0059     void signal_contextGetLogin();
0060     void signal_contextGetSavedLogin();
0061     void signal_contextGetLogMessage();
0062     void signal_contextSslClientCertPrompt();
0063     void signal_contextSslClientCertPwPrompt();
0064     void signal_contextSslServerTrustPrompt();
0065     void signal_contextNotify(const QString &msg);
0066 protected Q_SLOTS: // executed in main thread
0067     virtual void event_contextGetLogin();
0068     virtual void event_contextGetSavedLogin();
0069     virtual void event_contextGetLogMessage();
0070     virtual void event_contextSslClientCertPrompt();
0071     virtual void event_contextSslClientCertPwPrompt();
0072     virtual void event_contextSslServerTrustPrompt();
0073     virtual void event_contextNotify(const QString &msg);
0074 
0075 private:
0076     /* stores all internals */
0077     ThreadContextListenerData *m_Data;
0078 };
0079 
0080 #endif