From b5719fd747a9a6d9757eccb0f20c22c2daaa9928 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 15 Sep 2015 22:49:43 +0200 Subject: work around a NPE caused by arace condition in the http upload --- .../java/eu/siacs/conversations/http/HttpUploadConnection.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index 2e5458423..38e25e7af 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -70,11 +70,14 @@ public class HttpUploadConnection implements Transferable { @Override public long getFileSize() { - return this.file.getExpectedSize(); + return file == null ? 0 : file.getExpectedSize(); } @Override public int getProgress() { + if (file == null) { + return 0; + } return (int) ((((double) transmitted) / file.getExpectedSize()) * 100); } @@ -92,8 +95,6 @@ public class HttpUploadConnection implements Transferable { public void init(Message message, boolean delay) { this.message = message; - message.setTransferable(this); - mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND); this.account = message.getConversation().getAccount(); this.file = mXmppConnectionService.getFileBackend().getFile(message, false); this.mime = this.file.getMimeType(); @@ -139,6 +140,8 @@ public class HttpUploadConnection implements Transferable { } } }); + message.setTransferable(this); + mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND); } private class FileUploader implements Runnable { -- cgit v1.2.3 From b9002d7fd5455ca2c13934748531b30a97799a9f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 15 Sep 2015 22:52:35 +0200 Subject: added missing type='submit' to mam queries fixed some nasty inheritance problems along the way fixes #1411 --- src/main/java/eu/siacs/conversations/entities/Bookmark.java | 10 +++------- .../java/eu/siacs/conversations/entities/Conversation.java | 4 ++-- .../java/eu/siacs/conversations/generator/IqGenerator.java | 7 ++++--- .../eu/siacs/conversations/services/XmppConnectionService.java | 4 ++-- src/main/java/eu/siacs/conversations/xml/Element.java | 10 +++++----- src/main/java/eu/siacs/conversations/xmpp/forms/Field.java | 2 +- 6 files changed, 17 insertions(+), 20 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java index cc6f146b5..0210da245 100644 --- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java +++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java @@ -50,8 +50,8 @@ public class Bookmark extends Element implements ListItem { if (this.mJoinedConversation != null && (this.mJoinedConversation.getMucOptions().getSubject() != null)) { return this.mJoinedConversation.getMucOptions().getSubject(); - } else if (getName() != null) { - return getName(); + } else if (getBookmarkName() != null) { + return getBookmarkName(); } else { return this.getJid().getLocalpart(); } @@ -134,14 +134,10 @@ public class Bookmark extends Element implements ListItem { this.mJoinedConversation = conversation; } - public String getName() { + public String getBookmarkName() { return this.getAttribute("name"); } - public void setName(String name) { - this.name = name; - } - public void unregisterConversation() { if (this.mJoinedConversation != null) { this.mJoinedConversation.deregisterWithBookmark(); diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 1af87c429..f4d116fe0 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -340,8 +340,8 @@ public class Conversation extends AbstractEntity implements Blockable { if (getMode() == MODE_MULTI) { if (getMucOptions().getSubject() != null) { return getMucOptions().getSubject(); - } else if (bookmark != null && bookmark.getName() != null) { - return bookmark.getName(); + } else if (bookmark != null && bookmark.getBookmarkName() != null) { + return bookmark.getBookmarkName(); } else { String generatedName = getMucOptions().createNameFromParticipants(); if (generatedName != null) { diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index 898d218e4..835b9bf6c 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -176,7 +176,7 @@ public class IqGenerator extends AbstractGenerator { public IqPacket queryMessageArchiveManagement(final MessageArchiveService.Query mam) { final IqPacket packet = new IqPacket(IqPacket.TYPE.SET); final Element query = packet.query("urn:xmpp:mam:0"); - query.setAttribute("queryid",mam.getQueryId()); + query.setAttribute("queryid", mam.getQueryId()); final Data data = new Data(); data.setFormType("urn:xmpp:mam:0"); if (mam.muc()) { @@ -184,8 +184,9 @@ public class IqGenerator extends AbstractGenerator { } else if (mam.getWith()!=null) { data.put("with", mam.getWith().toString()); } - data.put("start",getTimestamp(mam.getStart())); - data.put("end",getTimestamp(mam.getEnd())); + data.put("start", getTimestamp(mam.getStart())); + data.put("end", getTimestamp(mam.getEnd())); + data.submit(); query.addChild(data); if (mam.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) { query.addChild("set", "http://jabber.org/protocol/rsm").addChild("before").setContent(mam.getReference()); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 1168e0403..ee0ccd4f7 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1701,8 +1701,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa if (packet.getType() == IqPacket.TYPE.RESULT) { Data data = Data.parse(packet.query().findChild("x", "jabber:x:data")); for (Field field : data.getFields()) { - if (options.containsKey(field.getName())) { - field.setValue(options.getString(field.getName())); + if (options.containsKey(field.getFieldName())) { + field.setValue(options.getString(field.getFieldName())); } } data.submit(); diff --git a/src/main/java/eu/siacs/conversations/xml/Element.java b/src/main/java/eu/siacs/conversations/xml/Element.java index 7b4937b26..e82c446bd 100644 --- a/src/main/java/eu/siacs/conversations/xml/Element.java +++ b/src/main/java/eu/siacs/conversations/xml/Element.java @@ -12,9 +12,9 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; public class Element { - protected String name; - protected Hashtable attributes = new Hashtable<>(); - protected String content; + private final String name; + private Hashtable attributes = new Hashtable<>(); + private String content; protected List children = new ArrayList<>(); public Element(String name) { @@ -98,7 +98,7 @@ public class Element { return this; } - public String getContent() { + public final String getContent() { return content; } @@ -162,7 +162,7 @@ public class Element { return elementOutput.toString(); } - public String getName() { + public final String getName() { return name; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java b/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java index ee2c51a9c..c83880005 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java +++ b/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java @@ -16,7 +16,7 @@ public class Field extends Element { super("field"); } - public String getName() { + public String getFieldName() { return this.getAttribute("var"); } -- cgit v1.2.3 From b1b13ba0e52a42e4c978cd77b75a3d750642f53d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 15 Sep 2015 22:56:02 +0200 Subject: pulled translations from transifex --- src/main/res/values-bg/strings.xml | 3 +++ src/main/res/values-cs/strings.xml | 5 +++++ src/main/res/values-de/strings.xml | 5 +++++ src/main/res/values-eu/strings.xml | 5 +++++ src/main/res/values-fr/strings.xml | 5 +++++ src/main/res/values-ru/strings.xml | 4 ++-- src/main/res/values-sv/strings.xml | 5 +++++ 7 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/res/values-bg/strings.xml b/src/main/res/values-bg/strings.xml index 2578b1a4f..955e2450b 100644 --- a/src/main/res/values-bg/strings.xml +++ b/src/main/res/values-bg/strings.xml @@ -408,7 +408,10 @@ Публично достъпни беседи Частни беседи, само за членове Настройки на беседата + Частно, само за членове Не-анонимна + С модератор + Вие не участвате Настройките на беседата бяха променени! Неуспешна промяна на настройките на беседата Никога diff --git a/src/main/res/values-cs/strings.xml b/src/main/res/values-cs/strings.xml index 696afc3b0..de7945599 100644 --- a/src/main/res/values-cs/strings.xml +++ b/src/main/res/values-cs/strings.xml @@ -408,7 +408,10 @@ Veřejně přístupná konference Soukromá konference pouze pro členy Nastavení konference + Soukromé, pouze pro členy Neanonymní + Moderováno + Neúčastníte se Nastavení konference upravena! Nepodařilo se upravit nastavení konference! Nikdy @@ -481,4 +484,6 @@ Stahování selhalo: Nelze se připojit k hostu Použít bílé pozadí Zobrazovat přijaté zprávy jako černý text na bílém pozadí + Vypršení v DNS + Rozbité diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 3ca5abc60..d2235f181 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -408,7 +408,10 @@ Öffentlich zugängliche Konferenz Private Konferenz nur für Mitglieder Konferenz-Optionen + Privat, nur Mitglieder De-anonymisiert + Moderiert + Du bist kein Mitglied Konferenz-Optionen wurden modifiziert! Konferenz-Optionen konnten nicht modifiziert werden Niemals @@ -479,4 +482,6 @@ Download fehlgeschlagen: keine Verbindung zum Host Weißen Hintergrund benutzen Empfangene Nachrichten als schwarzen Text auf weißem Hintergrund anzeigen + Zeitüberschreitung bei der Namensauflösung + Fehlerhaft diff --git a/src/main/res/values-eu/strings.xml b/src/main/res/values-eu/strings.xml index feccf39d4..70fa22e58 100644 --- a/src/main/res/values-eu/strings.xml +++ b/src/main/res/values-eu/strings.xml @@ -408,7 +408,10 @@ Publikoki edonor sar daiteken konferentzia Konferentzia pribatua, kideentzat soilik Konferentziaren aukerak + Pribatua, kideentzat soilik Ez anonimoa + Moderatua + Ez zara parte hartzen ari Konferentziaren aukerak aldatu dira Konferentziaren aukerak ezin izan dira aldatu Inoiz @@ -479,4 +482,6 @@ Deskargak huts egin du: ezin izan da ostalarira konektatu Atzeko-planoan kolore zuria erabili Jasotako mezuak testu beltza atzeko-plano zuri baten gainean bezala erakutsi + DNSan denboraz kanpoko arazoa + Hondatuta diff --git a/src/main/res/values-fr/strings.xml b/src/main/res/values-fr/strings.xml index c516f1eed..24e2f4f25 100644 --- a/src/main/res/values-fr/strings.xml +++ b/src/main/res/values-fr/strings.xml @@ -408,7 +408,10 @@ Conférence accessible au public Conférence privée, réservée aux membres Options de la conférence + Privé, membres uniquement Non anonyme + Modéré + Vous ne participez pas Options de la conférence modifiée! Impossible de modifier les options de la conférence Jamais @@ -479,4 +482,6 @@ Échec du téléchargement: Impossible de se connecter au serveur Utiliser un fond blanc Afficher les messages reçus en texte noir sur fond blanc + Expiration dans le DNS + Détraqué diff --git a/src/main/res/values-ru/strings.xml b/src/main/res/values-ru/strings.xml index 93ab2f3a8..e8b58dd66 100644 --- a/src/main/res/values-ru/strings.xml +++ b/src/main/res/values-ru/strings.xml @@ -443,13 +443,13 @@ Удалён %d сертификат Удалено %d сертификатов - + Удалено %d сертификатов Удалено %d сертификатов Выбран %d контакт Выбрано %d контактов - + Выбрано %d контактов Выбрано %d контактов Заменить кнопку отправки кнопкой быстрого действия diff --git a/src/main/res/values-sv/strings.xml b/src/main/res/values-sv/strings.xml index 734a8bda8..6a7908848 100644 --- a/src/main/res/values-sv/strings.xml +++ b/src/main/res/values-sv/strings.xml @@ -408,7 +408,10 @@ Publikt tillgänglig konferens Privat konferens där medlemsskap krävs Konferensalternativ + Privat, medlemsskap krävs Icke-anonymt + Modererad + Du deltar ej Ändrade konferensalternativ Kunde inte ändra konferensalternativ Aldrig @@ -479,4 +482,6 @@ Nerladdningen gick fel: Kunder inte ansluta till server Använd vit bakgrund Visa mottagna meddelanden som svart text på vit bakgrund + Timeout för DNS + Sönder -- cgit v1.2.3 From 7e712d9d4cdd7fb8aa6c7ef68ce2d5c39ff1c257 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 17 Sep 2015 13:55:27 +0200 Subject: fixed rare NPE in DnsHelper. fixed spelling and added logging --- .../java/eu/siacs/conversations/utils/DNSHelper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index 70bc73606..863cfb66b 100644 --- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java @@ -45,7 +45,7 @@ public class DNSHelper { public static Bundle getSRVRecord(final Jid jid, Context context) throws IOException { final String host = jid.getDomainpart(); - final List servers = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDnsServers(context) : getDnsServersPreLolipop(); + final List servers = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDnsServers(context) : getDnsServersPreLollipop(); Bundle b = null; for(InetAddress server : servers) { b = queryDNS(host, server); @@ -60,15 +60,23 @@ public class DNSHelper { private static List getDnsServers(Context context) { List servers = new ArrayList<>(); ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - Network[] networks = connectivityManager.getAllNetworks(); + Network[] networks = connectivityManager == null ? null : connectivityManager.getAllNetworks(); + if (networks == null) { + return getDnsServersPreLollipop(); + } for(int i = 0; i < networks.length; ++i) { LinkProperties linkProperties = connectivityManager.getLinkProperties(networks[i]); - servers.addAll(linkProperties.getDnsServers()); + if (linkProperties != null) { + servers.addAll(linkProperties.getDnsServers()); + } + } + if (servers.size() > 0) { + Log.d(Config.LOGTAG,"used lollipop variant to discover dns servers in "+networks.length+" networks"); } - return servers.size() > 0 ? servers : getDnsServersPreLolipop(); + return servers.size() > 0 ? servers : getDnsServersPreLollipop(); } - private static List getDnsServersPreLolipop() { + private static List getDnsServersPreLollipop() { List servers = new ArrayList<>(); String[] dns = client.findDNS(); for(int i = 0; i < dns.length; ++i) { -- cgit v1.2.3 From 07c7f5bc086de3f99396a773371e76cbbb2901e0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 17 Sep 2015 14:02:28 +0200 Subject: catch IndexOutOfBoundsException when swiping away conversations --- src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 913190b47..48045a64c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -210,7 +210,11 @@ public class ConversationActivity extends XmppActivity View v = listView.getChildAt(0); final int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop()); - swipedConversation = listAdapter.getItem(position); + try { + swipedConversation = listAdapter.getItem(position); + } catch (IndexOutOfBoundsException e) { + return null; + } listAdapter.remove(swipedConversation); swipedConversation.markRead(); xmppConnectionService.getNotificationService().clear(swipedConversation); -- cgit v1.2.3 From c173d78950fd495294691d1803d60ca868896a8f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 17 Sep 2015 14:13:38 +0200 Subject: ignore spoofed stanzas in facebook chat --- src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index a65f51fef..870f50d5d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -480,7 +480,7 @@ public class XmppConnection implements Runnable { final Pair packetCallbackDuple = packetCallbacks.get(packet.getId()); // Packets to the server should have responses from the server if (packetCallbackDuple.first.toServer(account)) { - if (packet.fromServer(account)) { + if (packet.fromServer(account) || account.getJid().getDomainpart().equals("chat.facebook.com")) { callback = packetCallbackDuple.second; packetCallbacks.remove(packet.getId()); } else { -- cgit v1.2.3 From 506b83ddc6f634f36729b0d498b64b61e31b5849 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 17 Sep 2015 14:18:06 +0200 Subject: be more careful when publishing device bundle --- .../siacs/conversations/crypto/axolotl/AxolotlService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index df7f905b2..70de2777d 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -394,6 +394,20 @@ public class AxolotlService { mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { + + if (packet.getType() == IqPacket.TYPE.TIMEOUT) { + return; //ignore timeout. do nothing + } + + if (packet.getType() == IqPacket.TYPE.ERROR) { + Element error = packet.findChild("error"); + if (error == null || !error.hasChild("item-not-found")) { + pepBroken = true; + Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account) + "request for device bundles came back with something other than item-not-found" + packet); + return; + } + } + PreKeyBundle bundle = mXmppConnectionService.getIqParser().bundle(packet); Map keys = mXmppConnectionService.getIqParser().preKeyPublics(packet); boolean flush = false; -- cgit v1.2.3 From b54b4ca78a85055292ea54b5acfaaec25c43f412 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 17 Sep 2015 14:42:50 +0200 Subject: introduced Config variable to use legacy namespace for http upload --- src/main/java/eu/siacs/conversations/Config.java | 2 ++ src/main/java/eu/siacs/conversations/utils/Xmlns.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 6b57f7ea8..b4dcf209d 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -13,6 +13,8 @@ public final class Config { public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox public static final boolean HIDE_PGP_IN_UI = false; //some more consumer focused clients might want to disable OpenPGP + public static final boolean LEGACY_NAMESPACE_HTTP_UPLOAD = false; + public static final int PING_MAX_INTERVAL = 300; public static final int PING_MIN_INTERVAL = 30; public static final int PING_TIMEOUT = 15; diff --git a/src/main/java/eu/siacs/conversations/utils/Xmlns.java b/src/main/java/eu/siacs/conversations/utils/Xmlns.java index de0a29ce2..a19ec791f 100644 --- a/src/main/java/eu/siacs/conversations/utils/Xmlns.java +++ b/src/main/java/eu/siacs/conversations/utils/Xmlns.java @@ -1,9 +1,11 @@ package eu.siacs.conversations.utils; +import eu.siacs.conversations.Config; + public final class Xmlns { public static final String BLOCKING = "urn:xmpp:blocking"; public static final String ROSTER = "jabber:iq:roster"; public static final String REGISTER = "jabber:iq:register"; public static final String BYTE_STREAMS = "http://jabber.org/protocol/bytestreams"; - public static final String HTTP_UPLOAD = "urn:xmpp:http:upload"; + public static final String HTTP_UPLOAD = Config.LEGACY_NAMESPACE_HTTP_UPLOAD ? "eu:siacs:conversations:http:upload" : "urn:xmpp:http:upload"; } -- cgit v1.2.3