CLOUDSTACK-4973: Specified keyboard language is not showing as default in consoleView passed during deployVM.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f6b063de Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f6b063de Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f6b063de Branch: refs/heads/master Commit: f6b063de7994c65d307d39fe51229c671ad91f16 Parents: 46c6b91 Author: Sanjay Tripathi <[email protected]> Authored: Mon Dec 9 16:31:07 2013 +0530 Committer: Sanjay Tripathi <[email protected]> Committed: Fri Dec 27 18:17:22 2013 +0530 ---------------------------------------------------------------------- server/src/com/cloud/servlet/ConsoleProxyClientParam.java | 10 +++++++++- server/src/com/cloud/servlet/ConsoleProxyServlet.java | 10 +++++++++- .../com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java | 2 ++ .../com/cloud/consoleproxy/ConsoleProxyClientBase.java | 6 +++--- .../com/cloud/consoleproxy/ConsoleProxyClientParam.java | 10 +++++++++- .../cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java | 3 +++ systemvm/js/ajaxviewer.js | 10 +++++++--- 7 files changed, 42 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/server/src/com/cloud/servlet/ConsoleProxyClientParam.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/servlet/ConsoleProxyClientParam.java b/server/src/com/cloud/servlet/ConsoleProxyClientParam.java index 7ea17c8..e979337 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyClientParam.java +++ b/server/src/com/cloud/servlet/ConsoleProxyClientParam.java @@ -23,7 +23,7 @@ public class ConsoleProxyClientParam { private String clientHostPassword; private String clientTag; private String ticket; - + private String locale; private String clientTunnelUrl; private String clientTunnelSession; @@ -89,6 +89,14 @@ public class ConsoleProxyClientParam { this.clientTunnelSession = clientTunnelSession; } + public String getLocale() { + return this.locale; + } + + public void setLocale(String locale) { + this.locale = locale; + } + public String getAjaxSessionId() { return this.ajaxSessionId; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/server/src/com/cloud/servlet/ConsoleProxyServlet.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index 06e542d..0359a45 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -57,8 +57,10 @@ import com.cloud.utils.Pair; import com.cloud.utils.Ternary; import com.cloud.utils.db.EntityManager; import com.cloud.utils.db.TransactionLegacy; +import com.cloud.vm.UserVmDetailVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineManager; +import com.cloud.vm.dao.UserVmDetailsDao; /** * Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx @@ -82,6 +84,8 @@ public class ConsoleProxyServlet extends HttpServlet { IdentityService _identityService; @Inject EntityManager _entityMgr; + @Inject + UserVmDetailsDao _userVmDetailsDao; static ManagementServer s_ms; @@ -391,6 +395,7 @@ public class ConsoleProxyServlet extends HttpServlet { Ternary<String, String, String> parsedHostInfo = parseHostInfo(portInfo.first()); + UserVmDetailVO details = _userVmDetailsDao.findDetail(vm.getId(), "keyboard"); String sid = vm.getVncPassword(); String tag = vm.getUuid(); String ticket = genAccessTicket(host, String.valueOf(portInfo.second()), sid, tag); @@ -401,7 +406,10 @@ public class ConsoleProxyServlet extends HttpServlet { param.setClientHostPassword(sid); param.setClientTag(tag); param.setTicket(ticket); - if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) { + if (details != null) { + param.setLocale(details.getValue()); + } + if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) { param.setClientTunnelUrl(parsedHostInfo.second()); param.setClientTunnelSession(parsedHostInfo.third()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java index 56e2ea9..18d97d2 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java @@ -79,6 +79,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler { String eventStr = queryMap.get("event"); String console_url = queryMap.get("consoleurl"); String console_host_session = queryMap.get("sessionref"); + String vm_locale = queryMap.get("locale"); if (tag == null) tag = ""; @@ -126,6 +127,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler { param.setTicket(ticket); param.setClientTunnelUrl(console_url); param.setClientTunnelSession(console_host_session); + param.setLocale(vm_locale); viewer = ConsoleProxy.getAjaxVncViewer(param, ajaxSessionIdStr); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java index daef040..eb38007 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java @@ -287,11 +287,11 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons } return getAjaxViewerPageContent(sbTileSequence.toString(), imgUrl, updateUrl, width, height, tileWidth, tileHeight, title, - ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages, guest); + ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages, guest, this.clientParam.getLocale()); } private String getAjaxViewerPageContent(String tileSequence, String imgUrl, String updateUrl, int width, int height, int tileWidth, int tileHeight, String title, - boolean rawKeyboard, List<String> languages, String guest) { + boolean rawKeyboard, List<String> languages, String guest, String locale) { StringBuffer sbLanguages = new StringBuffer(""); if (languages != null) { @@ -323,7 +323,7 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons "<li><a href=\"#\" cmd=\"keyboard_jp\"><span>Japanese keyboard</span></a></li>", "</ul>", "</li>", "</ul>", "<span id=\"light\" class=\"dark\" cmd=\"toggle_logwin\"></span>", "</div>", "<div id=\"main_panel\" tabindex=\"1\"></div>", "<script language=\"javascript\">", "var acceptLanguages = '" + sbLanguages.toString() + "';", "var tileMap = [ " + tileSequence + " ];", - "var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', tileMap, ", + "var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', '" + locale + "', tileMap, ", String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ");", "$(function() {", "ajaxViewer.start();", "});", http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java index d13ae0e..a04dd30 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java @@ -30,7 +30,7 @@ public class ConsoleProxyClientParam { private String clientTunnelUrl; private String clientTunnelSession; - + private String locale; private String ajaxSessionId; public ConsoleProxyClientParam() { @@ -101,6 +101,14 @@ public class ConsoleProxyClientParam { this.ajaxSessionId = ajaxSessionId; } + public String getLocale() { + return this.locale; + } + + public void setLocale(String locale) { + this.locale = locale; + } + public String getClientMapKey() { if (clientTag != null && !clientTag.isEmpty()) return clientTag; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java index 6b6db54..7811d50 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java @@ -68,6 +68,8 @@ public class ConsoleProxyHttpHandlerHelper { map.put("sessionref", param.getClientTunnelSession()); if (param.getTicket() != null) map.put("ticket", param.getTicket()); + if (param.getLocale() != null) + map.put("locale", param.getLocale()); } } else { // we no longer accept information from parameter other than token @@ -85,5 +87,6 @@ public class ConsoleProxyHttpHandlerHelper { map.remove("consoleurl"); map.remove("sessionref"); map.remove("ticket"); + map.remove("locale"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6b063de/systemvm/js/ajaxviewer.js ---------------------------------------------------------------------- diff --git a/systemvm/js/ajaxviewer.js b/systemvm/js/ajaxviewer.js index 9643204..ff899b1 100644 --- a/systemvm/js/ajaxviewer.js +++ b/systemvm/js/ajaxviewer.js @@ -332,7 +332,7 @@ KeyboardMapper.prototype = { ///////////////////////////////////////////////////////////////////////////// // class AjaxViewer // -function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight) { +function AjaxViewer(panelId, imageUrl, updateUrl, locale, tileMap, width, height, tileWidth, tileHeight) { // logging is disabled by default so that it won't have negative impact on performance // however, a back door key-sequence can trigger to open the logger window, it is designed to help // trouble-shooting @@ -358,8 +358,12 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.maxTileZIndex = 1; - - this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH; + + if (locale == AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH || locale == AjaxViewer.KEYBOARD_TYPE_JAPANESE) + this.currentKeyboard = locale; + else + this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH; + this.keyboardMappers = []; this.timer = 0;
