renamed OtrEngine to OtrService
This commit is contained in:
parent
f579602456
commit
dc91ff8f29
|
@ -36,14 +36,14 @@ import net.java.otr4j.session.InstanceTag;
|
||||||
import net.java.otr4j.session.SessionID;
|
import net.java.otr4j.session.SessionID;
|
||||||
import net.java.otr4j.session.FragmenterInstructions;
|
import net.java.otr4j.session.FragmenterInstructions;
|
||||||
|
|
||||||
public class OtrEngine extends OtrCryptoEngineImpl implements OtrEngineHost {
|
public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
private OtrPolicy otrPolicy;
|
private OtrPolicy otrPolicy;
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
private XmppConnectionService mXmppConnectionService;
|
private XmppConnectionService mXmppConnectionService;
|
||||||
|
|
||||||
public OtrEngine(XmppConnectionService service, Account account) {
|
public OtrService(XmppConnectionService service, Account account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.otrPolicy = new OtrPolicyImpl();
|
this.otrPolicy = new OtrPolicyImpl();
|
||||||
this.otrPolicy.setAllowV1(false);
|
this.otrPolicy.setAllowV1(false);
|
||||||
|
@ -285,7 +285,7 @@ public class OtrEngine extends OtrCryptoEngineImpl implements OtrEngineHost {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void verify(SessionID id, String fingerprint, boolean approved) {
|
public void verify(SessionID id, String fingerprint, boolean approved) {
|
||||||
Log.d(Config.LOGTAG,"OtrEngine.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
|
Log.d(Config.LOGTAG,"OtrService.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
|
||||||
try {
|
try {
|
||||||
final Jid jid = Jid.fromSessionID(id);
|
final Jid jid = Jid.fromSessionID(id);
|
||||||
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
|
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
|
|
@ -19,7 +19,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.crypto.OtrEngine;
|
import eu.siacs.conversations.crypto.OtrService;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
|
@ -117,7 +117,7 @@ public class Account extends AbstractEntity {
|
||||||
protected JSONObject keys = new JSONObject();
|
protected JSONObject keys = new JSONObject();
|
||||||
protected String avatar;
|
protected String avatar;
|
||||||
protected boolean online = false;
|
protected boolean online = false;
|
||||||
private OtrEngine otrEngine = null;
|
private OtrService mOtrService = null;
|
||||||
private XmppConnection xmppConnection = null;
|
private XmppConnection xmppConnection = null;
|
||||||
private long mEndGracePeriod = 0L;
|
private long mEndGracePeriod = 0L;
|
||||||
private String otrFingerprint;
|
private String otrFingerprint;
|
||||||
|
@ -273,12 +273,12 @@ public class Account extends AbstractEntity {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initOtrEngine(final XmppConnectionService context) {
|
public void initAccountServices(final XmppConnectionService context) {
|
||||||
this.otrEngine = new OtrEngine(context, this);
|
this.mOtrService = new OtrService(context, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OtrEngine getOtrEngine() {
|
public OtrService getOtrService() {
|
||||||
return this.otrEngine;
|
return this.mOtrService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmppConnection getXmppConnection() {
|
public XmppConnection getXmppConnection() {
|
||||||
|
@ -292,10 +292,10 @@ public class Account extends AbstractEntity {
|
||||||
public String getOtrFingerprint() {
|
public String getOtrFingerprint() {
|
||||||
if (this.otrFingerprint == null) {
|
if (this.otrFingerprint == null) {
|
||||||
try {
|
try {
|
||||||
if (this.otrEngine == null) {
|
if (this.mOtrService == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final PublicKey publicKey = this.otrEngine.getPublicKey();
|
final PublicKey publicKey = this.mOtrService.getPublicKey();
|
||||||
if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
|
if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,7 +419,7 @@ public class Conversation extends AbstractEntity implements Blockable {
|
||||||
final SessionID sessionId = new SessionID(this.getJid().toBareJid().toString(),
|
final SessionID sessionId = new SessionID(this.getJid().toBareJid().toString(),
|
||||||
presence,
|
presence,
|
||||||
"xmpp");
|
"xmpp");
|
||||||
this.otrSession = new SessionImpl(sessionId, getAccount().getOtrEngine());
|
this.otrSession = new SessionImpl(sessionId, getAccount().getOtrService());
|
||||||
try {
|
try {
|
||||||
if (sendStart) {
|
if (sendStart) {
|
||||||
this.otrSession.startSession();
|
this.otrSession.startSession();
|
||||||
|
@ -491,7 +491,7 @@ public class Conversation extends AbstractEntity implements Blockable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
|
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
|
||||||
this.otrFingerprint = getAccount().getOtrEngine().getFingerprint(remotePubKey);
|
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey);
|
||||||
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
|
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,7 +574,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
this.accounts = databaseBackend.getAccounts();
|
this.accounts = databaseBackend.getAccounts();
|
||||||
|
|
||||||
for (final Account account : this.accounts) {
|
for (final Account account : this.accounts) {
|
||||||
account.initOtrEngine(this);
|
account.initAccountServices(this);
|
||||||
}
|
}
|
||||||
restoreFromDatabase();
|
restoreFromDatabase();
|
||||||
|
|
||||||
|
@ -1176,7 +1176,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAccount(final Account account) {
|
public void createAccount(final Account account) {
|
||||||
account.initOtrEngine(this);
|
account.initAccountServices(this);
|
||||||
databaseBackend.createAccount(account);
|
databaseBackend.createAccount(account);
|
||||||
this.accounts.add(account);
|
this.accounts.add(account);
|
||||||
this.reconnectAccountInBackground(account);
|
this.reconnectAccountInBackground(account);
|
||||||
|
|
Loading…
Reference in a new issue