Frank Kobzik has uploaded a new change for review.

Change subject: frontend: Make VNC implementation configurable from UI
......................................................................

frontend: Make VNC implementation configurable from UI

This patch enables configuring VNC client mode to be configurable from
the console popup dialog.

Currently two options are available:
 - Native Client (MIME)
 - noVNC.

The patch also adds persisting the selected value to the browser
storage.

Change-Id: Ied777eaefe6c6dc25a002e761bbf5b501710b2ae
Signed-off-by: Frantisek Kobzik <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/popup/ConsolePopupPresenterWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleOptionsFrontendPersisterImpl.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleUtilsImpl.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.ui.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Configurator.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/ConsoleUtils.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VncConsoleModel.java
9 files changed, 221 insertions(+), 50 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/24/16224/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index 463b6fa..e84646e 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -1186,6 +1186,9 @@
     @DefaultStringValue("Browser plugin")
     String browserPlugin();
 
+    @DefaultStringValue("noVNC")
+    String noVnc();
+
     @DefaultStringValue("Pass Ctrl-Alt-Del to virtual machine")
     String ctrlAltDel();
 
@@ -1228,6 +1231,9 @@
     @DefaultStringValue("VNC")
     String vnc();
 
+    @DefaultStringValue("Websockets Proxy must be configured in the engine.")
+    String webSocketProxyNotSet();
+
     @DefaultStringValue("SPICE Options")
     String spiceOptions();
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/popup/ConsolePopupPresenterWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/popup/ConsolePopupPresenterWidget.java
index d1ae40f..8845308 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/popup/ConsolePopupPresenterWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/popup/ConsolePopupPresenterWidget.java
@@ -49,19 +49,26 @@
         HasValueChangeHandlers<Boolean> getSpiceNativeImplRadioButton();
         HasValueChangeHandlers<Boolean> getSpicePluginImplRadioButton();
 
+        HasValueChangeHandlers<Boolean> getNoVncImplRadioButton();
+        HasValueChangeHandlers<Boolean> getVncNativeImplRadioButton();
+
         HasValueChangeHandlers<Boolean> getRdpAutoImplRadioButton();
         HasValueChangeHandlers<Boolean> getRdpNativeImplRadioButton();
         HasValueChangeHandlers<Boolean> getRdpPluginImplRadioButton();
 
-        void rdpSelected(boolean selected);
+        void showRdpPanel(boolean visible);
 
-        void spiceSelected(boolean selected);
+        void showSpicePanel(boolean visible);
+
+        void showVncPanel(boolean visible);
 
         void selectSpice(boolean selected);
 
         void selectRdp(boolean selected);
 
         void selectVnc(boolean selected);
+
+        void setNoVncEnabled(boolean enabled, String reason);
 
         void setAdditionalConsoleAvailable(boolean hasAdditionalConsole);
 
@@ -82,6 +89,8 @@
         void setCtrlAltDelEnabled(boolean enabled, String reason);
 
         void setSpiceProxyEnabled(boolean enabled, String reason);
+
+        void selectVncImplementation(VncConsoleModel.ClientConsoleMode 
clientConsoleMode);
 
         void selectRdpImplementation(RdpConsoleModel.ClientConsoleMode 
consoleMode);
 
@@ -191,8 +200,9 @@
         getView().selectRdp(rdpPreselected);
         getView().selectVnc(vncPreselected);
 
-        getView().spiceSelected(spicePreselected);
-        getView().rdpSelected(rdpPreselected);
+        getView().showSpicePanel(spicePreselected);
+        getView().showRdpPanel(rdpPreselected);
+        getView().showVncPanel(vncPreselected);
 
         
getView().setDisableSmartcardVisible(consoleUtils.isSmartcardGloballyEnabled(currentItem));
 
@@ -207,12 +217,17 @@
             getView().setSpicePluginImplEnabled(false, 
constants.spicePluginNotSupportedByBrowser());
         }
 
