sdbHelper->openShell(vmName);
}
-void ContextMenu::slotControlPanel()
+void ContextMenu::launchControlPanel(QString& command,
+ QStringList& arguments)
{
- qDebug("Control Panel");
+ QString httpProxyAddr;
+ QString httpProxyPort;
+ const char *http_proxy_addr = get_http_proxy_addr();
+ if (http_proxy_addr) {
+ char **proxy = g_strsplit(http_proxy_addr, ":", 2);
+ if (proxy[0] && proxy[1]) {
+ httpProxyAddr = "-Dhttp.proxyHost=" + QString(proxy[0]);
+ httpProxyPort = "-Dhttp.proxyPort=" + QString(proxy[1]);
+ }
+ g_strfreev(proxy);
+ }
+
+ if (httpProxyAddr != NULL && httpProxyPort != NULL) {
+ arguments << httpProxyAddr << httpProxyPort;
+ }
- QString jar = QDir(QCoreApplication::applicationDirPath() +
- QDir::separator() + SDK_EMULATOR_BIN_PATH +
- SDK_ECP_FILE_JAR).absolutePath();
- if (!QFileInfo(jar).exists()) {
- // check ecp jar
- showMsgBox(QMessageBox::Warning,
- MSG_ECP_NOT_EXIST + jar);
+ QString loggingCommand = QString("staring ecp: \"" + command + "\"");
+ for (int i = 0; i < arguments.size(); ++i) {
+ loggingCommand += " \"" + arguments.at(i) + "\"";
+ }
+ qInfo() << qPrintable(loggingCommand);
+
+ QString workingDir = QFileInfo(command).canonicalPath();
+ try {
+ QProcess::startDetached(command, arguments, workingDir);
+ } catch (QString &error) {
+ showMsgBox(QMessageBox::Warning, MSG_INVALID_ECP_OPEN + error);
return;
}
+}
+
+void ContextMenu::slotControlPanel()
+{
+ qDebug("Control Panel");
- QString command = QDir(QCoreApplication::applicationDirPath() +
- QDir::separator() + SDK_EMULATOR_BIN_PATH +
- SDK_ECP_FILE).absolutePath();
+ QString command;
QStringList arguments;
- if (QFileInfo(command).exists()) {
+
+ // check for new ECP
+ QString newCommand = QDir(QCoreApplication::applicationDirPath() +
+ QDir::separator() + SDK_EMULATOR_TOOLS_BIN_PATH +
+ SDK_ECP_FILE).absolutePath();
+ if (QFileInfo(newCommand).exists()) {
+ command = newCommand;
+
+ QString vmNameOpt = "vm_name=" + parent->getUiInfo()->getVmName();
+ QString platformVersionOpt = "platform_version=" +
+ QString::fromLocal8Bit(get_platform_version());
+ QString profileOpt = "profile=" +
+ QString::fromLocal8Bit(get_profile_name());
+ QString basePortOpt =
+ "base_port=" + QString::number(parent->getUiInfo()->getBasePort());
+
+ arguments << vmNameOpt << platformVersionOpt << profileOpt
+ << basePortOpt;
+
// we have standalone command for ECP
// we respect standalone command, so nothing to do
- } else {
+ launchControlPanel(command, arguments);
+
+ return;
+ }
+
+ // check for old ECP
+ QString oldJar = QDir(QCoreApplication::applicationDirPath() +
+ QDir::separator() + SDK_EMULATOR_BIN_PATH +
+ SDK_ECP_FILE_JAR).absolutePath();
+ if (QFileInfo(oldJar).exists()) {
// we do not have standalone command for ECP
// we may have SWT based ECP
/* SWT Display must be created on main thread due to Cocoa restrictions */
arguments << "-XstartOnFirstThread";
#endif
- arguments << "-jar" << jar;
- }
+ arguments << "-jar" << oldJar;
- QString basePortOpt =
- "base.port=" + QString::number(parent->getUiInfo()->getBasePort());
- QString vmNameOpt = "vmname=" + parent->getUiInfo()->getVmName();
- QString vmProfileOpt = "profile=" + QString::fromLocal8Bit(get_profile_name());
+ QString vmNameOpt = "vmname=" + parent->getUiInfo()->getVmName();
+ QString profileOpt = "profile=" +
+ QString::fromLocal8Bit(get_profile_name());
+ QString basePortOpt = "base.port=" +
+ QString::number(parent->getUiInfo()->getBasePort());
- QString httpProxyAddr;
- QString httpProxyPort;
- const char *http_proxy_addr = get_http_proxy_addr();
- if (http_proxy_addr) {
- char **proxy = g_strsplit(http_proxy_addr, ":", 2);
- if (proxy[0] && proxy[1]) {
- httpProxyAddr = "-Dhttp.proxyHost=" + QString(proxy[0]);
- httpProxyPort = "-Dhttp.proxyPort=" + QString(proxy[1]);
- }
- g_strfreev(proxy);
- }
-
- if (httpProxyAddr != NULL && httpProxyPort != NULL) {
- arguments << httpProxyAddr << httpProxyPort;
- }
+ arguments << vmNameOpt << profileOpt << basePortOpt;
- arguments << vmNameOpt << basePortOpt << vmProfileOpt;
- QString loggingCommand = QString("staring ecp: \"" + command + "\"");
- for (int i = 0; i < arguments.size(); ++i) {
- loggingCommand += " \"" + arguments.at(i) + "\"";
- }
- qInfo() << qPrintable(loggingCommand);
+ launchControlPanel(command, arguments);
- try {
- QProcess::startDetached(command, arguments);
- } catch (QString &error) {
- showMsgBox(QMessageBox::Warning, MSG_INVALID_ECP_OPEN + error);
return;
}
+
+ // we can not launch ControlPanel
+ showMsgBox(QMessageBox::Warning, MSG_ECP_NOT_EXIST);
+
+ return;
}
void ContextMenu::slotRequestScreenshot()