1 /* 2 * ==================================================================== 3 * Copyright (c) 2002-2009 The RapidSvn Group. All rights reserved. 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program (in the file GPL.txt. 17 * If not, see <http://www.gnu.org/licenses/>. 18 * 19 * This software consists of voluntary contributions made by many 20 * individuals. For exact contribution history, see the revision 21 * history and logs, available at http://rapidsvn.tigris.org/. 22 * ==================================================================== 23 */ 24 25 #ifndef _SVNCPP_CONTEXT_LISTENER_HPP_ 26 #define _SVNCPP_CONTEXT_LISTENER_HPP_ 27 28 // stl 29 #include "kdevsvncpp/string_wrapper.hpp" 30 31 // Subversion api 32 #include "svn_client.h" 33 34 // svncpp 35 #include "kdevsvncpp/pool.hpp" 36 37 namespace svn 38 { 39 /** 40 * This is the interface that is used by @a Context 41 * for callbacks. 42 * To use this you will have to inherit from this 43 * interface and overwrite the virtual methods. 44 */ 45 class ContextListener 46 { 47 public: 48 /** 49 * this method will be called to retrieve 50 * authentication information 51 * 52 * WORKAROUND FOR apr_xlate PROBLEM: 53 * STRINGS ALREADY HAVE TO BE UTF8!!! 54 * 55 * @param realm in which username/password will be used 56 * @param maySave in/out set false to not save 57 * @return continue action? 58 * @retval true continue 59 */ 60 virtual bool 61 contextGetLogin(const std::string & realm, 62 std::string & username, 63 std::string & password, 64 bool & maySave) = 0; 65 66 /** 67 * this method will be called to notify about 68 * the progress of an ongoing action 69 * 70 */ 71 virtual void 72 contextNotify(const char *path, 73 svn_wc_notify_action_t action, 74 svn_node_kind_t kind, 75 const char *mime_type, 76 svn_wc_notify_state_t content_state, 77 svn_wc_notify_state_t prop_state, 78 svn_revnum_t revision) = 0; 79 80 /* 81 * this method will be called periodically to allow 82 * the app to cancel long running operations 83 * 84 * @return cancel action? 85 * @retval true cancel 86 */ 87 virtual bool 88 contextCancel() = 0; 89 90 /** 91 * this method will be called to retrieve 92 * a log message 93 * 94 * WORKAROUND FOR apr_xlate PROBLEM: 95 * STRINGS ALREADY HAVE TO BE UTF8!!! 96 * 97 * @param msg log message 98 * @return continue action? 99 * @retval true continue 100 */ 101 virtual bool 102 contextGetLogMessage(std::string & msg) = 0; 103 104 typedef enum 105 { 106 DONT_ACCEPT = 0, 107 ACCEPT_TEMPORARILY, 108 ACCEPT_PERMANENTLY 109 } SslServerTrustAnswer; 110 111 112 /** 113 * @see contextSslServerTrust 114 * @see svn_auth_cred_ssl_server_trust_t 115 */ 116 struct SslServerTrustData 117 { 118 public: 119 /** bit coded failures */ 120 apr_uint32_t failures; 121 122 /** certificate information */ 123 std::string hostname; 124 std::string fingerprint; 125 std::string validFrom; 126 std::string validUntil; 127 std::string issuerDName; 128 std::string realm; 129 bool maySave; 130 SslServerTrustDatasvn::ContextListener::SslServerTrustData131 SslServerTrustData(const apr_uint32_t failures_ = 0) 132 : failures(failures_) 133 , hostname("") 134 , fingerprint("") 135 , validFrom("") 136 , validUntil("") 137 , issuerDName("") 138 , realm("") 139 , maySave(true) 140 { 141 } 142 SslServerTrustDatasvn::ContextListener::SslServerTrustData143 SslServerTrustData(const SslServerTrustData & src) 144 : failures(src.failures) 145 , hostname(src.hostname) 146 , fingerprint(src.fingerprint) 147 , validFrom(src.validFrom) 148 , validUntil(src.validUntil) 149 , issuerDName(src.issuerDName) 150 , realm(src.realm) 151 , maySave(src.maySave) 152 { 153 } 154 155 SslServerTrustData & operator =svn::ContextListener::SslServerTrustData156 operator =(const SslServerTrustData & src) 157 { 158 if (this == &src) 159 return *this; 160 161 hostname = src.hostname; 162 fingerprint = src.fingerprint; 163 validFrom = src.validFrom; 164 validUntil = src.validUntil; 165 issuerDName = src.issuerDName; 166 realm = src.realm; 167 maySave = src.maySave; 168 failures = src.failures; 169 170 return *this; 171 } 172 }; 173 174 175 /** 176 * this method is called if there is ssl server 177 * information, that has to be confirmed by the user 178 * 179 * @return @a SslServerTrustAnswer 180 */ 181 virtual SslServerTrustAnswer 182 contextSslServerTrustPrompt(const SslServerTrustData & data, 183 apr_uint32_t & acceptedFailures) = 0; 184 185 /** 186 * this method is called to retrieve client side 187 * information 188 */ 189 virtual bool 190 contextSslClientCertPrompt(std::string & certFile) = 0; 191 192 /** 193 * this method is called to retrieve the password 194 * for the client certificate 195 */ 196 virtual bool 197 contextSslClientCertPwPrompt(std::string & password, 198 const std::string & realm, 199 bool & maySave) = 0; 200 ~ContextListener()201 virtual ~ContextListener() { } 202 }; 203 } 204 205 #endif 206 /* ----------------------------------------------------------------- 207 * local variables: 208 * eval: (load-file "../../rapidsvn-dev.el") 209 * end: 210 */ 211