org_tigris_subversion_javahl_svnclient.cpp

来自「linux subdivision ying gai ke yi le ba」· C++ 代码 · 共 1,380 行 · 第 1/3 页

CPP
1,380
字号
/**
 * @copyright
 * ====================================================================
 * Copyright (c) 2003 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 * @endcopyright
 *
 * @file org_tigris_subversion_javahl_SVNClient.cpp
 * @brief Implementation of the native methods in the java class SVNClient
 */
#include "../include/org_tigris_subversion_javahl_SVNClient.h"
#include "../include/org_tigris_subversion_javahl_SVNClientLogLevel.h"
#include "JNIUtil.h"
#include "JNIStackElement.h"
#include "JNIStringHolder.h"
#include "JNIByteArray.h"
#include "SVNClient.h"
#include "Revision.h"
#include "Notify.h"
#include "CommitMessage.h"
#include "Prompter.h"
#include "Targets.h"
#include "BlameCallback.h"
#include "svn_version.h"
#include "svn_private_config.h"
#include "version.h"
#include "Outputer.h"
#include <iostream>
/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    ctNative
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_org_tigris_subversion_javahl_SVNClient_ctNative
  (JNIEnv* env, jobject jthis)
{
    JNIEntry(SVNClient, ctNative);
    SVNClient *obj = new SVNClient;
    return obj->getCppAddr();
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    dispose
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_dispose
  (JNIEnv* env, jobject jthis)
{
    JNIEntry(SVNClient, dispose);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    cl->dispose(jthis);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    finalize
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_finalize
  (JNIEnv* env, jobject jthis)
{
    JNIEntry(SVNClient, finalize);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl != NULL)
    {
        cl->finalize();
    }
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    getLastPath
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_org_tigris_subversion_javahl_SVNClient_getLastPath
  (JNIEnv* env, jobject jthis)
{
    JNIEntry(Client, getLastPath);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return NULL;
    }
    const char *ret = cl->getLastPath();
    return JNIUtil::makeJString(ret);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    list
 * Signature: (Ljava/lang/String;Lorg/tigris/subversion/javahl/Revision;Z)
 *            [Lorg/tigris/subversion/javahl/DirEntry;
 */
JNIEXPORT jobjectArray JNICALL Java_org_tigris_subversion_javahl_SVNClient_list
  (JNIEnv* env, jobject jthis, jstring jurl, jobject jrevision, 
   jboolean jrecurse)
{
    JNIEntry(SVNClient, list);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        return NULL;
    }
    JNIStringHolder url(jurl);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    Revision revision(jrevision);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    return cl->list(url, revision, jrecurse ? true:false);

}
/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    status
 * Signature: (Ljava/lang/String;ZZZZ)[Lorg/tigris/subversion/javahl/Status;
 */
JNIEXPORT jobjectArray JNICALL Java_org_tigris_subversion_javahl_SVNClient_status
  (JNIEnv* env, jobject jthis, jstring jpath, jboolean jrecurse, 
   jboolean jonServer, jboolean jgetAll, jboolean jnoIgnore)
{
    JNIEntry(SVNClient, status);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        return NULL;
    }
    JNIStringHolder path(jpath);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    return cl->status(path, jrecurse ? true: false, jonServer ? true:false, 
                      jgetAll ? true:false, jnoIgnore ? true:false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    singleStatus
 * Signature: (Ljava/lang/String;ZZ)Lorg/tigris/subversion/javahl/Status;
 */
JNIEXPORT jobject JNICALL Java_org_tigris_subversion_javahl_SVNClient_singleStatus
  (JNIEnv* env, jobject jthis, jstring jpath, jboolean jonServer)
{
    JNIEntry(SVNClient, singleStatus);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        return NULL;
    }
    JNIStringHolder path(jpath);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    return cl->singleStatus(path, jonServer ? true:false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    username
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_username
  (JNIEnv* env, jobject jthis, jstring jusername)
{
    JNIEntry(SVNClient, username);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    JNIStringHolder username(jusername);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->username(username);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    password
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_password
  (JNIEnv* env, jobject jthis, jstring jpassword)
{
    JNIEntry(SVNClient, password);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    JNIStringHolder password(jpassword);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->password(password);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    setPrompt
 * Signature: (Lorg/tigris/subversion/javahl/PromptUserPassword;)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_setPrompt
  (JNIEnv* env, jobject jthis, jobject jprompter)
{
    JNIEntry(SVNClient, setPrompt);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    Prompter *prompter = Prompter::makeCPrompter(jprompter);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->setPrompt(prompter);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    logMessages
 * Signature: (Ljava/lang/String;Lorg/tigris/subversion/javahl/Revision;Lorg/tigris/subversion/javahl/Revision;ZZ)[Lorg/tigris/subversion/javahl/LogMessage;
 */
JNIEXPORT jobjectArray JNICALL Java_org_tigris_subversion_javahl_SVNClient_logMessages
  (JNIEnv* env, jobject jthis, jstring jpath, jobject jrevisionStart,
   jobject jrevisionEnd, jboolean jstopOnCopy, jboolean jdisoverPaths)
{
    JNIEntry(SVNClient, logMessages);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return NULL;
    }
    Revision revisionStart(jrevisionStart, false, true);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    Revision revisionEnd(jrevisionEnd, true);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    JNIStringHolder path(jpath);
    if(JNIUtil::isExceptionThrown())
    {
        return NULL;
    }
    return cl->logMessages(path, revisionStart, revisionEnd,
        jstopOnCopy ? true: false, jdisoverPaths ? true : false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    checkout
 * Signature: (Ljava/lang/String;Ljava/lang/String;
 *             Lorg/tigris/subversion/javahl/Revision;Z)J
 */
JNIEXPORT jlong JNICALL Java_org_tigris_subversion_javahl_SVNClient_checkout
  (JNIEnv* env, jobject jthis, jstring jmoduleName, jstring jdestPath, 
   jobject jrevision, jboolean jrecurse)
{
    JNIEntry(SVNClient, checkout);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return -1;
    }
    Revision revision(jrevision, true);
    if(JNIUtil::isExceptionThrown())
    {
        return -1;
    }
    JNIStringHolder moduleName(jmoduleName);
    if(JNIUtil::isExceptionThrown())
    {
        return -1;
    }
    JNIStringHolder destPath(jdestPath);
    if(JNIUtil::isExceptionThrown())
    {
        return -1;
    }
    return cl->checkout(moduleName, destPath, revision, jrecurse ? true:false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    notification
 * Signature: (Lorg/tigris/subversion/javahl/Notify;)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_notification
  (JNIEnv* env, jobject jthis, jobject jnotify)
{
    JNIEntry(SVNClient, notification);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    Notify *notify = Notify::makeCNotify(jnotify);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->notification(notify);
}
/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    commitMessageHandler
 * Signature: (Lorg/tigris/subversion/javahl/CommitMessage;)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_commitMessageHandler
  (JNIEnv *env, jobject jthis, jobject jcommitMessage)
{
    JNIEntry(SVNClient, commitMessageHandler);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError("bad c++ this");
        return;
    }
    CommitMessage *commitMessage = 
        CommitMessage::makeCCommitMessage(jcommitMessage);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->commitMessageHandler(commitMessage);
}
/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    remove
 * Signature: (Ljava/lang/String;Ljava/lang/String;Z)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_remove
  (JNIEnv* env, jobject jthis, jobjectArray jtargets, jstring jmessage, 
   jboolean jforce)
{
    JNIEntry(SVNClient, remove);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    Targets targets(jtargets);
    JNIStringHolder message(jmessage);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->remove(targets, message, jforce ? true : false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    revert
 * Signature: (Ljava/lang/String;Z)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_revert
  (JNIEnv* env, jobject jthis, jstring jpath, jboolean jrecurse)
{
    JNIEntry(SVNClient, revert);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    JNIStringHolder path(jpath);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->revert(path, jrecurse ? true : false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    add
 * Signature: (Ljava/lang/String;Z)V
 */
JNIEXPORT void JNICALL Java_org_tigris_subversion_javahl_SVNClient_add
  (JNIEnv* env, jobject jthis, jstring jpath, jboolean jrecurse)
{
    JNIEntry(SVNClient, add);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return;
    }
    JNIStringHolder path(jpath);
    if(JNIUtil::isExceptionThrown())
    {
        return;
    }
    cl->add(path, jrecurse ? true : false);
}

/*
 * Class:     org_tigris_subversion_javahl_SVNClient
 * Method:    update
 * Signature: (Ljava/lang/String;Lorg/tigris/subversion/javahl/Revision;Z)J
 */
JNIEXPORT jlong JNICALL Java_org_tigris_subversion_javahl_SVNClient_update
  (JNIEnv* env, jobject jthis, jstring jpath, jobject jrevision, 
   jboolean jrecurse)
{
    JNIEntry(SVNClient, update);
    SVNClient *cl = SVNClient::getCppObject(jthis);
    if(cl == NULL)
    {
        JNIUtil::throwError(_("bad c++ this"));
        return -1;
    }
    Revision revision(jrevision);
    if(JNIUtil::isExceptionThrown())
    {
        return -1;
    }
    JNIStringHolder path(jpath);
    if(JNIUtil::isExceptionThrown())
    {
        return -1;
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?