aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-09 10:20:16 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-09 10:20:16 +0200
commit937fc51b503344948997a1924ee6fdba23850315 (patch)
tree3d4094e30c0bbc4e946af21a43bb13fbad9358b8 /src/eu/siacs
parent0bab1a4613ca91b89266b105ee800b3501dcaa01 (diff)
added warning lable if server doesn't support pubsub. refactored feature identification into seperate class
Diffstat (limited to 'src/eu/siacs')
-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
3 files changed, 63 insertions, 35 deletions
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");
+ }
+ }
+ }
}