presist http upload availibility
This commit is contained in:
		
							parent
							
								
									f2ea609b51
								
							
						
					
					
						commit
						5514958e93
					
				| 
						 | 
					@ -54,6 +54,7 @@ public class Account extends AbstractEntity {
 | 
				
			||||||
	public static final int OPTION_MAGIC_CREATE = 4;
 | 
						public static final int OPTION_MAGIC_CREATE = 4;
 | 
				
			||||||
	public static final int OPTION_REQUIRES_ACCESS_MODE_CHANGE = 5;
 | 
						public static final int OPTION_REQUIRES_ACCESS_MODE_CHANGE = 5;
 | 
				
			||||||
	public static final int OPTION_LOGGED_IN_SUCCESSFULLY = 6;
 | 
						public static final int OPTION_LOGGED_IN_SUCCESSFULLY = 6;
 | 
				
			||||||
 | 
						public static final int OPTION_HTTP_UPLOAD_AVAILABLE = 7;
 | 
				
			||||||
	public final HashSet<Pair<String, String>> inProgressDiscoFetches = new HashSet<>();
 | 
						public final HashSet<Pair<String, String>> inProgressDiscoFetches = new HashSet<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public boolean httpUploadAvailable(long filesize) {
 | 
						public boolean httpUploadAvailable(long filesize) {
 | 
				
			||||||
| 
						 | 
					@ -61,7 +62,7 @@ public class Account extends AbstractEntity {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public boolean httpUploadAvailable() {
 | 
						public boolean httpUploadAvailable() {
 | 
				
			||||||
		return httpUploadAvailable(0);
 | 
							return isOptionSet(OPTION_HTTP_UPLOAD_AVAILABLE) || httpUploadAvailable(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setDisplayName(String displayName) {
 | 
						public void setDisplayName(String displayName) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,7 @@
 | 
				
			||||||
package eu.siacs.conversations.http;
 | 
					package eu.siacs.conversations.http;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.http.conn.ssl.StrictHostnameVerifier;
 | 
					import org.apache.http.conn.ssl.StrictHostnameVerifier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
| 
						 | 
					@ -16,10 +18,13 @@ import javax.net.ssl.HttpsURLConnection;
 | 
				
			||||||
import javax.net.ssl.SSLSocketFactory;
 | 
					import javax.net.ssl.SSLSocketFactory;
 | 
				
			||||||
import javax.net.ssl.X509TrustManager;
 | 
					import javax.net.ssl.X509TrustManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import eu.siacs.conversations.Config;
 | 
				
			||||||
 | 
					import eu.siacs.conversations.entities.Account;
 | 
				
			||||||
import eu.siacs.conversations.entities.Message;
 | 
					import eu.siacs.conversations.entities.Message;
 | 
				
			||||||
import eu.siacs.conversations.services.AbstractConnectionManager;
 | 
					import eu.siacs.conversations.services.AbstractConnectionManager;
 | 
				
			||||||
import eu.siacs.conversations.services.XmppConnectionService;
 | 
					import eu.siacs.conversations.services.XmppConnectionService;
 | 
				
			||||||
import eu.siacs.conversations.utils.TLSSocketFactory;
 | 
					import eu.siacs.conversations.utils.TLSSocketFactory;
 | 
				
			||||||
 | 
					import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class HttpConnectionManager extends AbstractConnectionManager {
 | 
					public class HttpConnectionManager extends AbstractConnectionManager {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -136,10 +136,6 @@ import rocks.xmpp.addr.Jid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class XmppConnectionService extends Service {
 | 
					public class XmppConnectionService extends Service {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static {
 | 
					 | 
				
			||||||
		URL.setURLStreamHandlerFactory(new AesGcmURLStreamHandlerFactory());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final String ACTION_REPLY_TO_CONVERSATION = "reply_to_conversations";
 | 
						public static final String ACTION_REPLY_TO_CONVERSATION = "reply_to_conversations";
 | 
				
			||||||
	public static final String ACTION_MARK_AS_READ = "mark_as_read";
 | 
						public static final String ACTION_MARK_AS_READ = "mark_as_read";
 | 
				
			||||||
	public static final String ACTION_SNOOZE = "snooze";
 | 
						public static final String ACTION_SNOOZE = "snooze";
 | 
				
			||||||
| 
						 | 
					@ -147,24 +143,28 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
	public static final String ACTION_DISMISS_ERROR_NOTIFICATIONS = "dismiss_error";
 | 
						public static final String ACTION_DISMISS_ERROR_NOTIFICATIONS = "dismiss_error";
 | 
				
			||||||
	public static final String ACTION_TRY_AGAIN = "try_again";
 | 
						public static final String ACTION_TRY_AGAIN = "try_again";
 | 
				
			||||||
	public static final String ACTION_IDLE_PING = "idle_ping";
 | 
						public static final String ACTION_IDLE_PING = "idle_ping";
 | 
				
			||||||
	private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts";
 | 
					 | 
				
			||||||
	public static final String ACTION_GCM_TOKEN_REFRESH = "gcm_token_refresh";
 | 
						public static final String ACTION_GCM_TOKEN_REFRESH = "gcm_token_refresh";
 | 
				
			||||||
	public static final String ACTION_GCM_MESSAGE_RECEIVED = "gcm_message_received";
 | 
						public static final String ACTION_GCM_MESSAGE_RECEIVED = "gcm_message_received";
 | 
				
			||||||
 | 
						private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static {
 | 
				
			||||||
 | 
							URL.setURLStreamHandlerFactory(new AesGcmURLStreamHandlerFactory());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public final CountDownLatch restoredFromDatabaseLatch = new CountDownLatch(1);
 | 
				
			||||||
	private final SerialSingleThreadExecutor mFileAddingExecutor = new SerialSingleThreadExecutor("FileAdding");
 | 
						private final SerialSingleThreadExecutor mFileAddingExecutor = new SerialSingleThreadExecutor("FileAdding");
 | 
				
			||||||
	private final SerialSingleThreadExecutor mVideoCompressionExecutor = new SerialSingleThreadExecutor("VideoCompression");
 | 
						private final SerialSingleThreadExecutor mVideoCompressionExecutor = new SerialSingleThreadExecutor("VideoCompression");
 | 
				
			||||||
	private final SerialSingleThreadExecutor mDatabaseWriterExecutor = new SerialSingleThreadExecutor("DatabaseWriter");
 | 
						private final SerialSingleThreadExecutor mDatabaseWriterExecutor = new SerialSingleThreadExecutor("DatabaseWriter");
 | 
				
			||||||
	private final SerialSingleThreadExecutor mDatabaseReaderExecutor = new SerialSingleThreadExecutor("DatabaseReader");
 | 
						private final SerialSingleThreadExecutor mDatabaseReaderExecutor = new SerialSingleThreadExecutor("DatabaseReader");
 | 
				
			||||||
	private final SerialSingleThreadExecutor mNotificationExecutor = new SerialSingleThreadExecutor("NotificationExecutor");
 | 
						private final SerialSingleThreadExecutor mNotificationExecutor = new SerialSingleThreadExecutor("NotificationExecutor");
 | 
				
			||||||
	private ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor(true);
 | 
					 | 
				
			||||||
	private final IBinder mBinder = new XmppConnectionBinder();
 | 
						private final IBinder mBinder = new XmppConnectionBinder();
 | 
				
			||||||
	private final List<Conversation> conversations = new CopyOnWriteArrayList<>();
 | 
						private final List<Conversation> conversations = new CopyOnWriteArrayList<>();
 | 
				
			||||||
	private final IqGenerator mIqGenerator = new IqGenerator(this);
 | 
						private final IqGenerator mIqGenerator = new IqGenerator(this);
 | 
				
			||||||
	private final List<String> mInProgressAvatarFetches = new ArrayList<>();
 | 
						private final List<String> mInProgressAvatarFetches = new ArrayList<>();
 | 
				
			||||||
	private final HashSet<Jid> mLowPingTimeoutMode = new HashSet<>();
 | 
						private final HashSet<Jid> mLowPingTimeoutMode = new HashSet<>();
 | 
				
			||||||
 | 
					 | 
				
			||||||
	private long mLastActivity = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public DatabaseBackend databaseBackend;
 | 
						public DatabaseBackend databaseBackend;
 | 
				
			||||||
 | 
						private ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor(true);
 | 
				
			||||||
 | 
						private long mLastActivity = 0;
 | 
				
			||||||
	private ContentObserver contactObserver = new ContentObserver(null) {
 | 
						private ContentObserver contactObserver = new ContentObserver(null) {
 | 
				
			||||||
		@Override
 | 
							@Override
 | 
				
			||||||
		public void onChange(boolean selfChange) {
 | 
							public void onChange(boolean selfChange) {
 | 
				
			||||||
| 
						 | 
					@ -197,10 +197,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	private MessageGenerator mMessageGenerator = new MessageGenerator(this);
 | 
						private MessageGenerator mMessageGenerator = new MessageGenerator(this);
 | 
				
			||||||
	private PresenceGenerator mPresenceGenerator = new PresenceGenerator(this);
 | 
					 | 
				
			||||||
	private List<Account> accounts;
 | 
					 | 
				
			||||||
	private JingleConnectionManager mJingleConnectionManager = new JingleConnectionManager(
 | 
					 | 
				
			||||||
			this);
 | 
					 | 
				
			||||||
	public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() {
 | 
						public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		@Override
 | 
							@Override
 | 
				
			||||||
| 
						 | 
					@ -215,14 +211,23 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						private PresenceGenerator mPresenceGenerator = new PresenceGenerator(this);
 | 
				
			||||||
 | 
						private List<Account> accounts;
 | 
				
			||||||
 | 
						private JingleConnectionManager mJingleConnectionManager = new JingleConnectionManager(
 | 
				
			||||||
 | 
								this);
 | 
				
			||||||
 | 
						private final OnJinglePacketReceived jingleListener = new OnJinglePacketReceived() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							@Override
 | 
				
			||||||
 | 
							public void onJinglePacketReceived(Account account, JinglePacket packet) {
 | 
				
			||||||
 | 
								mJingleConnectionManager.deliverPacket(account, packet);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
	private HttpConnectionManager mHttpConnectionManager = new HttpConnectionManager(
 | 
						private HttpConnectionManager mHttpConnectionManager = new HttpConnectionManager(
 | 
				
			||||||
			this);
 | 
								this);
 | 
				
			||||||
	private AvatarService mAvatarService = new AvatarService(this);
 | 
						private AvatarService mAvatarService = new AvatarService(this);
 | 
				
			||||||
	private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this);
 | 
						private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this);
 | 
				
			||||||
	private PushManagementService mPushManagementService = new PushManagementService(this);
 | 
						private PushManagementService mPushManagementService = new PushManagementService(this);
 | 
				
			||||||
	private OnConversationUpdate mOnConversationUpdate = null;
 | 
						private OnConversationUpdate mOnConversationUpdate = null;
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private final ConversationsFileObserver fileObserver = new ConversationsFileObserver(
 | 
						private final ConversationsFileObserver fileObserver = new ConversationsFileObserver(
 | 
				
			||||||
			Environment.getExternalStorageDirectory().getAbsolutePath()
 | 
								Environment.getExternalStorageDirectory().getAbsolutePath()
 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
| 
						 | 
					@ -231,13 +236,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			markFileDeleted(path);
 | 
								markFileDeleted(path);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	private final OnJinglePacketReceived jingleListener = new OnJinglePacketReceived() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public void onJinglePacketReceived(Account account, JinglePacket packet) {
 | 
					 | 
				
			||||||
			mJingleConnectionManager.deliverPacket(account, packet);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
	private final OnMessageAcknowledged mOnMessageAcknowledgedListener = new OnMessageAcknowledged() {
 | 
						private final OnMessageAcknowledged mOnMessageAcknowledgedListener = new OnMessageAcknowledged() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		@Override
 | 
							@Override
 | 
				
			||||||
| 
						 | 
					@ -267,10 +265,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
	private OnMucRosterUpdate mOnMucRosterUpdate = null;
 | 
						private OnMucRosterUpdate mOnMucRosterUpdate = null;
 | 
				
			||||||
	private int mucRosterChangedListenerCount = 0;
 | 
						private int mucRosterChangedListenerCount = 0;
 | 
				
			||||||
	private OnKeyStatusUpdated mOnKeyStatusUpdated = null;
 | 
						private OnKeyStatusUpdated mOnKeyStatusUpdated = null;
 | 
				
			||||||
	private int keyStatusUpdatedListenerCount = 0;
 | 
					 | 
				
			||||||
	private AtomicLong mLastExpiryRun = new AtomicLong(0);
 | 
					 | 
				
			||||||
	private SecureRandom mRandom;
 | 
					 | 
				
			||||||
	private LruCache<Pair<String, String>, ServiceDiscoveryResult> discoCache = new LruCache<>(20);
 | 
					 | 
				
			||||||
	private final OnBindListener mOnBindListener = new OnBindListener() {
 | 
						private final OnBindListener mOnBindListener = new OnBindListener() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		@Override
 | 
							@Override
 | 
				
			||||||
| 
						 | 
					@ -283,7 +277,10 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY, true)) {
 | 
								boolean needsUpdating = account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY, true);
 | 
				
			||||||
 | 
								needsUpdating |= account.setOption(Account.OPTION_HTTP_UPLOAD_AVAILABLE, account.getXmppConnection().getFeatures().httpUpload(0));
 | 
				
			||||||
 | 
								if (needsUpdating) {
 | 
				
			||||||
 | 
									Log.d(Config.LOGTAG, "account needed updating");
 | 
				
			||||||
				databaseBackend.updateAccount(account);
 | 
									databaseBackend.updateAccount(account);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			account.getRoster().clearPresences();
 | 
								account.getRoster().clearPresences();
 | 
				
			||||||
| 
						 | 
					@ -307,6 +304,10 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			syncDirtyContacts(account);
 | 
								syncDirtyContacts(account);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						private int keyStatusUpdatedListenerCount = 0;
 | 
				
			||||||
 | 
						private AtomicLong mLastExpiryRun = new AtomicLong(0);
 | 
				
			||||||
 | 
						private SecureRandom mRandom;
 | 
				
			||||||
 | 
						private LruCache<Pair<String, String>, ServiceDiscoveryResult> discoCache = new LruCache<>(20);
 | 
				
			||||||
	private OnStatusChanged statusListener = new OnStatusChanged() {
 | 
						private OnStatusChanged statusListener = new OnStatusChanged() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		@Override
 | 
							@Override
 | 
				
			||||||
| 
						 | 
					@ -379,6 +380,16 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			getNotificationService().updateErrorNotification();
 | 
								getNotificationService().updateErrorNotification();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						private OpenPgpServiceConnection pgpServiceConnection;
 | 
				
			||||||
 | 
						private PgpEngine mPgpEngine = null;
 | 
				
			||||||
 | 
						private WakeLock wakeLock;
 | 
				
			||||||
 | 
						private PowerManager pm;
 | 
				
			||||||
 | 
						private LruCache<String, Bitmap> mBitmapCache;
 | 
				
			||||||
 | 
						private EventReceiver mEventReceiver = new EventReceiver();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static String generateFetchKey(Account account, final Avatar avatar) {
 | 
				
			||||||
 | 
							return account.getJid().asBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private boolean isInLowPingTimeoutMode(Account account) {
 | 
						private boolean isInLowPingTimeoutMode(Account account) {
 | 
				
			||||||
		synchronized (mLowPingTimeoutMode) {
 | 
							synchronized (mLowPingTimeoutMode) {
 | 
				
			||||||
| 
						 | 
					@ -396,19 +407,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		toggleForegroundService();
 | 
							toggleForegroundService();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private OpenPgpServiceConnection pgpServiceConnection;
 | 
					 | 
				
			||||||
	private PgpEngine mPgpEngine = null;
 | 
					 | 
				
			||||||
	private WakeLock wakeLock;
 | 
					 | 
				
			||||||
	private PowerManager pm;
 | 
					 | 
				
			||||||
	private LruCache<String, Bitmap> mBitmapCache;
 | 
					 | 
				
			||||||
	private EventReceiver mEventReceiver = new EventReceiver();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public final CountDownLatch restoredFromDatabaseLatch = new CountDownLatch(1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private static String generateFetchKey(Account account, final Avatar avatar) {
 | 
					 | 
				
			||||||
		return account.getJid().asBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public boolean areMessagesInitialized() {
 | 
						public boolean areMessagesInitialized() {
 | 
				
			||||||
		return this.restoredFromDatabaseLatch.getCount() == 0;
 | 
							return this.restoredFromDatabaseLatch.getCount() == 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -511,10 +509,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		message.setCounterpart(conversation.getNextCounterpart());
 | 
							message.setCounterpart(conversation.getNextCounterpart());
 | 
				
			||||||
		message.setType(Message.TYPE_IMAGE);
 | 
							message.setType(Message.TYPE_IMAGE);
 | 
				
			||||||
		mFileAddingExecutor.execute(new Runnable() {
 | 
							mFileAddingExecutor.execute(() -> {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				getFileBackend().copyImageToPrivateStorage(message, uri);
 | 
									getFileBackend().copyImageToPrivateStorage(message, uri);
 | 
				
			||||||
				if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
 | 
									if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
 | 
				
			||||||
| 
						 | 
					@ -531,7 +526,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			} catch (final FileBackend.FileCopyException e) {
 | 
								} catch (final FileBackend.FileCopyException e) {
 | 
				
			||||||
				callback.error(e.getResId(), message);
 | 
									callback.error(e.getResId(), message);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -912,9 +906,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void expireOldMessages(final boolean resetHasMessagesLeftOnServer) {
 | 
						public void expireOldMessages(final boolean resetHasMessagesLeftOnServer) {
 | 
				
			||||||
		mLastExpiryRun.set(SystemClock.elapsedRealtime());
 | 
							mLastExpiryRun.set(SystemClock.elapsedRealtime());
 | 
				
			||||||
		mDatabaseWriterExecutor.execute(new Runnable() {
 | 
							mDatabaseWriterExecutor.execute(() -> {
 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
			long timestamp = getAutomaticMessageDeletionDate();
 | 
								long timestamp = getAutomaticMessageDeletionDate();
 | 
				
			||||||
			if (timestamp > 0) {
 | 
								if (timestamp > 0) {
 | 
				
			||||||
				databaseBackend.expireOldMessages(timestamp);
 | 
									databaseBackend.expireOldMessages(timestamp);
 | 
				
			||||||
| 
						 | 
					@ -929,7 +921,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				updateConversationUi();
 | 
									updateConversationUi();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -976,12 +967,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		restoreFromDatabase();
 | 
							restoreFromDatabase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver);
 | 
							getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver);
 | 
				
			||||||
		new Thread(new Runnable() {
 | 
							new Thread(() -> fileObserver.startWatching()).start();
 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
				fileObserver.startWatching();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}).start();
 | 
					 | 
				
			||||||
		if (Config.supportOpenPgp()) {
 | 
							if (Config.supportOpenPgp()) {
 | 
				
			||||||
			this.pgpServiceConnection = new OpenPgpServiceConnection(this, "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() {
 | 
								this.pgpServiceConnection = new OpenPgpServiceConnection(this, "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() {
 | 
				
			||||||
				@Override
 | 
									@Override
 | 
				
			||||||
| 
						 | 
					@ -1081,12 +1067,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			databaseBackend.writeRoster(account.getRoster());
 | 
								databaseBackend.writeRoster(account.getRoster());
 | 
				
			||||||
			if (account.getXmppConnection() != null) {
 | 
								if (account.getXmppConnection() != null) {
 | 
				
			||||||
				new Thread(new Runnable() {
 | 
									new Thread(() -> disconnect(account, false)).start();
 | 
				
			||||||
					@Override
 | 
					 | 
				
			||||||
					public void run() {
 | 
					 | 
				
			||||||
						disconnect(account, false);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}).start();
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (stop || activeAccounts == 0) {
 | 
							if (stop || activeAccounts == 0) {
 | 
				
			||||||
| 
						 | 
					@ -1399,9 +1380,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			long diffConversationsRestore = SystemClock.elapsedRealtime() - startTimeConversationsRestore;
 | 
								long diffConversationsRestore = SystemClock.elapsedRealtime() - startTimeConversationsRestore;
 | 
				
			||||||
			Log.d(Config.LOGTAG, "finished restoring conversations in " + diffConversationsRestore + "ms");
 | 
								Log.d(Config.LOGTAG, "finished restoring conversations in " + diffConversationsRestore + "ms");
 | 
				
			||||||
			Runnable runnable = new Runnable() {
 | 
								Runnable runnable = () -> {
 | 
				
			||||||
				@Override
 | 
					 | 
				
			||||||
				public void run() {
 | 
					 | 
				
			||||||
				long deletionDate = getAutomaticMessageDeletionDate();
 | 
									long deletionDate = getAutomaticMessageDeletionDate();
 | 
				
			||||||
				mLastExpiryRun.set(SystemClock.elapsedRealtime());
 | 
									mLastExpiryRun.set(SystemClock.elapsedRealtime());
 | 
				
			||||||
				if (deletionDate > 0) {
 | 
									if (deletionDate > 0) {
 | 
				
			||||||
| 
						 | 
					@ -1439,17 +1418,13 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
				final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore;
 | 
									final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore;
 | 
				
			||||||
				Log.d(Config.LOGTAG, "finished restoring messages in " + diffMessageRestore + "ms");
 | 
									Log.d(Config.LOGTAG, "finished restoring messages in " + diffMessageRestore + "ms");
 | 
				
			||||||
				updateConversationUi();
 | 
									updateConversationUi();
 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
			mDatabaseReaderExecutor.execute(runnable); //will contain one write command (expiry) but that's fine
 | 
								mDatabaseReaderExecutor.execute(runnable); //will contain one write command (expiry) but that's fine
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void loadPhoneContacts() {
 | 
						public void loadPhoneContacts() {
 | 
				
			||||||
		mContactMergerExecutor.execute(new Runnable() {
 | 
							mContactMergerExecutor.execute(() -> PhoneHelper.loadPhoneContacts(XmppConnectionService.this, new OnPhoneContactsLoadedListener() {
 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
				PhoneHelper.loadPhoneContacts(XmppConnectionService.this, new OnPhoneContactsLoadedListener() {
 | 
					 | 
				
			||||||
			@Override
 | 
								@Override
 | 
				
			||||||
			public void onPhoneContactsLoaded(List<Bundle> phoneContacts) {
 | 
								public void onPhoneContactsLoaded(List<Bundle> phoneContacts) {
 | 
				
			||||||
				Log.d(Config.LOGTAG, "start merging phone contacts with roster");
 | 
									Log.d(Config.LOGTAG, "start merging phone contacts with roster");
 | 
				
			||||||
| 
						 | 
					@ -1487,9 +1462,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
				mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true));
 | 
									mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true));
 | 
				
			||||||
				updateAccountUi();
 | 
									updateAccountUi();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
				});
 | 
							}));
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public List<Conversation> getConversations() {
 | 
						public List<Conversation> getConversations() {
 | 
				
			||||||
| 
						 | 
					@ -1497,10 +1470,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void checkDeletedFiles(Conversation conversation) {
 | 
						private void checkDeletedFiles(Conversation conversation) {
 | 
				
			||||||
		conversation.findMessagesWithFiles(new Conversation.OnMessageFound() {
 | 
							conversation.findMessagesWithFiles(message -> {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void onMessageFound(Message message) {
 | 
					 | 
				
			||||||
			if (!getFileBackend().isFileAvailable(message)) {
 | 
								if (!getFileBackend().isFileAvailable(message)) {
 | 
				
			||||||
				message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
 | 
									message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
 | 
				
			||||||
				final int s = message.getStatus();
 | 
									final int s = message.getStatus();
 | 
				
			||||||
| 
						 | 
					@ -1508,16 +1478,13 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
					markMessage(message, Message.STATUS_SEND_FAILED);
 | 
										markMessage(message, Message.STATUS_SEND_FAILED);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void markFileDeleted(final String path) {
 | 
						private void markFileDeleted(final String path) {
 | 
				
			||||||
		Log.d(Config.LOGTAG, "deleted file " + path);
 | 
							Log.d(Config.LOGTAG, "deleted file " + path);
 | 
				
			||||||
		for (Conversation conversation : getConversations()) {
 | 
							for (Conversation conversation : getConversations()) {
 | 
				
			||||||
			conversation.findMessagesWithFiles(new Conversation.OnMessageFound() {
 | 
								conversation.findMessagesWithFiles(message -> {
 | 
				
			||||||
				@Override
 | 
					 | 
				
			||||||
				public void onMessageFound(Message message) {
 | 
					 | 
				
			||||||
				DownloadableFile file = fileBackend.getFile(message);
 | 
									DownloadableFile file = fileBackend.getFile(message);
 | 
				
			||||||
				if (file.getAbsolutePath().equals(path)) {
 | 
									if (file.getAbsolutePath().equals(path)) {
 | 
				
			||||||
					if (!file.exists()) {
 | 
										if (!file.exists()) {
 | 
				
			||||||
| 
						 | 
					@ -1532,7 +1499,6 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
						Log.d(Config.LOGTAG, "found matching message for file " + path + " but file still exists");
 | 
											Log.d(Config.LOGTAG, "found matching message for file " + path + " but file still exists");
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -3066,12 +3032,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void reconnectAccountInBackground(final Account account) {
 | 
						public void reconnectAccountInBackground(final Account account) {
 | 
				
			||||||
		new Thread(new Runnable() {
 | 
							new Thread(() -> reconnectAccount(account, false, true)).start();
 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
				reconnectAccount(account, false, true);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}).start();
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void invite(Conversation conversation, Jid contact) {
 | 
						public void invite(Conversation conversation, Jid contact) {
 | 
				
			||||||
| 
						 | 
					@ -3298,13 +3259,10 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		final List<Message> readMessages = conversation.markRead();
 | 
							final List<Message> readMessages = conversation.markRead();
 | 
				
			||||||
		if (readMessages.size() > 0) {
 | 
							if (readMessages.size() > 0) {
 | 
				
			||||||
			Runnable runnable = new Runnable() {
 | 
								Runnable runnable = () -> {
 | 
				
			||||||
				@Override
 | 
					 | 
				
			||||||
				public void run() {
 | 
					 | 
				
			||||||
				for (Message message : readMessages) {
 | 
									for (Message message : readMessages) {
 | 
				
			||||||
					databaseBackend.updateMessage(message);
 | 
										databaseBackend.updateMessage(message);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
			mDatabaseWriterExecutor.execute(runnable);
 | 
								mDatabaseWriterExecutor.execute(runnable);
 | 
				
			||||||
			updateUnreadCountBadge();
 | 
								updateUnreadCountBadge();
 | 
				
			||||||
| 
						 | 
					@ -3369,26 +3327,10 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		setMemorizingTrustManager(tm);
 | 
							setMemorizingTrustManager(tm);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public PowerManager getPowerManager() {
 | 
					 | 
				
			||||||
		return this.pm;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LruCache<String, Bitmap> getBitmapCache() {
 | 
						public LruCache<String, Bitmap> getBitmapCache() {
 | 
				
			||||||
		return this.mBitmapCache;
 | 
							return this.mBitmapCache;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void syncRosterToDisk(final Account account) {
 | 
					 | 
				
			||||||
		Runnable runnable = new Runnable() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
				databaseBackend.writeRoster(account.getRoster());
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		mDatabaseWriterExecutor.execute(runnable);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public Collection<String> getKnownHosts() {
 | 
						public Collection<String> getKnownHosts() {
 | 
				
			||||||
		final Set<String> hosts = new HashSet<>();
 | 
							final Set<String> hosts = new HashSet<>();
 | 
				
			||||||
		for (final Account account : getAccounts()) {
 | 
							for (final Account account : getAccounts()) {
 | 
				
			||||||
| 
						 | 
					@ -3600,12 +3542,9 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		conversation.clearMessages();
 | 
							conversation.clearMessages();
 | 
				
			||||||
		conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam
 | 
							conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam
 | 
				
			||||||
		conversation.setLastClearHistory(clearDate, reference);
 | 
							conversation.setLastClearHistory(clearDate, reference);
 | 
				
			||||||
		Runnable runnable = new Runnable() {
 | 
							Runnable runnable = () -> {
 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void run() {
 | 
					 | 
				
			||||||
			databaseBackend.deleteMessagesInConversation(conversation);
 | 
								databaseBackend.deleteMessagesInConversation(conversation);
 | 
				
			||||||
			databaseBackend.updateConversation(conversation);
 | 
								databaseBackend.updateConversation(conversation);
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		mDatabaseWriterExecutor.execute(runnable);
 | 
							mDatabaseWriterExecutor.execute(runnable);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -3675,12 +3614,9 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		String displayName = account.getDisplayName();
 | 
							String displayName = account.getDisplayName();
 | 
				
			||||||
		if (displayName != null && !displayName.isEmpty()) {
 | 
							if (displayName != null && !displayName.isEmpty()) {
 | 
				
			||||||
			IqPacket publish = mIqGenerator.publishNick(displayName);
 | 
								IqPacket publish = mIqGenerator.publishNick(displayName);
 | 
				
			||||||
			sendIqPacket(account, publish, new OnIqPacketReceived() {
 | 
								sendIqPacket(account, publish, (account1, packet) -> {
 | 
				
			||||||
				@Override
 | 
					 | 
				
			||||||
				public void onIqPacketReceived(Account account, IqPacket packet) {
 | 
					 | 
				
			||||||
				if (packet.getType() == IqPacket.TYPE.ERROR) {
 | 
									if (packet.getType() == IqPacket.TYPE.ERROR) {
 | 
				
			||||||
						Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not publish nick");
 | 
										Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": could not publish nick");
 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -3711,20 +3647,17 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
				request.setTo(jid);
 | 
									request.setTo(jid);
 | 
				
			||||||
				request.query("http://jabber.org/protocol/disco#info");
 | 
									request.query("http://jabber.org/protocol/disco#info");
 | 
				
			||||||
				Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid);
 | 
									Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid);
 | 
				
			||||||
				sendIqPacket(account, request, new OnIqPacketReceived() {
 | 
									sendIqPacket(account, request, (account1, discoPacket) -> {
 | 
				
			||||||
					@Override
 | 
					 | 
				
			||||||
					public void onIqPacketReceived(Account account, IqPacket discoPacket) {
 | 
					 | 
				
			||||||
					if (discoPacket.getType() == IqPacket.TYPE.RESULT) {
 | 
										if (discoPacket.getType() == IqPacket.TYPE.RESULT) {
 | 
				
			||||||
							ServiceDiscoveryResult disco = new ServiceDiscoveryResult(discoPacket);
 | 
											ServiceDiscoveryResult disco1 = new ServiceDiscoveryResult(discoPacket);
 | 
				
			||||||
							if (presence.getVer().equals(disco.getVer())) {
 | 
											if (presence.getVer().equals(disco1.getVer())) {
 | 
				
			||||||
								databaseBackend.insertDiscoveryResult(disco);
 | 
												databaseBackend.insertDiscoveryResult(disco1);
 | 
				
			||||||
								injectServiceDiscorveryResult(account.getRoster(), presence.getHash(), presence.getVer(), disco);
 | 
												injectServiceDiscorveryResult(account1.getRoster(), presence.getHash(), presence.getVer(), disco1);
 | 
				
			||||||
						} else {
 | 
											} else {
 | 
				
			||||||
								Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + disco.getVer());
 | 
												Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + disco1.getVer());
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
						account.inProgressDiscoFetches.remove(key);
 | 
										account1.inProgressDiscoFetches.remove(key);
 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -3744,16 +3677,13 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		final boolean legacy = account.getXmppConnection().getFeatures().mamLegacy();
 | 
							final boolean legacy = account.getXmppConnection().getFeatures().mamLegacy();
 | 
				
			||||||
		IqPacket request = new IqPacket(IqPacket.TYPE.GET);
 | 
							IqPacket request = new IqPacket(IqPacket.TYPE.GET);
 | 
				
			||||||
		request.addChild("prefs", legacy ? Namespace.MAM_LEGACY : Namespace.MAM);
 | 
							request.addChild("prefs", legacy ? Namespace.MAM_LEGACY : Namespace.MAM);
 | 
				
			||||||
		sendIqPacket(account, request, new OnIqPacketReceived() {
 | 
							sendIqPacket(account, request, (account1, packet) -> {
 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			public void onIqPacketReceived(Account account, IqPacket packet) {
 | 
					 | 
				
			||||||
			Element prefs = packet.findChild("prefs", legacy ? Namespace.MAM_LEGACY : Namespace.MAM);
 | 
								Element prefs = packet.findChild("prefs", legacy ? Namespace.MAM_LEGACY : Namespace.MAM);
 | 
				
			||||||
			if (packet.getType() == IqPacket.TYPE.RESULT && prefs != null) {
 | 
								if (packet.getType() == IqPacket.TYPE.RESULT && prefs != null) {
 | 
				
			||||||
				callback.onPreferencesFetched(prefs);
 | 
									callback.onPreferencesFetched(prefs);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				callback.onPreferencesFetchFailed();
 | 
									callback.onPreferencesFetchFailed();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3859,18 +3789,18 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
		return mShortcutService;
 | 
							return mShortcutService;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public interface OnMamPreferencesFetched {
 | 
					 | 
				
			||||||
		void onPreferencesFetched(Element prefs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		void onPreferencesFetchFailed();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public void pushMamPreferences(Account account, Element prefs) {
 | 
						public void pushMamPreferences(Account account, Element prefs) {
 | 
				
			||||||
		IqPacket set = new IqPacket(IqPacket.TYPE.SET);
 | 
							IqPacket set = new IqPacket(IqPacket.TYPE.SET);
 | 
				
			||||||
		set.addChild(prefs);
 | 
							set.addChild(prefs);
 | 
				
			||||||
		sendIqPacket(account, set, null);
 | 
							sendIqPacket(account, set, null);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public interface OnMamPreferencesFetched {
 | 
				
			||||||
 | 
							void onPreferencesFetched(Element prefs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void onPreferencesFetchFailed();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public interface OnAccountCreated {
 | 
						public interface OnAccountCreated {
 | 
				
			||||||
		void onAccountCreated(Account account);
 | 
							void onAccountCreated(Account account);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3910,10 +3840,7 @@ public class XmppConnectionService extends Service {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public interface OnCaptchaRequested {
 | 
						public interface OnCaptchaRequested {
 | 
				
			||||||
		void onCaptchaRequested(Account account,
 | 
							void onCaptchaRequested(Account account, String id, Data data, Bitmap captcha);
 | 
				
			||||||
		                        String id,
 | 
					 | 
				
			||||||
		                        Data data,
 | 
					 | 
				
			||||||
		                        Bitmap captcha);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public interface OnRosterUpdate {
 | 
						public interface OnRosterUpdate {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,6 +36,7 @@ import java.util.Hashtable;
 | 
				
			||||||
import java.util.Iterator;
 | 
					import java.util.Iterator;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map.Entry;
 | 
					import java.util.Map.Entry;
 | 
				
			||||||
 | 
					import java.util.Set;
 | 
				
			||||||
import java.util.concurrent.CountDownLatch;
 | 
					import java.util.concurrent.CountDownLatch;
 | 
				
			||||||
import java.util.concurrent.TimeUnit;
 | 
					import java.util.concurrent.TimeUnit;
 | 
				
			||||||
import java.util.concurrent.atomic.AtomicBoolean;
 | 
					import java.util.concurrent.atomic.AtomicBoolean;
 | 
				
			||||||
| 
						 | 
					@ -135,7 +136,7 @@ public class XmppConnection implements Runnable {
 | 
				
			||||||
	private final HashMap<Jid, ServiceDiscoveryResult> disco = new HashMap<>();
 | 
						private final HashMap<Jid, ServiceDiscoveryResult> disco = new HashMap<>();
 | 
				
			||||||
	private final SparseArray<AbstractAcknowledgeableStanza> mStanzaQueue = new SparseArray<>();
 | 
						private final SparseArray<AbstractAcknowledgeableStanza> mStanzaQueue = new SparseArray<>();
 | 
				
			||||||
	private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
 | 
						private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
 | 
				
			||||||
	private final ArrayList<OnAdvancedStreamFeaturesLoaded> advancedStreamFeaturesLoadedListeners = new ArrayList<>();
 | 
						private final Set<OnAdvancedStreamFeaturesLoaded> advancedStreamFeaturesLoadedListeners = new HashSet<>();
 | 
				
			||||||
	private final XmppConnectionService mXmppConnectionService;
 | 
						private final XmppConnectionService mXmppConnectionService;
 | 
				
			||||||
	private Socket socket;
 | 
						private Socket socket;
 | 
				
			||||||
	private XmlReader tagReader;
 | 
						private XmlReader tagReader;
 | 
				
			||||||
| 
						 | 
					@ -1431,10 +1432,8 @@ public class XmppConnection implements Runnable {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void addOnAdvancedStreamFeaturesAvailableListener(final OnAdvancedStreamFeaturesLoaded listener) {
 | 
						public void addOnAdvancedStreamFeaturesAvailableListener(final OnAdvancedStreamFeaturesLoaded listener) {
 | 
				
			||||||
		if (!this.advancedStreamFeaturesLoadedListeners.contains(listener)) {
 | 
					 | 
				
			||||||
		this.advancedStreamFeaturesLoadedListeners.add(listener);
 | 
							this.advancedStreamFeaturesLoadedListeners.add(listener);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void forceCloseSocket() {
 | 
						private void forceCloseSocket() {
 | 
				
			||||||
		if (socket != null) {
 | 
							if (socket != null) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue