Bläddra i källkod

added 2 methods to the conference related to external auth

dev1
isymchych 10 år sedan
förälder
incheckning
2f0c8b7245
5 ändrade filer med 1231 tillägg och 773 borttagningar
  1. 56
    3
      JitsiConference.js
  2. 8
    0
      JitsiConferenceErrors.js
  3. 2
    2
      JitsiConferenceEvents.js
  4. 1158
    763
      lib-jitsi-meet.js
  5. 7
    5
      modules/xmpp/moderator.js

+ 56
- 3
JitsiConference.js Visa fil

@@ -1,4 +1,4 @@
1
-/* global Strophe, $ */
1
+/* global Strophe, $, Promise */
2 2
 /* jshint -W101 */
3 3
 var logger = require("jitsi-meet-logger").getLogger(__filename);
4 4
 var RTC = require("./modules/RTC/RTC");
@@ -52,6 +52,13 @@ JitsiConference.prototype.join = function (password) {
52 52
         this.room.join(password, this.connection.tokenPassword);
53 53
 };
54 54
 
55
+/**
56
+ * Check if joined to the conference.
57
+ */
58
+JitsiConference.prototype.isJoined = function () {
59
+    return this.room && this.room.joined;
60
+};
61
+
55 62
 /**
56 63
  * Leaves the conference.
57 64
  */
@@ -61,6 +68,40 @@ JitsiConference.prototype.leave = function () {
61 68
     this.room = null;
62 69
 };
63 70
 
71
+/**
72
+ * Returns name of this conference.
73
+ */
74
+JitsiConference.prototype.getName = function () {
75
+    return this.options.name;
76
+};
77
+
78
+/**
79
+ * Check if external authentication is enabled for this conference.
80
+ */
81
+JitsiConference.prototype.isExternalAuthEnabled = function () {
82
+    return this.room && this.room.moderator.isExternalAuthEnabled();
83
+};
84
+
85
+/**
86
+ * Get url for external authentication.
87
+ * @param {boolean} [urlForPopup] if true then return url for login popup,
88
+ *                                else url of login page.
89
+ * @returns {Promise}
90
+ */
91
+JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
92
+    return new Promise(function (resolve, reject) {
93
+        if (!this.isExternalAuthEnabled()) {
94
+            reject();
95
+            return;
96
+        }
97
+        if (urlForPopup) {
98
+            this.room.moderator.getPopupLoginUrl(resolve, reject);
99
+        } else {
100
+            this.room.moderator.getLoginUrl(resolve, reject);
101
+        }
102
+    }.bind(this));
103
+};
104
+
64 105
 /**
65 106
  * Returns the local tracks.
66 107
  */
@@ -267,7 +308,7 @@ JitsiConference.prototype.lock = function (password) {
267 308
     }, function (err) {
268 309
       reject(err);
269 310
     }, function () {
270
-      reject(JitsiConferenceErrors.PASSWORD_REQUIRED);
311
+      reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
271 312
     });
272 313
   });
273 314
 };
@@ -478,6 +519,18 @@ function setupListeners(conference) {
478 519
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
479 520
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
480 521
     });
522
+    conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
523
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
524
+    });
525
+    conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
526
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
527
+    });
528
+    conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
529
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
530
+    });
531
+    conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
532
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
533
+    });
481 534
 //    FIXME
482 535
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
483 536
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
@@ -501,7 +554,7 @@ function setupListeners(conference) {
501 554
         conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
502 555
     });
503 556
     conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
504
-        conference.eventEmitter.emit(JitsiConferenceEvents.SETUP_FAILED);
557
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED);
505 558
     });
506 559
 
507 560
     conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {

+ 8
- 0
JitsiConferenceErrors.js Visa fil

@@ -7,6 +7,10 @@ var JitsiConferenceErrors = {
7 7
      * Indicates that a password is required in order to join the conference.
8 8
      */
9 9
     PASSWORD_REQUIRED: "conference.passwordRequired",
10
+    /**
11
+     * Indicates that client must be authenticated to create the conference.
12
+     */
13
+    AUTHENTICATION_REQUIRED: "conference.authenticationRequired",
10 14
     /**
11 15
      * Indicates that password cannot be set for this conference.
12 16
      */
@@ -16,6 +20,10 @@ var JitsiConferenceErrors = {
16 20
      * conference.
17 21
      */
18 22
     CONNECTION_ERROR: "conference.connectionError",
23
+    /**
24
+     * Indicates that the conference setup failed.
25
+     */
26
+    SETUP_FAILED: "conference.setup_failed",
19 27
     /**
20 28
      * Indicates that there is no available videobridge.
21 29
      */

+ 2
- 2
JitsiConferenceEvents.js Visa fil

@@ -69,9 +69,9 @@ var JitsiConferenceEvents = {
69 69
      */
70 70
     CONNECTION_RESTORED: "conference.connectionRestored",
71 71
     /**
72
-     * Indicates that the conference setup failed.
72
+     * Indicates that conference failed.
73 73
      */
74
-    SETUP_FAILED: "conference.setup_failed",
74
+    CONFERENCE_FAILED: "conference.failed",
75 75
     /**
76 76
      * Indicates that conference has been joined.
77 77
      */

+ 1158
- 763
lib-jitsi-meet.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 7
- 5
modules/xmpp/moderator.js Visa fil

@@ -354,7 +354,7 @@ Moderator.prototype.allocateConferenceFocus =  function (callback) {
354 354
     );
355 355
 };
356 356
 
357
-Moderator.prototype.getLoginUrl =  function (urlCallback) {
357
+Moderator.prototype.getLoginUrl =  function (urlCallback, failureCallback) {
358 358
     var iq = $iq({to: this.getFocusComponent(), type: 'get'});
359 359
     iq.c('login-url', {
360 360
         xmlns: 'http://jitsi.org/protocol/focus',
@@ -372,14 +372,17 @@ Moderator.prototype.getLoginUrl =  function (urlCallback) {
372 372
             } else {
373 373
                 logger.error(
374 374
                     "Failed to get auth url from the focus", result);
375
+                failureCallback(result);
375 376
             }
376 377
         },
377 378
         function (error) {
378 379
             logger.error("Get auth url error", error);
380
+            failureCallback(error);
379 381
         }
380 382
     );
381 383
 };
382
-Moderator.prototype.getPopupLoginUrl =  function (urlCallback) {
384
+
385
+Moderator.prototype.getPopupLoginUrl = function (urlCallback, failureCallback) {
383 386
     var iq = $iq({to: this.getFocusComponent(), type: 'get'});
384 387
     iq.c('login-url', {
385 388
         xmlns: 'http://jitsi.org/protocol/focus',
@@ -398,10 +401,12 @@ Moderator.prototype.getPopupLoginUrl =  function (urlCallback) {
398 401
             } else {
399 402
                 logger.error(
400 403
                     "Failed to get POPUP auth url from the focus", result);
404
+               failureCallback(result);
401 405
             }
402 406
         },
403 407
         function (error) {
404 408
             logger.error('Get POPUP auth url error', error);
409
+            failureCallback(error);
405 410
         }
406 411
     );
407 412
 };
@@ -435,6 +440,3 @@ Moderator.prototype.logout =  function (callback) {
435 440
 };
436 441
 
437 442
 module.exports = Moderator;
438
-
439
-
440
-

Laddar…
Avbryt
Spara