Changeset 31

Show
Ignore:
Timestamp:
06/25/04 02:08:28
Author:
DenisG
Message:

[SubversionSharp] Temporary checkin

- Generic Delegates
- Several new structure
- First SvnClient? functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SubversionSharp/dev/src/SubversionSharp.prjx

    r21 r31  
    1212    <File name="./SvnAuthSslServerCertInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
    1313    <File name="./SvnAuthBaton.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
     14    <File name="./SvnWcNotify.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
     15    <File name="./SvnDelegate.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
     16    <File name="./SvnClient.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
     17    <File name="./SvnOptRevision.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
     18    <File name="./SvnClientCommitInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
     19    <File name="./SvnClientCommitItem.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 
    1420  </Contents> 
    1521  <References> 
  • trunk/SubversionSharp/dev/src/Svn.cs

    r21 r31  
    1818 
    1919    ///<summary>Embeds all Svn external calls</summary> 
    20     public class Svn 
     20    public sealed class Svn 
    2121    { 
    2222        // no instance constructor ! 
    2323        private Svn() { } 
     24 
     25        public enum NodeKind 
     26        { 
     27            None, 
     28            File, 
     29            Dir, 
     30            Unknown 
     31        } 
     32 
     33 
     34        internal delegate IntPtr svn_cancel_func_t(IntPtr baton); 
     35        public delegate SvnError CancelFunc(IntPtr baton); 
    2436         
    2537        #region Wrapper around APR Pool 
     
    6678        #endregion 
    6779 
    68         #region ClientContext 
     80        #region SvnClientContext 
    6981        [DllImport("svn_client-1")] static extern 
    7082        internal IntPtr svn_client_create_context(out IntPtr ctx, IntPtr pool); 
    71         #endregion 
    72                  
    73         #region Config 
     83         
     84        internal delegate void svn_wc_notify_func_t(IntPtr baton, IntPtr path,  
     85                                                    int action, int kind,  
     86                                                    IntPtr mime_type, int content_state,  
     87                                                    int prop_state, uint revision); 
     88        #endregion 
     89                                                     
     90        #region SvnConfig 
    7491        [DllImport("svn_client-1")] static extern 
    7592        internal IntPtr svn_config_ensure(IntPtr config_dir, IntPtr pool); 
     
    83100        #endregion 
    84101         
    85         #region AuthProvider 
    86         public delegate IntPtr svn_auth_simple_prompt_func_t(out IntPtr cred, IntPtr baton,  
    87                                                             IntPtr realm, IntPtr username,  
    88                                                              int may_save, IntPtr pool); 
    89  
    90         public delegate IntPtr svn_auth_username_prompt_func_t(out IntPtr cred, IntPtr baton,  
    91                                                                IntPtr realm, int may_save,  
    92                                                                IntPtr pool); 
     102        #region SvnAuthProvider 
     103        internal delegate IntPtr svn_auth_simple_prompt_func_t(out IntPtr cred, IntPtr baton,  
     104                                                              IntPtr realm, IntPtr username,  
     105                                                               int may_save, IntPtr pool); 
     106 
     107        internal delegate IntPtr svn_auth_username_prompt_func_t(out IntPtr cred, IntPtr baton,  
     108                                                                 IntPtr realm, int may_save,  
     109                                                                 IntPtr pool); 
    93110                                                                
    94         [CLSCompliant(false)] 
    95         public delegate IntPtr svn_auth_ssl_server_trust_prompt_func_t(out IntPtr cred, IntPtr baton,  
    96                                                                        IntPtr realm, uint failures,  
    97                                                                        IntPtr cert_info,  
    98                                                                        int may_save, IntPtr pool); 
    99  
    100         public delegate IntPtr svn_auth_ssl_client_cert_prompt_func_t(out IntPtr cred, IntPtr baton, 
    101                                                                       IntPtr realm, int may_save, 
    102                                                                       IntPtr pool); 
    103  
    104         public delegate IntPtr svn_auth_ssl_client_cert_pw_prompt_func_t(out IntPtr cred,  
    105                                                                          IntPtr baton, 
    106                                                                          IntPtr realm, int may_save, 
    107                                                                          IntPtr pool); 
     111        //[CLSCompliant(false)] 
     112        internal delegate IntPtr svn_auth_ssl_server_trust_prompt_func_t(out IntPtr cred, IntPtr baton,  
     113                                                                         IntPtr realm, uint failures,  
     114                                                                         IntPtr cert_info,  
     115                                                                         int may_save, IntPtr pool); 
     116 
     117        internal delegate IntPtr svn_auth_ssl_client_cert_prompt_func_t(out IntPtr cred, IntPtr baton, 
     118                                                                        IntPtr realm, int may_save, 
     119                                                                        IntPtr pool); 
     120 
     121        internal delegate IntPtr svn_auth_ssl_client_cert_pw_prompt_func_t(out IntPtr cred,  
     122                                                                           IntPtr baton, 
     123                                                                           IntPtr realm, int may_save, 
     124                                                                           IntPtr pool); 
    108125                                                                          
    109126        [DllImport("svn_client-1")] static extern 
     
    144161        #endregion 
    145162         
    146         #region AuthBaton 
     163        #region SvnAuthBaton 
    147164        [DllImport("svn_client-1")] static extern 
    148165        internal void svn_auth_open(out IntPtr auth_baton, IntPtr providers, IntPtr pool); 
     
    154171        internal IntPtr svn_auth_get_parameter(IntPtr auth_baton, IntPtr name); 
    155172        #endregion 
     173 
     174        #region SvnClient 
     175        internal delegate IntPtr svn_client_get_commit_log_t(out IntPtr log_message,  
     176                                                             out IntPtr tmp_file,  
     177                                                             IntPtr commit_items, IntPtr baton, 
     178                                                             IntPtr pool); 
     179                                                              
     180        [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 
     181        internal IntPtr svn_client_checkout(out int result_rev, string URL,  
     182                                            string path, IntPtr revision, int recurse,  
     183                                            IntPtr ctx, IntPtr pool); 
     184                                             
     185        [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 
     186        internal IntPtr svn_client_update (out int result_rev, string path,  
     187                                           IntPtr revision, int recurse, 
     188                                           IntPtr ctx, IntPtr pool); 
     189         
     190        [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 
     191        internal IntPtr svn_client_switch(out int result_rev, string path, string url,  
     192                                          IntPtr revision, int recurse,  
     193                                          IntPtr ctx, IntPtr pool); 
     194                                           
     195        [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 
     196        internal IntPtr svn_client_add(string path, int recursive,  
     197                                       IntPtr ctx, IntPtr pool); 
     198        #endregion                 
    156199    } 
    157200}    
  • trunk/SubversionSharp/dev/src/SvnAuthBaton.cs

    r26 r31  
    7777                mAuthProviders.Add(authObj.mAuthProvider); 
    7878            } 
     79            Debug.Write(String.Format("svn_auth_open({0},{1})...",authArray,pool)); 
    7980            Svn.svn_auth_open(out mAuthBaton, authArray, pool); 
     81            Debug.WriteLine(String.Format("Done({0:X})",mAuthBaton.ToInt32())); 
    8082            mParamName = null; 
    8183            mPool = pool; 
     
    118120 
    119121        #region Wrapper methods 
    120         public SvnAuthBaton Open(ArrayList authProviders, AprPool pool) 
     122        public static SvnAuthBaton Open(ArrayList authProviders, AprPool pool) 
    121123        { 
    122124            return(new SvnAuthBaton(authProviders,pool)); 
     
    136138                mParamName[(int)param] = new AprString(mPool, ParamName[(int)param]); 
    137139                     
     140            Debug.WriteLine(String.Format("svn_auth_set_parameter({0},{1:X},{2:X})",this,mParamName[(int)param].ToInt32(),value.ToInt32())); 
    138141            Svn.svn_auth_set_parameter(mAuthBaton, mParamName[(int)param], value); 
    139142        } 
     
    151154            if( mParamName[(int)param] == IntPtr.Zero ) 
    152155                mParamName[(int)param] = new AprString(mPool, ParamName[(int)param]); 
    153                      
    154             return(Svn.svn_auth_get_parameter(mAuthBaton, mParamName[(int)param])); 
     156 
     157            IntPtr ptr;                  
     158            Debug.Write(String.Format("svn_auth_get_parameter({0},{1:X})...",this,mParamName[(int)param].ToInt32())); 
     159            ptr = Svn.svn_auth_get_parameter(mAuthBaton, mParamName[(int)param]); 
     160            Debug.WriteLine(String.Format("Done({0:X})",ptr.ToInt32())); 
     161            return(ptr); 
    155162        } 
    156163        #endregion 
  • trunk/SubversionSharp/dev/src/SvnAuthCred.cs

    r27 r31  
    8787            get 
    8888            { 
     89                CheckPtr(); 
    8990                return(new AprString(mCred->username)); 
    9091            } 
    9192            set 
    9293            { 
     94                CheckPtr(); 
    9395                mCred->username = value; 
    9496            } 
     
    99101            get 
    100102            { 
     103                CheckPtr(); 
    101104                return(mCred->password); 
    102105            } 
    103106            set 
    104107            { 
     108                CheckPtr(); 
    105109                mCred->password = value; 
    106110            } 
     
    111115            get 
    112116            { 
     117                CheckPtr(); 
    113118                return(mCred->may_save != 0); 
    114119            } 
    115120            set 
    116121            { 
     122                CheckPtr(); 
    117123                mCred->may_save = (value) ? 1 : 0; 
    118124            } 
     
    216222    public unsafe struct SvnAuthCredSslServerTrust 
    217223    { 
     224        [Flags] 
     225        public enum CertFailures 
     226        { 
     227            NotYetValid = 0x00000001, 
     228            Expired     = 0x00000002, 
     229            CNMismatch  = 0x00000004, 
     230            UnknownCA   = 0x00000008, 
     231            Other       = 0x40000000 
     232        } 
     233         
    218234        private svn_auth_cred_ssl_server_trust_t *mCred; 
    219235 
     
    292308        } 
    293309         
    294         public int AcceptedFailure 
    295         { 
    296             get 
    297             { 
    298                 return(unchecked((int)mCred->accepted_failures)); 
    299             } 
    300             set 
    301             { 
    302                 mCred->accepted_failures = unchecked((uint)value); 
    303             } 
    304         } 
    305          
    306         [CLSCompliant(false)] 
    307         public uint NativeAcceptedFailure 
    308         { 
    309             get 
    310             { 
    311                 return(mCred->accepted_failures); 
    312             } 
    313             set 
    314             { 
    315                 mCred->accepted_failures = value; 
     310        public CertFailures AcceptedFailures 
     311        { 
     312            get 
     313            { 
     314                return((CertFailures)mCred->accepted_failures); 
     315            } 
     316            set 
     317            { 
     318                mCred->accepted_failures = (uint)value; 
    316319            } 
    317320        } 
  • trunk/SubversionSharp/dev/src/SvnAuthProvider.cs

    r21 r31  
    1818    { 
    1919        private IntPtr mAuthProviderObject; 
    20         internal SvnAuthProvider mAuthProvider; 
     20        internal SvnDelegate mAuthProvider; 
    2121 
    2222        #region Generic embedding functions of an IntPtr 
     
    2727        } 
    2828 
    29         private SvnAuthProviderObject(IntPtr ptr, SvnAuthProvider authProvider) 
     29        private SvnAuthProviderObject(IntPtr ptr, SvnDelegate authProvider) 
    3030        { 
    3131            mAuthProviderObject = ptr; 
     
    7979        public delegate SvnError SslServerTrustPrompt(out SvnAuthCredSslServerTrust cred,  
    8080                                                      IntPtr baton, AprString realm,  
    81                                                       int failures,  
     81                                                      SvnAuthCredSslServerTrust.CertFailures failures,  
    8282                                                      SvnAuthSslServerCertInfo certInfo,  
    8383                                                      bool maySave, IntPtr pool); 
     
    9898        { 
    9999            IntPtr authObj; 
    100             SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 
     100            SvnDelegate auth = new SvnDelegate(promptFunc); 
     101            Debug.Write(String.Format("svn_client_get_simple_prompt_provider([callback:{0}],{1:X},{2},{3})...",promptFunc.Method.Name,promptBaton.ToInt32(),retryLimit,pool)); 
    101102            Svn.svn_client_get_simple_prompt_provider(out authObj,  
    102103                                            (Svn.svn_auth_simple_prompt_func_t) auth.Wrapper,  
    103104                                            promptBaton, retryLimit, pool); 
     105            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    104106            return(new SvnAuthProviderObject(authObj,auth)); 
    105107        } 
     
    110112        { 
    111113            IntPtr authObj;  
    112             SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 
     114            SvnDelegate auth = new SvnDelegate(promptFunc); 
     115            Debug.Write(String.Format("svn_client_get_username_prompt_provider([callback:{0}],{1:X},{2},{3})...",promptFunc.Method.Name,promptBaton.ToInt32(),retryLimit,pool)); 
    113116            Svn.svn_client_get_username_prompt_provider(out authObj,  
    114117                                            (Svn.svn_auth_username_prompt_func_t) auth.Wrapper,  
    115118                                            promptBaton, retryLimit, pool); 
     119            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    116120            return(new SvnAuthProviderObject(authObj,auth)); 
    117121        } 
     
    120124        { 
    121125            IntPtr authObj; 
     126            Debug.Write(String.Format("svn_client_get_simple_provider({0:X})",pool)); 
    122127            Svn.svn_client_get_simple_provider(out authObj, pool);  
     128            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    123129            return(new SvnAuthProviderObject(authObj)); 
    124130        } 
     
    127133        { 
    128134            IntPtr authObj;  
     135            Debug.Write(String.Format("svn_client_get_username_provider({0:X})",pool)); 
    129136            Svn.svn_client_get_username_provider(out authObj, pool);  
     137            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    130138            return(new SvnAuthProviderObject(authObj)); 
    131139        } 
     
    134142        { 
    135143            IntPtr authObj;  
     144            Debug.Write(String.Format("svn_client_get_ssl_server_trust_file_provider({0:X})",pool)); 
    136145            Svn.svn_client_get_ssl_server_trust_file_provider(out authObj, pool);  
     146            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    137147            return(new SvnAuthProviderObject(authObj)); 
    138148        } 
     
    141151        { 
    142152            IntPtr authObj;  
     153            Debug.Write(String.Format("svn_client_get_ssl_client_cert_file_provider({0:X})",pool)); 
    143154            Svn.svn_client_get_ssl_client_cert_file_provider(out authObj, pool);  
     155            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    144156            return(new SvnAuthProviderObject(authObj)); 
    145157        } 
     
    148160        { 
    149161            IntPtr authObj;  
     162            Debug.Write(String.Format("svn_client_get_ssl_client_cert_pw_file_provider({0:X})",pool)); 
    150163            Svn.svn_client_get_ssl_client_cert_pw_file_provider(out authObj, pool);  
     164            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    151165            return(new SvnAuthProviderObject(authObj)); 
    152166        } 
     
    157171        { 
    158172            IntPtr authObj;  
    159             SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 
     173            SvnDelegate auth = new SvnDelegate(promptFunc); 
     174            Debug.Write(String.Format("svn_client_get_ssl_server_trust_prompt_provider([callback:{0}],{1:X},{2})...",promptFunc.Method.Name,promptBaton.ToInt32(),pool)); 
    160175            Svn.svn_client_get_ssl_server_trust_prompt_provider(out authObj,  
    161176                                        (Svn.svn_auth_ssl_server_trust_prompt_func_t) auth.Wrapper,  
    162177                                        promptBaton, pool); 
     178            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    163179            return(new SvnAuthProviderObject(authObj,auth)); 
    164180        } 
     
    169185        { 
    170186            IntPtr authObj;  
    171             SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 
     187            SvnDelegate auth = new SvnDelegate(promptFunc); 
     188            Debug.Write(String.Format("svn_client_get_ssl_client_cert_prompt_provider([callback:{0}],{1},{2},{3})...",auth.Wrapper,promptBaton,retryLimit,pool)); 
    172189            Svn.svn_client_get_ssl_client_cert_prompt_provider(out authObj,  
    173190                                        (Svn.svn_auth_ssl_client_cert_prompt_func_t) auth.Wrapper,  
    174191                                        promptBaton, retryLimit, pool); 
     192            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    175193            return(new SvnAuthProviderObject(authObj,auth)); 
    176194        } 
     
    181199        { 
    182200            IntPtr authObj;  
    183             SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 
     201            SvnDelegate auth = new SvnDelegate(promptFunc); 
     202            Debug.Write(String.Format("svn_client_get_ssl_client_cert_pw_prompt_provider([callback:{0}],{1:X},{2},{3})...",promptFunc.Method.Name,promptBaton.ToInt32(),retryLimit,pool)); 
    184203            Svn.svn_client_get_ssl_client_cert_pw_prompt_provider(out authObj,  
    185204                                        (Svn.svn_auth_ssl_client_cert_pw_prompt_func_t) auth.Wrapper,  
    186205                                        promptBaton, retryLimit, pool); 
     206            Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 
    187207            return(new SvnAuthProviderObject(authObj,auth)); 
    188208        } 
    189209        #endregion 
    190210    } 
    191      
    192     internal class SvnAuthProvider 
    193     { 
    194         object mFunc; 
    195         object mWrapperFunc; 
    196          
    197         public SvnAuthProvider(SvnAuthProviderObject.SimplePrompt func) 
    198         { 
    199             mFunc = func; 
    200             mWrapperFunc = new Svn.svn_auth_simple_prompt_func_t(SvnAuthSimplePrompt); 
    201         } 
    202          
    203         public SvnAuthProvider(SvnAuthProviderObject.UsernamePrompt func) 
    204         { 
    205             mFunc = func; 
    206             mWrapperFunc = new Svn.svn_auth_username_prompt_func_t(SvnAuthUsernamePrompt); 
    207         } 
    208  
    209         public SvnAuthProvider(SvnAuthProviderObject.SslServerTrustPrompt func) 
    210         { 
    211             mFunc = func; 
    212             mWrapperFunc = new Svn.svn_auth_ssl_server_trust_prompt_func_t(SvnAuthSslServerTrustPrompt); 
    213         } 
    214  
    215         public SvnAuthProvider(SvnAuthProviderObject.SslClientCertPrompt func) 
    216         { 
    217             mFunc = func; 
    218             mWrapperFunc = new Svn.svn_auth_ssl_client_cert_prompt_func_t(SvnAuthSslClientCertPrompt); 
    219         } 
    220  
    221         public SvnAuthProvider(SvnAuthProviderObject.SslClientCertPwPrompt func) 
    222         { 
    223             mFunc = func; 
    224             mWrapperFunc = new Svn.svn_auth_ssl_client_cert_pw_prompt_func_t(SvnAuthSslClientCertPwPrompt); 
    225         } 
    226          
    227         public object Wrapper 
    228         { 
    229             get 
    230             { 
    231                 return(mWrapperFunc); 
    232             } 
    233         } 
    234          
    235         private IntPtr SvnAuthSimplePrompt(out IntPtr cred, IntPtr baton,  
    236                                            IntPtr realm, IntPtr username,  
    237                                            int may_save, IntPtr pool) 
    238         { 
    239             cred = IntPtr.Zero; 
    240             SvnError err = SvnError.NoError; 
    241             SvnAuthProviderObject.SimplePrompt func =  
    242                                     mFunc as SvnAuthProviderObject.SimplePrompt; 
    243             if( func == null ) { 
    244                 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function"); 
    245                 return(err); 
    246             } 
    247             try { 
    248                 SvnAuthCredSimple credSimple; 
    249                 err = func(out credSimple, baton, 
    250                            new AprString(realm), new AprString(username),  
    251                            (may_save != 0), new AprPool(pool)); 
    252                 cred = credSimple; 
    253             } 
    254             catch( SvnException e ) { 
    255                 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message); 
    256             } 
    257             catch( Exception e ) { 
    258                 err = SvnError.Create(215000, SvnError.NoError, e.Message); 
    259             } 
    260             return(err); 
    261         } 
    262  
    263         private  IntPtr SvnAuthUsernamePrompt(out IntPtr cred, IntPtr baton,  
    264                                               IntPtr realm, int may_save,  
    265                                               IntPtr pool) 
    266         { 
    267             cred = IntPtr.Zero; 
    268             SvnError err = SvnError.NoError; 
    269             SvnAuthProviderObject.UsernamePrompt func =  
    270                                     mFunc as SvnAuthProviderObject.UsernamePrompt; 
    271             if( func == null ) { 
    272                 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function"); 
    273                 return(err); 
    274             } 
    275             try { 
    276                 SvnAuthCredUsername credUsername; 
    277                 err = func(out credUsername, baton, 
    278                            new AprString(realm),   
    279                            (may_save != 0), new AprPool(pool)); 
    280                 cred = credUsername; 
    281             } 
    282             catch( SvnException e ) { 
    283                 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message); 
    284             } 
    285             catch( Exception e ) { 
    286                 err = SvnError.Create(215000, SvnError.NoError, e.Message); 
    287             } 
    288             return(err); 
    289         } 
    290                                                                 
    291         //[CLSCompliant(false)] 
    292         private  IntPtr SvnAuthSslServerTrustPrompt(out IntPtr cred, IntPtr baton,  
    293                                                     IntPtr realm, uint failures,  
    294                                                     IntPtr cert_info,  
    295                                                     int may_save, IntPtr pool) 
    296         { 
    297             cred = IntPtr.Zero; 
    298             SvnError err = SvnError.NoError; 
    299             SvnAuthProviderObject.SslServerTrustPrompt func =  
    300                                     mFunc as SvnAuthProviderObject.SslServerTrustPrompt; 
    301             if( func == null ) { 
    302                 err = SvnError.Create(0,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function"); 
    303                 return(err); 
    304             } 
    305             try { 
    306                 SvnAuthCredSslServerTrust credSslServerTrust; 
    307                 err = func(out credSslServerTrust, baton, 
    308                            new AprString(realm), unchecked((int)failures), 
    309                            new SvnAuthSslServerCertInfo(cert_info),  
    310                            (may_save != 0), new AprPool(pool)); 
    311                 cred = credSslServerTrust; 
    312             } 
    313             catch( SvnException e ) { 
    314                 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message); 
    315             } 
    316             catch( Exception e ) { 
    317                 err = SvnError.Create(215000, SvnError.NoError, e.Message); 
    318             } 
    319             return(err); 
    320         } 
    321  
    322         private  IntPtr SvnAuthSslClientCertPrompt(out IntPtr cred, IntPtr baton, 
    323                                                    IntPtr realm, int may_save, 
    324                                                    IntPtr pool) 
    325         { 
    326             cred = IntPtr.Zero; 
    327             SvnError err = SvnError.NoError; 
    328             SvnAuthProviderObject.SslClientCertPrompt func =  
    329                                     mFunc as SvnAuthProviderObject.SslClientCertPrompt; 
    330             if( func == null ) { 
    331                 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function"); 
    332                 return(err); 
    333             } 
    334             try { 
    335                 SvnAuthCredSslClientCert credSslClientCert; 
    336                 err = func(out credSslClientCert, baton, 
    337                            new AprString(realm),  
    338                            (may_save != 0), new AprPool(pool)); 
    339                 cred = credSslClientCert; 
    340             } 
    341             catch( SvnException e ) { 
    342                 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message); 
    343             } 
    344             catch( Exception e ) { 
    345                 err = SvnError.Create(215000, SvnError.NoError, e.Message); 
    346             } 
    347             return(err); 
    348         } 
    349  
    350         private  IntPtr SvnAuthSslClientCertPwPrompt(out IntPtr cred,  
    351                                                      IntPtr baton, 
    352                                                      IntPtr realm, int may_save, 
    353                                                      IntPtr pool) 
    354         { 
    355             cred = IntPtr.Zero; 
    356             SvnError err = SvnError.NoError; 
    357             SvnAuthProviderObject.SslClientCertPwPrompt func =  
    358                                     mFunc as SvnAuthProviderObject.SslClientCertPwPrompt; 
    359             if( func == null ) { 
    360                 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function"); 
    361                 return(err); 
    362             } 
    363             try { 
    364                 SvnAuthCredSslClientCertPw credSslClientCertPw; 
    365                 err = func(out credSslClientCertPw, baton, 
    366                            new AprString(realm),   
    367                            (may_save != 0), new AprPool(pool)); 
    368                 cred = credSslClientCertPw; 
    369             } 
    370             catch( SvnException e ) { 
    371                 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message); 
    372             } 
    373             catch( Exception e ) { 
    374                 err = SvnError.Create(215000, SvnError.NoError, e.Message); 
    375             } 
    376             return(err); 
    377         } 
    378     } 
    379211} 
  • trunk/SubversionSharp/dev/src/SvnAuthSslServerCertInfo.cs

    r27 r31  
    8383            get 
    8484            { 
     85                CheckPtr(); 
    8586                return(mSslServerCertInfo->hostname); 
    8687            } 
     
    9091            get 
    9192            { 
     93                CheckPtr(); 
    9294                return(mSslServerCertInfo->fingerprint); 
    9395            } 
     
    9799            get 
    98100            { 
     101                CheckPtr(); 
    99102                return(mSslServerCertInfo->valid_from); 
    100103            } 
     
    104107            get 
    105108            { 
     109                CheckPtr(); 
    106110                return(mSslServerCertInfo->valid_until); 
    107111            } 
     
    111115            get 
    112116            { 
     117                CheckPtr(); 
    113118                return(mSslServerCertInfo->issuer_dname); 
    114119            } 
     
    118123            get 
    119124            { 
     125                CheckPtr(); 
    120126                return(mSslServerCertInfo->ascii_cert); 
    121127            } 
  • trunk/SubversionSharp/dev/src/SvnClientContext.cs

    r27 r31  
    1717{ 
    1818 
    19     public unsafe struct SvnClientContext 
     19    public unsafe class SvnClientContext 
    2020    { 
    2121        private svn_client_ctx_t *mClientContext; 
     22        private SvnAuthBaton mAuthBaton; 
     23        private SvnDelegate mNotifyFunc; 
     24        private SvnDelegate mLogMsgFunc; 
     25        private SvnDelegate mCancelFunc; 
     26        private GCHandle mHandle; 
    2227 
    2328        [StructLayout( LayoutKind.Sequential )] 
     
    2631            public IntPtr auth_baton; 
    2732            public IntPtr notify_func; 
    28             public void *notify_baton; 
     33            public IntPtr notify_baton; 
    2934            public IntPtr log_msg_func; 
    30             public void *log_msg_baton; 
     35            public IntPtr log_msg_baton; 
    3136            public IntPtr config; 
    3237            public IntPtr cancel_func; 
    33             public void *cancel_baton; 
     38            public IntPtr cancel_baton; 
    3439        } 
    3540 
     
    3843        { 
    3944            mClientContext = ptr; 
     45            mAuthBaton = new SvnAuthBaton(); 
     46            mNotifyFunc = SvnDelegate.NullFunc; 
     47            mLogMsgFunc = SvnDelegate.NullFunc; 
     48            mCancelFunc = SvnDelegate.NullFunc; 
     49            mHandle = new GCHandle(); 
    4050        } 
    4151         
     
    4353        { 
    4454            mClientContext = (svn_client_ctx_t *) ptr.ToPointer(); 
     55            mAuthBaton = new SvnAuthBaton(); 
     56            mNotifyFunc = SvnDelegate.NullFunc; 
     57            mLogMsgFunc = SvnDelegate.NullFunc; 
     58            mCancelFunc = SvnDelegate.NullFunc; 
     59            mHandle = new GCHandle(); 
    4560        } 
    4661         
     
    96111 
    97112        #region Wrapper Properties 
     113        public SvnAuthBaton AuthBaton 
     114        { 
     115            get 
     116            { 
     117                CheckPtr(); 
     118                return(mAuthBaton); 
     119            } 
     120            set 
     121            { 
     122                CheckPtr(); 
     123                mAuthBaton = value; 
     124                mClientContext->auth_baton = mAuthBaton; 
     125            } 
     126        } 
     127         
     128        public SvnDelegate NotifyFunc 
     129        { 
     130            get 
     131            { 
     132                CheckPtr(); 
     133                return(mNotifyFunc); 
     134            } 
     135            set 
     136            { 
     137                CheckPtr(); 
     138                mNotifyFunc = value; 
     139                mClientContext->notify_func = mNotifyFunc.WrapperPtr; 
     140                //fixed(IntPtr *ptr = &(mClientContext->notify_func)) 
     141                //  mNotifyFunc.MarshalWrapperToPtr(new IntPtr(ptr)); 
     142            } 
     143        } 
     144 
     145        public IntPtr NotifyBaton 
     146        { 
     147            get 
     148            { 
     149                CheckPtr(); 
     150                return(mClientContext->notify_baton); 
     151 
     152            } 
     153            set 
     154            { 
     155                CheckPtr(); 
     156                mClientContext->notify_baton = value; 
     157            } 
     158        } 
     159 
     160        public SvnDelegate LogMsgFunc 
     161        { 
     162            get 
     163            { 
     164                CheckPtr(); 
     165                return(mLogMsgFunc); 
     166            } 
     167            set 
     168            { 
     169                CheckPtr(); 
     170                mLogMsgFunc = value; 
     171                mClientContext->log_msg_func = mLogMsgFunc.WrapperPtr; 
     172                //fixed(IntPtr *ptr = &(mClientContext->log_msg_func)) 
     173                //  mLogMsgFunc.MarshalWrapperToPtr(new IntPtr(ptr)); 
     174            } 
     175        } 
     176 
     177        public IntPtr LogMsgBaton 
     178        { 
     179            get 
     180            { 
     181                CheckPtr(); 
     182                return(mClientContext->log_msg_baton); 
     183 
     184            } 
     185            set 
     186            { 
     187                CheckPtr(); 
     188                mClientContext->log_msg_baton = value; 
     189            } 
     190        } 
     191         
    98192        public AprHash Config 
    99193        { 
    100194            get 
    101195            { 
     196                CheckPtr(); 
    102197                return(mClientContext->config); 
    103198            } 
    104199            set 
    105200            { 
     201                CheckPtr(); 
    106202                mClientContext->config = value; 
    107203            } 
    108204        } 
    109         #endregion 
     205         
     206        public SvnDelegate CancelFunc 
     207        { 
     208            get 
     209            { 
     210                CheckPtr(); 
     211                return(mCancelFunc); 
     212            } 
     213            set 
     214            { 
     215                CheckPtr(); 
     216                mCancelFunc = value; 
     217                mClientContext->cancel_func = mCancelFunc.WrapperPtr; 
     218                //fixed(IntPtr *ptr = &(mClientContext->cancel_func)) 
     219                //  mCancelFunc.MarshalWrapperToPtr(new IntPtr(ptr)); 
     220            } 
     221        } 
     222 
     223        public IntPtr CancelBaton 
     224        { 
     225            get 
     226            { 
     227                CheckPtr(); 
     228                return(mClientContext->cancel_baton); 
     229 
     230            } 
     231            set 
     232            { 
     233                CheckPtr(); 
     234                mClientContext->cancel_baton = value; 
     235            } 
     236        } 
     237        #endregion 
    110238    } 
    111239} 
  • trunk/SubversionSharp/dev/src/SvnConfig.cs

    r8 r31  
    7777        public static void Ensure(AprPool pool) 
    7878        { 
    79             Debug.WriteLine(String.Format("svn_config_ensure({0},{1})",IntPtr.Zero,pool)); 
     79            Debug.WriteLine(String.Format("svn_config_ensure(NULL,{0})",pool)); 
    8080            SvnError err = Svn.svn_config_ensure(IntPtr.Zero, pool); 
    8181            if(!err.IsNoError) 
     
    102102        { 
    103103            IntPtr h; 
    104             Debug.WriteLine(String.Format("svn_config_get_config({0},{1})",IntPtr.Zero,pool)); 
     104            Debug.WriteLine(String.Format("svn_config_get_config(NULL,{0})",pool)); 
    105105            SvnError err = Svn.svn_config_get_config(out h, IntPtr.Zero, pool); 
    106106            if(!err.IsNoError) 
  • trunk/SubversionSharp/dev/src/SvnError.cs

    r27 r31  
    4242        } 
    4343         
    44         public static SvnError NoError
     44        public static SvnError NoError = new SvnError(IntPtr.Zero)
    4545         
    4646        public bool IsNoError 
     
    6565        public static implicit operator IntPtr(SvnError error) 
    6666        { 
    67             return new IntPtr(error.mError); 
     67            if( error.IsNoError ) 
     68                return IntPtr.Zero; 
     69            else 
     70                return new IntPtr(error.mError); 
    6871        } 
    6972         
  • trunk/SubversionSharp/dev/src/SvnNullReferenceException.cs

    r18 r31  
    4242               : base ( error ) 
    4343        { 
     44            error.Clear(); 
    4445        } 
    4546         
     
    4748               : base ( error, innerException ) 
    4849        { 
     50            error.Clear(); 
    4951        } 
    5052 
  • trunk/SubversionSharp/test/src/Main.cs

    r21 r31  
    33using System.Diagnostics; 
    44using System.Collections; 
     5using System.Runtime.InteropServices; 
    56using Softec.AprSharp; 
    67using Softec.SubversionSharp; 
     
    1718        ctx.Config = SvnConfig.GetConfig(pool); 
    1819         
    19         ArrayList authObj = new ArrayList(); 
    20         authObj.Add(SvnAuthProviderObject.GetSimpleProvider(pool)); 
    21         authObj.Add(SvnAuthProviderObject.GetUsernameProvider(pool)); 
    22         authObj.Add(SvnAuthProviderObject.GetSslServerTrustFileProvider(pool)); 
    23         authObj.Add(SvnAuthProviderObject.GetSslClientCertFileProvider(pool)); 
    24         authObj.Add(SvnAuthProviderObject.GetSslClientCertPwFileProvider(pool)); 
    25         authObj.Add(SvnAuthProviderObject.GetPromptProvider( 
     20        ArrayList authObjs = new ArrayList(); 
     21        authObjs.Add(SvnAuthProviderObject.GetSimpleProvider(pool)); 
     22        authObjs.Add(SvnAuthProviderObject.GetUsernameProvider(pool)); 
     23        authObjs.Add(SvnAuthProviderObject.GetSslServerTrustFileProvider(pool)); 
     24        authObjs.Add(SvnAuthProviderObject.GetSslClientCertFileProvider(pool)); 
     25        authObjs.Add(SvnAuthProviderObject.GetSslClientCertPwFileProvider(pool)); 
     26        authObjs.Add(SvnAuthProviderObject.GetPromptProvider( 
    2627                        new SvnAuthProviderObject.SimplePrompt(SimpleAuth), 
    2728                        IntPtr.Zero, 2, pool)); 
    28         authObj.Add(SvnAuthProviderObject.GetPromptProvider( 
     29        authObjs.Add(SvnAuthProviderObject.GetPromptProvider( 
    2930                        new SvnAuthProviderObject.UsernamePrompt(UsernameAuth), 
    3031                        IntPtr.Zero, 2, pool)); 
     32        authObjs.Add(SvnAuthProviderObject.GetPromptProvider( 
     33                        new SvnAuthProviderObject.SslServerTrustPrompt(SslServerTrustAuth), 
     34                        IntPtr.Zero, pool)); 
     35        ctx.AuthBaton = SvnAuthBaton.Open(authObjs,pool); 
     36        ctx.NotifyFunc = new SvnDelegate(new SvnWcNotify.Func(NotifyCallback)); 
     37        ctx.LogMsgFunc = new SvnDelegate(new SvnClient.GetCommitLog(GetCommitLogCallback)); 
     38        ctx.CancelFunc = new SvnDelegate(new Svn.CancelFunc(CancelCallback)); 
    3139         
    32          
     40        GCHandle h; 
     41        SvnOptRevision revision = SvnOptRevision.Alloc(out h); 
     42        try 
     43        { 
     44            revision.Number = 100; 
     45            SvnClient.SvnClientCheckout("https://www.softec.st/svn/test",  
     46                                        "/home/denisg/dev/lib/SubversionSharp/test/bin/Debug/test", 
     47                                        revision, true, ctx, pool); 
     48                                         
     49            revision.Kind = SvnOptRevision.RevisionKind.Head; 
     50            SvnClient.SvnClientUpdate("/home/denisg/dev/lib/SubversionSharp/test/bin/Debug/test", 
     51                                      revision, true,   ctx, pool); 
     52        } 
     53        finally 
     54        { 
     55            h.Free(); 
     56        }         
    3357        pool.Destroy(); 
     58    } 
     59     
     60    public static void NotifyCallback(IntPtr baton, AprString Path,   
     61                                      SvnWcNotify.Action action, Svn.NodeKind kind, 
     62                                      AprString mimeType, SvnWcNotify.State contentState, 
     63                                      SvnWcNotify.State propState, int revNum) 
     64    { 
     65    } 
     66     
     67    public static SvnError GetCommitLogCallback(out AprString logMessage, out AprString tmpFile, 
     68                                                AprArray commitItems, IntPtr baton, 
     69                                                AprPool pool) 
     70    { 
     71        if (!commitItems.IsNull) 
     72        { 
     73            foreach (SvnClientCommitItem item in gclea.CommitItems) 
     74            { 
     75                Console.WriteLine("C{0}: {1} ({2}) r{3}", 
     76                    ++mCommitCounter, 
     77                    item.Path, item.Kind, item.Revision); 
     78                Console.WriteLine("C{0}: {1} -> {2}", 
     79                    mCommitCounter, 
     80                    item.URL, 
     81                    item.CopyFromUrl); 
     82            } 
     83            Console.WriteLine(); 
     84        } 
     85         
     86        Console.Write("Enter log message: "); 
     87        logMessage = new AprString(pool, Console.ReadLine()); 
     88        tmpFile = new AprString(); 
     89         
     90        return(SvnError.NoError); 
     91    } 
     92 
     93     
     94    public static SvnError CancelCallback(IntPtr baton) 
     95    { 
     96        return(SvnError.NoError);        
    3497    } 
    3598     
     
    44107         
    45108        bool valid = false; 
    46         string line
     109        string line = ""
    47110         
    48111        while(!valid) 
     
    83146 
    84147        bool valid = false; 
    85         string line
     148        string line = ""
    86149         
    87150        while(!valid) 
     
    102165        return(SvnError.NoError); 
    103166    } 
     167     
     168    public static SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred,  
     169                                              IntPtr baton, AprString realm,  
     170                                              SvnAuthCredSslServerTrust.CertFailures failures,  
     171                                              SvnAuthSslServerCertInfo certInfo,  
     172                                              bool maySave, IntPtr pool) 
     173    { 
     174        Console.WriteLine("Ssl Server Trust Prompt:"); 
     175        Console.WriteLine("------------------------"); 
     176        Console.WriteLine(""); 
     177         
     178        Console.WriteLine("Error validating server certificate for '{0}':", realm); 
     179        if ((failures & SvnAuthCredSslServerTrust.CertFailures.UnknownCA) > 0) 
     180            Console.WriteLine(" - The certificate is not issued by a trusted authority"); 
     181        if ((failures & SvnAuthCredSslServerTrust.CertFailures.CNMismatch) > 0) 
     182            Console.WriteLine(" - The certificate hostname does not match"); 
     183        if ((failures & SvnAuthCredSslServerTrust.CertFailures.NotYetValid) > 0) 
     184            Console.WriteLine(" - The certificate is not yet valid"); 
     185        if ((failures & SvnAuthCredSslServerTrust.CertFailures.Expired) > 0) 
     186            Console.WriteLine(" - The certificate has expired"); 
     187        if ((failures & SvnAuthCredSslServerTrust.CertFailures.Other) > 0) 
     188            Console.WriteLine(" - The certificate has an unknown error"); 
     189     
     190        Console.WriteLine("Certificate informations:"); 
     191        Console.WriteLine("\tHostName:    " + certInfo.Hostname); 
     192        Console.WriteLine("\tIssuer:      " + certInfo.IssuerDName); 
     193        Console.WriteLine("\tValid From:  " + certInfo.ValidFrom); 
     194        Console.WriteLine("\tValid Until: " + certInfo.ValidUntil); 
     195        Console.WriteLine("\tFingerprint: " + certInfo.Fingerprint); 
     196     
     197        cred = SvnAuthCredSslServerTrust.Alloc(pool); 
     198        bool valid = false; 
     199        while (!valid) 
     200        { 
     201            if (maySave) 
     202                Console.WriteLine("(R)eject, accept (t)emporarily or accept (p)ermanently? "); 
     203            else 
     204                Console.WriteLine("(R)eject or accept (t)emporarily? "); 
     205                 
     206            string line = Console.ReadLine(); 
     207            if (line.Length > 0) 
     208            { 
     209                char choice = line.ToLower()[0]; 
     210                if (choice == 'r') 
     211                { 
     212                    cred.AcceptedFailures = 0; 
     213                    cred.MaySave=false; 
     214                    valid = true; 
     215                } 
     216                else if (choice == 't') 
     217                { 
     218                    cred.AcceptedFailures = failures; 
     219                    cred.MaySave=false; 
     220                    valid = true; 
     221                } 
     222                else if (choice == 'p') 
     223                { 
     224                    cred.AcceptedFailures = failures; 
     225                    cred.MaySave=true; 
     226                    valid = true; 
     227                } 
     228            } 
     229        } 
     230        return(SvnError.NoError); 
     231    } 
    104232}