From: sungmin ha Date: Mon, 4 Aug 2014 09:51:58 +0000 (+0900) Subject: contextmenu: added shell and ecp menu operation X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5affb82a079b962541d4c4ea82adc173ce4aa15f;p=sdk%2Femulator%2Fqemu.git contextmenu: added shell and ecp menu operation deleted unused code in contextmenu.cpp Change-Id: Ic0dc57039e688acb6d24a1d6bb795d8b133025d6 Signed-off-by: sungmin ha --- diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 467123ae64..fab075e4b5 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -357,3 +357,7 @@ char* get_emul_skin_path(void) return _emul_info.skin_path; } +int get_sdbd_state(void) +{ + return is_sdbd_initialized; +} diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index e963c2fc46..1257aeefc5 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -161,4 +161,6 @@ MultiTouchState *get_emul_multi_touch_state(void); void set_multi_touch_enable(int enable); int get_multi_touch_enable(void); +/* sdb */ +int get_sdbd_state(void); #endif /* __EMUL_STATE_H__ */ diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index e8229ee1c7..faa4c3e6cf 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -132,7 +132,6 @@ static uint16_t svr_port = 0; static int server_sock = 0; static int client_sock = 0; static int stop_server = 0; -static int is_sdbd_initialized = 0; static int ready_server = 0; static int ignore_heartbeat = 0; static int is_force_close_client = 0; @@ -141,6 +140,8 @@ static int is_started_heartbeat = 0; static int stop_heartbeat = 0; static int recv_heartbeat_count = 0; +int is_sdbd_initialized = 0; + /* 0: not drawing, 1: drawing */ int draw_display_state = 0; diff --git a/tizen/src/skin/maruskin_server.h b/tizen/src/skin/maruskin_server.h index 0db67fc05d..5d0a4c1bf1 100644 --- a/tizen/src/skin/maruskin_server.h +++ b/tizen/src/skin/maruskin_server.h @@ -30,6 +30,8 @@ #ifndef MARUSKIN_SERVER_H_ #define MARUSKIN_SERVER_H_ +extern int is_sdbd_initialized; + int start_skin_server(int argc, char** argv, int qemu_argc, char** qemu_argv); void notify_draw_frame(void); diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 502826eb23..e6b63fc87f 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -124,6 +124,7 @@ ContextMenu::ContextMenu(QWidget *parent) : /* Control Panel menu */ action = addAction("Control Panel"); action->setIcon(QIcon(QPixmap(":/icons/control_panel.png"))); + connect(action, SIGNAL(triggered()), this, SLOT(slotControlPanel())); addSeparator(); @@ -174,15 +175,115 @@ void ContextMenu::slotShell() { qDebug("SDB shell"); - // TODO: path - QString command = "/usr/bin/gnome-terminal"; + if (is_sdbd_initialized == 0) { + QString msg = "SDB is not ready.\nPlease wait until the emulator is completely boot up."; + QMessageBox msgBox; + msgBox.setWindowTitle("Info"); + msgBox.setText(msg); + msgBox.exec(); + qDebug() << msg; + return; + } + + qint32 basePort = get_emul_vm_base_port(); + QString sdbPort = QString::number(basePort + 1); + QString sdbSerial = "emulator-" + sdbPort; + + QString vmName = get_emul_vm_name(); + QString sdbPath; +#ifdef __WIN32 + sdbPath = "..\\..\\ansicon.exe"; +#else + sdbPath = "../../sdb"; +#endif + + QFileInfo fileInfo(sdbPath); + if (!fileInfo.exists()) { + QString msg = "SDB file does not exist : " + fileInfo.absoluteFilePath(); + QMessageBox msgBox; + msgBox.setWindowTitle("Error"); + msgBox.setText(msg); + msgBox.exec(); + qWarning() << msg; + return; + } + + QString command; QStringList arguments; - QString sdbPath = "~/tizen-sdk/tools/sdb"; - arguments << "-x" << sdbPath << "shell"; +#ifdef CONFIG_WIN32 + command = "cmd.exe"; + arguments << "/c start" << sdbPath << "-s" << sdbSerial << "shell"; +#elif defined CONFIG_DARWIN + QString binPath = get_bin_path(); + command = binPath + "/sdbscript"; + arguments << sdbSerial; +#else + QString title = "--title=" + vmName; + command = "/usr/bin/gnome-terminal"; + arguments << title << "-x" << sdbPath << "-s" << sdbSerial << "shell"; +#endif + + try { + QProcess *terminal = new QProcess(this); + terminal->start(command, arguments); + } catch (QString error) { + QString msg = "Fail to open Shell : " + error; + QMessageBox msgBox; + msgBox.setWindowTitle("Fail"); + msgBox.setText(msg); + msgBox.exec(); + qDebug() << msg; + return; + } +} + +void ContextMenu::slotControlPanel() +{ + qDebug("Control Panel"); + + QString basePortOpt = "base.port=" + QString::number(get_emul_vm_base_port()); + QString vmNameOpt = "vmname=" + QString(get_emul_vm_name()); + QString ecpPath; +#ifdef __WIN32 + ecpPath = ".\\emulator-control-panel.jar"; +#else + ecpPath = "./emulator-control-panel.jar"; +#endif + + QFileInfo fileInfo(ecpPath); + if (!fileInfo.exists()) { + QString msg = "Control Panel file does not exist in the following path.\n" + fileInfo.absoluteFilePath(); + QMessageBox msgBox; + msgBox.setWindowTitle("Error"); + msgBox.setText(msg); + msgBox.exec(); + qWarning() << msg; + return; + } + + QString command; +#ifdef CONFIG_WIN32 + command = "java.exe"; +#else + command = "java"; +#endif - QProcess *terminal = new QProcess(this); - terminal->start(command, arguments); + QStringList arguments; + arguments << "-jar" << ecpPath << vmNameOpt << basePortOpt; + + try { + QProcess *terminal = new QProcess(this); + terminal->start(command, arguments); + } catch (QString error) { + QString msg = "Fail to open control panel : " + error; + QMessageBox msgBox; + msgBox.setWindowTitle("Fail"); + msgBox.setText(msg); + msgBox.exec(); + qDebug() << msg; + return; + } } void ContextMenu::slotAbout() @@ -209,26 +310,9 @@ void ContextMenu::slotForceClose() qDebug() << "exit!"; /* force close */ shutdown_qemu_gracefully(); -// MainWindow *win = (MainWindow *)this->parent(); -// win->~MainWindow(); - } else { - qDebug() << "cancel"; - } - -/* - QMessageBox::StandardButton reply; - reply = QMessageBox::question((QWidget *)this->parent(), "Emulator", - "If you force stop an emulator, it may cause some problems.\n" - "Are you sure you want to continue?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - - if (reply == QMessageBox::Yes) { - qDebug() << "exit!"; - - QApplication::exit(-1); } else { qDebug() << "cancel"; } -*/ } void ContextMenu::slotPwkeyRelease() diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 5c3fe96ebe..eb38728fc3 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -6,6 +6,7 @@ extern "C" { #include "skin/maruskin_operation.h" +#include "skin/maruskin_server.h" #include "emul_state.h" } @@ -27,6 +28,7 @@ public slots: void slotRotate(int angle); void slotScale(int scale); void slotShell(); + void slotControlPanel(); void slotAbout(); void slotForceClose(); void slotClose();