浏览代码

Implements extension external installation for popup windows

j8
hristoterezov 8 年前
父节点
当前提交
f899d16a79
共有 4 个文件被更改,包括 80 次插入4 次删除
  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 查看文件

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

+ 4
- 1
lang/main.json 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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
 };

正在加载...
取消
保存