diff --git a/src/Makefile.conf b/src/Makefile.conf index 2c3aeb0..fa335b4 100644 --- a/src/Makefile.conf +++ b/src/Makefile.conf @@ -1,3 +1,2 @@ -JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") CXXFLAGS=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I$(HOME)/include CLASSPATH=.:$(HOME)/src/k-9/k9mail/src diff --git a/src/org/pEp/jniadapter/AbstractEngine.java b/src/org/pEp/jniadapter/AbstractEngine.java index cec9b46..93d4f38 100644 --- a/src/org/pEp/jniadapter/AbstractEngine.java +++ b/src/org/pEp/jniadapter/AbstractEngine.java @@ -2,13 +2,16 @@ package org.pEp.jniadapter; import java.util.ArrayList; import java.util.Vector; -import java.io.UnsupportedEncodingException; import java.text.Normalizer; +import java.io.UnsupportedEncodingException; +import java.text.Normalizer; -abstract class AbstractEngine implements AutoCloseable { static { - System.loadLibrary("pEpJNI"); } +abstract class AbstractEngine implements AutoCloseable { + static { + System.loadLibrary("pEpJNI"); + } - private native void init() throws pEpException; private native void - release(); + private native void init() throws pEpException; + private native void release(); private long handle; diff --git a/src/org/pEp/jniadapter/Engine.java.target b/src/org/pEp/jniadapter/Engine.java.target new file mode 100644 index 0000000..746c0d1 --- /dev/null +++ b/src/org/pEp/jniadapter/Engine.java.target @@ -0,0 +1,28 @@ +package org.pEp.jniadapter; + +import java.util.ArrayList; +import java.util.Vector; + +final public class Engine extends AbstractEngine { + public Engine() throws pEpException { } + + public native Message encrypt_message( + Message src, + ArrayList extra, + Message.EncFormat enc_format + ) throws pEpException; + + public class DecryptResult { + public Message dst; + public Color color; + } + + public native DecryptResult decrypt_message( + Message src, + ArrayList keylist + ) throws pEpException; + + public native Color outgoing_message_color( + Message msg + ) throws pEpException; +} diff --git a/src/org/pEp/jniadapter/Message.java.target b/src/org/pEp/jniadapter/Message.java.target new file mode 100644 index 0000000..8699ecf --- /dev/null +++ b/src/org/pEp/jniadapter/Message.java.target @@ -0,0 +1,218 @@ +package org.pEp.jniadapter; + +import java.util.ArrayList; +import java.util.Vector; +import java.util.Date; +import java.util.HashMap; + +public class Message implements AutoCloseable { + private final long handle; + + native long init(); + native void release(long handle); + + public Message() { + handle = init(); + } + + public final void close() { + release(handle); + } + + public enum TextFormat { + Plain (0), + Html (1), + Other (255) + ; + + static class Management { + public static final HashMap tag = + new HashMap(); + } + + public final int value; + + TextFormat(int value) { + this.value = value; + fill(value); + } + + private void fill(int value) { + Management.tag.put(value, this); + } + } + + public enum Direction { + Incoming (0), + Outgoing (1) + ; + + static class Management { + public static final HashMap tag = + new HashMap(); + } + + public final int value; + + Direction(int value) { + this.value = value; + fill(value); + } + + private void fill(int value) { + Management.tag.put(value, this); + } + } + + public enum EncFormat { + None (0), + Pieces (1), + SMIME (2), + PGPMIME (3), + PEP (4) + ; + + static class Management { + public static final HashMap tag = + new HashMap(); + } + + public final int value; + + EncFormat(int value) { + this.value = value; + fill(value); + } + + private void fill(int value) { + Management.tag.put(value, this); + } + } + + private native int _getDir(); + private native void _setDir(int value); + public Direction getDir() { + return Direction.tag.get(_getDir()); + } + public void setDir(Direction value) { + _setDir(value.value); + } + + private native byte[] _getId(); + private native void _setId(byte[] value); + public String getId() { + return AbstractEngine.toUTF16(_getId()); + } + public void setId(String value) { + _setId(AbstractEngine.toUTF8(value)); + } + + private native byte[] _getShortmsg(); + private native void _setShortmsg(byte[] value); + public String getShortmsg() { + return AbstractEngine.toUTF16(_getShortmsg()); + } + public void setShortmsg(String value) { + _setShortmsg(AbstractEngine.toUTF8(value)); + } + + private native byte[] _getLongmsg(); + private native void _setLongmsg(byte[] value); + public String getLongmsg() { + return AbstractEngine.toUTF16(_getLongmsg()); + } + public void setLongmsg(String value) { + _setLongmsg(AbstractEngine.toUTF8(value)); + } + + private native byte[] _getLongmsgFormatted(); + private native void _setLongmsgFormatted(byte[] value); + public String getLongmsgFormatted() { + return AbstractEngine.toUTF16(_getLongmsgFormatted()); + } + public void setLongmsgFormatted(String value) { + _setLongmsgFormatted(AbstractEngine.toUTF8(value)); + } + + public native ArrayList getAttachments(); + public native void setAttachments(ArrayList value); + + public native Date getSent(); + public native void setSent(Date value); + + public native Date getRecv(); + public native void setRecv(Date value); + + private native AbstractEngine._Identity _getFrom(); + private native void _setFrom(AbstractEngine._Identity value); + public Identity getFrom() { + return new _getFrom().getIdentity(); + } + public void setFrom(Identity value) { + _setFrom(new AbstractEngine._Identity(value)); + } + + public native ArrayList getTo(); + public native void setTo(ArrayList value); + + public native Identity getRecvBy(); + public native void setRecvBy(Identity value); + + public native ArrayList getCc(); + public native void setCc(ArrayList value); + + public native ArrayList getBcc(); + public native void setBcc(ArrayList value); + + public native ArrayList getReplyTo(); + public native void setReplyTo(ArrayList value); + + private native ArrayList _getInReplyTo(); + private native void _setInReplyTo(ArrayList value); + public ArrayList getInReplyTo() { + return AbstractEngine.toUTF16(_getInReplyTo()); + } + public void setInReplyTo(ArrayList value) { + _setInReplyTo(AbstractEngine.toUTF8(value)); + } + + private native ArrayList _getReferences(); + private native void _setReferences(ArrayList value); + public ArrayList getReferences() { + return AbstractEngine.toUTF16(_getReferences()); + } + public void setReferences(ArrayList value) { + _setReferences(AbstractEngine.toUTF8(value)); + } + + private native ArrayList _getKeywords(); + private native void _setKeywords(ArrayList value); + public ArrayList getKeywords() { + return AbstractEngine.toUTF16(_getKeywords()); + } + public void setKeywords(ArrayList value) { + _setKeywords(AbstractEngine.toUTF8(value)); + } + + private native byte[] _getComments(); + private native void _setComments(byte[] value); + public String getComments() { + return AbstractEngine.toUTF16(_getComments()); + } + public void setComments(String value) { + _setComments(AbstractEngine.toUTF8(value)); + } + + private native Vector> _getOptFields(); + private native void _setOptFields(Vector> value); + public Vector> getOptFields() { + return AbstractEngine.toUTF16(_getOptFields()); + } + public void setOptFields(Vector> value) { + _setOptFields(AbstractEngine.toUTF8(value)); + } + + public native Message.EncFormat getEncFormat(); + public native void setEncFormat(Message.EncFormat value); + +}