diff --git a/src/basic_api.cc b/src/basic_api.cc index a7e869c..6be089b 100644 --- a/src/basic_api.cc +++ b/src/basic_api.cc @@ -24,7 +24,10 @@ JNIEXPORT jobject JNICALL Java_org_pEp_jniadapter_Engine_trustwords( size_t wsize; if (_ident->fpr == NULL || _ident->fpr[0] == 0) { - ::update_identity(session, _ident); + if (_ident->me) + ::myself(session, _ident); + else + ::update_identity(session, _ident); } if (_ident->fpr == NULL || _ident->fpr[0] == 0) { @@ -101,7 +104,10 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_keyMistrusted( pEp_identity *_ident = to_identity(env, ident); if (_ident->fpr == NULL || _ident->fpr[0] == 0) { - ::update_identity(session, _ident); + if (_ident->me) + ::myself(session, _ident); + else + ::update_identity(session, _ident); } if (_ident->fpr == NULL || _ident->fpr[0] == 0) { @@ -122,7 +128,10 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_keyResetTrust( pEp_identity *_ident = to_identity(env, ident); if (_ident->fpr == NULL || _ident->fpr[0] == 0) { - ::update_identity(session, _ident); + if (_ident->me) + ::myself(session, _ident); + else + ::update_identity(session, _ident); } if (_ident->fpr == NULL || _ident->fpr[0] == 0) { @@ -143,7 +152,10 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_trustPersonalKey( pEp_identity *_ident = to_identity(env, ident); if (_ident->fpr == NULL || _ident->fpr[0] == 0) { - ::update_identity(session, _ident); + if (_ident->me) + ::myself(session, _ident); + else + ::update_identity(session, _ident); } if (_ident->fpr == NULL || _ident->fpr[0] == 0) { diff --git a/src/jniutils.cc b/src/jniutils.cc index 000465b..225b3b3 100644 --- a/src/jniutils.cc +++ b/src/jniutils.cc @@ -460,6 +460,9 @@ namespace pEp { _setStringField(env, classname, obj, "lang", ident->lang); + jfieldID me_id = getFieldID(env, classname, "me", "Z"); + env->SetBooleanField(obj, me_id, (jboolean) ident->me); + jfieldID flags_id = getFieldID(env, classname, "flags", "I"); env->SetIntField(obj, flags_id, (jint) (int) ident->flags); } @@ -489,6 +492,9 @@ namespace pEp { _setStringField(env, classname, obj, "lang", ident->lang, identityClass); + jfieldID me_id = getFieldID(env, classname, "me", "Z", identityClass); + env->SetBooleanField(obj, me_id, (jboolean) ident->me); + jfieldID flags_id = getFieldID(env, classname, "flags", "I", identityClass); env->SetIntField(obj, flags_id, (jint) (int) ident->flags); } @@ -531,6 +537,9 @@ namespace pEp { } free(lang); + jfieldID me_id = getFieldID(env, classname, "me", "Z"); + ident->me = (bool) env->GetBooleanField(obj, me_id); + jfieldID flags_id = getFieldID(env, classname, "flags", "I"); ident->flags = (identity_flags_t) (int) env->GetIntField(obj, flags_id); diff --git a/src/org/pEp/jniadapter/Identity.java b/src/org/pEp/jniadapter/Identity.java index f31d8c0..56478a6 100644 --- a/src/org/pEp/jniadapter/Identity.java +++ b/src/org/pEp/jniadapter/Identity.java @@ -9,9 +9,16 @@ public class Identity implements Serializable{ public String username; public CommType comm_type; public String lang; + public boolean me; public int flags; public Identity() { + this.me = false; + comm_type = CommType.PEP_ct_unknown; + } + + public Identity(boolean me) { + this.me = me; comm_type = CommType.PEP_ct_unknown; } @@ -22,6 +29,7 @@ public class Identity implements Serializable{ username = AbstractEngine.toUTF16(i.username); comm_type = CommType.Management.tag.get(i.comm_type); lang = AbstractEngine.toUTF16(i.lang); + me = i.me; flags = i.flags; } diff --git a/src/org/pEp/jniadapter/_Identity.java b/src/org/pEp/jniadapter/_Identity.java index e9dfe5b..28b721a 100644 --- a/src/org/pEp/jniadapter/_Identity.java +++ b/src/org/pEp/jniadapter/_Identity.java @@ -7,9 +7,15 @@ public class _Identity { public byte[] username; public int comm_type; public byte[] lang; + public boolean me; public int flags; public _Identity() { + this.me = false; + } + + public _Identity(boolean me) { + this.me = me; } public _Identity(Identity i) { @@ -19,6 +25,7 @@ public class _Identity { username = AbstractEngine.toUTF8(i.username); comm_type = i.comm_type.value; lang = AbstractEngine.toUTF8(i.lang); + me = i.me; flags = i.flags; } }