renamed OtrEngine to OtrService

This commit is contained in:
Daniel Gultsch 2015-05-26 04:36:32 +02:00
parent f579602456
commit dc91ff8f29
4 changed files with 16 additions and 16 deletions

View file

@ -36,14 +36,14 @@ import net.java.otr4j.session.InstanceTag;
import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.FragmenterInstructions;
public class OtrEngine extends OtrCryptoEngineImpl implements OtrEngineHost {
public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
private Account account;
private OtrPolicy otrPolicy;
private KeyPair keyPair;
private XmppConnectionService mXmppConnectionService;
public OtrEngine(XmppConnectionService service, Account account) {
public OtrService(XmppConnectionService service, Account account) {
this.account = account;
this.otrPolicy = new OtrPolicyImpl();
this.otrPolicy.setAllowV1(false);
@ -285,7 +285,7 @@ public class OtrEngine extends OtrCryptoEngineImpl implements OtrEngineHost {
@Override
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 {
final Jid jid = Jid.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);

View file

@ -19,7 +19,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import eu.siacs.conversations.Config;
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.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
@ -117,7 +117,7 @@ public class Account extends AbstractEntity {
protected JSONObject keys = new JSONObject();
protected String avatar;
protected boolean online = false;
private OtrEngine otrEngine = null;
private OtrService mOtrService = null;
private XmppConnection xmppConnection = null;
private long mEndGracePeriod = 0L;
private String otrFingerprint;
@ -273,12 +273,12 @@ public class Account extends AbstractEntity {
return values;
}
public void initOtrEngine(final XmppConnectionService context) {
this.otrEngine = new OtrEngine(context, this);
public void initAccountServices(final XmppConnectionService context) {
this.mOtrService = new OtrService(context, this);
}
public OtrEngine getOtrEngine() {
return this.otrEngine;
public OtrService getOtrService() {
return this.mOtrService;
}
public XmppConnection getXmppConnection() {
@ -292,10 +292,10 @@ public class Account extends AbstractEntity {
public String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (this.otrEngine == null) {
if (this.mOtrService == null) {
return null;
}
final PublicKey publicKey = this.otrEngine.getPublicKey();
final PublicKey publicKey = this.mOtrService.getPublicKey();
if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
return null;
}

View file

@ -419,7 +419,7 @@ public class Conversation extends AbstractEntity implements Blockable {
final SessionID sessionId = new SessionID(this.getJid().toBareJid().toString(),
presence,
"xmpp");
this.otrSession = new SessionImpl(sessionId, getAccount().getOtrEngine());
this.otrSession = new SessionImpl(sessionId, getAccount().getOtrService());
try {
if (sendStart) {
this.otrSession.startSession();
@ -491,7 +491,7 @@ public class Conversation extends AbstractEntity implements Blockable {
return null;
}
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
this.otrFingerprint = getAccount().getOtrEngine().getFingerprint(remotePubKey);
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey);
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
return null;
}

View file

@ -574,7 +574,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
this.accounts = databaseBackend.getAccounts();
for (final Account account : this.accounts) {
account.initOtrEngine(this);
account.initAccountServices(this);
}
restoreFromDatabase();
@ -1176,7 +1176,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
public void createAccount(final Account account) {
account.initOtrEngine(this);
account.initAccountServices(this);
databaseBackend.createAccount(account);
this.accounts.add(account);
this.reconnectAccountInBackground(account);
@ -2267,7 +2267,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void updateUnreadCountBadge() {
int count = unreadCount();
Log.d(Config.LOGTAG,"update unread count to "+count);
Log.d(Config.LOGTAG, "update unread count to " + count);
if (count > 0) {
ShortcutBadger.with(getApplicationContext()).count(count);
} else {