obj-$(CONFIG_QT) += advancedmenuitem.o
obj-$(CONFIG_QT) += scalemenuitem.o
obj-$(CONFIG_QT) += screenshotview.o
+obj-$(CONFIG_QT) += shellopener.o
$(obj)/moc_aboutdialog.o: $(obj)/moc_aboutdialog.cpp
$(obj)/moc_aboutdialog.cpp: $(obj)/aboutdialog.h
this->infoDialog = NULL;
this->aboutDialog = NULL;
this->screenshotDialog = NULL;
- this->vmName = this->parent->uiInfo->vmName + " : "
- + QString::number(get_device_serial_number());
advancedMenu = NULL;
switchMenu = NULL;
actionForceClose = NULL;
actionClose = NULL;
+ vmName = this->parent->uiInfo->vmName + " : "
+ + QString::number(get_device_serial_number());
+
+ /* for SDB shell */
+ shellOpener = new ShellOpener();
+
+ /* for close */
longPressTimer = new QTimer(this);
createItems(this, this->parent->uiInfo->menuList);
return;
}
- QString sdbPort = QString::number(get_device_serial_number());
- QString sdbSerialName;
- if (is_netclient_tap_attached()) {
- sdbSerialName = QString(get_emul_guest_ip());
- } else {
- sdbSerialName = "emulator-" + sdbPort;
- }
-
- QString sdbPath = QCoreApplication::applicationDirPath();
-#ifdef CONFIG_WIN32
- sdbPath += "\\..\\..\\..\\..\\..\\tools\\ansicon.exe";
-#else
- sdbPath += "/../../../../../tools/sdb";
-#endif
+ const QString sdbPath = shellOpener->getSdbPath();
QFileInfo sdbFileInfo(sdbPath);
if (sdbFileInfo.exists() == false) {
return;
}
- QString command;
- QStringList arguments;
-
-#ifdef CONFIG_WIN32
- command = "cmd.exe";
- arguments << "/c" << "start" << sdbPath << "sdb" << "-s" << sdbSerialName << "shell";
-#elif defined CONFIG_DARWIN
- command = QCoreApplication::applicationDirPath() + "/sdbscript";
- arguments << sdbPath << sdbSerialName;
-#else
- command = "/usr/bin/gnome-terminal";
- QString title = "--title=" + vmName;
- arguments << title << "-x" << sdbPath << "-s" << sdbSerialName << "shell";
-#endif
-
- qDebug() << command << arguments;
-
- try {
- QProcess::startDetached(command, arguments);
- } catch (QString &error) {
- showMsgBox(QMessageBox::Warning,
- "Failed to open Shell : " + error);
- return;
- }
+ /* start command in a new process */
+ shellOpener->openShell(vmName);
}
#ifdef CONFIG_WIN32
{
qDebug("destroy menu");
+ delete shellOpener;
+
longPressTimer->stop();
}
#include "aboutdialog.h"
#include "screenshotdialog.h"
#include "menu/menuitem.h"
+#include "menu/shellopener.h"
#include "input/keyboardshortcut.h"
class MainWindow;
QAction *addGeneralAction(QMenu *menu,
const QIcon &icon, const QString &text, const char *slot);
QMessageBox *showMsgBox(QMessageBox::Icon iconType, const QString &text,
- QMessageBox::StandardButtons buttons = QMessageBox::NoButton,
- QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+ QMessageBox::StandardButtons buttons = QMessageBox::NoButton,
+ QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
MainWindow *parent;
QString vmName;
DetailedInfoDialog *infoDialog;
AboutDialog *aboutDialog;
- QTimer *longPressTimer;
QMenu *advancedMenu;
QMenu *switchMenu;
QSignalMapper *switchMapper;
QSignalMapper *scaleMapper;
QSignalMapper *controllerMapper;
+
+ ShellOpener *shellOpener;
+ QTimer *longPressTimer;
};
#endif // CONTEXTMENU_H
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "config-host.h"
+#include "shellopener.h"
+
+extern "C" {
+#include "emul_state.h"
+}
+
+ShellOpener::ShellOpener()
+{
+ sdbPath = QCoreApplication::applicationDirPath();
+#ifdef CONFIG_WIN32
+ sdbPath += "\\..\\..\\..\\..\\..\\tools\\ansicon.exe";
+#else
+ sdbPath += "/../../../../../tools/sdb";
+#endif
+}
+
+QString ShellOpener::getSdbPath()
+{
+ return sdbPath;
+}
+
+void ShellOpener::openShell(QString title)
+{
+ qDebug() << "open the shell";
+
+ QString command;
+ QStringList arguments;
+
+ QString sdbPort = QString::number(get_device_serial_number());
+ QString sdbSerialName;
+ if (is_netclient_tap_attached()) {
+ sdbSerialName = QString(get_emul_guest_ip());
+ } else {
+ sdbSerialName = "emulator-" + sdbPort;
+ }
+
+#ifdef CONFIG_WIN32
+ command = "cmd.exe";
+ arguments << "/c" << "start" << sdbPath << "sdb" << "-s" << sdbSerialName << "shell";
+#elif defined CONFIG_DARWIN
+ command = QCoreApplication::applicationDirPath() + "/sdbscript";
+ arguments << sdbPath << sdbSerialName;
+#else
+ command = "/usr/bin/gnome-terminal";
+ const QString titleOption = "--title=" + title;
+ arguments << titleOption << "-x" << sdbPath << "-s" << sdbSerialName << "shell";
+#endif
+
+ qDebug() << command << arguments;
+
+ QProcess::startDetached(command, arguments);
+}
+
+ShellOpener::~ShellOpener()
+{
+ qDebug("destroy shell opener");
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef SHELLOPENER_H
+#define SHELLOPENER_H
+
+#include <QtWidgets>
+
+
+class ShellOpener
+{
+public:
+ ShellOpener();
+ ~ShellOpener();
+
+ QString getSdbPath();
+ void openShell(QString title);
+
+private:
+ QString sdbPath;
+};
+
+#endif // SHELLOPENER_H