diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartConversationActivity.java | 10 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/XmppUri.java | 32 |
2 files changed, 36 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 83d69004d..9a589e34b 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -422,7 +422,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU if (invite != null && invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact,invite.getFingerprints()); } - switchToConversation(contact); + switchToConversation(contact, invite == null ? null : invite.getBody()); return true; } } @@ -561,11 +561,11 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU return xmppConnectionService.findAccountByJid(jid); } - protected void switchToConversation(Contact contact) { + protected void switchToConversation(Contact contact, String body) { Conversation conversation = xmppConnectionService .findOrCreateConversation(contact.getAccount(), contact.getJid(), false); - switchToConversation(conversation); + switchToConversation(conversation, body, false); } public static void populateAccountSpinner(Context context, List<String> accounts, Spinner spinner) { @@ -854,7 +854,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU if (invite.isMuc()) { Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid()); if (muc != null) { - switchToConversation(muc); + switchToConversation(muc,invite.getBody(),false); return true; } else { showJoinConferenceDialog(invite.getJid().toBareJid().toString()); @@ -868,7 +868,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU if (invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints()); } - switchToConversation(contact); + switchToConversation(contact,invite.getBody()); return true; } else { if (mMenuSearchView != null) { diff --git a/src/main/java/de/pixart/messenger/utils/XmppUri.java b/src/main/java/de/pixart/messenger/utils/XmppUri.java index 52d575feb..10fa0324b 100644 --- a/src/main/java/de/pixart/messenger/utils/XmppUri.java +++ b/src/main/java/de/pixart/messenger/utils/XmppUri.java @@ -17,6 +17,7 @@ public class XmppUri { protected boolean muc; protected String fingerprint; protected List<Fingerprint> fingerprints = new ArrayList<>(); + private String body; public static final String OMEMO_URI_PARAM = "omemo-sid-"; public static final String OTR_URI_PARAM = "otr-fingerprint"; @@ -60,13 +61,14 @@ public class XmppUri { muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0)); } else if ("xmpp".equalsIgnoreCase(scheme)) { // sample: xmpp:foo@bar.com - muc = "join".equalsIgnoreCase(uri.getQuery()); + muc = isMuc(uri.getQuery()); if (uri.getAuthority() != null) { jid = uri.getAuthority(); } else { jid = uri.getSchemeSpecificPart().split("\\?")[0]; } this.fingerprints = parseFingerprints(uri.getQuery()); + this.body = parseBody(uri.getQuery()); } else if ("imto".equalsIgnoreCase(scheme)) { // sample: imto://xmpp/foo@bar.com try { @@ -107,6 +109,30 @@ public class XmppUri { return fingerprints; } + protected String parseBody(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))) { + try { + return URLDecoder.decode(parts[1],"UTF-8"); + } catch (UnsupportedEncodingException e) { + return null; + } + } + } + return null; + } + + protected boolean isMuc(String query) { + for(String pair : query == null ? new String[0] : query.split(";")) { + final String[] parts = pair.split("=",2); + if (parts.length == 1 && "join".equals(parts[0])) { + return true; + } + } + return false; + } + public Jid getJid() { try { return this.jid == null ? null : Jid.fromString(this.jid.toLowerCase()); @@ -115,6 +141,10 @@ public class XmppUri { } } + public String getBody() { + return body; + } + public List<Fingerprint> getFingerprints() { return this.fingerprints; } |