Browse Source

updateIdentity and myself

JNI-44
Volker Birk 10 years ago
parent
commit
bcbb6f49cb
  1. 31
      src/gen_java_Engine.ysl2
  2. 34
      src/org/pEp/jniadapter/AbstractEngine.java
  3. 6
      src/pEp.yml2
  4. 1
      src/types_java.ysl2

31
src/gen_java_Engine.ysl2

@ -18,12 +18,35 @@ tstylesheet {
public «$cname»() throws pEpException { } public «$cname»() throws pEpException { }
`` apply "method", mode=plain `` apply "method", mode=plain
private native byte[] trustwords(_Identity ident); `` apply "basic"
}
public String trustwords(Identity ident) { ||
_Identity _ident = new _Identity(ident);
return AbstractEngine.toUTF16(trustwords(_ident));
} }
template "basic" {
const "itype" call "toIntermediate" with "type", "@type";
const "jtype" call "toJava" with "type", "@type";
const "ptype", "name(parm/*[1])";
const "pitype" call "toIntermediate" with "type", "$ptype";
const "pjtype" call "toJava" with "type", "$ptype";
const "pname", "name(parm/*[2])";
||
private native «$itype» «@name»(«$pitype» «$pname»);
public «$jtype» «@name»(«$pjtype» «$pname») {
«$pitype» _«$pname» = new «$pitype»(«$pname»);
||
choose {
when "@type = 'void'"
|> «@name»(_«$pname»);
when "@type = 'identity'"
|> return new Identity(«@name»(_«$pname»));
otherwise
|> return AbstractEngine.toUTF16(«@name»(_«$pname»));
}
||
} }
|| ||

34
src/org/pEp/jniadapter/AbstractEngine.java

@ -101,39 +101,5 @@ abstract class AbstractEngine implements AutoCloseable {
return result; return result;
} }
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(Identity value) {
address = toUTF8(value.address);
fpr = toUTF8(value.fpr);
user_id = toUTF8(value.user_id);
username = toUTF8(value.username);
comm_type = value.comm_type;
lang = toUTF8(value.lang);
me = value.me;
}
public Identity getIdentity() {
Identity ident = new Identity(me);
ident.address = toUTF16(address);
ident.fpr = toUTF16(fpr);
ident.user_id = toUTF16(user_id);
ident.username = toUTF16(username);
ident.comm_type = comm_type;
ident.lang = toUTF16(lang);
ident.me = me;
return ident;
}
}
} }

6
src/pEp.yml2

@ -4,6 +4,7 @@ decl interface @name;
decl exception @name; decl exception @name;
decl method @name; decl method @name;
decl struct @name; decl struct @name;
decl basic @type @name;
namespace pEp { namespace pEp {
exception pEp_status { exception pEp_status {
@ -86,6 +87,11 @@ namespace pEp {
in message msg, in message msg,
returns Color color returns Color color
); );
basic string trustwords(identity ident);
basic identity myself(identity ident);
basic identity updateIdentity(identity ident);
basic void keyCompromized(identity ident);
}; };
struct message { struct message {

1
src/types_java.ysl2

@ -12,6 +12,7 @@ function "toJava" {
when "$type='bloblist'" > Vector<Blob> when "$type='bloblist'" > Vector<Blob>
when "$type='stringpairlist'" > ArrayList<Pair<String, String>> when "$type='stringpairlist'" > ArrayList<Pair<String, String>>
when "$type='message'" > Message when "$type='message'" > Message
when "$type='void'" > void
otherwise call "CamelCase" with "text", "$type"; otherwise call "CamelCase" with "text", "$type";
} }

Loading…
Cancel
Save