+        getView().setNoVncEnabled(consoleUtils.isWebSocketProxyDefined(), 
constants.webSocketProxyNotSet());
+
         if (!consoleUtils.isBrowserPluginSupported(ConsoleProtocol.RDP)) {
             getView().setRdpPluginImplEnabled(false, 
constants.rdpPluginNotSupportedByBrowser());
         }
 
         SpiceConsoleModel spiceModel = extractSpiceModel(model);
         getView().selectSpiceImplementation(spiceModel == null ? 
SpiceConsoleModel.ClientConsoleMode.Auto : spiceModel.getClientConsoleMode());
+
+        VncConsoleModel vncModel = extractVncModel(model);
+        getView().selectVncImplementation(vncModel == null ? 
VncConsoleModel.ClientConsoleMode.Native : vncModel.getClientConsoleMode());
 
         RdpConsoleModel rdpModel = extractRdpModel(model);
         getView().selectRdpImplementation(rdpModel == null ? 
RdpConsoleModel.ClientConsoleMode.Auto : rdpModel.getClientConsoleMode());
@@ -259,21 +274,9 @@
 
     protected void listenOnRadioButtons(final ConsolePopupModel model) {
         
registerHandler(getView().getRdpRadioButton().addValueChangeHandler(new 
ValueChangeHandler<Boolean>() {
-
             @Override
             public void onValueChange(ValueChangeEvent<Boolean> event) {
-                getView().rdpSelected(event.getValue());
-                getView().spiceSelected(!event.getValue());
-                getView().setWanOptionsVisible(wanOptionsAvailable && 
!event.getValue());
-            }
-        }));
-
-        
registerHandler(getView().getSpiceRadioButton().addValueChangeHandler(new 
ValueChangeHandler<Boolean>() {
-            @Override
-            public void onValueChange(ValueChangeEvent<Boolean> event) {
-                getView().spiceSelected(event.getValue());
-                getView().setWanOptionsVisible(wanOptionsAvailable && 
event.getValue());
-                getView().rdpSelected(!event.getValue());
+                getView().showRdpPanel(event.getValue());
             }
         }));
 
@@ -281,13 +284,14 @@
 
             @Override
             public void onValueChange(ValueChangeEvent<Boolean> event) {
-                if (event.getValue()) {
-                    // hide all detail panels if this is selected.
-                    // Ignore if deselected
-                    getView().spiceSelected(false);
-                    getView().setWanOptionsVisible(false);
-                    getView().rdpSelected(false);
-                }
+                getView().showVncPanel(event.getValue());
+            }
+        }));
+
+        
registerHandler(getView().getSpiceRadioButton().addValueChangeHandler(new 
ValueChangeHandler<Boolean>() {
+            @Override
+            public void onValueChange(ValueChangeEvent<Boolean> event) {
+                getView().showSpicePanel(event.getValue());
             }
         }));
 
@@ -313,6 +317,22 @@
                         
getView().selectSpiceImplementation(SpiceConsoleModel.ClientConsoleMode.Plugin);
                     }
                 }));
+
+         registerHandler(getView().getNoVncImplRadioButton()
+                .addValueChangeHandler(new ValueChangeHandler<Boolean>() {
+                    @Override
+                    public void onValueChange(ValueChangeEvent<Boolean> event) 
{
+                        
getView().selectVncImplementation(VncConsoleModel.ClientConsoleMode.NoVnc);
+                    }
+                }));
+
+         registerHandler(getView().getVncNativeImplRadioButton()
+                 .addValueChangeHandler(new ValueChangeHandler<Boolean>() {
+                     @Override
+                     public void onValueChange(ValueChangeEvent<Boolean> 
event) {
+                         
getView().selectVncImplementation(VncConsoleModel.ClientConsoleMode.Native);
+                     }
+                 }));
 
         registerHandler(getView().getRdpAutoImplRadioButton()
                 .addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@@ -359,6 +379,16 @@
         return null;
     }
 
