aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services
diff options
context:
space:
mode:
authorMichael <betheg@bitcloner.org>2014-11-23 15:19:44 +0100
committerMichael <betheg@bitcloner.org>2014-11-23 15:19:44 +0100
commitdbe8280662bbe90426931a465f767f2ff76f2cbc (patch)
tree9531aef704fe99d986284747dfb01e759dab8ab6 /src/main/java/eu/siacs/conversations/services
parentbdfdc5fb1030b3ae49c43b8872476cae0ad89081 (diff)
add an listener for the muc roster update.
this is for the ConferenceDetailsActivity to show precence updates immediately.
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java42
1 files changed, 42 insertions, 0 deletions
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();