aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2015-12-16 19:55:31 +0100
committerChristian S <christian@pix-art.de>2015-12-16 19:55:31 +0100
commit081c5e4a1c8de7053d394d60c9afc82b9ea6a892 (patch)
treed5680195ef37ac6b9da16f309a49419ac7ed01d9 /src/main/java/eu/siacs
parentefaa1223b6e002d5afba0462d57ff30be91dd0e5 (diff)
parent43dd681239ea5a287f5761597de5dcdc4daed3de (diff)
copy commits
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java7
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java2
-rw-r--r--src/main/java/eu/siacs/conversations/services/AvatarService.java5
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java4
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java14
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/SettingsActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java3
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java51
10 files changed, 70 insertions, 22 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java
index 8173c05d7..430980a20 100644
--- a/src/main/java/eu/siacs/conversations/Config.java
+++ b/src/main/java/eu/siacs/conversations/Config.java
@@ -14,7 +14,10 @@ public final class Config {
public static final boolean HIDE_PGP_IN_UI = false; //some more consumer focused clients might want to disable OpenPGP
public static final boolean HIDE_ENCRYPTION_IN_UI = false; //completely hide encryption options in menu bar
- public static final boolean PARANOID_MODE = false; //disables ability to send unencrypted 1-on-1 chats and forces TOR
+
+ public static final boolean FORCE_ENCRYPTION = false; //disables ability to send unencrypted 1-on-1
+ public static final boolean FORCE_ORBOT = false; // always use TOR
+ public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
public static final boolean SHOW_CONNECTED_ACCOUNTS = false; //show number of connected accounts in foreground notification
@@ -25,6 +28,8 @@ public final class Config {
public static final int PING_TIMEOUT = 15;
public static final int SOCKET_TIMEOUT = 15;
public static final int CONNECT_TIMEOUT = 60;
+ public static final int CONNECT_DISCO_TIMEOUT = 20;
+
public static final int CARBON_GRACE_PERIOD = 90;
public static final int MINI_GRACE_PERIOD = 750;
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index bef1e5bc8..81f789f8d 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -630,7 +630,7 @@ public class Conversation extends AbstractEntity implements Blockable {
next = outgoing;
}
}
- if (Config.PARANOID_MODE && mode == MODE_SINGLE && next <= 0) {
+ if (Config.FORCE_ENCRYPTION && mode == MODE_SINGLE && next <= 0) {
if (getAccount().getAxolotlService().isContactAxolotlCapable(getContact())) {
return Message.ENCRYPTION_AXOLOTL;
} else {
diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java
index bdeab06a8..8f9b26ab4 100644
--- a/src/main/java/eu/siacs/conversations/services/AvatarService.java
+++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java
@@ -351,6 +351,11 @@ public class AvatarService {
if (drawTile(canvas, uri, left, top, right, bottom)) {
return true;
}
+ } else if (user.getAvatar() != null) {
+ Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(user.getAvatar());
+ if (drawTile(canvas, uri, left, top, right, bottom)) {
+ return true;
+ }
}
String name = contact != null ? contact.getDisplayName() : user.getName();
drawTile(canvas, name, left, top, right, bottom);
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index 7e6919581..b69e5f79e 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -234,7 +234,7 @@ public class NotificationService {
if (messages.size() > 0) {
conversation = messages.get(0).getConversation();
final String name = conversation.getName();
- if (Config.PARANOID_MODE) {
+ if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
int count = messages.size();
style.addLine(Html.fromHtml("<b>"+name+"</b> "+mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count)));
} else {
@@ -269,7 +269,7 @@ public class NotificationService {
mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
.get(conversation, getPixel(64)));
mBuilder.setContentTitle(conversation.getName());
- if (Config.PARANOID_MODE) {
+ if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
int count = messages.size();
mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count));
} else {
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 9ecdf6ae8..649ddacd8 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -547,12 +547,18 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
} else if (account.getStatus() == Account.State.OFFLINE) {
reconnectAccount(account, true, interactive);
} else if (account.getStatus() == Account.State.CONNECTING) {
- long timeout = Config.CONNECT_TIMEOUT - ((SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000);
+ long secondsSinceLastConnect = (SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000;
+ long secondsSinceLastDisco = (SystemClock.elapsedRealtime() - account.getXmppConnection().getLastDiscoStarted()) / 1000;
+ long discoTimeout = Config.CONNECT_DISCO_TIMEOUT - secondsSinceLastDisco;
+ long timeout = Config.CONNECT_TIMEOUT - secondsSinceLastConnect;
if (timeout < 0) {
Log.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting");
reconnectAccount(account, true, interactive);
+ } else if (discoTimeout < 0) {
+ account.getXmppConnection().sendDiscoTimeout();
+ scheduleWakeUpCall((int) Math.min(timeout,discoTimeout), account.getUuid().hashCode());
} else {
- scheduleWakeUpCall((int) timeout, account.getUuid().hashCode());
+ scheduleWakeUpCall((int) Math.min(timeout,discoTimeout), account.getUuid().hashCode());
}
} else {
if (account.getXmppConnection().getTimeToNextAttempt() <= 0) {
@@ -748,7 +754,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
stopSelf();
}
- protected void scheduleWakeUpCall(int seconds, int requestCode) {
+ public void scheduleWakeUpCall(int seconds, int requestCode) {
final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000;
Context context = getApplicationContext();
@@ -2568,7 +2574,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
public boolean useTorToConnect() {
- return Config.PARANOID_MODE || getPreferences().getBoolean("use_tor", false);
+ return Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false);
}
public int unreadCount() {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 547f977ba..47edd1a42 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -923,7 +923,7 @@ public class ConversationActivity extends XmppActivity
MenuItem pgp = popup.getMenu().findItem(R.id.encryption_choice_pgp);
MenuItem axolotl = popup.getMenu().findItem(R.id.encryption_choice_axolotl);
pgp.setVisible(!Config.HIDE_PGP_IN_UI);
- none.setVisible(!Config.PARANOID_MODE);
+ none.setVisible(!Config.FORCE_ENCRYPTION);
if (conversation.getMode() == Conversation.MODE_MULTI) {
otr.setVisible(false);
axolotl.setVisible(false);
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index c1c8d75cf..439ada3a6 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -491,7 +491,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
}
}
}
- this.mUseTor = Config.PARANOID_MODE || getPreferences().getBoolean("use_tor", false);
+ this.mUseTor = Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false);
this.mNamePort.setVisibility(mUseTor ? View.VISIBLE : View.GONE);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
index da9738ab5..aa23e36db 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
@@ -61,7 +61,7 @@ public class SettingsActivity extends XmppActivity implements
}
}
- if (Config.PARANOID_MODE) {
+ if (Config.FORCE_ORBOT) {
PreferenceCategory connectionOptions = (PreferenceCategory) mSettingsFragment.findPreference("connection_options");
PreferenceScreen expert = (PreferenceScreen) mSettingsFragment.findPreference("expert");
if (connectionOptions != null) {
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 2325187ec..a3cea867f 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -246,7 +246,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setText(text);
viewHolder.messageBody.setTextColor(getMessageTextColor(darkBackground, false));
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
- viewHolder.messageBody.setTextIsSelectable(false);
}
private void displayDecryptionFailed(ViewHolder viewHolder, boolean darkBackground) {
@@ -259,7 +258,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
R.string.decryption_failed));
viewHolder.messageBody.setTextColor(getMessageTextColor(darkBackground, false));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
- viewHolder.messageBody.setTextIsSelectable(false);
}
private void displayHeartMessage(final ViewHolder viewHolder, final String body) {
@@ -341,7 +339,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setLinkTextColor(this.getMessageTextColor(darkBackground, true));
viewHolder.messageBody.setHighlightColor(activity.getResources().getColor(darkBackground ? R.color.grey800 : R.color.grey500));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
- viewHolder.messageBody.setTextIsSelectable(true);
}
private void displayDownloadableMessage(ViewHolder viewHolder,
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 7455ff8d3..978f9f60b 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -116,7 +116,9 @@ public class XmppConnection implements Runnable {
private long lastPingSent = 0;
private long lastConnect = 0;
private long lastSessionStarted = 0;
+ private long lastDiscoStarted = 0;
private int mPendingServiceDiscoveries = 0;
+ private final ArrayList<String> mPendingServiceDiscoveriesIds = new ArrayList<>();
private boolean mInteractive = false;
private int attempt = 0;
private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
@@ -225,6 +227,7 @@ public class XmppConnection implements Runnable {
features.encryptionEnabled = false;
lastConnect = SystemClock.elapsedRealtime();
lastPingSent = SystemClock.elapsedRealtime();
+ lastDiscoStarted = Long.MAX_VALUE;
this.attempt++;
if (account.getJid().getDomainpart().equals("chat.facebook.com")) {
mServerIdentity = Identity.FACEBOOK;
@@ -893,6 +896,29 @@ public class XmppConnection implements Runnable {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": done clearing iq callbacks. " + this.packetCallbacks.size() + " left");
}
+ public void sendDiscoTimeout() {
+ final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR); //don't use timeout
+ final ArrayList<OnIqPacketReceived> callbacks = new ArrayList<>();
+ synchronized (this.mPendingServiceDiscoveriesIds) {
+ for(String id : mPendingServiceDiscoveriesIds) {
+ synchronized (this.packetCallbacks) {
+ Pair<IqPacket, OnIqPacketReceived> pair = this.packetCallbacks.remove(id);
+ if (pair != null) {
+ callbacks.add(pair.second);
+ }
+ }
+ }
+ this.mPendingServiceDiscoveriesIds.clear();
+ }
+ if (callbacks.size() > 0) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": sending disco timeout");
+ resetStreamId(); //we don't want to live with this for ever
+ }
+ for(OnIqPacketReceived callback : callbacks) {
+ callback.onIqPacketReceived(account,failurePacket);
+ }
+ }
+
private void sendStartSession() {
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
startSession.addChild("session", "urn:ietf:params:xml:ns:xmpp-session");
@@ -928,10 +954,12 @@ public class XmppConnection implements Runnable {
this.disco.clear();
}
mPendingServiceDiscoveries = 0;
+ lastDiscoStarted = SystemClock.elapsedRealtime();
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery");
+ mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
sendServiceDiscoveryItems(account.getServer());
sendServiceDiscoveryInfo(account.getServer());
sendServiceDiscoveryInfo(account.getJid().toBareJid());
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
this.lastSessionStarted = SystemClock.elapsedRealtime();
}
@@ -940,7 +968,7 @@ public class XmppConnection implements Runnable {
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setTo(jid);
iq.query("http://jabber.org/protocol/disco#info");
- this.sendIqPacket(iq, new OnIqPacketReceived() {
+ String id = this.sendIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
@@ -990,7 +1018,8 @@ public class XmppConnection implements Runnable {
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
mPendingServiceDiscoveries--;
if (mPendingServiceDiscoveries <= 0) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done with service discovery");
+ Log.d(Config.LOGTAG, account.getJid().toBareJid()+": done with service discovery");
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
changeStatus(Account.State.ONLINE);
if (bindListener != null) {
bindListener.onBind(account);
@@ -999,6 +1028,9 @@ public class XmppConnection implements Runnable {
}
}
});
+ synchronized (this.mPendingServiceDiscoveriesIds) {
+ this.mPendingServiceDiscoveriesIds.add(id);
+ }
}
private void enableAdvancedStreamFeatures() {
@@ -1033,7 +1065,7 @@ public class XmppConnection implements Runnable {
}
}
} else {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not query disco items of "+server);
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server);
}
}
});
@@ -1086,13 +1118,12 @@ public class XmppConnection implements Runnable {
return new BigInteger(50, mXmppConnectionService.getRNG()).toString(32);
}
- public void sendIqPacket(final IqPacket packet, final OnIqPacketReceived callback) {
+ public String sendIqPacket(final IqPacket packet, final OnIqPacketReceived callback) {
packet.setFrom(account.getJid());
- this.sendUnmodifiedIqPacket(packet, callback);
-
+ return this.sendUnmodifiedIqPacket(packet, callback);
}
- private synchronized void sendUnmodifiedIqPacket(final IqPacket packet, final OnIqPacketReceived callback) {
+ private synchronized String sendUnmodifiedIqPacket(final IqPacket packet, final OnIqPacketReceived callback) {
if (packet.getId() == null) {
final String id = nextRandomId();
packet.setAttribute("id", id);
@@ -1103,6 +1134,7 @@ public class XmppConnection implements Runnable {
}
}
this.sendPacket(packet);
+ return packet.getId();
}
public void sendMessagePacket(final MessagePacket packet) {
@@ -1293,6 +1325,9 @@ public class XmppConnection implements Runnable {
return this.lastPingSent;
}
+ public long getLastDiscoStarted() {
+ return this.lastDiscoStarted;
+ }
public long getLastPacketReceived() {
return this.lastPacketReceived;
}