From b6ea028a9d2ceed5da7aa15e68c56cfd91291e94 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 20 Mar 2014 15:49:53 +0100 Subject: added no-copy --- src/eu/siacs/conversations/crypto/OtrEngine.java | 5 ++- .../services/XmppConnectionService.java | 27 ++++------------ src/eu/siacs/conversations/xml/Element.java | 17 +++++++++- .../siacs/conversations/xmpp/XmppConnection.java | 37 ++++++---------------- .../siacs/conversations/xmpp/stanzas/IqPacket.java | 3 +- 5 files changed, 36 insertions(+), 53 deletions(-) diff --git a/src/eu/siacs/conversations/crypto/OtrEngine.java b/src/eu/siacs/conversations/crypto/OtrEngine.java index 3aa87658..8efa21eb 100644 --- a/src/eu/siacs/conversations/crypto/OtrEngine.java +++ b/src/eu/siacs/conversations/crypto/OtrEngine.java @@ -158,9 +158,8 @@ public class OtrEngine implements OtrEngineHost { packet.setFrom(account.getFullJid()); //sender packet.setTo(session.getAccountID()+"/"+session.getUserID()); //reciepient packet.setBody(body); - Element privateTag = new Element("private"); - privateTag.setAttribute("xmlns","urn:xmpp:carbons:2"); - packet.addChild(privateTag); + packet.addChild("private","urn:xmpp:carbons:2"); + packet.addChild("no-copy","urn:xmpp:hints"); packet.setType(MessagePacket.TYPE_CHAT); Log.d(LOGTAG,packet.toString()); account.getXmppConnection().sendMessagePacket(packet); diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 3e964800..187f6879 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -619,11 +619,8 @@ public class XmppConnectionService extends Service { .getFullJid()); packet.setTo(message.getCounterpart()); packet.setBody("This is an XEP-0027 encryted message"); - Element x = new Element("x"); - x.setAttribute("xmlns", "jabber:x:encrypted"); - x.setContent(this.getPgpEngine().encrypt(keyId, + packet.addChild("x","jabber:x:encrypted").setContent(this.getPgpEngine().encrypt(keyId, message.getBody())); - packet.addChild(x); account.getXmppConnection().sendMessagePacket(packet); message.setStatus(Message.STATUS_SEND); message.setEncryption(Message.ENCRYPTION_DECRYPTED); @@ -694,9 +691,8 @@ public class XmppConnectionService extends Service { + ": could not encrypt message to " + message.getCounterpart()); } - Element privateMarker = new Element("private"); - privateMarker.setAttribute("xmlns", "urn:xmpp:carbons:2"); - packet.addChild(privateMarker); + packet.addChild("private","urn:xmpp:carbons:2"); + packet.addChild("no-copy","urn:xmpp:hints"); packet.setTo(otrSession.getSessionID().getAccountID() + "/" + otrSession.getSessionID().getUserID()); packet.setFrom(account.getFullJid()); @@ -736,16 +732,13 @@ public class XmppConnectionService extends Service { public void updateRoster(final Account account, final OnRosterFetchedListener listener) { IqPacket iqPacket = new IqPacket(IqPacket.TYPE_GET); - Element query = new Element("query"); - query.setAttribute("xmlns", "jabber:iq:roster"); if (!"".equals(account.getRosterVersion())) { Log.d(LOGTAG, account.getJid() + ": fetching roster version " + account.getRosterVersion()); } else { Log.d(LOGTAG, account.getJid() + ": fetching roster"); } - query.setAttribute("ver", account.getRosterVersion()); - iqPacket.addChild(query); + iqPacket.query("jabber:iq:roster").setAttribute("ver", account.getRosterVersion()); account.getXmppConnection().sendIqPacket(iqPacket, new OnIqPacketReceived() { @@ -958,13 +951,8 @@ public class XmppConnectionService extends Service { public void deleteContact(Contact contact) { IqPacket iq = new IqPacket(IqPacket.TYPE_SET); - Element query = new Element("query"); - query.setAttribute("xmlns", "jabber:iq:roster"); - Element item = new Element("item"); - item.setAttribute("jid", contact.getJid()); - item.setAttribute("subscription", "remove"); - query.addChild(item); - iq.addChild(query); + Element query = iq.query("jabber:iq:roster"); + query.addChild("item").setAttribute("jid", contact.getJid()).setAttribute("subscription", "remove"); contact.getAccount().getXmppConnection().sendIqPacket(iq, null); replaceContactInConversation(contact.getJid(), null); databaseBackend.deleteContact(contact); @@ -1035,8 +1023,7 @@ public class XmppConnectionService extends Service { Element history = new Element("history"); long lastMsgTime = conversation.getLatestMessage().getTimeSent(); long diff = (System.currentTimeMillis() - lastMsgTime) / 1000 - 1; - history.setAttribute("seconds", diff + ""); - x.addChild(history); + x.addChild("history").setAttribute("seconds", diff + ""); } packet.addChild(x); conversation.getAccount().getXmppConnection() diff --git a/src/eu/siacs/conversations/xml/Element.java b/src/eu/siacs/conversations/xml/Element.java index 6cf6d3a5..91d9ed6b 100644 --- a/src/eu/siacs/conversations/xml/Element.java +++ b/src/eu/siacs/conversations/xml/Element.java @@ -17,7 +17,22 @@ public class Element { public Element addChild(Element child) { this.content = null; children.add(child); - return this; + return child; + } + + public Element addChild(String name) { + this.content = null; + Element child = new Element(name); + children.add(child); + return child; + } + + public Element addChild(String name, String xmlns) { + this.content = null; + Element child = new Element(name); + child.setAttribute("xmlns", xmlns); + children.add(child); + return child; } public Element setContent(String content) { diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index 49aca167..9b332c94 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -461,11 +461,7 @@ public class XmppConnection implements Runnable { if (this.streamFeatures.hasChild("session")) { Log.d(LOGTAG,"sending session"); IqPacket startSession = new IqPacket(IqPacket.TYPE_SET); - Element session = new Element("session"); - session.setAttribute("xmlns", - "urn:ietf:params:xml:ns:xmpp-session"); - session.setContent(""); - startSession.addChild(session); + startSession.addChild("session","urn:ietf:params:xml:ns:xmpp-session"); //setContent("") this.sendIqPacket(startSession, null); } } @@ -484,7 +480,8 @@ public class XmppConnection implements Runnable { IqPacket register = new IqPacket(IqPacket.TYPE_SET); Element username = new Element("username").setContent(account.getUsername()); Element password = new Element("password").setContent(account.getPassword()); - register.query("jabber:iq:register").addChild(username).addChild(password); + register.query("jabber:iq:register").addChild(username); + register.query().addChild(password); sendIqPacket(register, new OnIqPacketReceived() { @Override @@ -515,14 +512,9 @@ public class XmppConnection implements Runnable { packet.setAttribute("from", account.getFullJid()); if (account.getKeys().has("pgp_signature")) { try { - String signature = account.getKeys().getString("pgp_signature"); - Element status = new Element("status"); - status.setContent("online"); - packet.addChild(status); - Element x = new Element("x"); - x.setAttribute("xmlns", "jabber:x:signed"); - x.setContent(signature); - packet.addChild(x); + String signature = account.getKeys().getString("pgp_signature"); + packet.addChild("status").setContent("online"); + packet.addChild("x","jabber:x:signed").setContent(signature); } catch (JSONException e) { // } @@ -532,12 +524,7 @@ public class XmppConnection implements Runnable { private void sendBindRequest() throws IOException { IqPacket iq = new IqPacket(IqPacket.TYPE_SET); - Element bind = new Element("bind"); - bind.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-bind"); - Element resource = new Element("resource"); - resource.setContent("Conversations"); - bind.addChild(resource); - iq.addChild(bind); + iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent("Conversations"); this.sendIqPacket(iq, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { @@ -601,9 +588,7 @@ public class XmppConnection implements Runnable { private void sendEnableCarbons() { IqPacket iq = new IqPacket(IqPacket.TYPE_SET); - Element enable = new Element("enable"); - enable.setAttribute("xmlns", "urn:xmpp:carbons:2"); - iq.addChild(enable); + iq.addChild("enable","urn:xmpp:carbons:2"); this.sendIqPacket(iq, new OnIqPacketReceived() { @Override @@ -679,10 +664,8 @@ public class XmppConnection implements Runnable { tagWriter.writeStanzaAsync(new RequestPacket()); } else { IqPacket iq = new IqPacket(IqPacket.TYPE_GET); - Element ping = new Element("ping"); - iq.setAttribute("from",account.getFullJid()); - ping.setAttribute("xmlns", "urn:xmpp:ping"); - iq.addChild(ping); + iq.setFrom(account.getFullJid()); + iq.addChild("ping","urn:xmpp:ping"); this.sendIqPacket(iq, null); } } diff --git a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java index f70a74dd..8cd1abc0 100644 --- a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java +++ b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java @@ -39,8 +39,7 @@ public class IqPacket extends AbstractStanza { public Element query() { Element query = findChild("query"); if (query==null) { - query = new Element("query"); - addChild(query); + query = addChild("query"); } return query; } -- cgit v1.2.3 From 36dccb9f77c4f21d231ab907e21c03903cc263f4 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 21 Mar 2014 14:58:33 +0100 Subject: fixed users profile picture --- src/eu/siacs/conversations/crypto/OtrEngine.java | 2 +- .../siacs/conversations/entities/Conversation.java | 1 - src/eu/siacs/conversations/utils/MessageParser.java | 2 ++ src/eu/siacs/conversations/utils/UIHelper.java | 20 ++++++++++++-------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/eu/siacs/conversations/crypto/OtrEngine.java b/src/eu/siacs/conversations/crypto/OtrEngine.java index 8efa21eb..74e6036d 100644 --- a/src/eu/siacs/conversations/crypto/OtrEngine.java +++ b/src/eu/siacs/conversations/crypto/OtrEngine.java @@ -161,7 +161,7 @@ public class OtrEngine implements OtrEngineHost { packet.addChild("private","urn:xmpp:carbons:2"); packet.addChild("no-copy","urn:xmpp:hints"); packet.setType(MessagePacket.TYPE_CHAT); - Log.d(LOGTAG,packet.toString()); + //Log.d(LOGTAG,packet.toString()); account.getXmppConnection().sendMessagePacket(packet); } diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index b4ec210c..a13d4ea6 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -219,7 +219,6 @@ public class Conversation extends AbstractEntity { } public void startOtrSession(Context context, String presence) { - Log.d("xmppService", "starting otr session with " + presence); SessionID sessionId = new SessionID(this.getContactJid(), presence, "xmpp"); this.otrSession = new SessionImpl(sessionId, getAccount().getOtrEngine( diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index de8f4de8..1e1ec46f 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -37,6 +37,7 @@ public class MessageParser { String body = packet.getBody(); if (!conversation.hasValidOtrSession()) { if (properlyAddressed) { + Log.d("xmppService","starting new otr session with "+packet.getFrom()+" because no valid otr session has been found"); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); } else { Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]); @@ -47,6 +48,7 @@ public class MessageParser { if (!foreignPresence.equals(fromParts[1])) { conversation.resetOtrSession(); if (properlyAddressed) { + Log.d("xmppService","replacing otr session with "+packet.getFrom()); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); } else { return null; diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index 5d879714..96d628fa 100644 --- a/src/eu/siacs/conversations/utils/UIHelper.java +++ b/src/eu/siacs/conversations/utils/UIHelper.java @@ -305,15 +305,19 @@ public class UIHelper { } public static Bitmap getSelfContactPicture(Account account, int size, boolean showPhoneSelfContactPicture, Activity activity) { - Uri selfiUri = PhoneHelper.getSefliUri(activity); - if (selfiUri != null) { - try { - return BitmapFactory.decodeStream(activity - .getContentResolver().openInputStream(selfiUri)); - } catch (FileNotFoundException e) { - return getUnknownContactPicture(account.getJid(), size); + if (showPhoneSelfContactPicture) { + Uri selfiUri = PhoneHelper.getSefliUri(activity); + if (selfiUri != null) { + try { + return BitmapFactory.decodeStream(activity + .getContentResolver().openInputStream(selfiUri)); + } catch (FileNotFoundException e) { + return getUnknownContactPicture(account.getJid(), size); + } } + return getUnknownContactPicture(account.getJid(), size); + } else { + return getUnknownContactPicture(account.getJid(), size); } - return getUnknownContactPicture(account.getJid(), size); } } -- cgit v1.2.3 From bbfe102e91a4c708134228ce195497f8fe6446ff Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 21 Mar 2014 19:58:47 +0100 Subject: sending offline msgs --- .../conversations/services/XmppConnectionService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 187f6879..2c905fec 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -203,6 +203,12 @@ public class XmppConnectionService extends Service { accountChangedListener.onAccountListChangedListener(); } if (account.getStatus() == Account.STATUS_ONLINE) { + List conversations = getConversations(); + for (int i = 0; i < conversations.size(); ++i) { + if (conversations.get(i).getAccount() == account) { + sendUnsendMessages(conversations.get(i)); + } + } scheduleWakeupCall(PING_MAX_INTERVAL, true); } else if (account.getStatus() == Account.STATUS_OFFLINE) { if (!account.isOptionSet(Account.OPTION_DISABLED)) { @@ -574,12 +580,6 @@ public class XmppConnectionService extends Service { updateRoster(account, null); } connectMultiModeConversations(account); - List conversations = getConversations(); - for (int i = 0; i < conversations.size(); ++i) { - if (conversations.get(i).getAccount() == account) { - sendUnsendMessages(conversations.get(i)); - } - } if (convChangedListener != null) { convChangedListener.onConversationListChanged(); } @@ -658,7 +658,7 @@ public class XmppConnectionService extends Service { private void sendUnsendMessages(Conversation conversation) { for (int i = 0; i < conversation.getMessages().size(); ++i) { - if (conversation.getMessages().get(i).getStatus() == Message.STATUS_UNSEND) { + if ((conversation.getMessages().get(i).getStatus() == Message.STATUS_UNSEND)&&(conversation.getMessages().get(i).getEncryption() == Message.ENCRYPTION_NONE)) { Message message = conversation.getMessages().get(i); MessagePacket packet = prepareMessagePacket( conversation.getAccount(), message, null); @@ -1020,7 +1020,6 @@ public class XmppConnectionService extends Service { Element x = new Element("x"); x.setAttribute("xmlns", "http://jabber.org/protocol/muc"); if (conversation.getMessages().size() != 0) { - Element history = new Element("history"); long lastMsgTime = conversation.getLatestMessage().getTimeSent(); long diff = (System.currentTimeMillis() - lastMsgTime) / 1000 - 1; x.addChild("history").setAttribute("seconds", diff + ""); -- cgit v1.2.3 From 079712060c2a61515867e97ffb98c7c4e88e0d5a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 21 Mar 2014 21:25:28 +0100 Subject: otr safety guard --- src/eu/siacs/conversations/utils/MessageParser.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index 1e1ec46f..5cbdfd7b 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -31,6 +31,7 @@ public class MessageParser { } public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) { + boolean justStarted = false; boolean properlyAddressed = (packet.getTo().split("/").length == 2) || (account.countPresences() == 1); String[] fromParts = packet.getFrom().split("/"); Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false); @@ -39,6 +40,7 @@ public class MessageParser { if (properlyAddressed) { Log.d("xmppService","starting new otr session with "+packet.getFrom()+" because no valid otr session has been found"); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + justStarted = true; } else { Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]); return null; @@ -50,6 +52,7 @@ public class MessageParser { if (properlyAddressed) { Log.d("xmppService","replacing otr session with "+packet.getFrom()); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + justStarted = true; } else { return null; } @@ -86,7 +89,13 @@ public class MessageParser { Log.d(LOGTAG,"otr session stoped"); } } catch (Exception e) { - conversation.resetOtrSession(); + Log.d(LOGTAG,"otr execption"); + if (justStarted) { + Log.d(LOGTAG,"ran into safeguard"); + } else { + Log.d(LOGTAG,"resett otr session"); + conversation.resetOtrSession(); + } return null; } -- cgit v1.2.3 From a9e34d34926d7df3fb01143d6733b481c31c292d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 21 Mar 2014 22:14:52 +0100 Subject: tryed to fix more otr bugs. new resource setting --- res/values/arrays.xml | 19 ++--- res/xml/preferences.xml | 16 ++--- src/eu/siacs/conversations/entities/Account.java | 6 +- .../services/XmppConnectionService.java | 6 +- .../conversations/ui/ConversationFragment.java | 84 +++++++++++----------- .../siacs/conversations/utils/MessageParser.java | 7 +- .../siacs/conversations/xmpp/XmppConnection.java | 2 +- .../siacs/conversations/xmpp/stanzas/IqPacket.java | 1 - 8 files changed, 69 insertions(+), 72 deletions(-) diff --git a/res/values/arrays.xml b/res/values/arrays.xml index b8135cde..2210fbb8 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -1,17 +1,10 @@ - - None - OpenPGP - Off the record - - - none - pgp - otr - - - Delete - Disable + + Mobile + Phone + Tablet + Conversations + Android diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 904ea07e..49b3e580 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -1,20 +1,20 @@ - + android:title="General"> + diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java index 3f9510b3..8fd9444a 100644 --- a/src/eu/siacs/conversations/entities/Account.java +++ b/src/eu/siacs/conversations/entities/Account.java @@ -52,7 +52,7 @@ public class Account extends AbstractEntity{ protected String password; protected int options = 0; protected String rosterVersion; - protected String resource; + protected String resource = "mobile"; protected int status = -1; protected JSONObject keys = new JSONObject(); @@ -137,6 +137,10 @@ public class Account extends AbstractEntity{ this.resource = resource; } + public String getResource() { + return this.resource; + } + public String getJid() { return username+"@"+server; } diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 2c905fec..8bc1b389 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -7,6 +7,7 @@ import java.util.Comparator; import java.util.Date; import java.util.Hashtable; import java.util.List; +import java.util.Locale; import java.util.Random; import org.openintents.openpgp.util.OpenPgpApi; @@ -550,6 +551,9 @@ public class XmppConnectionService extends Service { } public XmppConnection createConnection(Account account) { + 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); connection.setOnMessagePacketReceivedListener(this.messageListener); @@ -588,7 +592,7 @@ public class XmppConnectionService extends Service { return connection; } - public void sendMessage(Message message, String presence) { + synchronized public void sendMessage(Message message, String presence) { Account account = message.getConversation().getAccount(); Conversation conv = message.getConversation(); boolean saveInDb = false; diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 4ae85dc2..6e5105f5 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -388,52 +388,54 @@ public class ConversationFragment extends Fragment { public void updateMessages() { ConversationActivity activity = (ConversationActivity) getActivity(); - List encryptedMessages = new LinkedList(); - for (Message message : this.conversation.getMessages()) { - if (message.getEncryption() == Message.ENCRYPTION_PGP) { - encryptedMessages.add(message); - } - } - if (encryptedMessages.size() > 0) { - DecryptMessage task = new DecryptMessage(); - Message[] msgs = new Message[encryptedMessages.size()]; - task.execute(encryptedMessages.toArray(msgs)); - } - this.messageList.clear(); - this.messageList.addAll(this.conversation.getMessages()); - this.messageListAdapter.notifyDataSetChanged(); - if (conversation.getMode() == Conversation.MODE_SINGLE) { - if (messageList.size() >= 1) { - int latestEncryption = this.conversation.getLatestMessage() - .getEncryption(); - if (latestEncryption == Message.ENCRYPTION_DECRYPTED) { - conversation.nextMessageEncryption = Message.ENCRYPTION_PGP; - } else { - conversation.nextMessageEncryption = latestEncryption; + if (this.conversation != null) { + List encryptedMessages = new LinkedList(); + for (Message message : this.conversation.getMessages()) { + if (message.getEncryption() == Message.ENCRYPTION_PGP) { + encryptedMessages.add(message); } - makeFingerprintWarning(latestEncryption); } - } else { - if (conversation.getMucOptions().getError() != 0) { - mucError.setVisibility(View.VISIBLE); - if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) { - mucErrorText.setText(getString(R.string.nick_in_use)); + if (encryptedMessages.size() > 0) { + DecryptMessage task = new DecryptMessage(); + Message[] msgs = new Message[encryptedMessages.size()]; + task.execute(encryptedMessages.toArray(msgs)); + } + this.messageList.clear(); + this.messageList.addAll(this.conversation.getMessages()); + this.messageListAdapter.notifyDataSetChanged(); + if (conversation.getMode() == Conversation.MODE_SINGLE) { + if (messageList.size() >= 1) { + int latestEncryption = this.conversation.getLatestMessage() + .getEncryption(); + if (latestEncryption == Message.ENCRYPTION_DECRYPTED) { + conversation.nextMessageEncryption = Message.ENCRYPTION_PGP; + } else { + conversation.nextMessageEncryption = latestEncryption; + } + makeFingerprintWarning(latestEncryption); } } else { - mucError.setVisibility(View.GONE); + if (conversation.getMucOptions().getError() != 0) { + mucError.setVisibility(View.VISIBLE); + if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) { + mucErrorText.setText(getString(R.string.nick_in_use)); + } + } else { + mucError.setVisibility(View.GONE); + } + } + getActivity().invalidateOptionsMenu(); + updateChatMsgHint(); + int size = this.messageList.size(); + if (size >= 1) + messagesView.setSelection(size - 1); + if (!activity.shouldPaneBeOpen()) { + conversation.markRead(); + // TODO update notifications + UIHelper.updateNotification(getActivity(), + activity.getConversationList(), null, false); + activity.updateConversationList(); } - } - getActivity().invalidateOptionsMenu(); - updateChatMsgHint(); - int size = this.messageList.size(); - if (size >= 1) - messagesView.setSelection(size - 1); - if (!activity.shouldPaneBeOpen()) { - conversation.markRead(); - // TODO update notifications - UIHelper.updateNotification(getActivity(), - activity.getConversationList(), null, false); - activity.updateConversationList(); } } diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index 5cbdfd7b..58235678 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -2,7 +2,6 @@ package eu.siacs.conversations.utils; import java.util.List; -import net.java.otr4j.OtrException; import net.java.otr4j.session.Session; import net.java.otr4j.session.SessionStatus; import android.util.Log; @@ -89,11 +88,7 @@ public class MessageParser { Log.d(LOGTAG,"otr session stoped"); } } catch (Exception e) { - Log.d(LOGTAG,"otr execption"); - if (justStarted) { - Log.d(LOGTAG,"ran into safeguard"); - } else { - Log.d(LOGTAG,"resett otr session"); + if (!justStarted) { conversation.resetOtrSession(); } return null; diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index 9b332c94..1d386f91 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -524,7 +524,7 @@ public class XmppConnection implements Runnable { private void sendBindRequest() throws IOException { IqPacket iq = new IqPacket(IqPacket.TYPE_SET); - iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent("Conversations"); + iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent(account.getResource()); this.sendIqPacket(iq, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { diff --git a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java index 8cd1abc0..3ab3b6c3 100644 --- a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java +++ b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java @@ -1,6 +1,5 @@ package eu.siacs.conversations.xmpp.stanzas; -import android.graphics.YuvImage; import eu.siacs.conversations.xml.Element; -- cgit v1.2.3