GME  13
SVNClient.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #ifndef _WIN64
00004 
00005 #include "svn_client.h"
00006 #include "svn_config.h"
00007 #include "svn_pools.h"
00008 
00009 class CSVNClient;
00010 
00011 #define SVN_ERROR_MSG_MAX       256
00012 
00013 class CSVNError
00014 {
00015         friend class CSVNClient;
00016         friend class CSVNFile;
00017 
00018 private:
00019         CSVNError(svn_error_t* e);
00020         CSVNError(const CSVNError&) {ASSERT(("Copying CVSNError objects are not supported", false));}
00021 
00022 public:
00023         virtual ~CSVNError();
00024         CString msg() const;
00025 
00026 private:
00027         svn_error_t     *svnError;
00028 };
00029 
00030 class CSVNPool
00031 {
00032         typedef apr_pool_t* apr_pool_ptr;
00033 public:
00034         CSVNPool(apr_pool_t* parentPool);
00035         CSVNPool(const CSVNPool&) {ASSERT(("Copying CSVNPool objects are not supported", false));}
00036         virtual ~CSVNPool();
00037 
00038         operator apr_pool_ptr() const;
00039 
00040 private:
00041         apr_pool_ptr pool;
00042 };
00043 
00044 class CSVNFile
00045 {
00046         friend class CSVNClient;
00047 
00048 private:
00049         CSVNFile(CSVNClient* client, const CString & filePath);
00050 
00051         void updateStatus(bool checkServer = false);
00052 
00053         // Callbacks
00054         static svn_error_t* cbStatus(void *baton, const char *path, const svn_client_status_t *status, apr_pool_t *scratch_pool);
00055 
00056 public:
00057         virtual ~CSVNFile();
00058 
00059         bool isVersioned();
00060         bool isTracked();
00061         bool isOwned();
00062         bool isLatest();
00063 
00064         bool update();
00065         bool takeOwnership();
00066         bool commit();
00067 
00068 private:
00069         CSVNClient *client;
00070         CString filePath;
00071         bool    versioned;
00072         bool    tracked;
00073         bool    owned;
00074         bool    latest;
00075 };
00076 
00077 
00078 class CSVNClient
00079 {
00080         friend class CSVNFile;
00081 
00082 public:
00083         CSVNClient();
00084         virtual ~CSVNClient();
00085 
00086         void initialize();
00087 
00088         CSVNFile* embraceFile(const CString & filePath);
00089         void forgetFile(CSVNFile* svnFile);
00090 
00091 private:
00092         // Context Callbacks
00093         static void cbNotify(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool);
00094         static svn_error_t* cbLog(const char **log_msg, const char **tmp_file, const apr_array_header_t *commit_items, void *baton, apr_pool_t *pool);
00095         static svn_error_t* cbCancel(void *cancel_baton);
00096         static void cbProgress(apr_off_t progress, apr_off_t total, void *baton, apr_pool_t *pool);
00097         static svn_error_t* cbConflict(svn_wc_conflict_result_t **result, const svn_wc_conflict_description2_t *description, void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool);
00098 
00099         // Auth Callbacks
00100         static svn_error_t* cbAuthPlaintextPrompt(svn_boolean_t *may_save_plaintext, const char *realmstring, void *baton, apr_pool_t *pool);
00101         static svn_error_t* cbAuthPlaintextPassphrasePrompt(svn_boolean_t *may_save_plaintext, const char *realmstring, void *baton, apr_pool_t *pool);
00102         static svn_error_t* cbAuthSimplePrompt(svn_auth_cred_simple_t **cred, void *baton, const char *realm, const char *username, svn_boolean_t may_save, apr_pool_t *pool);
00103         static svn_error_t* cbAuthUsernamePrompt(svn_auth_cred_username_t **cred, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool);
00104         static svn_error_t* cbAuthSSLServerTrustPrompt(svn_auth_cred_ssl_server_trust_t **cred, void *baton, const char *realm, apr_uint32_t failures, const svn_auth_ssl_server_cert_info_t *cert_info, svn_boolean_t may_save, apr_pool_t *pool);
00105         static svn_error_t* cbAuthSSLClientCertPWPrompt(svn_auth_cred_ssl_client_cert_pw_t **cred, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool);
00106         static svn_error_t* cbAuthSSLClientCertPrompt(svn_auth_cred_ssl_client_cert_t **cred, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool);
00107 
00108 private:
00109         CList<CSVNFile*, CSVNFile*> svnFiles;
00110         
00111         bool isInitialized;
00112 
00113         // These are valid only if initialized
00114         svn_client_ctx_t *ctx;
00115         apr_pool_t *pool;
00116 
00117         // Internal communication
00118         bool canceledOperation;
00119         svn_wc_notify_action_t lastNotifyAction;
00120 };
00121 
00122 #else // #ifndef _WIN64
00123 // Dummy implementation for x64
00124 
00125 class CSVNClient;
00126 
00127 class CSVNFile
00128 {
00129         friend class CSVNClient;
00130 
00131 private:
00132         CSVNFile() {}
00133 
00134 public:
00135 
00136         bool isVersioned() {return false;}
00137         bool isTracked() {return false;}
00138         bool isOwned() {return false;}
00139         bool isLatest() {return true;}
00140 
00141         bool update() {}
00142         bool takeOwnership() {}
00143         bool commit() {}
00144 };
00145 
00146 class CSVNClient
00147 {
00148 public:
00149         CSVNClient() : dummyFile() {}
00150 
00151         void initialize() {}
00152 
00153         CSVNFile* embraceFile(const CString & filePath) {return &dummyFile;}
00154         void forgetFile(CSVNFile* svnFile) {}
00155 
00156 private:
00157         CSVNFile dummyFile;
00158 };
00159 
00160 #endif // #ifndef _WIN64
00161