From 9360f5c960947137d0af986b317bce35b07dfe81 Mon Sep 17 00:00:00 2001 From: Christoph Scholz Date: Mon, 12 Feb 2018 20:00:42 +0100 Subject: [PATCH] allow roster action with name --- .../conversations/ui/StartConversationActivity.java | 3 +++ .../java/eu/siacs/conversations/utils/XmppUri.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index fd125609f..8e86ccdb2 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -423,6 +423,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } final Contact contact = account.getRoster().getContact(contactJid); + if (invite.getName() != null) { + contact.setServerName(invite.getName()); + } if (contact.isSelf()) { switchToConversation(contact,null); return true; diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java index ec8fd51c0..2719acf36 100644 --- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java +++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java @@ -16,6 +16,7 @@ public class XmppUri { protected String jid; protected List fingerprints = new ArrayList<>(); private String body; + private String name; private String action; protected boolean safeSource = true; @@ -92,7 +93,8 @@ public class XmppUri { } } this.fingerprints = parseFingerprints(uri.getQuery()); - this.body = parseBody(uri.getQuery()); + this.body = parseParameter("body", uri.getQuery()); + this.name = parseParameter("name", uri.getQuery()); } else if ("imto".equalsIgnoreCase(scheme)) { // sample: imto://xmpp/foo@bar.com try { @@ -137,10 +139,10 @@ public class XmppUri { return fingerprints; } - protected String parseBody(String query) { + protected String parseParameter(String key, String query) { for(String pair : query == null ? new String[0] : query.split(";")) { final String[] parts = pair.split("=",2); - if (parts.length == 2 && "body".equals(parts[0].toLowerCase(Locale.US))) { + if (parts.length == 2 && key.equals(parts[0].toLowerCase(Locale.US))) { try { return URLDecoder.decode(parts[1],"UTF-8"); } catch (UnsupportedEncodingException e) { @@ -190,6 +192,10 @@ public class XmppUri { return body; } + public String getName() { + return name; + } + public List getFingerprints() { return this.fingerprints; }