From bdfdc5fb1030b3ae49c43b8872476cae0ad89081 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Nov 2014 15:19:07 +0100 Subject: MUC: do not add yourself to the muc user list. --- src/main/java/eu/siacs/conversations/entities/MucOptions.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/eu/siacs') diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 065b6ee47..beb9612d1 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -190,6 +190,8 @@ public class MucOptions { this.onJoinListener.onSuccess(); this.onJoinListener = null; } + } else if (packet.getFrom().equals(this.conversation.getContactJid())) { + self = user; } else { addUser(user); } -- cgit v1.2.3 From dbe8280662bbe90426931a465f767f2ff76f2cbc Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Nov 2014 15:19:44 +0100 Subject: add an listener for the muc roster update. this is for the ConferenceDetailsActivity to show precence updates immediately. --- .../siacs/conversations/parser/PresenceParser.java | 2 ++ .../services/XmppConnectionService.java | 42 ++++++++++++++++++++++ .../ui/ConferenceDetailsActivity.java | 14 +++++++- .../eu/siacs/conversations/ui/XmppActivity.java | 6 ++++ 4 files changed, 63 insertions(+), 1 deletion(-) (limited to 'src/main/java/eu/siacs') diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 12167a1e4..43c8fa8d5 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -31,6 +31,8 @@ public class PresenceParser extends AbstractParser implements mXmppConnectionService.getAvatarService().clear(conversation); if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUsers().size())) { mXmppConnectionService.updateConversationUi(); + } else if (mucOptions.online()) { + mXmppConnectionService.updateMucRosterUi(); } } } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 6958a062c..12237f731 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -212,6 +212,8 @@ public class XmppConnectionService extends Service { private Integer accountChangedListenerCount = 0; private OnRosterUpdate mOnRosterUpdate = null; private Integer rosterChangedListenerCount = 0; + private OnMucRosterUpdate mOnMucRosterUpdate = null; + private Integer mucRosterChangedListenerCount = 0; private SecureRandom mRandom; private FileObserver fileObserver = new FileObserver( FileBackend.getConversationsImageDirectory()) { @@ -1116,6 +1118,13 @@ public class XmppConnectionService extends Service { removedListener = true; } } + synchronized (this.mucRosterChangedListenerCount) { + if (this.mOnMucRosterUpdate != null) { + this.mOnMucRosterUpdate = null; + this.mucRosterChangedListenerCount = 0; + removedListener = true; + } + } if (removedListener) { final String msg = "removed stale listeners"; Log.d(Config.LOGTAG, msg); @@ -1217,6 +1226,29 @@ public class XmppConnectionService extends Service { } } + public void setOnMucRosterUpdateListener(OnMucRosterUpdate listener) { + synchronized (this.mucRosterChangedListenerCount) { + if (checkListeners()) { + switchToForeground(); + } + this.mOnMucRosterUpdate = listener; + this.mucRosterChangedListenerCount++; + } + } + + public void removeOnMucRosterUpdateListener() { + synchronized (this.mucRosterChangedListenerCount) { + this.mucRosterChangedListenerCount--; + if (this.mucRosterChangedListenerCount <= 0) { + this.mucRosterChangedListenerCount = 0; + this.mOnMucRosterUpdate = null; + if (checkListeners()) { + switchToBackground(); + } + } + } + } + private boolean checkListeners() { return (this.mOnAccountUpdate == null && this.mOnConversationUpdate == null && this.mOnRosterUpdate == null); @@ -1928,6 +1960,12 @@ public class XmppConnectionService extends Service { } } + public void updateMucRosterUi() { + if (mOnMucRosterUpdate != null) { + mOnMucRosterUpdate.onMucRosterUpdate(); + } + } + public Account findAccountByJid(final Jid accountJid) { for (Account account : this.accounts) { if (account.getJid().toBareJid().equals(accountJid.toBareJid())) { @@ -2125,6 +2163,10 @@ public class XmppConnectionService extends Service { public void onRosterUpdate(); } + public interface OnMucRosterUpdate { + public void onMucRosterUpdate(); + } + private interface OnConferenceOptionsPushed { public void onPushSucceeded(); public void onPushFailed(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 290842fb4..47a11e012 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -30,10 +30,11 @@ import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.MucOptions.User; +import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate { +public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate { public static final String ACTION_VIEW_MUC = "view_muc"; private Conversation mConversation; private OnClickListener inviteListener = new OnClickListener() { @@ -96,6 +97,17 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers }); } + @Override + public void onMucRosterUpdate() { + runOnUiThread(new Runnable() { + + @Override + public void run() { + populateView(); + } + }); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index ddc57c2e8..5fba1664b 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -241,6 +241,9 @@ public abstract class XmppActivity extends Activity { if (this instanceof XmppConnectionService.OnRosterUpdate) { this.xmppConnectionService.setOnRosterUpdateListener((XmppConnectionService.OnRosterUpdate) this); } + if (this instanceof XmppConnectionService.OnMucRosterUpdate) { + this.xmppConnectionService.setOnMucRosterUpdateListener((XmppConnectionService.OnMucRosterUpdate) this); + } } protected void unregisterListeners() { @@ -253,6 +256,9 @@ public abstract class XmppActivity extends Activity { if (this instanceof XmppConnectionService.OnRosterUpdate) { this.xmppConnectionService.removeOnRosterUpdateListener(); } + if (this instanceof XmppConnectionService.OnMucRosterUpdate) { + this.xmppConnectionService.removeOnMucRosterUpdateListener(); + } } public boolean onOptionsItemSelected(MenuItem item) { -- cgit v1.2.3