diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-08 14:10:37 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-08 14:10:37 +0200 |
commit | 10411944b1bd18c0b5d7b1353f4c55eb0ec4aff6 (patch) | |
tree | 013a1756234483f8a5f3f59c525c032e5a464048 | |
parent | 3d88ffc5cd4b9e500048557f9ce5f01653123526 (diff) |
bullet proofing some code
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/persistance/DatabaseBackend.java | 3 | ||||
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 28 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java index 0231c0e7..0991dd2d 100644 --- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -210,6 +210,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { while (cursor.moveToNext()) { list.add(Account.fromCursor(cursor)); } + cursor.close(); return list; } @@ -232,6 +233,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { + Account.TABLENAME + " where not options & (1 <<1)", null); cursor.moveToFirst(); int count = cursor.getInt(0); + cursor.close(); return (count > 0); } @@ -258,6 +260,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { while (cursor.moveToNext()) { roster.initContact(Contact.fromCursor(cursor)); } + cursor.close(); } public void writeRoster(Roster roster) { diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index e2c17b7e..5aca9ce3 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -908,10 +908,12 @@ public class XmppConnectionService extends Service { public void archiveConversation(Conversation conversation) { if (conversation.getMode() == Conversation.MODE_MULTI) { - Bookmark bookmark = conversation.getBookmark(); - if (bookmark != null && bookmark.autojoin()) { - bookmark.setAutojoin(false); - pushBookmarks(bookmark.getAccount()); + if (conversation.getAccount().getStatus() == Account.STATUS_ONLINE) { + Bookmark bookmark = conversation.getBookmark(); + if (bookmark != null && bookmark.autojoin()) { + bookmark.setAutojoin(false); + pushBookmarks(bookmark.getAccount()); + } } leaveMuc(conversation); } else { @@ -1639,7 +1641,8 @@ public class XmppConnectionService extends Service { String id = conversation.getLatestMarkableMessageId(); conversation.markRead(); if (confirmMessages() && id != null && calledByUi) { - Log.d(Config.LOGTAG,conversation.getAccount().getJid()+": sending read marker for "+conversation.getName()); + Log.d(Config.LOGTAG, conversation.getAccount().getJid() + + ": sending read marker for " + conversation.getName()); Account account = conversation.getAccount(); String to = conversation.getContactJid(); this.sendMessagePacket(conversation.getAccount(), @@ -1722,16 +1725,25 @@ public class XmppConnectionService extends Service { } public void sendMessagePacket(Account account, MessagePacket packet) { - account.getXmppConnection().sendMessagePacket(packet); + XmppConnection connection = account.getXmppConnection(); + if (connection != null) { + connection.sendMessagePacket(packet); + } } public void sendPresencePacket(Account account, PresencePacket packet) { - account.getXmppConnection().sendPresencePacket(packet); + XmppConnection connection = account.getXmppConnection(); + if (connection != null) { + connection.sendPresencePacket(packet); + } } public void sendIqPacket(Account account, IqPacket packet, OnIqPacketReceived callback) { - account.getXmppConnection().sendIqPacket(packet, callback); + XmppConnection connection = account.getXmppConnection(); + if (connection != null) { + connection.sendIqPacket(packet, callback); + } } public MessageGenerator getMessageGenerator() { |