aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-12-18 21:43:27 +0100
committerChristian Schneppe <christian@pix-art.de>2016-12-18 21:43:27 +0100
commitba4184b633b33d03bd40ea7ea7495567f95c8a46 (patch)
tree2185d19ad17728f2a6f95c039a473fa76e8e8393 /src
parent09b3ffd482251ce7ef2031f445d81879e22cfa93 (diff)
add omemo fingerprints to web links as well
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Account.java28
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/XmppUri.java21
3 files changed, 33 insertions, 18 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Account.java b/src/main/java/de/pixart/messenger/entities/Account.java
index d2295e2db..2642845b6 100644
--- a/src/main/java/de/pixart/messenger/entities/Account.java
+++ b/src/main/java/de/pixart/messenger/entities/Account.java
@@ -21,6 +21,7 @@ import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
+import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.OtrService;
import de.pixart.messenger.crypto.PgpDecryptionService;
@@ -610,23 +611,16 @@ public class Account extends AbstractEntity {
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
String uri = "xmpp:" + this.getJid().toBareJid().toString();
if (fingerprints.size() > 0) {
- StringBuilder builder = new StringBuilder(uri);
- builder.append('?');
- for (int i = 0; i < fingerprints.size(); ++i) {
- XmppUri.FingerprintType type = fingerprints.get(i).type;
- if (type == XmppUri.FingerprintType.OMEMO) {
- builder.append(XmppUri.OMEMO_URI_PARAM);
- builder.append(fingerprints.get(i).deviceId);
- } else if (type == XmppUri.FingerprintType.OTR) {
- builder.append(XmppUri.OTR_URI_PARAM);
- }
- builder.append('=');
- builder.append(fingerprints.get(i).fingerprint);
- if (i != fingerprints.size() - 1) {
- builder.append(';');
- }
- }
- return builder.toString();
+ return XmppUri.getFingerprintUri(uri,fingerprints,';');
+ } else {
+ return uri;
+ }
+ }
+ public String getShareableLink() {
+ List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
+ String uri = Config.inviteUserURL+this.getJid().toBareJid().toString();
+ if (fingerprints.size() > 0) {
+ return XmppUri.getFingerprintUri(uri,fingerprints,'&');
} else {
return uri;
}
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 2617fd94c..41657e25b 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -769,7 +769,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
intent.setType("text/plain");
String text;
if (http) {
- text = Config.inviteUserURL+mAccount.getJid().toBareJid().toString();
+ text = mAccount.getShareableLink();
} else {
text = mAccount.getShareableUri();
}
diff --git a/src/main/java/de/pixart/messenger/utils/XmppUri.java b/src/main/java/de/pixart/messenger/utils/XmppUri.java
index b8b9233fd..1de4f59f7 100644
--- a/src/main/java/de/pixart/messenger/utils/XmppUri.java
+++ b/src/main/java/de/pixart/messenger/utils/XmppUri.java
@@ -69,6 +69,7 @@ public class XmppUri {
jid = segments.get(1) + "@" + segments.get(2);
}
muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0));
+ fingerprints = parseFingerprints(uri.getQuery(),'&');
} else if ("xmpp".equalsIgnoreCase(scheme)) {
// sample: xmpp:foo@bar.com
muc = isMuc(uri.getQuery());
@@ -172,6 +173,26 @@ public class XmppUri {
OTR
}
+ public static String getFingerprintUri(String base, List<XmppUri.Fingerprint> fingerprints, char seperator) {
+ StringBuilder builder = new StringBuilder(base);
+ builder.append('?');
+ for(int i = 0; i < fingerprints.size(); ++i) {
+ XmppUri.FingerprintType type = fingerprints.get(i).type;
+ if (type == XmppUri.FingerprintType.OMEMO) {
+ builder.append(XmppUri.OMEMO_URI_PARAM);
+ builder.append(fingerprints.get(i).deviceId);
+ } else if (type == XmppUri.FingerprintType.OTR) {
+ builder.append(XmppUri.OTR_URI_PARAM);
+ }
+ builder.append('=');
+ builder.append(fingerprints.get(i).fingerprint);
+ if (i != fingerprints.size() -1) {
+ builder.append(seperator);
+ }
+ }
+ return builder.toString();
+ }
+
public static class Fingerprint {
public final FingerprintType type;
public final String fingerprint;