diff options
Diffstat (limited to 'src/main/java')
7 files changed, 38 insertions, 32 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 16635f7c..47861d06 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -73,14 +73,21 @@ public class Message extends AbstractEntity { } public Message(Conversation conversation, String body, int encryption, int status) { - this(java.util.UUID.randomUUID().toString(), conversation.getUuid(), - conversation.getContactJid().toBareJid(), null, body, System - .currentTimeMillis(), encryption, - status, TYPE_TEXT, null, null); + this(java.util.UUID.randomUUID().toString(), + conversation.getUuid(), + conversation.getContactJid() == null ? null : conversation.getContactJid().toBareJid(), + null, + body, + System.currentTimeMillis(), + encryption, + status, + TYPE_TEXT, + null, + null); this.conversation = conversation; } - public Message(final String uuid, final String conversationUUid, final Jid counterpart, + private Message(final String uuid, final String conversationUUid, final Jid counterpart, final Jid trueCounterpart, final String body, final long timeSent, final int encryption, final int status, final int type, final String remoteMsgId, final String relativeFilePath) { this.uuid = uuid; diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index 419964ea..cd212943 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -20,7 +20,7 @@ public abstract class AbstractGenerator { "http://jabber.org/protocol/disco#info", "urn:xmpp:avatar:metadata+notify", "urn:xmpp:ping"}; - public final String IDENTITY_NAME = "Conversations 0.9-alpha"; + public final String IDENTITY_NAME = "Conversations 0.9.1"; public final String IDENTITY_TYPE = "phone"; protected XmppConnectionService mXmppConnectionService; diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java index b38cdc72..aeec56d0 100644 --- a/src/main/java/eu/siacs/conversations/parser/IqParser.java +++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java @@ -25,14 +25,11 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived { } for (Element item : query.getChildren()) { if (item.getName().equals("item")) { - Jid jid; - try { - jid = Jid.fromString(item.getAttribute("jid")); - } catch (final InvalidJidException e) { - // TODO: Handle this? - jid = null; - } - String name = item.getAttribute("name"); + final Jid jid = item.getAttributeAsJid("jid"); + if (jid == null) { + break; + } + String name = item.getAttribute("name"); String subscription = item.getAttribute("subscription"); Contact contact = account.getRoster().getContact(jid); if (!contact.getOption(Contact.Options.DIRTY_PUSH)) { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 0f9761e5..5b0fa562 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -771,12 +771,8 @@ public class ConversationActivity extends XmppActivity implements super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == REQUEST_DECRYPT_PGP) { - ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() - .findFragmentByTag("conversation"); - if (selectedFragment != null) { - selectedFragment.hideSnackbar(); - selectedFragment.updateMessages(); - } + mConversationFragment.hideSnackbar(); + mConversationFragment.updateMessages(); } else if (requestCode == REQUEST_ATTACH_IMAGE_DIALOG) { mPendingImageUri = data.getData(); if (xmppConnectionServiceBound) { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 287d1636..1d26ff8a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -35,6 +35,7 @@ import net.java.otr4j.session.SessionStatus; import java.util.ArrayList; import java.util.List; +import java.util.NoSuchElementException; import java.util.concurrent.ConcurrentLinkedQueue; import eu.siacs.conversations.R; @@ -503,6 +504,8 @@ public class ConversationFragment extends Fragment { } this.activity = (ConversationActivity) getActivity(); this.conversation = conversation; + this.mDecryptJobRunning = false; + this.mEncryptedMessages.clear(); if (this.conversation.getMode() == Conversation.MODE_MULTI) { this.conversation.setNextCounterpart(null); } @@ -626,7 +629,11 @@ public class ConversationFragment extends Fragment { @Override public void success(Message message) { mDecryptJobRunning = false; - mEncryptedMessages.remove(); + try { + mEncryptedMessages.remove(); + } catch (final NoSuchElementException ignored) { + + } activity.xmppConnectionService.updateMessage(message); } @@ -634,7 +641,11 @@ public class ConversationFragment extends Fragment { public void error(int error, Message message) { message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED); mDecryptJobRunning = false; - mEncryptedMessages.remove(); + try { + mEncryptedMessages.remove(); + } catch (final NoSuchElementException ignored) { + + } activity.xmppConnectionService.updateConversationUi(); } }); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java index 143dfda1..0993735f 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java @@ -60,11 +60,8 @@ public class KnownHostsAdapter extends ArrayAdapter<String> { public KnownHostsAdapter(Context context, int viewResourceId, List<String> mKnownHosts) { - super(context, viewResourceId, mKnownHosts); - domains = new ArrayList<String>(mKnownHosts.size()); - for (String domain : mKnownHosts) { - domains.add(new String(domain)); - } + super(context, viewResourceId, new ArrayList<String>()); + domains = new ArrayList<String>(mKnownHosts); } @Override diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 2f5994c4..fb151427 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -848,11 +848,9 @@ public class XmppConnection implements Runnable { List<Element> elements = packet.query().getChildren(); for (Element element : elements) { if (element.getName().equals("item")) { - final String jid = element.getAttribute("jid"); - try { - sendServiceDiscoveryInfo(Jid.fromString(jid).toDomainJid()); - } catch (final InvalidJidException ignored) { - // TODO: Handle the case where an external JID is technically invalid? + final Jid jid = element.getAttributeAsJid("jid"); + if (jid != null && !jid.equals(account.getServer())) { + sendServiceDiscoveryInfo(jid); } } } |