File indexing completed on 2024-04-28 05:42:09
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 * https://kde.org/applications/development/org.kde.kdesvn 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/commititem.h> 0037 #include <svnqt/pool.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 } 0063 /** 0064 * this method will be called to retrieve 0065 * authentication information. This will called until valid information were 0066 * inserted or it returns false. 0067 * 0068 * @param username username set as default by subversion 0069 * @param realm in which username/password will be used 0070 * @param password target storage for password 0071 * @param maySave in/out set false to not save 0072 * @return continue action? 0073 * @retval true continue 0074 */ 0075 virtual bool contextGetLogin(const QString &realm, QString &username, QString &password, bool &maySave) = 0; 0076 /** 0077 * this method will be called to retrieve 0078 * authentication information stored not by subversion. This 0079 * will only called once! 0080 * 0081 * @param username username set as default by subversion 0082 * @param realm in which username/password will be used 0083 * @param password target storage for password 0084 * @return continue action? should only in case of emergency return false. 0085 * @retval true continue 0086 */ 0087 virtual bool contextGetSavedLogin(const QString &realm, QString &username, QString &password) = 0; 0088 /** 0089 * this method will be called to retrieve 0090 * authentication information stored not persistent. This 0091 * will only called once! 0092 * 0093 * @param username username set as default by subversion 0094 * @param realm in which username/password will be used 0095 * @param password target storage for password 0096 * @return continue action? should only in case of emergency return false. 0097 * @retval true continue 0098 */ 0099 virtual bool contextGetCachedLogin(const QString &realm, QString &username, QString &password) = 0; 0100 0101 /** 0102 * this method will be called to notify about 0103 * the progress of an ongoing action 0104 * 0105 * @param path 0106 * @param action 0107 * @param kind 0108 * @param mime_type 0109 * @param content_state 0110 * @param prop_state 0111 * @param revision 0112 */ 0113 virtual void contextNotify(const char *path, 0114 svn_wc_notify_action_t action, 0115 svn_node_kind_t kind, 0116 const char *mime_type, 0117 svn_wc_notify_state_t content_state, 0118 svn_wc_notify_state_t prop_state, 0119 svn_revnum_t revision) = 0; 0120 /** 0121 * this method will be called to notify about 0122 * the progress of an ongoing action 0123 * 0124 * @param action the action got notified about 0125 * @since subversion 1.2 0126 */ 0127 virtual void contextNotify(const svn_wc_notify_t *action) = 0; 0128 0129 /** 0130 * this method will be called periodically to allow 0131 * the app to cancel long running operations 0132 * 0133 * @return cancel action? 0134 * @retval true cancel 0135 */ 0136 virtual bool contextCancel() = 0; 0137 0138 /** 0139 * this method will be called to retrieve 0140 * a log message 0141 * 0142 * WORKAROUND FOR apr_xlate PROBLEM: 0143 * STRINGS ALREADY HAVE TO BE UTF8!!! 0144 * 0145 * @param msg log message 0146 * @return continue action? 0147 * @retval true continue 0148 */ 0149 virtual bool contextGetLogMessage(QString &msg, const CommitItemList &) = 0; 0150 0151 typedef enum { DONT_ACCEPT = 0, ACCEPT_TEMPORARILY, ACCEPT_PERMANENTLY } SslServerTrustAnswer; 0152 0153 /** 0154 * @see contextSslServerTrust 0155 * @see svn_auth_cred_ssl_server_trust_t 0156 */ 0157 struct SslServerTrustData { 0158 public: 0159 /** bit coded failures */ 0160 apr_uint32_t failures; 0161 0162 /** certificate information */ 0163 QString hostname; 0164 QString fingerprint; 0165 QString validFrom; 0166 QString validUntil; 0167 QString issuerDName; 0168 QString realm; 0169 bool maySave; 0170 0171 SslServerTrustData(const apr_uint32_t failures_ = 0) 0172 : failures(failures_) 0173 , hostname() 0174 , fingerprint() 0175 , validFrom() 0176 , validUntil() 0177 , issuerDName() 0178 , realm() 0179 , maySave(true) 0180 { 0181 } 0182 }; 0183 0184 /** 0185 * this method is called if there is ssl server 0186 * information, that has to be confirmed by the user 0187 * 0188 * @param data 0189 * @param acceptedFailures 0190 * @return @a SslServerTrustAnswer 0191 */ 0192 virtual SslServerTrustAnswer contextSslServerTrustPrompt(const SslServerTrustData &data, apr_uint32_t &acceptedFailures) = 0; 0193 0194 /** 0195 * this method is called to retrieve client side 0196 * information 0197 */ 0198 virtual bool contextSslClientCertPrompt(QString &certFile) = 0; 0199 0200 /** 0201 * this method is called to retrieve the password 0202 * for the client certificate 0203 * 0204 * @param password 0205 * @param realm 0206 * @param maySave 0207 */ 0208 virtual bool contextSslClientCertPwPrompt(QString &password, const QString &realm, bool &maySave) = 0; 0209 /** 0210 * this method is called to retrieve the password 0211 * for the client certificate from a local storage or such. it will called only once. 0212 * 0213 * @param password 0214 * @param realm 0215 */ 0216 virtual bool contextLoadSslClientCertPw(QString &password, const QString &realm) = 0; 0217 0218 virtual void contextProgress(long long int current, long long int max) = 0; 0219 0220 /** 0221 * try to translate a text. In current implementation does 0222 * nothing than returning the origin but may used to get an 0223 * application specific translation. 0224 * @param what text to translate 0225 * @return translated text or origin. 0226 */ 0227 virtual QString translate(const QString &what) 0228 { 0229 return what; 0230 } 0231 0232 /** Callback for svn_wc_conflict_resolver_func_t in subversion 1.5 0233 * This method is only useful when build with subverion 1.5 or above. The default implementation sets 0234 * result to ConflictResult::ChoosePostpone. Then conflicts while merge, update and switch results in an 0235 * item with "conflict" status set. 0236 * 0237 * @param result The result where to store 0238 * @param description description of conflict. 0239 * @return true if result may used and operaion should continue. 0240 * @sa svn_wc_conflict_description_t, svn_wc_conflict_result_t 0241 * @since subversion 1.5 0242 */ 0243 virtual bool contextConflictResolve(ConflictResult &result, const ConflictDescription &description); 0244 /** Callback for svn_auth_plaintext_prompt_func_t in subversion 1.6 0245 * @param may_save call back memory where to store true (yes, save plaintext) or false (no save of plaintext passwords) 0246 * The default implementation set it to "true" 0247 */ 0248 virtual void maySavePlaintext(svn_boolean_t *may_save_plaintext, const QString &realmstring); 0249 /** Callback for generating list entries 0250 * This base implementation just adds items to @a entries. This may used for special listener like the one from KIO 0251 * where items may displayed direkt on call and not stored into @a entries. 0252 * @param entries default target list 0253 * @param dirent entry to add (send by subversion) 0254 * @param lock accociated lock (may be null!) 0255 * @param path the path of the item 0256 * @return true if inserted/displayd, false if dirent or entries aren't valid. 0257 */ 0258 virtual bool contextAddListItem(DirEntries *entries, const svn_dirent_t *dirent, const svn_lock_t *lock, const QString &path); 0259 }; 0260 } 0261 0262 #endif 0263 /* ----------------------------------------------------------------- 0264 * local variables: 0265 * eval: (load-file "../../rapidsvn-dev.el") 0266 * end: 0267 */