File indexing completed on 2024-04-21 05:42:02
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * 0003 * https://kde.org/applications/development/org.kde.kdesvn * 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 0021 #include "kdesvnd_listener.h" 0022 #include "kdesvnd.h" 0023 0024 #include "ksvnwidgets/pwstorage.h" 0025 #include "settings/kdesvnsettings.h" 0026 0027 KdesvndListener::KdesvndListener(kdesvnd *p) 0028 : svn::ContextListener() 0029 , m_back(p) 0030 , m_CurrentContext(new svn::Context) 0031 , m_Svnclient(svn::Client::getobject(m_CurrentContext)) 0032 { 0033 m_CurrentContext->setListener(this); 0034 } 0035 0036 KdesvndListener::~KdesvndListener() 0037 { 0038 } 0039 0040 bool KdesvndListener::contextGetSavedLogin(const QString &realm, QString &username, QString &password) 0041 { 0042 PwStorage::self()->getLogin(realm, username, password); 0043 return true; 0044 } 0045 0046 bool KdesvndListener::contextGetCachedLogin(const QString &realm, QString &username, QString &password) 0047 { 0048 PwStorage::self()->getCachedLogin(realm, username, password); 0049 return true; 0050 } 0051 0052 bool KdesvndListener::contextGetLogin(const QString &realm, QString &username, QString &password, bool &maySave) 0053 { 0054 maySave = false; 0055 QStringList res = m_back->get_login(realm, username); 0056 if (res.count() != 3) { 0057 return false; 0058 } 0059 username = res[0]; 0060 password = res[1]; 0061 maySave = (res[2] == QLatin1String("true")); 0062 if (maySave && Kdesvnsettings::passwords_in_wallet()) { 0063 PwStorage::self()->setLogin(realm, username, password); 0064 maySave = false; 0065 } 0066 return true; 0067 } 0068 0069 void KdesvndListener::contextNotify(const char * /*path*/, 0070 svn_wc_notify_action_t /*action*/, 0071 svn_node_kind_t /*kind*/, 0072 const char * /*mime_type*/, 0073 svn_wc_notify_state_t /*content_state*/, 0074 svn_wc_notify_state_t /*prop_state*/, 0075 svn_revnum_t /*revision*/) 0076 { 0077 } 0078 0079 void KdesvndListener::contextNotify(const svn_wc_notify_t * /*action*/) 0080 { 0081 } 0082 0083 bool KdesvndListener::contextCancel() 0084 { 0085 return false; 0086 } 0087 0088 bool KdesvndListener::contextGetLogMessage(QString &msg, const svn::CommitItemList &) 0089 { 0090 const QStringList res = m_back->get_logmsg(); 0091 if (res.isEmpty()) { 0092 return false; 0093 } 0094 msg = res[1]; 0095 return true; 0096 } 0097 0098 svn::ContextListener::SslServerTrustAnswer KdesvndListener::contextSslServerTrustPrompt(const SslServerTrustData &data, apr_uint32_t & /*acceptedFailures*/) 0099 { 0100 int res = m_back->get_sslaccept(data.hostname, data.fingerprint, data.validFrom, data.validUntil, data.issuerDName, data.realm); 0101 switch (res) { 0102 case -1: 0103 return DONT_ACCEPT; 0104 break; 0105 case 1: 0106 return ACCEPT_PERMANENTLY; 0107 break; 0108 default: 0109 case 0: 0110 return ACCEPT_TEMPORARILY; 0111 break; 0112 } 0113 /* avoid compiler warnings */ 0114 return ACCEPT_TEMPORARILY; 0115 } 0116 0117 bool KdesvndListener::contextSslClientCertPrompt(QString &certFile) 0118 { 0119 certFile = m_back->get_sslclientcertfile(); 0120 if (certFile.isEmpty()) { 0121 return false; 0122 } 0123 return true; 0124 } 0125 0126 bool KdesvndListener::contextLoadSslClientCertPw(QString &password, const QString &realm) 0127 { 0128 return PwStorage::self()->getCertPw(realm, password); 0129 } 0130 0131 bool KdesvndListener::contextSslClientCertPwPrompt(QString &password, const QString &realm, bool &maySave) 0132 { 0133 maySave = false; 0134 if (PwStorage::self()->getCertPw(realm, password)) { 0135 return true; 0136 } 0137 QStringList res = m_back->get_sslclientcertpw(realm); 0138 if (res.size() != 2) { 0139 return false; 0140 } 0141 password = res[0]; 0142 maySave = res[1] == QLatin1String("true"); 0143 0144 if (maySave && Kdesvnsettings::passwords_in_wallet()) { 0145 PwStorage::self()->setCertPw(realm, password); 0146 maySave = false; 0147 } 0148 0149 return true; 0150 } 0151 0152 void KdesvndListener::contextProgress(long long int, long long int) 0153 { 0154 }