aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2016-04-11 19:52:37 +0200
committerChristian S <christian@pix-art.de>2016-04-11 19:52:37 +0200
commita096fb7c8bdabc609f0cf9ff3786c159a048d82c (patch)
tree7b0a50d4ac6dc713b613898884a9946667b6a16a /src/main
parentec870c793a3429519cc42971c45a446d946f1dd4 (diff)
parent23a0beab43a5f30baf6481afeb9188b86df0b32d (diff)
Merge remote-tracking branch 'refs/remotes/siacs/master' into development
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java5
-rw-r--r--src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java9
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java83
-rw-r--r--src/main/res/values-de/strings.xml4
-rw-r--r--src/main/res/values/strings.xml8
-rw-r--r--src/main/res/xml/preferences.xml7
6 files changed, 68 insertions, 48 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index 5d4927279..7eef10f8f 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -180,6 +180,7 @@ public class NotificationService {
final String ringtone = preferences.getString("notification_ringtone", null);
final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);
+ final boolean led = preferences.getBoolean("led", true);
if (notifications.size() == 0) {
notificationManager.cancel(NOTIFICATION_ID);
@@ -210,7 +211,9 @@ public class NotificationService {
mBuilder.setDefaults(0);
mBuilder.setSmallIcon(R.drawable.ic_notification);
mBuilder.setDeleteIntent(createDeleteIntent());
- mBuilder.setLights(0xff00FF00, 2000, 3000);
+ if (led) {
+ mBuilder.setLights(0xff00FF00, 2000, 3000);
+ }
final Notification notification = mBuilder.build();
notificationManager.notify(NOTIFICATION_ID, notification);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index 787c325ae..a8b667cee 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -241,12 +241,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
mFetchingAvatar = true;
xmppConnectionService.checkForAvatar(mAccount, mAvatarFetchCallback);
}
- } else {
- updateSaveButton();
}
if (mAccount != null) {
updateAccountInformation(false);
}
+ updateSaveButton();
}
@Override
@@ -335,7 +334,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
this.mSaveButton.setText(R.string.save);
this.mSaveButton.setEnabled(true);
this.mSaveButton.setTextColor(getPrimaryTextColor());
- } else if (mAccount != null && (mAccount.getStatus() == Account.State.CONNECTING || mFetchingAvatar)) {
+ } else if (mAccount != null
+ && (mAccount.getStatus() == Account.State.CONNECTING || mAccount.getStatus() == Account.State.REGISTRATION_SUCCESSFUL|| mFetchingAvatar)) {
this.mSaveButton.setEnabled(false);
this.mSaveButton.setTextColor(getSecondaryTextColor());
this.mSaveButton.setText(R.string.account_status_connecting);
@@ -536,6 +536,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
protected void onBackendConnected() {
if (this.jidToEdit != null) {
this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
+ this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER);
if (this.mAccount != null) {
if (this.mAccount.getPrivateKeyAlias() != null) {
this.mPassword.setHint(R.string.authenticate_with_certificate);
@@ -631,6 +632,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
if (!mInitMode) {
this.mAvatar.setVisibility(View.VISIBLE);
this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(Config.AVATAR_SIZE)));
+ } else {
+ this.mAvatar.setVisibility(View.GONE);
}
if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
this.mRegisterNew.setVisibility(View.VISIBLE);
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 6427c3471..7bc08e9ca 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -183,16 +183,18 @@ public class XmppConnection implements Runnable {
if (packet.getType() == IqPacket.TYPE.RESULT) {
account.setOption(Account.OPTION_REGISTER,
false);
+ forceCloseSocket();
changeStatus(Account.State.REGISTRATION_SUCCESSFUL);
} else if (packet.hasChild("error")
&& (packet.findChild("error")
.hasChild("conflict"))) {
+ forceCloseSocket();
changeStatus(Account.State.REGISTRATION_CONFLICT);
} else {
+ forceCloseSocket();
changeStatus(Account.State.REGISTRATION_FAILED);
Log.d(Config.LOGTAG, packet.toString());
}
- disconnect(true);
}
};
}
@@ -558,7 +560,6 @@ public class XmppConnection implements Runnable {
}
nextTag = tagReader.readTag();
}
- throw new IOException("reached end of stream. last tag was "+nextTag);
}
private void acknowledgeStanzaUpTo(int serverCount) {
@@ -739,47 +740,12 @@ public class XmppConnection implements Runnable {
}
} else if (!this.streamFeatures.hasChild("register")
&& account.isOptionSet(Account.OPTION_REGISTER)) {
+ forceCloseSocket();
changeStatus(Account.State.REGISTRATION_NOT_SUPPORTED);
- disconnect(true);
} else if (this.streamFeatures.hasChild("mechanisms")
&& shouldAuthenticate
&& (features.encryptionEnabled || Config.ALLOW_NON_TLS_CONNECTIONS)) {
- final List<String> mechanisms = extractMechanisms(streamFeatures
- .findChild("mechanisms"));
- final Element auth = new Element("auth");
- auth.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
- if (mechanisms.contains("EXTERNAL") && account.getPrivateKeyAlias() != null) {
- saslMechanism = new External(tagWriter, account, mXmppConnectionService.getRNG());
- } else if (mechanisms.contains("SCRAM-SHA-1")) {
- saslMechanism = new ScramSha1(tagWriter, account, mXmppConnectionService.getRNG());
- } else if (mechanisms.contains("PLAIN")) {
- saslMechanism = new Plain(tagWriter, account);
- } else if (mechanisms.contains("DIGEST-MD5")) {
- saslMechanism = new DigestMd5(tagWriter, account, mXmppConnectionService.getRNG());
- }
- if (saslMechanism != null) {
- final JSONObject keys = account.getKeys();
- try {
- if (keys.has(Account.PINNED_MECHANISM_KEY) &&
- keys.getInt(Account.PINNED_MECHANISM_KEY) > saslMechanism.getPriority()) {
- Log.e(Config.LOGTAG, "Auth failed. Authentication mechanism " + saslMechanism.getMechanism() +
- " has lower priority (" + String.valueOf(saslMechanism.getPriority()) +
- ") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) +
- "). Possible downgrade attack?");
- throw new SecurityException();
- }
- } catch (final JSONException e) {
- Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism");
- }
- Log.d(Config.LOGTAG, account.getJid().toString() + ": Authenticating with " + saslMechanism.getMechanism());
- auth.setAttribute("mechanism", saslMechanism.getMechanism());
- if (!saslMechanism.getClientFirstMessage().isEmpty()) {
- auth.setContent(saslMechanism.getClientFirstMessage());
- }
- tagWriter.writeElement(auth);
- } else {
- throw new IncompatibleServerException();
- }
+ authenticate();
} else if (this.streamFeatures.hasChild("sm", "urn:xmpp:sm:" + smVersion) && streamId != null) {
if (Config.EXTENDED_SM_LOGGING) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": resuming after stanza #"+stanzasReceived);
@@ -795,6 +761,45 @@ public class XmppConnection implements Runnable {
}
}
+ private void authenticate() throws IOException {
+ final List<String> mechanisms = extractMechanisms(streamFeatures
+ .findChild("mechanisms"));
+ final Element auth = new Element("auth");
+ auth.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
+ if (mechanisms.contains("EXTERNAL") && account.getPrivateKeyAlias() != null) {
+ saslMechanism = new External(tagWriter, account, mXmppConnectionService.getRNG());
+ } else if (mechanisms.contains("SCRAM-SHA-1")) {
+ saslMechanism = new ScramSha1(tagWriter, account, mXmppConnectionService.getRNG());
+ } else if (mechanisms.contains("PLAIN")) {
+ saslMechanism = new Plain(tagWriter, account);
+ } else if (mechanisms.contains("DIGEST-MD5")) {
+ saslMechanism = new DigestMd5(tagWriter, account, mXmppConnectionService.getRNG());
+ }
+ if (saslMechanism != null) {
+ final JSONObject keys = account.getKeys();
+ try {
+ if (keys.has(Account.PINNED_MECHANISM_KEY) &&
+ keys.getInt(Account.PINNED_MECHANISM_KEY) > saslMechanism.getPriority()) {
+ Log.e(Config.LOGTAG, "Auth failed. Authentication mechanism " + saslMechanism.getMechanism() +
+ " has lower priority (" + String.valueOf(saslMechanism.getPriority()) +
+ ") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) +
+ "). Possible downgrade attack?");
+ throw new SecurityException();
+ }
+ } catch (final JSONException e) {
+ Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism");
+ }
+ Log.d(Config.LOGTAG, account.getJid().toString() + ": Authenticating with " + saslMechanism.getMechanism());
+ auth.setAttribute("mechanism", saslMechanism.getMechanism());
+ if (!saslMechanism.getClientFirstMessage().isEmpty()) {
+ auth.setContent(saslMechanism.getClientFirstMessage());
+ }
+ tagWriter.writeElement(auth);
+ } else {
+ throw new IncompatibleServerException();
+ }
+ }
+
private List<String> extractMechanisms(final Element stream) {
final ArrayList<String> mechanisms = new ArrayList<>(stream
.getChildren().size());
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index 8ff58ede1..8fd8cd6ee 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -105,6 +105,8 @@
<string name="pref_notifications_summary">Benachrichtigen bei Erhalt einer neuen Nachricht</string>
<string name="pref_vibrate">Vibrieren</string>
<string name="pref_vibrate_summary">Vibrieren bei Erhalt einer neuen Nachricht</string>
+ <string name="pref_led">LED Benachrichtigung</string>
+ <string name="pref_led_summary">Blinke bei Erhalt einer neuen Nachricht</string>
<string name="pref_sound">Benachrichtigungston</string>
<string name="pref_sound_summary">Benachrichtigungston wiedergeben</string>
<string name="pref_notification_grace_period">Gnadenfrist</string>
@@ -607,5 +609,5 @@
<string name="shared_images_with_x">Bilder mit %s geteilt</string>
<string name="sharing_files_please_wait">Teile Dateien. Bitte warten…</string>
<string name="delete_x_file">%s löschen</string>
-
+ <string name="security_error_invalid_file_access">Sicherheitsfehler: Dateizugriff nicht erlaubt</string>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 461cf75ae..a11283bd3 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -108,9 +108,11 @@
<string name="pref_notifications">Notifications</string>
<string name="pref_notifications_summary">Notify when a new message arrives</string>
<string name="pref_vibrate">Vibrate</string>
- <string name="pref_vibrate_summary">Also vibrate when a new message arrives</string>
- <string name="pref_sound">Sound</string>
- <string name="pref_sound_summary">Play ringtone with notification</string>
+ <string name="pref_vibrate_summary">Vibrate when a new message arrives</string>
+ <string name="pref_led">LED Notification</string>
+ <string name="pref_led_summary">Blink notification light when a new message arrives</string>
+ <string name="pref_sound">Ringtone</string>
+ <string name="pref_sound_summary">Play sound when a new message arrives</string>
<string name="pref_notification_grace_period">Notification grace period</string>
<string name="pref_notification_grace_period_summary">Disable notifications for a short time after a carbon copy was received</string>
<string name="pref_advanced_options">Advanced</string>
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 734656a84..33a84e1b4 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -72,7 +72,12 @@
android:key="vibrate_on_notification"
android:summary="@string/pref_vibrate_summary"
android:title="@string/pref_vibrate"/>
-
+ <CheckBoxPreference
+ android:defaultValue="true"
+ android:dependency="show_notification"
+ android:key="led"
+ android:title="@string/pref_led"
+ android:summary="@string/pref_led_summary"/>
<RingtonePreference
android:defaultValue="content://settings/system/notification_sound"
android:dependency="show_notification"