Pārlūkot izejas kodu

Merge pull request #779 from jitsi/fix_ss_from_popup

Implements extension external installation for popup windows
j8
bgrozev 9 gadus atpakaļ
vecāks
revīzija
e59ad67055
4 mainītis faili ar 80 papildinājumiem un 4 dzēšanām
  1. 38
    2
      conference.js
  2. 4
    1
      lang/main.json
  3. 27
    0
      modules/UI/UI.js
  4. 11
    1
      service/UI/UIEvents.js

+ 38
- 2
conference.js Parādīt failu

@@ -32,6 +32,11 @@ let room, connection, localAudio, localVideo, roomLocker;
32 32
  */
33 33
 let connectionIsInterrupted = false;
34 34
 
35
+/**
36
+ * Indicates whether extension external installation is in progress or not.
37
+ */
38
+let DSExternalInstallationInProgress = false;
39
+
35 40
 import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo";
36 41
 
37 42
 /**
@@ -269,7 +274,9 @@ function createLocalTracks (options, checkForPermissionPrompt) {
269 274
                 ? APP.settings.getMicDeviceId()
270 275
                 : options.micDeviceId,
271 276
             // adds any ff fake device settings if any
272
-            firefox_fake_device: config.firefox_fake_device
277
+            firefox_fake_device: config.firefox_fake_device,
278
+            desktopSharingExtensionExternalInstallation:
279
+                options.desktopSharingExtensionExternalInstallation
273 280
         }, checkForPermissionPrompt)
274 281
         .catch(function (err) {
275 282
             console.error(
@@ -877,9 +884,27 @@ export default {
877 884
         }
878 885
 
879 886
         this.videoSwitchInProgress = true;
887
+        let externalInstallation = false;
880 888
 
881 889
         if (shareScreen) {
882
-            createLocalTracks({ devices: ['desktop'] }).then(([stream]) => {
890
+            createLocalTracks({
891
+                devices: ['desktop'],
892
+                desktopSharingExtensionExternalInstallation: {
893
+                    interval: 500,
894
+                    checkAgain: () => {
895
+                        return DSExternalInstallationInProgress;
896
+                    },
897
+                    listener: (url) => {
898
+                        DSExternalInstallationInProgress = true;
899
+                        externalInstallation = true;
900
+                        APP.UI.showExtensionExternalInstallationDialog(url);
901
+                    }
902
+                }
903
+            }).then(([stream]) => {
904
+                DSExternalInstallationInProgress = false;
905
+                // close external installation dialog on success.
906
+                if(externalInstallation)
907
+                    $.prompt.close();
883 908
                 stream.on(
884 909
                     TrackEvents.LOCAL_TRACK_STOPPED,
885 910
                     () => {
@@ -1135,6 +1160,17 @@ export default {
1135 1160
             APP.UI.updateDTMFSupport(isDTMFSupported);
1136 1161
         });
1137 1162
 
1163
+        APP.UI.addListener(UIEvents.EXTERNAL_INSTALLATION_CANCELED, () => {
1164
+            // Wait a little bit more just to be sure that we won't miss the
1165
+            // extension installation
1166
+            setTimeout(() => DSExternalInstallationInProgress = false, 500);
1167
+        });
1168
+        APP.UI.addListener(UIEvents.OPEN_EXTENSION_STORE, (url) => {
1169
+            window.open(
1170
+                url, "extension_store_window",
1171
+                "resizable,scrollbars=yes,status=1");
1172
+        });
1173
+
1138 1174
         APP.UI.addListener(UIEvents.ROOM_LOCK_CLICKED, () => {
1139 1175
             if (room.isModerator()) {
1140 1176
                 let promise = roomLocker.isLocked

+ 4
- 1
lang/main.json Parādīt failu

@@ -263,7 +263,10 @@
263 263
         "micUnknownError": "Cannot use microphone for a unknown reason.",
264 264
         "micPermissionDeniedError": "You have not granted permission to use your microphone. You can still join the conference but others won't hear you. Use the camera button in the address bar to fix this.",
265 265
         "micNotFoundError": "Requested microphone was not found.",
266
-        "micConstraintFailedError": "Yor microphone does not satisfy some of required constraints."
266
+        "micConstraintFailedError": "Yor microphone does not satisfy some of required constraints.",
267
+        "goToStore": "Go to the webstore",
268
+        "externalInstallationTitle": "Extension required",
269
+        "externalInstallationMsg": "You need to install our desktop sharing extension."
267 270
     },
268 271
     "email":
269 272
     {

+ 27
- 0
modules/UI/UI.js Parādīt failu

@@ -1213,6 +1213,33 @@ UI.showExtensionRequiredDialog = function (url) {
1213 1213
             "dialog.firefoxExtensionPrompt", {url: url}));
1214 1214
 };
1215 1215
 
1216
+/**
1217
+ * Shows "Please go to chrome webstore to install the desktop sharing extension"
1218
+ * 2 button dialog with buttons - cancel and go to web store.
1219
+ * @param url {string} the url of the extension.
1220
+ */
1221
+UI.showExtensionExternalInstallationDialog = function (url) {
1222
+    messageHandler.openTwoButtonDialog(
1223
+        "dialog.externalInstallationTitle",
1224
+        null,
1225
+        "dialog.externalInstallationMsg",
1226
+        null,
1227
+        true,
1228
+        "dialog.goToStore",
1229
+         function(e,v,m,f){
1230
+            if (v) {
1231
+                e.preventDefault();
1232
+                eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
1233
+            }
1234
+        },
1235
+        function () {},
1236
+        function () {
1237
+            eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
1238
+        }
1239
+    );
1240
+};
1241
+
1242
+
1216 1243
 /**
1217 1244
  * Shows dialog with combined information about camera and microphone errors.
1218 1245
  * @param {JitsiTrackError} micError

+ 11
- 1
service/UI/UIEvents.js Parādīt failu

@@ -83,5 +83,15 @@ export default {
83 83
     LOCAL_FLIPX_CHANGED: "UI.local_flipx_changed",
84 84
     // An event which indicates that the resolution of a remote video has
85 85
     // changed.
86
-    RESOLUTION_CHANGED: "UI.resolution_changed"
86
+    RESOLUTION_CHANGED: "UI.resolution_changed",
87
+    /**
88
+     * Notifies that the button "Go to webstore" is pressed on the dialog for
89
+     * external extension installation.
90
+     */
91
+    OPEN_EXTENSION_STORE: "UI.open_extension_store",
92
+    /**
93
+     * Notifies that the button "Cancel" is pressed on the dialog for
94
+     * external extension installation.
95
+     */
96
+    EXTERNAL_INSTALLATION_CANCELED: "UI.external_installation_canceled"
87 97
 };

Notiek ielāde…
Atcelt
Saglabāt