You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2013/12/27 11:52:07 UTC
[2/2] git commit: updated refs/heads/4.3 to 1ee3612
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/526043b7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/526043b7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/526043b7
Branch: refs/heads/4.3
Commit: 526043b715dc279ad58cb37c28d81b177eb2aa44
Parents: 029f4e3
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Mon Dec 9 16:31:07 2013 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Fri Dec 27 16:15:00 2013 +0530
----------------------------------------------------------------------
.../cloud/servlet/ConsoleProxyClientParam.java | 10 +++++++-
.../com/cloud/servlet/ConsoleProxyServlet.java | 11 ++++++---
.../consoleproxy/ConsoleProxyAjaxHandler.java | 6 +++--
.../consoleproxy/ConsoleProxyClientBase.java | 6 ++---
.../consoleproxy/ConsoleProxyClientParam.java | 12 ++++++++--
.../ConsoleProxyHttpHandlerHelper.java | 24 +++++++++++---------
systemvm/js/ajaxviewer.js | 12 ++++++----
7 files changed, 55 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526043b7/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 e420110..33f124a 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;
@@ -97,6 +97,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/526043b7/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 b3415db..aad00a4 100644
--- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java
+++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
@@ -58,9 +58,10 @@ import com.cloud.utils.Ternary;
import com.cloud.utils.db.EntityManager;
import com.cloud.utils.db.Transaction;
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
* Console access : /conosole?cmd=access&vm=xxx
@@ -77,8 +78,8 @@ public class ConsoleProxyServlet extends HttpServlet {
@Inject VirtualMachineManager _vmMgr;
@Inject ManagementServer _ms;
@Inject IdentityService _identityService;
- @Inject
- EntityManager _entityMgr;
+ @Inject EntityManager _entityMgr;
+ @Inject UserVmDetailsDao _userVmDetailsDao;
static ManagementServer s_ms;
@@ -389,6 +390,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);
@@ -399,6 +401,9 @@ public class ConsoleProxyServlet extends HttpServlet {
param.setClientHostPassword(sid);
param.setClientTag(tag);
param.setTicket(ticket);
+ 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/526043b7/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 6cadeca..f4d3a17 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java
@@ -77,7 +77,8 @@ 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 = "";
@@ -124,7 +125,8 @@ 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/526043b7/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 07a1b6f..d5b6ffd 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
@@ -283,11 +283,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);
+ 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) {
+ int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages, String guest, String locale) {
StringBuffer sbLanguages = new StringBuffer("");
if(languages != null) {
@@ -342,7 +342,7 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
"<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() {",
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526043b7/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 8de4955..7041ff0 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() {
@@ -96,11 +96,19 @@ public class ConsoleProxyClientParam {
public String getAjaxSessionId() {
return this.ajaxSessionId;
}
-
+
public void setAjaxSessionId(String ajaxSessionId) {
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/526043b7/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 297e711..353137c 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java
@@ -69,22 +69,24 @@ 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
- guardUserInput(map);
+ // we no longer accept information from parameter other than token
+ guardUserInput(map);
}
-
return map;
}
-
+
private static void guardUserInput(Map<String, String> map) {
- map.remove("host");
- map.remove("port");
- map.remove("tag");
- map.remove("sid");
- map.remove("consoleurl");
- map.remove("sessionref");
- map.remove("ticket");
+ map.remove("host");
+ map.remove("port");
+ map.remove("tag");
+ map.remove("sid");
+ map.remove("consoleurl");
+ map.remove("sessionref");
+ map.remove("ticket");
+ map.remove("locale");
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526043b7/systemvm/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/systemvm/js/ajaxviewer.js b/systemvm/js/ajaxviewer.js
index 9643204..aeb2bba 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,10 +358,14 @@ 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;
this.eventQueue = [];
this.sendingEventInProgress = false;