mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 01:32:17 -05:00
support omemo:// style urls
This commit is contained in:
parent
c37117b940
commit
71ad18beb9
@ -657,6 +657,12 @@ public class Message extends AbstractEntity {
|
||||
}
|
||||
try {
|
||||
URL url = new URL(body);
|
||||
String ref = url.getRef();
|
||||
final String protocol = url.getProtocol();
|
||||
final boolean encrypted = ref != null && ref.matches("([A-Fa-f0-9]{2}){48}");
|
||||
if ("omemo".equalsIgnoreCase(protocol) && encrypted) {
|
||||
return Decision.MUST;
|
||||
}
|
||||
if (!url.getProtocol().equalsIgnoreCase("http") && !url.getProtocol().equalsIgnoreCase("https")) {
|
||||
return Decision.NEVER;
|
||||
} else if (oob) {
|
||||
@ -666,8 +672,6 @@ public class Message extends AbstractEntity {
|
||||
if (extension == null) {
|
||||
return Decision.NEVER;
|
||||
}
|
||||
String ref = url.getRef();
|
||||
boolean encrypted = ref != null && ref.matches("([A-Fa-f0-9]{2}){48}");
|
||||
|
||||
if (encrypted) {
|
||||
return Decision.MUST;
|
||||
|
@ -1,7 +1,14 @@
|
||||
package eu.siacs.conversations.http;
|
||||
|
||||
/**
|
||||
* Created by daniel on 2/7/17.
|
||||
*/
|
||||
public class OmemoURLStreamHandler {
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
|
||||
|
||||
public class OmemoURLStreamHandler extends URLStreamHandler {
|
||||
@Override
|
||||
protected URLConnection openConnection(URL url) throws IOException {
|
||||
return new URL("https"+url.toString().substring(5)).openConnection();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,15 @@
|
||||
package eu.siacs.conversations.http;
|
||||
|
||||
/**
|
||||
* Created by daniel on 2/7/17.
|
||||
*/
|
||||
public class OmemoURLStreamHandlerFactory {
|
||||
import java.net.URLStreamHandler;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
|
||||
public class OmemoURLStreamHandlerFactory implements URLStreamHandlerFactory {
|
||||
@Override
|
||||
public URLStreamHandler createURLStreamHandler(String protocol) {
|
||||
if ("omemo".equals(protocol)) {
|
||||
return new OmemoURLStreamHandler();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
@ -95,6 +96,7 @@ import eu.siacs.conversations.generator.IqGenerator;
|
||||
import eu.siacs.conversations.generator.MessageGenerator;
|
||||
import eu.siacs.conversations.generator.PresenceGenerator;
|
||||
import eu.siacs.conversations.http.HttpConnectionManager;
|
||||
import eu.siacs.conversations.http.OmemoURLStreamHandlerFactory;
|
||||
import eu.siacs.conversations.parser.AbstractParser;
|
||||
import eu.siacs.conversations.parser.IqParser;
|
||||
import eu.siacs.conversations.parser.MessageParser;
|
||||
@ -142,6 +144,10 @@ import me.leolin.shortcutbadger.ShortcutBadger;
|
||||
|
||||
public class XmppConnectionService extends Service {
|
||||
|
||||
static {
|
||||
URL.setURLStreamHandlerFactory(new OmemoURLStreamHandlerFactory());
|
||||
}
|
||||
|
||||
public static final String ACTION_REPLY_TO_CONVERSATION = "reply_to_conversations";
|
||||
public static final String ACTION_CLEAR_NOTIFICATION = "clear_notification";
|
||||
public static final String ACTION_DISABLE_FOREGROUND = "disable_foreground";
|
||||
|
Loading…
Reference in New Issue
Block a user