aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-23 13:51:53 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-23 13:55:13 +0100
commit06ada3372ea812adb3ea1233bc6e224f7ba3de8b (patch)
tree4b6f9c09aa5804f85da4b1dd6c95534b77407d45 /src/main/java/de/pixart/messenger/services
parentb2969350c6b9ff64c9ae14fb7edcdcc5e69d7ae2 (diff)
added interface to edit nick
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index d889cdee8..b8986bf77 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -300,11 +300,19 @@ public class XmppConnectionService extends Service {
}
}
}
- boolean needsUpdating = account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY, true);
- needsUpdating |= account.setOption(Account.OPTION_HTTP_UPLOAD_AVAILABLE, account.getXmppConnection().getFeatures().httpUpload(0));
- if (needsUpdating) {
+ boolean loggedInSuccessfully = account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY, true);
+ boolean gainedFeature = account.setOption(Account.OPTION_HTTP_UPLOAD_AVAILABLE, account.getXmppConnection().getFeatures().httpUpload(0));
+ if (loggedInSuccessfully || gainedFeature) {
databaseBackend.updateAccount(account);
}
+
+ if (loggedInSuccessfully) {
+ if (!TextUtils.isEmpty(account.getDisplayName())) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": display name wasn't empty on first log in. publishing");
+ publishDisplayName(account);
+ }
+ }
+
account.getRoster().clearPresences();
mJingleConnectionManager.cancelInTransmission();
mQuickConversationsService.considerSyncBackground(false);
@@ -4204,14 +4212,17 @@ public class XmppConnectionService extends Service {
public void publishDisplayName(Account account) {
String displayName = account.getDisplayName();
- if (displayName != null && !displayName.isEmpty()) {
- IqPacket publish = mIqGenerator.publishNick(displayName);
- sendIqPacket(account, publish, (account1, packet) -> {
- if (packet.getType() == IqPacket.TYPE.ERROR) {
- Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": could not publish nick");
- }
- });
+ final IqPacket request;
+ if (TextUtils.isEmpty(displayName)) {
+ request = mIqGenerator.deleteNode(Namespace.NICK);
+ } else {
+ request = mIqGenerator.publishNick(displayName);
}
+ sendIqPacket(account, request, (account1, packet) -> {
+ if (packet.getType() == IqPacket.TYPE.ERROR) {
+ Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": unable to modify nick name " + packet.toString());
+ }
+ });
}
public ServiceDiscoveryResult getCachedServiceDiscoveryResult(Pair<String, String> key) {