diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-06-01 21:23:34 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-06-01 21:23:34 +0200 |
commit | c689078d018fe2d2da4153cab1d5e05a450b7fde (patch) | |
tree | 3567db2f60451de2a3c26b2b2ccdce07eb030294 /src/main/java/de/pixart/messenger/http | |
parent | aa85b4a17cb0e04cbb845ee5f0ded3064ca147b9 (diff) |
make sure account is connected before attempting to download p1s3
Diffstat (limited to 'src/main/java/de/pixart/messenger/http')
-rw-r--r-- | src/main/java/de/pixart/messenger/http/HttpConnectionManager.java | 11 |
1 files changed, 11 insertions, 0 deletions
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); } |