aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java6
-rw-r--r--src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java19
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java73
4 files changed, 64 insertions, 35 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6ea73318..7faeeed9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -276,4 +276,5 @@
<string name="error_publish_avatar_converting">Something went wrong while converting your picture</string>
<string name="error_saving_avatar">Could not save avatar to disk</string>
<string name="or_long_press_for_default">(Or long press to bring back default)</string>
+ <string name="error_publish_avatar_no_server_support">Your server does not support the publication of avatars</string>
</resources>
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index 238cf0a4..19c9552a 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -184,7 +184,7 @@ public class ManageAccountActivity extends XmppActivity {
connection.setText(connectionAge + " "
+ getString(R.string.mins));
}
- if (xmpp.hasFeatureStreamManagment()) {
+ if (xmpp.getFeatures().sm()) {
if (sessionAgeHours >= 2) {
session.setText(sessionAgeHours + " "
+ getString(R.string.hours));
@@ -197,12 +197,12 @@ public class ManageAccountActivity extends XmppActivity {
stream.setText(getString(R.string.no));
session.setText(connection.getText());
}
- if (xmpp.hasFeaturesCarbon()) {
+ if (xmpp.getFeatures().carbons()) {
carbon.setText(getString(R.string.yes));
} else {
carbon.setText(getString(R.string.no));
}
- if (xmpp.hasFeatureRosterManagment()) {
+ if (xmpp.getFeatures().rosterVersioning()) {
roster.setText(getString(R.string.yes));
} else {
roster.setText(getString(R.string.no));
diff --git a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
index e0e0826a..0661f1a9 100644
--- a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
+++ b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
@@ -32,6 +32,8 @@ public class PublishProfilePictureActivity extends XmppActivity {
private Uri defaultUri;
private Account account;
+
+ private boolean support = false;
private UiCallback<Avatar> avatarPublication = new UiCallback<Avatar>() {
@@ -148,6 +150,9 @@ public class PublishProfilePictureActivity extends XmppActivity {
String jid = getIntent().getStringExtra("account");
if (jid != null) {
this.account = xmppConnectionService.findAccountByJid(jid);
+ if (this.account.getXmppConnection() != null) {
+ this.support = this.account.getXmppConnection().getFeatures().pubsub();
+ }
if (this.avatarUri == null) {
if (this.account.getAvatar() != null) {
this.avatar.setImageBitmap(this.account.getImage(
@@ -173,10 +178,16 @@ public class PublishProfilePictureActivity extends XmppActivity {
Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(
uri, 384);
this.avatar.setImageBitmap(bm);
- enablePublishButton();
- this.publishButton.setText(R.string.publish_avatar);
- this.hintOrWarning.setText(R.string.publish_avatar_explanation);
- this.hintOrWarning.setTextColor(getPrimaryTextColor());
+ if (support) {
+ enablePublishButton();
+ this.publishButton.setText(R.string.publish_avatar);
+ this.hintOrWarning.setText(R.string.publish_avatar_explanation);
+ this.hintOrWarning.setTextColor(getPrimaryTextColor());
+ } else {
+ disablePublishButton();
+ this.hintOrWarning.setTextColor(getWarningTextColor());
+ this.hintOrWarning.setText(R.string.error_publish_avatar_no_server_support);
+ }
if (this.defaultUri != null && uri.equals(this.defaultUri)) {
this.secondaryHint.setVisibility(View.INVISIBLE);
this.avatar.setOnLongClickListener(null);
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 6d01825e..b1f580d8 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -64,6 +64,8 @@ public class XmppConnection implements Runnable {
private Socket socket;
private XmlReader tagReader;
private TagWriter tagWriter;
+
+ private Features features = new Features(this);
private boolean shouldBind = true;
private boolean shouldAuthenticate = true;
@@ -662,7 +664,7 @@ public class XmppConnection implements Runnable {
}
private void enableAdvancedStreamFeatures() {
- if (hasFeaturesCarbon()) {
+ if (getFeatures().carbons()) {
sendEnableCarbons();
}
}
@@ -833,33 +835,6 @@ public class XmppConnection implements Runnable {
}
}
- public boolean hasFeatureRosterManagment() {
- if (this.streamFeatures == null) {
- return false;
- } else {
- return this.streamFeatures.hasChild("ver");
- }
- }
-
- public boolean hasFeatureStreamManagment() {
- if (this.streamFeatures == null) {
- return false;
- } else {
- return this.streamFeatures.hasChild("sm");
- }
- }
-
- public boolean hasFeaturesCarbon() {
- return hasDiscoFeature(account.getServer(), "urn:xmpp:carbons:2");
- }
-
- public boolean hasDiscoFeature(String server, String feature) {
- if (!disco.containsKey(server)) {
- return false;
- }
- return disco.get(server).contains(feature);
- }
-
public List<String> findDiscoItemsByFeature(String feature) {
List<String> items = new ArrayList<String>();
for (Entry<String, List<String>> cursor : disco.entrySet()) {
@@ -903,4 +878,46 @@ public class XmppConnection implements Runnable {
public int getAttempt() {
return this.attempt;
}
+
+ public Features getFeatures() {
+ return this.features;
+ }
+
+ public class Features {
+ XmppConnection connection;
+ public Features(XmppConnection connection) {
+ this.connection = connection;
+ }
+
+ private boolean hasDiscoFeature(String server, String feature) {
+ if (!connection.disco.containsKey(server)) {
+ return false;
+ }
+ return connection.disco.get(server).contains(feature);
+ }
+
+ public boolean carbons() {
+ return hasDiscoFeature(account.getServer(), "urn:xmpp:carbons:2");
+ }
+
+ public boolean sm() {
+ if (connection.streamFeatures == null) {
+ return false;
+ } else {
+ return connection.streamFeatures.hasChild("sm");
+ }
+ }
+
+ public boolean pubsub() {
+ return hasDiscoFeature(account.getServer(), "http://jabber.org/protocol/pubsub#publish");
+ }
+
+ public boolean rosterVersioning() {
+ if (connection.streamFeatures == null) {
+ return false;
+ } else {
+ return connection.streamFeatures.hasChild("ver");
+ }
+ }
+ }
}