3
* ====================================================================
4
* Copyright (c) 2003-2004 CollabNet. All rights reserved.
6
* This software is licensed as described in the file COPYING, which
7
* you should have received as part of this distribution. The terms
8
* are also available at http://subversion.tigris.org/license-1.html.
9
* If newer versions of this license are posted there, you may use a
10
* newer version instead, at your option.
12
* This software consists of voluntary contributions made by many
13
* individuals. For exact contribution history, see the revision
14
* history and logs, available at http://subversion.tigris.org/.
15
* ====================================================================
19
* @brief Implementation of the class BlameCallback
22
#include "BlameCallback.h"
26
* Create a BlameCallback object
27
* @param jcallback the java callback object.
29
BlameCallback::BlameCallback(jobject jcallback)
31
m_callback = jcallback;
34
* Destroy a BlameCallback object
36
BlameCallback::~BlameCallback()
38
// the m_callback does not need to be destroyed, because it is the passed
39
// in parameter to the java SVNClient.blame method.
42
* Callback called for a single line in the file, for which the blame
43
* information was requested
44
* @param revision the revision number, when the line was last changed
45
* or -1, if not changed during the request revision
48
* @param author the author, who performed the last change of the line
49
* @param date the date of the last change of the line
50
* @param line the content of the line
51
* @param pool memory pool for the use of this function
53
void BlameCallback::callback(svn_revnum_t revision, const char *author,
54
const char *date, const char *line,
57
JNIEnv *env = JNIUtil::getEnv();
59
static jmethodID mid = 0; // the method id will not change during
60
// the time this library is loaded, so
64
jclass clazz = env->FindClass(JAVA_PACKAGE"/BlameCallback");
65
if(JNIUtil::isJavaExceptionThrown())
69
mid = env->GetMethodID(clazz, "singleLine",
70
"(Ljava/util/Date;JLjava/lang/String;Ljava/lang/String;)V");
71
if(JNIUtil::isJavaExceptionThrown() || mid == 0)
75
env->DeleteLocalRef(clazz);
76
if(JNIUtil::isJavaExceptionThrown())
82
// convert the parameters to their java relatives
83
jstring jauthor = JNIUtil::makeJString(author);
84
if(JNIUtil::isJavaExceptionThrown())
89
if(date != NULL && *date != '\0')
92
svn_time_from_cstring (&timeTemp, date, pool);
94
jdate = JNIUtil::createDate(timeTemp);
95
if(JNIUtil::isJavaExceptionThrown())
100
jstring jline = JNIUtil::makeJString(line);
101
if(JNIUtil::isJavaExceptionThrown())
106
// call the java method
107
env->CallVoidMethod(m_callback, mid, jdate, (jlong)revision, jauthor,
109
if(JNIUtil::isJavaExceptionThrown())
114
// cleanup the temporary java objects
115
env->DeleteLocalRef(jline);
116
if(JNIUtil::isJavaExceptionThrown())
120
env->DeleteLocalRef(jauthor);
121
if(JNIUtil::isJavaExceptionThrown())
125
env->DeleteLocalRef(jdate);
126
if(JNIUtil::isJavaExceptionThrown())