qt5: introduce qt5_msgbox to report message
authorJihye Won <jihye.won1@samsung.com>
Thu, 13 Aug 2015 06:07:40 +0000 (15:07 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 27 Aug 2015 12:35:29 +0000 (21:35 +0900)
Change-Id: Ia49ed159b0ceb9f4a9d529de0e2a484767c19bfa
Signed-off-by: Jihye Won <jihye.won1@samsung.com>
tizen/Makefile
tizen/src/util/Makefile.objs
tizen/src/util/error_handler.c
tizen/src/util/qt5_error_report.c [new file with mode: 0644]
tizen/src/util/qt5_error_report.h [new file with mode: 0644]
tizen/standalone-src/Makefile [new file with mode: 0644]
tizen/standalone-src/qt5_msgbox.cpp [new file with mode: 0644]
tizen/standalone-src/qt5_msgbox.rc [new file with mode: 0644]

index 2e5ac88da732462a6e565bf73a38f122022c49c8..953b8d38b1869c7e0e04216ecd5882f264b93f2c 100644 (file)
@@ -1,20 +1,20 @@
 all:
        cd src && $(MAKE) all
+       cd standalone-src && $(MAKE) all
 clean:
        cd src && $(MAKE) clean
+       cd standalone-src && $(MAKE) clean
 distclean:
        cd src && $(MAKE) distclean
+       cd standalone-src && $(MAKE) clean
 install:
        cd src && $(MAKE) install
-build_supplements:
-       cd src && $(MAKE) build_supplements
-install_supplements:
-       cd src && $(MAKE) install_supplements
+       cd standalone-src && $(MAKE) install
 
 # for dibs system...
 all_dibs:
        cd src && $(MAKE) all_dibs
+       cd standalone-src && $(MAKE) all
 install_dibs:
        cd src && $(MAKE) install_dibs
-install_supplements_dibs:
-       cd src && $(MAKE) install_supplements_dibs
+       cd standalone-src && $(MAKE) install_dibs
index ac77989bd3c12188e3cdd33ade228bfa977cd268..d36b6759b1f6652c410801838736a0f6d3f2f1dd 100644 (file)
@@ -28,6 +28,9 @@ obj-$(CONFIG_DARWIN) += check_gl_cgl.o
 # hotplug
 obj-y += device_hotplug.o
 
+# qt5 error handler
+obj-y += qt5_error_report.o
+
 # error handler
 obj-y += error_handler.o
 
index af179b8d6e573abce1c26e7a9b7623b6dfbb7d31..acf77604fe18af48c8e46e38b64f052e6898b396 100644 (file)
@@ -54,6 +54,10 @@ MULTI_DEBUG_CHANNEL(qemu, backtrace);
 #include "skin/maruskin_client.h"
 #endif
 
+#ifdef CONFIG_QT
+#include "qt5_error_report.h"
+#endif
+
 #if defined(CONFIG_WIN32)
 static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter;
 #elif defined(CONFIG_LINUX)
@@ -289,7 +293,7 @@ static void report(const char *fmt, va_list ap)
 #ifdef CONFIG_QT
         if (display_type == DT_MARU_QT_ONSCREEN ||
             display_type == DT_MARU_QT_OFFSCREEN) {
-            // TODO: new pop-up dialog is needed
+            start_qt5_msgbox(CRITICAL_ICON, message);
         }
 #endif
 #ifdef CONFIG_JAVA_UI
diff --git a/tizen/src/util/qt5_error_report.c b/tizen/src/util/qt5_error_report.c
new file mode 100644 (file)
index 0000000..e7968cc
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Qt Error Report
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye Won <jihye.won1@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 "qt5_error_report.h"
+#include <glib.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "debug_ch.h"
+#include "emul_state.h"
+
+#ifdef CONFIG_WIN32
+#include <process.h>
+#endif
+
+MULTI_DEBUG_CHANNEL(qemu, qt5_msgbox);
+
+static const char * const icon_types[] = {
+    "0", "1", "2", "3", "4"};
+
+char *get_app_path(void)
+{
+    const char *bin_dir = get_bin_path();
+    int bin_len = strlen(bin_dir);
+    const char *app_name = "qt5_msgbox";
+    int app_len = strlen(app_name);
+    int app_path_len = bin_len + app_len + 3;
+    char *tmp_path = (char *)g_malloc0(app_path_len);
+    strcpy(tmp_path, bin_dir);
+    strcat(tmp_path, app_name);
+    tmp_path[app_path_len - 1] = '\0';
+
+    INFO("qt5_msgbox path : %s\n", tmp_path);
+    return tmp_path;
+}
+
+void start_qt5_msgbox(qt5_msgbox_icon icon, const char *message)
+{
+    char *app_path = get_app_path();
+    const char *title = "Emulator";
+    const char *argv[] = {app_path, icon_types[icon], title, message, NULL};
+
+#ifdef CONFIG_WIN32
+    INFO("qt5_msgbox starts... \n");
+    if (spawnv(P_NOWAIT, app_path, argv) == -1)
+        ERR("qt5_msgbox can not be executed \n");
+#else
+    pid_t child_pid = fork();
+    if (child_pid == 0) {
+        INFO("qt5_msgbox starts... \n");
+        if(execvp(app_path, (char * const *) argv) == -1)
+            ERR("qt5_msgbox can not be executed \n");
+        exit(0);
+    } else if (child_pid == -1) {
+        ERR("qt5_msgbox can not be executed \n");
+    }
+#endif
+    g_free(app_path);
+}
diff --git a/tizen/src/util/qt5_error_report.h b/tizen/src/util/qt5_error_report.h
new file mode 100644 (file)
index 0000000..f1aecac
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Qt Error Report
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye Won <jihye.won1@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 __ERROR_REPORT_H__
+#define __ERROR_REPORT_H__
+
+typedef enum {
+    NO_ICON = 0,
+    INFORMATION_ICON = 1,
+    WARNING_ICON = 2,
+    CRITICAL_ICON = 3,
+    QUESTION_ICON = 4
+} qt5_msgbox_icon;
+
+char *get_app_path(void);
+void start_qt5_msgbox(qt5_msgbox_icon icon, const char *message);
+
+#endif /* __ERROR_REPORT_H__ */
diff --git a/tizen/standalone-src/Makefile b/tizen/standalone-src/Makefile
new file mode 100644 (file)
index 0000000..db7a534
--- /dev/null
@@ -0,0 +1,89 @@
+ifeq ($(wildcard ../../config-host.mak),../../config-host.mak)
+include ../../config-host.mak
+
+CXX = g++
+EMUL_DIR=../emulator
+DIBS_COMMON_DIR=../common
+TARGET_EXE += qt5_msgbox$(EXESUF)
+
+# for building qt5_msgbox
+QT5_MSGBOX_OBJS = qt5_msgbox
+QT5_MSGBOX_CFLAGS = $(QT_CFLAGS)
+QT5_MSGBOX_LIBS = $(shell pkg-config --libs Qt5Core Qt5Widgets Qt5Gui)
+ifndef CONFIG_DARWIN
+QT5_MSGBOX_LIBS += -L/usr/lib/x86_64-linux-gnu/
+endif
+QT5_MSGBOX_LDFLAGS = $(QT5_MSGBOX_LIBS)
+QT5_MSGBOX_TARGET = qt5_msgbox$(EXESUF)
+
+$(QT5_MSGBOX_TARGET): qt5_msgbox.cpp
+ifdef CONFIG_WIN32
+       $(shell windres qt5_msgbox.rc -O coff -o qt5_msgbox.res)
+       $(CXX) -o $(QT5_MSGBOX_OBJS) qt5_msgbox.res $< $(QT5_MSGBOX_CFLAGS) $(QT5_MSGBOX_LDFLAGS)
+else
+       $(CXX) -o $(QT5_MSGBOX_OBJS) $< $(QT5_MSGBOX_CFLAGS) $(QT5_MSGBOX_LDFLAGS)
+endif
+
+all: $(TARGET_EXE)
+
+clean:
+       rm -f $(TARGET_EXE)
+
+install: all
+# change loading path of dynamic shared libraries on MAC OS X
+ifdef CONFIG_DARWIN
+       @LIB_LIST="QtWidgets QtGui QtCore"; \
+       for target in $(TARGET_DIRS); do \
+       case "$$target" in \
+       i386-softmmu) \
+               BIN_ARR=( qt5_msgbox ); \
+               for bin in $${BIN_ARR[@]}; do \
+                       LIB_ARR=( $$(otool -L $$bin | awk '/\opt\/local\/Library/ { split($$1, lib, "/"); print lib[9]}') ); \
+                       for lib in $${LIB_ARR[@]}; do \
+                               [[ $$LIB_LIST =~ $$lib ]] && IS_LIB=true || IS_LIB=false; \
+                               if [ "$$IS_LIB" == "true" ] ; then \
+                                       install_name_tool -change /opt/local/Library/Frameworks/$$lib.framework/Versions/5/$$lib @loader_path/$$lib $$bin ; \
+                                       echo "$$bin: the loading path of $$lib is changed."; \
+                               else \
+                                       echo "$$bin: $$lib does not exist in the loading path."; \
+                               fi; \
+                       done \
+               done \
+               ;; \
+       arm-softmmu) \
+               ;; \
+       esac; \
+       done
+endif
+       cp -pP $(TARGET_EXE) $(EMUL_DIR)/bin
+
+####### for dibs system...
+install_dibs: all
+# change loading path of dynamic shared libraries on MAC OS X
+ifdef CONFIG_DARWIN
+       @LIB_LIST="QtWidgets QtGui QtCore"; \
+       for target in $(TARGET_DIRS); do \
+       case "$$target" in \
+       i386-softmmu) \
+               BIN_ARR=( qt5_msgbox ); \
+               for bin in $${BIN_ARR[@]}; do \
+                       LIB_ARR=( $$(otool -L $$bin | awk '/\opt\/local\/Library/ { split($$1, lib, "/"); print lib[9]}') ); \
+                       for lib in $${LIB_ARR[@]}; do \
+                               [[ $$LIB_LIST =~ $$lib ]] && IS_LIB=true || IS_LIB=false; \
+                               if [ "$$IS_LIB" == "true" ] ; then \
+                                       install_name_tool -change /opt/local/Library/Frameworks/$$lib.framework/Versions/5/$$lib @loader_path/$$lib $$bin ; \
+                                       echo "$$bin: the loading path of $$lib is changed."; \
+                               else \
+                                       echo "$$bin: $$lib does not exist in the loading path."; \
+                               fi; \
+                       done \
+               done \
+               ;; \
+       arm-softmmu) \
+               ;; \
+       esac; \
+       done
+endif
+       cp -pP qt5_msgbox $(DIBS_COMMON_DIR)/bin
+
+endif
diff --git a/tizen/standalone-src/qt5_msgbox.cpp b/tizen/standalone-src/qt5_msgbox.cpp
new file mode 100644 (file)
index 0000000..6c914b1
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Qt MessageBox
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye Won <jihye.won1@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 <QtWidgets>
+#include <QMessageBox>
+#include <QMessageBox>
+#include <stdlib.h>
+#include "../../config-host.h"
+
+#define MAX_MESSAGE_LEN 2048
+
+QMessageBox::Icon getIconType(int icon)
+{
+    QMessageBox::Icon ret;
+    switch(icon){
+    case 0:
+        ret = QMessageBox::NoIcon;
+        break;
+    case 1:
+        ret = QMessageBox::Information;
+        break;
+    case 2:
+        ret = QMessageBox::Warning;
+        break;
+    case 3:
+        ret = QMessageBox::Critical;
+        break;
+    case 4:
+        ret = QMessageBox::Question;
+        break;
+    default:
+        ret = QMessageBox::NoIcon;
+        break;
+    }
+    return ret;
+}
+
+static void createMsgBox(int argc, char *argv[])
+{
+#ifdef CONFIG_WIN32
+    char *tmp_msg = (char *)malloc(MAX_MESSAGE_LEN);
+    int index = 3;
+    strcpy(tmp_msg, argv[index]);
+
+    while(argv[++index] != NULL) {
+        strcat(tmp_msg, " ");
+        strcat(tmp_msg, argv[index]);
+    }
+    strcpy(argv[3], tmp_msg);
+    free(tmp_msg);
+#endif
+
+    QMessageBox *msgBox = new QMessageBox(
+        getIconType(atoi(argv[1])), // icon
+        argv[2],  // title
+        argv[3],  // message
+        QMessageBox::Ok);
+    msgBox->setDefaultButton(QMessageBox::Ok);
+    msgBox->setWindowModality(Qt::ApplicationModal);
+    msgBox->show();
+}
+
+int main(int argc, char *argv[])
+{
+    //check arguments
+    if(argc < 4)
+    {
+        qCritical("qt5_dialog needs correct arguments");
+        return 1;
+    }
+    else if(argv[2] == NULL || argv[3] == NULL)
+    {
+        qCritical("qt5_dialog title or message is null");
+        return 1;
+    }
+    else
+    {
+        QApplication msgApp(argc, argv);
+        createMsgBox(argc, argv);
+        return msgApp.exec();
+    }
+}
diff --git a/tizen/standalone-src/qt5_msgbox.rc b/tizen/standalone-src/qt5_msgbox.rc
new file mode 100644 (file)
index 0000000..45f4761
--- /dev/null
@@ -0,0 +1,7 @@
+#include "../../config-host.h"
+
+#ifdef CONFIG_MARU
+ID_ICON ICON "../src/ui/resource/icons/emulator_icon.ico"
+#else
+ID_ICON ICON "../../pc-bios/qemu-nsis.ico"
+#endif