From c689078d018fe2d2da4153cab1d5e05a450b7fde Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 1 Jun 2018 21:23:34 +0200 Subject: make sure account is connected before attempting to download p1s3 --- .../java/de/pixart/messenger/http/HttpConnectionManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java/de/pixart/messenger/http') diff --git a/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java b/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java index a16a369d4..fbb93d916 100644 --- a/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java +++ b/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Proxy; +import java.net.URL; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.util.List; @@ -16,6 +17,7 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; +import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Message; import de.pixart.messenger.services.AbstractConnectionManager; import de.pixart.messenger.services.XmppConnectionService; @@ -47,6 +49,15 @@ public class HttpConnectionManager extends AbstractConnectionManager { this.uploadConnections.add(connection); } + public boolean checkConnection(Message message) { + final Account account = message.getConversation().getAccount(); + final URL url = message.getFileParams().url; + if (url.getProtocol().equalsIgnoreCase(P1S3UrlStreamHandler.PROTOCOL_NAME) && account.getStatus() != Account.State.ONLINE) { + return false; + } + return mXmppConnectionService.hasInternetConnection(); + } + public void finishConnection(HttpDownloadConnection connection) { this.downloadConnections.remove(connection); } -- cgit v1.2.3