Пример #1
0
        static IntPtr _libsvnsharp_cancel_func(IntPtr cancelBaton)
        {
            var client = AprBaton <SvnClientContext> .Get(cancelBaton);

            SvnCancelEventArgs ea = new SvnCancelEventArgs();

            try
            {
                client.HandleClientCancel(ea);

                if (ea.Cancel)
                {
                    return(svn_error.svn_error_create(
                               (int)SvnErrorCode.SVN_ERR_CANCELLED,
                               null,
                               "Operation canceled from OnCancel").__Instance);
                }

                return(IntPtr.Zero);
            }
            catch (Exception e)
            {
                return(SvnException.CreateExceptionSvnError("Cancel function", e).__Instance);
            }
            finally
            {
                ea.Detach(false);
            }
        }
Пример #2
0
        static unsafe IntPtr _svn_wc_conflict_resolver_func(
            void **resultPtr, IntPtr descriptionPtr, IntPtr baton, IntPtr resultPoolPtr, IntPtr scratchPoolPtr)
        {
            var client = AprBaton <SvnClient> .Get(baton);

            var conflictResult = svn_wc.svn_wc_create_conflict_result(
                svn_wc_conflict_choice_t.svn_wc_conflict_choose_postpone,
                null,
                apr_pool_t.__CreateInstance(resultPoolPtr));

            *resultPtr = conflictResult.__Instance.ToPointer();

            var resultPool  = new AprPool(resultPoolPtr, false);  // Connect to parent pool
            var scratchPool = new AprPool(scratchPoolPtr, false); // Connect to parent pool

            var description = svn_wc_conflict_description2_t.__CreateInstance(descriptionPtr);

            var ea = new SvnConflictEventArgs(description, scratchPool);

            try
            {
                client.HandleClientConflict(ea);

                if (ea.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Operation canceled from OnConflict").__Instance);
                }

                conflictResult.choice = (svn_wc_conflict_choice_t)ea.Choice;

                if (ea.Choice == SvnAccept.Merged)
                {
                    if (ea.MergedValue != null)
                    {
                        conflictResult.merged_value = resultPool.AllocSvnString(ea.MergedValue);
                    }
                    if (ea.MergedFile != null)
                    {
                        conflictResult.merged_file = resultPool.AllocAbsoluteDirent(ea.MergedFile);
                    }
                }

                return(IntPtr.Zero);
            }
            catch (Exception e)
            {
                return(SvnException.CreateExceptionSvnError("Conflict resolver", e).__Instance);
            }
            finally
            {
                ea.Detach(false);

                scratchPool.Dispose();
                resultPool.Dispose();
            }
        }
Пример #3
0
        static unsafe /*svn_error_t*/ IntPtr _svn_auth_ssl_server_trust_prompt_func(
            /*out svn_auth_cred_ssl_server_trust_t*/ void **ppCred, IntPtr baton, sbyte *realm, uint failures, /*svn_auth_ssl_server_cert_info_t*/ IntPtr certInfo, int maySave, /*apr_pool_t*/ IntPtr pool)
        {
            var wrapper = AprBaton <SvnAuthWrapper <SvnSslServerTrustEventArgs> > .Get(baton);

            var certInfoT = svn_auth_ssl_server_cert_info_t.__CreateInstance(certInfo);

            var args = new SvnSslServerTrustEventArgs(
                (SvnCertificateTrustFailures)failures,
                SvnBase.Utf8_PtrToString(certInfoT.hostname),
                SvnBase.Utf8_PtrToString(certInfoT.fingerprint),
                SvnBase.Utf8_PtrToString(certInfoT.valid_from),
                SvnBase.Utf8_PtrToString(certInfoT.valid_until),
                SvnBase.Utf8_PtrToString(certInfoT.issuer_dname),
                SvnBase.Utf8_PtrToString(certInfoT.ascii_cert),
                SvnBase.Utf8_PtrToString(realm), maySave != 0);

            var cred = (svn_auth_cred_ssl_server_trust_t.__Internal * *)ppCred;

            using (var tmpPool = new AprPool(pool, false))
            {
                *cred = null;
                try
                {
                    wrapper.Raise(args);
                }
                catch (Exception e)
                {
                    return(SvnException.CreateExceptionSvnError("Authorization handler", e).__Instance);
                }

                if (args.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Authorization canceled operation").__Instance);
                }
                if (args.Break)
                {
                    return(IntPtr.Zero);
                }

                if (args.AcceptedFailures != SvnCertificateTrustFailures.None)
                {
                    *cred = (svn_auth_cred_ssl_server_trust_t.__Internal *)tmpPool.AllocCleared(
                        sizeof(svn_auth_cred_ssl_server_trust_t.__Internal));

                    (*cred)->accepted_failures = (uint)args.AcceptedFailures;
                    (*cred)->may_save          = args.Save ? 1 : 0;
                }
            }

            return(IntPtr.Zero);
        }