+    private VncConsoleModel extractVncModel(ConsolePopupModel model) {
+    ConsoleModel consoleModel = model.getModel().getDefaultConsoleModel();
+
+        if (consoleModel instanceof VncConsoleModel) {
+            return (VncConsoleModel) consoleModel;
+        }
+
+        return null;
+    }
+
     protected RdpConsoleModel extractRdpModel(ConsolePopupModel model) {
         ConsoleModel consoleModel = 
model.getModel().getAdditionalConsoleModel();
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleOptionsFrontendPersisterImpl.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleOptionsFrontendPersisterImpl.java
index 1cbaf24..c1f01dc 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleOptionsFrontendPersisterImpl.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleOptionsFrontendPersisterImpl.java
@@ -11,6 +11,7 @@
 import org.ovirt.engine.ui.uicommonweb.models.vms.SpiceConsoleModel;
 
 import com.google.inject.Inject;
+import org.ovirt.engine.ui.uicommonweb.models.vms.VncConsoleModel;
 
 public class ConsoleOptionsFrontendPersisterImpl implements 
ConsoleOptionsFrontendPersister {
 
@@ -26,6 +27,9 @@
     private static final String WAN_OPTIONS = "_wanOptions"; //$NON-NLS-1$
     private static final String USB_AUTOSHARE = "_usbAutoshare"; //$NON-NLS-1$
     private static final String SPICE_PROXY_ENABLED = "_spiceProxyEnabled"; 
//$NON-NLS-1$
+
+    // vnc options
+    private static final String VNC_CLIENT_MODE = "_vncClientMode"; 
//$NON-NLS-1$
 
     // rdp options
     private static final String RDP_CLIENT_MODE = "_rdpClientMode"; 
//$NON-NLS-1$
@@ -54,10 +58,16 @@
 
         clientStorage.setLocalItem(keyMaker.make(SELECTED_PROTOCOL), 
selectedProtocol.toString());
 
-        if (selectedProtocol == ConsoleProtocol.SPICE) {
-            storeSpiceData(model, keyMaker);
-        } else if (selectedProtocol == ConsoleProtocol.RDP) {
-            storeRdpData(model, keyMaker);
+        switch (selectedProtocol) {
+            case SPICE:
+                storeSpiceData(model, keyMaker);
+                break;
+            case VNC:
+                storeVncData(model, keyMaker);
+                break;
+            case RDP :
+                storeRdpData(model, keyMaker);
+                break;
         }
     }
 
@@ -77,14 +87,27 @@
 
         ConsoleProtocol selectedProtocol = 
ConsoleProtocol.valueOf(selectedProtocolString);
 
-        if (selectedProtocol == ConsoleProtocol.SPICE) {
-            loadSpiceData(model, keyMaker);
-        } else if (selectedProtocol == ConsoleProtocol.RDP) {
-            loadRdpData(model, keyMaker);
-        } else {
-            // VNC is available all the time
-            model.setSelectedProtocol(selectedProtocol);
+        switch (selectedProtocol) {
+            case SPICE:
+                loadSpiceData(model, keyMaker);
+                break;
+            case VNC:
+                loadVncData(model, keyMaker);
+                break;
+            case RDP:
+                loadRdpData(model, keyMaker);
+                break;
         }
+    }
+
+    private void loadVncData(HasConsoleModel model, KeyMaker keyMaker) {
+        if (!(model.getDefaultConsoleModel() instanceof VncConsoleModel)) {
+            return;
+        }
+
+        model.setSelectedProtocol(ConsoleProtocol.VNC);
+        
asVncConsoleModel(model).setVncImplementation(VncConsoleModel.ClientConsoleMode
+                
.valueOf(clientStorage.getLocalItem(keyMaker.make(VNC_CLIENT_MODE))));
     }
 
     protected RdpConsoleModel asRdpConsoleModel(HasConsoleModel model) {
@@ -104,6 +127,13 @@
         storeBool(keyMaker.make(WAN_OPTIONS), spice.isWanOptionsEnabled());
         storeBool(keyMaker.make(USB_AUTOSHARE), spice.getUsbAutoShare());
         storeBool(keyMaker.make(SPICE_PROXY_ENABLED), 
spice.isSpiceProxyEnabled());
+    }
+
+    private void storeVncData(HasConsoleModel model, KeyMaker keyMaker) {
+        VncConsoleModel consoleModel = asVncConsoleModel(model);
+        if (consoleModel != null) {
+            clientStorage.setLocalItem(keyMaker.make(VNC_CLIENT_MODE), 
consoleModel.getClientConsoleMode().toString());
+        }
     }
 
     protected void loadRdpData(HasConsoleModel model, KeyMaker keyMaker) {
@@ -167,6 +197,10 @@
         return ((SpiceConsoleModel) model.getDefaultConsoleModel());
     }
 
+    private VncConsoleModel asVncConsoleModel(HasConsoleModel model) {
+        return (VncConsoleModel) model.getDefaultConsoleModel();
+    }
+
     protected void storeRdpData(HasConsoleModel model, KeyMaker keyMaker) {
         RdpConsoleModel consoleModel = asRdpConsoleModel(model);
         IRdp rdpImpl = consoleModel.getrdp();
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleUtilsImpl.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleUtilsImpl.java
index b1e34c3..e01fa8f 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleUtilsImpl.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ConsoleUtilsImpl.java
@@ -214,6 +214,11 @@
     }
 
     @Override
+    public boolean isWebSocketProxyDefined() {
+        return configurator.isWebSocketProxyDefined();
+    }
+
+    @Override
     public boolean isBrowserPluginSupported(ConsoleProtocol protocol) {
         switch (protocol) {
         case SPICE:
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.java
index 2ef12b3..bfce4d1 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.java
@@ -27,6 +27,7 @@
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.inject.Inject;
+import org.ovirt.engine.ui.uicommonweb.models.vms.VncConsoleModel;
 
 public class ConsolePopupView extends 
AbstractModelBoundPopupView<ConsolePopupModel> implements 
ConsolePopupPresenterWidget.ViewDef {
 
@@ -103,6 +104,14 @@
 
     @UiField(provided = true)
     @WithElementId
+    EntityModelRadioButtonEditor vncNativeImplRadioButton;
+
+    @UiField(provided = true)
+    @WithElementId
+    EntityModelRadioButtonEditor noVncImplRadioButton;
+
+    @UiField(provided = true)
+    @WithElementId
     EntityModelRadioButtonEditor rdpAutoImplRadioButton;
 
     @UiField(provided = true)
@@ -115,6 +124,9 @@
 
     @UiField
     FlowPanel spicePanel;
+
+    @UiField
+    FlowPanel vncPanel;
 
     @UiField
     FlowPanel rdpPanel;
@@ -151,11 +163,16 @@
         spicePluginImplRadioButton = new EntityModelRadioButtonEditor("2"); 
//$NON-NLS-1$
         spicePluginImplRadioButton.setLabel(constants.browserPlugin());
 
-        rdpAutoImplRadioButton = new EntityModelRadioButtonEditor("3"); 
//$NON-NLS-1$
+        vncNativeImplRadioButton = new EntityModelRadioButtonEditor("3"); 
//$NON-NLS-1$
+        vncNativeImplRadioButton.setLabel(constants.nativeClient());
+        noVncImplRadioButton = new EntityModelRadioButtonEditor("3"); 
//$NON-NLS-1$
+        noVncImplRadioButton.setLabel(constants.noVnc());
+
+        rdpAutoImplRadioButton = new EntityModelRadioButtonEditor("4"); 
//$NON-NLS-1$
         rdpAutoImplRadioButton.setLabel(constants.auto());
-        rdpNativeImplRadioButton = new EntityModelRadioButtonEditor("3");// 
$NON-NLS-1$
+        rdpNativeImplRadioButton = new EntityModelRadioButtonEditor("4");// 
$NON-NLS-1$
         rdpNativeImplRadioButton.setLabel(constants.nativeClient());
-        rdpPluginImplRadioButton = new EntityModelRadioButtonEditor("3"); 
//$NON-NLS-1$
+        rdpPluginImplRadioButton = new EntityModelRadioButtonEditor("4"); 
//$NON-NLS-1$
         rdpPluginImplRadioButton.setLabel(constants.browserPlugin());
 
         disableSmartcard = new 
EntityModelValueCheckBoxEditor<ConsoleModel>(Align.RIGHT, new SpiceRenderer() {
@@ -281,6 +298,7 @@
         ViewIdHandler.idHandler.generateAndSetIds(this);
 
         spicePanel.setVisible(false);
+        vncPanel.setVisible(false);
         rdpPanel.setVisible(false);
 
         
ctrlAltDel.getContentWidgetContainer().addStyleName(style.ctrlAltDelContentWidget());
@@ -324,6 +342,7 @@
             setSelectedRdpImpl();
         } else if (vncRadioButton.asRadioButton().getValue()) {
             setSelectedProtocol(ConsoleProtocol.VNC);
+            setSelectedVncImpl();
         }
 
         flushCheckBoxes(
@@ -353,6 +372,18 @@
             
spiceModel.setSpiceImplementation(SpiceConsoleModel.ClientConsoleMode.Native);
         } else if (spicePluginImplRadioButton.asRadioButton().getValue()) {
             
spiceModel.setSpiceImplementation(SpiceConsoleModel.ClientConsoleMode.Plugin);
+        }
+    }
+
+    private void setSelectedVncImpl() {
+        Object defConsoleModel = model.getModel().getDefaultConsoleModel();
+        VncConsoleModel vncConsoleModel = defConsoleModel instanceof 
VncConsoleModel ?
+                (VncConsoleModel) defConsoleModel : null;
+
+        if (noVncImplRadioButton.asRadioButton().getValue()) {
+            
vncConsoleModel.setVncImplementation(VncConsoleModel.ClientConsoleMode.NoVnc);
+        } else {
+            
vncConsoleModel.setVncImplementation(VncConsoleModel.ClientConsoleMode.Native);
         }
     }
 
@@ -423,13 +454,30 @@
     }
 
     @Override
-    public void rdpSelected(boolean selected) {
-        rdpPanel.setVisible(selected);
+    public void showRdpPanel(boolean visible) {
+        rdpPanel.setVisible(visible);
+        if (visible) {
+            spicePanel.setVisible(false);
+            vncPanel.setVisible(false);
+        }
     }
 
     @Override
-    public void spiceSelected(boolean selected) {
-        spicePanel.setVisible(selected);
+    public void showSpicePanel(boolean visible) {
+        spicePanel.setVisible(visible);
+        if (visible) {
+            vncPanel.setVisible(false);
+            rdpPanel.setVisible(false);
+        }
+    }
+
+    @Override
+    public void showVncPanel(boolean visible) {
+        vncPanel.setVisible(visible);
+        if (visible) {
+            spicePanel.setVisible(false);
+            rdpPanel.setVisible(false);
+        }
     }
 
     @Override
@@ -445,6 +493,12 @@
     @Override
     public void selectVnc(boolean selected) {
         vncRadioButton.asRadioButton().setValue(selected);
+    }
+
+    @Override
+    public void setNoVncEnabled(boolean enabled, String reason) {
+        noVncImplRadioButton.setEnabled(enabled);
+        noVncImplRadioButton.setTitle(enabled ? "" : reason);
     }
 
     abstract class SpiceRenderer implements 
ValueCheckboxRenderer<ConsoleModel> {
@@ -558,6 +612,20 @@
     }
 
     @Override
+    public void selectVncImplementation(VncConsoleModel.ClientConsoleMode 
clientConsoleMode) {
+        switch (clientConsoleMode) {
+            case NoVnc:
+                noVncImplRadioButton.asRadioButton().setValue(true);
+                vncNativeImplRadioButton.asRadioButton().setValue(false);
+                break;
+            default:
+                noVncImplRadioButton.asRadioButton().setValue(false);
+                vncNativeImplRadioButton.asRadioButton().setValue(true);
+                break;
+        }
+    }
+
+    @Override
     public void selectRdpImplementation(RdpConsoleModel.ClientConsoleMode 
consoleMode) {
         switch (consoleMode) {
         case Native:
@@ -608,4 +676,11 @@
         return rdpPluginImplRadioButton.asRadioButton();
     }
 
+    public HasValueChangeHandlers<Boolean> getNoVncImplRadioButton() {
+        return noVncImplRadioButton.asRadioButton();
+    }
+
+    public HasValueChangeHandlers<Boolean> getVncNativeImplRadioButton() {
+        return vncNativeImplRadioButton.asRadioButton();
+    }
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.ui.xml
index d275f8d..1d7925b 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/popup/ConsolePopupView.ui.xml
@@ -75,6 +75,12 @@
                                        </g:FlowPanel>
                                </g:FlowPanel>
 
+                               <g:FlowPanel ui:field="vncPanel" 
addStyleNames="{style.protocolPanel}">
+                                       <g:Label 
ui:field="vncConsoleInvocation" text="{constants.consoleInvocation}" 
addStyleNames="{style.labelStyle}" />
+                                       <e:EntityModelRadioButtonEditor 
ui:field="vncNativeImplRadioButton" title="{constants.nativeClient}"/>
+                                       <e:EntityModelRadioButtonEditor 
ui:field="noVncImplRadioButton" title="{constants.noVnc}"/>
+                               </g:FlowPanel>
+
                                <g:FlowPanel ui:field="rdpPanel" 
addStyleNames="{style.protocolPanel}">
                                        <g:Label text="{constants.rdpOptions}" 
addStyleNames="{style.labelStyle}" />
                                        <e:EntityModelRadioButtonEditor 
ui:field="rdpAutoImplRadioButton" />
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Configurator.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Configurator.java
index fb681c2..15f3ca8 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Configurator.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Configurator.java
@@ -262,6 +262,12 @@
         }
     }
 
+    public boolean isWebSocketProxyDefined() {
+        String wsConfig = (String) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.WebSocketProxy);
+        return wsConfig != null && !"".equals(wsConfig) && 
!"Off".equals(wsConfig); //$NON-NLS-1$ $NON-NLS-2$
+    }
+
+
     public final class FileFetchEventArgs extends EventArgs {
         private String fileContent;
 
@@ -368,7 +374,6 @@
     public boolean isSpiceProxyDefined() {
         String spiceProxy = (String) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.SpiceProxyDefault);
         return spiceProxy != null && !"".equals(spiceProxy); //$NON-NLS-1$
-
     }
 
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/ConsoleUtils.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/ConsoleUtils.java
index 1ffe69e..990b92b 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/ConsoleUtils.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/ConsoleUtils.java
@@ -38,4 +38,6 @@
     public boolean isBrowserPluginSupported(ConsoleProtocol protocol);
 
     public boolean isSpiceProxyDefined();
+
+    public boolean isWebSocketProxyDefined();
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VncConsoleModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VncConsoleModel.java
index 6a13b29..f849059 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VncConsoleModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VncConsoleModel.java
@@ -5,7 +5,6 @@
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
 import org.ovirt.engine.core.common.businessentities.DisplayType;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
-import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
@@ -16,12 +15,15 @@
 import org.ovirt.engine.ui.uicommonweb.BaseCommandTarget;
 import org.ovirt.engine.ui.uicommonweb.TypeResolver;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
-import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
 import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult;
 import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback;
 
 public class VncConsoleModel extends ConsoleModel {
+
+    private ClientConsoleMode consoleMode;
+
+    public enum ClientConsoleMode { Native, NoVnc }
 
     private static final int TICKET_VALIDITY_SECONDS = 120;
 
@@ -29,7 +31,7 @@
 
     private String otp64 = null;
 
-    private final IVnc vncImpl;
+    private IVnc vncImpl;
 
     private String getPort() {
         if (getEntity() == null && getEntity().getDisplay() == null) {
@@ -49,11 +51,17 @@
 
     public VncConsoleModel() {
         setTitle(ConstantsManager.getInstance().getConstants().VNCTitle());
+        setVncImplementation(ClientConsoleMode.Native); //Native (MIME) way is 
the default
+    }
 
-        String noVncConfig = (String) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.WebSocketProxy);
-        this.vncImpl = StringHelper.isNullOrEmpty(noVncConfig) || 
noVncConfig.equals("Off") ? // $NON-NLS-1$
-            (IVnc) TypeResolver.getInstance().resolve(IVncNative.class) :
-            (IVnc) TypeResolver.getInstance().resolve(INoVnc.class);
+    public void setVncImplementation(ClientConsoleMode consoleMode) {
+        Class implClass = consoleMode == ClientConsoleMode.NoVnc ? 
INoVnc.class : IVncNative.class;
+        this.consoleMode = consoleMode;
+        this.vncImpl = (IVnc) TypeResolver.getInstance().resolve(implClass);
+    }
+
+    public ClientConsoleMode getClientConsoleMode() {
+        return consoleMode;
     }
 
     @Override


-- 
To view, visit http://gerrit.ovirt.org/16224
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied777eaefe6c6dc25a002e761bbf5b501710b2ae
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Frank Kobzik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to