diff --git a/src/gen_java_Message.ysl2 b/src/gen_java_Message.ysl2 index fc94e22..01c124a 100644 --- a/src/gen_java_Message.ysl2 +++ b/src/gen_java_Message.ysl2 @@ -108,11 +108,45 @@ tstylesheet { } template "*", mode=entry { + const "ctype", "name(.)"; const "type" call "toJava" with "type", "name(.)"; const "itype" call "toIntermediate" with "type", "name(.)"; const "name" call "toJava" with "type", "name(*[position()=1])"; choose { + when "$ctype = 'identity'" + || + private native «$itype» _get«$name»(); + private native void _set«$name»(«$itype» value); + public «$type» get«$name»() { + return new «$type»(_get«$name»()); + } + public void set«$name»(«$type» value) { + _set«$name»(new «$itype»(value)); + } + + || + + when "$ctype = 'identitylist' or $ctype = 'bloblist'" + || + `` const "ename", "substring-before(substring-after($type, '<'), '>')"; + private native «$itype» _get«$name»(); + private native void _set«$name»(«$itype» value); + public «$type» get«$name»() { + «$type» list = new «$type»(); + for (_«$ename» i : _get«$name»()) + list.add(new «$ename»(i)); + return list; + } + public void set«$name»(«$type» value) { + «$itype» list = new «$itype»(); + for («$ename» i : value) + list.add(new _«$ename»(i)); + _set«$name»(list); + } + + || + when "$itype != $type" || private native «$itype» _get«$name»(); @@ -125,6 +159,20 @@ tstylesheet { } || + + when "../enum[@name=$ctype]" + || + private native int _get«$name»(); + public «$itype» get«$name»() { + return «$itype».Management.tag.get(_get«$name»()); + } + private native void _set«$name»(int value); + public void set«$name»(«$itype» value) { + _set«$name»(value.value); + } + + || + otherwise || public native «$itype» get«$name»(); diff --git a/src/org/pEp/jniadapter/Blob.java b/src/org/pEp/jniadapter/Blob.java index 3be5ae4..4db23a9 100644 --- a/src/org/pEp/jniadapter/Blob.java +++ b/src/org/pEp/jniadapter/Blob.java @@ -4,5 +4,15 @@ public class Blob { public byte[] data; public String mime_type; public String filename; + + Blob() { + mime_type = "application/octet-stream"; + } + + Blob(_Blob b) { + data = b.data; + mime_type = AbstractEngine.toUTF16(b.mime_type); + filename = AbstractEngine.toUTF16(b.filename); + } } diff --git a/src/org/pEp/jniadapter/Identity.java b/src/org/pEp/jniadapter/Identity.java index 92a5c9b..bfcbd3e 100644 --- a/src/org/pEp/jniadapter/Identity.java +++ b/src/org/pEp/jniadapter/Identity.java @@ -16,5 +16,15 @@ public class Identity { public Identity(boolean me) { this.me = me; } + + public Identity(_Identity i) { + address = AbstractEngine.toUTF16(i.address); + fpr = AbstractEngine.toUTF16(i.address); + user_id = AbstractEngine.toUTF16(i.address); + username = AbstractEngine.toUTF16(i.address); + comm_type = i.comm_type; + lang = AbstractEngine.toUTF16(i.address); + me = i.me; + } } diff --git a/src/org/pEp/jniadapter/_Blob.java b/src/org/pEp/jniadapter/_Blob.java new file mode 100644 index 0000000..9432781 --- /dev/null +++ b/src/org/pEp/jniadapter/_Blob.java @@ -0,0 +1,16 @@ +package org.pEp.jniadapter; + +public class _Blob { + public byte[] data; + public byte[] mime_type; + public byte[] filename; + + _Blob() { } + + _Blob(Blob b) { + data = b.data; + mime_type = AbstractEngine.toUTF8(b.mime_type); + filename = AbstractEngine.toUTF8(b.filename); + } +} + diff --git a/src/org/pEp/jniadapter/_Identity.java b/src/org/pEp/jniadapter/_Identity.java new file mode 100644 index 0000000..9f2074c --- /dev/null +++ b/src/org/pEp/jniadapter/_Identity.java @@ -0,0 +1,30 @@ +package org.pEp.jniadapter; + +public class _Identity { + public byte[] address; + public byte[] fpr; + public byte[] user_id; + public byte[] username; + CommType comm_type; + public byte[] lang; + public boolean me; + + public _Identity() { + this.me = false; + } + + public _Identity(boolean me) { + this.me = me; + } + + public _Identity(Identity i) { + address = AbstractEngine.toUTF8(i.address); + fpr = AbstractEngine.toUTF8(i.address); + user_id = AbstractEngine.toUTF8(i.address); + username = AbstractEngine.toUTF8(i.address); + comm_type = i.comm_type; + lang = AbstractEngine.toUTF8(i.address); + me = i.me; + } +} + diff --git a/src/pEp.yml2 b/src/pEp.yml2 index f2b567a..2242534 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -96,7 +96,7 @@ namespace pEp { other > 255 } - enum Direction { + enum direction { incoming > 0 outgoing > 1 } diff --git a/src/types_java.ysl2 b/src/types_java.ysl2 index a362d1f..ae021d7 100644 --- a/src/types_java.ysl2 +++ b/src/types_java.ysl2 @@ -26,6 +26,9 @@ function "toIntermediate" { when "$type='stringlist'" > ArrayList when "$type='stringpairlist'" > Vector> when "$type='string'" > byte[] + when "$type='identity'" > _Identity + when "$type='identitylist'" > ArrayList<_Identity> + when "$type='bloblist'" > ArrayList<_Blob> otherwise call "toJava" with "type", "$type"; }