aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Account.java6
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java83
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java18
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java12
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java8
5 files changed, 27 insertions, 100 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index 46865a6f..4abfc801 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -162,16 +162,12 @@ public class Account extends AbstractEntity {
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<>();
private final Collection<Jid> blocklist = new CopyOnWriteArraySet<>();
- public Account() {
- this.uuid = "0";
- }
-
public Account(final Jid jid, final String password) {
this(java.util.UUID.randomUUID().toString(), jid,
password, 0, null, "", null, null, null, 5222);
}
- public Account(final String uuid, final Jid jid,
+ private Account(final String uuid, final Jid jid,
final String password, final int options, final String rosterVersion, final String keys,
final String avatar, String displayName, String hostname, int port) {
this.uuid = uuid;
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
index d6e580df..77c16f25 100644
--- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -379,22 +379,6 @@ public class DatabaseBackend extends SQLiteOpenHelper {
db.insert(Account.TABLENAME, null, account.getContentValues());
}
- public void createContact(Contact contact) {
- SQLiteDatabase db = this.getWritableDatabase();
- db.insert(Contact.TABLENAME, null, contact.getContentValues());
- }
-
- public int getConversationCount() {
- SQLiteDatabase db = this.getReadableDatabase();
- Cursor cursor = db.rawQuery("select count(uuid) as count from "
- + Conversation.TABLENAME + " where " + Conversation.STATUS
- + "=" + Conversation.STATUS_AVAILABLE, null);
- cursor.moveToFirst();
- int count = cursor.getInt(0);
- cursor.close();
- return count;
- }
-
public CopyOnWriteArrayList<Conversation> getConversations(int status) {
CopyOnWriteArrayList<Conversation> list = new CopyOnWriteArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
@@ -593,12 +577,6 @@ public class DatabaseBackend extends SQLiteOpenHelper {
updateAccount(account);
}
- public void deleteMessage(Message message) {
- SQLiteDatabase db = this.getWritableDatabase();
- String[] args = {message.getUuid()};
- db.delete(Message.TABLENAME, Message.UUID + "=?", args);
- }
-
public void deleteMessagesInConversation(Conversation conversation) {
SQLiteDatabase db = this.getWritableDatabase();
String[] args = {conversation.getUuid()};
@@ -622,67 +600,6 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
}
- public Conversation findConversationByUuid(String conversationUuid) {
- SQLiteDatabase db = this.getReadableDatabase();
- String[] selectionArgs = {conversationUuid};
- Cursor cursor = db.query(Conversation.TABLENAME, null,
- Conversation.UUID + "=?", selectionArgs, null, null, null);
- if (cursor.getCount() == 0) {
- return null;
- }
- cursor.moveToFirst();
- Conversation conversation = Conversation.fromCursor(cursor);
- cursor.close();
- return conversation;
- }
-
- public Message findMessageByUuid(String messageUuid) {
- SQLiteDatabase db = this.getReadableDatabase();
- String[] selectionArgs = {messageUuid};
- Cursor cursor = db.query(Message.TABLENAME, null, Message.UUID + "=?",
- selectionArgs, null, null, null);
- if (cursor.getCount() == 0) {
- return null;
- }
- cursor.moveToFirst();
- Message message = Message.fromCursor(cursor);
- cursor.close();
- return message;
- }
-
- public Account findAccountByUuid(String accountUuid) {
- SQLiteDatabase db = this.getReadableDatabase();
- String[] selectionArgs = {accountUuid};
- Cursor cursor = db.query(Account.TABLENAME, null, Account.UUID + "=?",
- selectionArgs, null, null, null);
- if (cursor.getCount() == 0) {
- return null;
- }
- cursor.moveToFirst();
- Account account = Account.fromCursor(cursor);
- cursor.close();
- return account;
- }
-
- public List<Message> getImageMessages(Conversation conversation) {
- ArrayList<Message> list = new ArrayList<>();
- SQLiteDatabase db = this.getReadableDatabase();
- Cursor cursor;
- String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.TYPE_IMAGE)};
- cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
- + "=? AND " + Message.TYPE + "=?", selectionArgs, null, null, null);
- if (cursor.getCount() > 0) {
- cursor.moveToLast();
- do {
- Message message = Message.fromCursor(cursor);
- message.setConversation(conversation);
- list.add(message);
- } while (cursor.moveToPrevious());
- }
- cursor.close();
- return list;
- }
-
private Cursor getCursorForSession(Account account, AxolotlAddress contact) {
final SQLiteDatabase db = this.getReadableDatabase();
String[] columns = null;
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 6e3e626a..a295b2ce 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -2451,11 +2451,14 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
synchronized (account) {
- if (account.getXmppConnection() != null) {
+ XmppConnection connection = account.getXmppConnection();
+ if (connection != null) {
disconnect(account, force);
+ } else {
+ connection = createConnection(account);
+ account.setXmppConnection(connection);
}
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
-
synchronized (this.mInProgressAvatarFetches) {
for (Iterator<String> iterator = this.mInProgressAvatarFetches.iterator(); iterator.hasNext(); ) {
final String KEY = iterator.next();
@@ -2464,10 +2467,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
}
-
- if (account.getXmppConnection() == null) {
- account.setXmppConnection(createConnection(account));
- } else if (!force) {
+ if (!force) {
try {
Log.d(Config.LOGTAG, "wait for disconnect");
Thread.sleep(500); //sleep wait for disconnect
@@ -2475,13 +2475,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
//ignored
}
}
- Thread thread = new Thread(account.getXmppConnection());
- account.getXmppConnection().setInteractive(interactive);
+ Thread thread = new Thread(connection);
+ connection.setInteractive(interactive);
thread.start();
scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
} else {
account.getRoster().clearPresences();
- account.setXmppConnection(null);
+ connection.resetEverything();
}
}
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index e5fbee43..f54ace3d 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -150,8 +150,7 @@ public class ConversationActivity extends XmppActivity
public boolean isConversationsOverviewHideable() {
if (mContentView instanceof SlidingPaneLayout) {
- SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
- return mSlidingPaneLayout.isSlideable();
+ return true;
} else {
return false;
}
@@ -1147,6 +1146,7 @@ public class ConversationActivity extends XmppActivity
} else {
if (isConversationsOverviewHideable()) {
openConversation();
+ updateActionBarTitle(true);
}
}
this.mConversationFragment.reInit(getSelectedConversation());
@@ -1330,7 +1330,13 @@ public class ConversationActivity extends XmppActivity
}
} else if (requestCode == REQUEST_TRUST_KEYS_TEXT || requestCode == REQUEST_TRUST_KEYS_MENU) {
this.forbidProcessingPendings = !xmppConnectionServiceBound;
- mConversationFragment.onActivityResult(requestCode, resultCode, data);
+ if (xmppConnectionServiceBound) {
+ mConversationFragment.onActivityResult(requestCode, resultCode, data);
+ this.mPostponedActivityResult = null;
+ } else {
+ this.mPostponedActivityResult = new Pair<>(requestCode, data);
+ }
+
}
} else {
mPendingImageUris.clear();
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 9e83491f..1f114141 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -875,6 +875,14 @@ public class XmppConnection implements Runnable {
+ instructions);
}
+ public void resetEverything() {
+ resetStreamId();
+ clearIqCallbacks();
+ synchronized (this.disco) {
+ disco.clear();
+ }
+ }
+
private void sendBindRequest() {
while(!mXmppConnectionService.areMessagesInitialized() && socket != null && !socket.isClosed()) {
try {