瀏覽代碼

Add events for lock icon update

dev1
Sam Whited 9 年之前
父節點
當前提交
ec34cf48a2
共有 5 個檔案被更改,包括 35 行新增2 行删除
  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 查看文件

6
 deploy-local.sh
6
 deploy-local.sh
7
 .remote-sync.json
7
 .remote-sync.json
8
 lib-jitsi-meet.*
8
 lib-jitsi-meet.*
9
+npm-*.log

+ 3
- 0
JitsiConferenceEventManager.js 查看文件

470
                 JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
470
                 JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
471
                 conference.getParticipantById(from), payload);
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 查看文件

140
      * Indicates that a message from another participant is received on
140
      * Indicates that a message from another participant is received on
141
      * data channel.
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
 module.exports = JitsiConferenceEvents;
150
 module.exports = JitsiConferenceEvents;

+ 24
- 0
modules/xmpp/ChatRoom.js 查看文件

88
     this.phonePin = null;
88
     this.phonePin = null;
89
     this.connectionTimes = {};
89
     this.connectionTimes = {};
90
     this.participantPropertyListener = null;
90
     this.participantPropertyListener = null;
91
+
92
+    this.locked = false;
91
 }
93
 }
92
 
94
 
93
 ChatRoom.prototype.initPresenceMap = function () {
95
 ChatRoom.prototype.initPresenceMap = function () {
193
     this.connection.flush();
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
 ChatRoom.prototype.createNonAnonymousRoom = function () {
217
 ChatRoom.prototype.createNonAnonymousRoom = function () {
198
     // http://xmpp.org/extensions/xep-0045.html#createroom-reserved
218
     // http://xmpp.org/extensions/xep-0045.html#createroom-reserved
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
     if (txt) {
563
     if (txt) {
540
         logger.log('chat', nick, txt);
564
         logger.log('chat', nick, txt);
541
         this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
565
         this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,

+ 2
- 0
service/xmpp/XMPPEvents.js 查看文件

79
     // Designates an event indicating that the MUC role of a participant has
79
     // Designates an event indicating that the MUC role of a participant has
80
     // changed.
80
     // changed.
81
     MUC_ROLE_CHANGED: "xmpp.muc_role_changed",
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
     // Designates an event indicating that a participant in the XMPP MUC has
84
     // Designates an event indicating that a participant in the XMPP MUC has
83
     // advertised that they have audio muted (or unmuted).
85
     // advertised that they have audio muted (or unmuted).
84
     PARTICIPANT_AUDIO_MUTED: "xmpp.audio_muted",
86
     PARTICIPANT_AUDIO_MUTED: "xmpp.audio_muted",

Loading…
取消
儲存