implementation for downloading only when enabled wlan
This commit is contained in:
parent
56e695cf1b
commit
7405d50c70
4 changed files with 30 additions and 3 deletions
|
@ -13,6 +13,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
|||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
|
||||
|
||||
import de.tzur.conversations.Settings;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
|
@ -59,6 +60,8 @@ public class PgpEngine {
|
|||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||
final HttpConnectionManager manager = mXmppConnectionService.getHttpConnectionManager();
|
||||
if (message.trusted()
|
||||
&& Settings.DOWNLOAD_IMAGE_LINKS
|
||||
&& mXmppConnectionService.isDownloadAllowedInConnection()
|
||||
&& message.bodyContainsDownloadable()
|
||||
&& manager.getAutoAcceptFileSize() > 0) {
|
||||
manager.createNewConnection(message);
|
||||
|
|
|
@ -619,7 +619,11 @@ public class MessageParser extends AbstractParser implements
|
|||
}
|
||||
}
|
||||
final HttpConnectionManager manager = this.mXmppConnectionService.getHttpConnectionManager();
|
||||
if (message.trusted() && Settings.DOWNLOAD_IMAGE_LINKS && message.bodyContainsDownloadable() && manager.getAutoAcceptFileSize() > 0) {
|
||||
if (message.trusted()
|
||||
&& Settings.DOWNLOAD_IMAGE_LINKS
|
||||
&& mXmppConnectionService.isDownloadAllowedInConnection()
|
||||
&& message.bodyContainsDownloadable()
|
||||
&& manager.getAutoAcceptFileSize() > 0) {
|
||||
manager.createNewConnection(message);
|
||||
} else if (!message.isRead()) {
|
||||
mXmppConnectionService.getNotificationService().push(message);
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.Map;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import de.duenndns.ssl.MemorizingTrustManager;
|
||||
import de.tzur.conversations.Settings;
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.PgpEngine;
|
||||
|
@ -526,6 +527,25 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||
return activeNetwork != null && activeNetwork.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether we are allowed to download at the moment
|
||||
*/
|
||||
public boolean isDownloadAllowedInConnection() {
|
||||
if (Settings.DOWNLOAD_ONLY_WLAN) {
|
||||
return isWifiConnected();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether wifi is connected
|
||||
*/
|
||||
public boolean isWifiConnected() {
|
||||
ConnectivityManager cm = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo niWifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
return niWifi.isConnected();
|
||||
}
|
||||
|
||||
@SuppressLint("TrulyRandom")
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
|
|
@ -317,8 +317,8 @@ public class JingleConnection implements Downloadable {
|
|||
message.setBody(Long.toString(size));
|
||||
conversation.add(message);
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
if (size <= this.mJingleConnectionManager
|
||||
.getAutoAcceptFileSize()) {
|
||||
if (size <= this.mJingleConnectionManager.getAutoAcceptFileSize()
|
||||
&& mXmppConnectionService.isDownloadAllowedInConnection()) {
|
||||
Log.d(Config.LOGTAG, "auto accepting file from "
|
||||
+ packet.getFrom());
|
||||
this.acceptedAutomatically = true;
|
||||
|
|
Loading…
Reference in a new issue