/***************************************************************************
 * 	(C) 2000-2001 Lost Highway Ltd. All rights reserved.                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

Here are Java JNI based api bindings for KDE 2.2.

All the C++/Java files in this project are generated from the KDE 2.2 C++ headers,
apart from the following:

KDESupport.cpp
KDESupport.h
	C++ static type conversion methods; Java <--> C++
	
BUILD INSTRUCTIONS

1)  Ensure that the kdebindings/qtjava project has been built first.
    $ cd kdebindings/kdejava
    $ make
    $ make install

  The koala.jar file is installed in $(kde_libraries)/java.You will need to add
  qtjava.jar and koala.jar to your classpath.

2) That's it - you should be able to compile and run the Java example
   kdejava/koala/test/KBase.java by typing:

	$ javac KBase.java
	$ java KBase

3) If you wish to write KDE Java applications, include the following in the class which has a main() function:

	static {
		try {
			Class c = Class.forName("org.kde.qt.qtjava");
		} catch (Exception e) {
			System.out.println("Can't load qtjava class");
		}

		try {
			Class c = Class.forName("org.kde.koala.kdejava");
		} catch (Exception e) {
			System.out.println("Can't load kdejava class");
		}
	}

It will load the KDE Java 'libkdejava.so' and 'libqtjava.so' shared libraries

5) THE KDOC BASED SOURCE CONVERTER
  The source conversion process uses the parser from the kdoc package
    written by Sirtaj Singh Kang. It has a specially written
    back end to generate .java and .cpp files instead of the usual html.

  The source of this hacked version of kdoc, used to generate the Java and C++ sources,
	is in the kdejava/koala/kdoc directory. It ignores the standard kdoc
	options and always generates Java/C++. So it isn't a good idea to install
	it over the top of a working kdoc. Just leave it uninstalled, and run the
	perl 'in situ'.

Here are some of the shell commands that were used in the conversion process:

# Generate Java and C++ sources. Copy all the target headers to directory 'test/tmp' under kdoc sources
cd kdejava/koala/kdoc
perl kdoc test/tmp/*.h test/tmp/arts/*.h test/tmp/artsc/*.h test/tmp/dom/*.h test/tmp/kio/*.h \
   test/tmp/kjs/*.h test/tmp/kparts/*.h test/tmp/kdesu/*.h test/tmp/libkmid/*.h

# Shorten generated filenames
mv DOM__Node.cpp DOMNode.cpp
mv DOM__Node.java DOMNode.java
mv DOM__Document.cpp DOMDocument.cpp
mv DOM__Document.java DOMDocument.java
for FILE in *__* ; do
 NAME=`echo $FILE | sed -e 's/^.*__//'`;
 echo $NAME;
 mv $FILE $NAME;
done
mv SlaveInterface.cpp Slave.cpp
mv SlaveInterface.java Slave.java

# Edit and Compile the generated java
cd kdejava/koala/org/kde/koala
make

# Build C++ JNI .h header files
cd kdejava/koala/org/kde/koala
for FILE in *.class ; do NAME=`echo $FILE | sed 's/.class//'`; echo $NAME; javah  -classpath '../../..' org.kde.koala.$NAME ; done
for FILE in org_kde* ; do NAME=`echo $FILE | sed -e 's/org_kde_koala_//'`; echo $NAME; mv $FILE $NAME; done
# Copy headers to kde-2.0.1java/koala/kdejava

# Check that  the JNI .h function names match the .cpp ones
cd kdejava/koala/org/kde/koala
grep Java_ *.cpp | sed -e 's/^[^:]*:\([^(]*\).*/\1/'  | grep -v '[/]' | sort | uniq > cpp.fns
grep Java_ *.h | awk '{ print $4 }' |  grep -v '[/]' | sort | uniq > h.fns
kdiff h.fns cpp.fns
# Reconcile and fix any differences

# Edit and compile the generated .cpp and .h files with KDevelop

# Generate documentation
cd kdejava/koala/api
javadoc -classpath "../kdejava.jar:../../qtjava/javalib/qtjava.jar"  -author -splitindex -windowtitle  "Koala KDE 2.2.1 Java api" ../org/kde/koala/*.java

