diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-03-24 10:50:06 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-03-24 10:50:06 +0100 |
commit | 76da74b7756947ed382c5e832525f026479caf7d (patch) | |
tree | 3a444ec5fcc3d7f6ca4bb3bba6fc40ed72ebbb6f | |
parent | 8cb0427d886a4ceda70e83aaaefd415a0aa44dfc (diff) | |
parent | 1b3c28822530b27adc7bd5657e89940e8c06fa49 (diff) |
Merge branch 'development'
Diffstat (limited to '')
5 files changed, 20 insertions, 21 deletions
diff --git a/src/eu/siacs/conversations/crypto/OtrEngine.java b/src/eu/siacs/conversations/crypto/OtrEngine.java index 74e6036d..01ba5e49 100644 --- a/src/eu/siacs/conversations/crypto/OtrEngine.java +++ b/src/eu/siacs/conversations/crypto/OtrEngine.java @@ -19,7 +19,6 @@ import android.util.Log; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.persistance.DatabaseBackend; -import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import net.java.otr4j.OtrEngineHost; @@ -199,15 +198,13 @@ public class OtrEngine implements OtrEngineHost { @Override public void smpError(SessionID arg0, int arg1, boolean arg2) throws OtrException { - // TODO Auto-generated method stub - + throw new OtrException(new Exception("smp error")); } @Override public void unencryptedMessageReceived(SessionID arg0, String arg1) throws OtrException { - // TODO Auto-generated method stub - + throw new OtrException(new Exception("unencrypted message received")); } @Override diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 72abcf5f..c2e227fa 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -61,6 +61,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.PowerManager; +import android.os.PowerManager.WakeLock; import android.os.SystemClock; import android.preference.PreferenceManager; import android.provider.ContactsContract; @@ -337,6 +338,7 @@ public class XmppConnectionService extends Service { private PgpEngine mPgpEngine = null; private Intent pingIntent; private PendingIntent pendingPingIntent = null; + private WakeLock wakeLock; public PgpEngine getPgpEngine() { if (pgpServiceConnection.isBound()) { @@ -415,6 +417,7 @@ public class XmppConnectionService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { + this.wakeLock.acquire(); // Log.d(LOGTAG,"calling start service. caller was:"+intent.getAction()); ConnectivityManager cm = (ConnectivityManager) getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); @@ -483,6 +486,9 @@ public class XmppConnectionService extends Service { } } } + if (wakeLock.isHeld()) { + wakeLock.release(); + } return START_STICKY; } @@ -498,6 +504,9 @@ public class XmppConnectionService extends Service { getApplicationContext(), "org.sufficientlysecure.keychain"); this.pgpServiceConnection.bindToService(); + PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); + this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + "XmppConnection"); } @Override @@ -554,8 +563,7 @@ public class XmppConnectionService extends Service { SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); account.setResource(sharedPref.getString("resource", "mobile").toLowerCase(Locale.getDefault())); - PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - XmppConnection connection = new XmppConnection(account, pm); + XmppConnection connection = new XmppConnection(account, this.wakeLock); connection.setOnMessagePacketReceivedListener(this.messageListener); connection.setOnStatusChangedListener(this.statusListener); connection.setOnPresencePacketReceivedListener(this.presenceListener); diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index 6d644f03..4bdb2539 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -84,16 +84,15 @@ public class MessageParser { conversation.resetOtrSession(); Log.d(LOGTAG,"otr session stoped"); } + //isEmpty is a work around for some weird clients which send emtpty strings over otr + if ((body == null)||(body.isEmpty())) { + return null; + } + return new Message(conversation, packet.getFrom(), body, Message.ENCRYPTION_OTR,Message.STATUS_RECIEVED); } catch (Exception e) { conversation.resetOtrSession(); return null; } - - //isEmpty is a work around for some weird clients which send emtpty strings over otr - if ((body == null)||(body.isEmpty())) { - return null; - } - return new Message(conversation, packet.getFrom(), body, Message.ENCRYPTION_OTR,Message.STATUS_RECIEVED); } public static Message parseGroupchat(MessagePacket packet, Account account, XmppConnectionService service) { diff --git a/src/eu/siacs/conversations/xml/TagWriter.java b/src/eu/siacs/conversations/xml/TagWriter.java index 15ad385f..c8294aed 100644 --- a/src/eu/siacs/conversations/xml/TagWriter.java +++ b/src/eu/siacs/conversations/xml/TagWriter.java @@ -33,14 +33,9 @@ public class TagWriter { } }; - public TagWriter() { } - public TagWriter(OutputStream out) { - this.setOutputStream(out); - } - public void setOutputStream(OutputStream out) { this.outputStream = new OutputStreamWriter(out); } diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index 1d386f91..ec5ab1f6 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -32,6 +32,7 @@ import org.xmlpull.v1.XmlPullParserException; import android.os.Bundle; import android.os.PowerManager; +import android.os.PowerManager.WakeLock; import android.os.SystemClock; import android.util.Log; import eu.siacs.conversations.entities.Account; @@ -91,10 +92,9 @@ public class XmppConnection implements Runnable { private OnTLSExceptionReceived tlsListener = null; private OnBindListener bindListener = null; - public XmppConnection(Account account, PowerManager pm) { + public XmppConnection(Account account, WakeLock wakeLock) { this.account = account; - wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, - "XmppConnection"); + this.wakeLock = wakeLock; tagReader = new XmlReader(wakeLock); tagWriter = new TagWriter(); } |