pending leaves and joins for muc
This commit is contained in:
parent
9cfb4ee6c3
commit
c65600edc9
|
@ -1,12 +1,9 @@
|
|||
package eu.siacs.conversations.entities;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import android.content.ContentValues;
|
||||
|
||||
public abstract class AbstractEntity implements Serializable {
|
||||
public abstract class AbstractEntity {
|
||||
|
||||
private static final long serialVersionUID = -1895605706690653719L;
|
||||
|
||||
public static final String UUID = "uuid";
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.security.interfaces.DSAPublicKey;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
|
||||
import net.java.otr4j.crypto.OtrCryptoException;
|
||||
|
@ -19,8 +20,6 @@ import android.database.Cursor;
|
|||
|
||||
public class Account extends AbstractEntity{
|
||||
|
||||
private static final long serialVersionUID = 6174825093869578035L;
|
||||
|
||||
public static final String TABLENAME = "accounts";
|
||||
|
||||
public static final String USERNAME = "username";
|
||||
|
@ -72,6 +71,9 @@ public class Account extends AbstractEntity{
|
|||
|
||||
private List<Bookmark> bookmarks = new ArrayList<Bookmark>();
|
||||
|
||||
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<Conversation>();
|
||||
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<Conversation>();
|
||||
|
||||
public Account() {
|
||||
this.uuid = "0";
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@ import android.database.Cursor;
|
|||
import android.net.Uri;
|
||||
|
||||
public class Conversation extends AbstractEntity {
|
||||
|
||||
private static final long serialVersionUID = -6727528868973996739L;
|
||||
|
||||
public static final String TABLENAME = "conversations";
|
||||
|
||||
public static final int STATUS_AVAILABLE = 0;
|
||||
|
|
|
@ -8,8 +8,6 @@ import android.database.Cursor;
|
|||
|
||||
public class Message extends AbstractEntity {
|
||||
|
||||
private static final long serialVersionUID = 7222081895167103025L;
|
||||
|
||||
public static final String TABLENAME = "messages";
|
||||
|
||||
public static final int STATUS_RECEPTION_FAILED = -3;
|
||||
|
|
|
@ -148,6 +148,12 @@ public class XmppConnectionService extends Service {
|
|||
mOnAccountUpdate.onAccountUpdate();;
|
||||
}
|
||||
if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
for(Conversation conversation : account.pendingConferenceLeaves) {
|
||||
leaveMuc(conversation);
|
||||
}
|
||||
for(Conversation conversation : account.pendingConferenceJoins) {
|
||||
joinMuc(conversation);
|
||||
}
|
||||
mJingleConnectionManager.cancelInTransmission();
|
||||
List<Conversation> conversations = getConversations();
|
||||
for (int i = 0; i < conversations.size(); ++i) {
|
||||
|
@ -196,6 +202,21 @@ public class XmppConnectionService extends Service {
|
|||
private PendingIntent pendingPingIntent = null;
|
||||
private WakeLock wakeLock;
|
||||
private PowerManager pm;
|
||||
private OnBindListener mOnBindListener = new OnBindListener() {
|
||||
|
||||
@Override
|
||||
public void onBind(final Account account) {
|
||||
account.getRoster().clearPresences();
|
||||
account.clearPresences(); // self presences
|
||||
account.pendingConferenceJoins.clear();
|
||||
account.pendingConferenceLeaves.clear();
|
||||
fetchRosterFromServer(account);
|
||||
fetchBookmarks(account);
|
||||
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
|
||||
connectMultiModeConversations(account);
|
||||
updateConversationUi();
|
||||
}
|
||||
};
|
||||
|
||||
public PgpEngine getPgpEngine() {
|
||||
if (pgpServiceConnection.isBound()) {
|
||||
|
@ -465,19 +486,7 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
}
|
||||
});
|
||||
connection.setOnBindListener(new OnBindListener() {
|
||||
|
||||
@Override
|
||||
public void onBind(final Account account) {
|
||||
account.getRoster().clearPresences();
|
||||
account.clearPresences(); // self presences
|
||||
fetchRosterFromServer(account);
|
||||
fetchBookmarks(account);
|
||||
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
|
||||
connectMultiModeConversations(account);
|
||||
updateConversationUi();
|
||||
}
|
||||
});
|
||||
connection.setOnBindListener(this.mOnBindListener);
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
@ -682,7 +691,6 @@ public class XmppConnectionService extends Service {
|
|||
if (storage!=null) {
|
||||
for(Element item : storage.getChildren()) {
|
||||
if (item.getName().equals("conference")) {
|
||||
Log.d(LOGTAG,item.toString());
|
||||
Bookmark bookmark = Bookmark.parse(item,account);
|
||||
bookmarks.add(bookmark);
|
||||
Conversation conversation = findMuc(bookmark);
|
||||
|
@ -939,8 +947,11 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
|
||||
public void joinMuc(Conversation conversation) {
|
||||
Log.d(LOGTAG,"joining conversation "+conversation.getContactJid());
|
||||
Account account = conversation.getAccount();
|
||||
account.pendingConferenceJoins.remove(conversation);
|
||||
account.pendingConferenceLeaves.remove(conversation);
|
||||
if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
Log.d(LOGTAG,"joining conversation "+conversation.getContactJid());
|
||||
String nick = conversation.getMucOptions().getProposedNick();
|
||||
conversation.getMucOptions().setJoinNick(nick);
|
||||
PresencePacket packet = new PresencePacket();
|
||||
|
@ -963,6 +974,9 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
packet.addChild(x);
|
||||
sendPresencePacket(account, packet);
|
||||
} else {
|
||||
account.pendingConferenceJoins.add(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
private OnRenameListener renameListener = null;
|
||||
|
@ -1020,6 +1034,10 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
|
||||
public void leaveMuc(Conversation conversation) {
|
||||
Account account = conversation.getAccount();
|
||||
account.pendingConferenceJoins.remove(conversation);
|
||||
account.pendingConferenceLeaves.remove(conversation);
|
||||
if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
PresencePacket packet = new PresencePacket();
|
||||
packet.setAttribute("to", conversation.getMucOptions().getJoinJid());
|
||||
packet.setAttribute("from", conversation.getAccount().getFullJid());
|
||||
|
@ -1028,6 +1046,9 @@ public class XmppConnectionService extends Service {
|
|||
conversation.getMucOptions().setOffline();
|
||||
conversation.deregisterWithBookmark();
|
||||
Log.d(LOGTAG,conversation.getAccount().getJid()+" leaving muc "+conversation.getContactJid());
|
||||
} else {
|
||||
account.pendingConferenceLeaves.add(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect(Account account, boolean force) {
|
||||
|
@ -1210,7 +1231,7 @@ public class XmppConnectionService extends Service {
|
|||
x.addChild(invite);
|
||||
packet.addChild(x);
|
||||
sendMessagePacket(account,packet);
|
||||
|
||||
Log.d(LOGTAG,packet.toString());
|
||||
}
|
||||
|
||||
public boolean markMessage(Account account, String recipient, String uuid,
|
||||
|
|
Loading…
Reference in a new issue