Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/subversion/bindings/javahl/native/ClientContext.cpp  view on Meta::CPAN

/**
 * @copyright
 * ====================================================================
 *    Licensed to the Apache Software Foundation (ASF) under one
 *    or more contributor license agreements.  See the NOTICE file
 *    distributed with this work for additional information
 *    regarding copyright ownership.  The ASF licenses this file
 *    to you under the Apache License, Version 2.0 (the
 *    "License"); you may not use this file except in compliance
 *    with the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing,
 *    software distributed under the License is distributed on an
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *    KIND, either express or implied.  See the License for the
 *    specific language governing permissions and limitations
 *    under the License.
 * ====================================================================
 * @endcopyright
 *
 * @file ClientContext.cpp
 * @brief Implementation of the class ClientContext
 */

#include "svn_client.h"
#include "private/svn_wc_private.h"
#include "svn_private_config.h"

#include "ClientContext.h"
#include "JNIUtil.h"
#include "JNICriticalSection.h"

#include "Prompter.h"
#include "CreateJ.h"
#include "EnumMapper.h"
#include "CommitMessage.h"


ClientContext::ClientContext(jobject jsvnclient, SVN::Pool &pool)
    : m_prompter(NULL),
      m_cancelOperation(false)
{
    JNIEnv *env = JNIUtil::getEnv();

    /* Grab a global reference to the Java object embedded in the parent Java
       object. */
    static jfieldID ctxFieldID = 0;
    if (ctxFieldID == 0)
    {
        jclass clazz = env->GetObjectClass(jsvnclient);
        if (JNIUtil::isJavaExceptionThrown())
            return;

        ctxFieldID = env->GetFieldID(clazz, "clientContext",
                                "L"JAVA_PACKAGE"/SVNClient$ClientContext;");
        if (JNIUtil::isJavaExceptionThrown() || ctxFieldID == 0)
            return;

        env->DeleteLocalRef(clazz);
    }

    jobject jctx = env->GetObjectField(jsvnclient, ctxFieldID);
    if (JNIUtil::isJavaExceptionThrown())
        return;

    m_jctx = env->NewGlobalRef(jctx);
    if (JNIUtil::isJavaExceptionThrown())
        return;

    env->DeleteLocalRef(jctx);

    SVN_JNI_ERR(svn_client_create_context2(&m_context, NULL,
                                           pool.getPool()),
                );

    /* Clear the wc_ctx as we don't want to maintain this unconditionally
       for compatibility reasons */
    SVN_JNI_ERR(svn_wc_context_destroy(m_context->wc_ctx),
                );
    m_context->wc_ctx = NULL;

    /* None of the following members change during the lifetime of
       this object. */
    m_context->notify_func = NULL;
    m_context->notify_baton = NULL;
    m_context->log_msg_func3 = CommitMessage::callback;
    m_context->log_msg_baton3 = NULL;
    m_context->cancel_func = checkCancel;
    m_context->cancel_baton = this;
    m_context->notify_func2= notify;
    m_context->notify_baton2 = m_jctx;
    m_context->progress_func = progress;
    m_context->progress_baton = m_jctx;
    m_context->conflict_func2 = resolve;
    m_context->conflict_baton2 = m_jctx;

    m_context->client_name = "javahl";
    m_pool = &pool;
}

ClientContext::~ClientContext()
{
    delete m_prompter;

    JNIEnv *env = JNIUtil::getEnv();



( run in 0.561 second using v1.01-cache-2.11-cpan-5b529ec07f3 )