Browse Source

Add events for lock icon update

dev1
Sam Whited 9 years ago
parent
commit
ec34cf48a2
5 changed files with 35 additions and 2 deletions
  1. 1
    0
      .gitignore
  2. 3
    0
      JitsiConferenceEventManager.js
  3. 5
    2
      JitsiConferenceEvents.js
  4. 24
    0
      modules/xmpp/ChatRoom.js
  5. 2
    0
      service/xmpp/XMPPEvents.js

+ 1
- 0
.gitignore View File

@@ -6,3 +6,4 @@ node_modules
6 6
 deploy-local.sh
7 7
 .remote-sync.json
8 8
 lib-jitsi-meet.*
9
+npm-*.log

+ 3
- 0
JitsiConferenceEventManager.js View File

@@ -470,6 +470,9 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function () {
470 470
                 JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
471 471
                 conference.getParticipantById(from), payload);
472 472
         });
473
+
474
+    this.chatRoomForwarder.forward(XMPPEvents.MUC_LOCK_CHANGED,
475
+        JitsiConferenceEvents.LOCK_STATE_CHANGED);
473 476
 };
474 477
 
475 478
 /**

+ 5
- 2
JitsiConferenceEvents.js View File

@@ -140,8 +140,11 @@ var JitsiConferenceEvents = {
140 140
      * Indicates that a message from another participant is received on
141 141
      * data channel.
142 142
      */
143
-    ENDPOINT_MESSAGE_RECEIVED:
144
-        "conference.endpoint_message_received"
143
+    ENDPOINT_MESSAGE_RECEIVED: "conference.endpoint_message_received",
144
+    /**
145
+     * Indicates that the room has been locked or unlocked.
146
+     */
147
+    LOCK_STATE_CHANGED: "conference.lock_state_changed"
145 148
 };
146 149
 
147 150
 module.exports = JitsiConferenceEvents;

+ 24
- 0
modules/xmpp/ChatRoom.js View File

@@ -88,6 +88,8 @@ function ChatRoom(connection, jid, password, XMPP, options, settings) {
88 88
     this.phonePin = null;
89 89
     this.connectionTimes = {};
90 90
     this.participantPropertyListener = null;
91
+
92
+    this.locked = false;
91 93
 }
92 94
 
93 95
 ChatRoom.prototype.initPresenceMap = function () {
@@ -193,6 +195,24 @@ ChatRoom.prototype.doLeave = function () {
193 195
     this.connection.flush();
194 196
 };
195 197
 
198
+ChatRoom.prototype.discoRoomInfo = function () {
199
+  // https://xmpp.org/extensions/xep-0045.html#disco-roominfo
200
+
201
+  var getInfo = $iq({type: 'get', to: this.roomjid})
202
+    .c('query', {xmlns: Strophe.NS.DISCO_INFO});
203
+
204
+  this.connection.sendIQ(getInfo, (result) => {
205
+    var locked = $(result).find('>query>feature[var="muc_passwordprotected"]').length;
206
+    if (locked != this.locked) {
207
+      this.eventEmitter.emit(XMPPEvents.MUC_LOCK_CHANGED, locked);
208
+      this.locked = locked;
209
+    }
210
+  }, (error) => {
211
+    GlobalOnErrorHandler.callErrorHandler(error);
212
+    logger.error("Error getting room info: ", error);
213
+  });
214
+};
215
+
196 216
 
197 217
 ChatRoom.prototype.createNonAnonymousRoom = function () {
198 218
     // http://xmpp.org/extensions/xep-0045.html#createroom-reserved
@@ -536,6 +556,10 @@ ChatRoom.prototype.onMessage = function (msg, from) {
536 556
         }
537 557
     }
538 558
 
559
+    if (from==this.myroomjid && $(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="104"]').length) {
560
+      this.discoRoomInfo();
561
+    }
562
+
539 563
     if (txt) {
540 564
         logger.log('chat', nick, txt);
541 565
         this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,

+ 2
- 0
service/xmpp/XMPPEvents.js View File

@@ -79,6 +79,8 @@ var XMPPEvents = {
79 79
     // Designates an event indicating that the MUC role of a participant has
80 80
     // changed.
81 81
     MUC_ROLE_CHANGED: "xmpp.muc_role_changed",
82
+    // Designates an event indicating that the MUC has been locked or unlocked.
83
+    MUC_LOCK_CHANGED: "xmpp.muc_lock_changed",
82 84
     // Designates an event indicating that a participant in the XMPP MUC has
83 85
     // advertised that they have audio muted (or unmuted).
84 86
     PARTICIPANT_AUDIO_MUTED: "xmpp.audio_muted",

Loading…
Cancel
Save