File indexing completed on 2024-05-12 17:16:23
0001 /* 0002 * Port for usage with qt-framework and development for kdesvn 0003 * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de) 0004 * http://kdesvn.alwins-world.de 0005 */ 0006 /* 0007 * ==================================================================== 0008 * Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved. 0009 * dev@rapidsvn.tigris.org 0010 * 0011 * This library is free software; you can redistribute it and/or 0012 * modify it under the terms of the GNU Lesser General Public 0013 * License as published by the Free Software Foundation; either 0014 * version 2.1 of the License, or (at your option) any later version. 0015 * 0016 * This library is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 * Lesser General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Lesser General Public 0022 * License along with this library (in the file LGPL.txt); if not, 0023 * write to the Free Software Foundation, Inc., 51 Franklin St, 0024 * Fifth Floor, Boston, MA 02110-1301 USA 0025 * 0026 * This software consists of voluntary contributions made by many 0027 * individuals. For exact contribution history, see the revision 0028 * history and logs, available at http://rapidsvn.tigris.org/. 0029 * ==================================================================== 0030 */ 0031 0032 #ifndef SVNQT_CONTEXT_LISTENER_H 0033 #define SVNQT_CONTEXT_LISTENER_H 0034 0035 // svncpp 0036 #include <svnqt/pool.h> 0037 #include <svnqt/commititem.h> 0038 #include <svnqt/svnqt_defines.h> 0039 // qt 0040 #include <QString> 0041 // Subversion api 0042 #include <svn_client.h> 0043 0044 namespace svn 0045 { 0046 class ConflictResult; 0047 class ConflictDescription; 0048 /** 0049 * This is the interface that is used by @a Context 0050 * for callbacks. 0051 * To use this you will have to inherit from this 0052 * interface and overwrite the virtual methods. 0053 */ 0054 class SVNQT_EXPORT ContextListener 0055 { 0056 public: 0057 /** 0058 * empty destructor avoids a lot of compiler warnings 0059 */ 0060 virtual ~ContextListener() {} 0061 /** 0062 * this method will be called to retrieve 0063 * authentication information. This will called until valid information were 0064 * inserted or it returns false. 0065 * 0066 * @param username username set as default by subversion 0067 * @param realm in which username/password will be used 0068 * @param password target storage for password 0069 * @param maySave in/out set false to not save 0070 * @return continue action? 0071 * @retval true continue 0072 */ 0073 virtual bool 0074 contextGetLogin(const QString &realm, 0075 QString &username, 0076 QString &password, 0077 bool &maySave) = 0; 0078 /** 0079 * this method will be called to retrieve 0080 * authentication information stored not by subversion. This 0081 * will only called once! 0082 * 0083 * @param username username set as default by subversion 0084 * @param realm in which username/password will be used 0085 * @param password target storage for password 0086 * @return continue action? should only in case of emergency return false. 0087 * @retval true continue 0088 */ 0089 virtual bool 0090 contextGetSavedLogin(const QString &realm, 0091 QString &username, 0092 QString &password) = 0; 0093 /** 0094 * this method will be called to retrieve 0095 * authentication information stored not persistent. This 0096 * will only called once! 0097 * 0098 * @param username username set as default by subversion 0099 * @param realm in which username/password will be used 0100 * @param password target storage for password 0101 * @return continue action? should only in case of emergency return false. 0102 * @retval true continue 0103 */ 0104 virtual bool 0105 contextGetCachedLogin(const QString &realm, 0106 QString &username, 0107 QString &password) = 0; 0108 0109 /** 0110 * this method will be called to notify about 0111 * the progress of an ongoing action 0112 * 0113 * @param path 0114 * @param action 0115 * @param kind 0116 * @param mime_type 0117 * @param content_state 0118 * @param prop_state 0119 * @param revision 0120 */ 0121 virtual void 0122 contextNotify(const char *path, 0123 svn_wc_notify_action_t action, 0124 svn_node_kind_t kind, 0125 const char *mime_type, 0126 svn_wc_notify_state_t content_state, 0127 svn_wc_notify_state_t prop_state, 0128 svn_revnum_t revision) = 0; 0129 /** 0130 * this method will be called to notify about 0131 * the progress of an ongoing action 0132 * 0133 * @param action the action got notified about 0134 * @since subversion 1.2 0135 */ 0136 virtual void contextNotify(const svn_wc_notify_t *action) = 0; 0137 0138 /** 0139 * this method will be called periodically to allow 0140 * the app to cancel long running operations 0141 * 0142 * @return cancel action? 0143 * @retval true cancel 0144 */ 0145 virtual bool 0146 contextCancel() = 0; 0147 0148 /** 0149 * this method will be called to retrieve 0150 * a log message 0151 * 0152 * WORKAROUND FOR apr_xlate PROBLEM: 0153 * STRINGS ALREADY HAVE TO BE UTF8!!! 0154 * 0155 * @param msg log message 0156 * @return continue action? 0157 * @retval true continue 0158 */ 0159 virtual bool 0160 contextGetLogMessage(QString &msg, const CommitItemList &) = 0; 0161 0162 typedef enum { 0163 DONT_ACCEPT = 0, 0164 ACCEPT_TEMPORARILY, 0165 ACCEPT_PERMANENTLY 0166 } SslServerTrustAnswer; 0167 0168 /** 0169 * @see contextSslServerTrust 0170 * @see svn_auth_cred_ssl_server_trust_t 0171 */ 0172 struct SslServerTrustData { 0173 public: 0174 /** bit coded failures */ 0175 apr_uint32_t failures; 0176 0177 /** certificate information */ 0178 QString hostname; 0179 QString fingerprint; 0180 QString validFrom; 0181 QString validUntil; 0182 QString issuerDName; 0183 QString realm; 0184 bool maySave; 0185 0186 SslServerTrustData(const apr_uint32_t failures_ = 0) 0187 : failures(failures_), hostname(), fingerprint(), 0188 validFrom(), validUntil(), issuerDName(), 0189 realm(), maySave(true) 0190 { 0191 } 0192 }; 0193 0194 /** 0195 * this method is called if there is ssl server 0196 * information, that has to be confirmed by the user 0197 * 0198 * @param data 0199 * @param acceptedFailures 0200 * @return @a SslServerTrustAnswer 0201 */ 0202 virtual SslServerTrustAnswer 0203 contextSslServerTrustPrompt(const SslServerTrustData &data, 0204 apr_uint32_t &acceptedFailures) = 0; 0205 0206 /** 0207 * this method is called to retrieve client side 0208 * information 0209 */ 0210 virtual bool 0211 contextSslClientCertPrompt(QString &certFile) = 0; 0212 0213 /** 0214 * this method is called to retrieve the password 0215 * for the client certificate 0216 * 0217 * @param password 0218 * @param realm 0219 * @param maySave 0220 */ 0221 virtual bool 0222 contextSslClientCertPwPrompt(QString &password, 0223 const QString &realm, 0224 bool &maySave) = 0; 0225 /** 0226 * this method is called to retrieve the password 0227 * for the client certificate from a local storage or such. it will called only once. 0228 * 0229 * @param password 0230 * @param realm 0231 */ 0232 virtual bool 0233 contextLoadSslClientCertPw(QString &password, const QString &realm) = 0; 0234 0235 virtual void 0236 contextProgress(long long int current, long long int max) = 0; 0237 0238 /** 0239 * try to translate a text. In current implementation does 0240 * nothing than returning the origin but may used to get an 0241 * application specific translation. 0242 * @param what text to translate 0243 * @return translated text or origin. 0244 */ 0245 virtual QString translate(const QString &what) 0246 { 0247 return what; 0248 } 0249 0250 /** Callback for svn_wc_conflict_resolver_func_t in subversion 1.5 0251 * This method is only useful when build with subverion 1.5 or above. The default implementation sets 0252 * result to ConflictResult::ChoosePostpone. Then conflicts while merge, update and switch results in an 0253 * item with "conflict" status set. 0254 * 0255 * @param result The result where to store 0256 * @param description description of conflict. 0257 * @return true if result may used and operaion should continue. 0258 * @sa svn_wc_conflict_description_t, svn_wc_conflict_result_t 0259 * @since subversion 1.5 0260 */ 0261 virtual bool contextConflictResolve(ConflictResult &result, const ConflictDescription &description); 0262 /** Callback for svn_auth_plaintext_prompt_func_t in subversion 1.6 0263 * @param may_save call back memory where to store true (yes, save plaintext) or false (no save of plaintext passwords) 0264 * The default implementation set it to "true" 0265 */ 0266 virtual void maySavePlaintext(svn_boolean_t *may_save_plaintext, const QString &realmstring); 0267 /** Callback for generating list entries 0268 * This base implementation just adds items to @a entries. This may used for special listener like the one from KIO 0269 * where items may displayed direkt on call and not stored into @a entries. 0270 * @param entries default target list 0271 * @param dirent entry to add (send by subversion) 0272 * @param lock accociated lock (may be null!) 0273 * @param path the path of the item 0274 * @return true if inserted/displayd, false if dirent or entries aren't valid. 0275 */ 0276 virtual bool contextAddListItem(DirEntries *entries, const svn_dirent_t *dirent, const svn_lock_t *lock, const QString &path); 0277 }; 0278 } 0279 0280 #endif 0281 /* ----------------------------------------------------------------- 0282 * local variables: 0283 * eval: (load-file "../../rapidsvn-dev.el") 0284 * end: 0285 */