Skip to content
Snippets Groups Projects
Commit 232de794 authored by pedroGitt's avatar pedroGitt
Browse files

Update return code for initOutboundSessionWithAccount() and initInboundSessionWithAccount():

An error code is now returned, no utility to return the object itself (initial implementation matching iOS)
parent eb2052ba
No related branches found
No related tags found
No related merge requests found
...@@ -231,20 +231,18 @@ public class OlmSession implements Serializable { ...@@ -231,20 +231,18 @@ public class OlmSession implements Serializable {
* @param aAccount the account to associate with this session * @param aAccount the account to associate with this session
* @param aTheirIdentityKey the identity key of the recipient * @param aTheirIdentityKey the identity key of the recipient
* @param aTheirOneTimeKey the one time key of the recipient * @param aTheirOneTimeKey the one time key of the recipient
* @return this if operation succeed, null otherwise * @return 0 if operation succeed, -1 otherwise
*/ */
public OlmSession initOutboundSessionWithAccount(OlmAccount aAccount, String aTheirIdentityKey, String aTheirOneTimeKey) { public int initOutboundSessionWithAccount(OlmAccount aAccount, String aTheirIdentityKey, String aTheirOneTimeKey) {
OlmSession retObj=null; int retCode=-1;
if((null==aAccount) || TextUtils.isEmpty(aTheirIdentityKey) || TextUtils.isEmpty(aTheirOneTimeKey)){ if((null==aAccount) || TextUtils.isEmpty(aTheirIdentityKey) || TextUtils.isEmpty(aTheirOneTimeKey)){
Log.e(LOG_TAG, "## initOutboundSession(): invalid input parameters"); Log.e(LOG_TAG, "## initOutboundSession(): invalid input parameters");
} else { } else {
if(0 == initOutboundSessionJni(aAccount.getOlmAccountId(), aTheirIdentityKey, aTheirOneTimeKey)) { retCode = initOutboundSessionJni(aAccount.getOlmAccountId(), aTheirIdentityKey, aTheirOneTimeKey);
retObj = this;
}
} }
return retObj; return retCode;
} }
private native int initOutboundSessionJni(long aOlmAccountId, String aTheirIdentityKey, String aTheirOneTimeKey); private native int initOutboundSessionJni(long aOlmAccountId, String aTheirIdentityKey, String aTheirOneTimeKey);
...@@ -252,25 +250,23 @@ public class OlmSession implements Serializable { ...@@ -252,25 +250,23 @@ public class OlmSession implements Serializable {
/** /**
* Create a new in-bound session for sending/receiving messages from an * Create a new in-bound session for sending/receiving messages from an
* incoming PRE_KEY ({@link OlmMessage#MESSAGE_TYPE_PRE_KEY}) message.<br> * incoming PRE_KEY message ({@link OlmMessage#MESSAGE_TYPE_PRE_KEY}).<br>
* Public API for {@link #initInboundSessionJni(long, String)}. * Public API for {@link #initInboundSessionJni(long, String)}.
* This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY). * This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY).
* @param aAccount the account to associate with this session * @param aAccount the account to associate with this session
* @param aPreKeyMsg PRE KEY message * @param aPreKeyMsg PRE KEY message
* @return this if operation succeed, null otherwise * @return 0 if operation succeed, -1 otherwise
*/ */
public OlmSession initInboundSessionWithAccount(OlmAccount aAccount, String aPreKeyMsg) { public int initInboundSessionWithAccount(OlmAccount aAccount, String aPreKeyMsg) {
OlmSession retObj=null; int retCode=-1;
if((null==aAccount) || TextUtils.isEmpty(aPreKeyMsg)){ if((null==aAccount) || TextUtils.isEmpty(aPreKeyMsg)){
Log.e(LOG_TAG, "## initInboundSessionWithAccount(): invalid input parameters"); Log.e(LOG_TAG, "## initInboundSessionWithAccount(): invalid input parameters");
} else { } else {
if( 0 == initInboundSessionJni(aAccount.getOlmAccountId(), aPreKeyMsg)) { retCode = initInboundSessionJni(aAccount.getOlmAccountId(), aPreKeyMsg);
retObj = this;
}
} }
return retObj; return retCode;
} }
private native int initInboundSessionJni(long aOlmAccountId, String aOneTimeKeyMsg); private native int initInboundSessionJni(long aOlmAccountId, String aOneTimeKeyMsg);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment