File indexing completed on 2024-05-05 17:50:47
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * 0003 * http://kdesvn.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 0021 #include "kdesvnd_listener.h" 0022 #include "kdesvnd.h" 0023 0024 #include "settings/kdesvnsettings.h" 0025 #include "ksvnwidgets/pwstorage.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, 0053 QString &username, 0054 QString &password, 0055 bool &maySave) 0056 { 0057 maySave = false; 0058 QStringList res = m_back->get_login(realm, username); 0059 if (res.count() != 3) { 0060 return false; 0061 } 0062 username = res[0]; 0063 password = res[1]; 0064 maySave = (res[2] == QLatin1String("true")); 0065 if (maySave && Kdesvnsettings::passwords_in_wallet()) { 0066 PwStorage::self()->setLogin(realm, username, password); 0067 maySave = false; 0068 } 0069 return true; 0070 } 0071 0072 void KdesvndListener::contextNotify(const char * /*path*/, 0073 svn_wc_notify_action_t /*action*/, 0074 svn_node_kind_t /*kind*/, 0075 const char */*mime_type*/, 0076 svn_wc_notify_state_t /*content_state*/, 0077 svn_wc_notify_state_t /*prop_state*/, 0078 svn_revnum_t /*revision*/) 0079 { 0080 } 0081 0082 void KdesvndListener::contextNotify(const svn_wc_notify_t * /*action*/) 0083 { 0084 } 0085 0086 bool KdesvndListener::contextCancel() 0087 { 0088 return false; 0089 } 0090 0091 bool KdesvndListener::contextGetLogMessage(QString &msg, const svn::CommitItemList &) 0092 { 0093 const QStringList res = m_back->get_logmsg(); 0094 if (res.isEmpty()) { 0095 return false; 0096 } 0097 msg = res[1]; 0098 return true; 0099 } 0100 0101 svn::ContextListener::SslServerTrustAnswer KdesvndListener::contextSslServerTrustPrompt(const SslServerTrustData &data, 0102 apr_uint32_t & /*acceptedFailures*/) 0103 { 0104 int res = m_back->get_sslaccept(data.hostname, 0105 data.fingerprint, 0106 data.validFrom, 0107 data.validUntil, 0108 data.issuerDName, 0109 data.realm); 0110 switch (res) { 0111 case -1: 0112 return DONT_ACCEPT; 0113 break; 0114 case 1: 0115 return ACCEPT_PERMANENTLY; 0116 break; 0117 default: 0118 case 0: 0119 return ACCEPT_TEMPORARILY; 0120 break; 0121 } 0122 /* avoid compiler warnings */ 0123 return ACCEPT_TEMPORARILY; 0124 } 0125 0126 bool KdesvndListener::contextSslClientCertPrompt(QString &certFile) 0127 { 0128 certFile = m_back->get_sslclientcertfile(); 0129 if (certFile.isEmpty()) { 0130 return false; 0131 } 0132 return true; 0133 } 0134 0135 bool KdesvndListener::contextLoadSslClientCertPw(QString &password, const QString &realm) 0136 { 0137 return PwStorage::self()->getCertPw(realm, password); 0138 } 0139 0140 bool KdesvndListener::contextSslClientCertPwPrompt(QString &password, 0141 const QString &realm, bool &maySave) 0142 { 0143 maySave = false; 0144 if (PwStorage::self()->getCertPw(realm, password)) { 0145 return true; 0146 } 0147 QStringList res = m_back->get_sslclientcertpw(realm); 0148 if (res.size() != 2) { 0149 return false; 0150 } 0151 password = res[0]; 0152 maySave = res[1] == QLatin1String("true"); 0153 0154 if (maySave && Kdesvnsettings::passwords_in_wallet()) { 0155 PwStorage::self()->setCertPw(realm, password); 0156 maySave = false; 0157 } 0158 0159 return true; 0160 } 0161 0162 void KdesvndListener::contextProgress(long long int, long long int) 0163 { 0164 }