Browse Source

generating message struct

JNI-44
Volker Birk 10 years ago
parent
commit
855694af50
  1. 6
      src/Makefile
  2. 60
      src/gen_java_Message.ysl2
  3. 103
      src/org/pEp/jniadapter/MimeMessage.java
  4. 34
      src/pEp.yml2
  5. 5
      src/types_java.ysl2

6
src/Makefile

@ -5,7 +5,7 @@ include Makefile.conf
all: $(JAR) $(LIBRARY)
$(JAR): org/pEp/jniadapter/pEpException.java org/pEp/jniadapter/AbstractEngine.java org/pEp/jniadapter/Engine.java
$(JAR): org/pEp/jniadapter/pEpException.java org/pEp/jniadapter/AbstractEngine.java org/pEp/jniadapter/Engine.java org/pEp/jniadapter/MimeMessage.java
javac org/pEp/jniadapter/*.java
jar cf $@ org/pEp/jniadapter/*.class
@ -26,6 +26,9 @@ org/pEp/jniadapter/pEpException.java: pEp.yml2 gen_java_exceptions.ysl2
org/pEp/jniadapter/Engine.java : pEp.yml2 gen_java_Engine.ysl2 types_java.ysl2
yml2proc -y gen_java_Engine.ysl2 $< -o $@
org/pEp/jniadapter/MimeMessage.java : pEp.yml2 gen_java_Message.ysl2 types_java.ysl2
yml2proc -y gen_java_Message.ysl2 $< -o $@
throw_pEp_exception.cc throw_pEp_exception.hh: pEp.yml2 gen_throw_pEp_exception.ysl2 textutils.ysl2
yml2proc -y gen_throw_pEp_exception.ysl2 $< -o throw_pEp_exception.cc
@ -41,5 +44,6 @@ clean:
rm -f org/pEp/jniadapter/*.class
rm -f org/pEp/jniadapter/pEp*.java
rm -f org/pEp/jniadapter/Engine.java
rm -f org/pEp/jniadapter/MimeMessage.java
rm -f throw_pEp_exception.*

60
src/gen_java_Message.ysl2

@ -0,0 +1,60 @@
include yslt.yml2
tstylesheet {
template "/namespace[@name='pEp']" apply "struct", 0;
template "struct"
||
package org.pEp.jniadapter;
import java.util.Date;
public class MimeMessage {
public enum TextFormat {
plain (0),
html (1),
other (255);
public final int value;
TextFormat(int value) {
this.value = value;
}
}
public enum Direction {
incoming (0),
outgoing (1);
public final int value;
Direction(int value) {
this.value = value;
}
}
public enum EncFormat {
none (0),
pieces (1),
S_MIME (2),
PGP_MIME (3),
PEP (4);
public final int value;
EncFormat(int value) {
this.value = value;
}
}
``apply "entry";
}
||
template "entry"
||
public native †@type «@name»();
public native void «@name»(†@type value);
||
}

103
src/org/pEp/jniadapter/MimeMessage.java

@ -1,103 +0,0 @@
package org.pEp.jniadapter;
import java.util.Date;
public class MimeMessage {
public enum TextFormat {
plain (0),
html (1),
other (255);
public final int value;
TextFormat(int value) {
this.value = value;
}
}
public enum Direction {
incoming (0),
outgoing (1);
public final int value;
Direction(int value) {
this.value = value;
}
}
public enum EncFormat {
none (0),
pieces (1),
S_MIME (2),
PGP_MIME (3),
PEP (4);
public final int value;
EncFormat(int value) {
this.value = value;
}
}
public native Direction dir();
public native void dir(Direction value);
public native String id();
public native void id(String value);
public native String shortmsg();
public native void shortmsg(String value);
public native String longmsg();
public native void longmsg(String value);
public native String longmsg_formatted();
public native void longmsg_formatted(String value);
public native Blob[] attachments();
public native void attachments(Blob[] value);
public native Date sent();
public native void sent(Date value);
public native Date recv();
public native void recv(Date value);
public native Identity from();
public native void from(Identity value);
public native Identity[] to();
public native void to(Identity[] value);
public native Identity recv_by();
public native void recv_by(Identity value);
public native Identity[] cc();
public native void cc(Identity[] value);
public native Identity[] bcc();
public native void bcc(Identity[] value);
public native Identity[] reply_to();
public native void reply_to(Identity[] value);
public native String[] in_reply_to();
public native void in_reply_to(String[] value);
public native String[] references();
public native void references(String[] value);
public native String[] keywords();
public native void keywords(String[] value);
public native String comments();
public native void comments(String value);
public native Pair<String, String>[] opt_fields();
public native void opt_fields(Pair<String, String>[] value);
public native EncFormat enc_format();
public native void enc_format(EncFormat value);
}

34
src/pEp.yml2

@ -53,13 +53,43 @@ namespace pEp {
in message src,
in stringlist extra,
creates message dst,
in pEp_enc_format enc_format
in encformat enc_format
);
method decrypt_message(
in message src,
creates message dst
creates message dst,
creates stringlist keylist,
returns Color color
);
method outgoing_message_color(
in message msg,
returns Color color
);
};
struct message {
direction dir;
string id;
string shortmsg;
string longmsg;
string longmsg_formatted;
bloblist attachments;
timestamp sent;
timestamp recv;
identity from;
identitylist to;
identity recv_by;
identitylist cc;
identitylist bcc;
identitylist reply_to;
stringlist in_reply_to;
stringlist references;
stringlist keywords;
string comments;
stringpairlist opt_fields;
encformat enc_format;
};
};

5
src/types_java.ysl2

@ -7,10 +7,11 @@ function "toJava" {
when "$type='stringlist'" > String[]
when "$type='string'" > String
when "$type='message'" > MimeMessage
when "$type='pEp-identity'" > Identity
when "$type='identity'" > Identity
when "$type='identity-list'" > Identity[]
when "$type='timestamp'" > Date
when "$type='pEp-enc-format'" > MimeMessage.EncFormat
when "$type='encformat'" > MimeMessage.EncFormat
when "$type='bloblist'" > Blob[]
otherwise call "CamelCase" with "text", "$type";
}
}

Loading…
Cancel
Save