contextmenu: added shell and ecp menu operation 56/25356/1
authorsungmin ha <sungmin82.ha@samsung.com>
Mon, 4 Aug 2014 09:51:58 +0000 (18:51 +0900)
committersungmin ha <sungmin82.ha@samsung.com>
Mon, 4 Aug 2014 09:54:04 +0000 (18:54 +0900)
deleted unused code in contextmenu.cpp

Change-Id: Ic0dc57039e688acb6d24a1d6bb795d8b133025d6
Signed-off-by: sungmin ha <sungmin82.ha@samsung.com>
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/skin/maruskin_server.c
tizen/src/skin/maruskin_server.h
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/menu/contextmenu.h

index 467123ae64c41793d70e5685a36e9a2b6f0fbcf8..fab075e4b5cfa491d6972a9d77393a4f01340ea5 100644 (file)
@@ -357,3 +357,7 @@ char* get_emul_skin_path(void)
     return _emul_info.skin_path;
 }
 
+int get_sdbd_state(void)
+{
+    return is_sdbd_initialized;
+}
index e963c2fc46be6a43cd5ca1e0b13410a66a6a54e9..1257aeefc597e0f15bb868d6ba8568927a95bafc 100644 (file)
@@ -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__ */
index e8229ee1c77a703a240db335fbd185fab33e31ac..faa4c3e6cf5227061b6a96036b10d6574a9fc9fd 100644 (file)
@@ -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;
 
index 0db67fc05d9c02bd982bf5e3f042497d13b43539..5d0a4c1bf11c2669514511fa6ed88c85604ba217 100644 (file)
@@ -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);
index 502826eb23aad948ed48fa8174287ed7e7644473..e6b63fc87f28b6e988dae80984919d2ab16430b8 100644 (file)
@@ -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()
index 5c3fe96ebe62a342124957cca18c077adbf2baf0..eb38728fc333f9dc60927367ba1d54a792f62f91 100644 (file)
@@ -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();