diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 729079f2a..5065d4242 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -173,6 +173,8 @@ public class XmppConnectionService extends Service { private WakeLock wakeLock; private long mLastActivity = 0; private NotificationManager mNotifyManager; + AbstractConnectionManager mAbstractConnectionManager; + private ContentObserver contactObserver = new ContentObserver(null) { @Override public void onChange(boolean selfChange) { @@ -345,6 +347,7 @@ public class XmppConnectionService extends Service { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed"); } sendUnsentMessages(conversation); + resendFailedFileMessages(conversation); } } for (Conversation conversation : account.pendingConferenceLeaves) { @@ -1404,6 +1407,36 @@ public class XmppConnectionService extends Service { }); } + private long AcceptFileSize() { + String config = "0"; + SharedPreferences sharedPref = getPreferences(); + if (isWIFI()) { + config = sharedPref.getString("auto_accept_file_size_wifi", "10485760"); + } else if (isMobile() && !isMobileRoaming()) { + config = sharedPref.getString("auto_accept_file_size_mobile", "262144"); + } else if (isMobile() && isMobileRoaming()) { + config = sharedPref.getString("auto_accept_file_size_roaming", "1"); + } + + try { + return Long.parseLong(config); + } catch (NumberFormatException e) { + return 1048576; + } + } + + private void resendFailedFileMessages(final Conversation conversation) { + conversation.findFailedMessagesWithFiles(new Conversation.OnMessageFound() { + + @Override + public void onMessageFound(Message message) { + if (AcceptFileSize() >= message.getFileParams().size) { + resendMessage(message, true); + } + } + }); + } + public void resendMessage(final Message message, final boolean delay) { sendMessage(message, true, delay); } |