[SCM] davmail packaging branch, master, updated. debian/4.1.0-2042-1_pre+1-19-g2445807
Alexandre Rossi
alexandre.rossi at gmail.com
Fri May 10 12:18:08 UTC 2013
The following commit has been merged in the master branch:
commit 0bb4230a5efdcd4874ecabdcc69576c3a7b20085
Author: Alexandre Rossi <alexandre.rossi at gmail.com>
Date: Fri May 10 14:16:55 2013 +0200
Imported Upstream version 4.2.1
diff --git a/build.xml b/build.xml
index 9528088..5fec007 100644
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,6 @@
<project name="DavMail" default="dist" basedir=".">
<property file="user.properties"/>
- <property name="version" value="4.1.0"/>
+ <property name="version" value="4.2.1"/>
<path id="classpath">
<pathelement location="classes"/>
@@ -29,10 +29,18 @@
</or>
</condition>
+ <condition property="is.utf8">
+ <equals arg1="${file.encoding}" arg2="UTF-8"/>
+ </condition>
+
<target name="check-java6" unless="is.java6">
<fail message="Java 6 needed to build DavMail, current version is ${ant.java.version}, check JAVA_HOME"/>
</target>
+ <target name="check-encoding" unless="is.utf8">
+ <fail message="Please force UTF-8 encoding to build debian package with set ANT_OPTS=-Dfile.encoding=UTF-8"/>
+ </target>
+
<target name="svnrelease" if="is.svn">
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml">
<classpath>
@@ -53,7 +61,7 @@
<property name="release" value="${version}"/>
</target>
- <target name="init" depends="check-java6, svnrelease, defaultrelease">
+ <target name="init" depends="check-encoding, check-java6, svnrelease, defaultrelease">
<echo message="Creating DavMail ${release} dist package"/>
<mkdir dir="target/classes"/>
</target>
@@ -136,7 +144,7 @@
<desktopentry
toFile="dist/davmail.desktop"
name="DavMail"
- comment="DavMail POP/SMTP/Caldav/LDAP Exchange Gateway"
+ comment="DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway"
exec="davmail"
icon="/usr/share/davmail/davmail.png"
categories="Network;"
@@ -144,7 +152,7 @@
<deb todir="dist"
package="davmail"
section="mail"
- depends="openjdk-7-jre|openjdk-6-jre|sun-java6-jre,libswt-gtk-3-java|libswt-gtk-3.6-java|libswt-gtk-3.5-java|libswt-gtk-3.4-java">
+ depends="openjdk-7-jre|openjdk-6-jre|oracle-java7-jre|sun-java6-jre,libswt-gtk-3-java|libswt-gtk-3.6-java|libswt-gtk-3.5-java|libswt-gtk-3.4-java,libswt-cairo-gtk-3-jni|libswt-cairo-gtk-3.5-jni">
<version upstream="${release}"/>
<maintainer email="mguessan at free.fr" name="Mickaël Guessant"/>
<description synopsis="DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway">
@@ -300,17 +308,20 @@
<copy file="src/winrun4j/davmailservice64.exe" todir="dist"/>
<zip file="dist/davmail-${release-name}.zip">
- <fileset dir="dist">
+ <zipfileset dir="dist">
<include name="lib/*.jar"/>
<include name="*.jar"/>
<include name="davmail.desktop"/>
- <include name="davmail.sh"/>
+ <exclude name="davmail.sh"/>
<!-- exclude swt jars from platform independent package -->
<exclude name="lib/swt*.jar"/>
<exclude name="lib/libgrowl-*.jar"/>
<exclude name="lib/junit-*.jar"/>
<exclude name="lib/winrun4j-*.jar"/>
- </fileset>
+ </zipfileset>
+ <zipfileset dir="dist" filemode="755">
+ <include name="davmail.sh"/>
+ </zipfileset>
</zip>
<copy todir="dist/web">
<fileset dir="src/web"/>
@@ -374,7 +385,7 @@
<antcall target="dist-deb"/>
<antcall target="dist-rpm"/>
<antcall target="dist-osx"/>
- <!-- source package -->
+ <!-- source with binary deps package -->
<tar tarfile="dist/davmail-src-${release-name}.tgz" compression="gzip" longfile="gnu">
<tarfileset prefix="davmail-src-${release-name}" dir=".">
<include name="**/*"/>
@@ -382,6 +393,29 @@
<exclude name="dist/**"/>
<exclude name="target/**"/>
<exclude name="archive/**"/>
+ <exclude name="user.properties"/>
+ </tarfileset>
+ </tar>
+ <!-- davmail source only package for GNU/Linux distributions -->
+ <tar tarfile="dist/davmail-srconly-${release-name}.tgz" compression="gzip" longfile="gnu">
+ <tarfileset prefix="davmail-${release-name}" dir=".">
+ <include name="**/*"/>
+ <exclude name="build.log"/>
+ <exclude name="dist/**"/>
+ <exclude name="target/**"/>
+ <exclude name="archive/**"/>
+ <exclude name="lib/**"/>
+ <exclude name="libgrowl/**"/>
+ <exclude name="nsis/**"/>
+ <exclude name="svnant/**"/>
+ <exclude name="jsmooth-*/**"/>
+ <exclude name="*.jsmooth"/>
+ <exclude name="user.properties"/>
+ <exclude name="src/winrun4j/**"/>
+ <exclude name="src/osx/**"/>
+ <exclude name="src/osx/**"/>
+ <exclude name="src/contribs/**"/>
+ <exclude name="*.nsi"/>
</tarfileset>
</tar>
</target>
diff --git a/davmail-setup.nsi b/davmail-setup.nsi
deleted file mode 100644
index 24dbe78..0000000
--- a/davmail-setup.nsi
+++ /dev/null
@@ -1,210 +0,0 @@
-; Script generated by the HM NIS Edit Script Wizard.
-
-; HM NIS Edit Wizard helper defines
-!define PRODUCT_NAME "DavMail"
-!define PRODUCT_VERSION "${VERSION}"
-!define PRODUCT_PUBLISHER "Mickaël Guessant"
-!define PRODUCT_WEB_SITE "http://sourceforge.net/projects/davmail"
-!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\davmail.exe"
-!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-!define PRODUCT_UNINST_ROOT_KEY "HKLM"
-
-; MUI 1.67 compatible ------
-!include "MUI.nsh"
-
-; MUI Settings
-!define MUI_ABORTWARNING
-!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
-!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
-
-; Language Selection Dialog Settings
-!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
-!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
-!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
-
-; Welcome page
-!insertmacro MUI_PAGE_WELCOME
-; License page
-!insertmacro MUI_PAGE_LICENSE "src\license.txt"
-; Directory page
-!insertmacro MUI_PAGE_DIRECTORY
-; Instfiles page
-!insertmacro MUI_PAGE_INSTFILES
-; Finish page
-!define MUI_FINISHPAGE_RUN "$INSTDIR\davmail.exe"
-!insertmacro MUI_PAGE_FINISH
-
-; Uninstaller pages
-!insertmacro MUI_UNPAGE_INSTFILES
-
-; Language files
-!insertmacro MUI_LANGUAGE "English"
-!insertmacro MUI_LANGUAGE "French"
-
-; MUI end ------
-
-Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
-OutFile "dist\davmail-${PRODUCT_VERSION}-setup.exe"
-InstallDir "$PROGRAMFILES\DavMail"
-InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
-ShowInstDetails show
-ShowUnInstDetails show
-
-Function .onInit
- !insertmacro MUI_LANGDLL_DISPLAY
-FunctionEnd
-
-Section
-Push $5
-loop:
- push "davmail.exe"
- processwork::existsprocess
- pop $5
- IntCmp $5 0 no_quest
- MessageBox MB_RETRYCANCEL|MB_ICONSTOP 'DavMail must be closed during this installation.$\r$\n Close DavMail now, or press "Retry" to automatically close DavMail and continue or press "Cancel" to cancel the installation entirely.' IDCANCEL BailOut
- push "davmail.exe"
- processwork::KillProcess
- Sleep 2000
-Goto loop
-
-BailOut:
- Abort
-
-no_quest:
-SectionEnd
-
-Section "MainSection" SEC01
- SetOutPath "$INSTDIR"
- SetOverwrite try
- File "dist\davmail.exe"
- CreateDirectory "$SMPROGRAMS\DavMail"
- CreateShortCut "$SMPROGRAMS\DavMail\DavMail.lnk" "$INSTDIR\davmail.exe"
- CreateShortCut "$SMPROGRAMS\DavMail\DavMail Console.lnk" "$INSTDIR\davmailconsole.exe"
- CreateShortCut "$DESKTOP\DavMail.lnk" "$INSTDIR\davmail.exe"
- File "dist\davmail.jar"
- File "dist\davmailconsole.exe"
- File "dist\davmailservice.exe"
- File "dist\davmail64.exe"
- File "dist\davmailservice64.exe"
- SetOutPath "$INSTDIR\lib"
- File "dist\lib\activation-1.1.1.jar"
- File "dist\lib\commons-codec-1.3.jar"
- File "dist\lib\commons-collections-3.1.jar"
- File "dist\lib\commons-httpclient-3.1.jar"
- File "dist\lib\commons-logging-1.0.4.jar"
- File "dist\lib\htmlcleaner-2.1.jar"
- File "dist\lib\jackrabbit-webdav-1.4.jar"
- File "dist\lib\jcharset-1.3.jar"
- File "dist\lib\jcifs-1.3.14.jar"
- File "dist\lib\jdom-1.0.jar"
- File "dist\lib\log4j-1.2.16.jar"
- File "dist\lib\mail-1.4.3.jar"
- File "dist\lib\slf4j-api-1.3.1.jar"
- File "dist\lib\slf4j-log4j12-1.3.1.jar"
- File "dist\lib\stax-api-1.0.1.jar"
- File "dist\lib\stax2-api-3.1.1.jar"
- File "dist\lib\swt-3.7-win32-x86.jar"
- File "dist\lib\swt-3.7-win32-x86_64.jar"
- File "dist\lib\winrun4j-0.4.4.jar"
- File "dist\lib\woodstox-core-asl-4.1.2.jar"
- File "dist\lib\xercesImpl-2.8.1.jar"
-
- WriteRegStr HKEY_CURRENT_USER "Software\Microsoft\Windows\CurrentVersion\Run" "DavMail" "$INSTDIR\davmail.exe"
-SectionEnd
-
-Section -AdditionalIcons
- SetOutPath $INSTDIR
- WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
- CreateShortCut "$SMPROGRAMS\DavMail\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
- CreateShortCut "$SMPROGRAMS\DavMail\Uninstall.lnk" "$INSTDIR\uninst.exe"
-SectionEnd
-
-Section -Post
- WriteUninstaller "$INSTDIR\uninst.exe"
- WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\davmail.exe"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\davmail.exe"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
-SectionEnd
-
-
-Function un.onUninstSuccess
- HideWindow
- MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) has been removed from your system."
-FunctionEnd
-
-Function un.onInit
-!insertmacro MUI_UNGETLANGUAGE
- MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
- Abort
-FunctionEnd
-
-Section Uninstall
-Push $5
-loop:
- push "davmail.exe"
- processwork::existsprocess
- pop $5
- IntCmp $5 0 no_quest
- MessageBox MB_RETRYCANCEL|MB_ICONSTOP 'DavMail must be closed during this installation.$\r$\n Close DavMail now, or press "Retry" to automatically close DavMail and continue or press "Cancel" to cancel the installation entirely.' IDCANCEL BailOut
- push "davmail.exe"
- processwork::KillProcess
- Sleep 2000
-Goto loop
-
-BailOut:
- Abort
-
-no_quest:
- Delete "$INSTDIR\${PRODUCT_NAME}.url"
- Delete "$INSTDIR\uninst.exe"
-
- Delete "$INSTDIR\lib\activation-1.1.1.jar"
- Delete "$INSTDIR\lib\commons-codec-1.3.jar"
- Delete "$INSTDIR\lib\commons-collections-3.1.jar"
- Delete "$INSTDIR\lib\commons-httpclient-3.1.jar"
- Delete "$INSTDIR\lib\commons-logging-1.0.4.jar"
- Delete "$INSTDIR\lib\htmlcleaner-2.1.jar"
- Delete "$INSTDIR\lib\jackrabbit-webdav-1.4.jar"
- Delete "$INSTDIR\lib\jcharset-1.3.jar"
- Delete "$INSTDIR\lib\jcifs-1.3.14.jar"
- Delete "$INSTDIR\lib\jdom-1.0.jar"
- Delete "$INSTDIR\lib\log4j-1.2.16.jar"
- Delete "$INSTDIR\lib\mail-1.4.3.jar"
- Delete "$INSTDIR\lib\slf4j-api-1.3.1.jar"
- Delete "$INSTDIR\lib\slf4j-log4j12-1.3.1.jar"
- Delete "$INSTDIR\lib\stax-api-1.0.1.jar"
- Delete "$INSTDIR\lib\stax2-api-3.1.1.jar"
- Delete "$INSTDIR\lib\swt-3.7-win32-x86.jar"
- Delete "$INSTDIR\lib\swt-3.7-win32-x86_64.jar"
- Delete "$INSTDIR\lib\winrun4j-0.4.4.jar"
- Delete "$INSTDIR\lib\woodstox-core-asl-4.1.2.jar"
- Delete "$INSTDIR\lib\xercesImpl-2.8.1.jar"
-
- Delete "$INSTDIR\davmailservice64.exe"
- Delete "$INSTDIR\davmail64.exe"
- Delete "$INSTDIR\davmailservice.exe"
- Delete "$INSTDIR\davmailconsole.exe"
- Delete "$INSTDIR\davmail.log"
- Delete "$INSTDIR\davmail.jar"
- Delete "$INSTDIR\davmail.exe"
-
- Delete "$SMPROGRAMS\DavMail\Uninstall.lnk"
- Delete "$SMPROGRAMS\DavMail\Website.lnk"
- Delete "$DESKTOP\DavMail.lnk"
- Delete "$SMPROGRAMS\DavMail\DavMail.lnk"
- Delete "$SMPROGRAMS\DavMail\DavMail Console.lnk"
-
- RMDir "$SMPROGRAMS\DavMail"
- RMDir "$INSTDIR\lib"
- RMDir "$INSTDIR"
-
- DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "DavMail"
-
- DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
- DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
- SetAutoClose true
-SectionEnd
\ No newline at end of file
diff --git a/davmail.jsmooth b/davmail.jsmooth
deleted file mode 100644
index ebb7fd2..0000000
--- a/davmail.jsmooth
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<arguments></arguments>
-<classPath>dist/davmail.jar</classPath>
-<classPath>dist/lib/activation-1.1.1.jar</classPath>
-<classPath>dist/lib/commons-codec-1.3.jar</classPath>
-<classPath>dist/lib/commons-collections-3.1.jar</classPath>
-<classPath>dist/lib/commons-httpclient-3.1.jar</classPath>
-<classPath>dist/lib/commons-logging-1.0.4.jar</classPath>
-<classPath>dist/lib/htmlcleaner-2.1.jar</classPath>
-<classPath>dist/lib/jackrabbit-webdav-1.4.jar</classPath>
-<classPath>dist/lib/jcharset-1.3.jar</classPath>
-<classPath>dist/lib/jcifs-1.3.14.jar</classPath>
-<classPath>dist/lib/jdom-1.0.jar</classPath>
-<classPath>dist/lib/log4j-1.2.16.jar</classPath>
-<classPath>dist/lib/mail-1.4.3.jar</classPath>
-<classPath>dist/lib/slf4j-api-1.3.1.jar</classPath>
-<classPath>dist/lib/slf4j-log4j12-1.3.1.jar</classPath>
-<classPath>dist/lib/stax-api-1.0.1.jar</classPath>
-<classPath>dist/lib/stax2-api-3.1.1.jar</classPath>
-<classPath>dist/lib/swt-3.7-win32-x86.jar</classPath>
-<classPath>dist/lib/woodstox-core-asl-4.1.2.jar</classPath>
-<classPath>dist/lib/xercesImpl-2.8.1.jar</classPath>
-<embeddedJar>false</embeddedJar>
-<executableName>dist/davmail.exe</executableName>
-<iconLocation>src/java/tray48.png</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<javaProperties>
-<name>sun.net.inetaddr.ttl</name>
-<value>60</value>
-</javaProperties>
-<mainClassName>davmail.DavGateway</mainClassName>
-<maximumMemoryHeap>268435456</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.6</minimumVersion>
-<skeletonName>Autodownload Wrapper</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>DownloadURL</key>
-<value>http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>SingleProcess</key>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>SingleInstance</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>JniSmooth</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/davmail64.jsmooth b/davmail64.jsmooth
deleted file mode 100644
index 8addd7c..0000000
--- a/davmail64.jsmooth
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<arguments></arguments>
-<classPath>dist\davmail.jar</classPath>
-<classPath>dist\lib\activation-1.1.1.jar</classPath>
-<classPath>dist\lib\commons-codec-1.3.jar</classPath>
-<classPath>dist\lib\commons-collections-3.1.jar</classPath>
-<classPath>dist\lib\commons-httpclient-3.1.jar</classPath>
-<classPath>dist\lib\commons-logging-1.0.4.jar</classPath>
-<classPath>dist\lib\htmlcleaner-2.1.jar</classPath>
-<classPath>dist\lib\jackrabbit-webdav-1.4.jar</classPath>
-<classPath>dist\lib\jcharset-1.3.jar</classPath>
-<classPath>dist\lib\jcifs-1.3.14.jar</classPath>
-<classPath>dist\lib\jdom-1.0.jar</classPath>
-<classPath>dist\lib\log4j-1.2.16.jar</classPath>
-<classPath>dist\lib\mail-1.4.3.jar</classPath>
-<classPath>dist\lib\slf4j-api-1.3.1.jar</classPath>
-<classPath>dist\lib\slf4j-log4j12-1.3.1.jar</classPath>
-<classPath>dist\lib\stax-api-1.0.1.jar</classPath>
-<classPath>dist\lib\stax2-api-3.1.1.jar</classPath>
-<classPath>dist\lib\swt-3.7-win32-x86_64.jar</classPath>
-<classPath>dist\lib\woodstox-core-asl-4.1.2.jar</classPath>
-<classPath>dist\lib\xercesImpl-2.8.1.jar</classPath>
-<embeddedJar>false</embeddedJar>
-<executableName>dist\davmail64.exe</executableName>
-<iconLocation>src\java\tray48.png</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<javaProperties>
-<name>sun.net.inetaddr.ttl</name>
-<value>60</value>
-</javaProperties>
-<mainClassName>davmail.DavGateway</mainClassName>
-<maximumMemoryHeap>268435456</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.6</minimumVersion>
-<skeletonName>Windowed Wrapper x64</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>URL</key>
-<value>http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>SingleProcess</key>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>SingleInstance</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>JniSmooth</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/davmailconsole.jsmooth b/davmailconsole.jsmooth
deleted file mode 100644
index 6b11532..0000000
--- a/davmailconsole.jsmooth
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<arguments></arguments>
-<classPath>dist/davmail.jar</classPath>
-<classPath>dist/lib/activation-1.1.1.jar</classPath>
-<classPath>dist/lib/commons-codec-1.3.jar</classPath>
-<classPath>dist/lib/commons-collections-3.1.jar</classPath>
-<classPath>dist/lib/commons-httpclient-3.1.jar</classPath>
-<classPath>dist/lib/commons-logging-1.0.4.jar</classPath>
-<classPath>dist/lib/htmlcleaner-2.1.jar</classPath>
-<classPath>dist/lib/jackrabbit-webdav-1.4.jar</classPath>
-<classPath>dist/lib/jcharset-1.3.jar</classPath>
-<classPath>dist/lib/jcifs-1.3.14.jar</classPath>
-<classPath>dist/lib/jdom-1.0.jar</classPath>
-<classPath>dist/lib/log4j-1.2.16.jar</classPath>
-<classPath>dist/lib/mail-1.4.3.jar</classPath>
-<classPath>dist/lib/slf4j-api-1.3.1.jar</classPath>
-<classPath>dist/lib/slf4j-log4j12-1.3.1.jar</classPath>
-<classPath>dist/lib/stax-api-1.0.1.jar</classPath>
-<classPath>dist/lib/stax2-api-3.1.1.jar</classPath>
-<classPath>dist/lib/swt-3.7-win32-x86.jar</classPath>
-<classPath>dist/lib/woodstox-core-asl-4.1.2.jar</classPath>
-<classPath>dist/lib/xercesImpl-2.8.1.jar</classPath>
-<embeddedJar>false</embeddedJar>
-<executableName>dist/davmailconsole.exe</executableName>
-<iconLocation>src/java/tray32.png</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<javaProperties>
-<name>sun.net.inetaddr.ttl</name>
-<value>60</value>
-</javaProperties>
-<mainClassName>davmail.DavGateway</mainClassName>
-<maximumMemoryHeap>268435456</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.5</minimumVersion>
-<skeletonName>Console Wrapper</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>PressKey</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/davmailservice.jsmooth b/davmailservice.jsmooth
deleted file mode 100644
index bd78ac7..0000000
--- a/davmailservice.jsmooth
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<arguments>davmail.properties</arguments>
-<classPath>dist/davmail.jar</classPath>
-<classPath>dist/lib/activation-1.1.1.jar</classPath>
-<classPath>dist/lib/commons-codec-1.3.jar</classPath>
-<classPath>dist/lib/commons-collections-3.1.jar</classPath>
-<classPath>dist/lib/commons-httpclient-3.1.jar</classPath>
-<classPath>dist/lib/commons-logging-1.0.4.jar</classPath>
-<classPath>dist/lib/htmlcleaner-2.1.jar</classPath>
-<classPath>dist/lib/jackrabbit-webdav-1.4.jar</classPath>
-<classPath>dist/lib/jcharset-1.3.jar</classPath>
-<classPath>dist/lib/jcifs-1.3.14.jar</classPath>
-<classPath>dist/lib/jdom-1.0.jar</classPath>
-<classPath>dist/lib/log4j-1.2.16.jar</classPath>
-<classPath>dist/lib/mail-1.4.3.jar</classPath>
-<classPath>dist/lib/slf4j-api-1.3.1.jar</classPath>
-<classPath>dist/lib/slf4j-log4j12-1.3.1.jar</classPath>
-<classPath>dist/lib/stax-api-1.0.1.jar</classPath>
-<classPath>dist/lib/stax2-api-3.1.1.jar</classPath>
-<classPath>dist/lib/swt-3.7-win32-x86.jar</classPath>
-<classPath>dist/lib/woodstox-core-asl-4.1.2.jar</classPath>
-<classPath>dist/lib/xercesImpl-2.8.1.jar</classPath>
-<currentDirectory>${EXECUTABLEPATH}</currentDirectory>
-<embeddedJar>false</embeddedJar>
-<executableName>dist/davmailservice.exe</executableName>
-<iconLocation>src/java/tray32.png</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<javaProperties>
-<name>sun.net.inetaddr.ttl</name>
-<value>60</value>
-<name>-Xrs</name>
-<value></value>
-</javaProperties>
-<mainClassName>davmail.DavGateway</mainClassName>
-<maximumMemoryHeap>268435456</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.6</minimumVersion>
-<skeletonName>WinService Wrapper</skeletonName>
-<skeletonProperties>
-<key>ServiceName</key>
-<value>DavMail</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>ServiceDisplayName</key>
-<value>DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Message</key>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Autostart</key>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Logfile</key>
-<value>davmailservice.log</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Interactive</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>JniSmooth</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/jsmooth-0.9.9-7-patch/build.xml b/jsmooth-0.9.9-7-patch/build.xml
deleted file mode 100644
index 091158c..0000000
--- a/jsmooth-0.9.9-7-patch/build.xml
+++ /dev/null
@@ -1,607 +0,0 @@
-<project name="jsmoothgen" default="jar" basedir=".">
-
- <!-- set here the properties specific to your computer -->
- <!-- see the README.txt file for additional information -->
- <!-- DO NOT SKIP THIS PART! REALLY! IT WON'T WORK OTHERWISE -->
- <property name="JDKDIR" value="c:\Program Files\Java\jdk1.5.0_11"/>
- <property name="RM" value="CMD /C DEL"/>
-
- <!-- the autodownload skeleton needs the fltk lib to be available -->
- <!-- Unfortunately, I couldn't find a way to call fltk-config -->
- <!-- directly from ANT or from the makefile. To find the correct -->
- <!-- values for your system, run the msys/mingw shell and type -->
- <!-- "fltk-config __ldflags" and "fltk-config __cxxflags" -->
- <!-- (replace each _ with a - above, due to xml syntax constraints -->
- <!-- Then, add the windows path so that the makefile gets it right -->
- <!-- Below are the default values when you ./configure, make and -->
- <!-- make install fltk under an msys environement -->
- <property name="fltk-ldflags" value="-LC:/msys/1.0/local/lib -mwindows -mno-cygwin -lfltk -lole32 -luuid -lcomctl32 -lwsock32"/>
- <property name="fltk-cxxflags" value="-IC:/msys/1.0/local/include -IC:/msys/1.0/local/include/FL/images -mwindows -DWIN32 -mno-cygwin"/>
-
- <!-- What's below is optional (needed only if you build a dist) -->
- <property name="FOP" value="c:/Programs/fop-0.93\fop.bat"/>
- <property name="DOCBOOKBASE" value="c:\programs\docbook-xsl-1.72.0"/>
-
- <!-- set here the properties specific to the release -->
-
- <property name="VERSION" value="0.9.9-7"/>
-
- <!-- You don't need to modify the properties below -->
-
- <property environment="env"/>
- <property name="src" value="src"/>
- <property name="tmp" value="tmp"/>
- <property name="docs" value="docs"/>
-
- <property name="anttask-src" value="ant"/>
- <property name="classes" value="classes"/>
- <property name="jsmoothjar" value="jsmoothgen.jar"/>
- <property name="jsmoothjar-ant" value="jsmoothgen-ant.jar"/>
- <property name="ant.jar" value="${env.ANT_HOME}/lib/ant.jar"/>
-
- <property name="distbase" value="dist"/>
- <property name="dist" value="${distbase}/jsmooth-${VERSION}"/>
-
- <path id="anttask-compile.class.path">
- <pathelement path="${ant.jar}"/>
- <pathelement path="${jsmoothjar}/"/>
- <pathelement path="lib/JimiProClasses.zip"/>
- <pathelement path="lib/jox116.jar"/>
- <pathelement path="lib/dtdparser113.jar"/>
- </path>
-
- <path id="anttask.class.path">
- <pathelement path="${ant.jar}"/>
- <pathelement path="${jsmoothjar-ant}/"/>
- <pathelement path="lib/JimiProClasses.zip"/>
- <pathelement path="lib/jox116.jar"/>
- <pathelement path="lib/dtdparser113.jar"/>
- </path>
-
- <path id="jsmooth.class.path">
- <fileset dir="lib">
- <include name="**/*.jar"/>
- </fileset>
- <fileset dir="skeletons/jnismooth">
- <include name="*.jar"/>
- </fileset>
- </path>
-
- <target name="init">
- <!-- Create the time stamp -->
- <tstamp/>
- <!-- Create the build directory structure used by compile -->
- <mkdir dir="${classes}"/>
- </target>
-
- <target depends="init" name="compile">
- <!-- Compile the java code from ${src} into ${classes} -->
- <echo>Compiling the application from ${src}</echo>
- <javac target="1.4" source="1.4" deprecation="yes" destdir="${classes}" srcdir="${src}" debug="true">
- <classpath refid="jsmooth.class.path"/>
- </javac>
- </target>
-
- <target name="docs" depends="init">
- <!-- Compile the java code from ${src} into ${classes} -->
-
- <xslt basedir="${docs}" destdir="${docs}"
- in="${docs}/jsmooth-doc.xml"
- out="${docs}/jsmooth-doc.html"
- style="${DOCBOOKBASE}/html/docbook.xsl" >
-
- <param name="admon.graphics" expression="1"/>
- <param name="section.autolabel" expression="1"/>
- <param name="section.label.includes.component.label" expression="1"/>
- <param name="chunk.section.depth" expression="2"/>
- <param name="html.stylesheet" expression="jsmooth.css"/>
-
- </xslt>
-
- <xslt basedir="${docs}" destdir="${docs}"
- in="${docs}/jsmooth-doc.xml"
- out="${docs}/jsmooth-doc.fo"
- style="${DOCBOOKBASE}/fo/docbook.xsl" >
- <param name="admon.graphics" expression="1"/>
- <param name="section.autolabel" expression="1"/>
- <param name="section.label.includes.component.label" expression="1"/>
- </xslt>
-
- <exec executable="${FOP}" dir="${docs}">
- <arg value="jsmooth-doc.fo"/>
- <arg value="jsmooth-doc.pdf"/>
- </exec>
-
- </target>
-
- <target depends="compile" name="jar">
- <!-- Compile the java code from ${src} into ${classes} -->
- <copy todir="classes/icons">
- <fileset dir="${src}/icons"/>
- </copy>
- <copy todir="classes/locale">
- <fileset dir="${src}/locale"/>
- </copy>
- <jar basedir="classes" jarfile="${jsmoothjar}" manifest="src\MANIFEST.txt"/>
- </target>
-
- <target depends="compile" name="anttask">
- <!-- Compile the java code from ${src} into ${classes} -->
- <javac deprecation="yes" destdir="${classes}" srcdir="${anttask-src}" debug="true">
- <classpath refid="anttask-compile.class.path"/>
- </javac>
- <unjar src="lib/jox116.jar" dest="${classes}"/>
- <unjar src="lib/dtdparser113.jar" dest="${classes}"/>
- <jar basedir="classes" jarfile="${jsmoothjar-ant}" manifest="src\MANIFEST.txt"/>
- </target>
-
- <!--
- Builds the distribution file for jsmooth.
- -->
-
- <target depends="jar" name="test">
- <echo>Running test class... ${jsmoothjar}</echo>
- <java classname="net.charabia.jsmoothgen.application.gui.beaneditors.BeanPanel" fork="yes" >
- <classpath refid="jsmooth.class.path"/>
- <classpath>
- <pathelement path="${jsmoothjar}"/>
- </classpath>
- </java>
- </target>
-
- <target depends="" name="dist">
-
- <tstamp/>
- <buildnumber/>
- <property name="RELEASEINFO" value="Build ${DSTAMP}-${build.number}"/>
-
- <echo>Building release ${VERSION} - ${RELEASEINFO}</echo>
-
- <!-- Clean up the directories -->
- <antcall target="clean"/>
-
- <!-- Clean up the distribution directory -->
-
- <delete dir="${distbase}"/>
- <mkdir dir="${dist}"/>
- <mkdir dir="${dist}/docs"/>
- <mkdir dir="${dist}/lib"/>
- <mkdir dir="${dist}/sample"/>
- <mkdir dir="${dist}/skeletons"/>
-
-
- <!-- Compile the classes and create the jars -->
- <!-- The sources are copied in a temp dir, so that -->
- <!-- the VERSION and RELEASEINFO data can be replaced -->
-
- <delete dir="${tmp}"/>
- <mkdir dir="${tmp}"/>
- <copy todir="${tmp}/src">
- <fileset dir="src"/>
- </copy>
-
- <replace token="@{VERSION}@" dir="${tmp}/src" value="${VERSION}">
- <include name="**/*.java"/>
- </replace>
- <replace token="@{RELEASEINFO}@" dir="${tmp}/src" value="${RELEASEINFO}">
- <include name="**/*.java"/>
- </replace>
-
- <replace token="@{VERSION}@" dir="${tmp}/src" value="${VERSION}">
- <include name="**/*.properties"/>
- </replace>
- <replace token="@{RELEASEINFO}@" dir="${tmp}/src" value="${RELEASEINFO}">
- <include name="**/*.properties"/>
- </replace>
-
- <ant antfile="build.xml" dir="skeletons/jnismooth/" target="dist"/>
-
- <antcall target="jar">
- <param name="src" value="${tmp}/src"/>
- </antcall>
-
- <antcall target="anttask">
- <param name="src" value="${tmp}/src"/>
- </antcall>
-
- <!-- Copy the jsmooth ant library -->
- <copy todir="${dist}/lib" file="jsmoothgen.jar"/>
- <copy todir="${dist}/lib" file="jsmoothgen-ant.jar"/>
- <copy todir="${dist}/lib" file="lib/jox116.jar"/>
- <copy todir="${dist}/lib" file="lib/dtdparser113.jar"/>
- <copy todir="${dist}/lib" file="lib/l2fprod-common-all.jar"/>
- <copy todir="${dist}/lib" file="lib/riverlayout.jar"/>
- <copy todir="${dist}/lib" file="lib/BrowserLauncher2-10.jar"/>
-
- <!-- Now that the ANT task is available, register it -->
-
- <taskdef name="jsmoothgen"
- classname="net.charabia.jsmoothgen.ant.JSmoothGen"
- classpathref="anttask.class.path"/>
-
- <!-- Builds the documentation -->
- <copy todir="${tmp}/docs">
- <fileset dir="docs"/>
- </copy>
- <replace token="@{VERSION}@" dir="${tmp}/docs/" value="${VERSION}">
- <include name="**/*.xml"/>
- <include name="**/*.txt"/>
- <include name="**/*.properties"/>
- </replace>
- <replace token="@{RELEASEINFO}@" dir="${tmp}/docs/" value="${RELEASEINFO}">
- <include name="**/*.xml"/>
- <include name="**/*.txt"/>
- <include name="**/*.properties"/>
- </replace>
-
- <antcall target="docs">
- <param name="docs" value="${tmp}/docs"/>
- </antcall>
-
- <copy todir="${dist}/docs">
- <fileset dir="${tmp}/docs">
- <include name="**/*.pdf"/>
- </fileset>
- <fileset dir="${tmp}/docs">
- <include name="**/*.html"/>
- </fileset>
- <fileset dir="${tmp}/docs">
- <include name="**/*.css"/>
- </fileset>
- </copy>
- <copy todir="${dist}/docs/images">
- <fileset dir="${tmp}/docs/images"/>
- </copy>
-
- <copy todir="${dist}" file="readme.txt"/>
- <copy todir="${dist}" file="LICENSE.txt"/>
- <copy todir="${dist}" file="LGPL-LICENSE.txt"/>
- <copy todir="${dist}" file="GPL-LICENSE.txt"/>
- <copy tofile="${dist}/Changelog.txt" file="Changelog"/>
-
- <!-- Compile the wrappers -->
- <ant antfile="build.xml" dir="skeletons/jnismooth/" target="dist"/>
- <ant antfile="build.xml" dir="skeletons/samplejar/" target="dist"/>
- <ant antfile="build.xml" dir="skeletons/consolewrapper/samplejar/" target="dist"/>
-
- <mkdir dir="${dist}/jni"/>
- <copy todir="${dist}/jni" file="skeletons/jnismooth/jnismooth.jar"/>
- <javadoc packagenames="jsmooth.*"
- sourcepath="skeletons/jnismooth/src"
- destdir="${dist}/docs/jniapi"
- author="true"
- version="true"
- use="true"
- windowtitle="JSmooth JNI API" />
-
- <!-- build all 32bit wrappers -->
- <mkdir dir="${dist}/skeletons/windowed-wrapper"/>
- <mkdir dir="${dist}/skeletons/console-wrapper"/>
- <mkdir dir="${dist}/skeletons/autodownload-wrapper"/>
- <mkdir dir="${dist}/skeletons/winservice-wrapper"/>
- <antcall target="compileskels">
- <param name="skelflags" value="-static-libgcc"/>
- </antcall>
- <copy todir="${dist}/skeletons/windowed-wrapper" file="skeletons/simplewrap/jwrap.exe"/>
- <copy todir="${dist}/skeletons/windowed-wrapper" file="skeletons/simplewrap/description.skel"/>
- <copy todir="${dist}/skeletons/console-wrapper" file="skeletons/consolewrapper/consolewrapper.exe"/>
- <copy todir="${dist}/skeletons/console-wrapper" file="skeletons/consolewrapper/description.skel"/>
- <copy todir="${dist}/skeletons/autodownload-wrapper" file="skeletons/autodownload/autodownload.skel"/>
- <copy todir="${dist}/skeletons/autodownload-wrapper" file="skeletons/autodownload/customdownload.skel"/>
- <copy todir="${dist}/skeletons/autodownload-wrapper" file="skeletons/autodownload/autodownload.exe"/>
- <copy todir="${dist}/skeletons/winservice-wrapper" file="skeletons/winservice/description.skel"/>
- <copy todir="${dist}/skeletons/winservice-wrapper" file="skeletons/winservice/winservice.exe"/>
- <exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/console-wrapper">
- <arg value="consolewrapper.exe"/>
- </exec>
- <exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/windowed-wrapper">
- <arg value="jwrap.exe"/>
- </exec>
- <exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/autodownload-wrapper">
- <arg value="autodownload.exe"/>
- </exec>
- <exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/winservice-wrapper">
- <arg value="winservice.exe"/>
- </exec>
-
- <!-- build all 64bits wrappers -->
- <antcall target="clean64"/>
- <mkdir dir="${dist}/skeletons/windowed-wrapper64"/>
- <mkdir dir="${dist}/skeletons/console-wrapper64"/>
- <!-- not available for x64
- <mkdir dir="${dist}/skeletons/autodownload-wrapper64"/>
- -->
- <mkdir dir="${dist}/skeletons/winservice-wrapper64"/>
- <antcall target="compileskels64">
- <param name="skelflags" value="-static-libgcc"/>
- </antcall>
- <copy todir="${dist}/skeletons/windowed-wrapper64" file="skeletons/simplewrap/jwrap.exe"/>
- <copy todir="${dist}/skeletons/windowed-wrapper64" file="skeletons/simplewrap/description64.skel"/>
- <copy todir="${dist}/skeletons/console-wrapper64" file="skeletons/consolewrapper/consolewrapper.exe"/>
- <copy todir="${dist}/skeletons/console-wrapper64" file="skeletons/consolewrapper/description64.skel"/>
- <!-- not available for x64
- <copy todir="${dist}/skeletons/autodownload-wrapper64" file="skeletons/autodownload/autodownload64.skel"/>
- <copy todir="${dist}/skeletons/autodownload-wrapper64" file="skeletons/autodownload/customdownload64.skel"/>
- <copy todir="${dist}/skeletons/autodownload-wrapper64" file="skeletons/autodownload/autodownload.exe"/>
- -->
- <copy todir="${dist}/skeletons/winservice-wrapper64" file="skeletons/winservice/description64.skel"/>
- <copy todir="${dist}/skeletons/winservice-wrapper64" file="skeletons/winservice/winservice.exe"/>
- <exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/console-wrapper64">
- <arg value="consolewrapper.exe"/>
- </exec>
- <exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/windowed-wrapper64">
- <arg value="jwrap.exe"/>
- </exec>
- <!-- not available for x64
- <exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/autodownload-wrapper64">
- <arg value="autodownload.exe"/>
- </exec>
- -->
- <exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/winservice-wrapper64">
- <arg value="winservice.exe"/>
- </exec>
-
- <!-- Builds the jsmooth executable -->
- <jsmoothgen project="jsprj/jsmoothgen.jsmooth" skeletonroot="${dist}/skeletons"/>
- <jsmoothgen project="jsprj/jsmoothcmd.jsmooth" skeletonroot="${dist}/skeletons"/>
- <jsmoothgen project="jsprj/jsmoothcmd64.jsmooth" skeletonroot="${dist}/skeletons"/>
- <ant antfile="build.xml" dir="sample" target="dist"/>
- <jsmoothgen project="jsprj/prooftest.jsmooth" skeletonroot="${dist}/skeletons"/>
- <jsmoothgen project="jsprj/prooftest64.jsmooth" skeletonroot="${dist}/skeletons"/>
-
- <copy todir="${dist}" file="jsmoothgen.exe"/>
- <copy todir="${dist}" file="jsmoothcmd.exe"/>
- <copy todir="${dist}" file="jsmoothcmd64.exe"/>
- <copy todir="${dist}" file="proof-test.exe"/>
- <copy todir="${dist}" file="proof-test64.exe"/>
- <copy todir="${dist}/sample">
- <fileset dir="sample"/>
- </copy>
-
- </target>
-
- <target name="compileskel" depends="">
- <echo>Making ${skelname} ${target}</echo>
- <exec executable="c:\mingw-w32\bin\make.exe" dir="skeletons/${skelname}">
- <env key="PATH" value="C:\mingw-w32\bin"/>
- <arg value="-f"/>
- <arg value="Makefile.win"/>
- <arg value="${target}"/>
- <arg value='CUSTOMFLAGS=${skelflags}'/>
- <arg value='"MINGW=c:/mingw-w32"'/>
- <arg value='"TARGET=i686-w64-mingw32"'/>
- <arg value='"JDK=${JDKDIR}"'/>
- <arg value='"RM=${RM}"'/>
- <arg value='"FLTK-LDFLAGS=${fltk-ldflags}"'/>
- <arg value='"FLTK-CXXFLAGS=${fltk-cxxflags}"'/>
- </exec>
- </target>
-
- <target name="compileskel64" depends="">
- <echo>Making ${skelname} ${target}</echo>
- <exec executable="c:\mingw-w64\bin\make.exe" dir="skeletons/${skelname}">
- <env key="PATH" value="C:\mingw-w64\bin"/>
- <arg value="-f"/>
- <arg value="Makefile.win"/>
- <arg value="${target}"/>
- <arg value='CUSTOMFLAGS=${skelflags}'/>
- <arg value='"MINGW=c:/mingw-w64"'/>
- <arg value='"TARGET=x86_64-w64-mingw32"'/>
- <arg value='"JDK=${JDKDIR}"'/>
- <arg value='"RM=${RM}"'/>
- <arg value='"FLTK-LDFLAGS=${fltk-ldflags}"'/>
- <arg value='"FLTK-CXXFLAGS=${fltk-cxxflags}"'/>
- </exec>
- </target>
-
- <target name="compileskels" depends="">
- <ant dir="skeletons/simplewrap/samplejar" />
- <ant dir="skeletons/consolewrapper/samplejar" />
-
- <antcall target="compileskel">
- <param name="skelname" value="util-core"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="util-net"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="commonjava"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="consolewrapper"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="simplewrap"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="autodownload"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="winservice"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- </target>
-
- <target name="clean">
- <delete dir="${classes}"/>
- <delete dir="${distbase}"/>
- <delete dir="${tmp}"/>
- <delete file="${jsmoothjar}"/>
- <delete file="${jsmoothjar-ant}"/>
-
- <ant antfile="build.xml" dir="sample" target="clean"/>
-
- <antcall target="compileskel">
- <param name="skelname" value="util-core"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="util-net"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="commonjava"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="consolewrapper"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="simplewrap"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="autodownload"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel">
- <param name="skelname" value="winservice"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
-
- <delete file="jsmoothgen.exe"/>
- <delete file="jsmoothcmd.exe"/>
- <delete file="proof-test.exe"/>
- </target>
-
- <target name="compileskels64" depends="">
- <ant dir="skeletons/simplewrap/samplejar" />
- <ant dir="skeletons/consolewrapper/samplejar" />
-
- <antcall target="compileskel64">
- <param name="skelname" value="util-core"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <!-- not available for x64
- <antcall target="compileskel64">
- <param name="skelname" value="util-net"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- -->
- <antcall target="compileskel64">
- <param name="skelname" value="commonjava"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="consolewrapper"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="simplewrap"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- <!-- not available for x64
- <antcall target="compileskel64">
- <param name="skelname" value="autodownload"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- -->
- <antcall target="compileskel64">
- <param name="skelname" value="winservice"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="all"/>
- </antcall>
- </target>
-
- <target name="clean64">
- <antcall target="compileskel64">
- <param name="skelname" value="util-core"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="util-net"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="commonjava"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="consolewrapper"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="simplewrap"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="autodownload"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
- <antcall target="compileskel64">
- <param name="skelname" value="winservice"/>
- <param name="skelflags" value="${skelflags}"/>
- <param name="target" value="clean"/>
- </antcall>
-
- <delete file="jsmoothgen.exe"/>
- <delete file="jsmoothcmd.exe"/>
- <delete file="proof-test.exe"/>
- </target>
-
- <target name="run" depends="jar">
- <java classname="net.charabia.jsmoothgen.application.gui.MainFrame" fork="yes" >
- <classpath refid="jsmooth.class.path"/>
- <classpath>
- <pathelement path="${jsmoothjar}"/>
- </classpath>
- <arg value="c:/temp/test/testservice.jsmooth"/>
- </java>
- </target>
-
- <target name="runskeletoneditor" depends="jar">
- <java classname="net.charabia.jsmoothgen.skeleton.SkeletonEditor" fork="yes" >
- <classpath refid="jsmooth.class.path"/>
- <classpath>
- <pathelement path="${jsmoothjar}"/>
- </classpath>
- </java>
- </target>
-
- <target name="swt-run" depends="jar">
- <java classname="net.charabia.jsmoothgen.application.swtgui.JSmoothApplication"
- fork="yes" >
-
- <classpath refid="jsmooth.class.path"/>
- <classpath>
- <pathelement path="${jsmoothjar}"/>
- </classpath>
- <jvmarg value="-Djava.library.path=lib/os"/>
- </java>
- </target>
-
-</project>
-
diff --git a/jsmooth-0.9.9-7-patch/jsprj/jsmoothcmd.jsmooth b/jsmooth-0.9.9-7-patch/jsprj/jsmoothcmd.jsmooth
deleted file mode 100644
index b9b4ec0..0000000
--- a/jsmooth-0.9.9-7-patch/jsprj/jsmoothcmd.jsmooth
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<classPath>..\lib\jox116.jar</classPath>
-<classPath>..\lib\JimiProClasses.zip</classPath>
-<classPath>..\lib\dtdparser113.jar</classPath>
-<classPath>..\lib\jsmoothgen.jar</classPath>
-<embeddedJar>false</embeddedJar>
-<executableName>..\jsmoothcmd.exe</executableName>
-<iconLocation>..\src\icons\gnome-application-x-jar-bm.gif</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<javaProperties>
-<name>jsmooth.basedir</name>
-<value>${EXECUTABLEPATH} </value>
-</javaProperties>
-<mainClassName>net.charabia.jsmoothgen.application.cmdline.CommandLine</mainClassName>
-<maximumMemoryHeap>-1</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.4</minimumVersion>
-<uacRequireAdministrator>0</uacRequireAdministrator>
-<skeletonName>Console Wrapper</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>This program needs Java 1.4 or higher to run.
-Please download it at http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>PressKey</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/jsmooth-0.9.9-7-patch/jsprj/jsmoothcmd64.jsmooth b/jsmooth-0.9.9-7-patch/jsprj/jsmoothcmd64.jsmooth
deleted file mode 100644
index acde98e..0000000
--- a/jsmooth-0.9.9-7-patch/jsprj/jsmoothcmd64.jsmooth
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<classPath>..\lib\jox116.jar</classPath>
-<classPath>..\lib\JimiProClasses.zip</classPath>
-<classPath>..\lib\dtdparser113.jar</classPath>
-<classPath>..\lib\jsmoothgen.jar</classPath>
-<embeddedJar>false</embeddedJar>
-<executableName>..\jsmoothcmd64.exe</executableName>
-<iconLocation>..\src\icons\gnome-application-x-jar-bm.gif</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<javaProperties>
-<name>jsmooth.basedir</name>
-<value>${EXECUTABLEPATH} </value>
-</javaProperties>
-<mainClassName>net.charabia.jsmoothgen.application.cmdline.CommandLine</mainClassName>
-<maximumMemoryHeap>-1</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.4</minimumVersion>
-<uacRequireAdministrator>0</uacRequireAdministrator>
-<skeletonName>Console Wrapper x64</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>This program needs Java 1.4 or higher to run.
-Please download it at http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>PressKey</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/jsmooth-0.9.9-7-patch/jsprj/jsmoothgen.jsmooth b/jsmooth-0.9.9-7-patch/jsprj/jsmoothgen.jsmooth
deleted file mode 100644
index ec86efc..0000000
--- a/jsmooth-0.9.9-7-patch/jsprj/jsmoothgen.jsmooth
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<classPath>..\lib\jox116.jar</classPath>
-<classPath>..\lib\dtdparser113.jar</classPath>
-<classPath>..\lib\jsmoothgen.jar</classPath>
-<classPath>..\lib\l2fprod-common-all.jar</classPath>
-<classPath>..\jsmoothgen.jar</classPath>
-<classPath>..\lib\riverlayout.jar</classPath>
-<classPath>..\lib\BrowserLauncher2-10.jar</classPath>
-<currentDirectory>${EXECUTABLEPATH}</currentDirectory>
-<embeddedJar>false</embeddedJar>
-<executableName>..\JSmoothGen.exe</executableName>
-<iconLocation>..\src\icons\gnome-application-x-jar-bm.gif</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<mainClassName>net.charabia.jsmoothgen.application.gui.MainFrame</mainClassName>
-<maximumMemoryHeap>-1</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.4</minimumVersion>
-<uacRequireAdministrator>0</uacRequireAdministrator>
-<skeletonName>Autodownload Wrapper</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>Java 1.4 or above has not been found on your computer. Do you want to download a compatible Java Environment?</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>DownloadURL</key>
-<value>http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>SingleProcess</key>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>SingleInstance</key>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>JniSmooth</key>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>0</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/jsmooth-0.9.9-7-patch/jsprj/prooftest.jsmooth b/jsmooth-0.9.9-7-patch/jsprj/prooftest.jsmooth
deleted file mode 100644
index fd56942..0000000
--- a/jsmooth-0.9.9-7-patch/jsprj/prooftest.jsmooth
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<arguments>simpleargument "multiple tokens" c:\my\test\here</arguments>
-<embeddedJar>true</embeddedJar>
-<executableName>..\proof-test.exe</executableName>
-<iconLocation>..\src\icons\stock_web-support.png</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<jarLocation>..\sample\sample.jar</jarLocation>
-<mainClassName>JSmoothPropertiesDisplayer</mainClassName>
-<maximumMemoryHeap>-1</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.1</minimumVersion>
-<uacRequireAdministrator>0</uacRequireAdministrator>
-<skeletonName>Console Wrapper</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>This program needs Java 1.4 or higher to run.
-Please download it at http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>PressKey</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>1</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/jsmooth-0.9.9-7-patch/jsprj/prooftest64.jsmooth b/jsmooth-0.9.9-7-patch/jsprj/prooftest64.jsmooth
deleted file mode 100644
index 9b50eca..0000000
--- a/jsmooth-0.9.9-7-patch/jsprj/prooftest64.jsmooth
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothproject>
-<JVMSearchPath>registry</JVMSearchPath>
-<JVMSearchPath>javahome</JVMSearchPath>
-<JVMSearchPath>jrepath</JVMSearchPath>
-<JVMSearchPath>jdkpath</JVMSearchPath>
-<JVMSearchPath>exepath</JVMSearchPath>
-<JVMSearchPath>jview</JVMSearchPath>
-<arguments>simpleargument "multiple tokens" c:\my\test\here</arguments>
-<embeddedJar>true</embeddedJar>
-<executableName>..\proof-test64.exe</executableName>
-<iconLocation>..\src\icons\stock_web-support.png</iconLocation>
-<initialMemoryHeap>-1</initialMemoryHeap>
-<jarLocation>..\sample\sample.jar</jarLocation>
-<mainClassName>JSmoothPropertiesDisplayer</mainClassName>
-<maximumMemoryHeap>-1</maximumMemoryHeap>
-<maximumVersion></maximumVersion>
-<minimumVersion>1.1</minimumVersion>
-<uacRequireAdministrator>0</uacRequireAdministrator>
-<skeletonName>Console Wrapper x64</skeletonName>
-<skeletonProperties>
-<key>Message</key>
-<value>This program needs Java 1.4 or higher to run.
-Please download it at http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>PressKey</key>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<key>Debug</key>
-<value>1</value>
-</skeletonProperties>
-</jsmoothproject>
diff --git a/jsmooth-0.9.9-7-patch/sample/build.xml b/jsmooth-0.9.9-7-patch/sample/build.xml
deleted file mode 100644
index 47c5390..0000000
--- a/jsmooth-0.9.9-7-patch/sample/build.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project basedir="." default="dist" name="jsmooth-sample">
-
- <!-- set global properties for this build -->
- <property name="src" value="src"/>
- <property name="classes" value="classes"/>
-
- <path id="build.class.path">
- <pathelement path="../skeletons/jnismooth/jnismooth.jar"/>
- </path>
-
- <target name="init">
- <!-- Create the time stamp -->
- <tstamp/>
- <!-- Create the build directory structure used by compile -->
- <mkdir dir="${classes}"/>
- </target>
-
- <target depends="init" name="compile">
- <!-- Compile the java code from ${src} into ${classes} -->
- <javac deprecation="yes" destdir="${classes}" srcdir="${src}" source="1.4" target="1.4">
- <classpath refid="build.class.path"/>
- </javac>
- </target>
-
- <target depends="compile" name="dist">
- <!-- Compile the java code from ${src} into ${classes} -->
- <jar basedir="classes" jarfile="sample.jar" manifest="src\MANIFEST.txt"/>
- </target>
-
- <target name="run" depends="dist">
- <java classname="JSmoothPropertiesDisplayer" fork="yes" >
- <classpath refid="build.class.path"/>
- <classpath>
- <pathelement path="sample.jar"/>
- </classpath>
- </java>
- </target>
-
- <target name="clean">
- <delete dir="${classes}"/>
- <delete file="sample.jar"/>
- </target>
-</project>
diff --git a/jsmooth-0.9.9-7-patch/skeletons/autodownload/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/autodownload/Makefile.win
deleted file mode 100644
index eb21df7..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/autodownload/Makefile.win
+++ /dev/null
@@ -1,46 +0,0 @@
-# Project: util-core
-
-PROJECTNAME=autodownload
-##libmscabd_la_SOURCES = mspack/system.c mspack/cabd.c mspack/lzxd.c mspack/mszipd.c mspack/qtmd.c
-##libmscabd_la_OBJS = system.o cabd.o lzxd.o mszipd.o qtmd.o
-
-SHELL = /bin/sh
-RM = rm -f
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-MINGW =
-RES = JWrap_private.res
-LINKOBJ = main.o execcab.o execexe.o $(RES)
-OBJ = main.o execcab.o execexe.o $(libmscabd_la_OBJS) $(RES)
-FLTK-LDFLAGS = $(shell fltk-config --ldflags --use-images)
-FLTK-CXXFLAGS = $(shell fltk-config --cxxflags --use-images)
-##LINKLIBS = ../commonjava/CommonJava.a ../util-core/util-core.a mspack.a ../util-net/util-net.a
-LINKLIBS = ../commonjava/CommonJava.a ../util-net/util-net.a ../util-core/util-core.a
-LIBS = -static-libgcc -L. -L"$(MINGW)/lib" -lws2_32 -L"${MINGW}/bin/libgcc_s_sjlj-1.dll" -L"/lib" -L"../commonjava" -mwindows -L"../util-core" -L"../util-net" $(LINKLIBS) $(FLTK-LDFLAGS) -lsetupapi -lwininet
-INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
-CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
-BIN = autodownload.exe
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-CFLAGS = $(INCS)
-
-.PHONY: all all-before all-after clean clean-custom $(PROJECTNAME)
-
-all: all-before $(BIN) all-after
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN) JWrap_private.res
-
-$(BIN): $(LINKOBJ) $(LINKLIBS)
- $(CPP) $(CXXFLAGS) $(LINKOBJ) $(LIBS) -o $(BIN)
-
-#mspack.a: $(libmscabd_la_SOURCES)
-# $(CC) -c -Imspack $(libmscabd_la_SOURCES)
-# ar r mspack.a $(libmscabd_la_OBJS)
-# ranlib mspack.a
-
-JWrap_private.res: JWrap_private.rc mainres.rc
- $(WINDRES) -i JWrap_private.rc -J rc -o JWrap_private.res -O coff
-
-main.o: main.cpp
- $(CPP) -c main.cpp $(CXXFLAGS)
diff --git a/jsmooth-0.9.9-7-patch/skeletons/autodownload/autodownload64.skel b/jsmooth-0.9.9-7-patch/skeletons/autodownload/autodownload64.skel
deleted file mode 100644
index 4841107..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/autodownload/autodownload64.skel
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothskeleton>
-<debug>false</debug>
-<description>SKEL_AUTODOWNLOAD_PROPERTY_DESCRIPTION</description>
-<executableName>autodownload.exe</executableName>
-<resourceCategory>JAVA</resourceCategory>
-<resourceJarId>102</resourceJarId>
-<resourcePropsId>103</resourcePropsId>
-<shortName>Autodownload Wrapper x64</shortName>
-<skeletonProperties>
-<description>SKEL_AUTODOWNLOAD_PROPERTY_MESSAGE_DESCRIPTION</description>
-<idName>Message</idName>
-<label>SKEL_AUTODOWNLOAD_PROPERTY_MESSAGE_LABEL</label>
-<type>textarea</type>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_AUTODOWNLOAD_PROPERTY_DLURL_DESCRIPTION</description>
-<idName>DownloadURL</idName>
-<label>SKEL_AUTODOWNLOAD_PROPERTY_DLURL_LABEL</label>
-<type>autodownloadurl</type>
-<value>http://java.sun.com/update/1.5.0/jinstall-1_5_0_11-windows-i586.cab</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION</description>
-<idName>SingleProcess</idName>
-<label>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_SINGLEINSTANCE_DESCRIPTION</description>
-<idName>SingleInstance</idName>
-<label>SKEL_GENERIC_SINGLEINSTANCE</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
-<idName>JniSmooth</idName>
-<label>SKEL_GENERIC_JNISMOOTH</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
-<idName>Debug</idName>
-<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-</jsmoothskeleton>
diff --git a/jsmooth-0.9.9-7-patch/skeletons/autodownload/customdownload64.skel b/jsmooth-0.9.9-7-patch/skeletons/autodownload/customdownload64.skel
deleted file mode 100644
index 5c81ff2..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/autodownload/customdownload64.skel
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothskeleton>
-<debug>false</debug>
-<description>SKEL_CUSTOMDOWNLOAD_DESCRIPTION</description>
-<executableName>autodownload.exe</executableName>
-<resourceCategory>JAVA</resourceCategory>
-<resourceJarId>102</resourceJarId>
-<resourcePropsId>103</resourcePropsId>
-<shortName>Custom Web Download Wrapper x64</shortName>
-<skeletonProperties>
-<description>SKEL_CUSTOMDOWNLOAD_PROPERTY_MESSAGE_DESCRIPTION</description>
-<idName>Message</idName>
-<label>SKEL_CUSTOMDOWNLOAD_PROPERTY_MESSAGE_LABEL</label>
-<type>textarea</type>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_CUSTOMDOWNLOAD_PROPERTY_URL_DESCRIPTION</description>
-<idName>DownloadURL</idName>
-<label>SKEL_CUSTOMDOWNLOAD_PROPERTY_URL_LABEL</label>
-<type>string</type>
-<value>http://</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION</description>
-<idName>SingleProcess</idName>
-<label>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_SINGLEINSTANCE_DESCRIPTION</description>
-<idName>SingleInstance</idName>
-<label>SKEL_GENERIC_SINGLEINSTANCE</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
-<idName>JniSmooth</idName>
-<label>SKEL_GENERIC_JNISMOOTH</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
-<idName>Debug</idName>
-<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-</jsmoothskeleton>
diff --git a/jsmooth-0.9.9-7-patch/skeletons/autodownload/mainres.rc b/jsmooth-0.9.9-7-patch/skeletons/autodownload/mainres.rc
deleted file mode 100644
index f2634f1..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/autodownload/mainres.rc
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include "resource.h"
-
-JARID JAVA "../samplejar/sample.jar"
-PROPID JAVA "../samplejar/sample.props"
-JNISMOOTHID JAVA "../jnismooth/jnismooth.jar"
-
-A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
-1 MANIFEST "../samplejar/sample.manifest"
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMBase.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMBase.cpp
deleted file mode 100644
index 14072b8..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMBase.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "JVMBase.h"
-
-JVMBase::JVMBase()
-{
- m_maxHeap = -1;
- m_initialHeap = -1;
- m_vmParameter = "";
-}
-
-void JVMBase::addPathElement(const std::string& element)
-{
- m_pathElements.push_back(element);
-}
-
-void JVMBase::addProperty(const JavaProperty& prop)
-{
- m_properties.push_back(prop);
-}
-
-void JVMBase::setMaxHeap(long size)
-{
- m_maxHeap = size;
-}
-
-void JVMBase::setInitialHeap(long size)
-{
- m_initialHeap = size;
-}
-
-void JVMBase::addArgument(const std::string& arg)
-{
- // m_arguments.push_back(StringUtils::requoteForCommandLine(arg));
- m_arguments.push_back(arg);
-}
-
-
-void JVMBase::setArguments(const std::string& args)
-{
- m_arguments.clear();
- DEBUG("arguments:<" + args + ">");
- // std::string ua = StringUtils::unescape(args);
- // DEBUG("arguments unescaped:<" + ua + ">");
- vector<string> splitted = StringUtils::split(args, " \t\n\r", "\"\'", false);
- for (int i=0; i<splitted.size(); i++)
- {
- DEBUG("SPLITTED-ARG[" + StringUtils::toString(i)+"]="+ splitted[i]);
- this->addArgument(splitted[i]);
- }
-}
-
-void JVMBase::setVmParameter(std::string parameter)
-{
- m_vmParameter = parameter;
-}
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMBase.h b/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMBase.h
deleted file mode 100644
index 5ad2cd0..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMBase.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __SUNJVMBASE_H_
-#define __SUNJVMBASE_H_
-
-#include <string>
-#include "jni.h"
-
-#include "Version.h"
-#include "StringUtils.h"
-#include "FileUtils.h"
-#include "ResourceManager.h"
-#include "JavaProperty.h"
-
-/**
- * @author Rodrigo Reyes <reyes at charabia.net>
- */
-
-class JVMBase
-{
- protected:
-
- std::vector<std::string> m_pathElements;
- std::vector<JavaProperty> m_properties;
- int m_maxHeap;
- int m_initialHeap;
- std::vector<std::string> m_arguments;
- std::string m_vmParameter;
-
- public:
- JVMBase();
-
- void addPathElement(const std::string& element);
- void addProperty(const JavaProperty& prop);
- void setMaxHeap(long size);
- void setInitialHeap(long size);
- void addArgument(const std::string& arg);
- void setArguments(const std::string& args);
- void setVmParameter(std::string parameter);
-};
-
-
-#endif
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMRegistryLookup.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMRegistryLookup.cpp
deleted file mode 100644
index c495ce8..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMRegistryLookup.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "JVMRegistryLookup.h"
-
-struct jvmsorter_dec : public binary_function<const SunJVMLauncher&, const SunJVMLauncher&, bool>
-{
- bool operator()(const SunJVMLauncher& s1, const SunJVMLauncher& s2)
- {
- return s2 < s1;
- }
-};
-
-vector<SunJVMLauncher> JVMRegistryLookup::lookupJVM()
-{
- vector<SunJVMLauncher> res = JVMRegistryLookup::lookup(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
-
- vector<SunJVMLauncher> res2 = JVMRegistryLookup::lookup(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Development Kit");
-
- for (vector<SunJVMLauncher>::iterator i = res2.begin(); i != res2.end(); i++)
- {
- res.insert(res.end(), *i);
- }
-
- sort(res.begin(), res.end(), jvmsorter_dec() );
-
- return res;
-}
-
-vector<SunJVMLauncher> JVMRegistryLookup::lookup(HKEY key, const string& path)
-{
- vector<SunJVMLauncher> result;
-
- HKEY hKey;
- LONG error = ERROR_SUCCESS;
- LONG val = RegOpenKeyEx(key, path.c_str(), 0, KEY_READ, &hKey);
-
- unsigned long buffersize = 1024;
- char buffer[1024];
-
- for (int i=0; RegEnumKey(hKey, i, buffer, buffersize) == ERROR_SUCCESS; i++)
- {
- int v = i;
- HKEY version;
- int foundver = RegOpenKeyEx(hKey, buffer, 0, KEY_READ, &version);
- if (foundver == ERROR_SUCCESS)
- {
- std::string versionname(buffer);
- HKEY runtimelib;
- unsigned long datatype;
- std::string runtimelibstr = "";
- std::string javahomestr = "";
-
- unsigned char *b = (unsigned char*)buffer;
- buffersize = 1024;
- int foundlib = RegQueryValueEx(version, TEXT("RuntimeLib"),
- NULL,
- &datatype,
- b,
- &buffersize);
-
- if (foundlib == ERROR_SUCCESS)
- {
- runtimelibstr = buffer;
- }
-
- b = (unsigned char*)buffer;
- buffersize = 1024;
- int foundhome = RegQueryValueEx(version, TEXT("JavaHome"),
- NULL,
- &datatype,
- b,
- &buffersize);
- if (foundhome == ERROR_SUCCESS)
- {
- javahomestr = buffer;
- }
-
- if ((runtimelibstr.length()>0) || (javahomestr.length()>0))
- {
- SunJVMLauncher vm;
- vm.RuntimeLibPath = runtimelibstr;
- vm.JavaHome = javahomestr;
- vm.VmVersion = Version(versionname);
- result.push_back(vm);
-
- char buffer[244];
- sprintf(buffer, "V(%d)(%d)(%d)", vm.VmVersion.getMajor(), vm.VmVersion.getMinor(), vm.VmVersion.getSubMinor());
- DEBUG(std::string("JVM Lookup: found VM (") + buffer + ") in registry.");
- }
- }
-
- }
-
- return result;
-}
-
-
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMRegistryLookup.h b/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMRegistryLookup.h
deleted file mode 100644
index 76ef6f9..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JVMRegistryLookup.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef _JVMREGISTRYLOOKUP_H_
-#define _JVMREGISTRYLOOKUP_H_
-
-#include <vector>
-#include <algorithm>
-
-#include "SunJVMLauncher.h"
-#include "JVMRegistryLookup.h"
-
-/** Utility class that scans the windows registry for installed JRE.
- *
- * @author Rodrigo Reyes <reyes at charabia.net>
- */
-
-class JVMRegistryLookup
-{
- public:
- /**
- * Scans the Windows Registry for the Java Runtime Environments. If
- * no JRE is found, an empty vector is returned.
- *
- * @return a vector containing the JRE found.
- */
- static vector<SunJVMLauncher> lookupJVM();
-
- private:
- static vector<SunJVMLauncher> lookup(HKEY key, const string& path);
-
-};
-
-
-#endif
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JavaMachineManager.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/JavaMachineManager.cpp
deleted file mode 100644
index 5d5ec84..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/JavaMachineManager.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "JavaMachineManager.h"
-
-
-JavaMachineManager::JavaMachineManager(ResourceManager& resman): m_resman(resman)
-{
- DEBUG("Now searching the JVM installed on the system...");
-
- m_registryVms = JVMRegistryLookup::lookupJVM();
- m_javahomeVm = JVMEnvVarLookup::lookupJVM("JAVA_HOME");
- m_jrepathVm = JVMEnvVarLookup::lookupJVM("JRE_HOME");
- m_jdkpathVm = JVMEnvVarLookup::lookupJVM("JDK_HOME");
- m_exitCode = 0;
- m_useConsole = true;
- m_acceptExe = true;
- m_acceptDLL = true;
- m_preferDLL = false;
-
- if (resman.getProperty("bundledvm").length() > 0)
- {
- string bjvm = resman.getProperty("bundledvm");
- DEBUG("Found a vm bundled with the application: (" + bjvm + ")");
- m_localVMenabled = true;
- std::string home = FileUtils::concFile(resman.getCurrentDirectory(), bjvm);
- m_localVM.JavaHome = home;
- } else
- {
- m_localVMenabled = false;
- }
- DEBUG("Current directory is " + resman.getCurrentDirectory());
-}
-
-bool JavaMachineManager::run()
-{
- string vmorder = m_resman.getProperty(ResourceManager::KEY_JVMSEARCH);
-
- if (m_localVMenabled)
- {
- if (internalRun(m_localVM, "bundled"))
- {
- return true;
- }
-
-// DEBUG("Trying to use bundled VM " + m_localVM.JavaHome);
-// if (m_localVM.runProc(m_resman, m_useConsole, "bundled"))
-// {
-// m_exitCode = m_localVM.getExitCode();
-// return true;
-// }
-// if (m_localVM.run(m_resman, "bundled"))
-// return true;
- }
-
- if (vmorder == "")
- {
- vmorder = "registry;jdkpath;jrepath;javahome;jview;exepath";
- }
-
- DEBUG("JSmooth will now try to use the VM in the following order: " + vmorder);
-
- vector<string> jvmorder = StringUtils::split(vmorder, ";,", "");
-
- Version max(m_resman.getProperty(ResourceManager:: KEY_MAXVERSION));
- Version min(m_resman.getProperty(ResourceManager:: KEY_MINVERSION));
-
- for (vector<string>::const_iterator i = jvmorder.begin(); i != jvmorder.end(); i++)
- {
- DEBUG("------------------------------");
-
- if (*i == "registry")
- {
- DEBUG("Trying to use a JVM defined in the registry (" + StringUtils::toString(m_registryVms.size()) + " available)");
- string vms = "VM will be tried in the following order: ";
- for (int i=0; i<m_registryVms.size(); i++)
- {
- vms += m_registryVms[i].VmVersion.toString();
- vms += ";";
- }
- DEBUG(vms);
-
- for (int i=0; i<m_registryVms.size(); i++)
- {
- DEBUG("- Trying registry: " + m_registryVms[i].toString());
-
- if (internalRun(m_registryVms[i], "registry") == true)
- return true;
-
- DEBUG("Couldn't use this VM, now trying something else");
- }
- }
- else if ((*i == "jview") && m_acceptExe)
- {
- DEBUG("- Trying to launch the application with JVIEW");
- if (m_jviewVm.runProc(m_resman, ! m_useConsole))
- {
- return true;
- }
-
- }
- else if ((*i == "javahome") && (m_javahomeVm.size()>0))
- {
- DEBUG("- Trying to use JAVAHOME");
- if (internalRun(m_javahomeVm[0], "jrehome"))
- return true;
- }
- else if ((*i == "jrepath") && (m_jrepathVm.size()>0))
- {
- DEBUG("- Trying to use JRE_HOME");
- if (internalRun(m_jrepathVm[0], "jrehome"))
- return true;
- }
- else if (*i == "exepath")
- {
- DEBUG("- Trying to use PATH");
-
- SunJVMLauncher launcher;
- if (launcher.runProc(m_resman, m_useConsole, "path"))
- {
- m_exitCode = m_localVM.getExitCode();
- return true;
- }
- }
- }
-
- DEBUG("Couldn't run any suitable JVM!");
- return false;
-}
-
-
-bool JavaMachineManager::internalRun(SunJVMLauncher& launcher, const string& org)
-{
- if (m_acceptDLL && m_preferDLL)
- {
- if (launcher.run(m_resman, org))
- return true;
- }
-
- if (m_acceptExe)
- {
- if (launcher.runProc(m_resman, m_useConsole, org))
- {
- m_exitCode = launcher.getExitCode();
- return true;
- }
- }
-
- if (m_acceptDLL && !m_preferDLL)
- {
- if (launcher.run(m_resman, org))
- return true;
- }
-
- return false;
-}
-
-
-
-SunJVMLauncher* JavaMachineManager::runDLLFromRegistry(bool justInstanciate)
-{
- string vms = "DLL VM will be tried in the following order: ";
- for (int i=0; i<m_registryVms.size(); i++)
- {
- vms += m_registryVms[i].VmVersion.toString();
- vms += ";";
- }
- DEBUG(vms);
-
- for (int i=0; i<m_registryVms.size(); i++)
- {
- DEBUG("- Trying registry: " + m_registryVms[i].toString());
-
- bool res = m_registryVms[i].run(m_resman, "registry", justInstanciate);
-
- if (res)
- return &m_registryVms[i];
- }
-
- if (m_localVMenabled) {
- if (m_localVM.run(m_resman, "bundled", justInstanciate)) {
- return &m_localVM;
- } else {
- DEBUG("Bundled VM launch failed");
- }
- }
-
-
- return NULL;
-}
-
-void JavaMachineManager::setUseConsole(bool useConsole)
-{
- m_useConsole = useConsole;
-}
-
-void JavaMachineManager::setAcceptExe(bool acceptExe)
-{
- m_acceptExe = acceptExe;
-}
-
-void JavaMachineManager::setAcceptDLL(bool acceptDLL)
-{
- m_acceptDLL = acceptDLL;;
-}
-
-void JavaMachineManager::setPreferDLL(bool prefDLL)
-{
- m_preferDLL = prefDLL;
-}
-
-int JavaMachineManager::getExitCode()
-{
- return m_exitCode;
-}
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/commonjava/Makefile.win
deleted file mode 100644
index f4d86e7..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/Makefile.win
+++ /dev/null
@@ -1,60 +0,0 @@
-# Project: CommonJava
-# Makefile created by Dev-C++ 4.9.8.0
-
-RM = rm -f
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-MINGW =
-RES =
-OBJ = JniSmooth.o JVMBase.o SunJVMExe.o JArgs.o JClassProxy.o SunJVMDLL.o JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o JMethodCaller.o $(RES)
-LINKOBJ = JniSmooth.o JVMBase.o SunJVMExe.o JArgs.o JClassProxy.o SunJVMDLL.o JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o JMethodCaller.o $(RES)
-LIBS = -static-libgcc -L"$(MINGW)/lib"
-INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
-CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
-BIN = CommonJava.a
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-CFLAGS = $(INCS)
-
-.PHONY: all all-before all-after clean clean-custom
-
-all: all-before CommonJava.a all-after
-
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN)
-
-$(BIN): $(LINKOBJ) test.cpp
- ar r $(BIN) $(LINKOBJ)
- ranlib $(BIN)
- $(CPP) $(CXXFLAGS) test.cpp $(BIN) ../util-core/util-core.a -o test.exe
-
-JavaMachineManager.o: JavaMachineManager.cpp
- $(CPP) -c JavaMachineManager.cpp -o JavaMachineManager.o $(CXXFLAGS)
-
-JVMEnvVarLookup.o: JVMEnvVarLookup.cpp
- $(CPP) -c JVMEnvVarLookup.cpp -o JVMEnvVarLookup.o $(CXXFLAGS)
-
-JVMRegistryLookup.o: JVMRegistryLookup.cpp
- $(CPP) -c JVMRegistryLookup.cpp -o JVMRegistryLookup.o $(CXXFLAGS)
-
-MSJViewLauncher.o: MSJViewLauncher.cpp
- $(CPP) -c MSJViewLauncher.cpp -o MSJViewLauncher.o $(CXXFLAGS)
-
-Properties.o: Properties.cpp
- $(CPP) -c Properties.cpp -o Properties.o $(CXXFLAGS)
-
-ResourceManager.o: ResourceManager.cpp
- $(CPP) -c ResourceManager.cpp -o ResourceManager.o $(CXXFLAGS)
-
-SunJVMLauncher.o: SunJVMLauncher.cpp
- $(CPP) -c SunJVMLauncher.cpp -o SunJVMLauncher.o $(CXXFLAGS)
-
-Version.o: Version.cpp
- $(CPP) -c Version.cpp -o Version.o $(CXXFLAGS)
-
-global.o: global.cpp
- $(CPP) -c global.cpp -o global.o $(CXXFLAGS)
-
-JavaProperty.o: JavaProperty.cpp
- $(CPP) -c JavaProperty.cpp -o JavaProperty.o $(CXXFLAGS)
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/ResourceManager.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/ResourceManager.cpp
deleted file mode 100644
index 2fb31d2..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/ResourceManager.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "ResourceManager.h"
-
-char * const ResourceManager::KEY_MAINCLASSNAME = "mainclassname";
-char * const ResourceManager::KEY_ARGUMENTS = "arguments";
-char * const ResourceManager::KEY_CLASSPATH = "classpath";
-char * const ResourceManager::KEY_JVMSEARCH = "jvmsearch";
-char * const ResourceManager::KEY_MINVERSION = "minversion";
-char * const ResourceManager::KEY_MAXVERSION = "maxversion";
-char * const ResourceManager::KEY_NOJVMMESSAGE = "nojvmmessage";
-char * const ResourceManager::KEY_NOJVMURL = "nojvmurl";
-char * const ResourceManager::KEY_BUNDLEDVM = "bundledvm";
-char * const ResourceManager::KEY_CURRENTDIR = "currentdir";
-char * const ResourceManager::KEY_EMBEDJAR = "embedjar";
-
-ResourceManager::ResourceManager(std::string category, int propsId, int jarId, int jniId)
-{
- m_resourceCategory = category;
- m_resourcePropsId = propsId;
- m_resourceJarId = jarId;
-
- //
- // Load the Properties
- //
- DEBUG("Initialize properties...");
- std::string propsidstr = this->idToResourceName(propsId);
- HRSRC resprop = FindResource(NULL, propsidstr.c_str(), category.c_str());
- if (resprop != NULL)
- {
- int mainsize = 0;
- mainsize = SizeofResource(NULL, resprop);
- // char mainbuf[mainsize+1];
- HGLOBAL main = LoadResource(NULL, resprop);
- m_props.setData((const char*)main, mainsize);
- }
- else
- {
- m_lastError = "Can't find resource 'main name'";
- return;
- }
-
- //
- // Split the arguments
- //
- m_arguments = StringUtils::split(getProperty(KEY_ARGUMENTS, ""), " \t\n\r", "\"\'");
-
- //
- // loads the jar information
- //
- std::string jaridstr = this->idToResourceName(jarId);
- HRSRC resjar = FindResource(NULL, jaridstr.c_str(), category.c_str());
- if (resjar != NULL)
- {
- m_jarSize = SizeofResource(NULL, resjar);
- m_jarHandler = LoadResource(NULL, resjar);
- }
- else
- {
- m_lastError = "Can't find JAR resource!";
- return;
- }
-
-
- m_jnismoothSize = this->getResourceSize(jniId);
- m_jnismoothHandler = this->getResource(jniId);
-
- //
- // Extract the java properties from the Property
- //
- std::string jpropcountstr = m_props.get("javapropertiescount");
-
- string exepath = FileUtils::getExecutablePath();
- string exename = FileUtils::getExecutableFileName();
- string computername = FileUtils::getComputerName();
-
- int jpropcount = StringUtils::parseInt(jpropcountstr);
- DEBUG("Number of Java Parameters: "+jpropcountstr);
- for (int i=0; i<jpropcount; i++)
- {
- string namekey = string("javaproperty_name_") + StringUtils::toString(i);
- string valuekey = string("javaproperty_value_") + StringUtils::toString(i);
- string name = m_props.get(namekey);
- string value = m_props.get(valuekey);
-
- DEBUG("Setting up java properties SOURCE: " + name + "=" + value + " : property if exist: " +getProperty(name,""));
-
- value = StringUtils::replaceEnvironmentVariable(value);
- value = StringUtils::replace(value, "${EXECUTABLEPATH}", exepath);
- value = StringUtils::replace(value, "${EXECUTABLENAME}", exename);
- value = StringUtils::replace(value, "${COMPUTERNAME}", computername);
-
- JavaProperty jprop(name, value);
- m_javaProperties.push_back(jprop);
-
- DEBUG("Setting up java properties DESTINATION: " + name + "=" + value);
- }
-
- std::string curdirmodifier = m_props.get(ResourceManager::KEY_CURRENTDIR);
- if (curdirmodifier.length()>0)
- {
- int pos = string::npos;
- if ( (pos=curdirmodifier.find("${EXECUTABLEPATH}")) != string::npos)
- {
- m_currentDirectory = FileUtils::concFile(exepath, curdirmodifier.substr(pos + string("${EXECUTABLEPATH}").size()));
- // m_currentDirectory = StringUtils::replace(curdirmodifier, "${EXECUTABLEPATH}", exepath);
- }
- else
- {
- DEBUG(string("Currentdirectory =") + curdirmodifier);
- m_currentDirectory = curdirmodifier;
- // m_currentDirectory = FileUtils::concFile(FileUtils::getExecutablePath(), curdirmodifier);
- m_currentDirectory = StringUtils::replaceEnvironmentVariable(m_currentDirectory);
- }
- }
- else
- {
- m_currentDirectory = "";
- }
- // printf("CURDIR SET TO: [%s]\n", m_currentDirectory.c_str());
-}
-
-ResourceManager::~ResourceManager()
-{
- for (std::vector<std::string>::iterator i=m_deleteOnFinalize.begin(); i != m_deleteOnFinalize.end(); i++)
- {
- int res = DeleteFile(i->c_str());
- }
-}
-
-void ResourceManager::setProperty(const std::string& key, const std::string& value)
-{
- m_props.set(key, value);
-}
-
-void ResourceManager::saveTemp(std::string tempname, HGLOBAL data, int size)
-{
- if ((data == 0) || (size == 0))
- return;
-
- HANDLE temp = CreateFile(tempname.c_str(),
- GENERIC_WRITE,
- FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (temp != NULL)
- {
- DWORD reallyWritten;
- WriteFile(temp, data, size, &reallyWritten, NULL);
-
- // TODO: check the reallyWritten value for errors
-
- CloseHandle(temp);
- string s = tempname;
- // m_deleteOnFinalize.push_back(s);
- FileUtils::deleteOnReboot(s);
- }
-}
-
-std::string ResourceManager::getMainName() const
-{
- return getProperty(string("mainclassname"));
-}
-
-std::string ResourceManager::getProperty(const std::string& key) const
-{
- return m_props.get(key);
-}
-
-std::string ResourceManager::getProperty(const std::string& key, const std::string& def) const
-{
- if (m_props.contains(key))
- return m_props.get(key);
- else
- return def;
-}
-
-bool ResourceManager::getBooleanProperty(const std::string& key) const
-{
- std::string prop = getProperty(key, "0");
-
- if (StringUtils::parseInt(prop)==1)
- return true;
-
- if (StringUtils::toLowerCase(prop) == "true")
- return true;
-
- return false;
-}
-
-std::string ResourceManager::saveJarInTempFile()
-{
- if (useEmbeddedJar() == false)
- return "";
-
- std::string tempfilename = FileUtils::createTempFileName(".jar");
- DEBUG("Created temporary filename to hold the jar (" + tempfilename + ")");
- saveTemp(tempfilename, m_jarHandler, m_jarSize);
- return tempfilename;
-}
-
-const vector<JavaProperty>& ResourceManager::getJavaProperties()
-{
- return m_javaProperties;
-}
-
-std::vector<std::string> ResourceManager::getNormalizedClassPathVector() const
-{
- std::string basepath = FileUtils::getExecutablePath();
- std::string curdirmodifier = getCurrentDirectory(); //getProperty(string(ResourceManager::KEY_CURRENTDIR));
- if (FileUtils::isAbsolute(curdirmodifier)){
- basepath = curdirmodifier;
- DEBUG("DEBUG: (absolut) Basepath is : " + basepath);
- } else {
- basepath = FileUtils::concFile(basepath, curdirmodifier);
- DEBUG("DEBUG: (not absolut) Basepath is : " + basepath);
- }
-
- std::string cp = getProperty(string(ResourceManager::KEY_CLASSPATH));
- vector<string>cps = StringUtils::split(cp, ";", "", false);
- for (int i=0; i<cps.size(); i++)
- {
- string lib = cps[i];
- DEBUG("ClassPath element is " + basepath + " + " +cps[i]);
-
- cps[i] = FileUtils::concFile(basepath, cps[i]);
- DEBUG("ClassPath element " + StringUtils::toString(i)+ "=" + cps[i]);
- }
-
- return cps;
-}
-
-std::string ResourceManager::getNormalizedClassPath() const
-{
- vector<string> cps = getNormalizedClassPathVector();
- return StringUtils::join(cps, ";");
-}
-
-std::string ResourceManager::getCurrentDirectory() const
-{
- return m_currentDirectory;
-}
-
-bool ResourceManager::useEmbeddedJar() const
-{
- std::string value = m_props.get(ResourceManager::KEY_EMBEDJAR);
- if (value == "true")
- return true;
- return false;
-}
-
-void ResourceManager::printDebug() const
-{
- DEBUG("ResourceManager resource configuration:");
- DEBUG(" - Resource category: " + m_resourceCategory);
- DEBUG(" - Current directory: " + m_currentDirectory);
-
- map<string, string> props = m_props.getDataCopy();
- DEBUG(" - Property count: " + StringUtils::toString(props.size()));
- for (map<string, string>::iterator i = props.begin(); i != props.end(); i++)
- {
- DEBUG(" - Property: " + i->first + "=<" + i->second+">");
- }
-}
-
-void ResourceManager::setUserArguments(std::vector<std::string> arguments)
-{
- m_arguments.clear();
-
- for (std::vector<std::string>::iterator i=arguments.begin(); i != arguments.end(); i++)
- {
- addUserArgument(*i);
- }
-}
-
-
-void ResourceManager::addUserArgument(std::string argument)
-{
- bool keyFound = false;
- if (argument.size()>3)
- {
- int pos = argument.find("=");
- if (pos != std::string::npos)
- {
- string key = argument.substr(2, pos-2);
- string value = argument.substr(pos+1);
- string argumentType = argument.substr(0,2);
- if (argumentType == "-J")
- {
- DEBUG("FOUND USER ARGUMENT for JSMOOTH: [" + key + "]=[" + value + "]");
- keyFound = true;
- setProperty(key, value);
- }
- if (argumentType == "-D")
- {
- DEBUG("FOUND USER ARGUMENT for JAVA: [" + key + "]=[" + value + "]");
- JavaProperty jprop(key, value);
- keyFound = true;
- m_javaProperties.push_back(jprop);
- }
- }
- }
- if (!keyFound)
- {
- m_arguments.push_back(argument);
-// setProperty(KEY_ARGUMENTS, getProperty(KEY_ARGUMENTS) + " " + StringUtils::requoteForCommandLine(StringUtils::escape(argument)) );
- }
-}
-
-
-std::vector<std::string> ResourceManager::getArguments()
-{
- return m_arguments;
-}
-
-int ResourceManager::getResourceSize(int id)
-{
- std::string propid = idToResourceName(id);
- HRSRC resprop = FindResource(NULL, propid.c_str(), m_resourceCategory.c_str());
- if (resprop != NULL)
- {
- return SizeofResource(NULL, resprop);
- }
- else
- return 0;
-}
-
-HGLOBAL ResourceManager::getResource(int id)
-{
- std::string propid = idToResourceName(id);
- HRSRC resprop = FindResource(NULL, propid.c_str(), m_resourceCategory.c_str());
- if (resprop != NULL)
- {
- return LoadResource(NULL, resprop);
- }
- else
- return 0;
-}
-
-
-std::string ResourceManager::saveJnismoothInTempFile()
-{
- if (m_jnismoothHandler == 0)
- {
- DEBUG("NO JNI SMOOTH ID !!");
- return "";
- }
-
- std::string tempfilename = FileUtils::createTempFileName(".jar");
- DEBUG("Saving jnismoothjar in " + tempfilename);
-
- DEBUG("Created temporary filename to hold the jar (" + tempfilename + ")");
- saveTemp(tempfilename, m_jnismoothHandler, m_jnismoothSize);
- return tempfilename;
-}
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/ResourceManager.h b/jsmooth-0.9.9-7-patch/skeletons/commonjava/ResourceManager.h
deleted file mode 100644
index 1c22fab..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/ResourceManager.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef RESOURCEMANAGER_H
-#define RESOURCEMANAGER_H
-
-#include <cstdio>
-#include <windows.h>
-#include <string>
-#include <vector>
-
-#include "common.h"
-#include "Properties.h"
-#include "FileUtils.h"
-#include "JavaProperty.h"
-
-/**
- * Manages the executable resources associated to a Java
- * application. This class manages the resources that are used to
- * store the data associated to a java application. Those resources
- * are:
- * - The JAR file, stored as a raw resource.
- * - The Property file, stored as a raw resource.
- *
- * The Property file contains an 8-bit text, as parsed and used by the
- * Properties class, which defines information relative to the java
- * application (for instance the name of the main class, the java
- * properties, and so on).
- *
- * @author Rodrigo Reyes <reyes at charabia.net>
- */
-
-class ResourceManager
-{
- private:
- std::string m_mainName;
- std::string m_resourceCategory;
- Properties m_props;
- std::string m_currentDirectory;
-
- int m_resourcePropsId;
- int m_resourceJarId;
- std::string m_lastError;
- HGLOBAL m_jarHandler;
- int m_jarSize;
- HGLOBAL m_jnismoothHandler;
- int m_jnismoothSize;
-
- std::vector<std::string> m_arguments;
-
- std::vector<std::string> m_deleteOnFinalize;
- std::vector<JavaProperty> m_javaProperties;
-
- public:
-
- static char * const KEY_MAINCLASSNAME;
- static char * const KEY_ARGUMENTS;
- static char * const KEY_CLASSPATH;
- static char * const KEY_JVMSEARCH;
- static char * const KEY_MINVERSION;
- static char * const KEY_MAXVERSION;
- static char * const KEY_NOJVMMESSAGE;
- static char * const KEY_NOJVMURL;
- static char * const KEY_BUNDLEDVM;
- static char * const KEY_CURRENTDIR;
- static char * const KEY_EMBEDJAR;
-
- /**
- * Constructs a ResourceManager which extract the jar and property
- * files from the resources defined by the given parameters. The
- * resource are loaded from the resource type and resource names
- * passed as parameters.
- *
- * @param category the resource type to look in
- * @param propsId the resource id, stored under the category type, for the property file
- * @param jarId the resource id, stored under the category type, for the jar file
- */
- ResourceManager(std::string category, int propsId, int jarId, int jniId = -1);
-
- /**
- * Default destructor. The detructor tries to delete all the
- * temporary files that have been created by the object. This is
- * mainly the files created by the saveJarInTempFile() method.
- *
- * @sa ResourceManager::saveJarInTempFile
- */
- ~ResourceManager();
-
- /** Saves the jar in a temporary folder. Extract the jar file
- * from the resource defined in the consructor, and saves it in
- * the temporary directory defined by the operating system.
- *
- * NOTE: if the KEY_EMBEDJAR key does not return "true", this method
- * does not save the jar, and returns an empty string ("").
- *
- * @return the filename of the temp file where the Jar can be found.
- */
- std::string saveJarInTempFile();
-
- std::string saveJnismoothInTempFile();
-
- /** Returns the name of the main class. The main class is the
- * class used to launch the java application. The static "public
- * void main(String[])" method of this class is called to start
- * the program.
- *
- * @return the name of the main class
- */
- std::string getMainName() const;
-
- /**
- * Returns the last error string. This is the string that describes
- * the last error that was raised by an operation on the object.
- * @return a string
- */
- std::string getLastErrorString()
- {
- return m_lastError;
- }
-
- /**
- * Retrieves a property value from the Properties resource defined
- * in the constructor.
- *
- * @param key the name of the property
- * @return a string that contains the value of the property, or an empty string if the property does not exist.
- */
- std::string getProperty(const std::string& key) const;
- std::string getProperty(const std::string& key, const std::string& def) const;
- bool getBooleanProperty(const std::string& key) const;
-
- /**
- * Adds a new property.
- *
- * @param key the name of the property
- * @param value the value associated to the property
- */
- void setProperty(const std::string& key, const std::string& value);
-
- std::vector<std::string> getNormalizedClassPathVector() const;
- std::string getNormalizedClassPath() const;
-
- /**
- * Return the list of JavaProperty elements defined in the property
- * resource.
- *
- * @return a vector of JavaProperty elements, or an empty vector if none are defined.
- */
- const vector<JavaProperty>& getJavaProperties();
-
- std::string getCurrentDirectory() const;
-
- bool useEmbeddedJar() const;
-
- void printDebug() const;
-
- void setUserArguments(std::vector<std::string> arguments);
- void addUserArgument(std::string argument);
-
- std::vector<std::string> getArguments();
-
- int getResourceSize(int id);
- HGLOBAL getResource(int id);
-
- private:
- void saveTemp(std::string tempname, HGLOBAL data, int size);
-
- std::string idToResourceName(int id) const
- {
- char buffer[32];
- sprintf(buffer, "%d", id);
- std::string result("#");
- result += buffer;
- return result;
- }
-
-};
-
-
-#endif
-
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMDLL.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMDLL.cpp
deleted file mode 100644
index d7efa55..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMDLL.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-
-#include "SunJVMDLL.h"
-
-#include "JClassProxy.h"
-#include "JniSmooth.h"
-
-SunJVMDLL::SunJVMDLL(const std::string& jvmdll, const Version& v)
-{
- m_dllpath = jvmdll;
- m_version = v;
- m_statusCode = SunJVMDLL::JVM_NOT_STARTED;
- m_vmlib = NULL;
-}
-
-SunJVMDLL::~SunJVMDLL()
-{
- if (m_vmlib != NULL)
- {
- FreeLibrary(m_vmlib);
- }
-}
-
-bool SunJVMDLL::run(const std::string& mainclass, bool waitDeath)
-{
- if (m_statusCode == SunJVMDLL::JVM_NOT_STARTED)
- instanciate();
-
- if (m_statusCode == SunJVMDLL::JVM_LOADED)
- {
- JClassProxy disp(this, mainclass);
- jstring emptystr = newUTFString(std::string(""));
- jobjectArray mainargs = newObjectArray(m_arguments.size(), "java.lang.String", emptystr);
- for (int i =0; i<m_arguments.size(); i++)
- {
- env()->SetObjectArrayElement(mainargs, i, newUTFString(m_arguments[i]));
- }
- printf("arguments array = %d\n", mainargs);
- jvalue ma[1];
- ma[0].l = mainargs;
- disp.invokeStatic(std::string("void main(java.lang.String[] args)"), ma);
- if (waitDeath == true)
- m_javavm->DestroyJavaVM();
- return true;
- }
-
- return false;
-}
-
-void SunJVMDLL::join()
-{
- if (m_statusCode == SunJVMDLL::JVM_LOADED)
- {
- m_javavm->DestroyJavaVM();
- }
-}
-
-bool SunJVMDLL::instanciate()
-{
- m_vmlib = LoadLibrary(m_dllpath.c_str());
- if (m_vmlib == NULL)
- {
- m_statusCode = SunJVMDLL::JVM_DLL_CANT_LOAD;
- return false;
- }
- CreateJavaVM_t CreateJavaVM = (CreateJavaVM_t)GetProcAddress(m_vmlib, "JNI_CreateJavaVM");
- GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)GetProcAddress(m_vmlib, "JNI_GetDefaultJavaVMInitArgs");
-
- if ((CreateJavaVM == NULL) || (GetDefaultJavaVMInitArgs == NULL))
- {
- m_statusCode = SunJVMDLL::JVM_CANT_USE_VM;
- return false;
- }
-
- DEBUG("VM Created successfully");
-
- m_javavm = new JavaVM();
- m_javaenv = new JNIEnv();
-
- DEBUG("DLL Setup on " + m_version.toString());
- bool res;
- if ((m_version.getMajor() == 1) && (m_version.getMinor() == 1))
- res = setupVM11DLL(CreateJavaVM, GetDefaultJavaVMInitArgs);
- else
- res = setupVM12DLL(CreateJavaVM, GetDefaultJavaVMInitArgs);
-
- registerJniSmooth();
-
- DEBUG("Result code on DLL: " + StringUtils::toString(res));
- if (res)
- {
- m_statusCode = SunJVMDLL::JVM_LOADED;
- return true;
- }
-
- m_statusCode = SunJVMDLL::JVM_CANT_USE_VM;
- return false;
-}
-
-bool SunJVMDLL::setupVM12DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs)
-{
- vector<string> jpropstrv;
- if (m_vmParameter != "")
- {
- std::vector<std::string> vmParameter = StringUtils::split(m_vmParameter, " ", " ", false);
- for (std::vector<std::string>::iterator i=vmParameter.begin(); i != vmParameter.end(); i++)
- {
- jpropstrv.push_back(*i);
- }
- }
-
- for (int i=0; i<m_properties.size(); i++)
- if(m_properties[i].getName()[0]=='-') {
- jpropstrv.push_back( StringUtils::requoteForCommandLine(m_properties[i].getName()));
- } else {
- jpropstrv.push_back( StringUtils::requoteForCommandLine("-D" + m_properties[i].getName()) + "=" + StringUtils::requoteForCommandLine(m_properties[i].getValue()));
- }
-
-// DEBUG("MAXHEAP: " + StringUtils::toString(m_maxHeap));
-// DEBUG("INITIALHEAP: " + StringUtils::toString(m_initialHeap));
-
- if (m_maxHeap > 0)
- {
- jpropstrv.push_back("-Xmx" +StringUtils::toString(m_maxHeap));
- }
-
- if (m_initialHeap > 0)
- {
- jpropstrv.push_back("-Xms" + StringUtils::toString(m_initialHeap));
- }
-
- JavaVMInitArgs vm_args;
- GetDefaultJavaVMInitArgs(&vm_args);
-
- JavaVMOption options[1 + jpropstrv.size()];
- std::string cpoption = "-Djava.class.path=" + StringUtils::join(m_pathElements, ";");
-
- DEBUG("Classpath: " + cpoption);
- options[0].optionString = (char*)cpoption.c_str();
- vm_args.version = 0x00010002;
- vm_args.version = JNI_VERSION_1_2;
- vm_args.options = options;
- vm_args.nOptions = 1 + jpropstrv.size();
-
- for (int i=0; i<jpropstrv.size(); i++)
- {
- options[1 + i].optionString = (char*)jpropstrv[i].c_str();
- DEBUG(string("Option added:") + options[1+i].optionString);
- }
-
- vm_args.ignoreUnrecognized = JNI_TRUE;
-
- //
- // Create the VM
- if (CreateJavaVM( &m_javavm, &m_javaenv, &vm_args) != 0)
- {
- DEBUG("Can't create VM");
- m_statusCode = SunJVMDLL::JVM_CANT_CREATE_VM;
- return false;
- }
-
- DEBUG("VM 1.2+ Created successfully !!");
- return true;
-}
-
-bool SunJVMDLL::setupVM11DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs)
-{
- JDK1_1InitArgs vm_args;
- vm_args.version = 0x00010001;
- GetDefaultJavaVMInitArgs(&vm_args);
-
- if (m_maxHeap > 0)
- vm_args.maxHeapSize = m_maxHeap;
- if (m_initialHeap > 0)
- vm_args.minHeapSize = m_initialHeap;
-
- //
- // create the properties array
- //
- char const * props[m_properties.size()+1];
- vector<string> jpropstrv;
-
- for (int i=0; i<m_properties.size(); i++)
- jpropstrv[i] = m_properties[i].getName() + "=" + m_properties[i].getValue();
-
- for (int i=0; i<m_properties.size(); i++)
- props[i] = jpropstrv[i].c_str();
- props[m_properties.size()] = NULL;
-
- vm_args.properties = (char**)props;
-
- /* Append USER_CLASSPATH to the default system class path */
-
- std::string classpath = vm_args.classpath;
- classpath += StringUtils::join(m_pathElements, ";");
-
- DEBUG("Classpath = " + classpath);
- vm_args.classpath = (char*)classpath.c_str();
-
- //
- // Create the VM
- if (CreateJavaVM( &m_javavm, &m_javaenv, &vm_args) != 0)
- {
- DEBUG("Can't create VM");
- m_statusCode = SunJVMDLL::JVM_CANT_CREATE_VM;
- return false;
- }
- DEBUG("VM 1.1 Created successfully !!");
- return true;
-}
-
-
-jclass SunJVMDLL::findClass(const std::string& clazz)
-{
- std::string classname = StringUtils::replace(clazz,".", "/");
- DEBUG("Looking up for class <" + classname + ">");
- jclass cls = env()->FindClass(classname.c_str());
- if (cls == 0)
- DEBUG("Can't find class " + classname + " !");
- return cls;
-}
-
-jmethodID SunJVMDLL::findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic)
-{
- std::string sig = StringUtils::replace(signature, ".", "/");
-
- jmethodID mid;
- if (isStatic)
- mid = env()->GetStaticMethodID(cls, methodname.c_str(), sig.c_str());
- else
- mid = env()->GetMethodID(cls, methodname.c_str(), sig.c_str());
-
- return mid;
-}
-
-JavaVM* SunJVMDLL::getJavaVM()
-{
- return m_javavm;
-}
-
-void SunJVMDLL::setIntField(jclass cls, jobject obj, const std::string& fieldName, int value)
-{
- jfieldID binding = env()->GetFieldID(cls, fieldName.c_str(), "I");
- env()->SetIntField(obj, binding, (jint)value);
-}
-
-void SunJVMDLL::setLongField(jclass cls, jobject obj, const std::string& fieldName, jlong value)
-{
- jfieldID binding = env()->GetFieldID(cls, fieldName.c_str(), "J");
- env()->SetLongField(obj, binding, (jlong)value);
-}
-
-void SunJVMDLL::setObjectField(jclass cls, jobject obj, const std::string& fieldName, const std::string& fieldclass, jobject value)
-{
- std::string fc = "L" + StringUtils::replace(fieldclass, "." , "/") + ";";
- jfieldID binding = env()->GetFieldID(cls, fieldName.c_str(), fc.c_str());
- env()->SetObjectField(obj, binding, value);
-}
-
-jstring SunJVMDLL::newUTFString(const std::string& str)
-{
- return env()->NewStringUTF(str.c_str());
-}
-
-jobject SunJVMDLL::newObject(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->NewObjectA(clazz, methodid, arguments);
-}
-
-jobjectArray SunJVMDLL::newObjectArray(int size, jclass clazz, jobject initialValue)
-{
- return env()->NewObjectArray((jsize)size, clazz, initialValue);
-}
-
-jobjectArray SunJVMDLL::newObjectArray(int size, const std::string& classname, jobject initialValue)
-{
- jclass cls = findClass(classname);
- return newObjectArray(size, cls, initialValue);
-}
-
-//
-// Static method invocation
-//
-
-void SunJVMDLL::invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- env()->CallStaticVoidMethodA(clazz, methodid, arguments);
-}
-
-jboolean SunJVMDLL::invokeBooleanStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticBooleanMethodA(clazz, methodid, arguments);
-}
-
-jbyte SunJVMDLL::invokeByteStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticByteMethodA(clazz, methodid, arguments);
-}
-
-jchar SunJVMDLL::invokeCharStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticCharMethodA(clazz, methodid, arguments);
-}
-
-jshort SunJVMDLL::invokeShortStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticShortMethodA(clazz, methodid, arguments);
-}
-
-jint SunJVMDLL::invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticIntMethodA(clazz, methodid, arguments);
-}
-
-jlong SunJVMDLL::invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticLongMethodA(clazz, methodid, arguments);
-}
-
-jfloat SunJVMDLL::invokeFloatStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticFloatMethodA(clazz, methodid, arguments);
-}
-
-jdouble SunJVMDLL::invokeDoubleStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticDoubleMethodA(clazz, methodid, arguments);
-}
-
-jobject SunJVMDLL::invokeObjectStatic(jclass clazz, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallStaticObjectMethodA(clazz, methodid, arguments);
-}
-
-
-//
-// method invocation
-//
-
-void SunJVMDLL::invokeVoid(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- env()->CallVoidMethodA(obj, methodid, arguments);
-}
-
-jboolean SunJVMDLL::invokeBoolean(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallBooleanMethodA(obj, methodid, arguments);
-}
-
-jbyte SunJVMDLL::invokeByte(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallByteMethodA(obj, methodid, arguments);
-}
-
-jchar SunJVMDLL::invokeChar(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallCharMethodA(obj, methodid, arguments);
-}
-
-jshort SunJVMDLL::invokeShort(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallShortMethodA(obj, methodid, arguments);
-}
-
-jint SunJVMDLL::invokeInt(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallIntMethodA(obj, methodid, arguments);
-}
-
-jlong SunJVMDLL::invokeLong(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallLongMethodA(obj, methodid, arguments);
-}
-
-jfloat SunJVMDLL::invokeFloat(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallFloatMethodA(obj, methodid, arguments);
-}
-
-jdouble SunJVMDLL::invokeDouble(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallDoubleMethodA(obj, methodid, arguments);
-}
-
-jobject SunJVMDLL::invokeObject(jobject& obj, jmethodID& methodid, jvalue arguments[])
-{
- return env()->CallObjectMethodA(obj, methodid, arguments);
-}
-
-bool SunJVMDLL::registerMethod(const std::string& classname, const std::string& methodname, const std::string& signature,
- void* fn)
-{
- jclass cc = this->findClass(classname);
- if (cc == 0)
- return false;
- JNINativeMethod jnm;
- jnm.name = (char*)methodname.c_str();
- jnm.signature = (char*)signature.c_str();
- jnm.fnPtr = fn;
-
- int res = env()->RegisterNatives(cc, &jnm, 1);
- if (res != 0)
- return false;
-
- return true;
-}
-
-bool SunJVMDLL::registerJniSmooth()
-{
- registerNativeMethods(this);
- return true;
-}
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMExe.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMExe.cpp
deleted file mode 100644
index aa3b518..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMExe.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "SunJVMExe.h"
-
-#include <vector>
-#include <string>
-#include "Process.h"
-#include "FileUtils.h"
-
-SunJVMExe::SunJVMExe(const std::string& jrehome)
-{
- m_jrehome = jrehome;
-}
-
-SunJVMExe::SunJVMExe(const std::string& jrehome, const Version& v)
-{
- m_jrehome = jrehome;
- m_version = v;
-}
-
-bool SunJVMExe::run(const std::string& mainclass, bool useconsole)
-{
- if (!m_version.isValid())
- {
- m_version = guessVersion();
- }
-
- if (!m_version.isValid())
- return false;
-
- std::vector<std::string> execv;
-
- execv.push_back(StringUtils::requoteForCommandLine(lookUpExecutable(useconsole)));
-
- if (m_vmParameter != "")
- {
- std::vector<std::string> vmParameter = StringUtils::split(m_vmParameter, " ", " ", false);
- for (std::vector<std::string>::iterator i=vmParameter.begin(); i != vmParameter.end(); i++)
- {
- execv.push_back(*i);
- }
- }
-
- if (m_maxHeap > 0)
- {
- if ((m_version.getMajor()==1)&&(m_version.getMinor()==1))
- execv.push_back("-mx" + StringUtils::toString(m_maxHeap));
- else
- execv.push_back("-Xmx" + StringUtils::toString(m_maxHeap));
- }
-
- if (m_initialHeap > 0)
- {
- if ((m_version.getMajor()==1)&&(m_version.getMinor()==1))
- execv.push_back("-ms" + StringUtils::toString(m_initialHeap));
- else
- execv.push_back("-Xms" + StringUtils::toString(m_initialHeap));
- }
-
- for (int i=0; i<m_properties.size(); i++)
- if(m_properties[i].getName()[0]=='-') {
- execv.push_back( StringUtils::requoteForCommandLine(m_properties[i].getName()));
- } else {
- execv.push_back( StringUtils::requoteForCommandLine("-D" + m_properties[i].getName()) + "=" + StringUtils::requoteForCommandLine(m_properties[i].getValue()));
- }
-
- std::string classpath;
- if ((m_version.getMajor()==1)&&(m_version.getMinor()==1))
- classpath = getClassPath(true);
- else
- classpath = getClassPath(false);
-
- if (classpath.size() > 0)
- execv.push_back("-classpath " + StringUtils::requoteForCommandLine(classpath));
-
- execv.push_back(mainclass);
-
- for (int i=0; i<m_arguments.size(); i++)
- {
- execv.push_back( StringUtils::requoteForCommandLine(m_arguments[i]) );
- }
-
- std::string execmd = StringUtils::join(execv, " ");
- DEBUG("COMMAND: <" + execmd + ">");
-
- Process proc(execmd, useconsole);
- if (proc.run())
- {
- DEBUG("Started successfully");
- proc.join();
- m_exitCode = proc.getExitCode();
- return true;
- }
- else
- {
- DEBUG("Failed running " + execmd);
- }
- return false;
-}
-
-
-std::string SunJVMExe::lookUpExecutable(bool useconsole)
-{
- std::string java;
-
- if (m_jrehome.size() == 0)
- {
- return useconsole?"java.exe":"javaw.exe";
- }
-
- if (useconsole)
- {
- if (FileUtils::fileExists(m_jrehome, "bin\\java.exe"))
- java = FileUtils::concFile(m_jrehome, "bin\\java.exe");
- else if (FileUtils::fileExists(m_jrehome, "bin\\jre.exe"))
- java = FileUtils::concFile(m_jrehome, "bin\\jre.exe");
- else
- {
- std::vector<std::string> javas = FileUtils::recursiveSearch(m_jrehome, "java.exe");
- DEBUG("REC: " + StringUtils::toString(javas));
-
- if (javas.size() == 0)
- javas = FileUtils::recursiveSearch(m_jrehome, "jre.exe");
-
- if (javas.size() > 0)
- java = javas[0];
- }
- }
- else
- {
- if (FileUtils::fileExists(m_jrehome, "bin\\javaw.exe"))
- java = FileUtils::concFile(m_jrehome, "bin\\javaw.exe");
- else if (FileUtils::fileExists(m_jrehome, "bin\\jrew.exe"))
- java = FileUtils::concFile(m_jrehome, "bin\\jrew.exe");
- else
- {
- std::vector<std::string> javas = FileUtils::recursiveSearch(m_jrehome, "javaw.exe");
-
- DEBUG("REC: " + StringUtils::toString(javas));
-
- if (javas.size() == 0)
- javas = FileUtils::recursiveSearch(m_jrehome, "jrew.exe");
-
- if (javas.size() > 0)
- java = javas[0];
- }
- }
-
- return java;
-}
-
-Version SunJVMExe::guessVersion()
-{
- std::string exepath = lookUpExecutable(true);
- string exeline = exepath + " -version";
-
- Version result;
-
- // Return immediatly if the exe does not exist
- if (!FileUtils::fileExists(exepath))
- return result;
-
- string tmpfilename = FileUtils::createTempFileName(".tmp");
-
- Process proc(exeline, true);
- proc.setRedirect(tmpfilename);
- proc.run();
- proc.join();
-
- std::string voutput = FileUtils::readFile(tmpfilename);
- vector<string> split = StringUtils::split(voutput, " \t\n\r", "\"");
- for (vector<string>::iterator i=split.begin(); i != split.end(); i++)
- {
- Version v(*i);
- if (v.isValid())
- {
- result = v;
- break;
- }
- }
-
- FileUtils::deleteOnReboot(tmpfilename);
- return result;
-}
-
-
-std::string SunJVMExe::getClassPath(bool full)
-{
- std::vector<std::string> cp;
- for (std::vector<std::string>::const_iterator i=m_pathElements.begin(); i!=m_pathElements.end(); i++)
- cp.push_back(*i);
-
- if (full)
- {
- std::string javaexe = lookUpExecutable(true);
- std::string home = FileUtils::getParent( FileUtils::getParent( javaexe ));
- if (FileUtils::fileExists(home))
- {
- vector<string> cpzips = FileUtils::recursiveSearch(home, "*.zip");
- cp.insert(cp.end(), cpzips.begin(), cpzips.end());
- vector<string> cpjars = FileUtils::recursiveSearch(home, "*.jar");
- cp.insert(cp.end(), cpjars.begin(), cpjars.end());
- }
- }
-
- return StringUtils::join(cp, ";");
-}
-
-int SunJVMExe::getExitCode()
-{
- return m_exitCode;
-}
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMLauncher.cpp b/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMLauncher.cpp
deleted file mode 100644
index 6441f11..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/SunJVMLauncher.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "SunJVMLauncher.h"
-#include "Process.h"
-
-#include "SunJVMDLL.h"
-#include "JArgs.h"
-#include "JClassProxy.h"
-
-extern "C" {
- static jint JNICALL myvprintf(FILE *fp, const char *format, va_list args)
- {
- DEBUG("MYPRINTF");
- }
- void JNICALL myexit(jint code)
- {
- DEBUG("EXIT CALLED FROM JVM DLL");
- exit(code);
- }
-}
-
-std::string SunJVMLauncher::toString() const
-{
- return "<" + JavaHome + "><" + RuntimeLibPath + "><" + VmVersion.toString() + ">";
-}
-
-bool SunJVMLauncher::run(ResourceManager& resource, const string& origin, bool justInstanciate)
-{
- DEBUG("Running now " + this->toString() + ", instanciate=" + (justInstanciate?"yes":"no"));
-
- Version max(resource.getProperty(ResourceManager:: KEY_MAXVERSION));
- Version min(resource.getProperty(ResourceManager:: KEY_MINVERSION));
-
- // patch proposed by zregvart: if you're using bundeled JVM, you
- // apriori know the version bundled and we can trust. The version
- // check is therefore unrequired.
- if (origin != "bundled") {
-
- if (VmVersion.isValid() == false)
- {
- DEBUG("No version identified for " + toString());
- SunJVMExe exe(this->JavaHome);
- VmVersion = exe.guessVersion();
- DEBUG("Version found: " + VmVersion.toString());
- }
-
- if (VmVersion.isValid() == false)
- {
- DEBUG("No version found, can't instanciate DLL without it");
- return false;
- }
-
- if (min.isValid() && (VmVersion < min))
- return false;
-
- if (max.isValid() && (max < VmVersion))
- return false;
- }
-
- DEBUG("Launching " + toString());
-
- //
- // search for the dll if it's not set in the registry, or if the
- // file doesn't exist
- //
- if ( (this->JavaHome.size()>0)
- && ((this->RuntimeLibPath.size() == 0) || (!FileUtils::fileExists(this->RuntimeLibPath))) )
- {
- std::string assump = FileUtils::concFile(this->JavaHome, "jre\\bin\\jvm.dll");
- std::string assump2 = FileUtils::concFile(this->JavaHome, "jre\\bin\\server\\jvm.dll"); // for JRE 1.5+
- std::string assump3 = FileUtils::concFile(this->JavaHome, "jre\\bin\\client\\jvm.dll"); // for JRE 1.5+
- std::string assump4 = FileUtils::concFile(this->JavaHome, "bin\\javai.dll"); // For JRE 1.1
-
- if (FileUtils::fileExists(assump))
- this->RuntimeLibPath = assump;
- else if (FileUtils::fileExists(assump2))
- this->RuntimeLibPath = assump2;
- else if (FileUtils::fileExists(assump3))
- this->RuntimeLibPath = assump3;
- else if (FileUtils::fileExists(assump4))
- this->RuntimeLibPath = assump4;
- else
- {
- vector<string> dlls = FileUtils::recursiveSearch(this->JavaHome, string("jvm.dll"));
- if (dlls.size() > 0)
- this->RuntimeLibPath = dlls[0];
- }
- }
-
- if (FileUtils::fileExists(this->RuntimeLibPath))
- {
- DEBUG("RuntimeLibPath used: " + this->RuntimeLibPath);
- Version v = this->VmVersion;
- if (!v.isValid())
- {
- v = min;
- if (!v.isValid())
- v = Version("1.2.0");
- DEBUG("No version, trying with " + v.toString());
- }
-
- m_dllrunner = new SunJVMDLL(this->RuntimeLibPath, v);
- // set up the vm parameters...
- setupVM(resource, m_dllrunner);
-
- if (justInstanciate)
- return m_dllrunner->instanciate();
- else
- return m_dllrunner->run(resource.getProperty(ResourceManager::KEY_MAINCLASSNAME),
- true);
- }
-
- return false;
-}
-
-bool SunJVMLauncher::runProc(ResourceManager& resource, bool useConsole, const string& origin)
-{
- std::string classname = resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME));
-
- if (VmVersion.isValid() == false)
- {
- DEBUG("No version identified for " + toString());
- SunJVMExe exe(this->JavaHome);
- VmVersion = exe.guessVersion();
- DEBUG("Version found: " + VmVersion.toString());
- }
-
- if (VmVersion.isValid() == false)
- return false;
-
- if (origin != "bundled") {
-
- Version max(resource.getProperty(ResourceManager:: KEY_MAXVERSION));
- Version min(resource.getProperty(ResourceManager:: KEY_MINVERSION));
-
- if (min.isValid() && (VmVersion < min))
- return false;
-
- if (max.isValid() && (max < VmVersion))
- return false;
- }
-
- SunJVMExe exe(this->JavaHome, VmVersion);
- setupVM(resource, &exe);
- if (exe.run(classname, useConsole))
- {
- m_exitCode = exe.getExitCode();
- return true;
- }
- return false;
-}
-
-bool SunJVMLauncher::setupVM(ResourceManager& resource, JVMBase* vm)
-{
- //
- // create the properties array
- const vector<JavaProperty>& jprops = resource.getJavaProperties();
- for (int i=0; i<jprops.size(); i++)
- {
- vm->addProperty(jprops[i]);
- }
-
- if (resource.getProperty("maxheap") != "")
- vm->setMaxHeap( StringUtils::parseInt(resource.getProperty("maxheap") ));
-
- if (resource.getProperty("initialheap") != "")
- vm->setInitialHeap( StringUtils::parseInt(resource.getProperty("initialheap") ));
-
- if (resource.getProperty("vmparameter") != "")
- vm->setVmParameter( resource.getProperty("vmparameter") );
-
- if (resource.useEmbeddedJar())
- {
- std::string embj = resource.saveJarInTempFile();
- vm->addPathElement(embj);
- }
-
- std::string jnijar = resource.saveJnismoothInTempFile();
- if (jnijar != "")
- vm->addPathElement(jnijar);
-
- //
- // Define the classpath
- std::vector<std::string> classpath = resource.getNormalizedClassPathVector();
- for (int i=0; i<classpath.size(); i++)
- {
- vm->addPathElement(classpath[i]);
- }
-
- //
- // Defines the arguments passed to the java application
- // vm->setArguments(resource.getProperty(ResourceManager::KEY_ARGUMENTS));
- std::vector<std::string> args = resource.getArguments();
- for (int i=0; i<args.size(); i++)
- {
- vm->addArgument(args[i]);
- }
-
-}
-
-SunJVMDLL* SunJVMLauncher::getDLL()
-{
- return m_dllrunner;
-}
-
-bool operator < (const SunJVMLauncher& v1, const SunJVMLauncher& v2)
-{
- return v1.VmVersion < v2.VmVersion;
-}
-
-int SunJVMLauncher::getExitCode()
-{
- return m_exitCode;
-}
-
diff --git a/jsmooth-0.9.9-7-patch/skeletons/commonjava/Version.h b/jsmooth-0.9.9-7-patch/skeletons/commonjava/Version.h
deleted file mode 100644
index bd94101..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/commonjava/Version.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __VERSION_H_
-#define __VERSION_H_
-
-#include <cstdio>
-#include <string>
-
-#include "common.h"
-#include "StringUtils.h"
-
-/**
- * Manages versions as used by Sun's JVM. The version scheme used is
- * major.minor.sub, for instance 1.1.8 or 1.4.2.
- *
- * @author Rodrigo Reyes <reyes at charabia.net>
- */
-
-class Version
-{
- private:
- int m_major;
- int m_minor;
- int m_sub;
-
- public:
- std::string Value;
-
- /**
- * Creates a Version object from a string representation. This
- * string needs to start as a normal version, but don't need to
- * follow exactly the schema X.Y.Z. The Major number is mandatory,
- * but the Minor and Sub numbers are optional.
- *
- * If the string representation does not represent a valid
- * version, the object is said 'invalid', and returns false to the
- * isInvalid() method.
- *
- * @param val a string representation of the version.
- */
- Version(std::string val);
-
- /**
- * Creates an invalid Version object. The object created returns
- * false to the isValid() method.
- */
- Version();
-
- /**
- * Returns the major number of this Version.
- */
- int getMajor() const;
- /**
- * Returns the minor number of this Version.
- */
- int getMinor() const;
- /**
- * Returns the subminor number of this Version.
- */
- int getSubMinor() const;
-
- std::string toString() const;
-
- // bool operator > (const Version& v) const;
-
- friend bool operator < (const Version& v1, const Version& v2);
- friend bool operator <= (const Version& v1, const Version& v2);
-
- /**
- * A version object may be invalid if it does not refer to a valid
- * version. In such a case, the behaviour of object the is altered
- * as follows:
- *
- * - The getMajor(), getMinor(), and getSubMinor() methods return 0
- * - Any comparison (< or <=) between an invalid Version object
- * and another object (invalid or not) return true.
- */
- bool isValid() const;
-
- private:
- void parseValue(const std::string& val);
-
- int extractIntAt(const std::string& val, int pos) const;
-
- public:
- struct AscendingSort
- {
- bool operator()(const Version& v1, const Version& v2)
- {
- if (v1.getMajor() > v2.getMajor())
- return true;
- if (v1.getMajor() < v2.getMajor())
- return false;
-
- if (v1.getMinor() > v2.getMinor())
- return true;
- if (v1.getMinor() < v2.getMinor())
- return false;
-
- if (v1.getSubMinor() > v2.getSubMinor())
- return true;
- if (v1.getSubMinor() < v2.getSubMinor())
- return false;
-
- return false;
- }
- };
-
-};
-
-
-
-#endif
diff --git a/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/Makefile.win
deleted file mode 100644
index 8913456..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/Makefile.win
+++ /dev/null
@@ -1,32 +0,0 @@
-# Project: ConsoleWrapper
-# Makefile created by Dev-C++ 4.9.8.0
-
-RM = rm -f
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-RES = ConsoleWrapper_private.res
-OBJ = main.o $(RES)
-LINKOBJ = main.o $(RES)
-LIBS = -static-libgcc -L"${MINGW}/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a
-INCS = -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32"
-CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
-BIN = ConsoleWrapper.exe
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-CFLAGS = $(INCS)
-
-.PHONY: all all-before all-after clean clean-custom
-
-all: all-before ConsoleWrapper.exe all-after
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN) ConsoleWrapper_private.res
-
-$(BIN): $(LINKOBJ) ../commonjava/CommonJava.a
- $(CPP) $(LINKOBJ) -o "ConsoleWrapper.exe" $(LIBS)
-
-main.o: main.cpp
- $(CPP) -c main.cpp -o main.o $(CXXFLAGS)
-
-ConsoleWrapper_private.res: ConsoleWrapper_private.rc mainres.rc
- $(WINDRES) -i ConsoleWrapper_private.rc -J rc -o ConsoleWrapper_private.res -O coff
diff --git a/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/description64.skel b/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/description64.skel
deleted file mode 100644
index 2d2fced..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/description64.skel
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothskeleton>
-<debug>false</debug>
-<description>SKEL_CONSOLEWRAPPER_DESCRIPTION</description>
-<executableName>consolewrapper.exe</executableName>
-<resourceCategory>JAVA</resourceCategory>
-<resourceJarId>102</resourceJarId>
-<resourcePropsId>103</resourcePropsId>
-<shortName>Console Wrapper x64</shortName>
-<skeletonProperties>
-<description>SKEL_CUSTOMWRAPPER_PROPERTY_MESSAGE_DESCRIPTION</description>
-<idName>Message</idName>
-<label>SKEL_CUSTOMWRAPPER_PROPERTY_MESSAGE_LABEL</label>
-<type>textarea</type>
-<value>This program needs Java to run.
-Please download it at http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_CUSTOMWRAPPER_PROPERTY_KEYPRESS_DESCRIPTION</description>
-<idName>PressKey</idName>
-<label>SKEL_CUSTOMWRAPPER_PROPERTY_KEYPRESS_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
-<idName>Debug</idName>
-<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-</jsmoothskeleton>
diff --git a/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/mainres.rc b/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/mainres.rc
deleted file mode 100644
index 8bd397f..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/consolewrapper/mainres.rc
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include "resource.h"
-
-JARID JAVA "samplejar/sample.jar"
-PROPID JAVA "samplejar/sample.props"
-
-A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
-1 MANIFEST "../samplejar/sample.manifest"
diff --git a/jsmooth-0.9.9-7-patch/skeletons/samplejar/sample.manifest b/jsmooth-0.9.9-7-patch/skeletons/samplejar/sample.manifest
deleted file mode 100644
index 3a9962e..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/samplejar/sample.manifest
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <assemblyIdentity type="win32"
- name="myOrganization.myDivision.mySampleApp"
- version="0.0.0.0"
- processorArchitecture="ia64/x86"
- />
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
- <security>
- <requestedPrivileges>
- <requestedExecutionLevel level="requireAdministrator"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
-</assembly>
\ No newline at end of file
diff --git a/jsmooth-0.9.9-7-patch/skeletons/simplewrap/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/simplewrap/Makefile.win
deleted file mode 100644
index 5841f20..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/simplewrap/Makefile.win
+++ /dev/null
@@ -1,32 +0,0 @@
-# Project: JWrap
-# Makefile created by Dev-C++ 4.9.8.0
-
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-RES = JWrap_private.res
-OBJ = main.o $(RES)
-LINKOBJ = main.o $(RES)
-LIBS = -static-libgcc -L"${MINGW}/lib" -L"../commonjava" -L"../util-core" -mwindows ../commonjava/CommonJava.a ../util-core/util-core.a
-INCS = -I"/include" -I"$(JDK)/include/win32" -I"$(JDK)/include" -I"../commonjava" -I"../util-core"
-CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
-BIN = JWrap.exe
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-CFLAGS = $(INCS)
-
-.PHONY: all all-before all-after clean clean-custom
-
-all: all-before JWrap.exe all-after
-
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN) JWrap_private.res
-
-$(BIN): $(LINKOBJ) ../commonjava/CommonJava.a
- $(CPP) $(LINKOBJ) -o "JWrap.exe" $(LIBS)
-
-main.o: main.cpp
- $(CPP) -c main.cpp -o main.o $(CXXFLAGS)
-
-JWrap_private.res: JWrap_private.rc mainres.rc
- $(WINDRES) -i JWrap_private.rc -J rc -o JWrap_private.res -O coff
diff --git a/jsmooth-0.9.9-7-patch/skeletons/simplewrap/description64.skel b/jsmooth-0.9.9-7-patch/skeletons/simplewrap/description64.skel
deleted file mode 100644
index da01764..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/simplewrap/description64.skel
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothskeleton>
-<debug>false</debug>
-<description>SKEL_SIMPLEWRAPPER_DESCRIPTION</description>
-<executableName>jwrap.exe</executableName>
-<resourceCategory>JAVA</resourceCategory>
-<resourceJarId>102</resourceJarId>
-<resourcePropsId>103</resourcePropsId>
-<shortName>Windowed Wrapper x64</shortName>
-<skeletonProperties>
-<description>SKEL_SIMPLEWRAPPER_PROPERTY_MESSAGE_DESCRIPTION</description>
-<idName>Message</idName>
-<label>SKEL_SIMPLEWRAPPER_PROPERTY_MESSAGE_LABEL</label>
-<type>textarea</type>
-<value>Java has not been found on your computer. Do you want to download it?</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_SIMPLEWRAPPER_PROPERTY_URL_DESCRIPTION</description>
-<idName>URL</idName>
-<label>SKEL_SIMPLEWRAPPER_PROPERTY_URL_LABEL</label>
-<type>string</type>
-<value>http://www.java.com</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION</description>
-<idName>SingleProcess</idName>
-<label>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_SINGLEINSTANCE_DESCRIPTION</description>
-<idName>SingleInstance</idName>
-<label>SKEL_GENERIC_SINGLEINSTANCE</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
-<idName>JniSmooth</idName>
-<label>SKEL_GENERIC_JNISMOOTH</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
-<idName>Debug</idName>
-<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-</jsmoothskeleton>
diff --git a/jsmooth-0.9.9-7-patch/skeletons/simplewrap/mainres.rc b/jsmooth-0.9.9-7-patch/skeletons/simplewrap/mainres.rc
deleted file mode 100644
index e082dad..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/simplewrap/mainres.rc
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "resource.h"
-
-JARID JAVA "../samplejar/sample.jar"
-PROPID JAVA "../samplejar/sample.props"
-JNISMOOTHID JAVA "../jnismooth/jnismooth.jar"
-
-A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
-1 MANIFEST "../samplejar/sample.manifest"
diff --git a/jsmooth-0.9.9-7-patch/skeletons/util-core/FileUtils.cpp b/jsmooth-0.9.9-7-patch/skeletons/util-core/FileUtils.cpp
deleted file mode 100644
index f57ebff..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/util-core/FileUtils.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "FileUtils.h"
-
-string FileUtils::createTempFileName(const string& suffix)
-{
- char temppath[512];
- int tplen = GetTempPath(512, temppath);
-
- int counter = 0;
- string temp;
- do {
-
- temp = string(temppath) + "temp" + StringUtils::toString(counter) + suffix;
- counter ++;
-
- } while (GetFileAttributes(temp.c_str()) != 0xFFFFFFFF);
-
- return temp;
-}
-
-
-bool FileUtils::fileExists(const string& filename)
-{
- if (filename[0] == '"')
- {
- string unquoted = StringUtils::replace(filename, "\"", "");
- return GetFileAttributes(unquoted.c_str()) != 0xFFFFFFFF;
- }
- return GetFileAttributes(filename.c_str()) != 0xFFFFFFFF;
-}
-
-bool FileUtils::fileExists(const std::string& path, const std::string& filename)
-{
- std::string f = FileUtils::concFile(path, filename);
- return fileExists(f);
-}
-
-vector<string> FileUtils::recursiveSearch(const string& pathdir, const string& pattern)
-{
- vector<string> result;
- string path = StringUtils::replace(pathdir, "\"", "");
-
- WIN32_FIND_DATA data;
- string file = path + ((path[path.length()-1]=='\\')?"":"\\") + pattern;
-
- HANDLE handle = FindFirstFile(file.c_str(), &data);
- if (handle != INVALID_HANDLE_VALUE)
- {
- result.push_back(path + ((path[path.length()-1]=='\\')?"":"\\") + data.cFileName);
- for ( ; FindNextFile(handle, &data) == TRUE ; )
- {
- result.push_back(path + ((path[path.length()-1]=='\\')?"":"\\") + data.cFileName);
- }
-
- FindClose(handle);
- }
-
- handle = FindFirstFile((path + ((path[path.length()-1]=='\\')?"":"\\") + "*").c_str(), &data);
- if (handle == INVALID_HANDLE_VALUE)
- return result;
-
- do {
- string foundpath(data.cFileName);
- if ((foundpath != ".") && (foundpath != "..") && ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
- {
- string npath = path + ((path[path.length()-1]=='\\')?"":"\\") + data.cFileName;
- vector<string> tres = FileUtils::recursiveSearch(npath, pattern);
- result.insert(result.end(), tres.begin(), tres.end());
- }
- } while (FindNextFile(handle, &data));
- FindClose(handle);
-
- return result;
-}
-
-std::string FileUtils::extractFileName(const std::string& filename)
-{
- int start = filename.rfind("\\", filename.length()-1);
- if (start != filename.npos)
- {
- return filename.substr(start+1);
- }
- return filename;
-}
-
-std::string FileUtils::getExecutablePath()
-{
- char buffer[512];
- GetModuleFileName(NULL, buffer, 512);
- string full = buffer;
- int pos = full.rfind('\\', full.npos);
-
- return full.substr(0, pos+1);
-}
-
-std::string FileUtils::getExecutableFileName()
-{
- char buffer[512];
- GetModuleFileName(NULL, buffer, 512);
- string full = buffer;
- int pos = full.rfind('\\', full.npos);
-
- return full.substr(pos+1);
-}
-
-std::string FileUtils::getParent(const std::string &path)
-{
- if (path[path.length()-1] == '\\')
- return getParent( path.substr(0, path.size() - 1) );
-
- int pos = path.rfind('\\', path.npos);
- if (pos != path.npos)
- return path.substr(0, pos+1);
- else
- return path;
-}
-
-std::string FileUtils::getComputerName()
-{
- char buffer[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD size = MAX_COMPUTERNAME_LENGTH+1;
- GetComputerName(buffer, &size);
- return buffer;
-}
-
-std::string FileUtils::concFile(std::string path, std::string file)
-{
- if (FileUtils::isAbsolute(file))
- return file;
-
- if (path.length() > 0)
- {
- if (path[path.length()-1] != '\\')
- path += '\\';
- }
- path += file;
-
- return path;
-}
-
-std::string FileUtils::getFileExtension(const std::string& filename)
-{
- int pos = filename.rfind('.');
- if (pos != std::string::npos)
- {
- return filename.substr(pos+1);
- }
- return "";
-}
-
-bool FileUtils::isAbsolute(const std::string& filename)
-{
- if (((filename.length()>2) && (filename[1] == ':') && (filename[2] =='\\')) || ((filename.length() >2) && (filename[0] == '\\') && (filename[1]=='\\')))
- return true;
-
- return false;
-}
-
-void FileUtils::deleteOnReboot(std::string file)
-{
- MoveFileEx(file.c_str(), 0, MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-
-std::string FileUtils::readFile(const std::string& filename)
-{
- HANDLE f = CreateFile(filename.c_str(), GENERIC_READ,
- FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-
- std::string result;
-
- if (f != INVALID_HANDLE_VALUE)
- {
- char buffer[129];
- DWORD hasread;
- buffer[127] = 0;
-
- do {
- ReadFile(f, buffer, 127, &hasread, NULL);
- buffer[hasread] = 0;
- result += buffer;
- } while (hasread > 0);
-
- CloseHandle(f);
- }
- else
- {
- // printf("Can't open file %s\n",filename.c_str());
- }
-
- return result;
-}
diff --git a/jsmooth-0.9.9-7-patch/skeletons/util-core/FileUtils.h b/jsmooth-0.9.9-7-patch/skeletons/util-core/FileUtils.h
deleted file mode 100644
index 665c6af..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/util-core/FileUtils.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __FILEUTILS_H_
-#define __FILEUTILS_H_
-
-#include <windows.h>
-#include <string>
-#include <vector>
-
-#include "StringUtils.h"
-
-using namespace std;
-
-/** File access utility class.
- * This class contains static class members that provide facilities
- * for manamement of files.
- *
- * @author Rodrigo Reyes <reyes at charabia.net>
- */
-
-class FileUtils
-{
- public:
-
- /**
- * Creates a temp filename. This method builds a temporary file
- * name in the default windows temporary directory.
- *
- * @param suffix the suffix to use for the filename.
- */
- static string createTempFileName(const string& suffix);
-
- /**
- * Test wether a file exists.
- * @param filename the file name to check.
- * @return true if the file exists, false otherwise.
- */
- static bool fileExists(const string& filename);
-
- static bool fileExists(const std::string&path, const string& filename);
-
- /**
- * Lookup recursively for files matching a given pattern in a given
- * path. The method scans all the directory provided and its
- * subdirectories. Each file matching the pattern is added to the
- * resulting vector of strings.
- *
- * @param path the path of the directory to scan.
- * @param pattern the file pattern, for instance "*.zip".
- * @return a vector of string that contains the result.
- */
- static vector<string> recursiveSearch(const string& path, const string& pattern);
-
- /**
- * Extracts the file part of a file path. Given a path of the form
- * c:\\a\\b\\c\\d or c\\d, return the last component of the file path
- * (that is, d in the previous example).
- *
- * @param filename an absolute or relative filename.
- * @return a string with the file part of the file.
- */
- static std::string extractFileName(const std::string& filename);
-
- /**
- * Returns the path where the executable application is executed
- * from. This is not the current directory, but the directory path
- * where the application was found. For instance if the application
- * was runned at c:\\programs\\bin\\test.exe, it returns
- * c:\\programs\\bin\\.
- *
- * @return a std::string text that holds the path.
- */
- static std::string getExecutablePath();
-
-
- static std::string getParent(const std::string &path);
-
- /**
- * Returns the name of the executable binary that was used to start
- * the application.For instance if the application
- * was runned at c:\\programs\\bin\\test.exe, it returns
- * test.exe
- *
- * @return the executable name.
- */
- static std::string getExecutableFileName();
-
-
- /**
- * Returns the name of the computer.
- * @return a std::string that holds the computer name.
- */
- static std::string getComputerName();
-
- static std::string concFile(std::string path, std::string file);
-
- static std::string getFileExtension(const std::string& filename);
-
- static bool isAbsolute(const std::string& filename);
-
- static std::string readFile(const std::string& filename);
-
- static void deleteOnReboot(std::string file);
-
-};
-
-#endif
-
-
diff --git a/jsmooth-0.9.9-7-patch/skeletons/util-core/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/util-core/Makefile.win
deleted file mode 100644
index 29e409e..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/util-core/Makefile.win
+++ /dev/null
@@ -1,32 +0,0 @@
-# Project: util-core
-
-PROJECTNAME=util-core
-RM = rm -f
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-MINGW =
-RES =
-OBJ = SingleInstanceManager.o Process.o Log.o Thread.o FileUtils.o StringUtils.o DebugConsole.o $(RES)
-LIBS = -static-libgcc -L"$(MINGW)/lib"
-INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
-CXXINCS = -Os -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
-BIN = $(PROJECTNAME).a
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-CFLAGS = $(INCS)
-
-.PHONY: all all-before all-after clean clean-custom $(PROJECTNAME)
-
-all: all-before $(PROJECTNAME).a testmain.cpp all-after
-
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN) testmain.o test.exe
-
-$(BIN): $(OBJ)
- ar r $(BIN) $(OBJ)
- ranlib $(BIN)
- $(CPP) $(OBJ) testmain.o -o test.exe $(LIBS)
-
-$(PROJECTNAME).a: $(OBJ) testmain.o
-
diff --git a/jsmooth-0.9.9-7-patch/skeletons/util-core/StringUtils.h b/jsmooth-0.9.9-7-patch/skeletons/util-core/StringUtils.h
deleted file mode 100644
index f64078e..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/util-core/StringUtils.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003-2007 Rodrigo Reyes <reyes at charabia.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __STRINGUTILS_H_
-#define __STRINGUTILS_H_
-
-#include <cstdio>
-#include <string>
-#include <vector>
-#include <windows.h>
-
-using namespace std;
-
-/**
- * Provides basic string operations.
- *
- * @author Rodrigo Reyes <reyes at charabia.net>
- */
-
-class StringUtils
-{
- public:
- /**
- * Splits a string in several substrings. The split method takes a
- * string as input, and outputs a vector of string. The string split
- * is done according to 2 parameters:
- *
- * - the separators parameter, defines which chars are
- * separators. Typically, this is a string that contains spaces,
- * line-feed, and tabulation chars (" \n\t").
- *
- * - the quotechars parameter, is useful when your input contains
- * quoted string that should not be broken down into substrings. For
- * instance, a typical quote char is a quote or a double quote
- * (resp. ' and ").
- *
- * For example, is the input string is the line belows:
- * - this is "my string" and this is 'another one'.
- *
- * Here is the result of the call with the following parameters:
- * - separators = \\n\\r\\t
- * - quotechars = \\"\\'
- *
- * The output string is:
- * - this
- * - is
- * - my string
- * - and
- * - this
- * - is
- * - another one
- *
- * @param str the string to be splitted
- * @param separators a string that contains all the characters to be used as separators.
- * @param quotechars a string that contains all the characters that are used as quote chars.
- */
- static vector<string> split(const string& str, const string& separators, const string& quotechars, bool handleEscape = true, bool returnSeparators = false);
-
- /**
- * Converts a string to an int. If the string is not a valid
- * integer, it returns 0.
- *
- * @param val the string to parse
- * @return an integer value
- */
- static int parseInt(const string& val);
-
- static int parseHexa(const string& val);
-
- /**
- * Convers an integer to a string.
- *
- * @param val an integer
- * @return a string
- */
- static string toString(int val);
- static string toHexString(int val);
-
- /**
- * Provides a string representation of a vector of string. A vector
- * that contains 2 string aaa and bbb is represented as follows:
- * [aaa, bbb].
- *
- * @param seq a vector of string
- * @return a string representation
- */
- static string toString(const vector<string>& seq);
-
- /**
- * Copies the content of a string in a char array.
- *
- * @param from the string to copy from
- * @param to the destination array of chars
- * @param length the length of the array of char
- */
- static void copyTo(const string& from, char* to, int length);
-
- /**
- * Returns a copy of the string with the environment variables
- * replaced. The environment variable must be surrounded by %
- * signs. For each variable defined between 2 % signs, the method
- * tries to replace it by the value of the corresponding environment
- * variable. If no variable exists, it just replaces it with an
- * empty string.
- *
- * @param str the string to transform
- * @return the same string, but with all the environment variable replaced
- */
- static string replaceEnvironmentVariable(const string& str);
-
- static string replace(const string& str, const string& pattern, const string& replacement);
-
- static string join(const vector<string>& seq, const string& separator);
- static string trim(string& str);
-
- /**
- * If a string does not start with a quote ("), it returns a copy of
- * the string with enclosing quotes.
- *
- * @param str a string
- * @return a fixed copy of the string
- */
- static std::string fixQuotes(const string& str);
-
- static std::string escape(const string& str);
- static std::string unescape(const string& str);
- /**
- * Ensures a string is correctly quoted, the quotes are enclosing
- * the whole string, not a part of the string. For instance
- * <<"c:\\my path"\\bin>> is transformed into <<"c:\\my path\\bin">>
- *
- * @param str a string
- * @return a fixed copy of the string
- */
- static std::string requote(const string& str);
- static std::string requoteForCommandLine(const string& str);
- static std::string toLowerCase(const string& str);
-
- static std::string fixArgumentString(const std::string& arg);
-
- static std::string sizeToJavaString(int size);
- static std::string sizeToJavaString(std::string size);
-
-};
-
-#endif
diff --git a/jsmooth-0.9.9-7-patch/skeletons/util-net/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/util-net/Makefile.win
deleted file mode 100644
index 32b2aaa..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/util-net/Makefile.win
+++ /dev/null
@@ -1,34 +0,0 @@
-# Project: CommonJava
-
-PROJECTNAME=util-net
-RM = rm -f
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-MINGW = "c:/MinGW"
-FLTK-LDFLAGS = $(shell fltk-config --ldflags)
-FLTK-CXXFLAGS = $(shell fltk-config --cxxflags)
-RES =
-OBJ = WinHttpClient.o HttpClient.o URL.o downloadgui.o httpdownload.o $(RES)
-LIBS = -static-libgcc -L"$(MINGW)/lib" -lws2_32 -lwininet $(FLTK-LDFLAGS)
-CXXINCS = -Os -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" $(FLTK-CXXFLAGS)
-BIN = $(PROJECTNAME).a
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-
-.PHONY: all all-before all-after clean clean-custom $(PROJECTNAME)
-
-all: all-before $(PROJECTNAME).a testmain.cpp all-after
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN) test.exe testmain.o
-
-$(BIN): $(OBJ)
- ar r $(BIN) $(OBJ)
- ranlib $(BIN)
- $(CPP) -g $(OBJ) ../util-core/util-core.a testmain.o -o test.exe $(LIBS)
-
-$(PROJECTNAME).a: $(OBJ) testmain.o
-
-
-testmain.o: testmain.cpp
- $(CPP) -c testmain.cpp -o testmain.o $(CXXFLAGS)
diff --git a/jsmooth-0.9.9-7-patch/skeletons/winservice/Makefile.win b/jsmooth-0.9.9-7-patch/skeletons/winservice/Makefile.win
deleted file mode 100644
index 064aefc..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/winservice/Makefile.win
+++ /dev/null
@@ -1,33 +0,0 @@
-# Project: WinService Wrapper
-# Makefile created by Dev-C++ 4.9.8.0
-
-RM = rm -f
-#cmd /C DEL
-CPP = ${MINGW}/bin/${TARGET}-g++.exe
-CC = ${MINGW}/bin/${TARGET}-gcc.exe
-WINDRES = windres.exe
-RES = winservice_private.res
-OBJ = main.o $(RES)
-LINKOBJ = WinService.o main.o $(RES)
-LIBS = -static-libgcc -L"${MINGW}/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a
-INCS = -I"/include" -I"../util-core" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32"
-CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
-BIN = winservice.exe
-CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
-CFLAGS = $(INCS)
-
-.PHONY: all all-before all-after clean clean-custom
-
-all: all-before winservice.exe all-after
-
-clean: clean-custom
- $(RM) $(OBJ) $(BIN) winservice.o winservice_private.res
-
-$(BIN): $(LINKOBJ) ../commonjava/CommonJava.a
- $(CPP) $(LINKOBJ) -o "winservice.exe" $(LIBS)
-
-main.o: main.cpp
- $(CPP) -c main.cpp -o main.o $(CXXFLAGS)
-
-winservice_private.res: winservice_private.rc mainres.rc
- $(WINDRES) -i winservice_private.rc -J rc -o winservice_private.res -O coff
diff --git a/jsmooth-0.9.9-7-patch/skeletons/winservice/description64.skel b/jsmooth-0.9.9-7-patch/skeletons/winservice/description64.skel
deleted file mode 100644
index bede8c4..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/winservice/description64.skel
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<jsmoothskeleton>
-<debug>false</debug>
-<description>SKEL_WINSERVICE_DESCRIPTION</description>
-<executableName>winservice.exe</executableName>
-<resourceCategory>JAVA</resourceCategory>
-<resourceJarId>102</resourceJarId>
-<resourcePropsId>103</resourcePropsId>
-<shortName>WinService Wrapper x64</shortName>
-<skeletonProperties>
-<description>SKEL_WINSERVICE_NAME_DESCRIPTION</description>
-<idName>ServiceName</idName>
-<label>SKEL_WINSERVICE_NAME_LABEL</label>
-<type>string</type>
-<value>myservice</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_WINSERVICE_DISPLAYNAME_DESCRIPTION</description>
-<idName>ServiceDisplayName</idName>
-<label>SKEL_WINSERVICE_DISPLAYNAME_LABEL</label>
-<type>string</type>
-<value>My Service</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_WINSERVICE_PROPERTY_MESSAGE_DESCRIPTION</description>
-<idName>Message</idName>
-<label>SKEL_WINSERVICE_PROPERTY_MESSAGE_LABEL</label>
-<type>textarea</type>
-<value>This program needs Java to run. Please download it at http://www.java.comf</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_WINSERVICE_AUTOSTART_DESCRIPTION</description>
-<idName>Autostart</idName>
-<label>SKEL_WINSERVICE_AUTOSTART_LABEL</label>
-<type>boolean</type>
-<value>1</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_WINSERVICE_LOGFILE_DESCRIPTION</description>
-<idName>Logfile</idName>
-<label>SKEL_WINSERVICE_LOGFILE_LABEL</label>
-<type>string</type>
-<value>service.log</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_WINSERVICE_INTERACTIVE_DESCRIPTION</description>
-<idName>Interactive</idName>
-<label>SKEL_WINSERVICE_INTERACTIVE_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
-<idName>JniSmooth</idName>
-<label>SKEL_GENERIC_JNISMOOTH</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-<skeletonProperties>
-<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
-<idName>Debug</idName>
-<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
-<type>boolean</type>
-<value>0</value>
-</skeletonProperties>
-</jsmoothskeleton>
diff --git a/jsmooth-0.9.9-7-patch/skeletons/winservice/mainres.rc b/jsmooth-0.9.9-7-patch/skeletons/winservice/mainres.rc
deleted file mode 100644
index f2634f1..0000000
--- a/jsmooth-0.9.9-7-patch/skeletons/winservice/mainres.rc
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include "resource.h"
-
-JARID JAVA "../samplejar/sample.jar"
-PROPID JAVA "../samplejar/sample.props"
-JNISMOOTHID JAVA "../jnismooth/jnismooth.jar"
-
-A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
-1 MANIFEST "../samplejar/sample.manifest"
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/ExeCompiler.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/ExeCompiler.java
deleted file mode 100644
index d197382..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/ExeCompiler.java
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-package net.charabia.jsmoothgen.application;
-
-import net.charabia.jsmoothgen.pe.PEFile;
-import net.charabia.jsmoothgen.pe.PEResourceDirectory;
-import net.charabia.jsmoothgen.skeleton.SkeletonBean;
-
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.awt.image.IndexColorModel;
-import java.awt.image.PixelGrabber;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-public class ExeCompiler {
- private java.util.Vector m_errors = new java.util.Vector();
- private Vector m_listeners = new Vector();
-
- public interface StepListener {
- public void setNewState(int percentComplete, String state);
-
- public void failed();
-
- public void complete();
- }
-
- public void addListener(ExeCompiler.StepListener listener) {
- m_listeners.add(listener);
-
- }
-
- public void cleanErrors() {
- m_errors.removeAllElements();
- }
-
- public java.util.Vector getErrors() {
- return m_errors;
- }
-
- public class CompilerRunner implements Runnable {
- private File m_skelroot;
- private SkeletonBean m_skel;
- private JSmoothModelBean m_data;
- private File m_out;
- private File m_basedir;
-
- public CompilerRunner(File skelroot, SkeletonBean skel, File basedir, JSmoothModelBean data, File out) {
- m_skelroot = skelroot;
- m_skel = skel;
- m_data = data;
- m_out = out;
- m_basedir = basedir;
- }
-
- public void run() {
- try {
- compile(m_skelroot, m_skel, m_basedir, m_data, m_out);
- } catch (Exception exc) {
- exc.printStackTrace();
- }
- }
-
- public ExeCompiler getCompiler() {
- return ExeCompiler.this;
- }
- }
-
- public ExeCompiler.CompilerRunner getRunnable(File skelroot, SkeletonBean skel, File basedir, JSmoothModelBean data, File out) {
- return new CompilerRunner(skelroot, skel, basedir, data, out);
- }
-
- public void compileAsync(File skelroot, SkeletonBean skel, File basedir, JSmoothModelBean data, File out) {
- Thread t = new Thread(new CompilerRunner(skelroot, skel, basedir, data, out));
- t.start();
- }
-
- public boolean compile(File skelroot, SkeletonBean skel, File basedir, JSmoothModelBean data, File out) throws Exception {
- try {
- fireStepChange(0, "Starting compilation");
-
- File pattern = new File(skelroot, skel.getExecutableName());
- if (pattern.exists() == false) {
- m_errors.add("Error: Can't find any skeleton at " + skelroot);
- fireFailedChange();
- return false;
- }
-
- fireStepChange(10, "Scanning skeleton...");
- PEFile pe = new PEFile(pattern);
- pe.open();
- PEResourceDirectory resdir = pe.getResourceDirectory();
-
- boolean resb = false;
-
- //
- // Adds the jar only if the user selected one
- //
- if (data.getEmbeddedJar() == true) {
- if (data.getJarLocation() == null) {
- m_errors.add("Error: Jar is not specified!");
- fireFailedChange();
- return false;
- }
-
- fireStepChange(40, "Loading Jar...");
- File jarloc = concFile(basedir, new File(data.getJarLocation()));
- if (jarloc.exists() == false) {
- m_errors.add("Error: Can't find jar at " + jarloc);
- fireFailedChange();
- return false;
- }
-
- ByteBuffer jardata = load(jarloc);
-
- fireStepChange(60, "Adding Jar to Resources...");
- resb = resdir.replaceResource(skel.getResourceCategory(), skel.getResourceJarId(), 1033, jardata);
- if (resb == false) {
- m_errors.add("Error: Can't replace jar resource! It is probably missing from the skeleton.");
- fireFailedChange();
- return false;
- }
- }
-
- fireStepChange(70, "Adding Properties and Manifest to Resources...");
- // Properties...
- String props = PropertiesBuilder.makeProperties(basedir, data);
- ByteBuffer propdata = convert(props);
- resb = resdir.replaceResource(skel.getResourceCategory(), skel.getResourcePropsId(), 1033, propdata);
-
- // Manifest...
- String manifest = PropertiesBuilder.makeManifest(data, skel);
- if (manifest == null || manifest.isEmpty()) {
- manifest = "";
- }
- ByteBuffer manifestData = convert(manifest);
- resb = resdir.replaceManifest(1, 1033, manifestData);
-
- if (data.getIconLocation() != null) {
- fireStepChange(80, "Loading icon...");
- String iconpath;
- if (new java.io.File(data.getIconLocation()).isAbsolute())
- iconpath = data.getIconLocation();
- else
- iconpath = new java.io.File(basedir, data.getIconLocation()).getAbsolutePath();
-
- Image img = getScaledImage(iconpath, 32, 32);
- //Hashtable set = calculateColorCount(img);
- // System.out.println("COLORS TOTAL 4: " + set.size());
-
- if (img != null) {
- net.charabia.jsmoothgen.pe.res.ResIcon32 resicon = new net.charabia.jsmoothgen.pe.res.ResIcon32(img);
- pe.replaceDefaultIcon(resicon);
- }
- }
-
- fireStepChange(90, "Saving exe...");
- pe.dumpTo(out);
-
- // System.out.println("PROPERTIES:\n" + props);
-
- fireCompleteChange();
- return true;
- } catch (Exception exc) {
- m_errors.add("Error: " + exc.getMessage());
- exc.printStackTrace();
- fireFailedChange();
- return false;
- }
- }
-
- public Image[] loadImages(String path) {
- File f = new File(path);
-
- if (path.toUpperCase().endsWith(".ICO")) {
- //
- // Try to load with our ico codec...
- //
- try {
- java.awt.Image[] images = net.charabia.util.codec.IcoCodec.loadImages(f);
- if ((images != null) && (images.length > 0)) {
- return images;
- }
- } catch (java.io.IOException exc) {
- exc.printStackTrace();
- }
- }
-
- //
- // defaults to the standard java loading process
- //
- BufferedImage bufferedImage;
- try {
- bufferedImage = ImageIO.read(f);
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(bufferedImage, "default icon");
- java.awt.Image[] imgs = new java.awt.Image[1];
- imgs[0] = icon.getImage();
- return imgs;
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public void checkImageLoaded(Image img) {
- MediaTracker mtrack = new MediaTracker(new Canvas());
- mtrack.addImage(img, 1);
- try {
- mtrack.waitForAll();
- } catch (InterruptedException e) {
- }
- }
-
- private Hashtable calculateColorCount(Image img) {
- int width = img.getWidth(null);
- int height = img.getHeight(null);
- int[] pixels = new int[width * height];
- PixelGrabber grabber = new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
- try {
- grabber.grabPixels();
- } catch (InterruptedException e) {
- System.err.println("interrupted waiting for pixels!");
- // throw new Exception("Can't load the image provided",e);
- }
-
-
- Hashtable result = new Hashtable();
- int colorindex = 0;
- for (int i = 0; i < pixels.length; i++) {
- int pix = pixels[i];
- if (((pix >> 24) & 0xFF) > 0) {
- pix &= 0x00FFFFFF;
- Integer pixi = new Integer(pix);
- Object o = result.get(pixi);
- if (o == null) {
- result.put(pixi, new Integer(colorindex++));
- }
- // if (colorindex > 256)
- // return result;
- }
- }
- return result;
- }
-
- public BufferedImage getQuantizedImage(Image img) {
- // 32 bit ico file already loaded as BufferedImage
- if (img instanceof BufferedImage) {
- return (BufferedImage) img;
- } else {
- int width = img.getWidth(null);
- int height = img.getHeight(null);
- int[][] data = new int[width][height];
-
- int[] pixelbuffer = new int[width * height];
- PixelGrabber grabber = new PixelGrabber(img, 0, 0, width, height, pixelbuffer, 0, width);
- try {
- grabber.grabPixels();
- } catch (InterruptedException e) {
- System.err.println("interrupted waiting for pixels!");
- throw new RuntimeException("Can't load the image provided", e);
- }
- for (int i = 0; i < pixelbuffer.length; i++) {
- data[i % width][i / width] = pixelbuffer[i];
- }
-
- int[][] savedata = new int[width][height];
-
- for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- savedata[x][y] = data[x][y];
-
- int[] palette = net.charabia.util.codec.Quantize.quantizeImage(data, 255);
- byte[] cmap = new byte[256 * 4];
-
- for (int i = 0; i < palette.length; i++) {
- // System.out.println(" i= " + (i));
- cmap[(i * 4)] = (byte) ((palette[i] >> 16) & 0xFF);
- cmap[(i * 4) + 1] = (byte) ((palette[i] >> 8) & 0xFF);
- cmap[(i * 4) + 2] = (byte) (palette[i] & 0xFF);
- cmap[(i * 4) + 3] = (byte) 0xFF;
- }
-
- IndexColorModel colmodel = new IndexColorModel(8, palette.length, cmap, 0, true, 0);
- BufferedImage result = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
- //
- // The normal manner of quantizing would be to run
- // result.setRGB(0,0, width, height, pixelbuffer, 0, width);
- // where result is a BufferedImage of
- // BufferedImage.TYPE_BYTE_INDEXED type. Unfortunately, I
- // couldn't make it work. So, here is a work-around that
- // should work similarly.
- //
- java.util.Hashtable set = new java.util.Hashtable();
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- int alpha = (savedata[x][y] >> 24) & 0xFF;
- if (alpha == 0) {
- result.setRGB(x, y, 0);
- // System.out.print(".");
- } else {
- int rgb = colmodel.getRGB(data[x][y]);
- rgb |= 0xFF000000;
- set.put(new Integer(rgb), new Integer(rgb));
- result.setRGB(x, y, rgb);
- // System.out.print("*");
- }
- }
- // System.out.println("");
- }
-
-
- return result;
- }
- }
-
- public Image checkImageSize(Image img, int width, int height) {
- int w = img.getWidth(null);
- int h = img.getHeight(null);
- if ((w == width) && (h == height))
- return img;
- return null;
- }
-
- public Image getScaledImage(String path, int width, int height) {
- Image[] orgimages = loadImages(path);
-
- if ((orgimages == null) || (orgimages.length == 0))
- return null;
-
- for (int i = 0; i < orgimages.length; i++)
- checkImageLoaded(orgimages[i]);
-
- // System.out.println("Loaded " + orgimages.length + " images");
- for (int i = 0; (i < orgimages.length); i++) {
- int w = orgimages[i].getWidth(null);
- int h = orgimages[i].getHeight(null);
- // System.out.println("Size of " + i + " = " + w + "," + h);
- }
-
- //
- // We prefer 32x32 pictures, then 64x64, then 16x16...
- //
- Image selected = null;
- for (int i = 0; (i < orgimages.length) && (selected == null); i++)
- selected = checkImageSize(orgimages[i], 32, 32);
- for (int i = 0; (i < orgimages.length) && (selected == null); i++)
- selected = checkImageSize(orgimages[i], 64, 64);
- for (int i = 0; (i < orgimages.length) && (selected == null); i++)
- selected = checkImageSize(orgimages[i], 16, 16);
-
- if (selected != null) {
- return getQuantizedImage(selected);
- }
-
- //
- // If there is no 32x32, 64x64, nor 16x16, then we scale the
- // biggest image to be 32x32... This should happen mainly when
- // loading an image from a png of gif file, and in most case
- // there is only one image on the array.
- //
- int maxsize = 0;
- Image biggest = null;
- for (int i = 0; (i < orgimages.length) && (selected == null); i++) {
- int size = orgimages[i].getWidth(null) * orgimages[i].getHeight(null);
- if (size > maxsize) {
- maxsize = size;
- biggest = orgimages[i];
- }
- }
-
- if (biggest != null) {
- BufferedImage result = getScaledInstance((BufferedImage) biggest, 32, 32, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
- checkImageLoaded(result);
- return getQuantizedImage(result);
- }
- //
- // Here, we have failed and return null
- //
- return null;
- }
-
- /**
- * Convenience method that returns a scaled instance of the
- * provided {@code BufferedImage}.
- *
- * @param img the original image to be scaled
- * @param targetWidth the desired width of the scaled instance,
- * in pixels
- * @param targetHeight the desired height of the scaled instance,
- * in pixels
- * @param hint one of the rendering hints that corresponds to
- * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
- * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
- * @param higherQuality if true, this method will use a multi-step
- * scaling technique that provides higher quality than the usual
- * one-step technique (only useful in downscaling cases, where
- * {@code targetWidth} or {@code targetHeight} is
- * smaller than the original dimensions, and generally only when
- * the {@code BILINEAR} hint is specified)
- * @return a scaled version of the original {@code BufferedImage}
- */
- public BufferedImage getScaledInstance(BufferedImage img,
- int targetWidth,
- int targetHeight,
- Object hint,
- boolean higherQuality) {
- int type = (img.getTransparency() == Transparency.OPAQUE) ?
- BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
- BufferedImage ret = (BufferedImage) img;
- int w, h;
- if (higherQuality) {
- // Use multi-step technique: start with original size, then
- // scale down in multiple passes with drawImage()
- // until the target size is reached
- w = img.getWidth();
- h = img.getHeight();
- } else {
- // Use one-step technique: scale directly from original
- // size to target size with a single drawImage() call
- w = targetWidth;
- h = targetHeight;
- }
-
- do {
- if (higherQuality && w > targetWidth) {
- w /= 2;
- if (w < targetWidth) {
- w = targetWidth;
- }
- }
-
- if (higherQuality && h > targetHeight) {
- h /= 2;
- if (h < targetHeight) {
- h = targetHeight;
- }
- }
-
- BufferedImage tmp = new BufferedImage(w, h, type);
- Graphics2D g2 = tmp.createGraphics();
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
- g2.drawImage(ret, 0, 0, w, h, null);
- g2.dispose();
-
- ret = tmp;
- } while (w != targetWidth || h != targetHeight);
-
- return ret;
- }
-
-
- private ByteBuffer load(File in) throws Exception {
- FileInputStream fis = new FileInputStream(in);
- ByteBuffer data = ByteBuffer.allocate((int) in.length());
- data.order(ByteOrder.LITTLE_ENDIAN);
- FileChannel fischan = fis.getChannel();
- fischan.read(data);
- data.position(0);
- fis.close();
-
- return data;
- }
-
- private ByteBuffer convert(String data) {
- data = data.replace("\r\n", "\n").replace("\n", "\r\n");
- ByteBuffer result = ByteBuffer.allocate(data.length());
- result.position(0);
-
- for (int i = 0; i < data.length(); i++) {
- result.put((byte) data.charAt(i));
- }
- // result.put((byte)0);
-
- result.position(0);
- return result;
- }
-
- static public File concFile(File root, File name) {
- if (name.isAbsolute())
- return name;
-
- return new File(root, name.toString());
- }
-
- public void fireStepChange(int percentComplete, String state) {
- for (Iterator i = m_listeners.iterator(); i.hasNext();) {
- ExeCompiler.StepListener l = (ExeCompiler.StepListener) i.next();
- l.setNewState(percentComplete, state);
- }
- }
-
- public void fireFailedChange() {
- for (Iterator i = m_listeners.iterator(); i.hasNext();) {
- ExeCompiler.StepListener l = (ExeCompiler.StepListener) i.next();
- l.failed();
- }
- }
-
- public void fireCompleteChange() {
- for (Iterator i = m_listeners.iterator(); i.hasNext();) {
- ExeCompiler.StepListener l = (ExeCompiler.StepListener) i.next();
- l.complete();
- }
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/JSmoothModelBean.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/JSmoothModelBean.java
deleted file mode 100644
index 5215a1c..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/JSmoothModelBean.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-/*
- * JSmoothModelBean.java
- *
- * Created on 7 aout 2003, 18:32
- */
-
-package net.charabia.jsmoothgen.application;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Vector;
-
-public class JSmoothModelBean {
- private String m_skeletonName;
- private String m_executableName;
- private String m_currentDirectory;
-
- private String m_iconLocation;
- private boolean m_embedJar = false;
- private String m_jarLocation;
- private String m_mainClassName;
- private String m_arguments;
- private String[] m_classPath;
- private String m_minimumVersion = "";
- private String m_maximumVersion = "";
- private String[] m_jvmSearch = null;
-
- private int m_maxHeap = -1;
- private int m_initialHeap = -1;
-
- private String m_vmParamter;
-
- private int m_uacRequireAdmin;
-
- private String m_noJvmMessage;
- private String m_noJvmURL;
-
- private String m_bundledJVM = null;
-
- private JavaPropertyPair[] m_javaprops = new JavaPropertyPair[0];
- private JSmoothModelBean.Property[] m_skelproperties;
-
- static public class Property {
- public String Key;
- public String Value;
-
- public void setKey(String key) {
- this.Key = key;
- }
-
- public String getKey() {
- return this.Key;
- }
-
- public void setValue(String val) {
- this.Value = val;
- }
-
- public String getValue() {
- return this.Value;
- }
-
- public String toString() {
- return getKey() + "==" + getValue();
- }
- }
-
- transient Vector m_listeners = new Vector();
-
- public static interface Listener {
- public void dataChanged();
- }
-
- transient Vector m_skeletonChangedListener = new Vector();
-
- public static interface SkeletonChangedListener {
- public void skeletonChanged();
- }
-
- /**
- * Creates a new instance of JSmoothModelBean
- */
- public JSmoothModelBean() {
- }
-
- public void addListener(JSmoothModelBean.Listener l) {
- m_listeners.add(l);
- }
-
- public void removeListener(JSmoothModelBean.Listener l) {
- m_listeners.remove(l);
- }
-
- public void addSkeletonChangedListener(JSmoothModelBean.SkeletonChangedListener l) {
- m_skeletonChangedListener.add(l);
- }
-
- public void removeSkeletonChangedListener(JSmoothModelBean.SkeletonChangedListener l) {
- m_skeletonChangedListener.remove(l);
- }
-
-
- private void fireChanged() {
- for (Iterator i = m_listeners.iterator(); i.hasNext();) {
- JSmoothModelBean.Listener l = (JSmoothModelBean.Listener)i.next();
- l.dataChanged();
- }
- }
-
- private void fireSkeletonChanged() {
- for (Iterator i = m_skeletonChangedListener.iterator(); i.hasNext();) {
- JSmoothModelBean.SkeletonChangedListener l = (JSmoothModelBean.SkeletonChangedListener)i.next();
- l.skeletonChanged();
- }
- }
-
- public void setSkeletonName(String name) {
- if (name != m_skeletonName) {
- m_skeletonName = name;
- fireSkeletonChanged();
- fireChanged();
- }
- }
-
- public String getSkeletonName() {
- return m_skeletonName;
- }
-
- public void setExecutableName(String name) {
- if (name != m_executableName) {
- m_executableName = name;
- fireChanged();
- }
- }
-
-
- public void setCurrentDirectory(String curdir) {
- if (curdir != m_currentDirectory) {
- m_currentDirectory = curdir;
- fireChanged();
- }
- }
-
- public String getCurrentDirectory() {
- return m_currentDirectory;
- }
-
- public String getExecutableName() {
- return m_executableName;
- }
-
- public void setIconLocation(String name) {
- if (name != m_iconLocation) {
- m_iconLocation = name;
- fireChanged();
- }
- }
-
- public String getIconLocation() {
- return m_iconLocation;
- }
-
- public boolean getEmbeddedJar() {
- return m_embedJar;
- }
-
- public void setEmbeddedJar(boolean b) {
- m_embedJar = b;
- fireChanged();
- }
-
- public void setJarLocation(String name) {
- if (name != m_jarLocation) {
- m_jarLocation = name;
- fireChanged();
- }
- }
-
- public String getJarLocation() {
- return m_jarLocation;
- }
-
-
- public void setMainClassName(String name) {
- if (name != m_mainClassName) {
- m_mainClassName = name;
- fireChanged();
- }
- }
-
- public String getMainClassName() {
- return m_mainClassName;
- }
-
- public void setArguments(String args) {
- m_arguments = args;
- fireChanged();
- }
-
- public String getArguments() {
- return m_arguments;
- }
-
- public void setClassPath(String[] cp) {
- m_classPath = cp;
- fireChanged();
- }
-
- public String[] getClassPath() {
- return m_classPath;
- }
-
- public void setMaximumVersion(String version) {
- m_maximumVersion = version;
- fireChanged();
- }
-
- public String getMaximumVersion() {
- return m_maximumVersion;
- }
-
- public void setMinimumVersion(String version) {
- m_minimumVersion = version;
- fireChanged();
- }
-
- public String getMinimumVersion() {
- return m_minimumVersion;
- }
-
- public void setJVMSearchPath(String[] path) {
- m_jvmSearch = path;
- fireChanged();
- }
-
- public String[] getJVMSearchPath() {
- return m_jvmSearch;
- }
-
- public void setSkeletonProperties(JSmoothModelBean.Property[] props) {
- // for (int i=0; i<props.length; i++)
- // System.out.println("SET PROPERTY: " + props[i].getIdName() + "=" + props[i].getValue());
-
- m_skelproperties = props;
- fireChanged();
- }
-
- public JSmoothModelBean.Property[] getSkeletonProperties() {
- return m_skelproperties;
- }
-
- public void setNoJvmMessage(String msg) {
- m_noJvmMessage = msg;
- fireChanged();
- }
-
- public String getNoJvmMessage() {
- return m_noJvmMessage;
- }
-
- public void setNoJvmURL(String url) {
- m_noJvmURL = url;
- fireChanged();
- }
-
- public String getNoJvmURL() {
- return m_noJvmURL;
- }
-
- public String getBundledJVMPath() {
- return m_bundledJVM;
- }
-
- public void setBundledJVMPath(String path) {
- m_bundledJVM = path;
- fireChanged();
- }
-
- public void setJavaProperties(JavaPropertyPair[] pairs) {
- m_javaprops = pairs;
- }
-
- public JavaPropertyPair[] getJavaProperties() {
- return m_javaprops;
- }
-
- public void setMaximumMemoryHeap(int size) {
- m_maxHeap = size;
- }
-
- public int getMaximumMemoryHeap() {
- return m_maxHeap;
- }
-
- public void setInitialMemoryHeap(int size) {
- m_initialHeap = size;
- }
-
- public int getInitialMemoryHeap() {
- return m_initialHeap;
- }
-
- public void setVmParameter(String parameter) {
- m_vmParamter = parameter;
- }
-
- public String getVmParameter() {
- return m_vmParamter;
- }
-
- public void setUacRequireAdministrator(int parameter) {
- m_uacRequireAdmin = parameter;
- }
-
- public int getUacRequireAdministrator() {
- return m_uacRequireAdmin;
- }
-
- public boolean isUacRequireAdmin() {
- return m_uacRequireAdmin > 0;
- }
-
- public String[] normalizePaths(java.io.File filebase) {
- return normalizePaths(filebase, true);
- }
-
- public String[] normalizePaths(java.io.File filebase, boolean toRelativePath) {
- // System.out.println("Normalize Path " + filebase + " / " + toRelativePath);
- Vector result = new Vector();
-
- m_iconLocation = checkRelativePath(filebase, m_iconLocation, result, "Icon location", toRelativePath);
- m_jarLocation = checkRelativePath(filebase, m_jarLocation, result, "Jar location", toRelativePath);
- m_bundledJVM = checkRelativePath(filebase, m_bundledJVM, result, "Bundle JVM location", toRelativePath);
- m_executableName = checkRelativePath(filebase, m_executableName, result, "Executable location", toRelativePath);
-
- if (m_executableName != null) {
- File exebase = new File(m_executableName);
- if (exebase.isAbsolute() == false)
- exebase = new File(filebase, exebase.toString()).getParentFile();
-
- // System.out.println("EXE FILEBASE: " + exebase.toString());
- if ((m_currentDirectory != null) && (m_currentDirectory.indexOf("${") >= 0))
- m_currentDirectory = checkRelativePath(exebase, m_currentDirectory, result, "Current directory", toRelativePath);
- }
-
- if (m_classPath != null) {
- for (int i = 0; i < m_classPath.length; i++) {
- m_classPath[i] = checkRelativePath(filebase, m_classPath[i], result, "Classpath entry (" + i + ")", toRelativePath);
- }
- }
-
- if (result.size() == 0)
- return null;
-
- String[] res = new String[result.size()];
- result.toArray(res);
-
- return res;
- }
-
- private String checkRelativePath(java.io.File root, String value, java.util.Vector errors, String name, boolean toRelativePath) {
- if (value == null)
- return value;
-
- if (toRelativePath) {
- File nf = JSmoothModelPersistency.makePathRelativeIfPossible(root, new File(value));
- if (nf.isAbsolute()) {
- errors.add(name);
- }
- return nf.toString();
- } else {
- File nf = new File(value);
- if (nf.isAbsolute() == false) {
- nf = new File(root, value);
- nf = nf.getAbsoluteFile();
-
- try {
- nf = nf.getCanonicalFile();
- nf = nf.getAbsoluteFile();
- } catch (IOException iox) {
- // do nothing
- }
- }
- return nf.toString();
- }
- }
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/PropertiesBuilder.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/PropertiesBuilder.java
deleted file mode 100644
index 82b7421..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/PropertiesBuilder.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-package net.charabia.jsmoothgen.application;
-
-import java.io.File;
-
-import net.charabia.jsmoothgen.skeleton.SkeletonBean;
-
-/**
- * @author Rodrigo
- */
-public class PropertiesBuilder {
- /**
- * Creates a text containing all the relevant properties of a
- * JSmoothModelBean object. The properties are output in the form
- * "key=value".
- * <p/>
- * <p/>
- * Note that all the paths are converted to be made relative to
- * the basedir parameter provided. All the paths converted are
- * expected to be relative to the targetted executable binary
- * (before the conversion is applied, that is).
- */
- static public String makeProperties(File basedir, JSmoothModelBean obj) {
- StringBuffer out = new StringBuffer();
-
- addPair("arguments", obj.getArguments(), out);
- addPair("mainclassname", obj.getMainClassName(), out);
- addPair("jvmsearch", makePathConc(obj.getJVMSearchPath()), out);
- addPair("minversion", obj.getMinimumVersion(), out);
- addPair("maxversion", obj.getMaximumVersion(), out);
-
- addPair("currentdir", obj.getCurrentDirectory(), out);
-
- if (obj.getEmbeddedJar() && (obj.getJarLocation().trim().length() > 0)) {
- addPair("embedjar", "true", out);
- } else {
- addPair("embedjar", "false", out);
- }
-
- if (obj.getMaximumMemoryHeap() > 1) {
- addPair("maxheap", Integer.toString(obj.getMaximumMemoryHeap()), out);
- }
-
- if (obj.getInitialMemoryHeap() > 1) {
- addPair("initialheap", Integer.toString(obj.getInitialMemoryHeap()), out);
- }
-
- if ((obj.getVmParameter() != null) && (!obj.getVmParameter().isEmpty())) {
- addPair("vmparameter", obj.getVmParameter(), out);
- }
- // BundledVM & classpaths are changed to be accessible
- // from the current directory
- File curdir = new File(obj.getExecutableName()).getParentFile();
-
- if (curdir == null)
- curdir = basedir.getAbsoluteFile();
-
- if (curdir.isAbsolute() == false) {
- curdir = new File(basedir, curdir.toString());
- }
-
-
- // System.out.println("... curdir1 : " + curdir.toString());
-
- if (obj.getCurrentDirectory() != null) {
- File newcurdir = new File(obj.getCurrentDirectory());
- // System.out.println("... curdir1.5 : " + obj.getCurrentDirectory());
-
- if (!"${EXECUTABLEPATH}".equalsIgnoreCase(obj.getCurrentDirectory())) {
- if (newcurdir.isAbsolute() == false) {
- curdir = new File(curdir, newcurdir.toString());
- } else
- curdir = newcurdir;
- }
- }
- // System.out.println("... curdir2 : " + curdir.toString());
-
- if (obj.getBundledJVMPath() != null)
- addPair("bundledvm", getRenormalizedPathIfNeeded(obj.getBundledJVMPath(), basedir, curdir), out);
-
- if (obj.getClassPath() != null) {
- String[] relcp = new String[obj.getClassPath().length];
- for (int i = 0; i < relcp.length; i++) {
- relcp[i] = getRenormalizedPathIfNeeded(obj.getClassPath()[i], basedir, curdir);
- }
- addPair("classpath", makePathConc(relcp), out);
- }
-
- //
- // Adds all the skeleton-specific properties
- //
- if (obj.getSkeletonProperties() != null) {
- for (int i = 0; i < obj.getSkeletonProperties().length; i++) {
- JSmoothModelBean.Property prop = obj.getSkeletonProperties()[i];
- if (prop.getKey() != null) {
- String val = prop.getValue();
- if (val == null)
- val = "";
- addPair("skel_" + prop.getKey(), val, out);
- }
- }
- }
-
-
- //
- // Adds all the java properties. Those properties are
- // typically passed as -Dname=value arguments for the sun's
- // JVM.
- //
-
- JavaPropertyPair[] javapairs = obj.getJavaProperties();
- if (javapairs != null) {
- addPair("javapropertiescount", new Integer(javapairs.length).toString(), out);
- for (int i = 0; i < javapairs.length; i++) {
- addPair("javaproperty_name_" + i, javapairs[i].getName(), out);
- addPair("javaproperty_value_" + i, javapairs[i].getValue(), out);
- }
- }
-
- return out.toString();
- }
-
- /**
- * Create a manifest entry for windows right elevation
- *
- * @param data
- * @param skel
- * @return the manifest xml
- */
- public static String makeManifest(JSmoothModelBean data, SkeletonBean skel) {
- StringBuilder retVal = new StringBuilder();
- String platform = "x86";
- String shortName = skel.getShortName();
- if (shortName.contains("64")) {
- platform = "ia64";
- }
- retVal.append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>").append("\n");
- retVal.append("<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">").append("\n");
- retVal.append(" <assemblyIdentity type=\"win32\"").append("\n");
- retVal.append(" name=\"").append(shortName).append("\"").append("\n");
- retVal.append(" version=\"1.0.0.0\"").append("\n");
- retVal.append(" processorArchitecture=\"").append(platform).append("\"").append("\n");
- retVal.append(" />").append("\n");
- retVal.append(" <dependency>").append("\n");
- retVal.append(" <dependentAssembly>").append("\n");
- retVal
- .append(
- " <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>")
- .append("\n");
- retVal.append(" </dependentAssembly>").append("\n");
- retVal.append(" </dependency>").append("\n");
- if (data.isUacRequireAdmin()) {
- retVal.append(" <trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">").append("\n");
- retVal.append(" <security>").append("\n");
- retVal.append(" <requestedPrivileges>").append("\n");
- retVal.append(" <requestedExecutionLevel level=\"requireAdministrator\"/>").append("\n");
- retVal.append(" </requestedPrivileges>").append("\n");
- retVal.append(" </security>").append("\n");
- retVal.append(" </trustInfo>").append("\n");
- }
- retVal.append("</assembly>");
- return retVal.toString();
- }
-
- /**
- * Converts a path relative to previousbasedir into a path
- * relative to newbasedir.
- */
- static public String getRenormalizedPathIfNeeded(String value, File previousbasedir, File newbasedir) {
- // File f = new File(value);
- // if (f.isAbsolute())
- // return value;
-
- if (newbasedir == null)
- return value;
-
- if (value == null)
- return "";
-
- File abs = new File(previousbasedir, value).getAbsoluteFile();
- File n = JSmoothModelPersistency.makePathRelativeIfPossible(newbasedir, abs);
-
- return n.toString();
- }
-
- static public String escapeString(String str) {
- if (str == null)
- return "";
-
- StringBuffer out = new StringBuffer();
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- switch (c) {
- case '\n':
- out.append("\\n");
- break;
- case '\t':
- out.append("\\t");
- break;
- case '\r':
- out.append("\\r");
- break;
- case '\\':
- out.append("\\\\");
- break;
- default:
- out.append(c);
- }
- }
- return out.toString();
- }
-
- static private void addPair(String name, String value, StringBuffer out) {
- out.append(escapeString(name));
- out.append("=");
- out.append(escapeString(value));
- out.append("\n");
- }
-
- static public String makePathConc(String[] elements) {
- StringBuffer buf = new StringBuffer();
- if (elements != null)
- for (int i = 0; i < elements.length; i++) {
- buf.append(elements[i]);
- if ((i + 1) < elements.length)
- buf.append(";");
- }
- return buf.toString();
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/gui/editors/ExecutableIcon.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/gui/editors/ExecutableIcon.java
deleted file mode 100644
index e7940dd..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/gui/editors/ExecutableIcon.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-package net.charabia.jsmoothgen.application.gui.editors;
-
-import net.charabia.jsmoothgen.skeleton.*;
-import net.charabia.jsmoothgen.application.*;
-import net.charabia.jsmoothgen.application.gui.*;
-import net.charabia.jsmoothgen.application.gui.util.*;
-import javax.swing.*;
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.util.*;
-import java.io.*;
-import com.l2fprod.common.swing.*;
-import com.l2fprod.common.propertysheet.*;
-
-public class ExecutableIcon extends Editor
-{
- private FileSelectionTextField m_selector = new FileSelectionTextField();
- private JLabel m_iconDisplay = new JLabel("(no image)");
-
- public ExecutableIcon()
- {
- setLayout(new BorderLayout());
- add(BorderLayout.CENTER, m_selector);
- add(BorderLayout.SOUTH, m_iconDisplay);
-
- m_iconDisplay.setHorizontalAlignment(JLabel.CENTER);
-
- m_selector.addListener(new FileSelectionTextField.FileSelected() {
- public void fileSelected(String filename)
- {
-// System.out.println("new icon: " + filename);
- setIconLocation(new File(filename));
- }
- });
- }
-
- public void dataChanged()
- {
- if (getBaseDir() != null)
- m_selector.setBaseDir(getBaseDir());
-
- if (m_model.getIconLocation() != null)
- {
- m_selector.setFile(getAbsolutePath(new java.io.File(m_model.getIconLocation())));
- setIconLocation(getAbsolutePath(new java.io.File(m_model.getIconLocation())));
-
- }
- else
- {
- m_selector.setFile(null);
- setIconLocation(new File(""));
- }
- }
-
- public void updateModel()
- {
- File f = m_selector.getFile();
- if (f != null)
- m_model.setIconLocation(m_selector.getFile().toString());
- else
- m_model.setIconLocation(null);
- }
-
- public String getLabel()
- {
- return "ICONLOCATION_LABEL";
- }
-
- public String getDescription()
- {
- return "ICONLOCATION_HELP";
- }
-
- private void setIconLocation(File iconfile)
- {
- if (iconfile.isAbsolute() == false)
- {
- iconfile = new File(m_basedir, iconfile.toString());
- }
- ImageIcon icon = null;
-
-// System.out.println("setIconLocation: " + iconfile);
-
- if (iconfile.toString().toUpperCase().endsWith(".ICO"))
- {
- //
- // Try to load with our ico codec...
- //
- try {
- java.awt.image.BufferedImage image = net.charabia.util.codec.IcoCodec.getPreferredImage(iconfile);
- if (image != null)
- {
- icon = new ImageIcon(image);
- }
- } catch (java.io.IOException exc)
- {
- exc.printStackTrace();
- }
- }
- else // Otherwise try with the standard toolkit functions...
- {
- BufferedImage bufferedImage;
- try {
- bufferedImage = ImageIO.read(iconfile);
- icon = new javax.swing.ImageIcon(bufferedImage, "default icon");
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-
- if (icon != null)
- {
- int width = icon.getIconWidth();
- int height = icon.getIconHeight();
-
- m_iconDisplay.setIcon(icon);
- m_iconDisplay.setText("");
- m_model.setIconLocation(iconfile.getAbsolutePath());
- this.validate();
- this.invalidate();
- }
- else
- {
- m_iconDisplay.setIcon(null);
- m_iconDisplay.setText("(no image)");
- m_model.setIconLocation(null);
- }
-
- doLayout();
- invalidate();
- validate();
- repaint();
- }
-
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/gui/util/HTMLPane.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/gui/util/HTMLPane.java
deleted file mode 100644
index 0129c4b..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/application/gui/util/HTMLPane.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-package net.charabia.jsmoothgen.application.gui.util;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import java.io.*;
-import java.util.*;
-import javax.swing.text.html.*;
-import javax.swing.event.*;
-import java.net.*;
-
-/**
- *
- */
-
-public class HTMLPane extends JPanel
-{
- private JScrollPane m_scroller;
- private JEditorPane m_html;
- private URL m_baseurl;
-
- edu.stanford.ejalbert.BrowserLauncher m_launcher;
-
- class Hyperactive implements HyperlinkListener {
-
- public void hyperlinkUpdate(HyperlinkEvent e) {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
-
- JEditorPane pane = (JEditorPane)e.getSource();
- if (e instanceof HTMLFrameHyperlinkEvent) {
- HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
- HTMLDocument doc = (HTMLDocument)pane.getDocument();
- doc.processHTMLFrameHyperlinkEvent(evt);
- } else {
- try {
- URL nurl = e.getURL();
- if (nurl == null)
- nurl = new URL(m_baseurl, e.getDescription());
- if (jsmooth.Native.isAvailable())
- {
- jsmooth.Native.shellExecute(jsmooth.Native.SHELLEXECUTE_OPEN, nurl.toString(), null, null, jsmooth.Native.SW_NORMAL);
- }
- else
- m_launcher.openURLinBrowser(nurl.toExternalForm());
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- }
- }
- }
-
-
- public HTMLPane()
- {
- try {
- m_baseurl = new File(".").toURI().toURL();
- } catch (Exception ex) { ex.printStackTrace(); }
- m_html = new JEditorPane("text/html","<html></html>") {
- public boolean getScrollableTracksViewportWidth()
- {
- return true;
- }
- };
- HTMLEditorKit hek = new HTMLEditorKit();
- m_html.setEditorKit(hek);
-
- m_scroller = new JScrollPane(m_html);
- setLayout(new BorderLayout());
- m_html.setEditable(false);
- add(m_scroller, BorderLayout.CENTER);
- // add(m_html, BorderLayout.CENTER);
- m_html.addHyperlinkListener(new Hyperactive());
-
- try {
- m_launcher = new edu.stanford.ejalbert.BrowserLauncher();
- }catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- }
-
- public java.awt.Dimension getPreferredSize()
- {
- return new java.awt.Dimension(200,200);
- }
-
- public void setPage(URL url)
- {
- try {
- URL u = new URL(m_baseurl, url.toExternalForm());
- m_html.setPage(u);
- } catch (Exception ex) { ex.printStackTrace(); }
- }
-
- public void setText(String s)
- {
- m_html.setContentType("text/html");
- m_html.setText(s);
- m_html.setCaretPosition(0);
- }
-
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEFile.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEFile.java
deleted file mode 100644
index e4bb992..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEFile.java
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-/*
- * PEFile.java
- *
- * Created on 28 juillet 2003, 21:28
- */
-
-package net.charabia.jsmoothgen.pe;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.Vector;
-
-import net.charabia.jsmoothgen.pe.res.ResIcon;
-import net.charabia.jsmoothgen.pe.res.ResIconDir;
-
-/**
- * @author Rodrigo
- */
-public class PEFile {
- private File m_file;
- private FileInputStream m_in = null;
- private FileChannel m_channel = null;
-
- private PEOldMSHeader m_oldmsheader;
- private PEHeader m_header;
- private Vector m_sections = new Vector();
-
- private PEResourceDirectory m_resourceDir;
-
- /**
- * Creates a new instance of PEFile
- */
- public PEFile(File f) {
- m_file = f;
- }
-
- public void close() throws IOException {
- m_in.close();
- }
-
- public void open() throws FileNotFoundException, IOException {
- m_in = new FileInputStream(m_file);
- m_channel = m_in.getChannel();
-
- m_oldmsheader = new PEOldMSHeader(this);
-
- m_oldmsheader.read();
- // m_oldmsheader.dump(System.out);
- long headoffset = m_oldmsheader.e_lfanew;
-
- m_header = new PEHeader(this, headoffset);
- m_header.read();
- // m_header.dump(System.out);
-
- int seccount = m_header.NumberOfSections;
- // System.out.println("LOADING " + seccount + " sections...");
-
- long offset = headoffset + (m_header.NumberOfRvaAndSizes * 8) + 24 + getPeHeaderOffset();
-
- for (int i = 0; i < seccount; i++) {
- // System.out.println("Offset: " + offset + " (" + this.m_channel.position());
-
- PESection sect = new PESection(this, offset);
- sect.read();
- // sect.dump(System.out);
- m_sections.add(sect);
- offset += 40;
- }
- // System.out.println("After sections: " + this.m_channel.position() + " (" + offset + ")");
-
- ByteBuffer resbuf = null;
- long resourceoffset = m_header.ResourceDirectory_VA;
- for (int i = 0; i < seccount; i++) {
- PESection sect = (PESection)m_sections.get(i);
- if (sect.VirtualAddress == resourceoffset) {
- // System.out.println(" Resource section found: " + resourceoffset);
- PEResourceDirectory prd = new PEResourceDirectory(this, sect);
- resbuf = prd.buildResource(sect.VirtualAddress);
- break;
- }
- }
- }
-
- private int getPeHeaderOffset() {
- int pe32Offset = 96;
- if (m_header.isPe32Plus()) {
- // It is a pe32+ header (x64)
- pe32Offset = 112;
- }
- return pe32Offset;
- }
-
- public FileChannel getChannel() {
- return m_channel;
- }
-
- public static void main(String args[]) throws IOException, CloneNotSupportedException, Exception {
- // (no)PEFile pe = new PEFile(new File("F:/Program Files/LAN Search PRO/lansearch.exe"));
-
- PEFile pe = new PEFile(new File("c:/scratch/rc3.exe"));
- // PEFile pe = new PEFile(new File("c:/projects/jwrap/Copie.exe"));
- // PEFile pe = new PEFile(new File("c:/projects/jwrap/test.exe"));
- // PEFile pe = new PEFile(new File("F:/Program Files/bQuery/bQuery.exe"));
- // PEFile pe = new PEFile(new File("F:/Program Files/Server Query/query.exe"));
- // PEFile pe = new PEFile(new File("F:/Program Files/AvRack/rtlrack.exe"));
- pe.open();
- System.out.println("OldMSHeader");
- pe.m_oldmsheader.dump(System.out);
- System.out.println("COFFHeader");
- pe.m_header.dump(System.out);
-
- // System.out.println("===============\nADDING A RES");
- // File fout = new File("F:/Documents and Settings/Rodrigo/Mes documents/projects/jsmooth/skeletons/simplewrap/gen-application.jar");
- // FileInputStream fis = new FileInputStream(fout);
- //
- // ByteBuffer data = ByteBuffer.allocate((int)fout.length());
- // data.order(ByteOrder.LITTLE_ENDIAN);
- // FileChannel fischan = fis.getChannel();
- // fischan.read(data);
- // data.position(0);
- // fis.close();
-
- PEResourceDirectory resdir = pe.getResourceDirectory();
- System.out.println("ResourceDirectory");
- resdir.dump(System.out);
-
- // DataEntry inputResData = resdir.getData("JAVA", "#" + String.valueOf(103), "#" + String.valueOf(1033));
- // ByteBuffer inputResDataBuffer = ByteBuffer.allocate(inputResData.diskSize() + 1024);
- // inputResDataBuffer.order(ByteOrder.LITTLE_ENDIAN);
- // inputResData.buildBuffer(inputResDataBuffer, 0, 0);
- // int inputResDataBufferSize = inputResDataBuffer.position();
- // inputResDataBuffer.flip();
- // int offset = inputResDataBuffer.getInt();
- // inputResDataBuffer.position(offset);
- // StringBuilder inputResDataString = new StringBuilder(inputResDataBufferSize);
- // while (inputResDataBuffer.position() <= inputResDataBufferSize - 2) {
- // byte dummyByte = inputResDataBuffer.get();
- // inputResDataString.append((char)dummyByte);
- // }
- // // Modify the data...
- // String newInputResDataString = inputResDataString.toString();
- // newInputResDataString = newInputResDataString.replace("samplejar", "ThisIsMyJarAndOnlyMine");
- //
- // inputResDataBuffer = ByteBuffer.allocate(newInputResDataString.length() + 2);
- // for (int index = 0; index < newInputResDataString.length(); index++) { // C- do not change because buffer can be modified during loop
- // inputResDataBuffer.put((byte)newInputResDataString.charAt(index));
- // }
- // inputResDataBuffer.put((byte)0);
- // inputResDataBuffer.put((byte)0);
- // inputResDataBuffer.position(0);
- //
- // boolean resb = resdir.replaceResource("JAVA", 102, 1033, inputResDataBuffer);
-
- // PEResourceDirectory.DataEntry entry = resdir.getData("#14", "A", "#1033");
- // entry.Data.position(0);
- // System.out.println("DataEntry found : " + entry + " (size=" + entry.Data.remaining() + ")");
- // entry.Data.position(0);
- //
- // ResIconDir rid = new ResIconDir(entry.Data);
- // System.out.println("ResIconDir :");
- // System.out.println(rid.toString());
- // int iconid = rid.getEntries()[0].dwImageOffset;
- // System.out.println("Icon Index: " + iconid);
- //
- // PEResourceDirectory.DataEntry iconentry = resdir.getData("#3", "#"+iconid, "#1033");
- // iconentry.Data.position(0);
- // ResIcon icon = new ResIcon(iconentry.Data);
- // System.out.println("Icon :");
- // System.out.println(icon.toString());
-
- // java.awt.Image img = java.awt.Toolkit.getDefaultToolkit().getImage ("c:\\test.gif");
- // java.awt.Image img = java.awt.Toolkit.getDefaultToolkit().getImage ("c:\\gnome-day2.png");
- // java.awt.Image img = java.awt.Toolkit.getDefaultToolkit().getImage("c:\\gnome-color-browser2.png");
- //
- // java.awt.MediaTracker mt = new java.awt.MediaTracker(new javax.swing.JLabel("toto"));
- // mt.addImage(img, 1);
- // try {
- // mt.waitForAll();
- // } catch (Exception exc) {
- // exc.printStackTrace();
- // }
- //
- // ResIcon newicon = new ResIcon(img);
- //
- // pe.replaceDefaultIcon(newicon);
-
- // System.out.println("-----------------\nNEW ICON:");
- // System.out.println(newicon.toString());
- //
- // rid.getEntries()[0].bWidth = (short)newicon.Width;
- // rid.getEntries()[0].bHeight = (short)(newicon.Height/2);
- // rid.getEntries()[0].bColorCount = (short)(1 <<newicon.BitsPerPixel);
- // rid.getEntries()[0].wBitCount = newicon.BitsPerPixel;
- // rid.getEntries()[0].dwBytesInRes = newicon.getData().remaining();
- //
- // iconentry.Data = newicon.getData();
- // iconentry.Size = iconentry.Data.remaining();
- //
- // entry.setData(rid.getData());
- // System.out.println("POST CHANGE ResIconDir :");
- // System.out.println(rid.toString());
-
- // ResIcon test = new ResIcon(icon.getData());
- // System.out.println("PROOF-TEST:\n" + test.toString());
-
- // / BACK
- //
- // rid.getEntries()[0].bWidth = (short)icon.Width;
- // rid.getEntries()[0].bHeight = (short)(icon.Height/2);
- // rid.getEntries()[0].bColorCount = (short)(1 <<icon.BitsPerPixel);
- // rid.getEntries()[0].wBitCount = icon.BitsPerPixel;
- // iconentry.Data = icon.getData();
- // iconentry.Size = iconentry.Data.remaining();
-
- // resdir.addNewResource("POUET", "A666", "#1033", data);
-
- // resdir.dump(System.out);
-
- // System.out.println("New size = " + resdir.size());
- File out = new File("c:/scratch/COPIE.exe");
- pe.dumpTo(out);
-
- }
-
- public PEResourceDirectory getResourceDirectory() throws IOException {
- if (m_resourceDir != null)
- return m_resourceDir;
-
- long resourceoffset = m_header.ResourceDirectory_VA;
- for (int i = 0; i < m_sections.size(); i++) {
- PESection sect = (PESection)m_sections.get(i);
- if (sect.VirtualAddress == resourceoffset) {
- m_resourceDir = new PEResourceDirectory(this, sect);
- return m_resourceDir;
- }
- }
-
- return null;
- }
-
- public void dumpTo(File destination) throws IOException, CloneNotSupportedException {
- int outputcount = 0;
- FileOutputStream fos = new FileOutputStream(destination);
- FileChannel out = fos.getChannel();
-
- //
- // Make a copy of the Header, for safe modifications
- //
- PEOldMSHeader oldmsheader = (PEOldMSHeader)this.m_oldmsheader.clone();
- PEHeader peheader = (PEHeader)m_header.clone();
- Vector sections = new Vector();
- for (int i = 0; i < m_sections.size(); i++) {
- PESection sect = (PESection)m_sections.get(i);
- PESection cs = (PESection)sect.clone();
- sections.add(cs);
- }
-
- //
- // First, write the old MS Header, the one starting
- // with "MZ"...
- //
- long newexeoffset = oldmsheader.e_lfanew;
- ByteBuffer msheadbuffer = oldmsheader.get();
- outputcount = out.write(msheadbuffer);
- this.m_channel.position(64);
- out.transferFrom(this.m_channel, 64, newexeoffset - 64);
-
-
- //
- // Then Write the new Header...
- //
- ByteBuffer headbuffer = peheader.get();
- out.position(newexeoffset);
- outputcount = out.write(headbuffer);
-
- //
- // After the header, there are all the section
- // headers...
- //
- long offset = oldmsheader.e_lfanew + (m_header.NumberOfRvaAndSizes * 8) + 24 + getPeHeaderOffset();
- out.position(offset);
- for (int i = 0; i < sections.size(); i++) {
- // System.out.println(" offset: " + out.position());
- PESection sect = (PESection)sections.get(i);
-
- ByteBuffer buf = sect.get();
- outputcount = out.write(buf);
- }
-
- //
- // Now, we write the real data: each of the section
- // and their data...
- //
-
- // Not sure why it's always at 1024... ?
- offset = 1024;
-
- //
- // Dump each section data
- //
-
- long virtualAddress = offset;
- if ((virtualAddress % peheader.SectionAlignment) > 0)
- virtualAddress += peheader.SectionAlignment - (virtualAddress % peheader.SectionAlignment);
-
- long resourceoffset = m_header.ResourceDirectory_VA;
- for (int i = 0; i < sections.size(); i++) {
- PESection sect = (PESection)sections.get(i);
- if (resourceoffset == sect.VirtualAddress) {
- // System.out.println("Dumping RES section " + i + " at " + offset + " from " + sect.PointerToRawData + " (VA=" + virtualAddress + ")");
- out.position(offset);
- long sectoffset = offset;
- PEResourceDirectory prd = this.getResourceDirectory();
- ByteBuffer resbuf = prd.buildResource(sect.VirtualAddress);
- resbuf.position(0);
-
- out.write(resbuf);
- offset += resbuf.capacity();
- long rem = offset % this.m_header.FileAlignment;
- if (rem != 0)
- offset += this.m_header.FileAlignment - rem;
-
- if (out.size() + 1 < offset) {
- ByteBuffer padder = ByteBuffer.allocate(1);
- out.write(padder, offset - 1);
- }
-
- long virtualSize = resbuf.capacity();
- if ((virtualSize % peheader.SectionAlignment) > 0)
- virtualSize += peheader.SectionAlignment - (virtualSize % peheader.SectionAlignment);
-
- sect.PointerToRawData = sectoffset;
- sect.SizeOfRawData = resbuf.capacity();
- if ((sect.SizeOfRawData % this.m_header.FileAlignment) > 0)
- sect.SizeOfRawData += (this.m_header.FileAlignment - (sect.SizeOfRawData % this.m_header.FileAlignment));
- sect.VirtualAddress = virtualAddress;
- sect.VirtualSize = virtualSize;
- // System.out.println(" VS=" + virtualSize + " at VA=" + virtualAddress);
- virtualAddress += virtualSize;
-
- } else if (sect.PointerToRawData > 0) {
- // System.out.println("Dumping section " + i + "/" + sect.getName() + " at " + offset + " from " + sect.PointerToRawData + " (VA=" + virtualAddress + ")");
- out.position(offset);
- this.m_channel.position(sect.PointerToRawData);
- long sectoffset = offset;
-
- out.position(offset + sect.SizeOfRawData);
- ByteBuffer padder = ByteBuffer.allocate(1);
- out.write(padder, offset + sect.SizeOfRawData - 1);
-
- long outted = out.transferFrom(this.m_channel, offset, sect.SizeOfRawData);
- offset += sect.SizeOfRawData;
- // System.out.println("offset before alignment, " + offset);
-
- long rem = offset % this.m_header.FileAlignment;
- if (rem != 0) {
- offset += this.m_header.FileAlignment - rem;
- }
- // System.out.println("offset after alignment, " + offset);
-
- // long virtualSize = sect.SizeOfRawData;
- // if ((virtualSize % peheader.SectionAlignment)>0)
- // virtualSize += peheader.SectionAlignment - (virtualSize%peheader.SectionAlignment);
-
- sect.PointerToRawData = sectoffset;
- // sect.SizeOfRawData =
- sect.VirtualAddress = virtualAddress;
- // sect.VirtualSize = virtualSize;
-
- virtualAddress += sect.VirtualSize;
- if ((virtualAddress % peheader.SectionAlignment) > 0)
- virtualAddress += peheader.SectionAlignment - (virtualAddress % peheader.SectionAlignment);
-
- } else {
- // generally a BSS, with a virtual size but no
- // data in the file...
- // System.out.println("Dumping section " + i + " at " + offset + " from " + sect.PointerToRawData + " (VA=" + virtualAddress + ")");
- long virtualSize = sect.VirtualSize;
- if ((virtualSize % peheader.SectionAlignment) > 0)
- virtualSize += peheader.SectionAlignment - (virtualSize % peheader.SectionAlignment);
-
- sect.VirtualAddress = virtualAddress;
- // sect.VirtualSize = virtualSize;
- virtualAddress += virtualSize;
-
- }
- }
-
- //
- // Now that all the sections have been written, we have the
- // correct VirtualAddress and Sizes, so we can update the new
- // header and all the section headers...
-
- peheader.updateVAAndSize(m_sections, sections);
- headbuffer = peheader.get();
- out.position(newexeoffset);
- outputcount = out.write(headbuffer);
-
- // peheader.dump(System.out);
- // System.out.println("Dumping the section again...");
- offset = oldmsheader.e_lfanew + (m_header.NumberOfRvaAndSizes * 8) + 24 + getPeHeaderOffset();
- out.position(offset);
- for (int i = 0; i < sections.size(); i++) {
- // System.out.println(" offset: " + out.position());
- PESection sect = (PESection)sections.get(i);
- // sect.dump(System.out);
- ByteBuffer buf = sect.get();
- outputcount = out.write(buf);
- }
-
- fos.flush();
- fos.close();
- }
-
- /*
- */
-
- public void replaceDefaultIcon(ResIcon icon) throws Exception {
- PEResourceDirectory resdir = getResourceDirectory();
-
- PEResourceDirectory.DataEntry entry = resdir.getData("#14", null, null);
- if (entry == null) {
- throw new Exception("Can't find any icon group in the file!");
- }
-
- entry.Data.position(0);
- // System.out.println("DataEntry found : " + entry + " (size=" + entry.Data.remaining() + ")");
- entry.Data.position(0);
-
- ResIconDir rid = new ResIconDir(entry.Data);
- // System.out.println("ResIconDir :");
- // System.out.println(rid.toString());
- int iconid = rid.getEntries()[0].dwImageOffset;
- // System.out.println("Icon Index: " + iconid);
-
- PEResourceDirectory.DataEntry iconentry = resdir.getData("#3", "#" + iconid, null);
- iconentry.Data.position(0);
- // System.out.println("Icon :");
- // System.out.println(icon.toString());
-
- rid.getEntries()[0].bWidth = (short)icon.Width;
- rid.getEntries()[0].bHeight = (short)(icon.Height / 2);
- rid.getEntries()[0].bColorCount = (short)(1 << icon.BitsPerPixel);
- rid.getEntries()[0].wBitCount = icon.BitsPerPixel;
- rid.getEntries()[0].dwBytesInRes = icon.getData().remaining();
-
- iconentry.Data = icon.getData();
- iconentry.Size = iconentry.Data.remaining();
-
- entry.setData(rid.getData());
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEHeader.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEHeader.java
deleted file mode 100644
index da96141..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEHeader.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-/*
- * PEHeader.java
- *
- * Created on 28 juillet 2003, 21:38
- */
-
-package net.charabia.jsmoothgen.pe;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-import java.util.Vector;
-
-/**
- * @author Rodrigo Reyes
- */
-public class PEHeader implements Cloneable {
- private int PeMagic; // 0
- public int Machine; // 4
- public int NumberOfSections; // 6
- public long TimeDateStamp; // 8
- public long PointerToSymbolTable; // C
- public long NumberOfSymbols; // 10
- public int SizeOfOptionalHeader; // 14
- public int Characteristics; // 16
-
- // Optional Header
- public int Magic; // 18
- public short MajorLinkerVersion; // 1a
- public short MinorLinkerVersion; // 1b
- public long SizeOfCode; // 1c
- public long SizeOfInitializedData; // 20
- public long SizeOfUninitializedData; // 24
- public long AddressOfEntryPoint; // 28
- public long BaseOfCode; // 2c
- public long BaseOfData; // NT additional fields. 30
- public long ImageBase; // 34
- public long SectionAlignment; // 38
- public long FileAlignment; // 3c
- public int MajorOperatingSystemVersion; // 40
- public int MinorOperatingSystemVersion; // 42
- public int MajorImageVersion; // 44
- public int MinorImageVersion; // 46
- public int MajorSubsystemVersion; // 48
- public int MinorSubsystemVersion; // 4a
- public long Reserved1; // 4c
- public long SizeOfImage; // 50
- public long SizeOfHeaders; // 54
- public long CheckSum; // 58
- public int Subsystem; // 5c
- public int DllCharacteristics; // 5e
- public long SizeOfStackReserve; // 60
- public long SizeOfStackCommit; // 64
- public long SizeOfHeapReserve; // 68
- public long SizeOfHeapCommit; // 6c
- public long LoaderFlags; // 70
- public long NumberOfRvaAndSizes; // 74
-
- public long ExportDirectory_VA; // 78
- public long ExportDirectory_Size; // 7c
- public long ImportDirectory_VA; // 80
- public long ImportDirectory_Size; // 84
- public long ResourceDirectory_VA; // 88
- public long ResourceDirectory_Size; // 8c
- public long ExceptionDirectory_VA; // 90
- public long ExceptionDirectory_Size; // 94
- public long SecurityDirectory_VA; // 98
- public long SecurityDirectory_Size; // 9c
- public long BaseRelocationTable_VA; // a0
- public long BaseRelocationTable_Size; // a4
- public long DebugDirectory_VA; // a8
- public long DebugDirectory_Size; // ac
- public long ArchitectureSpecificData_VA; // b0
- public long ArchitectureSpecificData_Size; // b4
- public long RVAofGP_VA; // b8
- public long RVAofGP_Size; // bc
- public long TLSDirectory_VA; // c0
- public long TLSDirectory_Size; // c4
- public long LoadConfigurationDirectory_VA; // c8
- public long LoadConfigurationDirectory_Size; // cc
- public long BoundImportDirectoryinheaders_VA; // d0
- public long BoundImportDirectoryinheaders_Size; // d4
- public long ImportAddressTable_VA; // d8
- public long ImportAddressTable_Size; // dc
- public long DelayLoadImportDescriptors_VA; // e0
- public long DelayLoadImportDescriptors_Size; // e4
- public long COMRuntimedescriptor_VA; // e8
- public long COMRuntimedescriptor_Size; // ec
-
- private long m_baseoffset;
- private PEFile m_pe;
-
- /**
- * Creates a new instance of PEHeader
- */
- public PEHeader(PEFile pef, long baseoffset) {
- m_pe = pef;
- m_baseoffset = baseoffset;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- public void read() throws IOException {
- FileChannel ch = m_pe.getChannel();
- ByteBuffer head = ByteBuffer.allocate(350);
- head.order(ByteOrder.LITTLE_ENDIAN);
- ch.position(m_baseoffset);
- ch.read(head);
- head.position(0);
-
- PeMagic = head.getInt();
- // System.out.println("MAGIC::: " + pemagic);
- Machine = head.getShort(); // 4
- NumberOfSections = head.getShort(); // 6
- TimeDateStamp = head.getInt(); // 8
- PointerToSymbolTable = head.getInt(); // C
- NumberOfSymbols = head.getInt(); // 10
- SizeOfOptionalHeader = head.getShort(); // 14
- Characteristics = head.getShort(); // 16
- // Optional Header
-
- Magic = head.getShort(); // 18
- MajorLinkerVersion = head.get(); // 1a
- MinorLinkerVersion = head.get(); // 1b
- SizeOfCode = head.getInt(); // 1c
- SizeOfInitializedData = head.getInt(); // 20
- SizeOfUninitializedData = head.getInt(); // 24
- AddressOfEntryPoint = head.getInt(); // 28
- BaseOfCode = head.getInt(); // 2c
- if (isPe32Plus()) {
- ImageBase = head.getLong(); // 34
- } else {
- BaseOfData = head.getInt(); // // NT additional fields. // 30
- ImageBase = head.getInt(); // 34
- }
- SectionAlignment = head.getInt(); // 38
- FileAlignment = head.getInt(); // 3c
- MajorOperatingSystemVersion = head.getShort(); // 40
- MinorOperatingSystemVersion = head.getShort(); // 42
- MajorImageVersion = head.getShort(); // 44
- MinorImageVersion = head.getShort(); // 46
- MajorSubsystemVersion = head.getShort(); // 48
- MinorSubsystemVersion = head.getShort(); // 4a
- Reserved1 = head.getInt(); // 4c
- SizeOfImage = head.getInt(); // 50
- SizeOfHeaders = head.getInt(); // 54
- CheckSum = head.getInt(); // 58
- Subsystem = head.getShort(); // 5c
- DllCharacteristics = head.getShort(); // 5e
- if (isPe32Plus()) {
- SizeOfStackReserve = head.getLong(); // 60
- SizeOfStackCommit = head.getLong(); // 64
- SizeOfHeapReserve = head.getLong(); // 68
- SizeOfHeapCommit = head.getLong(); // 6c
- } else {
- SizeOfStackReserve = head.getInt(); // 60
- SizeOfStackCommit = head.getInt(); // 64
- SizeOfHeapReserve = head.getInt(); // 68
- SizeOfHeapCommit = head.getInt(); // 6c
- }
- LoaderFlags = head.getInt(); // 70
- NumberOfRvaAndSizes = head.getInt(); // 74
-
- ExportDirectory_VA = head.getInt(); // 78
- ExportDirectory_Size = head.getInt(); // 7c
- ImportDirectory_VA = head.getInt(); // 80
- ImportDirectory_Size = head.getInt(); // 84
- ResourceDirectory_VA = head.getInt(); // 88
- ResourceDirectory_Size = head.getInt(); // 8c
- ExceptionDirectory_VA = head.getInt(); // 90
- ExceptionDirectory_Size = head.getInt(); // 94
- SecurityDirectory_VA = head.getInt(); // 98
- SecurityDirectory_Size = head.getInt(); // 9c
- BaseRelocationTable_VA = head.getInt(); // a0
- BaseRelocationTable_Size = head.getInt(); // a4
- DebugDirectory_VA = head.getInt(); // a8
- DebugDirectory_Size = head.getInt(); // ac
- ArchitectureSpecificData_VA = head.getInt(); // b0
- ArchitectureSpecificData_Size = head.getInt(); // b4
- RVAofGP_VA = head.getInt(); // b8
- RVAofGP_Size = head.getInt(); // bc
- TLSDirectory_VA = head.getInt(); // c0
- TLSDirectory_Size = head.getInt(); // c4
- LoadConfigurationDirectory_VA = head.getInt(); // c8
- LoadConfigurationDirectory_Size = head.getInt(); // cc
- BoundImportDirectoryinheaders_VA = head.getInt(); // d0
- BoundImportDirectoryinheaders_Size = head.getInt(); // d4
- ImportAddressTable_VA = head.getInt(); // d8
- ImportAddressTable_Size = head.getInt(); // dc
- DelayLoadImportDescriptors_VA = head.getInt(); // e0
- DelayLoadImportDescriptors_Size = head.getInt(); // e4
- COMRuntimedescriptor_VA = head.getInt(); // e8
- COMRuntimedescriptor_Size = head.getInt(); // ec
- }
-
- public void dump(PrintStream out) {
- out.println("HEADER:");
- out.println("int Machine=" + Machine + " // 4");
- out.println("int NumberOfSections=" + NumberOfSections + " // 6");
- out.println("long TimeDateStamp=" + TimeDateStamp + " // 8");
- out.println("long PointerToSymbolTable=" + PointerToSymbolTable + " // C");
- out.println("long NumberOfSymbols=" + NumberOfSymbols + " // 10");
- out.println("int SizeOfOptionalHeader=" + SizeOfOptionalHeader + " // 14");
- out.println("int Characteristics=" + Characteristics + " // 16");
- // Optional Header
-
- out.println("int Magic=" + Magic + " // 18");
- out.println("short MajorLinkerVersion=" + MajorLinkerVersion + " // 1a");
- out.println("short MinorLinkerVersion=" + MinorLinkerVersion + " // 1b");
- out.println("long SizeOfCode=" + SizeOfCode + " // 1c");
- out.println("long SizeOfInitializedData=" + SizeOfInitializedData + " // 20");
- out.println("long SizeOfUninitializedData=" + SizeOfUninitializedData + " // 24");
- out.println("long AddressOfEntryPoint=" + AddressOfEntryPoint + " // 28");
- out.println("long BaseOfCode=" + BaseOfCode + " // 2c");
- out.println("long BaseOfData=" + BaseOfData + " // // NT additional fields. // 30");
- //
- out.println("long ImageBase=" + ImageBase + " // 34");
- out.println("long SectionAlignment=" + SectionAlignment + " // 38");
- out.println("long FileAlignment=" + FileAlignment + " // 3c");
- out.println("int MajorOperatingSystemVersion=" + MajorOperatingSystemVersion + " // 40");
- out.println("int MinorOperatingSystemVersion=" + MinorOperatingSystemVersion + " // 42");
- out.println("int MajorImageVersion=" + MajorImageVersion + " // 44");
- out.println("int MinorImageVersion=" + MinorImageVersion + " // 46");
- out.println("int MajorSubsystemVersion=" + MajorSubsystemVersion + " // 48");
- out.println("int MinorSubsystemVersion=" + MinorSubsystemVersion + " // 4a");
- out.println("long Reserved1=" + Reserved1 + " // 4c");
- out.println("long SizeOfImage=" + SizeOfImage + " // 50");
- out.println("long SizeOfHeaders=" + SizeOfHeaders + " // 54");
- out.println("long CheckSum=" + CheckSum + " // 58");
- out.println("int Subsystem=" + Subsystem + " // 5c");
- out.println("int DllCharacteristics=" + DllCharacteristics + " // 5e");
- out.println("long SizeOfStackReserve=" + SizeOfStackReserve + " // 60");
- out.println("long SizeOfStackCommit=" + SizeOfStackCommit + " // 64");
- out.println("long SizeOfHeapReserve=" + SizeOfHeapReserve + " // 68");
- out.println("long SizeOfHeapCommit=" + SizeOfHeapCommit + " // 6c");
- out.println("long LoaderFlags=" + LoaderFlags + " // 70");
- out.println("long NumberOfRvaAndSizes=" + NumberOfRvaAndSizes + " // 74");
-
- out.println("long ExportDirectory_VA=" + ExportDirectory_VA + " // 78");
- out.println("long ExportDirectory_Size=" + ExportDirectory_Size + " // 7c");
- out.println("long ImportDirectory_VA=" + ImportDirectory_VA + " // 80");
- out.println("long ImportDirectory_Size=" + ImportDirectory_Size + " // 84");
- out.println("long ResourceDirectory_VA=" + ResourceDirectory_VA + " // 88");
- out.println("long ResourceDirectory_Size=" + ResourceDirectory_Size + " // 8c");
- out.println("long ExceptionDirectory_VA=" + ExceptionDirectory_VA + " // 90");
- out.println("long ExceptionDirectory_Size=" + ExceptionDirectory_Size + " // 94");
- out.println("long SecurityDirectory_VA=" + SecurityDirectory_VA + " // 98");
- out.println("long SecurityDirectory_Size=" + SecurityDirectory_Size + " // 9c");
- out.println("long BaseRelocationTable_VA=" + BaseRelocationTable_VA + " // a0");
- out.println("long BaseRelocationTable_Size=" + BaseRelocationTable_Size + " // a4");
- out.println("long DebugDirectory_VA=" + DebugDirectory_VA + " // a8");
- out.println("long DebugDirectory_Size=" + DebugDirectory_Size + " // ac");
- out.println("long ArchitectureSpecificData_VA=" + ArchitectureSpecificData_VA + " // b0");
- out.println("long ArchitectureSpecificData_Size=" + ArchitectureSpecificData_Size + " // b4");
- out.println("long RVAofGP_VA=" + RVAofGP_VA + " // b8");
- out.println("long RVAofGP_Size=" + RVAofGP_Size + " // bc");
- out.println("long TLSDirectory_VA=" + TLSDirectory_VA + " // c0");
- out.println("long TLSDirectory_Size=" + TLSDirectory_Size + " // c4");
- out.println("long LoadConfigurationDirectory_VA=" + LoadConfigurationDirectory_VA + " // c8");
- out.println("long LoadConfigurationDirectory_Size=" + LoadConfigurationDirectory_Size + " // cc");
- out.println("long BoundImportDirectoryinheaders_VA=" + BoundImportDirectoryinheaders_VA + " // d0");
- out.println("long BoundImportDirectoryinheaders_Size=" + BoundImportDirectoryinheaders_Size + " // d4");
- out.println("long ImportAddressTable_VA=" + ImportAddressTable_VA + " // d8");
- out.println("long ImportAddressTable_Size=" + ImportAddressTable_Size + " // dc");
- out.println("long DelayLoadImportDescriptors_VA=" + DelayLoadImportDescriptors_VA + " // e0");
- out.println("long DelayLoadImportDescriptors_Size=" + DelayLoadImportDescriptors_Size + " // e4");
- out.println("long COMRuntimedescriptor_VA=" + COMRuntimedescriptor_VA + " // e8");
- out.println("long COMRuntimedescriptor_Size=" + COMRuntimedescriptor_Size + " // ec");
- }
-
- public ByteBuffer get() {
- ByteBuffer head = ByteBuffer.allocate(16 + this.SizeOfOptionalHeader);
- head.order(ByteOrder.LITTLE_ENDIAN);
- head.position(0);
-
- head.putInt(PeMagic);
-
- head.putShort((short)Machine); // 4
- head.putShort((short)NumberOfSections); // 6
- head.putInt((int)TimeDateStamp); // 8
- head.putInt((int)PointerToSymbolTable); // C
- head.putInt((int)NumberOfSymbols); // 10
- head.putShort((short)SizeOfOptionalHeader); // 14
- head.putShort((short)Characteristics); // 16
- // Optional Header
-
- head.putShort((short)Magic); // 18
- head.put((byte)MajorLinkerVersion); // 1a
- head.put((byte)MinorLinkerVersion); // 1b
- head.putInt((int)SizeOfCode); // 1c
- head.putInt((int)SizeOfInitializedData); // 20
- head.putInt((int)SizeOfUninitializedData); // 24
- head.putInt((int)AddressOfEntryPoint); // 28
- head.putInt((int)BaseOfCode); // 2c
- if (isPe32Plus()) {
- head.putLong(ImageBase); // 34
- } else {
- head.putInt((int)BaseOfData); // // NT additional fields. // 30
- head.putInt((int)ImageBase); // 34
- }
- head.putInt((int)SectionAlignment); // 38
- head.putInt((int)FileAlignment); // 3c
- head.putShort((short)MajorOperatingSystemVersion); // 40
- head.putShort((short)MinorOperatingSystemVersion); // 42
- head.putShort((short)MajorImageVersion); // 44
- head.putShort((short)MinorImageVersion); // 46
- head.putShort((short)MajorSubsystemVersion); // 48
- head.putShort((short)MinorSubsystemVersion); // 4a
- head.putInt((int)Reserved1); // 4c
- head.putInt((int)SizeOfImage); // 50
- head.putInt((int)SizeOfHeaders); // 54
- head.putInt((int)CheckSum); // 58
- head.putShort((short)Subsystem); // 5c
- head.putShort((short)DllCharacteristics); // 5e
- if (isPe32Plus()) {
- head.putLong(SizeOfStackReserve); // 60
- head.putLong(SizeOfStackCommit); // 64
- head.putLong(SizeOfHeapReserve); // 68
- head.putLong(SizeOfHeapCommit); // 6c
- } else {
- head.putInt((int)SizeOfStackReserve); // 60
- head.putInt((int)SizeOfStackCommit); // 64
- head.putInt((int)SizeOfHeapReserve); // 68
- head.putInt((int)SizeOfHeapCommit); // 6c
- }
- head.putInt((int)LoaderFlags); // 70
- head.putInt((int)NumberOfRvaAndSizes); // 74
-
- head.putInt((int)ExportDirectory_VA); // 78
- head.putInt((int)ExportDirectory_Size); // 7c
- head.putInt((int)ImportDirectory_VA); // 80
- head.putInt((int)ImportDirectory_Size); // 84
- head.putInt((int)ResourceDirectory_VA); // 88
- head.putInt((int)ResourceDirectory_Size); // 8c
- head.putInt((int)ExceptionDirectory_VA); // 90
- head.putInt((int)ExceptionDirectory_Size); // 94
- head.putInt((int)SecurityDirectory_VA); // 98
- head.putInt((int)SecurityDirectory_Size); // 9c
- head.putInt((int)BaseRelocationTable_VA); // a0
- head.putInt((int)BaseRelocationTable_Size); // a4
- head.putInt((int)DebugDirectory_VA); // a8
- head.putInt((int)DebugDirectory_Size); // ac
- head.putInt((int)ArchitectureSpecificData_VA); // b0
- head.putInt((int)ArchitectureSpecificData_Size); // b4
- head.putInt((int)RVAofGP_VA); // b8
- head.putInt((int)RVAofGP_Size); // bc
- head.putInt((int)TLSDirectory_VA); // c0
- head.putInt((int)TLSDirectory_Size); // c4
- head.putInt((int)LoadConfigurationDirectory_VA); // c8
- head.putInt((int)LoadConfigurationDirectory_Size); // cc
- head.putInt((int)BoundImportDirectoryinheaders_VA); // d0
- head.putInt((int)BoundImportDirectoryinheaders_Size); // d4
- head.putInt((int)ImportAddressTable_VA); // d8
- head.putInt((int)ImportAddressTable_Size); // dc
- head.putInt((int)DelayLoadImportDescriptors_VA); // e0
- head.putInt((int)DelayLoadImportDescriptors_Size); // e4
- head.putInt((int)COMRuntimedescriptor_VA); // e8
- head.putInt((int)COMRuntimedescriptor_Size); // ec
-
- head.position(0);
- return head;
- }
-
- public void updateVAAndSize(Vector oldsections, Vector newsections) {
- long codebase = findNewVA(this.BaseOfCode, oldsections, newsections);
- long codesize = findNewSize(this.BaseOfCode, oldsections, newsections);
- // System.out.println("New BaseOfCode=" + codebase + " (size=" + codesize + ")");
- this.BaseOfCode = codebase;
- this.SizeOfCode = codesize;
-
- this.AddressOfEntryPoint = findNewVA(this.AddressOfEntryPoint, oldsections, newsections);
-
- long database = findNewVA(this.BaseOfData, oldsections, newsections);
- long datasize = findNewSize(this.BaseOfData, oldsections, newsections);
- // System.out.println("New BaseOfData=" + database + " (size=" + datasize + ")");
- this.BaseOfData = database;
-
- long imagesize = 0;
- for (int i = 0; i < newsections.size(); i++) {
- PESection sect = (PESection)newsections.get(i);
- long curmax = sect.VirtualAddress + sect.VirtualSize;
- if (curmax > imagesize)
- imagesize = curmax;
- }
- this.SizeOfImage = imagesize;
-
- // this.SizeOfInitializedData = datasize;
-
- ExportDirectory_Size = findNewSize(ExportDirectory_VA, oldsections, newsections);
- ExportDirectory_VA = findNewVA(ExportDirectory_VA, oldsections, newsections);
- ImportDirectory_Size = findNewSize(ImportDirectory_VA, oldsections, newsections);
- ImportDirectory_VA = findNewVA(ImportDirectory_VA, oldsections, newsections);
- ResourceDirectory_Size = findNewSize(ResourceDirectory_VA, oldsections, newsections);
- ResourceDirectory_VA = findNewVA(ResourceDirectory_VA, oldsections, newsections);
- ExceptionDirectory_Size = findNewSize(ExceptionDirectory_VA, oldsections, newsections);
- ExceptionDirectory_VA = findNewVA(ExceptionDirectory_VA, oldsections, newsections);
- SecurityDirectory_Size = findNewSize(SecurityDirectory_VA, oldsections, newsections);
- SecurityDirectory_VA = findNewVA(SecurityDirectory_VA, oldsections, newsections);
- BaseRelocationTable_Size = findNewSize(BaseRelocationTable_VA, oldsections, newsections);
- BaseRelocationTable_VA = findNewVA(BaseRelocationTable_VA, oldsections, newsections);
- DebugDirectory_Size = findNewSize(DebugDirectory_VA, oldsections, newsections);
- DebugDirectory_VA = findNewVA(DebugDirectory_VA, oldsections, newsections);
- ArchitectureSpecificData_Size = findNewSize(ArchitectureSpecificData_VA, oldsections, newsections);
- ArchitectureSpecificData_VA = findNewVA(ArchitectureSpecificData_VA, oldsections, newsections);
- RVAofGP_Size = findNewSize(RVAofGP_VA, oldsections, newsections);
- RVAofGP_VA = findNewVA(RVAofGP_VA, oldsections, newsections);
- TLSDirectory_Size = findNewSize(TLSDirectory_VA, oldsections, newsections);
- TLSDirectory_VA = findNewVA(TLSDirectory_VA, oldsections, newsections);
- LoadConfigurationDirectory_Size = findNewSize(LoadConfigurationDirectory_VA, oldsections, newsections);
- LoadConfigurationDirectory_VA = findNewVA(LoadConfigurationDirectory_VA, oldsections, newsections);
- BoundImportDirectoryinheaders_Size = findNewSize(BoundImportDirectoryinheaders_VA, oldsections, newsections);
- BoundImportDirectoryinheaders_VA = findNewVA(BoundImportDirectoryinheaders_VA, oldsections, newsections);
- ImportAddressTable_Size = findNewSize(ImportAddressTable_VA, oldsections, newsections);
- ImportAddressTable_VA = findNewVA(ImportAddressTable_VA, oldsections, newsections);
- DelayLoadImportDescriptors_Size = findNewSize(DelayLoadImportDescriptors_VA, oldsections, newsections);
- DelayLoadImportDescriptors_VA = findNewVA(DelayLoadImportDescriptors_VA, oldsections, newsections);
- COMRuntimedescriptor_Size = findNewSize(COMRuntimedescriptor_VA, oldsections, newsections);
- COMRuntimedescriptor_VA = findNewVA(COMRuntimedescriptor_VA, oldsections, newsections);
- }
-
- public boolean isPe32Plus() {
- return Magic == 523;
- }
-
- private long findNewVA(long current, Vector oldsections, Vector newsections) {
- for (int i = 0; i < oldsections.size(); i++) {
- PESection sect = (PESection)oldsections.get(i);
- if (sect.VirtualAddress == current) {
- PESection newsect = (PESection)newsections.get(i);
-
- // System.out.println("Translation VA found for " + current + " = " + i + " (" +newsect.VirtualAddress + ")=" + newsect.getName());
- return newsect.VirtualAddress;
- } else if ((current > sect.VirtualAddress) && (current < (sect.VirtualAddress + sect.VirtualSize))) {
- long diff = current - sect.VirtualAddress;
- PESection newsect = (PESection)newsections.get(i);
- // System.out.println("Translation VA found INSIDE " + current + " = " + i + " (" +newsect.VirtualAddress + ")=" + newsect.getName());
- return newsect.VirtualAddress + diff;
- }
- }
-
-
- return 0;
- }
-
- private long findNewSize(long current, Vector oldsections, Vector newsections) {
- for (int i = 0; i < oldsections.size(); i++) {
- PESection sect = (PESection)oldsections.get(i);
- if (sect.VirtualAddress == current) {
- PESection newsect = (PESection)newsections.get(i);
- // System.out.println("Translation Size found for " + current + " = " + i + " (" +newsect.VirtualAddress + ")=" + newsect.getName());
- // System.out.println(" Old size " + sect.VirtualSize + " vs new size " + newsect.VirtualSize);
- return newsect.VirtualSize;
- }
- }
- return 0;
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEResourceDirectory.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEResourceDirectory.java
deleted file mode 100644
index 09676ad..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PEResourceDirectory.java
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-/*
- * PEResourceDirectory.java
- *
- * Created on 2 aout 2003, 01:28
- */
-
-package net.charabia.jsmoothgen.pe;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-import java.util.Iterator;
-import java.util.Vector;
-
-/**
- * @author Rodrigo
- */
-public class PEResourceDirectory {
-
- /*
- typedef struct IMAGE_RESOURCE_DIRECTORY {
- uint32_t Characteristics;
- uint32_t TimeDateStamp;
- uint16_t MajorVersion;
- uint16_t MinorVersion;
- uint16_t NumberOfNamedEntries;
- uint16_t NumberOfIdEntries;
- }
- */
-
- public class DataEntry {
- long OffsetToData; // To update at each change
- long Size;
- long CodePage; // never changed
- long Reserved; // never changed
- ByteBuffer Data;
-
- public DataEntry(ByteBuffer data) {
- this.Data = data;
- this.Size = data.capacity();
- }
-
- public DataEntry(FileChannel chan, long offset) throws IOException {
- long orgpos = chan.position();
- chan.position(PEResourceDirectory.this.m_offsetBase + offset);
- ByteBuffer buf = ByteBuffer.allocate(16);
- buf.order(ByteOrder.LITTLE_ENDIAN);
- chan.read(buf);
- buf.position(0);
-
- OffsetToData = buf.getInt();
- Size = buf.getInt();
- CodePage = buf.getInt();
- Reserved = buf.getInt();
-
- long datapos = PEResourceDirectory.this.m_master.PointerToRawData + (OffsetToData - PEResourceDirectory.this.m_master.VirtualAddress);
- Data = ByteBuffer.allocate((int)Size);
- Data.order(ByteOrder.LITTLE_ENDIAN);
- chan.position(datapos);
- chan.read(Data);
- Data.position(0);
-
- chan.position(orgpos);
- }
-
- public int diskSize() {
- int size = 16 + (int)this.Size;
- if ((size % 4) > 0)
- size += 4 - (size % 4);
- return size;
- }
-
- public void dump(PrintStream out, int level) {
- indent(level, out);
- out.println("OffsetToData=" + OffsetToData);
- indent(level, out);
- out.println("Size=" + Size);
- indent(level, out);
- out.println("CodePage=" + CodePage);
- indent(level, out);
- out.println("Reserved=" + Reserved);
- indent(level, out);
- out.print("Data={ ");
- for (int i = 0; i < this.Data.capacity(); i++) {
- out.print("" + Integer.toHexString((byte)Data.get()) + ",");
- }
- out.println(" }");
-
- }
-
- private void indent(int level, PrintStream out) {
- for (int i = 0; i < level; i++)
- out.print(" ");
- }
-
- public int buildBuffer(ByteBuffer buffer, long virtualBaseOffset, int dataOffset) {
- // System.out.println("Building Data Entry buffer @ " + buffer.position() + " (" + dataOffset + ")");
-
- dataOffset = buffer.position() + 16;
-
- buffer.putInt((int)(dataOffset + virtualBaseOffset));
- buffer.putInt((int)Size);
- buffer.putInt((int)CodePage);
- buffer.putInt((int)Reserved);
-
- Data.position(0);
- buffer.put(Data);
-
- dataOffset += Size;
- if ((dataOffset % 4) > 0)
- dataOffset += (4 - (dataOffset % 4));
-
- return dataOffset;
- }
-
- public void setData(ByteBuffer data) {
- Data = data;
- Size = data.capacity();
- }
- }
-
- public class ResourceEntry {
- int Id;
- String Name;
-
- ImageResourceDirectory Directory;
- DataEntry Data;
-
- public ResourceEntry(int id, DataEntry data) {
- this.Id = id;
- this.Data = data;
- }
-
- public ResourceEntry(String name, DataEntry data) {
- this.Name = name;
- this.Data = data;
- }
-
- public ResourceEntry(int id, ImageResourceDirectory dir) {
- this.Id = id;
- this.Directory = dir;
- }
-
- public ResourceEntry(String name, ImageResourceDirectory dir) {
- this.Name = name;
- this.Directory = dir;
- }
-
- public ResourceEntry(FileChannel chan) throws IOException {
- // System.out.println("Resource Entry Offset: " + chan.position());
- ByteBuffer buf = ByteBuffer.allocate(8);
- buf.order(ByteOrder.LITTLE_ENDIAN);
- chan.read(buf);
- buf.position(0);
- long orgchanpos = chan.position();
- int val = buf.getInt();
- long offsetToData = buf.getInt();
- // System.out.println("Entry: Val=" + val);
- // System.out.println(" Off=" + offsetToData);
-
- if (val < 0) {
- val &= 0x7FFFFFFF;
- Name = extractStringAt(chan, val);
- Id = -1;
- // System.out.println(" String at " + val + " = " + Name);
- } else {
- Id = val;
- }
-
- if (offsetToData < 0) {
- offsetToData &= 0x7FFFFFFF;
- long orgpos = chan.position();
- chan.position(PEResourceDirectory.this.m_offsetBase + offsetToData);
- Directory = new PEResourceDirectory.ImageResourceDirectory(chan);
- chan.position(orgpos);
- } else {
- Data = new DataEntry(chan, offsetToData);
- }
- }
-
- public String extractStringAt(FileChannel chan, int offset) throws IOException {
- long orgchanpos = chan.position();
- chan.position(PEResourceDirectory.this.m_offsetBase + offset);
-
- ByteBuffer sizebuf = ByteBuffer.allocate(2);
- sizebuf.order(ByteOrder.LITTLE_ENDIAN);
- chan.read(sizebuf);
- sizebuf.position(0);
-
- int size = sizebuf.getShort();
- ByteBuffer buffer = ByteBuffer.allocate(size * 2);
- buffer.order(ByteOrder.LITTLE_ENDIAN);
- chan.read(buffer);
- buffer.position(0);
-
- StringBuffer buf = new StringBuffer(size);
- for (int i = 0; i < size; i++) {
- int c = buffer.getShort();
- buf.append((char)c);
- }
-
- chan.position(orgchanpos);
- return buf.toString();
- }
-
- public int diskSize() {
- int size = 8;
- if (Name != null)
- size += (Name.length() * 2) + 2;
-
- if (Directory != null)
- size += Directory.diskSize();
- else if (Data != null)
- size += Data.diskSize();
-
- if ((size % 4) > 0)
- size += 4 - (size % 4);
- return size;
- }
-
- public void dump(PrintStream out, int level) {
- indent(level, out);
- if (this.Name != null)
- out.println("Name=" + Name);
- else
- out.println("Id=#" + Id);
-
- indent(level, out);
- if (this.Directory != null) {
- out.println("ENTRY: DIRECTORY POINTER");
- this.Directory.dump(out, level + 1);
- } else {
- out.println("ENTRY: DATA ENTRY");
- Data.dump(out, level + 1);
- }
- }
-
- private void indent(int level, PrintStream out) {
- for (int i = 0; i < level; i++)
- out.print(" ");
- }
-
- public int buildBuffer(ByteBuffer buffer, long virtualBaseOffset, int dataOffset) {
- // System.out.println("Building Resource Entry buffer " + Name + "/" + Id + " @ " + buffer.position() + " (" + dataOffset + ")");
- if (Name != null) {
- buffer.putInt((int)(dataOffset | 0x80000000));
-
- int stringoffset = dataOffset;
- ByteBuffer strbuf = ByteBuffer.allocate(Name.length() * 2 + 2);
- strbuf.order(ByteOrder.LITTLE_ENDIAN);
-
- strbuf.putShort((short)Name.length());
- for (int i = 0; i < Name.length(); i++) {
- strbuf.putShort((short)Name.charAt(i));
- }
- strbuf.position(0);
-
- long oldpos = buffer.position();
- buffer.position(dataOffset);
- buffer.put(strbuf);
- dataOffset += Name.length() * 2 + 2;
- if ((dataOffset % 4) != 0)
- dataOffset += 4 - (dataOffset % 4);
- buffer.position((int) oldpos);
- } else {
- buffer.putInt(Id);
- }
-
- if (Directory != null) {
- buffer.putInt((int)(dataOffset | 0x80000000));
-
- int oldpos = buffer.position();
- buffer.position(dataOffset);
- int dirsize = Directory.buildBuffer(buffer, virtualBaseOffset);
- dataOffset = dirsize;
- buffer.position(oldpos);
-
- } else if (Data != null) {
- buffer.putInt(dataOffset);
- int oldpos = buffer.position();
- buffer.position(dataOffset);
- dataOffset = Data.buildBuffer(buffer, virtualBaseOffset, dataOffset);
- buffer.position(oldpos);
- } else {
- throw new RuntimeException("Directory and Data are both null!");
- }
-
- return dataOffset;
- }
- }
-
- public class ImageResourceDirectory {
- long Characteristics; // uint32_t
- long TimeDateStamp; // uint32_t
- int MajorVersion; // uint16_t
- int MinorVersion; // uint16_t
- int NumberOfNamedEntries; // uint16_t
- int NumberOfIdEntries; // uint16_t
- Vector NamedEntries = new Vector();
- Vector IdEntries = new Vector();
-
- public ImageResourceDirectory() {
- }
-
- public ImageResourceDirectory(FileChannel chan) throws IOException {
- ByteBuffer header = ByteBuffer.allocate(16);
- header.order(ByteOrder.LITTLE_ENDIAN);
- chan.read(header);
- header.position(0);
-
- Characteristics = header.getInt();
- TimeDateStamp = header.getInt();
- MajorVersion = header.getShort();
- MinorVersion = header.getShort();
- NumberOfNamedEntries = header.getShort();
- NumberOfIdEntries = header.getShort();
-
- for (int i = 0; i < NumberOfNamedEntries; i++) {
- ResourceEntry re = new ResourceEntry(chan);
- NamedEntries.add(re);
- }
- for (int i = 0; i < NumberOfIdEntries; i++) {
- ResourceEntry re = new ResourceEntry(chan);
- IdEntries.add(re);
- }
- }
-
- public void addNamedEntry(ResourceEntry entry) {
- this.NamedEntries.add(entry);
- }
-
- public void addIdEntry(ResourceEntry entry) {
- this.IdEntries.add(entry);
- }
-
- public void addEntry(ResourceEntry entry) {
- if (entry.Name != null)
- addNamedEntry(entry);
- else
- addIdEntry(entry);
- }
-
- public void dump(PrintStream out, int level) {
- indent(level, out);
- out.println("Directory: ");
- indent(level, out);
- out.println("Characteristics=" + this.Characteristics);
- indent(level, out);
- out.println("TimeDateStamp=" + this.TimeDateStamp);
- indent(level, out);
- out.println("MajorVersion=" + this.MajorVersion);
- indent(level, out);
- out.println("MinorVersion=" + this.MinorVersion);
- indent(level, out);
- out.println("NumberOfNamedEntries=" + this.NumberOfNamedEntries);
- indent(level, out);
- out.println("NumberOfIdEntries=" + this.NumberOfIdEntries);
- indent(level, out);
- out.println("Named Entries:");
- for (int i = 0; i < NumberOfNamedEntries; i++) {
- ResourceEntry re = (ResourceEntry)NamedEntries.get(i);
- re.dump(out, level + 1);
- }
- indent(level, out);
- out.println("Id Entries:");
- for (int i = 0; i < NumberOfIdEntries; i++) {
- ResourceEntry re = (ResourceEntry)IdEntries.get(i);
- re.dump(out, level + 1);
- }
- }
-
- private void indent(int level, PrintStream out) {
- for (int i = 0; i < level; i++)
- out.print(" ");
- }
-
- public int diskSize() {
- int size = 16;
- for (int i = 0; i < this.NamedEntries.size(); i++) {
- ResourceEntry re = (ResourceEntry)NamedEntries.get(i);
- size += re.diskSize();
- }
- for (int i = 0; i < this.IdEntries.size(); i++) {
- ResourceEntry re = (ResourceEntry)IdEntries.get(i);
- size += re.diskSize();
- }
-
- if ((size % 4) > 0)
- size += 4 - (size % 4);
-
- return size;
- }
-
- public int buildBuffer(ByteBuffer buffer, long virtualBaseOffset) {
- // System.out.println("Building Directory Entry buffer @ " + buffer.position());
-
- buffer.putInt((int)this.Characteristics);
- buffer.putInt((int)this.TimeDateStamp);
- buffer.putShort((short)this.MajorVersion);
- buffer.putShort((short)this.MinorVersion);
- buffer.putShort((short)this.NamedEntries.size());
- buffer.putShort((short)this.IdEntries.size());
-
- int dataOffset = buffer.position() + (NamedEntries.size() * 8) + (IdEntries.size() * 8);
-
- for (int i = 0; i < this.NamedEntries.size(); i++) {
- ResourceEntry re = (ResourceEntry)this.NamedEntries.get(i);
- dataOffset = re.buildBuffer(buffer, virtualBaseOffset, dataOffset);
- }
-
- for (int i = 0; i < this.IdEntries.size(); i++) {
- ResourceEntry re = (ResourceEntry)this.IdEntries.get(i);
- dataOffset = re.buildBuffer(buffer, virtualBaseOffset, dataOffset);
- }
-
- buffer.position(dataOffset);
- return dataOffset;
- }
-
- public ResourceEntry getResourceEntry(String name) {
- // If name == null, get the first entry in lexical
- // order. If no entry in lexical order, choose the
- // lowest integer id entry.
- if (name == null) {
- if (NamedEntries.size() > 0) {
- return (PEResourceDirectory.ResourceEntry)NamedEntries.get(0);
- }
- if (IdEntries.size() > 0) {
- return (PEResourceDirectory.ResourceEntry)IdEntries.get(0);
- }
- return null;
- }
-
- if ((name.length() > 0) && (name.charAt(0) == '#')) {
- try {
- String nb = name.substring(1);
- int i = Integer.parseInt(nb);
- return getResourceEntry(i);
- } catch (Exception exc) {
- exc.printStackTrace();
- }
- }
-
- for (Iterator i = this.NamedEntries.iterator(); i.hasNext();) {
- ResourceEntry re = (ResourceEntry)i.next();
- if (name.equals(re.Name)) {
- return re;
- }
- }
- return null;
- }
-
- public ResourceEntry getResourceEntry(int id) {
- for (Iterator i = this.IdEntries.iterator(); i.hasNext();) {
- ResourceEntry re = (ResourceEntry)i.next();
- if (id == re.Id) {
- return re;
- }
- }
- return null;
- }
-
- }
-
- PESection m_master;
- PEFile m_file;
- long m_offsetBase;
-
- PEResourceDirectory.ImageResourceDirectory m_root;
-
- /**
- * Creates a new instance of PEResourceDirectory
- */
- public PEResourceDirectory(PEFile file, PESection sect) throws IOException {
- m_master = sect;
- m_file = file;
- m_offsetBase = sect.PointerToRawData;
- init();
-
- // System.out.println("--------\nTOTAL SIZE: " + m_root.diskSize());
-
- // System.out.println("\n\n");
- }
-
- public void init() throws IOException {
- // / System.out.println("RESOURCE INIT");
- // System.out.println(" Offset: " + m_master.PointerToRawData);
- FileChannel chan = m_file.getChannel();
- chan.position(m_master.PointerToRawData);
- PEResourceDirectory.ImageResourceDirectory dir = new PEResourceDirectory.ImageResourceDirectory(chan);
- // System.out.println("-----------------\nDUMP\n---------------");
- m_root = dir;
-
- // dir.dump(System.out, 0);
- }
-
- public void dump(PrintStream out) {
- m_root.dump(out, 0);
- }
-
- public int size() {
- return m_root.diskSize();
- }
-
- public ByteBuffer buildResource(long virtualBaseOffset) {
- // System.out.println("BUILDING RESOURCE / VIRTUAL: " + virtualBaseOffset);
- int resourceSize = m_root.diskSize();
- ByteBuffer resbuf = ByteBuffer.allocate(resourceSize);
- resbuf.order(ByteOrder.LITTLE_ENDIAN);
- resbuf.position(0);
- m_root.buildBuffer(resbuf, virtualBaseOffset);
- return resbuf;
- }
-
- public PEResourceDirectory.ImageResourceDirectory getRoot() {
- return m_root;
- }
-
- public boolean replaceManifest(int resourceId, int langId, ByteBuffer data) {
- ResourceEntry catEntry = m_root.getResourceEntry(24);
- if ((catEntry != null) && (catEntry.Directory != null)) {
- ResourceEntry identEntry = catEntry.Directory.getResourceEntry(resourceId);
- if ((identEntry != null) && (identEntry.Directory != null)) {
- ResourceEntry langEntry = identEntry.Directory.getResourceEntry(langId);
- if ((langEntry != null) && (langEntry.Data != null)) {
- DataEntry dataslot = langEntry.Data;
- dataslot.setData(data);
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean replaceResource(String catId, int resourceId, int langId, ByteBuffer data) {
- ResourceEntry catEntry = m_root.getResourceEntry(catId);
- if ((catEntry != null) && (catEntry.Directory != null)) {
- ResourceEntry identEntry = catEntry.Directory.getResourceEntry(resourceId);
- if ((identEntry != null) && (identEntry.Directory != null)) {
- ResourceEntry langEntry = identEntry.Directory.getResourceEntry(langId);
- if ((langEntry != null) && (langEntry.Data != null)) {
- DataEntry dataslot = langEntry.Data;
- dataslot.setData(data);
- return true;
- }
- }
- }
- return false;
- }
-
- public void addNewResource(String catId, String resourceId, String languageId, ByteBuffer data) {
- DataEntry dataEntry = new DataEntry(data);
- ResourceEntry languageEntry = buildResourceEntry(languageId, dataEntry);
- ImageResourceDirectory languageDir = new ImageResourceDirectory();
-
- languageDir.TimeDateStamp = 0x3F2CCF64;
- languageDir.addEntry(languageEntry);
-
- ResourceEntry identEntry = buildResourceEntry(resourceId, languageDir);
-
- ImageResourceDirectory identDir = new ImageResourceDirectory();
- identDir.TimeDateStamp = 0x3F2CCF64;
- identDir.addEntry(identEntry);
-
- ResourceEntry catEntry = buildResourceEntry(catId, identDir);
- m_root.addEntry(catEntry);
- }
-
- public DataEntry getData(String catId, String resourceId, String langId) {
- ResourceEntry catEntry = m_root.getResourceEntry(catId);
- if ((catEntry != null) && (catEntry.Directory != null)) {
- ResourceEntry identEntry = catEntry.Directory.getResourceEntry(resourceId);
- if ((identEntry != null) && (identEntry.Directory != null)) {
- ResourceEntry langEntry = identEntry.Directory.getResourceEntry(langId);
- if ((langEntry != null) && (langEntry.Data != null)) {
- DataEntry dataslot = langEntry.Data;
- return dataslot;
- }
- }
- }
- return null;
- }
-
- public ResourceEntry buildResourceEntry(String id, DataEntry data) {
- if ((id.length() > 1) && (id.charAt(0) == '#')) {
- int intid = Integer.parseInt(id.substring(1));
- return new ResourceEntry(intid, data);
- }
-
- return new ResourceEntry(id, data);
- }
-
-
- public ResourceEntry buildResourceEntry(String id, ImageResourceDirectory dir) {
- if ((id.length() > 1) && (id.charAt(0) == '#')) {
- int intid = Integer.parseInt(id.substring(1));
- return new ResourceEntry(intid, dir);
- }
-
- return new ResourceEntry(id, dir);
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PESection.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PESection.java
deleted file mode 100644
index bbe857b..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/PESection.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/*
- * PESection.java
- *
- * Created on 29 juillet 2003, 21:34
- */
-
-package net.charabia.jsmoothgen.pe;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-
-/**
- * @author Rodrigo
- */
-public class PESection implements Cloneable {
- byte[] ANSI_Name; // Name of the Section. Can be anything (0)(8BYTES)
- long VirtualSize; // The size of the section when it is mapped to memory. Must be a multiple of 4096. (8)(DWORD)
- long VirtualAddress; // An rva to where it should be mapped in memory. (12)(DWORD)
- long SizeOfRawData; // The size of the section in the PE file. Must be a multiple of 512 (16)(DWORD)
- long PointerToRawData; // A file based offset which points to the location of this sections data (20)(DWORD)
- long PointerToRelocations; // In EXE's this field is meaningless, and is set 0 (24)(DWORD)
- long PointerToLinenumbers; // This is the file-based offset of the line number table. This field is only used for debug purposes, and is usualy set to 0 (28)(DWORD)
- int NumberOfRelocations; // In EXE's this field is meaningless, and is set 0 (32)(WORD)
- int NumberOfLinenumbers; // The number of line numbers in the line number table for this section. This field is only used for debug purposes, and is usualy set to 0 (34)(WORD)
- long Characteristics; // The kind of data stored in this section ie. Code, Data, Import data, Relocation data (36)(DWORD)
-
- private long m_baseoffset;
- private PEFile m_pe;
-
- /**
- * Creates a new instance of PESection
- */
- public PESection(PEFile pef, long baseoffset) {
- m_pe = pef;
- m_baseoffset = baseoffset;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- public String getName() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < 8; i++)
- buffer.append((char) ANSI_Name[i]);
- return buffer.toString();
- }
-
- public void read() throws IOException {
- FileChannel ch = m_pe.getChannel();
- ByteBuffer head = ByteBuffer.allocate(40);
- head.order(ByteOrder.LITTLE_ENDIAN);
- ch.position(m_baseoffset);
- ch.read(head);
- head.position(0);
-
- ANSI_Name = new byte[8];
- for (int i = 0; i < 8; i++)
- ANSI_Name[i] = head.get();
-
- VirtualSize = head.getInt();
- VirtualAddress = head.getInt();
- SizeOfRawData = head.getInt();
- PointerToRawData = head.getInt();
- PointerToRelocations = head.getInt();
- PointerToLinenumbers = head.getInt();
- NumberOfRelocations = head.getShort();
- NumberOfLinenumbers = head.getShort();
- Characteristics = head.getInt();
- }
-
- public void dump(PrintStream out) {
- out.println("SECTION:");
- out.println(" Name= "+getName());
- out.println(" VirtualSize= " + VirtualSize + " // The size of the section when it is mapped to memory. Must be a multiple of 4096. (8)(DWORD)");
- out.println(" VirtualAddress= " + VirtualAddress + " // An rva to where it should be mapped in memory. (12)(DWORD)");
- out.println(" SizeOfRawData= " + SizeOfRawData + " // The size of the section in the PE file. Must be a multiple of 512 (16)(DWORD)");
- out.println(" PointerToRawData= " + PointerToRawData + " // A file based offset which points to the location of this sections data (20)(DWORD)");
- out.println(" PointerToRelocations= " + PointerToRelocations + " // In EXE's this field is meaningless, and is set 0 (24)(DWORD)");
- out.println(" PointerToLinenumbers= " + PointerToLinenumbers + " // This is the file-based offset of the line number table. This field is only used for debug purposes, and is usualy set to 0 (28)(DWORD)");
- out.println(" NumberOfRelocations= " + NumberOfRelocations + " // In EXE's this field is meaningless, and is set 0 (32)(WORD)");
- out.println(" NumberOfLinenumbers= " + NumberOfLinenumbers + " // The number of line numbers in the line number table for this section. This field is only used for debug purposes, and is usualy set to 0 (34)(WORD)");
- out.println(" Characteristics= " + Characteristics + " // The kind of data stored in this section ie. Code, Data, Import data, Relocation data (36)(DWORD)");
-
- }
-
-
- public ByteBuffer get() {
- ByteBuffer head = ByteBuffer.allocate(40);
- head.order(ByteOrder.LITTLE_ENDIAN);
- head.position(0);
-
- for (int i = 0; i < 8; i++)
- head.put((byte)ANSI_Name[i]);
-
- head.putInt((int)VirtualSize);
- head.putInt((int)VirtualAddress);
- head.putInt((int)SizeOfRawData);
- head.putInt((int)PointerToRawData);
- head.putInt((int)PointerToRelocations);
- head.putInt((int)PointerToLinenumbers);
- head.putShort((short)NumberOfRelocations);
- head.putShort((short)NumberOfLinenumbers);
- head.putInt((int)Characteristics);
-
- head.position(0);
- return head;
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/res/ResIcon.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/res/ResIcon.java
deleted file mode 100644
index b5d3dec..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/res/ResIcon.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-/*
- * ResIcon.java
- *
- * Created on 17 août 2003, 22:51
- */
-
-package net.charabia.jsmoothgen.pe.res;
-
-import java.util.*;
-import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.awt.*;
-import java.awt.image.*;
-
-/**
- * @see
- */
-public class ResIcon
-{
- public long Size; /* Size of this header in bytes DWORD*/
- public long Width; /* Image width in pixels LONG*/
- public long Height; /* Image height in pixels LONG*/
- public int Planes; /* Number of color planes WORD*/
- public int BitsPerPixel; /* Number of bits per pixel WORD*/
- /* Fields added for Windows 3.x follow this line */
- public long Compression; /* Compression methods used DWORD*/
- public long SizeOfBitmap; /* Size of bitmap in bytes DWORD*/
- public long HorzResolution; /* Horizontal resolution in pixels per meter LONG*/
- public long VertResolution; /* Vertical resolution in pixels per meter LONG*/
- public long ColorsUsed; /* Number of colors in the image DWORD*/
- public long ColorsImportant; /* Minimum number of important colors DWORD*/
-
- public PaletteElement[] Palette;
- public short[] BitmapXOR;
- public short[] BitmapAND;
-
- public class PaletteElement
- {
- public int Blue;
- public int Green;
- public int Red;
- public int Reserved;
- public String toString()
- {
- return "{"+Blue+","+Green+","+Red+","+Reserved+"}";
- }
- }
-
- public ResIcon(){};
- /**
- * Creates a new instance of ResIcon
- * @see
- * @param in
- */
- public ResIcon(ByteBuffer in)
- {
- Size = in.getInt();
- Width = in.getInt();
- Height = in.getInt();
- Planes = in.getShort();
- BitsPerPixel = in.getShort();
- Compression = in.getInt();
- SizeOfBitmap = in.getInt();
- HorzResolution = in.getInt();
- VertResolution = in.getInt();
- ColorsUsed = in.getInt();
- ColorsImportant = in.getInt();
-
- int cols = (int)ColorsUsed;
- if (cols == 0)
- cols = 1 << BitsPerPixel;
-
- Palette = new PaletteElement[(int)cols];
- for (int i=0; i<Palette.length; i++)
- {
- PaletteElement el = new PaletteElement();
- el.Blue = in.get();
- el.Green = in.get();
- el.Red = in.get();
- el.Reserved = in.get();
- Palette[i] = el;
- }
-
- // int xorbytes = (((int)Height/2) * (int)Width * (int)BitsPerPixel) / 8;
- int xorbytes = (((int)Height/2) * (int)Width);
- // System.out.println("POSITION " + in.position() + " : xorbitmap = " + xorbytes + " bytes");
-
- BitmapXOR = new short[xorbytes];
- for (int i=0; i<BitmapXOR.length; i++)
- {
- switch(BitsPerPixel)
- {
- case 4:
- {
- int pix = in.get();
- BitmapXOR[i] = (short)((pix >> 4) & 0x0F);
- i++;
- BitmapXOR[i] = (short)(pix & 0x0F);
- }
- break;
- case 8:
- {
- BitmapXOR[i] = in.get();
- }
- break;
- }
- }
-
-
- int height = (int)(Height/2);
- int rowsize = (int)Width / 8;
- if ((rowsize%4)>0)
- {
- rowsize += 4 - (rowsize%4);
- }
-
- // System.out.println("POSITION " + in.position() + " : andbitmap = " + andbytes + " bytes");
-
- int andbytes = height * rowsize; // (((int)Height/2) * (int)Width) / 8;
-
- BitmapAND = new short[andbytes];
- for (int i=0; i<BitmapAND.length; i++)
- {
- BitmapAND[i] = in.get();
- }
-
- }
-
- /** Creates a new instance based on the data of the Image argument.
- * @param img
- */
- public ResIcon(Image img) throws Exception
- {
- int width = img.getWidth(null);
- int height = img.getHeight(null);
-
- if ((width % 8) != 0)
- width += (7-(width%8));
-
- if ((height % 8) != 0)
- height += (7-(height%8));
-
- // System.out.println("FOUND WIDTH " + width + " (was " + img.getWidth(null) + ")");
- // System.out.println("FOUND HEIGHT " + height + " (was " + img.getHeight(null) + ")");
-
- // System.out.println("RESICON...");
- if (img instanceof BufferedImage)
- {
- BufferedImage result = (BufferedImage)img;
-
- for (int y=0; y<result.getHeight(); y++)
- {
- for (int x=0; x<result.getWidth(); x++)
- {
- int rgb = result.getRGB(x, y);
- if (((rgb>>24)&0xFF)>0)
- {
- // System.out.print(".");
- }
- // else
- // System.out.print("*");
- }
- // System.out.println("");
- }
-
- }
-
- int[] pixelbuffer = new int[width*height];
- PixelGrabber grabber = new PixelGrabber(img, 0, 0, width, height, pixelbuffer, 0, width);
- try
- {
- grabber.grabPixels();
- } catch (InterruptedException e)
- {
- System.err.println("interrupted waiting for pixels!");
- throw new Exception("Can't load the image provided",e);
- }
-
- Hashtable colors = calculateColorCount(pixelbuffer);
-
- // FORCE ALWAYS to 8
- this.BitsPerPixel = 8;
-
- Palette = new ResIcon.PaletteElement[1 << BitsPerPixel];
- // System.out.println("Creating palette of " + Palette.length + " colors (" + colors.size() + ")");
- for (Enumeration e=colors.keys(); e.hasMoreElements(); )
- {
- Integer pixi = (Integer)e.nextElement();
- int pix = pixi.intValue();
- int index = ((Integer)colors.get(pixi)).intValue();
- // System.out.println("set pixel " + index);
-
- Palette[index] = new ResIcon.PaletteElement();
- Palette[index].Blue = pix & 0xFF;
- Palette[index].Green = (pix >> 8) & 0xff;
- Palette[index].Red = (pix >> 16) & 0xff;
- }
- for (int i=0; i<Palette.length; i++)
- {
- if (Palette[i] == null)
- Palette[i] = new ResIcon.PaletteElement();
- }
-
-
- this.Size = 40;
- this.Width = width;
- this.Height = height* 2;
- this.Planes = 1;
- this.Compression = 0;
-
- this.SizeOfBitmap = 0;
- this.HorzResolution = 0;
- this.VertResolution = 0;
-
- this.ColorsUsed = 0;
- this.ColorsImportant = 0;
-
- //
- // We calculate the rowsize in bytes. It seems that it must be
- // aligned on a double word, although none of the
- // documentation I have on the icon format states so.
- //
- int rowsize = width / 8;
- if ((rowsize%4)>0)
- {
- rowsize += 4 - (rowsize%4);
- }
-
- BitmapXOR = new short[(((int)Height/2) * (int)Width * (int)BitsPerPixel) / 8];
- BitmapAND = new short[((int)Height/2) * rowsize];
-
- int bxl = BitmapXOR.length-1;
- int bal = BitmapAND.length-1;
-
- for (int i=0; i<pixelbuffer.length; i++)
- {
- int col = i%width;
- int line = i/width;
-
- bxl = (width * height) - (((i/width)+1)*width) + (i%width);
- // bal = ((width * height)/8) - ((line+1)*(width/8)) + (col/8);
- bal = (rowsize * height) - ((line+1)*(rowsize)) + (col/8);
-
- // if ((pixelbuffer[i] & 0xFF000000) != 0x00000000)
-
- //
- // If the color is transparent, any color will suit
- // (as it is not supposed to be displayed)
- //
- if ( (((pixelbuffer[i]>>24)& 0xFF) == 0))
- {
- BitmapAND[ bal ] |= 1 << (7-(i%8));
- BitmapXOR[bxl] = 0xFF; // (short)getBrightest(); FF
-
- // int pixel = pixelbuffer[i] & 0x00FFFFFF;
- // pixel = 0x000000;
- // Integer icol = (Integer)colors.get(new Integer(pixel));
- // if (icol != null)
- // {
- // int palindex = icol.intValue();
- // BitmapXOR[bxl] = (short)palindex;
- // }
- // else
- // {
- // BitmapXOR[bxl] = 0; // (short)getBrightest();
- // System.out.println("Can't find TRANSP BLACK COL " + icol );
- // }
- }
- else
- {
- int pixel = pixelbuffer[i] & 0x00FFFFFF;
- // pixel = 0x000000;
- Integer icol = (Integer)colors.get(new Integer(pixel));
- if (icol != null)
- {
- int palindex = icol.intValue();
- BitmapXOR[bxl] = (short)palindex;
- }
- }
- }
- }
-
- private int getBrightest()
- {
- int result = 0;
- int averesult = 0;
- for (int i=0; i<Palette.length; i++)
- {
- int ave1 = (Palette[0].Red + Palette[0].Green + Palette[0].Blue)/3;
- if (ave1 > averesult)
- {
- averesult = ave1;
- result = i;
- }
- }
- return result;
- }
-
- private Hashtable calculateColorCount(int[] pixels)
- {
- Hashtable result = new Hashtable();
- int colorindex = 0;
- for (int i=0; i<pixels.length; i++)
- {
- int pix = pixels[i];
- if (((pix>>24)&0xFF) > 0)
- {
- pix &= 0x00FFFFFF;
- Integer pixi = new Integer(pix);
- Object o = result.get(pixi);
- if (o == null)
- {
- result.put(pixi, new Integer(colorindex++));
- }
- // if (colorindex > 256)
- // return result;
- }
- }
- return result;
- }
-
- /** Creates and returns a ByteBuffer containing an image under
- * the .ico format expected by Windows.
- * @return a ByteBuffer with the .ico data
- */
- public ByteBuffer getData()
- {
- int cols = (int)ColorsUsed;
- if (cols == 0)
- cols = 1 << BitsPerPixel;
-
- int rowsize = (int)Width / 8;
- if ((rowsize%4)>0)
- {
- rowsize += 4 - (rowsize%4);
- }
-
- ByteBuffer buf = ByteBuffer.allocate((int) (40 + (cols*4) + (Width*(Height/2)*BitsPerPixel)/8 + (rowsize*(Height/2))));
- buf.order(ByteOrder.LITTLE_ENDIAN);
- buf.position(0);
-
- buf.putInt((int)Size);
- buf.putInt((int)Width);
- buf.putInt((int)Height);
- buf.putShort((short)Planes);
- buf.putShort((short)BitsPerPixel);
- buf.putInt((int)Compression);
- buf.putInt((int)SizeOfBitmap);
- buf.putInt((int)HorzResolution);
- buf.putInt((int)VertResolution);
- buf.putInt((int)ColorsUsed);
- buf.putInt((int)ColorsImportant);
-
- // System.out.println("GET DATA :: Palette.size= "+Palette.length + " // position=" + buf.position());
- for (int i=0; i<Palette.length; i++)
- {
- PaletteElement el = Palette[i];
- buf.put((byte)el.Blue);
- buf.put((byte)el.Green);
- buf.put((byte)el.Red);
- buf.put((byte)el.Reserved);
- }
-
- switch (BitsPerPixel)
- {
- case 4:
- {
- for (int i=0; i<BitmapXOR.length; i+=2)
- {
- int v1 = BitmapXOR[i];
- int v2 = BitmapXOR[i+1];
- buf.put((byte)( (v1<<4) | v2 ));
- }
- }
- break;
-
- case 8:
- {
- // System.out.println("GET DATA :: XORBitmap.size= "+BitmapXOR.length + " // position=" + buf.position());
- for (int i=0; i<BitmapXOR.length; i++)
- {
- buf.put((byte)BitmapXOR[i]);
- }
- }
- break;
-
- default:
- throw new RuntimeException("BitRes " + BitsPerPixel + " not supported!");
- }
-
- // System.out.println("GET DATA :: AndBitmap.size= "+BitmapAND.length + " // position=" + buf.position());
- for (int i=0; i<BitmapAND.length; i++)
- {
- buf.put((byte)BitmapAND[i]);
- }
-
- // System.out.println("GET DATA END AT " + buf.position());
- buf.position(0);
- return buf;
- }
-
- public String toString()
- {
- StringBuffer out = new StringBuffer();
-
- out.append("Size: " + Size);
- out.append("\nWidth: " + Width);
- out.append("\nHeight: " + Height);
- out.append("\nPlanes: " + Planes);
- out.append("\nBitsPerPixel: " + BitsPerPixel);
- out.append("\nCompression: " + Compression);
- out.append("\nSizeOfBitmap: " + SizeOfBitmap);
- out.append("\nHorzResolution: " + HorzResolution);
- out.append("\nVertResolution: " + VertResolution);
- out.append("\nColorsUsed: " + ColorsUsed);
- out.append("\nColorsImportant: " + ColorsImportant);
-
- // for (int i = 0; i<Palette.length; i++)
- // {
- // out.append("\n");
- // out.append(Palette[i].toString());
- // }
- out.append("\nBitmapXOR["+ BitmapXOR.length+ "]={");
- for (int i=0; i<BitmapXOR.length; i++)
- {
- out.append((byte)BitmapXOR[i]);
- }
- out.append("}\nBitmapAnd["+ BitmapAND.length +"]={");
- for (int i=0; i<BitmapAND.length; i++)
- {
- out.append((byte)BitmapAND[i]);
- }
-
- return out.toString();
- }
-
- public static void main(String[]args) throws Exception
- {
- net.charabia.jsmoothgen.pe.PEFile.main(args);
- }
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/res/ResIcon32.java b/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/res/ResIcon32.java
deleted file mode 100644
index 0ecca5a..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/jsmoothgen/pe/res/ResIcon32.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package net.charabia.jsmoothgen.pe.res;
-
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * 32 bits res icon with alpha channel
- */
-public class ResIcon32 extends ResIcon {
- BufferedImage image;
-
- /**
- * Creates a new instance based on the data of the Image argument.
- *
- * @param img image
- * @throws Exception on error
- */
- public ResIcon32(Image img) throws Exception {
- int width = img.getWidth(null);
- int height = img.getHeight(null);
-
- image = (BufferedImage) img;
-
- this.BitsPerPixel = 32;
-
- // header size
- this.Size = 40;
- this.Width = width;
- this.Height = height * 2;
- this.Planes = 1;
- this.Compression = 0;
-
- this.SizeOfBitmap = 0;
- this.HorzResolution = 0;
- this.VertResolution = 0;
-
- this.ColorsUsed = 0;
- this.ColorsImportant = 0;
- }
-
- /**
- * Creates and returns a ByteBuffer containing an image under
- * the .ico format expected by Windows.
- *
- * @return a ByteBuffer with the .ico data
- */
- public ByteBuffer getData() {
- // transparency mask rows must be double bytes aligned
- int rowsize = (int) Width / 8;
- int padding = 0;
- if ((rowsize % 4) > 0) {
- padding = (int) ((4 - Width / 8 % 4) * 8);
- rowsize += 4 - (rowsize % 4);
- }
- // transparency line padding size
- // create transparency mask buffer
- int transparencyBytesSize = (int) (rowsize * (Height / 2));
- int[] transparencyMask = new int[transparencyBytesSize];
-
- // allocate header + pixel count * bytes / pixel + transparency mask size
- ByteBuffer buf = ByteBuffer.allocate((int) (40 + (Width * ((Height) / 2) * BitsPerPixel/8) + transparencyBytesSize));
-
- buf.order(ByteOrder.LITTLE_ENDIAN);
- buf.position(0);
-
- // write header
- buf.putInt((int) Size);
- buf.putInt((int) Width);
- buf.putInt((int) Height);
- buf.putShort((short) Planes);
- buf.putShort((short) BitsPerPixel);
- buf.putInt((int) Compression);
- buf.putInt((int) SizeOfBitmap);
- buf.putInt((int) HorzResolution);
- buf.putInt((int) VertResolution);
- buf.putInt((int) ColorsUsed);
- buf.putInt((int) ColorsImportant);
-
- int pixelCount = 0;
- for (int y = (int) ((Height / 2) - 1); y >= 0; y--) {
- for (int x = 0; x < Width; x++) {
- int pix = image.getRGB(x, y);
- //System.out.println(x+" "+y+":"+Integer.toHexString((pix >> 24) & 0xff));
- boolean isTransparent = ((pix >> 24) & 0xff) == 0;
- if (isTransparent) {
- int index = pixelCount / 8;
- byte bitindex = (byte) (pixelCount % 8);
- transparencyMask[index] |= 0x80 >> bitindex;
- }
- buf.putInt(pix);
- pixelCount++;
- }
- // skip to next transparency line
- pixelCount += padding;
- }
-
- // transparency mask
- for (int x = 0; x < transparencyBytesSize; x++) {
- buf.put((byte) (transparencyMask[x] & 0xff));
- }
-
- buf.position(0);
- return buf;
- }
-
- public String toString() {
- StringBuffer out = new StringBuffer();
-
- out.append("Size: ").append(Size);
- out.append("\nWidth: ").append(Width);
- out.append("\nHeight: ").append(Height);
- out.append("\nPlanes: ").append(Planes);
- out.append("\nBitsPerPixel: ").append(BitsPerPixel);
- out.append("\nCompression: ").append(Compression);
- out.append("\nSizeOfBitmap: ").append(SizeOfBitmap);
- out.append("\nHorzResolution: ").append(HorzResolution);
- out.append("\nVertResolution: ").append(VertResolution);
- out.append("\nColorsUsed: ").append(ColorsUsed);
- out.append("\nColorsImportant: ").append(ColorsImportant);
-
- return out.toString();
- }
-
-}
diff --git a/jsmooth-0.9.9-7-patch/src/net/charabia/util/codec/IcoCodec.java b/jsmooth-0.9.9-7-patch/src/net/charabia/util/codec/IcoCodec.java
deleted file mode 100644
index 7e88b27..0000000
--- a/jsmooth-0.9.9-7-patch/src/net/charabia/util/codec/IcoCodec.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- JSmooth: a VM wrapper toolkit for Windows
- Copyright (C) 2003 Rodrigo Reyes <reyes at charabia.net>
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- */
-
-package net.charabia.util.codec;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-import javax.imageio.ImageIO;
-
-import net.charabia.util.io.BinaryInputStream;
-
-/**
- *
- * @author Rodrigo Reyes
- * @author Riccardo Gerosa
- */
-public class IcoCodec
-{
-
- static private byte[] PNG_SIGNATURE = new byte[] { -119, 80, 78, 71, 13, 10, 26, 10 };
-
- static public class IconDir
- {
- int idType;
- int idCount;
-
- public IconDir(BinaryInputStream in) throws IOException
- {
- in.readUShortLE();
- idType = in.readUShortLE();
- idCount = in.readUShortLE();
- }
-
- public String toString()
- {
- return "{ idType=" + idType + ", " + idCount + " }";
- }
- }
-
- static public class IconEntry
- {
- short bWidth;
- short bHeight;
- short bColorCount;
- short bReserved;
- int wPlanes;
- int wBitCount;
- long dwBytesInRes;
- long dwImageOffset;
-
- public IconEntry(BinaryInputStream in) throws IOException
- {
- bWidth = in.readUByte();
- if (bWidth == 0) { bWidth = 256; }
- bHeight = in.readUByte();
- if (bHeight == 0) { bHeight = 256; }
- bColorCount = in.readUByte();
- bReserved = in.readUByte();
- wPlanes = in.readUShortLE();
- wBitCount = in.readUShortLE();
- dwBytesInRes = in.readUIntLE();
- dwImageOffset = in.readUIntLE();
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("{ bWidth="+bWidth+"\n");
- buffer.append(" bHeight="+bHeight+"\n");
- buffer.append(" bColorCount="+bColorCount+(bColorCount == 0 ? "(not paletted)":"")+"\n");
- buffer.append(" wPlanes="+wPlanes+"\n");
- buffer.append(" wBitCount="+wBitCount+"\n");
- buffer.append(" dwBytesInRes="+dwBytesInRes+"\n");
- buffer.append(" dwImageOffset="+dwImageOffset+"\n");
- buffer.append("}");
-
- return buffer.toString();
- }
-
- }
-
- static public class IconHeader
- {
- public long Size; /* Size of this header in bytes DWORD 0*/
- public long Width; /* Image width in pixels LONG 4*/
- public long Height; /* Image height in pixels LONG 8*/
- public int Planes; /* Number of color planes WORD 12 */
- public int BitsPerPixel; /* Number of bits per pixel WORD 14 */
- /* Fields added for Windows 3.x follow this line */
- public long Compression; /* Compression methods used DWORD 16 */
- public long SizeOfBitmap; /* Size of bitmap in bytes DWORD 20 */
- public long HorzResolution; /* Horizontal resolution in pixels per meter LONG 24 */
- public long VertResolution; /* Vertical resolution in pixels per meter LONG 28*/
- public long ColorsUsed; /* Number of colors in the image DWORD 32 */
- public long ColorsImportant; /* Minimum number of important colors DWORD 36 */
-
- public IconHeader(BinaryInputStream in) throws IOException
- {
- Size = in.readUIntLE();
- Width = in.readUIntLE();
- Height = in.readUIntLE();
- Planes = in.readUShortLE();
- BitsPerPixel = in.readUShortLE();
- Compression = in.readUIntLE();
- SizeOfBitmap = in.readUIntLE();
- HorzResolution = in.readUIntLE();
- VertResolution = in.readUIntLE();
- ColorsUsed = in.readUIntLE();
- ColorsImportant = in.readUIntLE();
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Size="); buffer.append(Size);
- buffer.append("\nWidth="); buffer.append(Width);
- buffer.append("\nHeight="); buffer.append(Height);
- buffer.append("\nPlanes="); buffer.append(Planes);
- buffer.append("\nBitsPerPixel="); buffer.append(BitsPerPixel);
- buffer.append("\nCompression="); buffer.append(Compression);
- buffer.append("\nSizeOfBitmap="); buffer.append(SizeOfBitmap);
- buffer.append("\nHorzResolution="); buffer.append(HorzResolution);
- buffer.append("\nVertResolution="); buffer.append(VertResolution);
- buffer.append("\nColorsUsed="); buffer.append(ColorsUsed);
- buffer.append("\nColorsImportant="); buffer.append(ColorsImportant);
-
- return buffer.toString();
- }
-
- }
-
- public static BufferedImage checkImageSize(BufferedImage img, int width, int height) {
- int w = img.getWidth(null);
- int h = img.getHeight(null);
- if ((w == width) && (h == height))
- return img;
- return null;
- }
-
- static boolean isSquareSize(BufferedImage bufferedImage, int size) {
- return bufferedImage.getWidth() == bufferedImage.getHeight() && bufferedImage.getWidth() == size;
- }
-
- static int getColorDepth(BufferedImage bufferedImage) {
- return bufferedImage.getColorModel().getPixelSize();
- }
-
- static public BufferedImage getPreferredImage(File f) throws IOException {
- BufferedImage selected = null;
- BufferedImage[] orgimages = loadImages(f);
- if (orgimages != null) {
- // select first image
- selected = orgimages[0];
- for (int i = 1; (i < orgimages.length); i++) {
- // We prefer 32x32 pictures, then 64x64, then 16x16...
- if (isSquareSize(orgimages[i], 32)) {
- if (!isSquareSize(selected, 32) || getColorDepth(orgimages[i]) > getColorDepth(selected)) {
- selected = orgimages[i];
- }
- } else if (isSquareSize(orgimages[i], 64)) {
- if (!isSquareSize(selected, 32) ||
- (isSquareSize(selected, 64) && getColorDepth(orgimages[i]) > getColorDepth(selected))) {
- selected = orgimages[i];
- }
-
- } else if (isSquareSize(orgimages[i], 16)) {
- if ((!isSquareSize(selected, 32) && !isSquareSize(selected, 64)) ||
- (isSquareSize(selected, 16) && getColorDepth(orgimages[i]) > getColorDepth(selected))) {
- selected = orgimages[i];
- }
- }
- }
-
- if (selected == null) {
- //
- // If there is no 32x32, 64x64, nor 16x16, then we scale the
- // biggest image to be 32x32... This should happen mainly when
- // loading an image from a png of gif file, and in most case
- // there is only one image on the array.
- //
- int maxsize = 0;
- for (int i = 0; (i < orgimages.length) && (selected == null); i++) {
- int size = orgimages[i].getWidth(null) * orgimages[i].getHeight(null);
- if (size > maxsize) {
- maxsize = size;
- selected = orgimages[i];
- }
- }
- }
- }
- return selected;
- }
-
- static public BufferedImage[] loadImages(File f) throws IOException
- {
- InputStream istream = new FileInputStream(f);
- BufferedInputStream buffin = new BufferedInputStream(istream);
- BinaryInputStream in = new BinaryInputStream(buffin);
-
- try {
- in.mark(1024 * 1024);
-
- IconDir dir = new IconDir(in);
- // System.out.println("DIR = " + dir);
-
- IconEntry[] entries = new IconEntry[dir.idCount];
- BufferedImage[] images = new BufferedImage[dir.idCount];
-
- for (int i=0; i<dir.idCount; i++)
- {
- entries[i] = new IconEntry(in);
- // System.out.println("ENTRY " + i + " = " + entries[i]);
- }
-
- IconEntry entry = entries[0];
- // System.out.println("ENTRYx = " + entry);
-
- for (int i=0; i<dir.idCount; i++)
- {
- in.reset();
-
- boolean pngIcon = false;
- if (entries[i].dwBytesInRes > PNG_SIGNATURE.length) {
- // Check if this is a PNG icon (introduced in Windows Vista)
- in.mark(1024 * 1024);
- in.skip(entries[i].dwImageOffset);
- byte[] signatureBuffer = new byte[PNG_SIGNATURE.length];
- in.read(signatureBuffer, 0, PNG_SIGNATURE.length);
- pngIcon = Arrays.equals(PNG_SIGNATURE, signatureBuffer);
- in.reset();
- }
- // System.out.println("PNG Icon = " + pngIcon);
-
- in.skip(entries[i].dwImageOffset);
-
- BufferedImage image;
-
- if (pngIcon) {
- // This is a PNG icon (introduced in Windows Vista)
- byte[] imageData = new byte[(int) entries[i].dwBytesInRes];
- in.read(imageData, 0, (int) entries[i].dwBytesInRes);
- ByteArrayInputStream imageDataBuffer = new ByteArrayInputStream(imageData);
- image = ImageIO.read(imageDataBuffer);
- } else {
- // This is a standard icon (not PNG)
- IconHeader header = new IconHeader(in);
- // System.out.println("Header: " + header);
-
- long toskip = header.Size - 40;
- if (toskip>0)
- in.skip((int)toskip);
-
- // System.out.println("skipped data");
-
-
- switch(header.BitsPerPixel)
- {
- case 4:
- case 8:
- image = new BufferedImage((int)header.Width, (int)header.Height/2,
- BufferedImage.TYPE_BYTE_INDEXED);
- loadPalettedImage(in, entries[i], header, image);
- break;
- case 24:
- case 32:
- image = new BufferedImage((int)header.Width, (int)header.Height/2,
- BufferedImage.TYPE_INT_ARGB);
- // This is a true-color icon (introduced in Windows XP)
- loadTrueColorImage(in, entries[i], header, image);
- break;
- default:
- throw new Exception("Unsupported ICO color depth: " + header.BitsPerPixel);
- }
- }
-
- images[i] = image;
- }
-
- return images;
-
- } catch (Exception exc)
- {
- exc.printStackTrace();
- }
-
- return null;
- }
-
- static private void loadPalettedImage(BinaryInputStream in, IconEntry entry, IconHeader header, BufferedImage image) throws Exception
- {
- // System.out.println("Loading image...");
-
- // System.out.println("Loading palette...");
-
- //
- // First, load the palette
- //
- int cols = (int)header.ColorsUsed;
- if (cols == 0)
- {
- if (entry.bColorCount != 0)
- cols = entry.bColorCount;
- else
- cols = 1 << header.BitsPerPixel;
- }
-
- int[] redp = new int[cols];
- int[] greenp = new int[cols];
- int[] bluep = new int[cols];
-
- for (int i=0; i<cols; i++)
- {
- bluep[i] = in.readUByte();
- greenp[i] = in.readUByte();
- redp[i] = in.readUByte();
- in.readUByte();
- }
-
- // System.out.println("Palette read!");
-
- //
- // Set the image
-
- //int xorbytes = (((int)header.Height/2) * (int)header.Width);
- int readbytes = 0;
-
- for (int y=(int)(header.Height/2)-1; y>=0; y--)
- {
- for (int x=0; x<header.Width; x++)
- {
- switch(header.BitsPerPixel)
- {
- case 4:
- {
- int pix = in.readUByte();
- readbytes++;
-
- int col1 = (pix>>4) & 0x0F;
- int col2 = pix & 0x0F;
- image.setRGB(x, y, (0xFF<<24) | (redp[col1]<<16) | (greenp[col1]<<8) | bluep[col1]);
- image.setRGB(++x, y, (0xFF<<24) | (redp[col2]<<16) | (greenp[col2]<<8) | bluep[col2]);
- }
- break;
- case 8:
- {
- int col1 = in.readUByte();
- readbytes++;
-
- image.setRGB(x, y, (0xFF<<24) | (redp[col1]<<16) | (greenp[col1]<<8) | bluep[col1]);
- }
- break;
- }
- }
- }
- // System.out.println("XOR data read (" + readbytes + " bytes)");
-
- int height = (int)(header.Height/2);
-
- int rowsize = (int)header.Width / 8;
- if ((rowsize%4)>0)
- {
- rowsize += 4 - (rowsize%4);
- }
-
- // System.out.println("rowsize = " + rowsize);
- int[] andbytes = new int[rowsize * height ];
-
- for (int i=0; i<andbytes.length; i++)
- andbytes[i] = in.readUByte();
-
-
- for (int y=height-1; y>=0; y--)
- {
- for (int x=0; x<header.Width; x++)
- {
- int offset = ((height - (y+1))*rowsize) + (x/8);
- if ( (andbytes[offset] & (1<<(7-x%8))) != 0)
- {
- image.setRGB(x, y, 0);
- }
- }
- }
-
- // for (int i=0; i<andbytes; i++)
- // {
- // int pix = in.readUByte();
- // readbytes++;
-
- // int xb = (i*8) % (int)header.Width;
- // int yb = ((int)header.Height/2) - (((i*8) / (int)header.Width)+1);
-
- // for (int offset=7; offset>=0; offset--)
- // {
- // //
- // // Modify the transparency only if necessary
- // //
- // System.out.println("SET AND (" + xb + "," + yb + ")-" + (7-offset));
-
- // if (((1<<offset) & pix)!=0)
- // {
- // int argb = image.getRGB(xb+(7-offset), yb);
- // image.setRGB(xb+(7-offset), yb, argb & 0xFFFFFF);
- // }
- // }
- // }
-
- // System.out.println("AND data read (" + readbytes + " bytes total)");
- }
-
- static private void loadTrueColorImage(BinaryInputStream in, IconEntry entry, IconHeader header, BufferedImage image) throws Exception
- {
- // System.out.println("Loading image...");
-
- //
- // Set the image
-
- //int xorbytes = (((int)header.Height/2) * (int)header.Width);
- int readbytes = 0;
-
- for (int y=(int)(header.Height/2)-1; y>=0; y--)
- {
- for (int x=0; x<header.Width; x++)
- {
- switch(header.BitsPerPixel)
- {
- case 32:
- {
- int b = in.readUByte();
- int g = in.readUByte();
- int r = in.readUByte();
- int a = in.readUByte();
- readbytes++;
-
- image.setRGB(x, y, (a<<24) | (r<<16) | (g<<8) | b);
- }
- break;
- case 24:
- {
- int b = in.readUByte();
- int g = in.readUByte();
- int r = in.readUByte();
- readbytes++;
-
- image.setRGB(x, y, (0xFF<<24) | (r<<16) | (g<<8) | b);
- }
- break;
- }
- }
- }
- // System.out.println("XOR data read (" + readbytes + " bytes)");
-
- if (header.BitsPerPixel < 32) {
- int height = (int)(header.Height/2);
-
- int rowsize = (int)header.Width / 8;
- if ((rowsize%4)>0)
- {
- rowsize += 4 - (rowsize%4);
- }
-
- // System.out.println("rowsize = " + rowsize);
- int[] andbytes = new int[rowsize * height ];
-
- for (int i=0; i<andbytes.length; i++)
- andbytes[i] = in.readUByte();
-
-
- for (int y=height-1; y>=0; y--)
- {
- for (int x=0; x<header.Width; x++)
- {
- int offset = ((height - (y+1))*rowsize) + (x/8);
- if ( (andbytes[offset] & (1<<(7-x%8))) != 0)
- {
- image.setRGB(x, y, 0);
- }
- }
- }
- }
-
- // System.out.println("AND data read (" + readbytes + " bytes total)");
- }
-
- static public void main(String[]args) throws Exception
- {
- File f = new File(args[0]);
- Image img = IcoCodec.loadImages(f)[0];
- // System.out.println("img = " + img);
-
- javax.swing.JFrame jf = new javax.swing.JFrame("Test");
- javax.swing.JButton button = new javax.swing.JButton(new javax.swing.ImageIcon(img));
- jf.getContentPane().add(button);
- jf.pack();
- jf.setVisible(true);
- }
-
-}
diff --git a/pom.xml b/pom.xml
index e4514b8..c1afd58 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<groupId>davmail</groupId>
<artifactId>davmail</artifactId>
<packaging>jar</packaging>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<name>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway</name>
<organization>
<name>Mickaël Guessant</name>
@@ -173,7 +173,7 @@
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-webdav</artifactId>
- <version>1.4</version>
+ <version>2.4.3</version>
<exclusions>
<exclusion>
<groupId>org.apache.jackrabbit</groupId>
@@ -244,7 +244,7 @@
<dependency>
<groupId>net.sourceforge.htmlcleaner</groupId>
<artifactId>htmlcleaner</artifactId>
- <version>2.1</version>
+ <version>2.2</version>
</dependency>
<!-- included in Java 1.6, needed with Java 1.5 -->
<dependency>
diff --git a/releasenotes.txt b/releasenotes.txt
index d1b5bdf..f436bdb 100644
--- a/releasenotes.txt
+++ b/releasenotes.txt
@@ -1,3 +1,81 @@
+** DavMail 4.2.1 released **
+Improved Kerberos support and a few bug fixes reported on tracker.
+
+Kerberos:
+- Add enable Kerberos checkbox to DavMail GUI
+- Kerberos read KRB5CCNAME environment variable to set ticket cache path
+- Kerberos implement graphical callback on missing token
+- Kerberos: Renew almost expired tickets and detect expired TGT in cache => try to relogin
+- Kerberos: Handle client context timeout, try to recreate context
+- Improve KerberosHelper implementation, prepare credential delegation support
+
+Enhancements:
+- Try to fix 3606267: New debian dependency with wrong package name
+- Fix 3602588, allow oracle-java7-jre
+- Fix regression: disable console appender in gui mode
+- Use NewIbmX509 on IBM JDK instead of NewSunX509 SSL algorithm implementation
+- Fix 3602351, detect missing item
+
+EWS:
+- EWS: do not catch socket exception in executeMethod
+- EWS: workaround for Nokia N9 Caldav implementation bug
+
+DAV:
+- DAV: throw error on broken connection
+
+SMTP:
+- SMTP: do not allow send as another user on Exchange 2003
+
+IMAP:
+- IMAP: exclude Mutt header request from size optimization
+- IMAP: change kerberos login error message
+- IMAP send error on authentication failed
+
+Documentation:
+- Doc: Additional Kerberos documentation
+- Initial Kerberos documentation
+
+Caldav:
+- Caldav: do not send 401 on authentication error in Kerberos mode
+
+
+** DavMail 4.2.0 released **
+Contains some enhancements on iOS 6 support, Debian package encoding issue fix
+and partial Kerberos support (workstation mode) to provide transparent Exchange
+authentication.
+
+Kerberos:
+- Kerberos: implement server side security context and token handling
+- Kerberos: server side login module
+- Improve Kerberos logging and implement command line callback
+- Do not set preemptive authentication in Kerberos mode
+- Enable Kerberos authentication scheme with davmail.enableKerberos setting
+- Kerberos authentication implementation: SpNegoScheme to implement Negotiate authentication scheme, KerberosHelper to handle ticket access and KerberosLoginConfiguration to replace JAAS configuration file
+
+Enhancements:
+- Fix accept certificate message
+- Make davmail.sh executable in platform independent package
+- Update desktop entry comment
+- Update RPM spec file from build.opensuse.org (marcindulak)
+- Add libswt-cairo-gtk-3-jni to debian package dependencies
+- Clear cookies created by authentication test
+- Upgrade jackrabbit-webdav and htmlcleaner in davmailconsole wrapper
+- Upgrade jackrabbit-webdav to 2.4.3
+- Upgrade htmlcleaner to 2.2
+- Exclude Jsmooth, nsi, OSX and contribs (with binary) from source only package
+- Prepare source only package
+
+Bugfix:
+- Check file encoding in build file
+- Refactor StringUtil and encode ~ in urlcompname
+
+IMAP:
+- IMAP: Implement custom IMAP flags to keywords mapping in settings
+
+Caldav:
+- Caldav: add iOS6 user agent
+
+
** DavMail 4.1.0 released **
Bugfix release with improved IMAP support, including IMAP flags mapping to Outlook categories,
enhanced IMAP noop/idle support, fixed emClient Caldav support and many Caldav and EWS fixes.
@@ -29,7 +107,7 @@ IMAP:
EWS:
- EWS: Get primary smtp email address with ResolveNames in direct EWS mode
-Enhancements
+Enhancements:
- Allow Java 7 to build DavMail
- Prepare message keywords/categories support
diff --git a/src/contribs/davmailpd/davmailpd b/src/contribs/davmailpd/davmailpd
deleted file mode 100644
index 98cf0b0..0000000
--- a/src/contribs/davmailpd/davmailpd
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/bash
-#
-# davmailpd: Davmail private daemon
-#
-# copyright Geert Stappers <stappers at stappers.nl> 2010
-# distributed under the terms of the GNU General Public License
-#
-usage() {
- cat << USAGE
-
- davmailpd {status|start|stop|restart}
-
- restart: stops and starts davmail
- status: tells if davmail is running for the executing user
- start: starts davmail
- stop: sends SIGHUP to davmail proces of the executing user
-
-USAGE
-}
-
-#### Example output of commands used in find_process_id()
-## # Executing User
-## $ who am i
-## stappers pts/4 2010-09-06 07:22 (:0.0)
-## # Possible Processes
-## $ ps -ef | grep -e "^stappers.*gv.*vol.*tor$"
-## stappers 23201 1 0 Sep06 ? 00:00:00 /usr/lib/gvfs-gdu-volume-monitor
-## stappers 23203 1 0 Sep06 ? 00:00:00 /usr/lib/gvfs-gphoto2-volume-monitor
-
-find_process_id() {
- EU=$( who ami | awk '{ print $1 }' )
- PP=$(ps -ef | grep -e "^${EU}.*java.*\.jar.*\.jar.*davmail\.DavGateway" )
- if [ -z "${PP}" ] ; then
- echo -n 'None'
- else
- echo ${PP} | awk '{ printf(" %s",$2) }'
- fi
-}
-
-status_cmd() {
- if [ $(find_process_id) == 'None' ] ; then
- echo 'NO Davmail running for you'
- else
- echo 'OKay, you have running Davmail process(es)'
- fi
-}
-
-send_signal_hangup() {
- if [ $(find_process_id) != 'None' ] ; then
- kill -n SIGHUP $(find_process_id)
- fi
-}
-
-case "$1" in
- status)
- status_cmd
- exit 0
- ;;
- stop)
- send_signal_hangup
- exit 0
- ;;
- start)
- shift # remove first parameter ( and leave others untouched )
- # continue, no exit here
- ;;
- restart)
- shift # remove first parameter ( and leave others untouched )
- send_signal_hangup
- # continue, no exit here
- ;;
- processes|proc*|debug|d*)
- EU=$( who ami | awk '{ print $1 }' )
- ps -ef | grep -e "^${EU}.*java.*\.jar.*\.jar.*davmail\.DavGateway"
- find_process_id ; echo
- exit 0
- ;;
- *)
- usage
- exit 0
- ;;
-esac
-# the actual start
-export LD_LIBRARY_PATH=/usr/lib/jni
-for i in /usr/share/davmail/lib/*; do export CLASSPATH=$CLASSPATH:$i; done
-java -Xmx512M -cp /usr/share/davmail/davmail.jar:$CLASSPATH davmail.DavGateway "$@" > /dev/null 2>&1 &
diff --git a/src/contribs/init/davmail-init b/src/contribs/init/davmail-init
deleted file mode 100644
index 9f43b6c..0000000
--- a/src/contribs/init/davmail-init
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/bin/bash
-#
-# chkconfig: 345 99 05
-# # description: Java deamon script for davmail (http://davmail.sourceforge.net/) write by qk4l at tem4uk.ru 2011
-#
-# Derived from -
-# Home page: http://www.source-code.biz
-# License: GNU/LGPL (http://www.gnu.org/licenses/lgpl.html)
-# Copyright 2006 Christian d'Heureuse, Inventec Informatik AG, Switzerland.
-#
-# History:
-# 2010-09-21 Josh Davis: Changed 'sudo' to 'su', fix some typos, removed unused variables
-# 2009-03-04 Josh Davis: Ubuntu/Redhat version.
-# 2006-06-27 Christian d'Heureuse: Script created.
-# 2006-07-02 chdh: Minor improvements.
-# 2006-07-10 chdh: Changes for SUSE 10.0.
-
-
-# Set this to your Java installation
-
-serviceNameLo="davmail" # service name with the first letter in lowercase
-serviceName="Davmail" # service name
-serviceUser="davmail" # OS user name for the service
-serviceGroup="root" # OS group name for the service
-applDir="/usr/share/$serviceNameLo/lib" # home directory of the service application
-serviceUserHome="/etc/$serviceNameLo" # home directory of the service user
-serviceLogFile="/var/log/$serviceNameLo.log" # log file for StdOut/StdErr
-maxShutdownTime=15 # maximum number of seconds to wait for the daemon to terminate normally
-pidFile="/var/run/$serviceNameLo.pid" # name of PID file (PID = process ID number)
-javaCommand="java" # name of the Java launcher without the path
-javaExe="/usr/bin/$javaCommand -Xmx512M" # file name of the Java application launcher executable
-javaCommandLineKeyword="davmail.jar" # a keyword that occurs on the commandline, used to detect an already running service process and to distinguish it from others
-DAEMON_ARGS="/etc/davmail/davmail.properties"
-
-# Makes the file $1 writable by the group $serviceGroup.
-function makeFileWritable {
- local filename="$1"
- touch $filename || return 1
- chown $serviceUser:$serviceGroup $filename || return 1
- #chgrp $serviceGroup $filename || return 1
- chmod g+w $filename || return 1
- return 0; }
-
-# Returns 0 if the process with PID $1 is running.
-function checkProcessIsRunning {
- local pid="$1"
- if [ -z "$pid" -o "$pid" == " " ]; then return 1; fi
- if [ ! -e /proc/$pid ]; then return 1; fi
- return 0; }
-
-# Returns 0 if the process with PID $1 is our Java service process.
-function checkProcessIsOurService {
- local pid="$1"
- if [ "$(ps -p $pid --no-headers -o comm)" != "$javaCommand" ]; then return 1; fi
- grep -q --binary -F "$javaCommandLineKeyword" /proc/$pid/cmdline
- if [ $? -ne 0 ]; then return 1; fi
- return 0; }
-
-# Returns 0 when the service is running and sets the variable $pid to the PID.
-function getServicePID {
- if [ ! -f $pidFile ]; then return 1; fi
- pid="$(<$pidFile)"
- checkProcessIsRunning $pid || return 1
- checkProcessIsOurService $pid || return 1
- return 0; }
-
-function startServiceProcess {
- cd $applDir || return 1
- rm -f $pidFile
- makeFileWritable $pidFile || return 1
- makeFileWritable $serviceLogFile || return 1
- for i in $applDir/*; do export CLASSPATH=$CLASSPATH:$i; done
- cmd="nohup $javaExe -cp /usr/share/davmail/davmail.jar:$CLASSPATH davmail.DavGateway $DAEMON_ARGS >>$serviceLogFile 2>&1 & echo \$! >$pidFile"
- #echo $cmd
- su -m $serviceUser -s $SHELL -c "$cmd" || return 1
- sleep 0.1
- pid="$(<$pidFile)"
- if checkProcessIsRunning $pid; then :; else
- echo -ne "\n$serviceName start failed, see logfile."
- return 1
- fi
- return 0; }
-
-function stopServiceProcess {
- kill $pid || return 1
- for ((i=0; i<maxShutdownTime*10; i++)); do
- checkProcessIsRunning $pid
- if [ $? -ne 0 ]; then
- rm -f $pidFile
- return 0
- fi
- sleep 0.1
- done
- echo -e "\n$serviceName did not terminate within $maxShutdownTime seconds, sending SIGKILL..."
- kill -s KILL $pid || return 1
- local killWaitTime=15
- for ((i=0; i<killWaitTime*10; i++)); do
- checkProcessIsRunning $pid
- if [ $? -ne 0 ]; then
- rm -f $pidFile
- return 0
- fi
- sleep 0.1
- done
- echo "Error: $serviceName could not be stopped within $maxShutdownTime+$killWaitTime seconds!"
- return 1; }
-
-function startService {
- getServicePID
- if [ $? -eq 0 ]; then echo -n "$serviceName is already running"; RETVAL=0; return 0; fi
- echo -n "Starting $serviceName "
- startServiceProcess
- if [ $? -ne 0 ]; then RETVAL=1; echo "failed"; return 1; fi
- echo "started PID=$pid"
- RETVAL=0
- return 0; }
-
-function stopService {
- getServicePID
- if [ $? -ne 0 ]; then echo -n "$serviceName is not running"; RETVAL=0; echo ""; return 0; fi
- echo -n "Stopping $serviceName "
- stopServiceProcess
- if [ $? -ne 0 ]; then RETVAL=1; echo "failed"; return 1; fi
- echo "stopped PID=$pid"
- RETVAL=0
- return 0; }
-
-function checkServiceStatus {
- echo -n "Checking for $serviceName: "
- if getServicePID; then
- echo "running PID=$pid"
- RETVAL=0
- else
- echo "stopped"
- RETVAL=3
- fi
- return 0; }
-
-function main {
- RETVAL=0
- case "$1" in
- start) # starts the Java program as a Linux service
- startService
- ;;
- stop) # stops the Java program service
- stopService
- ;;
- restart) # stops and restarts the service
- stopService && startService
- ;;
- status) # displays the service status
- checkServiceStatus
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
- exit 1
- ;;
- esac
- exit $RETVAL
-}
-
-main $1
\ No newline at end of file
diff --git a/src/contribs/rpm/SOURCES/davmail-init b/src/contribs/rpm/SOURCES/davmail-init
deleted file mode 100644
index 6bf9914..0000000
--- a/src/contribs/rpm/SOURCES/davmail-init
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/sh
-#
-# davmail: davmail exchange gateway daemon
-#
-# chkconfig: 345 98 02
-# description: DavMail gateway for Microsoft Exchange
-# processname: davmail
-# config: /etc/davmail.properties
-
-# LSB init-info
-### BEGIN INIT INFO
-# Provides: davmail
-# Required-Start: $network
-# Required-Stop: $network
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: DavMail gateway for Microsoft Exchange
-### END INIT INFO
-
-# Source function library.
-if [ -e /etc/init.d/functions ]; then
- . /etc/init.d/functions
-fi
-
-# LSB functions
-. /lib/lsb/init-functions
-
-# Check that networking is configured.
-[ "${NETWORKING}" = "no" ] && exit 0
-
-DAVMAIL_CONF=/etc/davmail.properties
-test -f $DAVMAIL_CONF || exit 4
-DAVMAIL_HOME=/var/lib/davmail
-test -d $DAVMAIL_HOME || exit 5
-
-LOGFILE=/var/log/davmail.log
-PIDFILE=/var/run/davmail.pid
-LOCKFILE=/var/lock/subsys/davmail
-
-start() {
- echo -n $"Starting DavMail gateway: "
- dostatus > /dev/null 2>&1
- if [ $RETVAL -eq 0 ]
- then
- echo -n $"DavMail gateway already running"
- log_failure_msg
- RETVAL=1
- return
- fi
- runuser - davmail -s /bin/sh -c "exec nohup $DAVMAIL_HOME/davmail $DAVMAIL_CONF >> $LOGFILE 2>&1 &"
- RETVAL=$?
- if [ $RETVAL -eq 0 ]
- then
- sleep 1
- cat $DAVMAIL_HOME/pid > $PIDFILE
- touch $LOCKFILE
- log_success_msg
- else
- log_failure_msg
- fi
- return $RETVAL
-}
-
-stop() {
- echo -n $"Shutting down DavMail gateway: "
- kill $(cat $PIDFILE 2>/dev/null) > /dev/null 2>&1
- RETVAL=$?
- sleep 1
- if [ $RETVAL -eq 0 ]
- then
- rm -f $PIDFILE $LOCKFILE
- log_success_msg
- else
- log_failure_msg
- fi
- return $RETVAL
-}
-
-restart() {
- stop
- start
-}
-
-condrestart() {
- [ -f $LOCKFILE ] && restart || :
-}
-
-dostatus() {
- kill -0 $(cat $PIDFILE 2>/dev/null) > /dev/null 2>&1
- RETVAL=$?
- if [ $RETVAL -eq 0 ]
- then
- echo "DavMail gateway (pid $(cat $PIDFILE 2>/dev/null)) is running..."
- else
- if [ -f $PIDFILE ]
- then
- echo "DavMail gateway dead but pid file exists"
- RETVAL=1
- return
- fi
- if [ -f $LOCKFILE ]
- then
- echo "DavMail gateway dead but subsys locked"
- RETVAL=2
- return
- fi
- echo "DavMail gateway is stopped"
- RETVAL=3
- fi
-}
-
-# See how we were called.
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- dostatus
- ;;
- restart|reload)
- restart
- ;;
- condrestart)
- condrestart
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
- exit 1
-esac
-
-exit $RETVAL
diff --git a/src/contribs/rpm/SOURCES/davmail-logrotate b/src/contribs/rpm/SOURCES/davmail-logrotate
deleted file mode 100644
index a88f0ae..0000000
--- a/src/contribs/rpm/SOURCES/davmail-logrotate
+++ /dev/null
@@ -1,7 +0,0 @@
-/var/log/davmail.log {
- missingok
- notifempty
- size 30k
- monthly
- create 0640 davmail davmail
-}
diff --git a/src/contribs/rpm/SOURCES/davmail-wrapper b/src/contribs/rpm/SOURCES/davmail-wrapper
deleted file mode 100644
index 96a726e..0000000
--- a/src/contribs/rpm/SOURCES/davmail-wrapper
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-LOGFILE=/var/log/davmail.log
-PIDFILE=/var/lib/davmail/pid
-
-for class in /usr/share/davmail/lib/*
-do
- export CLASSPATH=${CLASSPATH}:${class}
-done
-
-echo $$ > $PIDFILE
-exec java -cp /usr/share/davmail/davmail.jar:${CLASSPATH} \
- davmail.DavGateway "$@" >> $LOGFILE 2>&1
diff --git a/src/contribs/rpm/SOURCES/davmail.desktop b/src/contribs/rpm/SOURCES/davmail.desktop
deleted file mode 100644
index ac4916b..0000000
--- a/src/contribs/rpm/SOURCES/davmail.desktop
+++ /dev/null
@@ -1,10 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Terminal=false
-Encoding=UTF-8
-Name=DavMail
-Icon=davmail
-Exec=/usr/bin/davmail
-Comment=DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway
-Categories=Application;Office;Email;Network;Calendar;ContactManagement;
diff --git a/src/contribs/rpm/SOURCES/davmail.properties b/src/contribs/rpm/SOURCES/davmail.properties
deleted file mode 100644
index e703b91..0000000
--- a/src/contribs/rpm/SOURCES/davmail.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-# DavMail settings
-davmail.url=https\://owa.example.com/owa/
-davmail.enableEws=true
-davmail.ldapPort=1389
-davmail.caldavPort=1080
-davmail.smtpPort=1025
-davmail.popPort=1110
-davmail.imapPort=1143
-davmail.proxyPort=
-davmail.disableUpdateCheck=true
-davmail.bindAddress=127.0.0.1
-davmail.logFilePath=/var/log/davmail.log
-davmail.server=true
-davmail.server.certificate.hash=
-davmail.caldavPastDelay=90
-davmail.sentKeepDelay=90
-davmail.keepDelay=30
-davmail.allowRemote=false
-davmail.enableProxy=false
-davmail.proxyHost=
-davmail.proxyPassword=
-davmail.proxyUser=
-log4j.logger.davmail=WARN
-log4j.logger.httpclient.wire=WARN
-log4j.logger.org.apache.commons.httpclient=WARN
-log4j.rootLogger=WARN
diff --git a/src/contribs/rpm/SOURCES/davmail.sh b/src/contribs/rpm/SOURCES/davmail.sh
deleted file mode 100644
index 44b45db..0000000
--- a/src/contribs/rpm/SOURCES/davmail.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-#
-# Usage: davmail [</path/to/davmail.properties>]
-#
-
-# Create the $HOME/.davmail.properties if necessary
-if [ -r /etc/davmail.properties ]; then
- if [ ! -f ${HOME}/.davmail.properties ]; then
- grep -v ^davmail.logFilePath /etc/davmail.properties | \
- sed -e 's/^davmail.server=true/davmail.server=false/' > \
- ${HOME}/.davmail.properties
- fi
-fi
-
-# Add our libs into CLASSPATH
-for i in /usr/share/davmail/lib/*; do export CLASSPATH=${CLASSPATH}:${i}; done
-
-# Start davmail
-java -cp /usr/share/davmail/davmail.jar:${CLASSPATH} davmail.DavGateway $*
diff --git a/src/contribs/rpm/SPECS/davmail.spec b/src/contribs/rpm/SPECS/davmail.spec
deleted file mode 100644
index 2eb570e..0000000
--- a/src/contribs/rpm/SPECS/davmail.spec
+++ /dev/null
@@ -1,116 +0,0 @@
-%define davrel 3.8.5
-%define davsvn 1480
-%define davver %{davrel}-%{davsvn}
-%ifarch i686
-%define davarch x86
-%endif
-%ifarch x86_64
-%define davarch x86_64
-%endif
-
-Summary: DavMail is a POP/IMAP/SMTP/Caldav/Carddav/LDAP gateway for Microsoft Exchange
-Name: davmail
-Version: %{davrel}
-Release: 1%{?dist}
-License: GPL
-Group: Applications/Internet
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-BuildRequires: ant >= 1.7.1, ant-antlr, desktop-file-utils
-Requires(pre): chkconfig, coreutils, initscripts, shadow-utils
-Requires: logrotate, jre
-
-Source0: %{name}-src-%{davver}.tgz
-Source1: davmail.sh
-Source2: davmail-logrotate
-Source3: davmail-init
-Source4: davmail.properties
-Source5: davmail.desktop
-Source6: davmail-wrapper
-
-%description
-DavMail is a POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange gateway allowing
-users to use any mail/calendar client with an Exchange server, even from
-the internet or behind a firewall through Outlook Web Access. DavMail
-now includes an LDAP gateway to Exchange global address book and user
-personal contacts to allow recipient address completion in mail compose
-window and full calendar support with attendees free/busy display.
-
-%prep
-%setup -q -n %{name}-src-%{davver}
-
-%build
-export JAVA_HOME=/etc/alternatives/java_sdk
-ant
-
-%install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/%{_bindir}
-mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d
-mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
-mkdir -p $RPM_BUILD_ROOT/%{_datadir}/applications
-mkdir -p $RPM_BUILD_ROOT/%{_datadir}/pixmaps
-mkdir -p $RPM_BUILD_ROOT/%{_datadir}/davmail/lib
-mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/davmail
-mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log
-
-# Init scripts, icons, configurations
-install -m 0775 %{SOURCE1} $RPM_BUILD_ROOT/%{_bindir}/davmail
-install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/davmail
-install -m 0775 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/davmail
-install -m 0644 %{SOURCE4} $RPM_BUILD_ROOT/%{_sysconfdir}
-desktop-file-install --dir $RPM_BUILD_ROOT/%{_datadir}/applications/ %{SOURCE5}
-install -m 0775 %{SOURCE6} $RPM_BUILD_ROOT/%{_localstatedir}/lib/davmail/davmail
-
-# Actual DavMail files
-install -m 0644 src/java/tray32.png $RPM_BUILD_ROOT/%{_datadir}/pixmaps/davmail.png
-rm -f dist/lib/*win32*.jar
-install -m 0664 dist/lib/*-%{davarch}.jar $RPM_BUILD_ROOT/%{_datadir}/davmail/lib/
-rm -f dist/lib/*x86*.jar
-install -m 0664 dist/lib/* $RPM_BUILD_ROOT/%{_datadir}/davmail/lib/
-install -m 0664 dist/*.jar $RPM_BUILD_ROOT/%{_datadir}/davmail/
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%pre
-/usr/sbin/groupadd -r davmail > /dev/null 2>&1 || :
-/usr/sbin/useradd -r -s /sbin/nologin -d /var/lib/davmail -M \
- -g davmail davmail > /dev/null 2>&1 || :
-
-%post
-if [ ! -f /var/log/davmail.log ]
-then
- /bin/touch /var/log/davmail.log
-fi
-/bin/chown davmail:davmail /var/log/davmail.log
-/bin/chmod 0640 /var/log/davmail.log
-/sbin/chkconfig --add davmail
-#/sbin/chkconfig davmail on
-
-%preun
-if [ "$1" = "0" ]; then
- /sbin/service davmail stop > /dev/null 2>&1 || :
- /bin/rm -f /var/lib/davmail/pid > /dev/null 2>&1 || :
- /sbin/chkconfig davmail off
- /sbin/chkconfig --del davmail
-fi
-
-%postun
-if [ $1 -ge 1 ]; then
- /sbin/service davmail condrestart > /dev/null 2>&1 || :
-fi
-
-%files
-%defattr (-,root,root,-)
-%{_bindir}/*
-%{_sysconfdir}/rc.d/init.d/davmail
-%{_sysconfdir}/logrotate.d/davmail
-%{_sysconfdir}/davmail.properties
-%{_datadir}/applications/*
-%{_datadir}/pixmaps/*
-%{_datadir}/davmail/
-%attr(0775,davmail,davmail) %{_localstatedir}/lib/davmail
-
-%changelog
-* Mon Oct 18 2010 Marko Myllynen <myllynen at redhat.com>
-- Initial version
diff --git a/src/contribs/wrapper/bin/davmail b/src/contribs/wrapper/bin/davmail
deleted file mode 100644
index 59ad632..0000000
--- a/src/contribs/wrapper/bin/davmail
+++ /dev/null
@@ -1,732 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 1999, 2009 Tanuki Software, Ltd.
-# http://www.tanukisoftware.com
-# All rights reserved.
-#
-# This software is the proprietary information of Tanuki Software.
-# You shall use it only in accordance with the terms of the
-# license agreement you entered into with Tanuki Software.
-# http://wrapper.tanukisoftware.org/doc/english/licenseOverview.html
-#
-# Java Service Wrapper sh script. Suitable for starting and stopping
-# wrapped Java applications on UNIX platforms.
-#
-
-#-----------------------------------------------------------------------------
-# These settings can be modified to fit the needs of your application
-# Optimized for use with version 3.3.6 of the Wrapper.
-
-# Application
-BASEDIR="/opt/davmail/bin"
-APP_NAME="davmail"
-APP_LONG_NAME="DavMail Exchange Gateway"
-
-# Wrapper
-WRAPPER_CMD="$BASEDIR/wrapper"
-WRAPPER_CONF="$BASEDIR/../conf/wrapper.conf"
-
-# Priority at which to run the wrapper. See "man nice" for valid priorities.
-# nice is only used if a priority is specified.
-PRIORITY=
-
-# Location of the pid file.
-PIDDIR="$BASEDIR"
-
-# If uncommented, causes the Wrapper to be shutdown using an anchor file.
-# When launched with the 'start' command, it will also ignore all INT and
-# TERM signals.
-#IGNORE_SIGNALS=true
-
-# Wrapper will start the JVM asynchronously. Your application may have some
-# initialization tasks and it may be desirable to wait a few seconds
-# before returning. For example, to delay the invocation of following
-# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will
-# cause the start command to delay for the indicated period of time
-# (in seconds).
-#
-WAIT_AFTER_STARTUP=0
-
-# If set, the status, start_msg and stop_msg commands will print out detailed
-# state information on the Wrapper and Java processes.
-#DETAIL_STATUS=true
-
-# If specified, the Wrapper will be run as the specified user.
-# IMPORTANT - Make sure that the user has the required privileges to write
-# the PID file and wrapper.log files. Failure to be able to write the log
-# file will cause the Wrapper to exit without any way to write out an error
-# message.
-# NOTE - This will set the user which is used to run the Wrapper as well as
-# the JVM and is not useful in situations where a privileged resource or
-# port needs to be allocated prior to the user being changed.
-#RUN_AS_USER=
-
-# The following two lines are used by the chkconfig command. Change as is
-# appropriate for your application. They should remain commented.
-# chkconfig: 2345 20 80
-# description: @app.long.name@
-
-# Initialization block for the install_initd and remove_initd scripts used by
-# SUSE linux distributions.
-### BEGIN INIT INFO
-# Provides: @app.name@
-# Required-Start: $local_fs $network $syslog
-# Should-Start:
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: @app.long.name@
-# Description: @app.description@
-### END INIT INFO
-
-# Do not modify anything beyond this point
-#-----------------------------------------------------------------------------
-
-# Get the fully qualified path to the script
-case $0 in
- /*)
- SCRIPT="$0"
- ;;
- *)
- PWD=`pwd`
- SCRIPT="$PWD/$0"
- ;;
-esac
-
-# Resolve the true real path without any sym links.
-CHANGED=true
-while [ "X$CHANGED" != "X" ]
-do
- # Change spaces to ":" so the tokens can be parsed.
- SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
- # Get the real path to this script, resolving any symbolic links
- TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`
- REALPATH=
- for C in $TOKENS; do
- # Change any ":" in the token back to a space.
- C=`echo $C | sed -e 's;:; ;g'`
- REALPATH="$REALPATH/$C"
- # If REALPATH is a sym link, resolve it. Loop for nested links.
- while [ -h "$REALPATH" ] ; do
- LS="`ls -ld "$REALPATH"`"
- LINK="`expr "$LS" : '.*-> \(.*\)$'`"
- if expr "$LINK" : '/.*' > /dev/null; then
- # LINK is absolute.
- REALPATH="$LINK"
- else
- # LINK is relative.
- REALPATH="`dirname "$REALPATH"`""/$LINK"
- fi
- done
- done
-
- if [ "$REALPATH" = "$SCRIPT" ]
- then
- CHANGED=""
- else
- SCRIPT="$REALPATH"
- fi
-done
-
-# Change the current directory to the location of the script
-cd "`dirname "$REALPATH"`"
-REALDIR=`pwd`
-
-# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if
-# the working directory is later changed.
-FIRST_CHAR=`echo $PIDDIR | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- PIDDIR=$REALDIR/$PIDDIR
-fi
-# Same test for WRAPPER_CMD
-FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- WRAPPER_CMD=$REALDIR/$WRAPPER_CMD
-fi
-# Same test for WRAPPER_CONF
-FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- WRAPPER_CONF=$REALDIR/$WRAPPER_CONF
-fi
-
-# Process ID
-ANCHORFILE="$PIDDIR/$APP_NAME.anchor"
-STATUSFILE="$PIDDIR/$APP_NAME.status"
-JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status"
-PIDFILE="$PIDDIR/$APP_NAME.pid"
-LOCKDIR="/var/lock/subsys"
-LOCKFILE="$LOCKDIR/$APP_NAME"
-pid=""
-
-# Resolve the location of the 'ps' command
-PSEXE="/usr/ucb/ps"
- if [ ! -x "$PSEXE" ]
- then
- PSEXE="/usr/bin/ps"
- if [ ! -x "$PSEXE" ]
- then
- PSEXE="/bin/ps"
- if [ ! -x "$PSEXE" ]
- then
- echo "Unable to locate 'ps'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
- fi
- fi
-
-# Resolve the os
-DIST_OS=`uname -s | tr [:upper:] [:lower:] | tr -d [:blank:]`
-case "$DIST_OS" in
- 'sunos')
- DIST_OS="solaris"
- ;;
- 'hp-ux' | 'hp-ux64')
- # HP-UX needs the XPG4 version of ps (for -o args)
- DIST_OS="hpux"
- UNIX95=""
- export UNIX95
- ;;
- 'darwin')
- DIST_OS="macosx"
- ;;
- 'unix_sv')
- DIST_OS="unixware"
- ;;
-esac
-
-# Resolve the architecture
-if [ "$DIST_OS" = "macosx" ]
-then
- DIST_ARCH="universal"
-else
- DIST_ARCH=
- DIST_ARCH=`uname -p 2>/dev/null | tr [:upper:] [:lower:] | tr -d [:blank:]`
- if [ "X$DIST_ARCH" = "X" ]
- then
- DIST_ARCH="unknown"
- fi
- if [ "$DIST_ARCH" = "unknown" ]
- then
- DIST_ARCH=`uname -m 2>/dev/null | tr [:upper:] [:lower:] | tr -d [:blank:]`
- fi
- case "$DIST_ARCH" in
- 'amd64' | 'athlon' | 'i386' | 'i486' | 'i586' | 'i686' | 'x86_64')
- DIST_ARCH="x86"
- ;;
- 'ia32' | 'ia64' | 'ia64n' | 'ia64w')
- DIST_ARCH="ia"
- ;;
- 'ip27')
- DIST_ARCH="mips"
- ;;
- 'power' | 'powerpc' | 'power_pc' | 'ppc64')
- DIST_ARCH="ppc"
- ;;
- 'pa_risc' | 'pa-risc')
- DIST_ARCH="parisc"
- ;;
- 'sun4u' | 'sparcv9')
- DIST_ARCH="sparc"
- ;;
- '9000/800')
- DIST_ARCH="parisc"
- ;;
- esac
-fi
-
-# OSX always places Java in the same location so we can reliably set JAVA_HOME
-if [ "$DIST_OS" = "macosx" ]
-then
- if [ -z "$JAVA_HOME" ]; then
- JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
- fi
-fi
-
-outputFile() {
- if [ -f "$1" ]
- then
- echo " $1 (Found but not executable.)";
- else
- echo " $1"
- fi
-}
-
-# Decide on the wrapper binary to use.
-# If a 32-bit wrapper binary exists then it will work on 32 or 64 bit
-# platforms, if the 64-bit binary exists then the distribution most
-# likely wants to use long names. Otherwise, look for the default.
-WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
-if [ -x "$WRAPPER_TEST_CMD" ]
-then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
-else
- WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- if [ -x "$WRAPPER_TEST_CMD" ]
- then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
- else
- if [ ! -x "$WRAPPER_CMD" ]
- then
- echo "Unable to locate any of the following binaries:"
- outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
- outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- outputFile "$WRAPPER_CMD"
- exit 1
- fi
- fi
-fi
-
-# Build the nice clause
-if [ "X$PRIORITY" = "X" ]
-then
- CMDNICE=""
-else
- CMDNICE="nice -$PRIORITY"
-fi
-
-# Build the anchor file clause.
-if [ "X$IGNORE_SIGNALS" = "X" ]
-then
- ANCHORPROP=
- IGNOREPROP=
-else
- ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\"
- IGNOREPROP=wrapper.ignore_signals=TRUE
-fi
-
-# Build the status file clause.
-if [ "X$DETAIL_STATUS" = "X" ]
-then
- STATUSPROP=
-else
- STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\""
-fi
-
-# Build the lock file clause. Only create a lock file if the lock directory exists on this platform.
-LOCKPROP=
-if [ -d $LOCKDIR ]
-then
- if [ -w $LOCKDIR ]
- then
- LOCKPROP=wrapper.lockfile=\"$LOCKFILE\"
- fi
-fi
-
-checkUser() {
- # $1 touchLock flag
- # $2 command
-
- # Check the configured user. If necessary rerun this script as the desired user.
- if [ "X$RUN_AS_USER" != "X" ]
- then
- # Resolve the location of the 'id' command
- IDEXE="/usr/xpg4/bin/id"
- if [ ! -x "$IDEXE" ]
- then
- IDEXE="/usr/bin/id"
- if [ ! -x "$IDEXE" ]
- then
- echo "Unable to locate 'id'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
- fi
-
- if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
- then
- # Already running as the configured user. Avoid password prompts by not calling su.
- RUN_AS_USER=""
- fi
- fi
- if [ "X$RUN_AS_USER" != "X" ]
- then
- # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be
- # able to create the lock file. The Wrapper will be able to update this file once it
- # is created but will not be able to delete it on shutdown. If $2 is defined then
- # the lock file should be created for the current command
- if [ "X$LOCKPROP" != "X" ]
- then
- if [ "X$1" != "X" ]
- then
- # Resolve the primary group
- RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
- if [ "X$RUN_AS_GROUP" = "X" ]
- then
- RUN_AS_GROUP=$RUN_AS_USER
- fi
- touch $LOCKFILE
- chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE
- fi
- fi
-
- # Still want to change users, recurse. This means that the user will only be
- # prompted for a password once. Variables shifted by 1
- #
- # Use "runuser" if this exists. runuser should be used on RedHat in preference to su.
- #
- if test -f "/sbin/runuser"
- then
- /sbin/runuser - $RUN_AS_USER -c "\"$REALPATH\" $2"
- else
- su - $RUN_AS_USER -c "\"$REALPATH\" $2"
- fi
-
- # Now that we are the original user again, we may need to clean up the lock file.
- if [ "X$LOCKPROP" != "X" ]
- then
- getpid
- if [ "X$pid" = "X" ]
- then
- # Wrapper is not running so make sure the lock file is deleted.
- if [ -f "$LOCKFILE" ]
- then
- rm "$LOCKFILE"
- fi
- fi
- fi
-
- exit 0
- fi
-}
-
-getpid() {
- pid=""
- if [ -f "$PIDFILE" ]
- then
- if [ -r "$PIDFILE" ]
- then
- pid=`cat "$PIDFILE"`
- if [ "X$pid" != "X" ]
- then
- # It is possible that 'a' process with the pid exists but that it is not the
- # correct process. This can happen in a number of cases, but the most
- # common is during system startup after an unclean shutdown.
- # The ps statement below looks for the specific wrapper command running as
- # the pid. If it is not found then the pid file is considered to be stale.
- case "$DIST_OS" in
- 'macosx')
- pidtest=`$PSEXE -ww -p $pid -o command | grep "$WRAPPER_CMD" | tail -1`
- ;;
- 'solaris')
- pidtest=`$PSEXE -auxww $pid | grep "$WRAPPER_CMD" | tail -1`
- ;;
- 'hpux')
- pidtest=`$PSEXE -p $pid -x -o args | grep "$WRAPPER_CMD" | tail -1`
- ;;
- *)
- pidtest=`$PSEXE -p $pid -o args | grep "$WRAPPER_CMD" | tail -1`
- ;;
- esac
-
- if [ "X$pidtest" = "X" ]
- then
- # This is a stale pid file.
- rm -f "$PIDFILE"
- echo "Removed stale pid file: $PIDFILE"
- pid=""
- fi
- fi
- else
- echo "Cannot read $PIDFILE."
- exit 1
- fi
- fi
-}
-
-getstatus() {
- STATUS=
- if [ -f "$STATUSFILE" ]
- then
- if [ -r "$STATUSFILE" ]
- then
- STATUS=`cat "$STATUSFILE"`
- fi
- fi
- if [ "X$STATUS" = "X" ]
- then
- STATUS="Unknown"
- fi
-
- JAVASTATUS=
- if [ -f "$JAVASTATUSFILE" ]
- then
- if [ -r "$JAVASTATUSFILE" ]
- then
- JAVASTATUS=`cat "$JAVASTATUSFILE"`
- fi
- fi
- if [ "X$JAVASTATUS" = "X" ]
- then
- JAVASTATUS="Unknown"
- fi
-}
-
-testpid() {
- case "$DIST_OS" in
- 'solaris')
- pid=`$PSEXE $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
- ;;
- *)
- pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
- ;;
- esac
- if [ "X$pid" = "X" ]
- then
- # Process is gone so remove the pid file.
- rm -f "$PIDFILE"
- pid=""
- fi
-}
-
-console() {
- echo "Running $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- # The string passed to eval must handles spaces in paths correctly.
- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $LOCKPROP"
- eval $COMMAND_LINE
- else
- echo "$APP_LONG_NAME is already running."
- exit 1
- fi
-}
-
-start() {
- echo -n "Starting $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- # The string passed to eval must handles spaces in paths correctly.
- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $LOCKPROP"
- eval $COMMAND_LINE
- else
- echo "$APP_LONG_NAME is already running."
- exit 1
- fi
-
- # Sleep for a few seconds to allow for intialization if required
- # then test to make sure we're still running.
- #
- i=0
- while [ $i -lt $WAIT_AFTER_STARTUP ]
- do
- sleep 1
- echo -n "."
- i=`expr $i + 1`
- done
- if [ $WAIT_AFTER_STARTUP -gt 0 ]
- then
- getpid
- if [ "X$pid" = "X" ]
- then
- echo " WARNING: $APP_LONG_NAME may have failed to start."
- exit 1
- else
- echo " running ($pid)."
- fi
- else
- echo ""
- fi
-}
-
-stopit() {
- # $1 exit if down flag
-
- echo "Stopping $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME was not running."
- if [ "X$1" = "X1" ]
- then
- exit 1
- fi
- else
- if [ "X$IGNORE_SIGNALS" = "X" ]
- then
- # Running so try to stop it.
- kill $pid
- if [ $? -ne 0 ]
- then
- # An explanation for the failure should have been given
- echo "Unable to stop $APP_LONG_NAME."
- exit 1
- fi
- else
- rm -f "$ANCHORFILE"
- if [ -f "$ANCHORFILE" ]
- then
- # An explanation for the failure should have been given
- echo "Unable to stop $APP_LONG_NAME."
- exit 1
- fi
- fi
-
- # We can not predict how long it will take for the wrapper to
- # actually stop as it depends on settings in wrapper.conf.
- # Loop until it does.
- savepid=$pid
- CNT=0
- TOTCNT=0
- while [ "X$pid" != "X" ]
- do
- # Show a waiting message every 5 seconds.
- if [ "$CNT" -lt "5" ]
- then
- CNT=`expr $CNT + 1`
- else
- echo "Waiting for $APP_LONG_NAME to exit..."
- CNT=0
- fi
- TOTCNT=`expr $TOTCNT + 1`
-
- sleep 1
-
- testpid
- done
-
- pid=$savepid
- testpid
- if [ "X$pid" != "X" ]
- then
- echo "Failed to stop $APP_LONG_NAME."
- exit 1
- else
- echo "Stopped $APP_LONG_NAME."
- fi
- fi
-}
-
-status() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME is not running."
- exit 1
- else
- if [ "X$DETAIL_STATUS" = "X" ]
- then
- echo "$APP_LONG_NAME is running (PID:$pid)."
- else
- getstatus
- echo "$APP_LONG_NAME is running (PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS)"
- fi
- exit 0
- fi
-}
-
-dump() {
- echo "Dumping $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME was not running."
- else
- kill -3 $pid
-
- if [ $? -ne 0 ]
- then
- echo "Failed to dump $APP_LONG_NAME."
- exit 1
- else
- echo "Dumped $APP_LONG_NAME."
- fi
- fi
-}
-
-# Used by HP-UX init scripts.
-startmsg() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "Starting $APP_LONG_NAME... (Wrapper:Stopped)"
- else
- if [ "X$DETAIL_STATUS" = "X" ]
- then
- echo "Starting $APP_LONG_NAME... (Wrapper:Running)"
- else
- getstatus
- echo "Starting $APP_LONG_NAME... (Wrapper:$STATUS, Java:$JAVASTATUS)"
- fi
- fi
-}
-
-# Used by HP-UX init scripts.
-stopmsg() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "Stopping $APP_LONG_NAME... (Wrapper:Stopped)"
- else
- if [ "X$DETAIL_STATUS" = "X" ]
- then
- echo "Stopping $APP_LONG_NAME... (Wrapper:Running)"
- else
- getstatus
- echo "Stopping $APP_LONG_NAME... (Wrapper:$STATUS, Java:$JAVASTATUS)"
- fi
- fi
-}
-
-case "$1" in
-
- 'console')
- checkUser touchlock $1
- console
- ;;
-
- 'start')
- checkUser touchlock $1
- start
- ;;
-
- 'stop')
- checkUser "" $1
- stopit "0"
- ;;
-
- 'restart')
- checkUser touchlock $1
- stopit "0"
- start
- ;;
-
- 'condrestart')
- checkUser touchlock $1
- stopit "1"
- start
- ;;
-
- 'status')
- checkUser "" $1
- status
- ;;
-
- 'dump')
- checkUser "" $1
- dump
- ;;
-
- 'start_msg')
- checkUser "" $1
- startmsg
- ;;
-
- 'stop_msg')
- checkUser "" $1
- stopmsg
- ;;
-
- *)
- echo "Usage: $0 { console | start | stop | restart | condrestart | status | dump }"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/src/contribs/wrapper/bin/davmail_2 b/src/contribs/wrapper/bin/davmail_2
deleted file mode 100644
index b6603b2..0000000
--- a/src/contribs/wrapper/bin/davmail_2
+++ /dev/null
@@ -1,732 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 1999, 2009 Tanuki Software, Ltd.
-# http://www.tanukisoftware.com
-# All rights reserved.
-#
-# This software is the proprietary information of Tanuki Software.
-# You shall use it only in accordance with the terms of the
-# license agreement you entered into with Tanuki Software.
-# http://wrapper.tanukisoftware.org/doc/english/licenseOverview.html
-#
-# Java Service Wrapper sh script. Suitable for starting and stopping
-# wrapped Java applications on UNIX platforms.
-#
-
-#-----------------------------------------------------------------------------
-# These settings can be modified to fit the needs of your application
-# Optimized for use with version 3.3.6 of the Wrapper.
-
-# Application
-BASEDIR="/opt/davmail/bin"
-APP_NAME="davmail_2"
-APP_LONG_NAME="DavMail Exchange Gateway #2"
-
-# Wrapper
-WRAPPER_CMD="$BASEDIR/wrapper"
-WRAPPER_CONF="$BASEDIR/../conf/wrapper.conf_2"
-
-# Priority at which to run the wrapper. See "man nice" for valid priorities.
-# nice is only used if a priority is specified.
-PRIORITY=
-
-# Location of the pid file.
-PIDDIR="$BASEDIR"
-
-# If uncommented, causes the Wrapper to be shutdown using an anchor file.
-# When launched with the 'start' command, it will also ignore all INT and
-# TERM signals.
-#IGNORE_SIGNALS=true
-
-# Wrapper will start the JVM asynchronously. Your application may have some
-# initialization tasks and it may be desirable to wait a few seconds
-# before returning. For example, to delay the invocation of following
-# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will
-# cause the start command to delay for the indicated period of time
-# (in seconds).
-#
-WAIT_AFTER_STARTUP=0
-
-# If set, the status, start_msg and stop_msg commands will print out detailed
-# state information on the Wrapper and Java processes.
-#DETAIL_STATUS=true
-
-# If specified, the Wrapper will be run as the specified user.
-# IMPORTANT - Make sure that the user has the required privileges to write
-# the PID file and wrapper.log files. Failure to be able to write the log
-# file will cause the Wrapper to exit without any way to write out an error
-# message.
-# NOTE - This will set the user which is used to run the Wrapper as well as
-# the JVM and is not useful in situations where a privileged resource or
-# port needs to be allocated prior to the user being changed.
-#RUN_AS_USER=
-
-# The following two lines are used by the chkconfig command. Change as is
-# appropriate for your application. They should remain commented.
-# chkconfig: 2345 20 80
-# description: @app.long.name@
-
-# Initialization block for the install_initd and remove_initd scripts used by
-# SUSE linux distributions.
-### BEGIN INIT INFO
-# Provides: @app.name@
-# Required-Start: $local_fs $network $syslog
-# Should-Start:
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: @app.long.name@
-# Description: @app.description@
-### END INIT INFO
-
-# Do not modify anything beyond this point
-#-----------------------------------------------------------------------------
-
-# Get the fully qualified path to the script
-case $0 in
- /*)
- SCRIPT="$0"
- ;;
- *)
- PWD=`pwd`
- SCRIPT="$PWD/$0"
- ;;
-esac
-
-# Resolve the true real path without any sym links.
-CHANGED=true
-while [ "X$CHANGED" != "X" ]
-do
- # Change spaces to ":" so the tokens can be parsed.
- SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
- # Get the real path to this script, resolving any symbolic links
- TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`
- REALPATH=
- for C in $TOKENS; do
- # Change any ":" in the token back to a space.
- C=`echo $C | sed -e 's;:; ;g'`
- REALPATH="$REALPATH/$C"
- # If REALPATH is a sym link, resolve it. Loop for nested links.
- while [ -h "$REALPATH" ] ; do
- LS="`ls -ld "$REALPATH"`"
- LINK="`expr "$LS" : '.*-> \(.*\)$'`"
- if expr "$LINK" : '/.*' > /dev/null; then
- # LINK is absolute.
- REALPATH="$LINK"
- else
- # LINK is relative.
- REALPATH="`dirname "$REALPATH"`""/$LINK"
- fi
- done
- done
-
- if [ "$REALPATH" = "$SCRIPT" ]
- then
- CHANGED=""
- else
- SCRIPT="$REALPATH"
- fi
-done
-
-# Change the current directory to the location of the script
-cd "`dirname "$REALPATH"`"
-REALDIR=`pwd`
-
-# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if
-# the working directory is later changed.
-FIRST_CHAR=`echo $PIDDIR | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- PIDDIR=$REALDIR/$PIDDIR
-fi
-# Same test for WRAPPER_CMD
-FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- WRAPPER_CMD=$REALDIR/$WRAPPER_CMD
-fi
-# Same test for WRAPPER_CONF
-FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- WRAPPER_CONF=$REALDIR/$WRAPPER_CONF
-fi
-
-# Process ID
-ANCHORFILE="$PIDDIR/$APP_NAME.anchor"
-STATUSFILE="$PIDDIR/$APP_NAME.status"
-JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status"
-PIDFILE="$PIDDIR/$APP_NAME.pid"
-LOCKDIR="/var/lock/subsys"
-LOCKFILE="$LOCKDIR/$APP_NAME"
-pid=""
-
-# Resolve the location of the 'ps' command
-PSEXE="/usr/ucb/ps"
- if [ ! -x "$PSEXE" ]
- then
- PSEXE="/usr/bin/ps"
- if [ ! -x "$PSEXE" ]
- then
- PSEXE="/bin/ps"
- if [ ! -x "$PSEXE" ]
- then
- echo "Unable to locate 'ps'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
- fi
- fi
-
-# Resolve the os
-DIST_OS=`uname -s | tr [:upper:] [:lower:] | tr -d [:blank:]`
-case "$DIST_OS" in
- 'sunos')
- DIST_OS="solaris"
- ;;
- 'hp-ux' | 'hp-ux64')
- # HP-UX needs the XPG4 version of ps (for -o args)
- DIST_OS="hpux"
- UNIX95=""
- export UNIX95
- ;;
- 'darwin')
- DIST_OS="macosx"
- ;;
- 'unix_sv')
- DIST_OS="unixware"
- ;;
-esac
-
-# Resolve the architecture
-if [ "$DIST_OS" = "macosx" ]
-then
- DIST_ARCH="universal"
-else
- DIST_ARCH=
- DIST_ARCH=`uname -p 2>/dev/null | tr [:upper:] [:lower:] | tr -d [:blank:]`
- if [ "X$DIST_ARCH" = "X" ]
- then
- DIST_ARCH="unknown"
- fi
- if [ "$DIST_ARCH" = "unknown" ]
- then
- DIST_ARCH=`uname -m 2>/dev/null | tr [:upper:] [:lower:] | tr -d [:blank:]`
- fi
- case "$DIST_ARCH" in
- 'amd64' | 'athlon' | 'i386' | 'i486' | 'i586' | 'i686' | 'x86_64')
- DIST_ARCH="x86"
- ;;
- 'ia32' | 'ia64' | 'ia64n' | 'ia64w')
- DIST_ARCH="ia"
- ;;
- 'ip27')
- DIST_ARCH="mips"
- ;;
- 'power' | 'powerpc' | 'power_pc' | 'ppc64')
- DIST_ARCH="ppc"
- ;;
- 'pa_risc' | 'pa-risc')
- DIST_ARCH="parisc"
- ;;
- 'sun4u' | 'sparcv9')
- DIST_ARCH="sparc"
- ;;
- '9000/800')
- DIST_ARCH="parisc"
- ;;
- esac
-fi
-
-# OSX always places Java in the same location so we can reliably set JAVA_HOME
-if [ "$DIST_OS" = "macosx" ]
-then
- if [ -z "$JAVA_HOME" ]; then
- JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
- fi
-fi
-
-outputFile() {
- if [ -f "$1" ]
- then
- echo " $1 (Found but not executable.)";
- else
- echo " $1"
- fi
-}
-
-# Decide on the wrapper binary to use.
-# If a 32-bit wrapper binary exists then it will work on 32 or 64 bit
-# platforms, if the 64-bit binary exists then the distribution most
-# likely wants to use long names. Otherwise, look for the default.
-WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
-if [ -x "$WRAPPER_TEST_CMD" ]
-then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
-else
- WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- if [ -x "$WRAPPER_TEST_CMD" ]
- then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
- else
- if [ ! -x "$WRAPPER_CMD" ]
- then
- echo "Unable to locate any of the following binaries:"
- outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
- outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- outputFile "$WRAPPER_CMD"
- exit 1
- fi
- fi
-fi
-
-# Build the nice clause
-if [ "X$PRIORITY" = "X" ]
-then
- CMDNICE=""
-else
- CMDNICE="nice -$PRIORITY"
-fi
-
-# Build the anchor file clause.
-if [ "X$IGNORE_SIGNALS" = "X" ]
-then
- ANCHORPROP=
- IGNOREPROP=
-else
- ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\"
- IGNOREPROP=wrapper.ignore_signals=TRUE
-fi
-
-# Build the status file clause.
-if [ "X$DETAIL_STATUS" = "X" ]
-then
- STATUSPROP=
-else
- STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\""
-fi
-
-# Build the lock file clause. Only create a lock file if the lock directory exists on this platform.
-LOCKPROP=
-if [ -d $LOCKDIR ]
-then
- if [ -w $LOCKDIR ]
- then
- LOCKPROP=wrapper.lockfile=\"$LOCKFILE\"
- fi
-fi
-
-checkUser() {
- # $1 touchLock flag
- # $2 command
-
- # Check the configured user. If necessary rerun this script as the desired user.
- if [ "X$RUN_AS_USER" != "X" ]
- then
- # Resolve the location of the 'id' command
- IDEXE="/usr/xpg4/bin/id"
- if [ ! -x "$IDEXE" ]
- then
- IDEXE="/usr/bin/id"
- if [ ! -x "$IDEXE" ]
- then
- echo "Unable to locate 'id'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
- fi
-
- if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
- then
- # Already running as the configured user. Avoid password prompts by not calling su.
- RUN_AS_USER=""
- fi
- fi
- if [ "X$RUN_AS_USER" != "X" ]
- then
- # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be
- # able to create the lock file. The Wrapper will be able to update this file once it
- # is created but will not be able to delete it on shutdown. If $2 is defined then
- # the lock file should be created for the current command
- if [ "X$LOCKPROP" != "X" ]
- then
- if [ "X$1" != "X" ]
- then
- # Resolve the primary group
- RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
- if [ "X$RUN_AS_GROUP" = "X" ]
- then
- RUN_AS_GROUP=$RUN_AS_USER
- fi
- touch $LOCKFILE
- chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE
- fi
- fi
-
- # Still want to change users, recurse. This means that the user will only be
- # prompted for a password once. Variables shifted by 1
- #
- # Use "runuser" if this exists. runuser should be used on RedHat in preference to su.
- #
- if test -f "/sbin/runuser"
- then
- /sbin/runuser - $RUN_AS_USER -c "\"$REALPATH\" $2"
- else
- su - $RUN_AS_USER -c "\"$REALPATH\" $2"
- fi
-
- # Now that we are the original user again, we may need to clean up the lock file.
- if [ "X$LOCKPROP" != "X" ]
- then
- getpid
- if [ "X$pid" = "X" ]
- then
- # Wrapper is not running so make sure the lock file is deleted.
- if [ -f "$LOCKFILE" ]
- then
- rm "$LOCKFILE"
- fi
- fi
- fi
-
- exit 0
- fi
-}
-
-getpid() {
- pid=""
- if [ -f "$PIDFILE" ]
- then
- if [ -r "$PIDFILE" ]
- then
- pid=`cat "$PIDFILE"`
- if [ "X$pid" != "X" ]
- then
- # It is possible that 'a' process with the pid exists but that it is not the
- # correct process. This can happen in a number of cases, but the most
- # common is during system startup after an unclean shutdown.
- # The ps statement below looks for the specific wrapper command running as
- # the pid. If it is not found then the pid file is considered to be stale.
- case "$DIST_OS" in
- 'macosx')
- pidtest=`$PSEXE -ww -p $pid -o command | grep "$WRAPPER_CMD" | tail -1`
- ;;
- 'solaris')
- pidtest=`$PSEXE -auxww $pid | grep "$WRAPPER_CMD" | tail -1`
- ;;
- 'hpux')
- pidtest=`$PSEXE -p $pid -x -o args | grep "$WRAPPER_CMD" | tail -1`
- ;;
- *)
- pidtest=`$PSEXE -p $pid -o args | grep "$WRAPPER_CMD" | tail -1`
- ;;
- esac
-
- if [ "X$pidtest" = "X" ]
- then
- # This is a stale pid file.
- rm -f "$PIDFILE"
- echo "Removed stale pid file: $PIDFILE"
- pid=""
- fi
- fi
- else
- echo "Cannot read $PIDFILE."
- exit 1
- fi
- fi
-}
-
-getstatus() {
- STATUS=
- if [ -f "$STATUSFILE" ]
- then
- if [ -r "$STATUSFILE" ]
- then
- STATUS=`cat "$STATUSFILE"`
- fi
- fi
- if [ "X$STATUS" = "X" ]
- then
- STATUS="Unknown"
- fi
-
- JAVASTATUS=
- if [ -f "$JAVASTATUSFILE" ]
- then
- if [ -r "$JAVASTATUSFILE" ]
- then
- JAVASTATUS=`cat "$JAVASTATUSFILE"`
- fi
- fi
- if [ "X$JAVASTATUS" = "X" ]
- then
- JAVASTATUS="Unknown"
- fi
-}
-
-testpid() {
- case "$DIST_OS" in
- 'solaris')
- pid=`$PSEXE $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
- ;;
- *)
- pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
- ;;
- esac
- if [ "X$pid" = "X" ]
- then
- # Process is gone so remove the pid file.
- rm -f "$PIDFILE"
- pid=""
- fi
-}
-
-console() {
- echo "Running $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- # The string passed to eval must handles spaces in paths correctly.
- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $LOCKPROP"
- eval $COMMAND_LINE
- else
- echo "$APP_LONG_NAME is already running."
- exit 1
- fi
-}
-
-start() {
- echo -n "Starting $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- # The string passed to eval must handles spaces in paths correctly.
- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $LOCKPROP"
- eval $COMMAND_LINE
- else
- echo "$APP_LONG_NAME is already running."
- exit 1
- fi
-
- # Sleep for a few seconds to allow for intialization if required
- # then test to make sure we're still running.
- #
- i=0
- while [ $i -lt $WAIT_AFTER_STARTUP ]
- do
- sleep 1
- echo -n "."
- i=`expr $i + 1`
- done
- if [ $WAIT_AFTER_STARTUP -gt 0 ]
- then
- getpid
- if [ "X$pid" = "X" ]
- then
- echo " WARNING: $APP_LONG_NAME may have failed to start."
- exit 1
- else
- echo " running ($pid)."
- fi
- else
- echo ""
- fi
-}
-
-stopit() {
- # $1 exit if down flag
-
- echo "Stopping $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME was not running."
- if [ "X$1" = "X1" ]
- then
- exit 1
- fi
- else
- if [ "X$IGNORE_SIGNALS" = "X" ]
- then
- # Running so try to stop it.
- kill $pid
- if [ $? -ne 0 ]
- then
- # An explanation for the failure should have been given
- echo "Unable to stop $APP_LONG_NAME."
- exit 1
- fi
- else
- rm -f "$ANCHORFILE"
- if [ -f "$ANCHORFILE" ]
- then
- # An explanation for the failure should have been given
- echo "Unable to stop $APP_LONG_NAME."
- exit 1
- fi
- fi
-
- # We can not predict how long it will take for the wrapper to
- # actually stop as it depends on settings in wrapper.conf.
- # Loop until it does.
- savepid=$pid
- CNT=0
- TOTCNT=0
- while [ "X$pid" != "X" ]
- do
- # Show a waiting message every 5 seconds.
- if [ "$CNT" -lt "5" ]
- then
- CNT=`expr $CNT + 1`
- else
- echo "Waiting for $APP_LONG_NAME to exit..."
- CNT=0
- fi
- TOTCNT=`expr $TOTCNT + 1`
-
- sleep 1
-
- testpid
- done
-
- pid=$savepid
- testpid
- if [ "X$pid" != "X" ]
- then
- echo "Failed to stop $APP_LONG_NAME."
- exit 1
- else
- echo "Stopped $APP_LONG_NAME."
- fi
- fi
-}
-
-status() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME is not running."
- exit 1
- else
- if [ "X$DETAIL_STATUS" = "X" ]
- then
- echo "$APP_LONG_NAME is running (PID:$pid)."
- else
- getstatus
- echo "$APP_LONG_NAME is running (PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS)"
- fi
- exit 0
- fi
-}
-
-dump() {
- echo "Dumping $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME was not running."
- else
- kill -3 $pid
-
- if [ $? -ne 0 ]
- then
- echo "Failed to dump $APP_LONG_NAME."
- exit 1
- else
- echo "Dumped $APP_LONG_NAME."
- fi
- fi
-}
-
-# Used by HP-UX init scripts.
-startmsg() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "Starting $APP_LONG_NAME... (Wrapper:Stopped)"
- else
- if [ "X$DETAIL_STATUS" = "X" ]
- then
- echo "Starting $APP_LONG_NAME... (Wrapper:Running)"
- else
- getstatus
- echo "Starting $APP_LONG_NAME... (Wrapper:$STATUS, Java:$JAVASTATUS)"
- fi
- fi
-}
-
-# Used by HP-UX init scripts.
-stopmsg() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "Stopping $APP_LONG_NAME... (Wrapper:Stopped)"
- else
- if [ "X$DETAIL_STATUS" = "X" ]
- then
- echo "Stopping $APP_LONG_NAME... (Wrapper:Running)"
- else
- getstatus
- echo "Stopping $APP_LONG_NAME... (Wrapper:$STATUS, Java:$JAVASTATUS)"
- fi
- fi
-}
-
-case "$1" in
-
- 'console')
- checkUser touchlock $1
- console
- ;;
-
- 'start')
- checkUser touchlock $1
- start
- ;;
-
- 'stop')
- checkUser "" $1
- stopit "0"
- ;;
-
- 'restart')
- checkUser touchlock $1
- stopit "0"
- start
- ;;
-
- 'condrestart')
- checkUser touchlock $1
- stopit "1"
- start
- ;;
-
- 'status')
- checkUser "" $1
- status
- ;;
-
- 'dump')
- checkUser "" $1
- dump
- ;;
-
- 'start_msg')
- checkUser "" $1
- startmsg
- ;;
-
- 'stop_msg')
- checkUser "" $1
- stopmsg
- ;;
-
- *)
- echo "Usage: $0 { console | start | stop | restart | condrestart | status | dump }"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/src/contribs/wrapper/conf/wrapper.conf b/src/contribs/wrapper/conf/wrapper.conf
deleted file mode 100644
index 2442d7b..0000000
--- a/src/contribs/wrapper/conf/wrapper.conf
+++ /dev/null
@@ -1,119 +0,0 @@
-#********************************************************************
-# Wrapper License Properties (Ignored by Community Edition)
-#********************************************************************
-# Include file problems can be debugged by removing the first '#'
-# from the following line:
-##include.debug
-#include ../conf/wrapper-license.conf
-#include ../conf/wrapper-license-%WRAPPER_HOST_NAME%.conf
-
-#********************************************************************
-# Wrapper Java Properties
-#********************************************************************
-# Java Application
-wrapper.java.command=java
-wrapper.debug=false
-# Tell the Wrapper to log the full generated Java command line.
-#wrapper.java.command.loglevel=INFO
-
-# Java Main class. This class must implement the WrapperListener interface
-# or guarantee that the WrapperManager class is initialized. Helper
-# classes are provided to do this for you. See the Integration section
-# of the documentation for details.
-wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
-
-# Java Classpath (include wrapper.jar) Add class path elements as
-# needed starting from 1
-wrapper.java.classpath.1=../lib/wrapper.jar
-wrapper.java.classpath.2=../lib/*.jar
-
-
-# Java Library Path (location of Wrapper.DLL or libwrapper.so)
-wrapper.java.library.path.1=../lib
-
-# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
-wrapper.java.additional.auto_bits=TRUE
-
-# Java Additional Parameters
-#wrapper.java.additional.1=
-
-# Initial Java Heap Size (in MB)
-wrapper.java.initmemory=3
-
-# Maximum Java Heap Size (in MB)
-wrapper.java.maxmemory=64
-
-# Application parameters. Add parameters as needed starting from 1
-wrapper.app.parameter.1=davmail.DavGateway
-wrapper.app.parameter.2=../conf/davmail.properties
-
-
-#********************************************************************
-# Wrapper Logging Properties
-#********************************************************************
-# Enables Debug output from the Wrapper.
-# wrapper.debug=TRUE
-
-# Format of output for the console. (See docs for formats)
-wrapper.console.format=PM
-
-# Log Level for console output. (See docs for log levels)
-wrapper.console.loglevel=INFO
-
-# Log file to use for wrapper output logging.
-wrapper.logfile=../logs/davmail.log
-
-# Format of output for the log file. (See docs for formats)
-wrapper.logfile.format=LPTM
-
-# Log Level for log file output. (See docs for log levels)
-wrapper.logfile.loglevel=INFO
-
-# Maximum size that the log file will be allowed to grow to before
-# the log is rolled. Size is specified in bytes. The default value
-# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
-# 'm' (mb) suffix. For example: 10m = 10 megabytes.
-wrapper.logfile.maxsize=10m
-
-# Maximum number of rolled log files which will be allowed before old
-# files are deleted. The default value of 0 implies no limit.
-wrapper.logfile.maxfiles=5
-
-# Log Level for sys/event log output. (See docs for log levels)
-wrapper.syslog.loglevel=NONE
-
-#********************************************************************
-# Wrapper General Properties
-#********************************************************************
-# Allow for the use of non-contiguous numbered properties
-wrapper.ignore_sequence_gaps=TRUE
-
-# Title to use when running as a console
-wrapper.console.title=DavMail
-
-#********************************************************************
-# Wrapper Windows NT/2000/XP Service Properties
-#********************************************************************
-# WARNING - Do not modify any of these properties when an application
-# using this configuration file has been installed as a service.
-# Please uninstall the service before modifying this section. The
-# service can then be reinstalled.
-
-# Name of the service
-wrapper.name=davmail
-
-# Display name of the service
-wrapper.displayname=DavMail
-
-# Description of the service
-wrapper.description=DavMail
-
-# Service dependencies. Add dependencies as needed starting from 1
-wrapper.ntservice.dependency.1=
-
-# Mode in which the service is installed. AUTO_START or DEMAND_START
-wrapper.ntservice.starttype=AUTO_START
-
-# Allow the service to interact with the desktop.
-wrapper.ntservice.interactive=false
-
diff --git a/src/contribs/wrapper/conf/wrapper.conf_2 b/src/contribs/wrapper/conf/wrapper.conf_2
deleted file mode 100644
index 1a531bf..0000000
--- a/src/contribs/wrapper/conf/wrapper.conf_2
+++ /dev/null
@@ -1,119 +0,0 @@
-#********************************************************************
-# Wrapper License Properties (Ignored by Community Edition)
-#********************************************************************
-# Include file problems can be debugged by removing the first '#'
-# from the following line:
-##include.debug
-#include ../conf/wrapper-license.conf
-#include ../conf/wrapper-license-%WRAPPER_HOST_NAME%.conf
-
-#********************************************************************
-# Wrapper Java Properties
-#********************************************************************
-# Java Application
-wrapper.java.command=java
-wrapper.debug=false
-# Tell the Wrapper to log the full generated Java command line.
-#wrapper.java.command.loglevel=INFO
-
-# Java Main class. This class must implement the WrapperListener interface
-# or guarantee that the WrapperManager class is initialized. Helper
-# classes are provided to do this for you. See the Integration section
-# of the documentation for details.
-wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
-
-# Java Classpath (include wrapper.jar) Add class path elements as
-# needed starting from 1
-wrapper.java.classpath.1=../lib/wrapper.jar
-wrapper.java.classpath.2=../lib/*.jar
-
-
-# Java Library Path (location of Wrapper.DLL or libwrapper.so)
-wrapper.java.library.path.1=../lib
-
-# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
-wrapper.java.additional.auto_bits=TRUE
-
-# Java Additional Parameters
-#wrapper.java.additional.1=
-
-# Initial Java Heap Size (in MB)
-wrapper.java.initmemory=3
-
-# Maximum Java Heap Size (in MB)
-wrapper.java.maxmemory=64
-
-# Application parameters. Add parameters as needed starting from 1
-wrapper.app.parameter.1=davmail.DavGateway
-wrapper.app.parameter.2=../conf/davmail.properties_2
-
-
-#********************************************************************
-# Wrapper Logging Properties
-#********************************************************************
-# Enables Debug output from the Wrapper.
-# wrapper.debug=TRUE
-
-# Format of output for the console. (See docs for formats)
-wrapper.console.format=PM
-
-# Log Level for console output. (See docs for log levels)
-wrapper.console.loglevel=INFO
-
-# Log file to use for wrapper output logging.
-wrapper.logfile=../logs/davmail.log_2
-
-# Format of output for the log file. (See docs for formats)
-wrapper.logfile.format=LPTM
-
-# Log Level for log file output. (See docs for log levels)
-wrapper.logfile.loglevel=INFO
-
-# Maximum size that the log file will be allowed to grow to before
-# the log is rolled. Size is specified in bytes. The default value
-# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
-# 'm' (mb) suffix. For example: 10m = 10 megabytes.
-wrapper.logfile.maxsize=10m
-
-# Maximum number of rolled log files which will be allowed before old
-# files are deleted. The default value of 0 implies no limit.
-wrapper.logfile.maxfiles=5
-
-# Log Level for sys/event log output. (See docs for log levels)
-wrapper.syslog.loglevel=NONE
-
-#********************************************************************
-# Wrapper General Properties
-#********************************************************************
-# Allow for the use of non-contiguous numbered properties
-wrapper.ignore_sequence_gaps=TRUE
-
-# Title to use when running as a console
-wrapper.console.title=DavMail
-
-#********************************************************************
-# Wrapper Windows NT/2000/XP Service Properties
-#********************************************************************
-# WARNING - Do not modify any of these properties when an application
-# using this configuration file has been installed as a service.
-# Please uninstall the service before modifying this section. The
-# service can then be reinstalled.
-
-# Name of the service
-wrapper.name=davmail
-
-# Display name of the service
-wrapper.displayname=DavMail
-
-# Description of the service
-wrapper.description=DavMail
-
-# Service dependencies. Add dependencies as needed starting from 1
-wrapper.ntservice.dependency.1=
-
-# Mode in which the service is installed. AUTO_START or DEMAND_START
-wrapper.ntservice.starttype=AUTO_START
-
-# Allow the service to interact with the desktop.
-wrapper.ntservice.interactive=false
-
diff --git a/src/contribs/wrapper/readme.txt b/src/contribs/wrapper/readme.txt
deleted file mode 100644
index 8d6a65d..0000000
--- a/src/contribs/wrapper/readme.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-From Dustin Hawkins:
-
-I run two instances of DavMail on my linux desktop to connect to work and university exchange servers.
-In order to accomplish this, I used the Java Service Wrapper.
-
-Thought I would share my configs in case any one else wanted to run multi-instance under the java service wrapper.
-
-http://wrapper.tanukisoftware.org/doc/english/download.jsp
-
-
-I created the following directory structure
-
-/opt/davmail
- bin/
- wrapper <-- this is provided by java service wrapper. platform specific native executable.
- davmail
- davmail_2
- lib/
- <davmail jars>
- <wrapper static objects/dll's for appropriate platform>
- conf/
- wrapper.conf
- wrapper.conf_2
- davmail.properties
- davmail.properties_2
- logs/
-
-
-The bin/davmail* scripts are the linux start/stop scripts for each instance
-the conf/ directory has two files for each instance, a wrapper.conf, and a davmail.properties.
-
-by linking the bin/davmail* scripts into /etc/init.d and /etc/rc.d, I start davmail as a linux service,
-and its easily start/stop/restart-able via the standard linux commands.
-
-If you download the Java Service Wrapper, you can find the appropriate executables and start scripts for
-your platform under <wrapper install dir>/bin
-You can find the correct static object or DLL files under the <wrapper install dir>/lib
-
-I have included a ZIP of my wrapper.conf and davmail startup scripts
diff --git a/src/java/davmail/Settings.java b/src/java/davmail/Settings.java
index 7c6c70e..67078ad 100644
--- a/src/java/davmail/Settings.java
+++ b/src/java/davmail/Settings.java
@@ -22,10 +22,7 @@ import davmail.ui.tray.DavGatewayTray;
import org.apache.log4j.*;
import java.io.*;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.TreeSet;
+import java.util.*;
/**
* Settings facade.
@@ -146,6 +143,7 @@ public final class Settings {
SETTINGS.put("davmail.useSystemProxies", Boolean.FALSE.toString());
SETTINGS.put("davmail.enableProxy", Boolean.FALSE.toString());
SETTINGS.put("davmail.enableEws", "auto");
+ SETTINGS.put("davmail.enableKerberos", "false");
SETTINGS.put("davmail.proxyHost", "");
SETTINGS.put("davmail.proxyPort", "");
SETTINGS.put("davmail.proxyUser", "");
@@ -466,6 +464,32 @@ public final class Settings {
}
/**
+ * Get all properties that are in the specified scope, that is, that start with '<scope>.'.
+ *
+ * @param scope start of property name
+ * @return properties
+ */
+ public static synchronized Properties getSubProperties(String scope) {
+ final String keyStart;
+ if (scope == null || scope.length() == 0) {
+ keyStart = "";
+ } else if (scope.endsWith(".")) {
+ keyStart = scope;
+ } else {
+ keyStart = scope + '.';
+ }
+ Properties result = new Properties();
+ for (Map.Entry entry : SETTINGS.entrySet()) {
+ String key = (String)entry.getKey();
+ if (key.startsWith(keyStart)) {
+ String value = (String)entry.getValue();
+ result.setProperty(key.substring(keyStart.length()), value);
+ }
+ }
+ return result;
+ }
+
+ /**
* Set Log4J logging level for the category
*
* @param category logging category
diff --git a/src/java/davmail/caldav/CaldavConnection.java b/src/java/davmail/caldav/CaldavConnection.java
index 18fc922..ed1ff04 100644
--- a/src/java/davmail/caldav/CaldavConnection.java
+++ b/src/java/davmail/caldav/CaldavConnection.java
@@ -170,7 +170,12 @@ public class CaldavConnection extends AbstractConnection {
session = ExchangeSessionFactory.getInstance(userName, password);
handleRequest(command, path, headers, content);
} catch (DavMailAuthenticationException e) {
- sendUnauthorized();
+ if (Settings.getBooleanProperty("davmail.enableKerberos")) {
+ // authentication failed in Kerberos mode => not available
+ sendErr(HttpStatus.SC_SERVICE_UNAVAILABLE, "Kerberos authentication failed");
+ } else {
+ sendUnauthorized();
+ }
}
}
@@ -1440,7 +1445,7 @@ public class CaldavConnection extends AbstractConnection {
}
protected boolean isIcal5() {
- return isUserAgent("CoreDAV/") || isUserAgent("iOS/5")
+ return isUserAgent("CoreDAV/") || isUserAgent("iOS/5") || isUserAgent("iOS/6")
// iCal 6
|| isUserAgent("Mac OS X/10.8");
}
diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java
index 89e8350..36ece60 100644
--- a/src/java/davmail/exchange/ExchangeSession.java
+++ b/src/java/davmail/exchange/ExchangeSession.java
@@ -33,8 +33,8 @@ import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.log4j.Logger;
-import org.htmlcleaner.CommentToken;
-import org.htmlcleaner.ContentToken;
+import org.htmlcleaner.CommentNode;
+import org.htmlcleaner.ContentNode;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
@@ -180,6 +180,8 @@ public abstract class ExchangeSession {
// set private connection pool
DavGatewayHttpClientFacade.createMultiThreadedHttpConnectionManager(httpClient);
boolean isBasicAuthentication = isBasicAuthentication(httpClient, url);
+ // clear cookies created by authentication test
+ httpClient.getState().clearCookies();
// The user may have configured an OTP pre-auth username. It is processed
// so early because OTP pre-auth may disappear in the Exchange LAN and this
@@ -187,13 +189,13 @@ public abstract class ExchangeSession {
if (preAuthUsername == null) {
// Searches for the delimiter in configured username for the pre-auth user.
// The double-quote is not allowed inside email addresses anyway.
- int doubleQuoteIndex = this.userName.indexOf('"');
+ int doubleQuoteIndex = this.userName.indexOf('"');
if (doubleQuoteIndex > 0) {
preAuthUsername = this.userName.substring(0, doubleQuoteIndex);
this.userName = this.userName.substring(doubleQuoteIndex + 1);
} else {
// No doublequote: the pre-auth user is the full username, or it is not used at all.
- preAuthUsername = this.userName;
+ preAuthUsername = this.userName;
}
}
@@ -225,7 +227,7 @@ public abstract class ExchangeSession {
}
// avoid 401 roundtrips, only if NTLM is disabled and basic authentication enabled
- if (isBasicAuthentication && !DavGatewayHttpClientFacade.hasNTLM(httpClient)) {
+ if (isBasicAuthentication && !DavGatewayHttpClientFacade.hasNTLMorNegotiate(httpClient)) {
httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
}
@@ -475,8 +477,8 @@ public abstract class ExchangeSession {
for (Object script : scriptList) {
List contents = ((TagNode) script).getChildren();
for (Object content : contents) {
- if (content instanceof CommentToken) {
- String scriptValue = ((CommentToken) content).getCommentedContent();
+ if (content instanceof CommentNode) {
+ String scriptValue = ((CommentNode) content).getCommentedContent();
String sUrl = StringUtil.getToken(scriptValue, "var a_sUrl = \"", "\"");
String sLgn = StringUtil.getToken(scriptValue, "var a_sLgnQS = \"", "\"");
if (sLgn == null) {
@@ -489,9 +491,9 @@ public abstract class ExchangeSession {
logonMethod = buildLogonMethod(httpClient, newInitMethod);
}
- } else if (content instanceof ContentToken) {
+ } else if (content instanceof ContentNode) {
// Microsoft Forefront Unified Access Gateway redirect
- String scriptValue = ((ContentToken) content).getContent();
+ String scriptValue = ((ContentNode) content).getContent().toString();
String location = StringUtil.getToken(scriptValue, "window.location.replace(\"", "\"");
if (location != null) {
LOGGER.debug("Post logon redirect to: " + location);
@@ -513,7 +515,7 @@ public abstract class ExchangeSession {
protected HttpMethod postLogonMethod(HttpClient httpClient, HttpMethod logonMethod, String userName, String password) throws IOException {
- setAuthFormFields(logonMethod, httpClient, password);
+ setAuthFormFields(logonMethod, httpClient, password);
// add exchange 2010 PBack cookie in compatibility mode
httpClient.getState().addCookie(new Cookie(httpClient.getHostConfiguration().getHost(), "PBack", "0", "/", null, false));
@@ -1281,7 +1283,10 @@ public abstract class ExchangeSession {
convertResentHeader(mimeMessage, "Bcc");
convertResentHeader(mimeMessage, "Message-Id");
- mimeMessage.removeHeader("From");
+ // do not allow send as another user on Exchange 2003
+ if ("Exchange2003".equals(serverVersion)) {
+ mimeMessage.removeHeader("From");
+ }
// remove visible recipients from list
Set<String> visibleRecipients = new HashSet<String>();
@@ -1472,39 +1477,58 @@ public abstract class ExchangeSession {
/**
* Convert keyword value to IMAP flag.
+ *
* @param value keyword value
* @return IMAP flag
*/
public String convertKeywordToFlag(String value) {
- String result = value;
- // convert flags to Thunderbird flags
+ // first test for keyword in settings
+ Properties flagSettings = Settings.getSubProperties("davmail.imapFlags");
+ Enumeration flagSettingsEnum = flagSettings.propertyNames();
+ while (flagSettingsEnum.hasMoreElements()) {
+ String key = (String) flagSettingsEnum.nextElement();
+ if (value.equalsIgnoreCase(flagSettings.getProperty(key))) {
+ return key;
+ }
+ }
+
ResourceBundle flagBundle = ResourceBundle.getBundle("imapflags");
- Enumeration<String> flagEnumeration = flagBundle.getKeys();
- while (flagEnumeration.hasMoreElements()) {
- String key = flagEnumeration.nextElement();
+ Enumeration<String> flagBundleEnum = flagBundle.getKeys();
+ while (flagBundleEnum.hasMoreElements()) {
+ String key = flagBundleEnum.nextElement();
if (value.equalsIgnoreCase(flagBundle.getString(key))) {
- result = key;
+ return key;
}
}
- return result;
+
+ // fall back to raw value
+ return value;
}
/**
* Convert IMAP flag to keyword value.
+ *
* @param value IMAP flag
* @return keyword value
*/
public String convertFlagToKeyword(String value) {
- String result = value;
- // convert flags to Thunderbird flags
+ // first test for flag in settings
+ Properties flagSettings = Settings.getSubProperties("davmail.imapFlags");
+ String flagValue = flagSettings.getProperty(value);
+ if (flagValue != null) {
+ return flagValue;
+ }
+
+ // fall back to predefined flags
ResourceBundle flagBundle = ResourceBundle.getBundle("imapflags");
try {
- result = flagBundle.getString(value);
+ return flagBundle.getString(value);
} catch (MissingResourceException e) {
// ignore
}
- return result;
+ // fall back to raw value
+ return value;
}
/**
@@ -1668,8 +1692,8 @@ public abstract class ExchangeSession {
*
* @return imap uid list
*/
- public TreeMap<Long,String> getImapFlagMap() {
- TreeMap<Long,String> imapFlagMap = new TreeMap<Long,String>();
+ public TreeMap<Long, String> getImapFlagMap() {
+ TreeMap<Long, String> imapFlagMap = new TreeMap<Long, String>();
for (ExchangeSession.Message message : messages) {
imapFlagMap.put(message.getImapUid(), message.getImapFlags());
}
@@ -1864,7 +1888,7 @@ public abstract class ExchangeSession {
buffer.append("$Forwarded ");
}
if (keywords != null) {
- for (String keyword:keywords.split(",")) {
+ for (String keyword : keywords.split(",")) {
buffer.append(convertKeywordToFlag(keyword)).append(" ");
}
}
@@ -1891,7 +1915,7 @@ public abstract class ExchangeSession {
mimeBody.reset();
// workaround for Exchange 2003 ActiveSync bug
if (mimeMessage.getHeader("MAIL FROM") != null) {
- mimeBody = (SharedByteArrayInputStream)mimeMessage.getRawInputStream();
+ mimeBody = (SharedByteArrayInputStream) mimeMessage.getRawInputStream();
mimeMessage = new MimeMessage(null, mimeBody);
mimeBody.reset();
}
@@ -1913,7 +1937,7 @@ public abstract class ExchangeSession {
}
public Enumeration getMatchingHeaderLines(String[] headerNames) throws MessagingException, IOException {
- Enumeration result = null;
+ Enumeration result = null;
if (mimeMessage == null) {
// message not loaded, try to get headers only
InputStream headers = getMimeHeaders();
@@ -2780,7 +2804,7 @@ public abstract class ExchangeSession {
}
return andCondition;
} catch (ParseException e) {
- throw new IOException(e+" "+e.getMessage());
+ throw new IOException(e + " " + e.getMessage());
}
}
diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java
index 7639eb8..e3a2fe5 100644
--- a/src/java/davmail/exchange/dav/DavExchangeSession.java
+++ b/src/java/davmail/exchange/dav/DavExchangeSession.java
@@ -30,7 +30,6 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.util.URIUtil;
-import org.apache.jackrabbit.webdav.DavConstants;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
@@ -41,6 +40,7 @@ import org.apache.jackrabbit.webdav.client.methods.PropPatchMethod;
import org.apache.jackrabbit.webdav.property.DavProperty;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.PropEntry;
import org.w3c.dom.Node;
import javax.mail.MessagingException;
@@ -54,6 +54,7 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.*;
import java.net.NoRouteToHostException;
+import java.net.SocketException;
import java.net.URL;
import java.net.UnknownHostException;
import java.text.ParseException;
@@ -764,7 +765,7 @@ public class DavExchangeSession extends ExchangeSession {
DavGatewayHttpClientFacade.executeMethod(httpClient, propFindMethod);
} catch (IOException e) {
// workaround for NTLM authentication only on /public
- if (!DavGatewayHttpClientFacade.hasNTLM(httpClient)) {
+ if (!DavGatewayHttpClientFacade.hasNTLMorNegotiate(httpClient)) {
DavGatewayHttpClientFacade.addNTLM(httpClient);
DavGatewayHttpClientFacade.executeMethod(httpClient, propFindMethod);
}
@@ -1691,7 +1692,7 @@ public class DavExchangeSession extends ExchangeSession {
// trigger activeSync push event, only if davmail.forceActiveSyncUpdate setting is true
if ((status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED) &&
(Settings.getBooleanProperty("davmail.forceActiveSyncUpdate"))) {
- ArrayList<DavConstants> propertyList = new ArrayList<DavConstants>();
+ ArrayList<PropEntry> propertyList = new ArrayList<PropEntry>();
// Set contentclass to make ActiveSync happy
propertyList.add(Field.createDavProperty("contentclass", contentClass));
// ... but also set PR_INTERNET_CONTENT to preserve custom properties
@@ -2336,7 +2337,7 @@ public class DavExchangeSession extends ExchangeSession {
public void processItem(String folderPath, String itemName) throws IOException {
String eventPath = URIUtil.encodePath(getFolderPath(folderPath) + '/' + convertItemNameToEML(itemName));
// do not delete calendar messages, mark read and processed
- ArrayList<DavConstants> list = new ArrayList<DavConstants>();
+ ArrayList<PropEntry> list = new ArrayList<PropEntry>();
list.add(Field.createDavProperty("processed", "true"));
list.add(Field.createDavProperty("read", "1"));
PropPatchMethod patchMethod = new PropPatchMethod(eventPath, list);
@@ -2378,7 +2379,7 @@ public class DavExchangeSession extends ExchangeSession {
}
// failover for Exchange 2007, use PROPPATCH with forced timezone
if (fakeEventUrl == null) {
- ArrayList<DavConstants> propertyList = new ArrayList<DavConstants>();
+ ArrayList<PropEntry> propertyList = new ArrayList<PropEntry>();
propertyList.add(Field.createDavProperty("contentclass", "urn:content-classes:appointment"));
propertyList.add(Field.createDavProperty("outlookmessageclass", "IPM.Appointment"));
propertyList.add(Field.createDavProperty("instancetype", "0"));
@@ -2479,8 +2480,8 @@ public class DavExchangeSession extends ExchangeSession {
return new Contact(getFolderPath(folderPath), itemName, properties, etag, noneMatch).createOrUpdate();
}
- protected List<DavConstants> buildProperties(Map<String, String> properties) {
- ArrayList<DavConstants> list = new ArrayList<DavConstants>();
+ protected List<PropEntry> buildProperties(Map<String, String> properties) {
+ ArrayList<PropEntry> list = new ArrayList<PropEntry>();
if (properties != null) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
if ("read".equals(entry.getKey())) {
@@ -2527,7 +2528,7 @@ public class DavExchangeSession extends ExchangeSession {
public void createMessage(String folderPath, String messageName, HashMap<String, String> properties, MimeMessage mimeMessage) throws IOException {
String messageUrl = URIUtil.encodePathQuery(getFolderPath(folderPath) + '/' + messageName);
PropPatchMethod patchMethod;
- List<DavConstants> davProperties = buildProperties(properties);
+ List<PropEntry> davProperties = buildProperties(properties);
if (properties != null && properties.containsKey("draft")) {
// note: draft is readonly after create, create the message first with requested messageFlags
@@ -2570,7 +2571,7 @@ public class DavExchangeSession extends ExchangeSession {
if (code == HttpStatus.SC_NOT_ACCEPTABLE) {
LOGGER.warn("Draft message creation failed, failover to property update. Note: attachments are lost");
- ArrayList<DavConstants> propertyList = new ArrayList<DavConstants>();
+ ArrayList<PropEntry> propertyList = new ArrayList<PropEntry>();
propertyList.add(Field.createDavProperty("to", mimeMessage.getHeader("to", ",")));
propertyList.add(Field.createDavProperty("cc", mimeMessage.getHeader("cc", ",")));
propertyList.add(Field.createDavProperty("message-id", mimeMessage.getHeader("message-id", ",")));
@@ -2634,7 +2635,7 @@ public class DavExchangeSession extends ExchangeSession {
try {
// need to update bcc after put
if (mimeMessage.getHeader("Bcc") != null) {
- davProperties = new ArrayList<DavConstants>();
+ davProperties = new ArrayList<PropEntry>();
davProperties.add(Field.createDavProperty("bcc", mimeMessage.getHeader("Bcc", ",")));
patchMethod = new PropPatchMethod(messageUrl, davProperties);
try {
@@ -2770,6 +2771,10 @@ public class DavExchangeSession extends ExchangeSession {
// throw error on expired session
LOGGER.warn(e.getMessage());
throw e;
+ } catch (SocketException e) {
+ // throw error on broken connection
+ LOGGER.warn(e.getMessage());
+ throw e;
} catch (IOException e) {
LOGGER.warn("Broken message at: " + message.messageUrl + " permanentUrl: " + message.permanentUrl + ", trying to rebuild from properties");
diff --git a/src/java/davmail/exchange/dav/Field.java b/src/java/davmail/exchange/dav/Field.java
index 15b71b9..992e95e 100644
--- a/src/java/davmail/exchange/dav/Field.java
+++ b/src/java/davmail/exchange/dav/Field.java
@@ -19,9 +19,9 @@
package davmail.exchange.dav;
import davmail.util.StringUtil;
-import org.apache.jackrabbit.webdav.DavConstants;
import org.apache.jackrabbit.webdav.property.DavPropertyName;
import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.PropEntry;
import org.apache.jackrabbit.webdav.xml.DomUtil;
import org.apache.jackrabbit.webdav.xml.Namespace;
import org.apache.jackrabbit.webdav.xml.XmlSerializable;
@@ -530,7 +530,7 @@ public class Field {
* @param value field value
* @return DavProperty with value or DavPropertyName for null values
*/
- public static DavConstants createDavProperty(String alias, String value) {
+ public static PropEntry createDavProperty(String alias, String value) {
Field field = Field.get(alias);
if (value == null) {
// return DavPropertyName to remove property
diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java
index 5cd960e..2ffafa4 100644
--- a/src/java/davmail/exchange/ews/EwsExchangeSession.java
+++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java
@@ -241,7 +241,7 @@ public class EwsExchangeSession extends ExchangeSession {
}
// enable preemptive authentication on non NTLM endpoints
- if (!DavGatewayHttpClientFacade.hasNTLM(httpClient)) {
+ if (!DavGatewayHttpClientFacade.hasNTLMorNegotiate(httpClient)) {
httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
}
@@ -585,6 +585,10 @@ public class EwsExchangeSession extends ExchangeSession {
executeMethod(getItemMethod);
EWSMethod.Item item = getItemMethod.getResponseItem();
+ if (item == null) {
+ throw new HttpNotFoundException("Item " + itemId + " not found");
+ }
+
MimeMessage mimeMessage = new MimeMessage((Session) null);
mimeMessage.addHeader("Content-class", item.get(Field.get("contentclass").getResponseName()));
mimeMessage.setSentDate(parseDateFromExchange(item.get(Field.get("date").getResponseName())));
@@ -1856,7 +1860,7 @@ public class EwsExchangeSession extends ExchangeSession {
String urlcompname = convertItemNameToEML(itemName);
// workaround for missing urlcompname in Exchange 2010
if (isItemId(urlcompname)) {
- ItemId itemId = new ItemId(StringUtil.urlToBase64(urlcompname.substring(0, itemName.length() - 4)));
+ ItemId itemId = new ItemId(StringUtil.urlToBase64(urlcompname.substring(0, urlcompname.indexOf('.'))));
GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, false);
for (String attribute : EVENT_REQUEST_PROPERTIES) {
getItemMethod.addAdditionalProperty(Field.get(attribute));
@@ -2218,9 +2222,6 @@ public class EwsExchangeSession extends ExchangeSession {
serverVersion = ewsMethod.getServerVersion();
}
ewsMethod.checkSuccess();
- } catch (SocketException e) {
- LOGGER.error(e + " " + e.getMessage(), e);
- throw new EWSException(e + " " + e.getMessage());
} finally {
ewsMethod.releaseConnection();
}
diff --git a/src/java/davmail/http/DavGatewayHttpClientFacade.java b/src/java/davmail/http/DavGatewayHttpClientFacade.java
index 403ace5..82e839c 100644
--- a/src/java/davmail/http/DavGatewayHttpClientFacade.java
+++ b/src/java/davmail/http/DavGatewayHttpClientFacade.java
@@ -167,12 +167,12 @@ public final class DavGatewayHttpClientFacade {
public static void configureClient(HttpClient httpClient, String url) throws DavMailException {
setClientHost(httpClient, url);
- /*if (Settings.getBooleanProperty("davmail.enableKerberos", false)) {
- AuthPolicy.registerAuthScheme("Negotiate", NegotiateScheme.class);
+ if (Settings.getBooleanProperty("davmail.enableKerberos", false)) {
+ AuthPolicy.registerAuthScheme("Negotiate", SpNegoScheme.class);
ArrayList<String> authPrefs = new ArrayList<String>();
authPrefs.add("Negotiate");
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
- } else */if (!needNTLM) {
+ } else if (!needNTLM) {
ArrayList<String> authPrefs = new ArrayList<String>();
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
@@ -305,7 +305,7 @@ public final class DavGatewayHttpClientFacade {
private static int checkNTLM(HttpClient httpClient, HttpMethod currentMethod) throws IOException {
int status = currentMethod.getStatusCode();
if ((status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
- && acceptsNTLMOnly(currentMethod) && !hasNTLM(httpClient)) {
+ && acceptsNTLMOnly(currentMethod) && !hasNTLMorNegotiate(httpClient)) {
LOGGER.debug("Received " + status + " unauthorized at " + currentMethod.getURI() + ", retrying with NTLM");
resetMethod(currentMethod);
addNTLM(httpClient);
@@ -415,7 +415,7 @@ public final class DavGatewayHttpClientFacade {
status = httpClient.executeMethod(method);
// check NTLM
if ((status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
- && acceptsNTLMOnly(method) && !hasNTLM(httpClient)) {
+ && acceptsNTLMOnly(method) && !hasNTLMorNegotiate(httpClient)) {
LOGGER.debug("Received " + status + " unauthorized at " + method.getURI() + ", retrying with NTLM");
resetMethod(method);
addNTLM(httpClient);
@@ -574,9 +574,10 @@ public final class DavGatewayHttpClientFacade {
* @param httpClient HttpClient instance
* @return true if NTLM is enabled
*/
- public static boolean hasNTLM(HttpClient httpClient) {
+ public static boolean hasNTLMorNegotiate(HttpClient httpClient) {
Object authPrefs = httpClient.getParams().getParameter(AuthPolicy.AUTH_SCHEME_PRIORITY);
- return authPrefs == null || (authPrefs instanceof List<?> && ((Collection) authPrefs).contains(AuthPolicy.NTLM));
+ return authPrefs == null || (authPrefs instanceof List<?> &&
+ (((Collection) authPrefs).contains(AuthPolicy.NTLM) || ((Collection) authPrefs).contains("Negotiate")));
}
/**
@@ -659,7 +660,7 @@ public final class DavGatewayHttpClientFacade {
method.setFollowRedirects(false);
int status = httpClient.executeMethod(method);
if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED
- && acceptsNTLMOnly(method) && !hasNTLM(httpClient)) {
+ && acceptsNTLMOnly(method) && !hasNTLMorNegotiate(httpClient)) {
resetMethod(method);
LOGGER.debug("Received " + status + " unauthorized at " + method.getURI() + ", retrying with NTLM");
addNTLM(httpClient);
@@ -682,7 +683,7 @@ public final class DavGatewayHttpClientFacade {
method.setFollowRedirects(followRedirects);
int status = httpClient.executeMethod(method);
if ((status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
- && acceptsNTLMOnly(method) && !hasNTLM(httpClient)) {
+ && acceptsNTLMOnly(method) && !hasNTLMorNegotiate(httpClient)) {
resetMethod(method);
LOGGER.debug("Received " + status + " unauthorized at " + method.getURI() + ", retrying with NTLM");
addNTLM(httpClient);
diff --git a/src/java/davmail/http/DavGatewaySSLProtocolSocketFactory.java b/src/java/davmail/http/DavGatewaySSLProtocolSocketFactory.java
index 6aa0ab7..33ff57b 100644
--- a/src/java/davmail/http/DavGatewaySSLProtocolSocketFactory.java
+++ b/src/java/davmail/http/DavGatewaySSLProtocolSocketFactory.java
@@ -107,8 +107,13 @@ public class DavGatewaySSLProtocolSocketFactory implements SecureProtocolSocketF
}
SunPKCS11ProviderHandler.registerProvider(pkcs11Buffer.toString());
}
-
- KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(/*KeyManagerFactory.getDefaultAlgorithm()*/"NewSunX509");
+ String algorithm = KeyManagerFactory.getDefaultAlgorithm();
+ if ("SunX509".equals(algorithm)) {
+ algorithm = "NewSunX509";
+ } else if ("IbmX509".equals(algorithm)) {
+ algorithm = "NewIbmX509";
+ }
+ KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
ArrayList<KeyStore.Builder> keyStoreBuilders = new ArrayList<KeyStore.Builder>();
// PKCS11 (smartcard) keystore with password callback
diff --git a/src/java/davmail/http/KerberosHelper.java b/src/java/davmail/http/KerberosHelper.java
new file mode 100644
index 0000000..3e40322
--- /dev/null
+++ b/src/java/davmail/http/KerberosHelper.java
@@ -0,0 +1,339 @@
+/*
+ * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
+ * Copyright (C) 2012 Mickael Guessant
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package davmail.http;
+
+import davmail.Settings;
+import davmail.ui.CredentialPromptDialog;
+import org.apache.log4j.Logger;
+import org.ietf.jgss.*;
+
+import javax.security.auth.RefreshFailedException;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.*;
+import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.awt.GraphicsEnvironment;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.security.PrivilegedAction;
+import java.security.Security;
+
+
+/**
+ * Kerberos helper class.
+ */
+public class KerberosHelper {
+ protected static final Logger LOGGER = Logger.getLogger(KerberosHelper.class);
+ protected static final Object LOCK = new Object();
+ protected static final KerberosCallbackHandler KERBEROS_CALLBACK_HANDLER;
+ protected static LoginContext clientLoginContext;
+
+ static {
+ // Load Jaas configuration from class
+ Security.setProperty("login.configuration.provider", "davmail.http.KerberosLoginConfiguration");
+ // Kerberos callback handler singleton
+ KERBEROS_CALLBACK_HANDLER = new KerberosCallbackHandler();
+ }
+
+ protected static class KerberosCallbackHandler implements CallbackHandler {
+ String principal;
+ String password;
+
+ protected KerberosCallbackHandler() {
+ }
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof NameCallback) {
+ if (principal == null) {
+ // if we get there kerberos token is missing or invalid
+ if (Settings.getBooleanProperty("davmail.server") || GraphicsEnvironment.isHeadless()) {
+ // headless or server mode
+ System.out.print(((NameCallback) callbacks[i]).getPrompt());
+ BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));
+ principal = inReader.readLine();
+ } else {
+ CredentialPromptDialog credentialPromptDialog = new CredentialPromptDialog(((NameCallback) callbacks[i]).getPrompt());
+ principal = credentialPromptDialog.getPrincipal();
+ password = String.valueOf(credentialPromptDialog.getPassword());
+ }
+ }
+ if (principal == null) {
+ throw new IOException("KerberosCallbackHandler: failed to retrieve principal");
+ }
+ ((NameCallback) callbacks[i]).setName(principal);
+
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ if (password == null) {
+ // if we get there kerberos token is missing or invalid
+ if (Settings.getBooleanProperty("davmail.server") || GraphicsEnvironment.isHeadless()) {
+ // headless or server mode
+ System.out.print(((PasswordCallback) callbacks[i]).getPrompt());
+ BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));
+ password = inReader.readLine();
+ }
+ }
+ if (password == null) {
+ throw new IOException("KerberosCallbackHandler: failed to retrieve password");
+ }
+ ((PasswordCallback) callbacks[i]).setPassword(password.toCharArray());
+
+ } else {
+ throw new UnsupportedCallbackException(callbacks[i]);
+ }
+ }
+ }
+ }
+
+ public static void setPrincipal(String principal) {
+ KERBEROS_CALLBACK_HANDLER.principal = principal;
+ }
+
+ public static void setPassword(String password) {
+ KERBEROS_CALLBACK_HANDLER.password = password;
+ }
+
+ /**
+ * Get response Kerberos token for host with provided token.
+ *
+ * @param protocol target protocol
+ * @param host target host
+ * @param token input token
+ * @return response token
+ * @throws GSSException on error
+ * @throws LoginException on error
+ */
+ public static byte[] initSecurityContext(final String protocol, final String host, final byte[] token) throws GSSException, LoginException {
+ return initSecurityContext(protocol, host, null, token);
+ }
+
+ /**
+ * Get response Kerberos token for host with provided token, use client provided delegation credentials.
+ * Used to authenticate with target host on a gateway server with client credentials,
+ * gateway must have its own principal authorized for delegation
+ *
+ * @param protocol target protocol
+ * @param host target host
+ * @param delegatedCredentials client delegated credentials
+ * @param token input token
+ * @return response token
+ * @throws GSSException on error
+ * @throws LoginException on error
+ */
+ public static byte[] initSecurityContext(final String protocol, final String host, final GSSCredential delegatedCredentials, final byte[] token) throws GSSException, LoginException {
+ LOGGER.debug("KerberosHelper.initSecurityContext " + protocol + "/" + host + " " + token.length + " bytes token");
+
+ // create client login context
+ clientLogin();
+
+ Object result = internalInitSecContext(protocol, host, delegatedCredentials, token);
+ if (result instanceof GSSException) {
+ LOGGER.info("KerberosHelper.initSecurityContext exception code " + ((GSSException) result).getMajor() + " minor code " + ((GSSException) result).getMinor() + " message " + ((GSSException) result).getMessage());
+ throw (GSSException) result;
+ }
+
+ LOGGER.debug("KerberosHelper.initSecurityContext return " + ((byte[]) result).length + " bytes token");
+ return (byte[]) result;
+ }
+
+ protected static Object internalInitSecContext(final String protocol, final String host, final GSSCredential delegatedCredentials, final byte[] token) {
+ return Subject.doAs(clientLoginContext.getSubject(), new PrivilegedAction() {
+
+ public Object run() {
+ Object result;
+ GSSContext context = null;
+ try {
+ GSSManager manager = GSSManager.getInstance();
+ GSSName serverName = manager.createName(protocol + "/" + host, null);
+ // Kerberos v5 OID
+ Oid krb5Oid = new Oid("1.2.840.113554.1.2.2");
+
+ context = manager.createContext(serverName, krb5Oid, delegatedCredentials, GSSContext.DEFAULT_LIFETIME);
+
+ //context.requestMutualAuth(true);
+ // TODO: used by IIS to pass token to Exchange ?
+ context.requestCredDeleg(true);
+
+ result = context.initSecContext(token, 0, token.length);
+ } catch (GSSException e) {
+ result = e;
+ } finally {
+ if (context != null) {
+ try {
+ context.dispose();
+ } catch (GSSException e) {
+ LOGGER.debug("KerberosHelper.internalInitSecContext " + e + " " + e.getMessage());
+ }
+ }
+ }
+ return result;
+ }
+ });
+ }
+
+ /**
+ * Create client Kerberos context.
+ *
+ * @throws LoginException on error
+ */
+ public static void clientLogin() throws LoginException {
+ synchronized (LOCK) {
+ if (clientLoginContext != null) {
+ // check cached TGT
+ for (Object ticket : clientLoginContext.getSubject().getPrivateCredentials(KerberosTicket.class)) {
+ KerberosTicket kerberosTicket = (KerberosTicket) ticket;
+ if (kerberosTicket.getServer().getName().startsWith("krbtgt") && !kerberosTicket.isCurrent()) {
+ LOGGER.debug("KerberosHelper.clientLogin cached TGT expired, try to relogin");
+ clientLoginContext = null;
+ }
+ }
+ }
+ if (clientLoginContext == null) {
+ final LoginContext localLoginContext = new LoginContext("spnego-client", KERBEROS_CALLBACK_HANDLER);
+ localLoginContext.login();
+ clientLoginContext = localLoginContext;
+ }
+ // try to renew almost expired tickets
+ for (Object ticket : clientLoginContext.getSubject().getPrivateCredentials(KerberosTicket.class)) {
+ KerberosTicket kerberosTicket = (KerberosTicket) ticket;
+ LOGGER.debug("KerberosHelper.clientLogin ticket for " + kerberosTicket.getServer().getName() + " expires at " + kerberosTicket.getEndTime());
+ if (kerberosTicket.getEndTime().getTime() < System.currentTimeMillis() + 10000) {
+ if (kerberosTicket.isRenewable()) {
+ try {
+ kerberosTicket.refresh();
+ } catch (RefreshFailedException e) {
+ LOGGER.debug("KerberosHelper.clientLogin failed to renew ticket " + kerberosTicket.toString());
+ }
+ } else {
+ LOGGER.debug("KerberosHelper.clientLogin ticket is not renewable");
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create server side Kerberos login context for provided credentials.
+ *
+ * @param principal server principal
+ * @param password server passsword
+ * @return LoginContext server login context
+ * @throws LoginException on error
+ */
+ public static LoginContext serverLogin(final String principal, final String password) throws LoginException {
+ LoginContext serverLoginContext = new LoginContext("spnego-server", new CallbackHandler() {
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof NameCallback) {
+ final NameCallback nameCallback = (NameCallback) callbacks[i];
+ nameCallback.setName(principal);
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ final PasswordCallback passCallback = (PasswordCallback) callbacks[i];
+ passCallback.setPassword(password.toCharArray());
+ } else {
+ throw new UnsupportedCallbackException(callbacks[i]);
+ }
+ }
+
+ }
+ });
+ serverLoginContext.login();
+ return serverLoginContext;
+ }
+
+ /**
+ * Contains server Kerberos context information in server mode.
+ */
+ public static class SecurityContext {
+ /**
+ * response token
+ */
+ public byte[] token;
+ /**
+ * authenticated principal
+ */
+ public String principal;
+ /**
+ * client delegated credential
+ */
+ public GSSCredential clientCredential;
+ }
+
+ /**
+ * Check client provided Kerberos token in server login context
+ *
+ * @param serverLoginContext server login context
+ * @param token Kerberos client token
+ * @return result with client principal and optional returned Kerberos token
+ * @throws GSSException on error
+ */
+ public static SecurityContext acceptSecurityContext(LoginContext serverLoginContext, final byte[] token) throws GSSException {
+ Object result = Subject.doAs(serverLoginContext.getSubject(), new PrivilegedAction() {
+
+ public Object run() {
+ Object result;
+ SecurityContext securityContext = new SecurityContext();
+ GSSContext context = null;
+ try {
+ GSSManager manager = GSSManager.getInstance();
+
+ // get server credentials from context
+ Oid krb5oid = new Oid("1.2.840.113554.1.2.2");
+ GSSCredential serverCreds = manager.createCredential(null/* use name from login context*/,
+ GSSCredential.DEFAULT_LIFETIME,
+ krb5oid,
+ GSSCredential.ACCEPT_ONLY/* server mode */);
+ context = manager.createContext(serverCreds);
+
+ securityContext.token = context.acceptSecContext(token, 0, token.length);
+ if (context.isEstablished()) {
+ securityContext.principal = context.getSrcName().toString();
+ LOGGER.debug("Authenticated user: " + securityContext.principal);
+ if (!context.getCredDelegState()) {
+ LOGGER.debug("Credentials can not be delegated");
+ } else {
+ // Get client delegated credentials from context (gateway mode)
+ securityContext.clientCredential = context.getDelegCred();
+ }
+ }
+ result = securityContext;
+ } catch (GSSException e) {
+ result = e;
+ } finally {
+ if (context != null) {
+ try {
+ context.dispose();
+ } catch (GSSException e) {
+ LOGGER.debug("KerberosHelper.acceptSecurityContext " + e + " " + e.getMessage());
+ }
+ }
+ }
+ return result;
+ }
+ });
+ if (result instanceof GSSException) {
+ LOGGER.info("KerberosHelper.acceptSecurityContext exception code " + ((GSSException) result).getMajor() + " minor code " + ((GSSException) result).getMinor() + " message " + ((GSSException) result).getMessage());
+ throw (GSSException) result;
+ }
+ return (SecurityContext) result;
+ }
+}
diff --git a/src/java/davmail/http/KerberosLoginConfiguration.java b/src/java/davmail/http/KerberosLoginConfiguration.java
new file mode 100644
index 0000000..8a7a19a
--- /dev/null
+++ b/src/java/davmail/http/KerberosLoginConfiguration.java
@@ -0,0 +1,86 @@
+/*
+ * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
+ * Copyright (C) 2012 Mickael Guessant
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package davmail.http;
+
+import org.apache.log4j.Logger;
+
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import java.util.HashMap;
+
+/**
+ * Custom JAAS login configuration.
+ * Equivalent to the following configuration:
+ * spnego-client {
+ * com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true renewTGT=true;
+ * };
+ * spnego-server {
+ * com.sun.security.auth.module.Krb5LoginModule required isInitiator=false useKeyTab=false storeKey=true;
+ * };
+ * <p/>
+ */
+public class KerberosLoginConfiguration extends Configuration {
+ protected static final Logger LOGGER = Logger.getLogger(KerberosLoginConfiguration.class);
+ protected static final AppConfigurationEntry[] CLIENT_LOGIN_MODULE;
+ protected static final AppConfigurationEntry[] SERVER_LOGIN_MODULE;
+
+ static {
+ HashMap<String, String> clientLoginModuleOptions = new HashMap<String, String>();
+ if (LOGGER.isDebugEnabled()) {
+ clientLoginModuleOptions.put("debug", "true");
+ }
+
+ clientLoginModuleOptions.put("useTicketCache", "true");
+ clientLoginModuleOptions.put("renewTGT", "true");
+ //clientLoginModuleOptions.put("doNotPrompt", "true");
+ String krb5ccName = System.getenv().get("KRB5CCNAME");
+ if (krb5ccName != null && krb5ccName.length() > 0) {
+ clientLoginModuleOptions.put("ticketCache", krb5ccName);
+ }
+ //clientLoginModuleOptions.put("ticketCache", FileCredentialsCache.getDefaultCacheName());
+ //clientLoginModuleOptions.put("refreshKrb5Config", "true");
+ //clientLoginModuleOptions.put("storeKey", "true");
+ CLIENT_LOGIN_MODULE = new AppConfigurationEntry[]{new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, clientLoginModuleOptions)};
+
+ HashMap<String, String> serverLoginModuleOptions = new HashMap<String, String>();
+ if (LOGGER.isDebugEnabled()) {
+ serverLoginModuleOptions.put("debug", "true");
+ }
+
+ serverLoginModuleOptions.put("isInitiator", "false"); // acceptor (server) mode
+ serverLoginModuleOptions.put("useKeyTab", "false"); // do not use credentials stored in keytab file
+ serverLoginModuleOptions.put("storeKey", "true"); // store credentials in subject
+ SERVER_LOGIN_MODULE = new AppConfigurationEntry[]{new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, serverLoginModuleOptions)};
+ }
+
+ @Override
+ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
+ if ("spnego-client".equals(name)) {
+ return CLIENT_LOGIN_MODULE;
+ } else if ("spnego-server".equals(name)) {
+ return SERVER_LOGIN_MODULE;
+ } else {
+ return null;
+ }
+ }
+
+ public void refresh() {
+ // nothing to do
+ }
+}
\ No newline at end of file
diff --git a/src/java/davmail/http/SpNegoScheme.java b/src/java/davmail/http/SpNegoScheme.java
new file mode 100644
index 0000000..b7701d1
--- /dev/null
+++ b/src/java/davmail/http/SpNegoScheme.java
@@ -0,0 +1,217 @@
+/*
+ * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
+ * Copyright (C) 2012 Mickael Guessant
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package davmail.http;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.auth.*;
+import org.apache.commons.httpclient.util.EncodingUtil;
+import org.ietf.jgss.GSSException;
+
+import javax.security.auth.login.LoginException;
+
+/**
+ * Implement spnego (Negotiate) authentication scheme.
+ */
+public class SpNegoScheme implements AuthScheme {
+ private static final int UNINITIATED = 0;
+ private static final int INITIATED = 1;
+ private static final int TYPE1_MSG_GENERATED = 2;
+ private static final int TYPE2_MSG_RECEIVED = 3;
+ private static final int TYPE3_MSG_GENERATED = 4;
+ private static final int FAILED = Integer.MAX_VALUE;
+
+ private byte[] serverToken;
+ /**
+ * Authentication process state
+ */
+ private int state;
+
+ /**
+ * Processes the Negotiate challenge.
+ *
+ * @param challenge the challenge string
+ * @throws MalformedChallengeException is thrown if the authentication challenge is malformed
+ */
+ public void processChallenge(final String challenge) throws MalformedChallengeException {
+ String authScheme = AuthChallengeParser.extractScheme(challenge);
+ if (!authScheme.equalsIgnoreCase(getSchemeName())) {
+ throw new MalformedChallengeException("Invalid Negotiate challenge: " + challenge);
+ }
+ int spaceIndex = challenge.indexOf(' ');
+ if (spaceIndex != -1) {
+ // step 2: received server challenge
+ serverToken = Base64.decodeBase64(EncodingUtil.getBytes(
+ challenge.substring(spaceIndex, challenge.length()).trim(), "ASCII"));
+ this.state = TYPE2_MSG_RECEIVED;
+ } else {
+ this.serverToken = null;
+ if (this.state == UNINITIATED) {
+ this.state = INITIATED;
+ } else {
+ this.state = FAILED;
+ }
+ }
+ }
+
+
+ /**
+ * Returns textual designation of the Negotiate authentication scheme.
+ *
+ * @return <code>Negotiate</code>
+ */
+ public String getSchemeName() {
+ return "Negotiate";
+ }
+
+ /**
+ * Not used with Negotiate.
+ *
+ * @return null
+ */
+ public String getParameter(String s) {
+ return null;
+ }
+
+ /**
+ * Not used with Negotiate.
+ *
+ * @return null
+ */
+ public String getRealm() {
+ return null;
+ }
+
+ /**
+ * Deprecated.
+ */
+ @Deprecated
+ public String getID() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Negotiate is connection based.
+ *
+ * @return true
+ */
+ public boolean isConnectionBased() {
+ return true;
+ }
+
+ /**
+ * Tests if the Negotiate authentication process has been completed.
+ *
+ * @return <tt>true</tt> if authorization has been processed
+ */
+ public boolean isComplete() {
+ return state == TYPE3_MSG_GENERATED || state == FAILED;
+ }
+
+ /**
+ * Not implemented.
+ *
+ * @param credentials user credentials
+ * @param method method name
+ * @param uri URI
+ * @return an Negotiate authorization string
+ * @throws org.apache.commons.httpclient.auth.InvalidCredentialsException
+ * if authentication credentials
+ * are not valid or not applicable for this authentication scheme
+ * @throws org.apache.commons.httpclient.auth.AuthenticationException
+ * if authorization string cannot
+ * be generated due to an authentication failure
+ */
+ @Deprecated
+ public String authenticate(final Credentials credentials, String method, String uri) throws AuthenticationException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Produces Negotiate authorization string for the given set of
+ * {@link Credentials}.
+ *
+ * @param credentials The set of credentials to be used for authentication
+ * @param httpMethod The method being authenticated
+ * @return an Negotiate authorization string
+ * @throws org.apache.commons.httpclient.auth.InvalidCredentialsException
+ * if authentication credentials
+ * are not valid or not applicable for this authentication scheme
+ * @throws AuthenticationException if authorization string cannot
+ * be generated due to an authentication failure
+ */
+ public String authenticate(Credentials credentials, HttpMethod httpMethod) throws AuthenticationException {
+ if (this.state == UNINITIATED) {
+ throw new IllegalStateException("Negotiate authentication process has not been initiated");
+ }
+ String host = null;
+ try {
+ host = httpMethod.getURI().getHost();
+ } catch (URIException e) {
+ // ignore
+ }
+ if (host == null) {
+ Header header = httpMethod.getRequestHeader("Host");
+ if (header != null) {
+ host = header.getValue();
+ if (host.indexOf(':') >= 0) {
+ host = host.substring(0, host.indexOf(':'));
+ }
+ }
+ }
+ if (host == null) {
+ throw new IllegalStateException("Negotiate authentication failed: empty host");
+ }
+
+ // no credentials needed
+ String response;
+ try {
+ if (this.state == INITIATED || this.state == FAILED) {
+ // send initial token to server
+ response = EncodingUtil.getAsciiString(Base64.encodeBase64(KerberosHelper.initSecurityContext("HTTP", host, new byte[0])));
+ this.state = TYPE1_MSG_GENERATED;
+ } else {
+ // send challenge response
+ response = EncodingUtil.getAsciiString(Base64.encodeBase64(KerberosHelper.initSecurityContext("HTTP", host, serverToken)));
+ this.state = TYPE3_MSG_GENERATED;
+ }
+ } catch (GSSException gsse) {
+ state = FAILED;
+ if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
+ || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
+ throw new InvalidCredentialsException(gsse.getMessage(), gsse);
+ if (gsse.getMajor() == GSSException.NO_CRED)
+ throw new CredentialsNotAvailableException(gsse.getMessage(), gsse);
+ if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
+ || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
+ || gsse.getMajor() == GSSException.OLD_TOKEN)
+ throw new AuthChallengeException(gsse.getMessage(), gsse);
+ // other error
+ throw new AuthenticationException(gsse.getMessage(), gsse);
+ } catch (LoginException e) {
+ state = FAILED;
+ throw new InvalidCredentialsException(e.getMessage(), e);
+ }
+ return "Negotiate " + response;
+ }
+
+}
diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java
index b42004e..772fba7 100644
--- a/src/java/davmail/imap/ImapConnection.java
+++ b/src/java/davmail/imap/ImapConnection.java
@@ -115,7 +115,11 @@ public class ImapConnection extends AbstractConnection {
state = State.AUTHENTICATED;
} catch (Exception e) {
DavGatewayTray.error(e);
- sendClient(commandId + " NO LOGIN failed");
+ if (Settings.getBooleanProperty("davmail.enableKerberos")) {
+ sendClient(commandId + " NO LOGIN Kerberos authentication failed");
+ } else {
+ sendClient(commandId + " NO LOGIN failed");
+ }
state = State.INITIAL;
}
} else if ("AUTHENTICATE".equalsIgnoreCase(command)) {
@@ -162,11 +166,11 @@ public class ImapConnection extends AbstractConnection {
if (tokens.hasMoreTokens()) {
String folderQuery = folderContext + BASE64MailboxDecoder.decode(tokens.nextToken());
if (folderQuery.endsWith("%/%") && !"/%/%".equals(folderQuery)) {
- List<ExchangeSession.Folder> folders = session.getSubFolders(folderQuery.substring(0, folderQuery.length() - 3), false);
- for (ExchangeSession.Folder folder : folders) {
- sendClient("* " + command + " (" + folder.getFlags() + ") \"/\" \"" + BASE64MailboxEncoder.encode(folder.folderPath) + '\"');
- sendSubFolders(command, folder.folderPath, false);
- }
+ List<ExchangeSession.Folder> folders = session.getSubFolders(folderQuery.substring(0, folderQuery.length() - 3), false);
+ for (ExchangeSession.Folder folder : folders) {
+ sendClient("* " + command + " (" + folder.getFlags() + ") \"/\" \"" + BASE64MailboxEncoder.encode(folder.folderPath) + '\"');
+ sendSubFolders(command, folder.folderPath, false);
+ }
sendClient(commandId + " OK " + command + " completed");
} else if (folderQuery.endsWith("%") || folderQuery.endsWith("*")) {
if ("/*".equals(folderQuery) || "/%".equals(folderQuery) || "/%/%".equals(folderQuery)) {
@@ -300,7 +304,7 @@ public class ImapConnection extends AbstractConnection {
try {
handleFetch(message, uidRangeIterator.currentIndex, parameters);
} catch (HttpNotFoundException e) {
- LOGGER.warn("Ignore missing message "+uidRangeIterator.currentIndex);
+ LOGGER.warn("Ignore missing message " + uidRangeIterator.currentIndex);
} catch (SocketException e) {
// client closed connection
throw e;
@@ -386,7 +390,7 @@ public class ImapConnection extends AbstractConnection {
try {
handleFetch(message, rangeIterator.currentIndex, parameters);
} catch (HttpNotFoundException e) {
- LOGGER.warn("Ignore missing message "+rangeIterator.currentIndex);
+ LOGGER.warn("Ignore missing message " + rangeIterator.currentIndex);
} catch (SocketException e) {
// client closed connection, rethrow exception
throw e;
@@ -517,7 +521,7 @@ public class ImapConnection extends AbstractConnection {
while (in.available() == 0) {
if (++count >= imapIdleDelay) {
count = 0;
- TreeMap<Long,String> previousImapFlagMap = currentFolder.getImapFlagMap();
+ TreeMap<Long, String> previousImapFlagMap = currentFolder.getImapFlagMap();
if (session.refreshFolder(currentFolder)) {
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
}
@@ -542,7 +546,7 @@ public class ImapConnection extends AbstractConnection {
} else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) {
if (currentFolder != null) {
DavGatewayTray.debug(new BundleMessage("LOG_IMAP_COMMAND", command, currentFolder.folderPath));
- TreeMap<Long,String> previousImapFlagMap = currentFolder.getImapFlagMap();
+ TreeMap<Long, String> previousImapFlagMap = currentFolder.getImapFlagMap();
if (session.refreshFolder(currentFolder)) {
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
}
@@ -691,16 +695,16 @@ public class ImapConnection extends AbstractConnection {
* @param imapUidList uid list after refresh
* @throws IOException on error
*/
- private void handleRefresh(TreeMap<Long,String> previousImapFlagMap, TreeMap<Long,String> imapFlagMap) throws IOException {
+ private void handleRefresh(TreeMap<Long, String> previousImapFlagMap, TreeMap<Long, String> imapFlagMap) throws IOException {
// send deleted message expunge notification
int index = 1;
for (long previousImapUid : previousImapFlagMap.keySet()) {
if (!imapFlagMap.keySet().contains(previousImapUid)) {
sendClient("* " + index + " EXPUNGE");
} else {
- // send updated flags
+ // send updated flags
if (!previousImapFlagMap.get(previousImapUid).equals(imapFlagMap.get(previousImapUid))) {
- sendClient("* " + index + " FETCH (UID "+previousImapUid+" FLAGS ("+imapFlagMap.get(previousImapUid)+"))");
+ sendClient("* " + index + " FETCH (UID " + previousImapUid + " FLAGS (" + imapFlagMap.get(previousImapUid) + "))");
}
index++;
}
@@ -722,7 +726,9 @@ public class ImapConnection extends AbstractConnection {
buffer.append(" FLAGS (").append(message.getImapFlags()).append(')');
} else if ("RFC822.SIZE".equals(param)) {
int size;
- if (parameters.indexOf("BODY.PEEK[HEADER.FIELDS (") >= 0) {
+ if (parameters.indexOf("BODY.PEEK[HEADER.FIELDS (") >= 0
+ // exclude mutt header request
+ && parameters.indexOf("X-LABEL") < 0) {
// Header request, send approximate size
size = message.size;
} else {
@@ -949,7 +955,7 @@ public class ImapConnection extends AbstractConnection {
iterator = new RangeIterator(currentFolder.messages, conditions.indexRange);
localMessagesUidList = new ArrayList<Long>();
// build search result uid list
- for (ExchangeSession.Message message:localMessages) {
+ for (ExchangeSession.Message message : localMessages) {
localMessagesUidList.add(message.getImapUid());
}
} else {
diff --git a/src/java/davmail/ui/PasswordPromptDialog.java b/src/java/davmail/ui/CredentialPromptDialog.java
similarity index 53%
copy from src/java/davmail/ui/PasswordPromptDialog.java
copy to src/java/davmail/ui/CredentialPromptDialog.java
index cb7cee3..276fc25 100644
--- a/src/java/davmail/ui/PasswordPromptDialog.java
+++ b/src/java/davmail/ui/CredentialPromptDialog.java
@@ -1,37 +1,20 @@
-/*
- * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
- * Copyright (C) 2009 Mickael Guessant
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package davmail.ui;
import davmail.BundleMessage;
import davmail.ui.tray.DavGatewayTray;
import javax.swing.*;
-import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
- * Get smartcard password
+ * Prompt for Exchange credential and password.
*/
-public class PasswordPromptDialog extends JDialog {
- final JPasswordField passwordField = new JPasswordField(20);
+public class CredentialPromptDialog extends JDialog {
+ final JTextField principalField = new JTextField(15);
+ final JPasswordField passwordField = new JPasswordField(15);
+ protected String principal;
protected char[] password;
/**
@@ -47,25 +30,20 @@ public class PasswordPromptDialog extends JDialog {
}
}
- /**
- * Get smartcard password.
- *
- * @param prompt password prompt from PKCS11 module
- */
- public PasswordPromptDialog(String prompt) {
- this(prompt, null);
+ public String getPrincipal() {
+ return principal;
}
/**
- * Get smartcard password.
+ * Get credentials.
*
- * @param prompt password prompt from PKCS11 module
- * @param captchaImage ISA filter pinsafe image
+ * @param prompt Kerberos prompt from callback handler
*/
- public PasswordPromptDialog(String prompt, Image captchaImage) {
+ public CredentialPromptDialog(String prompt) {
setAlwaysOnTop(true);
- setTitle(BundleMessage.format("UI_PASSWORD_PROMPT"));
+ setTitle(BundleMessage.format("UI_KERBEROS_CREDENTIAL_PROMPT"));
+
try {
//noinspection Since15
setIconImage(DavGatewayTray.getFrameIcon());
@@ -78,28 +56,37 @@ public class PasswordPromptDialog extends JDialog {
questionPanel.setLayout(new BoxLayout(questionPanel, BoxLayout.Y_AXIS));
JLabel imageLabel = new JLabel();
imageLabel.setIcon(UIManager.getIcon("OptionPane.questionIcon"));
- imageLabel.setText(prompt);
questionPanel.add(imageLabel);
passwordField.setMaximumSize(passwordField.getPreferredSize());
passwordField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
+ principal = principalField.getText();
password = passwordField.getPassword();
setVisible(false);
}
});
- JPanel passwordPanel = new JPanel();
- passwordPanel.setLayout(new BoxLayout(passwordPanel, BoxLayout.Y_AXIS));
- if (captchaImage != null) {
- JLabel captchaLabel = new JLabel(new ImageIcon(captchaImage));
- captchaLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
- captchaLabel.setBorder(new EmptyBorder(10,10,10,10));
- passwordPanel.add(captchaLabel);
- }
- passwordPanel.add(passwordField);
+ JPanel credentialPanel = new JPanel(new GridLayout(2, 2));
+
+ JLabel promptLabel = new JLabel(" "+prompt.trim());
+ promptLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+ promptLabel.setVerticalAlignment(SwingConstants.CENTER);
- add(questionPanel, BorderLayout.NORTH);
- add(passwordPanel, BorderLayout.CENTER);
+ credentialPanel.add(promptLabel);
+
+ principalField.setMaximumSize(principalField.getPreferredSize());
+ credentialPanel.add(principalField);
+
+ JLabel passwordLabel = new JLabel(BundleMessage.format("UI_KERBEROS_PASSWORD_PROMPT"));
+ passwordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+ passwordLabel.setVerticalAlignment(SwingConstants.CENTER);
+ credentialPanel.add(passwordLabel);
+
+ passwordField.setMaximumSize(passwordField.getPreferredSize());
+ credentialPanel.add(passwordField);
+
+ add(questionPanel, BorderLayout.WEST);
+ add(credentialPanel, BorderLayout.CENTER);
add(getButtonPanel(), BorderLayout.SOUTH);
setModal(true);
@@ -109,7 +96,7 @@ public class PasswordPromptDialog extends JDialog {
getSize().width / 2,
getToolkit().getScreenSize().height / 2 -
getSize().height / 2);
- setAlwaysOnTop(true);
+ setAlwaysOnTop(true);
setVisible(true);
}
@@ -119,12 +106,14 @@ public class PasswordPromptDialog extends JDialog {
JButton cancelButton = new JButton(BundleMessage.format("UI_BUTTON_CANCEL"));
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
+ principal = principalField.getText();
password = passwordField.getPassword();
setVisible(false);
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
+ principal = null;
password = null;
setVisible(false);
}
diff --git a/src/java/davmail/ui/SettingsFrame.java b/src/java/davmail/ui/SettingsFrame.java
index b200bdd..2cce304 100644
--- a/src/java/davmail/ui/SettingsFrame.java
+++ b/src/java/davmail/ui/SettingsFrame.java
@@ -102,6 +102,7 @@ public class SettingsFrame extends JFrame {
JCheckBox imapAutoExpungeCheckBox;
JCheckBox popMarkReadOnRetrCheckBox;
JComboBox enableEwsComboBox;
+ JCheckBox enableKerberosCheckBox;
JCheckBox smtpSaveInSentCheckBox;
JCheckBox osxHideFromDockCheckBox;
@@ -145,10 +146,12 @@ public class SettingsFrame extends JFrame {
}
protected JPanel getSettingsPanel() {
- JPanel settingsPanel = new JPanel(new GridLayout(6, 2));
+ JPanel settingsPanel = new JPanel(new GridLayout(7, 2));
settingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_GATEWAY")));
- urlField = new JTextField(Settings.getProperty("davmail.url"), 17);
+ enableEwsComboBox = new JComboBox(new String[]{WEBDAV, EWS, AUTO});
+ setEwsModeSelectedItem(Settings.getProperty("davmail.enableEws", "auto"));
+ urlField = new JTextField(Settings.getProperty("davmail.url"), 20);
popPortField = new JTextField(Settings.getProperty("davmail.popPort"), 4);
popPortCheckBox = new JCheckBox();
popNoSSLCheckBox = new JCheckBox(BundleMessage.format("UI_NO_SSL"), Settings.getBooleanProperty("davmail.ssl.nosecurepop"));
@@ -214,6 +217,8 @@ public class SettingsFrame extends JFrame {
}
});
+ addSettingComponent(settingsPanel, BundleMessage.format("UI_ENABLE_EWS"), enableEwsComboBox,
+ BundleMessage.format("UI_ENABLE_EWS_HELP"));
addSettingComponent(settingsPanel, BundleMessage.format("UI_OWA_URL"), urlField, BundleMessage.format("UI_OWA_URL_HELP"));
addPortSettingComponent(settingsPanel, BundleMessage.format("UI_POP_PORT"), popPortField, popPortCheckBox,
popNoSSLCheckBox, BundleMessage.format("UI_POP_PORT_HELP"));
@@ -423,8 +428,8 @@ public class SettingsFrame extends JFrame {
JPanel otherSettingsPanel = new JPanel(new GridLayout(11, 2));
otherSettingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_OTHER")));
- enableEwsComboBox = new JComboBox(new String[]{WEBDAV, EWS, AUTO});
- setEwsModeSelectedItem(Settings.getProperty("davmail.enableEws", "auto"));
+ enableKerberosCheckBox = new JCheckBox();
+ enableKerberosCheckBox.setSelected(Settings.getBooleanProperty("davmail.enableKerberos"));
caldavEditNotificationsField = new JCheckBox();
caldavEditNotificationsField.setSelected(Settings.getBooleanProperty("davmail.caldavEditNotifications"));
caldavAlarmSoundField = new JTextField(Settings.getProperty("davmail.caldavAlarmSound"), 15);
@@ -444,8 +449,8 @@ public class SettingsFrame extends JFrame {
disableUpdateCheck = new JCheckBox();
disableUpdateCheck.setSelected(Settings.getBooleanProperty("davmail.disableUpdateCheck"));
- addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_ENABLE_EWS"), enableEwsComboBox,
- BundleMessage.format("UI_ENABLE_EWS_HELP"));
+ addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_ENABLE_KERBEROS"), enableKerberosCheckBox,
+ BundleMessage.format("UI_ENABLE_KERBEROS_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_CALDAV_EDIT_NOTIFICATIONS"), caldavEditNotificationsField,
BundleMessage.format("UI_CALDAV_EDIT_NOTIFICATIONS_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_CALDAV_ALARM_SOUND"), caldavAlarmSoundField,
@@ -598,6 +603,7 @@ public class SettingsFrame extends JFrame {
popMarkReadOnRetrCheckBox.setSelected(Settings.getBooleanProperty("davmail.popMarkReadOnRetrCheckBox", false));
setEwsModeSelectedItem(Settings.getProperty("davmail.enableEws", "auto"));
smtpSaveInSentCheckBox.setSelected(Settings.getBooleanProperty("davmail.smtpSaveInSent", true));
+ enableKerberosCheckBox.setSelected(Settings.getBooleanProperty("davmail.enableKerberos", false));
keystoreTypeCombo.setSelectedItem(Settings.getProperty("davmail.ssl.keystoreType"));
keystoreFileField.setText(Settings.getProperty("davmail.ssl.keystoreFile"));
@@ -766,6 +772,7 @@ public class SettingsFrame extends JFrame {
enableEws = "auto";
}
Settings.setProperty("davmail.enableEws", enableEws);
+ Settings.setProperty("davmail.enableKerberos", String.valueOf(enableKerberosCheckBox.isSelected()));
Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected()));
Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem());
diff --git a/src/java/davmail/util/StringUtil.java b/src/java/davmail/util/StringUtil.java
index c11674e..d09773f 100644
--- a/src/java/davmail/util/StringUtil.java
+++ b/src/java/davmail/util/StringUtil.java
@@ -24,7 +24,9 @@ import org.apache.commons.codec.binary.Hex;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@@ -128,80 +130,113 @@ public final class StringUtil {
}
}
+ static class PatternMap {
+ protected String match;
+ protected String value;
+ protected Pattern pattern;
+
+ protected PatternMap(String match, String value) {
+ this.match = match;
+ this.value = value;
+ pattern = Pattern.compile(match);
+ }
+
+ protected PatternMap(String match, String escapedMatch, String value) {
+ this.match = match;
+ this.value = value;
+ pattern = Pattern.compile(escapedMatch);
+ }
+
+ protected PatternMap(String match, Pattern pattern, String value) {
+ this.match = match;
+ this.value = value;
+ this.pattern = pattern;
+ }
+
+ protected String replaceAll(String string) {
+ if (string != null && string.indexOf(match) >= 0) {
+ return pattern.matcher(string).replaceAll(value);
+ } else {
+ return string;
+ }
+ }
+ }
+
private static final Pattern AMP_PATTERN = Pattern.compile("&");
- private static final Pattern LT_PATTERN = Pattern.compile("<");
- private static final Pattern GT_PATTERN = Pattern.compile(">");
- private static final Pattern PERCENT_PATTERN = Pattern.compile("%");
- private static final Pattern HASH_PATTERN = Pattern.compile("#");
- private static final Pattern STAR_PATTERN = Pattern.compile("\\*");
+ private static final Pattern PLUS_PATTERN = Pattern.compile("\\+");
private static final Pattern QUOTE_PATTERN = Pattern.compile("\"");
private static final Pattern CR_PATTERN = Pattern.compile("\r");
private static final Pattern LF_PATTERN = Pattern.compile("\n");
- private static final Pattern URLENCODED_F8FF_PATTERN = Pattern.compile(String.valueOf((char) 0xF8FF));
- private static final Pattern URLENCODED_AMP_PATTERN = Pattern.compile("%26");
- private static final Pattern URLENCODED_PLUS_PATTERN = Pattern.compile("%2B");
- private static final Pattern URLENCODED_COLON_PATTERN = Pattern.compile("%3A");
- private static final Pattern URLENCODED_SEMICOLON_PATTERN = Pattern.compile("%3B");
- private static final Pattern URLENCODED_LT_PATTERN = Pattern.compile("%3C");
- private static final Pattern URLENCODED_GT_PATTERN = Pattern.compile("%3E");
- private static final Pattern URLENCODED_QUOTE_PATTERN = Pattern.compile("%22");
- private static final Pattern URLENCODED_X0D0A_PATTERN = Pattern.compile("\n");
- private static final Pattern URLENCODED_PERCENT_PATTERN = Pattern.compile("%25");
- private static final Pattern URLENCODED_HASH_PATTERN = Pattern.compile("%23");
- private static final Pattern URLENCODED_STAR_PATTERN = Pattern.compile("%2A");
- private static final Pattern URLENCODED_PIPE_PATTERN = Pattern.compile("%7C");
- private static final Pattern URLENCODED_QUESTION_PATTERN = Pattern.compile("%3F");
-
- private static final Pattern ENCODED_AMP_PATTERN = Pattern.compile("&");
- private static final Pattern ENCODED_LT_PATTERN = Pattern.compile("<");
- private static final Pattern ENCODED_GT_PATTERN = Pattern.compile(">");
-
- private static final Pattern F8FF_PATTERN = Pattern.compile("_xF8FF_");
- private static final Pattern X0D0A_PATTERN = Pattern.compile("_x000D__x000A_");
+ private static final List<PatternMap> URLENCODED_PATTERNS = new ArrayList<PatternMap>();
+ static {
+ URLENCODED_PATTERNS.add(new PatternMap(String.valueOf((char) 0xF8FF), "_xF8FF_"));
+ URLENCODED_PATTERNS.add(new PatternMap("%26", "&"));
+ URLENCODED_PATTERNS.add(new PatternMap("%2B", "+"));
+ URLENCODED_PATTERNS.add(new PatternMap("%3A", ":"));
+ URLENCODED_PATTERNS.add(new PatternMap("%3B", ";"));
+ URLENCODED_PATTERNS.add(new PatternMap("%3C", "<"));
+ URLENCODED_PATTERNS.add(new PatternMap("%3E", ">"));
+ URLENCODED_PATTERNS.add(new PatternMap("%22", "\""));
+ URLENCODED_PATTERNS.add(new PatternMap("%23", "#"));
+ URLENCODED_PATTERNS.add(new PatternMap("%2A", "*"));
+ URLENCODED_PATTERNS.add(new PatternMap("%7C", "|"));
+ URLENCODED_PATTERNS.add(new PatternMap("%3F", "?"));
+ URLENCODED_PATTERNS.add(new PatternMap("%7E", "~"));
+
+ // CRLF is replaced with LF in response
+ URLENCODED_PATTERNS.add(new PatternMap("\n", "_x000D__x000A_"));
+
+ // last replace %
+ URLENCODED_PATTERNS.add(new PatternMap("%25", "%"));
+ }
+
+ private static final List<PatternMap> URLENCODE_PATTERNS = new ArrayList<PatternMap>();
+ static {
+ // first replace %
+ URLENCODE_PATTERNS.add(new PatternMap("%", "%25"));
+
+ URLENCODE_PATTERNS.add(new PatternMap("_xF8FF_", String.valueOf((char) 0xF8FF)));
+ URLENCODE_PATTERNS.add(new PatternMap("&", AMP_PATTERN, "%26"));
+ URLENCODE_PATTERNS.add(new PatternMap("+", PLUS_PATTERN, "%2B"));
+ URLENCODE_PATTERNS.add(new PatternMap(":", "%3A"));
+ URLENCODE_PATTERNS.add(new PatternMap(";", "%3B"));
+ URLENCODE_PATTERNS.add(new PatternMap("<", "%3C"));
+ URLENCODE_PATTERNS.add(new PatternMap(">", "%3E"));
+ URLENCODE_PATTERNS.add(new PatternMap("\"", "%22"));
+ URLENCODE_PATTERNS.add(new PatternMap("#", "%23"));
+ URLENCODE_PATTERNS.add(new PatternMap("~", "%7E"));
+ URLENCODE_PATTERNS.add(new PatternMap("*", "\\*", "%2A"));
+ URLENCODE_PATTERNS.add(new PatternMap("|", "\\|", "%7C"));
+ URLENCODE_PATTERNS.add(new PatternMap("?", "\\?", "%3F"));
+
+ URLENCODE_PATTERNS.add(new PatternMap("_x000D__x000A_", "\r\n"));
+
+ }
+
+ private static final List<PatternMap> XML_DECODE_PATTERNS = new ArrayList<PatternMap>();
+ static {
+ XML_DECODE_PATTERNS.add(new PatternMap("&", "&"));
+ XML_DECODE_PATTERNS.add(new PatternMap("<", "<"));
+ XML_DECODE_PATTERNS.add(new PatternMap(">", ">"));
+ }
+
+ private static final List<PatternMap> XML_ENCODE_PATTERNS = new ArrayList<PatternMap>();
+ static {
+ XML_ENCODE_PATTERNS.add(new PatternMap("&", AMP_PATTERN, "&"));
+ XML_ENCODE_PATTERNS.add(new PatternMap("<", "<"));
+ XML_ENCODE_PATTERNS.add(new PatternMap(">", ">"));
+ }
- private static final Pattern PLUS_PATTERN = Pattern.compile("\\+");
- private static final Pattern COLON_PATTERN = Pattern.compile(":");
- private static final Pattern SEMICOLON_PATTERN = Pattern.compile(";");
private static final Pattern SLASH_PATTERN = Pattern.compile("/");
private static final Pattern UNDERSCORE_PATTERN = Pattern.compile("_");
private static final Pattern DASH_PATTERN = Pattern.compile("-");
- private static final Pattern PIPE_PATTERN = Pattern.compile("\\|");
- private static final Pattern QUESTION_PATTERN = Pattern.compile("\\?");
// WebDav search parameter encode
private static final Pattern APOS_PATTERN = Pattern.compile("'");
/**
- * Encode & to %26 for urlcompname.
- *
- * @param name decoded name
- * @return name encoded name
- */
- public static String urlEncodeAmpersand(String name) {
- String result = name;
- if (name.indexOf('&') >= 0) {
- result = AMP_PATTERN.matcher(result).replaceAll("%26");
- }
- return result;
- }
-
- /**
- * Decode %26 to & for urlcompname.
- *
- * @param name decoded name
- * @return name encoded name
- */
- public static String urlDecodeAmpersand(String name) {
- String result = name;
- if (name != null && name.indexOf("%26") >= 0) {
- result = URLENCODED_AMP_PATTERN.matcher(result).replaceAll("&");
- }
- return result;
- }
-
- /**
* Xml encode content.
*
* @param name decoded name
@@ -209,15 +244,9 @@ public final class StringUtil {
*/
public static String xmlEncode(String name) {
String result = name;
- if (name != null) {
- if (name.indexOf('&') >= 0) {
- result = AMP_PATTERN.matcher(result).replaceAll("&");
- }
- if (name.indexOf('<') >= 0) {
- result = LT_PATTERN.matcher(result).replaceAll("<");
- }
- if (name.indexOf('>') >= 0) {
- result = GT_PATTERN.matcher(result).replaceAll(">");
+ if (result != null) {
+ for (PatternMap patternMap : XML_ENCODE_PATTERNS) {
+ result = patternMap.replaceAll(result);
}
}
return result;
@@ -253,14 +282,10 @@ public final class StringUtil {
*/
public static String xmlDecode(String name) {
String result = name;
- if (name.indexOf("&") >= 0) {
- result = ENCODED_AMP_PATTERN.matcher(result).replaceAll("&");
- }
- if (name.indexOf("<") >= 0) {
- result = ENCODED_LT_PATTERN.matcher(result).replaceAll("<");
- }
- if (name.indexOf(">") >= 0) {
- result = ENCODED_GT_PATTERN.matcher(result).replaceAll(">");
+ if (result != null) {
+ for (PatternMap patternMap : XML_DECODE_PATTERNS) {
+ result = patternMap.replaceAll(result);
+ }
}
return result;
}
@@ -302,47 +327,10 @@ public final class StringUtil {
*/
public static String encodeUrlcompname(String value) {
String result = value;
- if (result.indexOf('%') >= 0) {
- result = PERCENT_PATTERN.matcher(result).replaceAll("%25");
- }
- if (result.indexOf("_xF8FF_") >= 0) {
- result = F8FF_PATTERN.matcher(result).replaceAll(String.valueOf((char) 0xF8FF));
- }
- if (result.indexOf('&') >= 0) {
- result = AMP_PATTERN.matcher(result).replaceAll("%26");
- }
- if (result.indexOf('+') >= 0) {
- result = PLUS_PATTERN.matcher(result).replaceAll("%2B");
- }
- if (result.indexOf(':') >= 0) {
- result = COLON_PATTERN.matcher(result).replaceAll("%3A");
- }
- if (result.indexOf(';') >= 0) {
- result = SEMICOLON_PATTERN.matcher(result).replaceAll("%3B");
- }
- if (result.indexOf('<') >= 0) {
- result = LT_PATTERN.matcher(result).replaceAll("%3C");
- }
- if (result.indexOf('>') >= 0) {
- result = GT_PATTERN.matcher(result).replaceAll("%3E");
- }
- if (result.indexOf('"') >= 0) {
- result = QUOTE_PATTERN.matcher(result).replaceAll("%22");
- }
- if (result.indexOf('#') >= 0) {
- result = HASH_PATTERN.matcher(result).replaceAll("%23");
- }
- if (result.indexOf('*') >= 0) {
- result = STAR_PATTERN.matcher(result).replaceAll("%2A");
- }
- if (result.indexOf("_x000D__x000A_") >= 0) {
- result = X0D0A_PATTERN.matcher(result).replaceAll("\r\n");
- }
- if (result.indexOf('|') >= 0) {
- result = PIPE_PATTERN.matcher(result).replaceAll("%7C");
- }
- if (result.indexOf('?') >= 0) {
- result = QUESTION_PATTERN.matcher(result).replaceAll("%3F");
+ if (result != null) {
+ for (PatternMap patternMap : URLENCODE_PATTERNS) {
+ result = patternMap.replaceAll(result);
+ }
}
return result;
}
@@ -356,49 +344,8 @@ public final class StringUtil {
public static String decodeUrlcompname(String urlcompname) {
String result = urlcompname;
if (result != null) {
- if (result.indexOf((char) 0xF8FF) >= 0) {
- result = URLENCODED_F8FF_PATTERN.matcher(result).replaceAll("_xF8FF_");
- }
- if (result.indexOf("%26") >= 0) {
- result = URLENCODED_AMP_PATTERN.matcher(result).replaceAll("&");
- }
- if (result.indexOf("%2B") >= 0) {
- result = URLENCODED_PLUS_PATTERN.matcher(result).replaceAll("+");
- }
- if (result.indexOf("%3A") >= 0) {
- result = URLENCODED_COLON_PATTERN.matcher(result).replaceAll(":");
- }
- if (result.indexOf("%3B") >= 0) {
- result = URLENCODED_SEMICOLON_PATTERN.matcher(result).replaceAll(";");
- }
- if (result.indexOf("%3C") >= 0) {
- result = URLENCODED_LT_PATTERN.matcher(result).replaceAll("<");
- }
- if (result.indexOf("%3E") >= 0) {
- result = URLENCODED_GT_PATTERN.matcher(result).replaceAll(">");
- }
- if (result.indexOf("%22") >= 0) {
- result = URLENCODED_QUOTE_PATTERN.matcher(result).replaceAll("\"");
- }
- // CRLF is replaced with LF in response
- if (result.indexOf('\n') >= 0) {
- result = URLENCODED_X0D0A_PATTERN.matcher(result).replaceAll("_x000D__x000A_");
- }
- if (result.indexOf("%23") >= 0) {
- result = URLENCODED_HASH_PATTERN.matcher(result).replaceAll("#");
- }
- if (result.indexOf("%2A") >= 0) {
- result = URLENCODED_STAR_PATTERN.matcher(result).replaceAll("*");
- }
- if (result.indexOf("%7C") >= 0) {
- result = URLENCODED_PIPE_PATTERN.matcher(result).replaceAll("|");
- }
- if (result.indexOf("%3F") >= 0) {
- result = URLENCODED_QUESTION_PATTERN.matcher(result).replaceAll("?");
- }
- // last replace %
- if (result.indexOf("%25") >= 0) {
- result = URLENCODED_PERCENT_PATTERN.matcher(result).replaceAll("%");
+ for (PatternMap patternMap : URLENCODED_PATTERNS) {
+ result = patternMap.replaceAll(result);
}
}
return result;
diff --git a/src/java/davmailmessages.properties b/src/java/davmailmessages.properties
index 0131aa1..fc76c01 100644
--- a/src/java/davmailmessages.properties
+++ b/src/java/davmailmessages.properties
@@ -141,6 +141,8 @@ UI_ACCEPT_CERTIFICATE=DavMail: Accept certificate ?
UI_ALLOW_REMOTE_CONNECTION=Allow Remote Connections:
UI_ALLOW_REMOTE_CONNECTION_HELP=Allow remote connections to the gateway (server mode)
UI_PASSWORD_PROMPT=DavMail: Enter password
+UI_KERBEROS_CREDENTIAL_PROMPT=DavMail: Kerberos credentials
+UI_KERBEROS_PASSWORD_PROMPT=Kerberos password:
UI_ANSWER_NO=n
UI_ANSWER_YES=y
UI_BIND_ADDRESS=Bind address:
@@ -279,6 +281,8 @@ TENTATIVE=Tentative:
DECLINED=Declined:
UI_ENABLE_EWS=Exchange Protocol
UI_ENABLE_EWS_HELP=Choose EWS on Exchange 2010 or Exchange 2007 with Webdav disabled
+UI_ENABLE_KERBEROS=Enable Kerberos
+UI_ENABLE_KERBEROS_HELP=Enable windows single sign on (Kerberos)
UI_CALDAV_NOTIFICATION=DavMail: Caldav scheduling notification
UI_BUTTON_SEND=Send
UI_TO=To:
diff --git a/src/java/davmailmessages_fr.properties b/src/java/davmailmessages_fr.properties
index e84e4c5..cc63682 100644
--- a/src/java/davmailmessages_fr.properties
+++ b/src/java/davmailmessages_fr.properties
@@ -210,11 +210,13 @@ UI_TAB_ADVANCED=Avanc
UI_TAB_ENCRYPTION=Chiffrement
UI_TAB_MAIN=Général
UI_TAB_NETWORK=Réseau
-UI_UNTRUSTED_CERTIFICATE=Le certificat fourni par le serveur n''est certifié par aucune autorité de confiance,\n vous pouvez choisir d''accepter ou de rejeter l''accès
+UI_UNTRUSTED_CERTIFICATE=Le certificat fourni par le serveur n''est certifié par aucune autorité de confiance,\n vous pouvez choisir d''accepter ou de rejeter l''accès\n Accepter le certificat (o/n) ?
UI_UNTRUSTED_CERTIFICATE_HTML=<html><b>Le certificat fourni par le serveur n''est certifié par aucune autorité de confiance,<br> vous pouvez choisir d''accepter ou de rejeter l''accès</b></html>
UI_VALID_FROM=Emis le
UI_VALID_UNTIL=Expire le
UI_PASSWORD_PROMPT=DavMail : Entrer le mot de passe
+UI_KERBEROS_CREDENTIAL_PROMPT=DavMail : Identifiants Kerberos
+UI_KERBEROS_PASSWORD_PROMPT=Mot de passe Kerberos :
UI_PKCS11_LIBRARY_HELP=Chemin de la librarie PKCS11 (carte à puce) (.so or .dll)
UI_PKCS11_LIBRARY=Librairie PKCS11 :
UI_PKCS11_CONFIG_HELP=Configuration PKCS11 complémentaire optionnelle (slot, nssArgs, ...)
@@ -279,6 +281,8 @@ TENTATIVE=Provisoire :
DECLINED=Refusé :
UI_ENABLE_EWS=Protocole Exchange :
UI_ENABLE_EWS_HELP=Activer EWS sur Exchange 2010 ou Exchange 2007 sans support Webdav
+UI_ENABLE_KERBEROS=Activer Kerberos
+UI_ENABLE_KERBEROS_HELP=Activer l''authentification Kerberos Windows
UI_CALDAV_NOTIFICATION=DavMail : Notification Caldav
UI_BUTTON_SEND=Envoyer
UI_SUBJECT=Sujet :
diff --git a/src/osx/davmail b/src/osx/davmail
deleted file mode 100644
index 2fe00d3..0000000
Binary files a/src/osx/davmail and /dev/null differ
diff --git a/src/osx/tray.icns b/src/osx/tray.icns
deleted file mode 100644
index c0b3093..0000000
Binary files a/src/osx/tray.icns and /dev/null differ
diff --git a/src/site/site.xml b/src/site/site.xml
index 2d6fc13..4aefd78 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -44,6 +44,7 @@
<item name="Getting Started" href="/gettingstarted.html"/>
<item name="Advanced Settings" href="/advanced.html"/>
<item name="SSL Setup" href="/sslsetup.html"/>
+ <item name="Kerberos" href="/kerberos.html"/>
</menu>
<menu name="Thunderbird Setup">
diff --git a/src/site/xdoc/kerberos.xml b/src/site/xdoc/kerberos.xml
new file mode 100644
index 0000000..acc6e89
--- /dev/null
+++ b/src/site/xdoc/kerberos.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!--
+ ~ DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
+ ~ Copyright (C) 2013 Mickael Guessant
+ ~
+ ~ 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.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with this program; if not, write to the Free Software
+ ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ -->
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+
+ <properties>
+ <title>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway - Kerberos</title>
+ <author email="mguessan at free.fr">Mickael Guessant</author>
+ </properties>
+
+ <body>
+
+ <section name="Kerberos">
+ <p>DavMail now includes Windows authentication support, aka Kerberos.
+ A new option is available in DavMail settings to rely on Kerberos token for Exchange authentication.
+ </p>
+
+ <subsection name="Windows workstation Kerberos setup">
+ <p>On windows, you have a valid Kerberos ticket on any workstation using your
+ Active Directory logon. However, on recent Windows versions the TGT is not readable from Java.
+ The workaround is to change the following registry key:
+ </p>
+ <source><![CDATA[
+HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Kerberos\
+REG_DWORD name: allowtgtsessionkey
+Value: 1
+]]></source>
+ <p>More details at:
+ <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/jgss/tutorials/Troubleshooting.html">JGSS Troubleshooting</a>
+ </p>
+ </subsection>
+
+ <subsection name="Linux workstation Kerberos setup">
+ <p>Windows kerberos token is not available on a default Linux workstation setup. You will need to
+ configure /etc/krb5.conf with Active directory domain name. You may also need to provide a kdc
+ (Active Directory Domain controller):
+ </p>
+ <source><![CDATA[
+[libdefaults]
+ default_realm = CORP.COMPANY.COM
+
+[realms]
+ CORP.COMPANY.COM = {
+ kdc = 192.168.184.129
+ default_domain = CORP.COMPANY.COM
+ }
+]]></source>
+ <p>Then create Kerberos ticket: <code>kinit <i>username</i></code>.</p>
+ <p>Check ticket with<code>klist</code></p>
+ </subsection>
+
+ <subsection name="DavMail configuration">
+ <p>In Kerberos mode, password provided by clients (IMAP, SMTP, POP, HTTP, LDAP) is ignored, thus you
+ must make sure external connections to DavMail are disabled.</p>
+ <p>There is no way in current implementation to define a local password to secure client to DavMail
+ communication.</p>
+ <p>DavMail needs direct access to Kerberos ticket, which means Kerberos will not work in server mode.</p>
+ </subsection>
+
+ </section>
+ </body>
+</document>
diff --git a/src/site/xdoc/roadmap.xml b/src/site/xdoc/roadmap.xml
index d25137f..bce8dde 100644
--- a/src/site/xdoc/roadmap.xml
+++ b/src/site/xdoc/roadmap.xml
@@ -15,21 +15,14 @@
for improvement. The following section lists the expected new features
and enhancements in next DavMail versions.
</p>
- <subsection name="4.1.1">
- <p>
- <strong>Next patch release</strong>
- </p>
- <ul>
- <li>Test windows install on seven without admin rights</li>
- </ul>
- </subsection>
- <subsection name="4.2">
+ <subsection name="4.3">
<p>
<strong>Next minor release</strong>
</p>
<ul>
<li>Switch from registry to link on windows</li>
<li>Implement split and kerberos authentication</li>
+ <li>Test windows install on seven without admin rights</li>
</ul>
</subsection>
<subsection name="4.x">
diff --git a/src/test/davmail/imap/TestImap.java b/src/test/davmail/imap/TestImap.java
index 2d93aa1..045fb24 100644
--- a/src/test/davmail/imap/TestImap.java
+++ b/src/test/davmail/imap/TestImap.java
@@ -19,6 +19,7 @@
package davmail.imap;
import davmail.Settings;
+import davmail.exchange.ExchangeSession;
import javax.mail.MessagingException;
import javax.mail.Session;
@@ -26,6 +27,9 @@ import javax.mail.internet.MimeMessage;
import javax.mail.util.SharedByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Locale;
import java.util.Random;
/**
@@ -34,6 +38,14 @@ import java.util.Random;
@SuppressWarnings({"JavaDoc", "UseOfSystemOutOrSystemErr"})
public class TestImap extends AbstractImapTestCase {
+ protected String getLastMonth() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.MONTH, -1);
+ SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
+ formatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
+ return formatter.format(calendar.getTime());
+ }
+
public void testListFolders() throws IOException {
writeLine(". LSUB \"\" \"*\"");
assertEquals(". OK LSUB completed", readFullAnswer("."));
@@ -451,4 +463,29 @@ public class TestImap extends AbstractImapTestCase {
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
}
+ public void testFetchHeadersInboxMutt() throws IOException {
+ writeLine(". SELECT INBOX");
+ assertEquals(". OK [READ-WRITE] SELECT completed", readFullAnswer("."));
+ writeLine(". UID SEARCH (SINCE \""+getLastMonth()+"\")");
+ String messageLine = readLine();
+ int uidIndex = messageLine.indexOf(" ", "* SEARCH".length()) + 1;
+ messageUid = messageLine.substring(uidIndex, messageLine.indexOf(' ', uidIndex));
+ assertEquals(". OK SEARCH completed", readFullAnswer("."));
+ System.out.println(messageUid);
+ writeLine(". UID FETCH "+messageUid+":* (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL)])");
+ assertEquals(". OK UID FETCH completed", readFullAnswer("."));
+ }
+
+ public void testFetchHeadersInboxOSX() throws IOException {
+ writeLine(". SELECT INBOX");
+ assertEquals(". OK [READ-WRITE] SELECT completed", readFullAnswer("."));
+ writeLine(". UID SEARCH (SINCE \""+getLastMonth()+"\")");
+ String messageLine = readLine();
+ int uidIndex = messageLine.indexOf(" ", "* SEARCH".length()) + 1;
+ messageUid = messageLine.substring(uidIndex, messageLine.indexOf(' ', uidIndex));
+ assertEquals(". OK SEARCH completed", readFullAnswer("."));
+ System.out.println(messageUid);
+ writeLine(". UID FETCH "+messageUid+":* (INTERNALDATE UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (date subject from to cc message-id in-reply-to references x-priority x-uniform-type-identifier x-universally-unique-identifier received-spf x-spam-status x-spam-flag)])");
+ assertEquals(". OK UID FETCH completed", readFullAnswer("."));
+ }
}
diff --git a/src/test/davmail/util/StringUtilTest.java b/src/test/davmail/util/StringUtilTest.java
index 7a7612a..f91e7ff 100644
--- a/src/test/davmail/util/StringUtilTest.java
+++ b/src/test/davmail/util/StringUtilTest.java
@@ -60,22 +60,17 @@ public class StringUtilTest extends TestCase {
assertEquals("<test>", StringUtil.xmlEncode("<test>"));
}
- public void testUrlEncodeAmpersand() {
- assertEquals("%26", StringUtil.urlEncodeAmpersand("&"));
- assertEquals("&", StringUtil.urlDecodeAmpersand("%26"));
- }
-
public void testPerf() {
String value = "dqsdqs+dsqds+dsqdqs";
for (int j = 0; j < 5; j++) {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
//String result = StringUtil.encodePlusSign(value);
- //String result = StringUtil.replaceAll(value, '+', "%2B");
+ //String result = value.replaceAll("\\+", "%2B");
- /*int length = value.length();
+ int length = value.length();
StringBuilder buffer = new StringBuilder(length);
- int startIndex = 0;
+ /*int startIndex = 0;
int endIndex = value.indexOf('+');
while (endIndex >= 0) {
buffer.append(value.substring(startIndex, endIndex));
@@ -83,8 +78,8 @@ public class StringUtilTest extends TestCase {
startIndex = endIndex + 1;
endIndex = value.indexOf('+', startIndex);
}
- buffer.append(value.substring(startIndex)); */
- /*
+ buffer.append(value.substring(startIndex));*/
+
for (int k = 0; k < length; k++) {
char c = value.charAt(k);
if (c == '+') {
@@ -92,7 +87,7 @@ public class StringUtilTest extends TestCase {
} else {
buffer.append(c);
}
- }*/
+ }
//String result = buffer.toString();
//String result = value.replaceAll("\\+", "%2B");
}
@@ -119,4 +114,10 @@ public class StringUtilTest extends TestCase {
assertEquals("test %3F", StringUtil.encodeUrlcompname("test ?"));
assertEquals("test ?", StringUtil.decodeUrlcompname("test %3F"));
}
+
+ public void testEncodeUrlCompname() {
+
+ assertEquals("test %7E", StringUtil.encodeUrlcompname("test ~"));
+ assertEquals("test ~", StringUtil.decodeUrlcompname("test %7E"));
+ }
}
diff --git a/src/winrun4j/davmail.exe b/src/winrun4j/davmail.exe
deleted file mode 100644
index 8a3db9c..0000000
Binary files a/src/winrun4j/davmail.exe and /dev/null differ
diff --git a/src/winrun4j/davmail.ico b/src/winrun4j/davmail.ico
deleted file mode 100644
index 7f07861..0000000
Binary files a/src/winrun4j/davmail.ico and /dev/null differ
diff --git a/src/winrun4j/davmail.ini b/src/winrun4j/davmail.ini
deleted file mode 100644
index bf637c3..0000000
--- a/src/winrun4j/davmail.ini
+++ /dev/null
@@ -1,29 +0,0 @@
-main.class=davmail.DavGateway
-classpath.1=davmail.jar
-classpath.2=lib/activation-1.1.1.jar
-classpath.3=lib/commons-codec-1.3.jar
-classpath.4=lib/commons-collections-3.1.jar
-classpath.5=lib/commons-httpclient-3.1.jar
-classpath.6=lib/commons-logging-1.0.4.jar
-classpath.7=lib/htmlcleaner-2.1.jar
-classpath.8=lib/jackrabbit-webdav-1.4.jar
-classpath.9=lib/jcharset-1.3.jar
-classpath.10=lib/jcifs-1.3.14.jar
-classpath.11=lib/jdom-1.0.jar
-classpath.12=lib/log4j-1.2.16.jar
-classpath.13=lib/mail-1.4.3.jar
-classpath.14=lib/slf4j-api-1.3.1.jar
-classpath.15=lib/slf4j-log4j12-1.3.1.jar
-classpath.16=lib/stax-api-1.0.1.jar
-classpath.17=lib/stax2-api-3.1.1.jar
-classpath.18=lib/swt-3.7-win32-x86.jar
-classpath.19=lib/woodstox-core-asl-4.1.2.jar
-classpath.20=lib/xercesImpl-2.8.1.jar
-
-vm.version.min=1.6
-vmarg.1=-Dsun.net.inetaddr.ttl=60
-vmarg.2=-XmX512M
-
-[ErrorMessages]
-java.not.found=A suitable version of Java could not be found on your system, please install Java from http://java.com
-java.failed=Java failed to startup successfully, please install Java from http://java.com
diff --git a/src/winrun4j/davmail64.exe b/src/winrun4j/davmail64.exe
deleted file mode 100644
index 6329c39..0000000
Binary files a/src/winrun4j/davmail64.exe and /dev/null differ
diff --git a/src/winrun4j/davmail64.ini b/src/winrun4j/davmail64.ini
deleted file mode 100644
index 8a9f909..0000000
--- a/src/winrun4j/davmail64.ini
+++ /dev/null
@@ -1,29 +0,0 @@
-main.class=davmail.DavGateway
-classpath.1=davmail.jar
-classpath.2=lib/activation-1.1.1.jar
-classpath.3=lib/commons-codec-1.3.jar
-classpath.4=lib/commons-collections-3.1.jar
-classpath.5=lib/commons-httpclient-3.1.jar
-classpath.6=lib/commons-logging-1.0.4.jar
-classpath.7=lib/htmlcleaner-2.1.jar
-classpath.8=lib/jackrabbit-webdav-1.4.jar
-classpath.9=lib/jcharset-1.3.jar
-classpath.10=lib/jcifs-1.3.14.jar
-classpath.11=lib/jdom-1.0.jar
-classpath.12=lib/log4j-1.2.16.jar
-classpath.13=lib/mail-1.4.3.jar
-classpath.14=lib/slf4j-api-1.3.1.jar
-classpath.15=lib/slf4j-log4j12-1.3.1.jar
-classpath.16=lib/stax-api-1.0.1.jar
-classpath.17=lib/stax2-api-3.1.1.jar
-classpath.18=lib/swt-3.7-win32-x86_64.jar
-classpath.19=lib/woodstox-core-asl-4.1.2.jar
-classpath.20=lib/xercesImpl-2.8.1.jar
-
-vm.version.min=1.6
-vmarg.1=-Dsun.net.inetaddr.ttl=60
-vmarg.2=-XmX512M
-
-[ErrorMessages]
-java.not.found=A suitable version of Java could not be found on your system, please install Java (64-bit) from http://java.com/en/download/manual.jsp
-java.failed=Java failed to startup successfully, please install Java (64-bit) from http://java.com/en/download/manual.jsp
diff --git a/src/winrun4j/davmailconsole.exe b/src/winrun4j/davmailconsole.exe
deleted file mode 100644
index f6767fd..0000000
Binary files a/src/winrun4j/davmailconsole.exe and /dev/null differ
diff --git a/src/winrun4j/davmailservice.exe b/src/winrun4j/davmailservice.exe
deleted file mode 100644
index b0686a0..0000000
Binary files a/src/winrun4j/davmailservice.exe and /dev/null differ
diff --git a/src/winrun4j/davmailservice.ini b/src/winrun4j/davmailservice.ini
deleted file mode 100644
index 1cfb7ce..0000000
--- a/src/winrun4j/davmailservice.ini
+++ /dev/null
@@ -1,19 +0,0 @@
-service.startup=auto
-service.class=davmail.service.DavService
-service.id=DavMail
-service.name=DavMail Gateway
-service.description=DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway
-
-classpath.1=davmail.jar
-classpath.2=lib/*
-
-vm.version.min=1.6
-vmarg.1=-Dsun.net.inetaddr.ttl=60
-vmarg.2=-Xrs
-
-
-arg.1=davmail.properties
-
-[ErrorMessages]
-java.not.found=A suitable version of Java could not be found on your system, please install Java from http://java.com
-java.failed=Java failed to startup successfully, please install Java from http://java.com
diff --git a/src/winrun4j/davmailservice64.exe b/src/winrun4j/davmailservice64.exe
deleted file mode 100644
index b11f15a..0000000
Binary files a/src/winrun4j/davmailservice64.exe and /dev/null differ
diff --git a/src/winrun4j/davmailservice64.ini b/src/winrun4j/davmailservice64.ini
deleted file mode 100644
index 8412932..0000000
--- a/src/winrun4j/davmailservice64.ini
+++ /dev/null
@@ -1,19 +0,0 @@
-service.startup=auto
-service.class=davmail.service.DavService
-service.id=DavMail
-service.name=DavMail Gateway
-service.description=DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway
-
-classpath.1=davmail.jar
-classpath.2=lib/*
-
-vm.version.min=1.6
-vmarg.1=-Dsun.net.inetaddr.ttl=60
-vmarg.2=-Xrs
-
-
-arg.1=davmail.properties
-
-[ErrorMessages]
-java.not.found=A suitable version of Java could not be found on your system, please install Java (64-bit) from http://java.com/en/download/manual.jsp
-java.failed=Java failed to startup successfully, please install Java (64-bit) from http://java.com/en/download/manual.jsp
diff --git a/src/winrun4j/rcedit.exe b/src/winrun4j/rcedit.exe
deleted file mode 100644
index 642e955..0000000
Binary files a/src/winrun4j/rcedit.exe and /dev/null differ
diff --git a/src/winrun4j/rcedit64.exe b/src/winrun4j/rcedit64.exe
deleted file mode 100644
index ce17dcb..0000000
Binary files a/src/winrun4j/rcedit64.exe and /dev/null differ
diff --git a/user.properties b/user.properties
deleted file mode 100644
index 1d12c7a..0000000
--- a/user.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-username=mguessan
-keyfile=C:/mguessan/.ssh/id_dsa
-passphrase=
--
davmail packaging
More information about the pkg-java-commits
mailing list