diff --git a/src/Makefile b/src/Makefile index 38404ab..7be6c16 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,13 +37,13 @@ JAVA_SOURCES=foundation/pEp/jniadapter/AbstractEngine.java \ foundation/pEp/jniadapter/_Blob.java \ foundation/pEp/jniadapter/_Identity.java \ foundation/pEp/jniadapter/pEpException.java \ - foundation/pEp/jniadapter/Message.java \ + foundation/pEp/jniadapter/AbstractMessage.java \ foundation/pEp/jniadapter/Engine.java \ C_SOURCES=foundation_pEp_jniadapter_Engine.cc \ foundation_pEp_jniadapter_Engine.h \ - foundation_pEp_jniadapter_Message.cc \ - foundation_pEp_jniadapter_Message.h \ + foundation_pEp_jniadapter_AbstractMessage.cc \ + foundation_pEp_jniadapter_AbstractMessage.h \ throw_pEp_exception.cc \ throw_pEp_exception.hh \ foundation_pEp_jniadapter_AbstractEngine.h @@ -58,7 +58,7 @@ $(JAR): status_list.yml2 $(JAVA_SOURCES) $(C_SOURCES) $(JP)/javac foundation/pEp/jniadapter/*.java $(JP)/jar cf $@ foundation/pEp/jniadapter/*.class -BLUBB=foundation_pEp_jniadapter_AbstractEngine.h foundation_pEp_jniadapter_Engine.h foundation_pEp_jniadapter_Message.h +BLUBB=foundation_pEp_jniadapter_AbstractEngine.h foundation_pEp_jniadapter_Engine.h foundation_pEp_jniadapter_AbstractMessage.h $(BLUBB): foundation_pEp_jniadapter_%.h: foundation/pEp/jniadapter/%.java ifdef OLD_JAVA $(JP)/javah $(subst /,.,$(subst .java,,$<)) @@ -69,10 +69,10 @@ endif foundation_pEp_jniadapter_AbstractEngine.o: %.o: %.cc %.h throw_pEp_exception.hh jniutils.hh $(CXX) $(CXXFLAGS) -c $< -o $@ -foundation_pEp_jniadapter_Engine.o foundation_pEp_jniadapter_Message.o: %.o: %.cc %.h +foundation_pEp_jniadapter_Engine.o foundation_pEp_jniadapter_AbstractMessage.o: %.o: %.cc %.h $(CXX) $(CXXFLAGS) -c $< -o $@ -$(LIBRARY): foundation_pEp_jniadapter_AbstractEngine.o foundation_pEp_jniadapter_Engine.o foundation_pEp_jniadapter_Message.o throw_pEp_exception.o jniutils.o basic_api.o +$(LIBRARY): foundation_pEp_jniadapter_AbstractEngine.o foundation_pEp_jniadapter_Engine.o foundation_pEp_jniadapter_AbstractMessage.o throw_pEp_exception.o jniutils.o basic_api.o ar -r $@ *.o $(SHARED): $(LIBRARY) @@ -84,13 +84,13 @@ status_list.yml2: pEp.yml2 foundation/pEp/jniadapter/pEpException.java: pEp.yml2 gen_java_exceptions.ysl2 pEp.yml2 $(YML2_PROC) -y gen_java_exceptions.ysl2 $< -o $@ -foundation/pEp/jniadapter/Message.java: pEp.yml2 gen_java_Message.ysl2 types_java.ysl2 +foundation/pEp/jniadapter/AbstractMessage.java: pEp.yml2 gen_java_Message.ysl2 types_java.ysl2 $(YML2_PROC) -y gen_java_Message.ysl2 $< foundation/pEp/jniadapter/Engine.java: pEp.yml2 gen_java_Engine.ysl2 types_java.ysl2 $(YML2_PROC) -y gen_java_Engine.ysl2 $< -foundation_pEp_jniadapter_Message.cc: pEp.yml2 gen_cpp_Message.ysl2 types_c.ysl2 +foundation_pEp_jniadapter_AbstractMessage.cc: pEp.yml2 gen_cpp_Message.ysl2 types_c.ysl2 $(YML2_PROC) -y gen_cpp_Message.ysl2 $< foundation_pEp_jniadapter_Engine.cc: pEp.yml2 gen_cpp_Engine.ysl2 types_c.ysl2 @@ -113,7 +113,7 @@ clean: rm -f foundation/pEp/jniadapter/*.class rm -f foundation/pEp/jniadapter/pEp*.java rm -f foundation/pEp/jniadapter/Engine.java - rm -f foundation/pEp/jniadapter/Message.java + rm -f foundation/pEp/jniadapter/AbstractMessage.java rm -f foundation/pEp/jniadapter/Color.java rm -f foundation/pEp/jniadapter/DecryptFlags.java rm -f foundation/pEp/jniadapter/IdentityFlags.java @@ -123,5 +123,5 @@ clean: rm -f foundation/pEp/jniadapter/SyncHandshakeSignal.java rm -f foundation/pEp/jniadapter/CipherSuite.java rm -f throw_pEp_exception.* - rm -f foundation_pEp_jniadapter_Message.cc foundation_pEp_jniadapter_Engine.cc + rm -f foundation_pEp_jniadapter_AbstractMessage.cc foundation_pEp_jniadapter_Engine.cc rm -f status_list.yml2 diff --git a/src/foundation/pEp/jniadapter/Message.java b/src/foundation/pEp/jniadapter/Message.java new file mode 100644 index 0000000..65be77a --- /dev/null +++ b/src/foundation/pEp/jniadapter/Message.java @@ -0,0 +1,105 @@ +package foundation.pEp.jniadapter; + +import java.util.HashMap; + + +public class Message extends AbstractMessage { + + // Explicit Super Constructor call + public Message() { + super(); + } + + public Message(String mime_text) { + super(mime_text); + } + + private Message(long h) { + super(h); + } + + + public enum TextFormat { + Plain (0), + Html (1), + Other (255) + ; + + public final int value; + + private static HashMap intMap; + + private TextFormat(int value) { + this.value = value; + } + + public static TextFormat getByInt(int value){ + if (intMap == null) { + intMap = new HashMap(); + for (TextFormat s : TextFormat.values()) { + intMap.put(s.value, s); + } + } + if (intMap.containsKey(value)) { + return intMap.get(value); + } + return null; + } + } + public enum Direction { + Incoming (0), + Outgoing (1) + ; + + public final int value; + + private static HashMap intMap; + + private Direction(int value) { + this.value = value; + } + + public static Direction getByInt(int value){ + if (intMap == null) { + intMap = new HashMap(); + for (Direction s : Direction.values()) { + intMap.put(s.value, s); + } + } + if (intMap.containsKey(value)) { + return intMap.get(value); + } + return null; + } + } + public enum EncFormat { + None (0), + Inline (1), + SMIME (2), + PGPMIME (3), + PEP (4) + ; + + public final int value; + + private static HashMap intMap; + + private EncFormat(int value) { + this.value = value; + } + + public static EncFormat getByInt(int value){ + if (intMap == null) { + intMap = new HashMap(); + for (EncFormat s : EncFormat.values()) { + intMap.put(s.value, s); + } + } + if (intMap.containsKey(value)) { + return intMap.get(value); + } + return null; + } + } + +} \ No newline at end of file diff --git a/src/gen_cpp_Message.ysl2 b/src/gen_cpp_Message.ysl2 index 8a7c598..57ea985 100644 --- a/src/gen_cpp_Message.ysl2 +++ b/src/gen_cpp_Message.ysl2 @@ -7,7 +7,7 @@ tstylesheet { template "/namespace[@name='pEp']" apply "struct", 0; template "struct" { - const "jname" call "CamelCase" with "text", "@name"; + const "jname" call "CamelCase" with "text", "concat('Abstract-',@name)"; document("foundation_pEp_jniadapter_{$jname}.cc", "text") { || @@ -93,7 +93,7 @@ tstylesheet { || apply "*[name(.)!='enum']", 0, mode=entry { with "name", "@name"; - with "class" call "CamelCase" with "text", "@name"; + with "class" call "CamelCase" with "text", "$jname"; } || } // extern "C" @@ -105,7 +105,7 @@ tstylesheet { function "mangle" { param "type"; param "name"; - param "classname" call "CamelCase" with "text", "../@name"; + param "classname"; const "convert", "$type != 'timestamp'"; choose { @@ -125,10 +125,12 @@ tstylesheet { const "type", "name(.)"; const "getname" call "mangle" { with "type", "$type"; + with "classname", "$class"; with "name", "concat('get', $jname)"; } const "setname" call "mangle" { with "type", "$type"; + with "classname", "$class"; with "name", "concat('set', $jname)"; } || diff --git a/src/gen_java_Message.ysl2 b/src/gen_java_Message.ysl2 index a16658a..16334ca 100644 --- a/src/gen_java_Message.ysl2 +++ b/src/gen_java_Message.ysl2 @@ -7,7 +7,7 @@ tstylesheet { template "/namespace[@name='pEp']" apply "struct|enum|exception", 0; template "struct" { - const "cname" call "toJava" with "type", "@name"; + const "cname" call "toJava" with "type", "concat('Abstract-',@name)"; document("foundation/pEp/jniadapter/{$cname}.java", "text") || package foundation.pEp.jniadapter; @@ -18,7 +18,7 @@ tstylesheet { import java.util.HashMap; import java.io.Serializable; - public class «$cname» implements AutoCloseable, Serializable { + public abstract class «$cname» implements AutoCloseable, Serializable { private static final long serialVersionUID = 2119420428331150924L; private long handle; @@ -44,7 +44,7 @@ tstylesheet { return AbstractEngine.toUTF16(_encodeMIME()); } - private «$cname»(long h) { + public «$cname»(long h) { handle = h; } diff --git a/src/types_java.ysl2 b/src/types_java.ysl2 index a6806e5..4725392 100644 --- a/src/types_java.ysl2 +++ b/src/types_java.ysl2 @@ -20,6 +20,7 @@ function "toJava" { when "$type='Color'" > Color when "$type='DecryptFlags'" > DecryptFlags when "$type='EncFormat'" > Message.EncFormat + when "$type='direction'" > Message.Direction when "$type='Rating'" > Rating otherwise call "CamelCase" with "text", "$type";