aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2015-09-18 12:25:12 +0200
committerChristian S <christian@pix-art.de>2015-09-18 12:25:12 +0200
commita3c12ed17d9468aef95521f4fa9ae5dfeaf91abd (patch)
tree321d53cbee15dcc004fe68172edc8221be396855 /src/main/java/eu/siacs
parenteb829eb307b69989ae4efdcb23cf2d8a28979b33 (diff)
parentb54b4ca78a85055292ea54b5acfaaec25c43f412 (diff)
copy commits
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java2
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java14
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Bookmark.java10
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java4
-rw-r--r--src/main/java/eu/siacs/conversations/generator/IqGenerator.java7
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java9
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java4
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java115
-rw-r--r--src/main/java/eu/siacs/conversations/utils/DNSHelper.java18
-rw-r--r--src/main/java/eu/siacs/conversations/utils/Xmlns.java4
-rw-r--r--src/main/java/eu/siacs/conversations/xml/Element.java10
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java2
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/forms/Field.java2
13 files changed, 115 insertions, 86 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java
index cddcd6d55..30f762a6b 100644
--- a/src/main/java/eu/siacs/conversations/Config.java
+++ b/src/main/java/eu/siacs/conversations/Config.java
@@ -14,6 +14,8 @@ public final class Config {
public static final boolean HIDE_PGP_IN_UI = true; //some more consumer focused clients might want to disable OpenPGP
public static final boolean HIDE_ENCRYPTION_IN_UI = true; //completely hide encryption options in menu bar
+ 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/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<Integer, ECPublicKey> keys = mXmppConnectionService.getIqParser().preKeyPublics(packet);
boolean flush = false;
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 dce60e4a5..8ffc44141 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -341,8 +341,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/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 {
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/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 986abf6a5..16ce570c8 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -204,65 +204,68 @@ public class ConversationActivity extends XmppActivity
});
listView.setDismissCallback(new EnhancedListView.OnDismissCallback() {
+ @Override
+ public EnhancedListView.Undoable onDismiss(final EnhancedListView enhancedListView, final int position) {
- @Override
- public EnhancedListView.Undoable onDismiss(final EnhancedListView enhancedListView, final int position) {
-
- final int index = listView.getFirstVisiblePosition();
- View v = listView.getChildAt(0);
- final int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
-
- swipedConversation = listAdapter.getItem(position);
- listAdapter.remove(swipedConversation);
- swipedConversation.markRead();
- xmppConnectionService.getNotificationService().clear(swipedConversation);
-
- final boolean formerlySelected = (getSelectedConversation() == swipedConversation);
- if (position == 0 && listAdapter.getCount() == 0) {
- endConversation(swipedConversation, false, true);
- return null;
- } else if (formerlySelected) {
- setSelectedConversation(listAdapter.getItem(0));
- ConversationActivity.this.mConversationFragment
- .reInit(getSelectedConversation());
- }
-
- return new EnhancedListView.Undoable() {
-
- @Override
- public void undo() {
- listAdapter.insert(swipedConversation, position);
- if (formerlySelected) {
- setSelectedConversation(swipedConversation);
- ConversationActivity.this.mConversationFragment
- .reInit(getSelectedConversation());
- }
- swipedConversation = null;
- listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
- }
+ final int index = listView.getFirstVisiblePosition();
+ View v = listView.getChildAt(0);
+ final int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
- @Override
- public void discard() {
- if (!swipedConversation.isRead()
- && swipedConversation.getMode() == Conversation.MODE_SINGLE) {
- swipedConversation = null;
- return;
- }
- endConversation(swipedConversation, false, false);
- swipedConversation = null;
- }
+ try {
+ swipedConversation = listAdapter.getItem(position);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
+ listAdapter.remove(swipedConversation);
+ swipedConversation.markRead();
+ xmppConnectionService.getNotificationService().clear(swipedConversation);
+
+ final boolean formerlySelected = (getSelectedConversation() == swipedConversation);
+ if (position == 0 && listAdapter.getCount() == 0) {
+ endConversation(swipedConversation, false, true);
+ return null;
+ } else if (formerlySelected) {
+ setSelectedConversation(listAdapter.getItem(0));
+ ConversationActivity.this.mConversationFragment
+ .reInit(getSelectedConversation());
+ }
- @Override
- public String getTitle() {
- if (swipedConversation.getMode() == Conversation.MODE_MULTI) {
- return getResources().getString(R.string.title_undo_swipe_out_muc);
- } else {
- return getResources().getString(R.string.title_undo_swipe_out_conversation);
- }
- }
- };
- }
- });
+ return new EnhancedListView.Undoable() {
+
+ @Override
+ public void undo() {
+ listAdapter.insert(swipedConversation, position);
+ if (formerlySelected) {
+ setSelectedConversation(swipedConversation);
+ ConversationActivity.this.mConversationFragment
+ .reInit(getSelectedConversation());
+ }
+ swipedConversation = null;
+ listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
+ }
+
+ @Override
+ public void discard() {
+ if (!swipedConversation.isRead()
+ && swipedConversation.getMode() == Conversation.MODE_SINGLE) {
+ swipedConversation = null;
+ return;
+ }
+ endConversation(swipedConversation, false, false);
+ swipedConversation = null;
+ }
+
+ @Override
+ public String getTitle() {
+ if (swipedConversation.getMode() == Conversation.MODE_MULTI) {
+ return getResources().getString(R.string.title_undo_swipe_out_muc);
+ } else {
+ return getResources().getString(R.string.title_undo_swipe_out_conversation);
+ }
+ }
+ };
+ }
+ });
listView.enableSwipeToDismiss();
listView.setSwipingLayout(R.id.swipeable_item);
listView.setUndoStyle(EnhancedListView.UndoStyle.SINGLE_POPUP);
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<InetAddress> servers = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDnsServers(context) : getDnsServersPreLolipop();
+ final List<InetAddress> 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<InetAddress> getDnsServers(Context context) {
List<InetAddress> 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<InetAddress> getDnsServersPreLolipop() {
+ private static List<InetAddress> getDnsServersPreLollipop() {
List<InetAddress> servers = new ArrayList<>();
String[] dns = client.findDNS();
for(int i = 0; i < dns.length; ++i) {
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";
}
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<String, String> attributes = new Hashtable<>();
- protected String content;
+ private final String name;
+ private Hashtable<String, String> attributes = new Hashtable<>();
+ private String content;
protected List<Element> 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/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<IqPacket, OnIqPacketReceived> 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 {
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");
}