Пример #4
0
        static unsafe IntPtr _libsvnsharp_commit_log_func(
            sbyte **logMsg, sbyte **tmpFile, IntPtr commitItemsPtr, IntPtr baton, IntPtr pool)
        {
            var client = AprBaton <SvnClientContext> .Get(baton);

            var tmpPool = new AprPool(pool, false);

            var commit_items = apr_array_header_t.__CreateInstance(commitItemsPtr);

            var ea = new SvnCommittingEventArgs(commit_items, client.CurrentCommandArgs.CommandType, tmpPool);

            *logMsg  = null;
            *tmpFile = null;

            try
            {
                client.HandleClientCommitting(ea);

                if (ea.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Operation canceled from OnCommitting").__Instance);
                }
                else if (ea.LogMessage != null)
                {
                    *logMsg = tmpPool.AllocUnixString(ea.LogMessage);
                }
                else if (!client._noLogMessageRequired)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Commit canceled: A logmessage is required").__Instance);
                }
                else
                {
                    *logMsg = tmpPool.AllocString("");
                }

                return(IntPtr.Zero);
            }
            catch (Exception e)
            {
                return(SvnException.CreateExceptionSvnError("Commit log", e).__Instance);
            }
            finally
            {
                ea.Detach(false);

                tmpPool.Dispose();
            }
        }
Пример #5
0
        static unsafe IntPtr svnStreamSeek(IntPtr baton, IntPtr mark)
        {
            SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton);

            long newPos = 0;

            if (mark != IntPtr.Zero)
            {
                newPos = *(long *)mark.ToPointer();
            }

            try
            {
                sw.Stream.Position = newPos;
            }
            catch (Exception ex)
            {
                return(SvnException.CreateExceptionSvnError("Seek stream", ex).__Instance);
            }

            return(IntPtr.Zero);
        }
Пример #6
0
        static IntPtr the_commit_callback2(IntPtr commit_info_ptr, IntPtr baton, IntPtr pool)
        {
            var tmpPool  = new AprPool(pool, false);
            var receiver = AprBaton <CommitResultReceiver> .Get(baton);

            try
            {
                var commit_info = svn_commit_info_t.__CreateInstance(commit_info_ptr);

                receiver.ProvideCommitResult(commit_info, tmpPool);

                return(IntPtr.Zero);
            }
            catch (Exception e)
            {
                return(SvnException.CreateExceptionSvnError("CommitResult function", e).__Instance);
            }
            finally
            {
                tmpPool.Dispose();
            }
        }
Пример #7
0
        static unsafe /*svn_error_t*/ IntPtr _svn_auth_simple_prompt_func(
            /*out svn_auth_cred_simple_t*/ void **credPtr, IntPtr baton, sbyte *realm, sbyte *username, int maySave, /*apr_pool_t*/ IntPtr pool)
        {
            var wrapper = AprBaton <SvnAuthWrapper <SvnUserNamePasswordEventArgs> > .Get(baton);

            var args = new SvnUserNamePasswordEventArgs(SvnBase.Utf8_PtrToString(username), SvnBase.Utf8_PtrToString(realm), maySave != 0);

            var cred = (svn_auth_cred_simple_t.__Internal * *)credPtr;

            using (var tmpPool = new AprPool(pool, false))
            {
                *cred = null;
                try
                {
                    wrapper.Raise(args);
                }
                catch (Exception e)
                {
                    return(SvnException.CreateExceptionSvnError("Authorization handler", e).__Instance);
                }

                if (args.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Authorization canceled operation").__Instance);
                }
                if (args.Break)
                {
                    return(IntPtr.Zero);
                }

                *cred = (svn_auth_cred_simple_t.__Internal *)tmpPool.AllocCleared(sizeof(svn_auth_cred_simple_t.__Internal));

                (*cred)->username = new IntPtr(tmpPool.AllocString(args.UserName));
                (*cred)->password = new IntPtr(tmpPool.AllocString(args.Password));
                (*cred)->may_save = args.Save ? 1 : 0;
            }

            return(IntPtr.Zero);
        }