From f4fb66bf4e1e567fd86dc2d595b9f412b44e19ac Mon Sep 17 00:00:00 2001 From: Munkyu Im Date: Tue, 12 Apr 2016 18:00:09 +0900 Subject: [PATCH] dnd: implement file push/install - install: support one wgt/tpk/rpm file. - push: support multiple files/directories. - rename "shellopener" to "sdbhelper" and add more sdb specific job. - Limitation: We use sdb client to push/install, but it has some issues related with exit code and error message. it will be fixed soon by sdb developers. Change-Id: I5e6f06b36f8a354e79a9c42386042c3ca7b3c89a Signed-off-by: Munkyu Im --- tizen/src/ui/displaybase.cpp | 77 ++++- tizen/src/ui/displaybase.h | 4 + tizen/src/ui/menu/Makefile.objs | 8 +- tizen/src/ui/menu/contextmenu.cpp | 8 +- tizen/src/ui/menu/contextmenu.h | 4 +- tizen/src/ui/menu/sdbhelper.cpp | 266 ++++++++++++++++++ .../ui/menu/{shellopener.h => sdbhelper.h} | 40 ++- tizen/src/ui/menu/sdbhelperthread.cpp | 108 +++++++ tizen/src/ui/menu/sdbhelperthread.h | 63 +++++ tizen/src/ui/menu/shellopener.cpp | 88 ------ tizen/src/ui/resource/ui_strings.h | 15 + 11 files changed, 577 insertions(+), 104 deletions(-) create mode 100644 tizen/src/ui/menu/sdbhelper.cpp rename tizen/src/ui/menu/{shellopener.h => sdbhelper.h} (54%) create mode 100644 tizen/src/ui/menu/sdbhelperthread.cpp create mode 100644 tizen/src/ui/menu/sdbhelperthread.h delete mode 100644 tizen/src/ui/menu/shellopener.cpp diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 04fcadf900..ebac382a71 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -32,6 +32,7 @@ #include "displaybase.h" #include "mainwindow.h" #include "resource/ui_strings.h" +#include "menu/sdbhelper.h" extern "C" { #include "util/ui_operations.h" @@ -63,6 +64,8 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale this->movingMode = false; this->grabPos = SKINVIEW_NULLITY_POSITION; this->grabWinPos = win->pos(); + this->dropping = false; + this->sdbHelper = new SdbHelper((MainWindow *)widget->parentWidget(), this); this->isTsEnabled = is_touchscreen_enabled(); if (isTsEnabled == true) { @@ -220,6 +223,9 @@ void DisplayBase::handleResize(QResizeEvent *event) maskImage.width() * scaleFactor, maskImage.height() * scaleFactor).mask()); } + + /* update widget position */ + sdbHelper->updateGeometry(rect); } QPoint DisplayBase::getGuestPos(QPoint hostPos) @@ -441,17 +447,79 @@ void DisplayBase::turnOffMovingMode() void DisplayBase::handleDragEnterEvent(QDragEnterEvent *event) { - if (event->mimeData()->hasUrls()) { + if (!event->mimeData()->hasUrls()) { + qDebug() << "ignore action"; + event->setDropAction(Qt::IgnoreAction); + } + /* check if sdb is ready */ + if (!sdbHelper->isSdbReady()) { + event->setDropAction(Qt::IgnoreAction); + return; + } + + foreach (const QUrl &url, event->mimeData()->urls()) { + QString fileName = url.toLocalFile(); + if (fileName.isEmpty()) { + qDebug() << "empty file"; + event->setDropAction(Qt::IgnoreAction); + return; + } + } + + if (dropping == false && sdbHelper->isProgressing() == false) { event->acceptProposedAction(); + event->setDropAction(Qt::CopyAction); + } else { + event->setDropAction(Qt::IgnoreAction); } } void DisplayBase::handleDropEvent(QDropEvent *event) { - foreach (const QUrl &url, event->mimeData()->urls()) { + dropping = true; + QList urls = event->mimeData()->urls(); + QList fileNameList; + int result; + foreach (const QUrl &url, urls) { QString fileName = url.toLocalFile(); - qDebug() << "Dropped file:" << fileName; + if (!fileName.isEmpty()) { + fileNameList << fileName; + } + } + + if (fileNameList.isEmpty()) { + qDebug("There is nothing to drop."); + return; } + qDebug() << "fileNameList: " << fileNameList; + + //TODO: support user selected path + QString path = SDB_PUSH_DEFAULT_PATH; + /* Installation is supported if dropping item is only one packaging file.*/ + if (fileNameList.size() == 1) { + QString installFileName = fileNameList.at(0); + QFileInfo fi(installFileName); + QString extension = fi.suffix(); + if (QString::compare(extension, FILE_EXTENSION_WGT, Qt::CaseInsensitive) == 0 || + QString::compare(extension, FILE_EXTENSION_TPK, Qt::CaseInsensitive) == 0 || + QString::compare(extension, FILE_EXTENSION_RPM, Qt::CaseInsensitive) == 0) { + result = QMessageBox::question(win, EMULATOR_TITLE, + MSG_INSTALL_POPUP + installFileName, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default); + if (result == QMessageBox::Yes) { + sdbHelper->install(fi); + } + dropping = false; + return; + } + } + + /* multiple files */ + result = QMessageBox::question(win, EMULATOR_TITLE, + MSG_PUSH_POPUP + path, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default); + if (result == QMessageBox::Yes) { + sdbHelper->push(fileNameList, path); + } + dropping = false; } bool DisplayBase::isMovingMode() @@ -491,4 +559,7 @@ DisplayBase::~DisplayBase() if (mouseHelper != NULL) { delete mouseHelper; } + if (sdbHelper != NULL) { + delete sdbHelper; + } } diff --git a/tizen/src/ui/displaybase.h b/tizen/src/ui/displaybase.h index 3279f663ab..21ce9956c8 100644 --- a/tizen/src/ui/displaybase.h +++ b/tizen/src/ui/displaybase.h @@ -42,14 +42,17 @@ #include "input/mousehelper.h" class MainWindow; +class SdbHelper; class DisplayBase { public: + SdbHelper *sdbHelper; void switchForm(DisplayType *displayForm); void scaleForm(qreal scaleFactor); void update(); void updateGeometry(); + QWidget *getWidget(); const QRect &getGeometry(); QRegion getMask(); @@ -107,6 +110,7 @@ private: TouchScreenHelper *tsHelper; MouseHelper *mouseHelper; + bool dropping; QLabel *offGuide; QPixmap offGuideImg; bool offGuideShown; diff --git a/tizen/src/ui/menu/Makefile.objs b/tizen/src/ui/menu/Makefile.objs index f01325a877..22975104f1 100644 --- a/tizen/src/ui/menu/Makefile.objs +++ b/tizen/src/ui/menu/Makefile.objs @@ -5,7 +5,9 @@ obj-$(CONFIG_QT) += menuitem.o obj-$(CONFIG_QT) += advancedmenuitem.o obj-$(CONFIG_QT) += scalemenuitem.o obj-$(CONFIG_QT) += screenshotview.o -obj-$(CONFIG_QT) += shellopener.o +obj-$(CONFIG_QT) += sdbhelper.o moc_sdbhelper.o +obj-$(CONFIG_QT) += sdbhelperthread.o moc_sdbhelperthread.o + $(obj)/moc_detailedinfodialog.cpp: $(obj)/detailedinfodialog.h moc $< -o $@ @@ -13,6 +15,10 @@ $(obj)/moc_contextmenu.cpp: $(obj)/contextmenu.h moc $< -o $@ $(obj)/moc_screenshotdialog.cpp: $(obj)/screenshotdialog.h moc $< -o $@ +$(obj)/moc_sdbhelper.cpp: $(obj)/sdbhelper.h + moc $< -o $@ +$(obj)/moc_sdbhelperthread.cpp: $(obj)/sdbhelperthread.h + moc $< -o $@ # product extension ifdef CONFIG_EXTENSION_PATH diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 4e4514ca82..ce681217f6 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -80,7 +80,7 @@ ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent) + QString::number(get_vm_device_serial_number()); /* for SDB shell */ - shellOpener = new ShellOpener(); + sdbHelper = new SdbHelper(this->parent, this->parent->getDisplay()); /* for close */ longPressTimer = new QTimer(this); @@ -917,7 +917,7 @@ void ContextMenu::slotShell() { qDebug("SDB shell"); - const QString sdbPath = shellOpener->getSdbPath(); + const QString sdbPath = sdbHelper->getSdbPath(); QFileInfo sdbFileInfo(sdbPath); if (sdbFileInfo.exists() == false) { @@ -931,7 +931,7 @@ void ContextMenu::slotShell() } /* start command in a new process */ - shellOpener->openShell(vmName); + sdbHelper->openShell(vmName); } void ContextMenu::slotControlPanel() @@ -1145,7 +1145,7 @@ ContextMenu::~ContextMenu() infoDialog = NULL; } - delete shellOpener; + delete sdbHelper; longPressTimer->stop(); diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index bae1553eb7..7dad213ff9 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -39,7 +39,7 @@ #include "aboutdialog.h" #include "screenshotdialog.h" #include "menu/menuitem.h" -#include "menu/shellopener.h" +#include "menu/sdbhelper.h" #include "input/keyboardshortcut.h" class MainWindow; @@ -161,7 +161,7 @@ private: QSignalMapper *scaleMapper; QSignalMapper *controllerMapper; - ShellOpener *shellOpener; + SdbHelper *sdbHelper; QTimer *longPressTimer; QTimer *rebootTimer; }; diff --git a/tizen/src/ui/menu/sdbhelper.cpp b/tizen/src/ui/menu/sdbhelper.cpp new file mode 100644 index 0000000000..3d5eb9ae60 --- /dev/null +++ b/tizen/src/ui/menu/sdbhelper.cpp @@ -0,0 +1,266 @@ +/* + * Qt UI + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Munkyu Im + * GiWoong Kim + * Sangho Park + * + * 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 "mainwindow.h" +#include "sdbhelper.h" +#include "sdbhelperthread.h" +#include "resource/ui_strings.h" + +extern "C" { +#include "emul_state.h" +#include "util/net_helper.h" +} + +SdbHelper::SdbHelper(MainWindow *parent, DisplayBase *displaybase) +{ + QString tmpSdbPath = QCoreApplication::applicationDirPath(); +#ifdef CONFIG_WIN32 + QString tmpAnsiconPath = QCoreApplication::applicationDirPath(); + tmpAnsiconPath += "\\..\\..\\..\\..\\..\\tools\\ansicon.exe"; + ansiconPath = QDir::toNativeSeparators(tmpAnsiconPath); + + sdbPath = QDir::toNativeSeparators(tmpSdbPath); + tmpSdbPath += "\\..\\..\\..\\..\\..\\tools\\sdb.exe"; +#else + tmpSdbPath += "/../../../../../tools/sdb"; +#endif + sdbPath = QDir::toNativeSeparators(tmpSdbPath); + this->mainWindow = parent; + this->displaybase = displaybase; + this->progressing = false; + + connect(this, SIGNAL(geometryChanged(QRect)), this, SLOT(handleGeometryChanged(QRect))); +} + +bool SdbHelper::isSdbReady() +{ + QFileInfo sdbFileInfo(sdbPath); + if (sdbFileInfo.exists() == false) { + qDebug(MSG_SDB_NOT_EXIST); + return false; + } + + if (!is_sdb_daemon_initialized()) { + qDebug(MSG_SDB_NOT_READY); + return false; + } + return true; +} + +QString SdbHelper::getSdbPath() +{ + return sdbPath; +} + +MainWindow *SdbHelper::getMainWindow() +{ + return mainWindow; +} + +DisplayBase *SdbHelper::getDisplayBase() +{ + return displaybase; +} + +void SdbHelper::updateGeometry(QRect rect) +{ + emit geometryChanged(rect); +} + +void SdbHelper::push(QList srcList, const QString &dest) +{ + QString program; + QStringList arguments; + QList argList; + + QString sdbSerialName = getSerialName(); + program = sdbPath; + foreach ( const QString &src, srcList) { + arguments << "-s" << sdbSerialName << "push" << src << dest + g_path_get_basename(src.toLocal8Bit().data()); + argList << arguments; + } + + SdbHelperThread *thread = new SdbHelperThread(this); + thread->setArguments(SDB_PUSH_COMMNAD , program, argList); + connect(thread, SIGNAL(started()), this, SLOT(handleThreadStarted())); + connect(thread, SIGNAL(finished()), this, SLOT(handleThreadFinished())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + thread->start(); +} + +void SdbHelper::install(QFileInfo fi) +{ + if (QString::compare(fi.suffix(), FILE_EXTENSION_RPM, Qt::CaseInsensitive) == 0) { + installRpm(fi); + return; + } + QString program; + QStringList arguments; + QList argList; + + QString sdbSerialName = getSerialName(); + program = sdbPath; + arguments << "-s" << sdbSerialName << "install" << fi.absoluteFilePath(); + argList << arguments; + qDebug() << program << arguments; + + SdbHelperThread *thread = new SdbHelperThread(this); + thread->setArguments(SDB_INSTALL_COMMAND, program, argList); + connect(thread, SIGNAL(started()), this, SLOT(handleThreadStarted())); + connect(thread, SIGNAL(finished()), this, SLOT(handleThreadFinished())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + thread->start(); +} + +void SdbHelper::installRpm(QFileInfo fi) +{ + QString program; + QStringList argRootOn; + QStringList argPush; + QStringList argInstall; + QStringList argRemove; + QStringList argRootOff; + QList argList; + QString baseName = fi.fileName(); + QString destFileName = QString(GUEST_TMP_PATH + baseName); + QString sdbSerialName = getSerialName(); + program = sdbPath; + /* to install rpm package, need sudo permission. */ + argRootOn << "root" << "on"; + argList << argRootOn; + + argPush << "-s" << sdbSerialName << "push" << fi.absoluteFilePath() << GUEST_TMP_PATH; + argList << argPush; + + argInstall << "-s" << sdbSerialName << "shell" << "rpm" << "-Uvh" << destFileName << "--force" << "--nodeps"; + argList << argInstall; + + argRemove << "-s" << sdbSerialName << "shell" << "rm" << "-f" << destFileName; + argList << argRemove; + + argRootOff << "root" << "off"; + argList << argRootOff; + + qDebug() << program << argList; + + SdbHelperThread *thread = new SdbHelperThread(this); + thread->setArguments(SDB_INSTALL_COMMAND, program, argList); + connect(thread, SIGNAL(started()), this, SLOT(handleThreadStarted())); + connect(thread, SIGNAL(finished()), this, SLOT(handleThreadFinished())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + thread->start(); +} + +void SdbHelper::handleThreadStarted() +{ + progressBar = new QProgressBar((QWidget *)mainWindow); + progressBar->setAlignment(Qt::AlignCenter); + progressBar->setMinimum(0); + progressBar->setMaximum(0); + progressBar->setValue(0); + progressBar->setTextVisible(false); + progressBar->setAttribute(Qt::WA_DeleteOnClose); + progressBar->setWindowModality(Qt::NonModal); + QRect rect = getDisplayBase()->getGeometry(); + int x = rect.x() + (rect.width() - progressBar->width()) / 2; + int y = rect.y() + (rect.height() - progressBar->height()) / 2; + progressBar->move(x,y); + progressBar->resize(PROGRESSBAR_DEFAULT_WITDH, PROGRESSBAR_DEFAULT_HEIGHT); + setProgressing(true); + progressBar->show(); +} + +void SdbHelper::handleThreadFinished() +{ + progressBar->close(); + setProgressing(false); +} + +void SdbHelper::handleGeometryChanged(QRect newRect) +{ + //XXX: need to support rotation? + qDebug() << "handleGeometryChanged: " << newRect; + if (isProgressing()) { + QRect rect = getDisplayBase()->getGeometry(); + int x = rect.x() + (rect.width() - progressBar->width()) / 2; + int y = rect.y() + (rect.height() - progressBar->height()) / 2; + qDebug() << " x: " << x << " ,y: " << y; + progressBar->move(x,y); + progressBar->update(); + } +} + +void SdbHelper::setProgressing(bool isProgressing) +{ + this->progressing = isProgressing; +} + +bool SdbHelper::isProgressing() +{ + return this->progressing; +} + +QString SdbHelper::getSerialName() +{ + QString sdbPort = QString::number(get_vm_device_serial_number()); + QString sdbSerialName; + if (is_netclient_tap_attached()) { + sdbSerialName = QString(get_guest_ip()); + } else { + sdbSerialName = "emulator-" + sdbPort; + } + return sdbSerialName; +} + +void SdbHelper::openShell(QString title) +{ + qDebug() << "open the shell"; + + QString command; + QStringList arguments; + + QString sdbSerialName = getSerialName(); +#ifdef CONFIG_WIN32 + command = ansiconPath; + arguments << "sdb" << "-s" << sdbSerialName << "shell"; +#elif defined CONFIG_DARWIN + command = QDir::toNativeSeparators(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); +} diff --git a/tizen/src/ui/menu/shellopener.h b/tizen/src/ui/menu/sdbhelper.h similarity index 54% rename from tizen/src/ui/menu/shellopener.h rename to tizen/src/ui/menu/sdbhelper.h index da55e580af..cf167a9306 100644 --- a/tizen/src/ui/menu/shellopener.h +++ b/tizen/src/ui/menu/sdbhelper.h @@ -27,23 +27,51 @@ * */ -#ifndef SHELLOPENER_H -#define SHELLOPENER_H +#ifndef SDBHELPER_H +#define SDBHELPER_H #include +class MainWindow; +class DisplayBase; -class ShellOpener +class SdbHelper : public QObject { + Q_OBJECT public: - ShellOpener(); - ~ShellOpener(); + explicit SdbHelper(MainWindow *parent, DisplayBase *displaybase); QString getSdbPath(); + QString getSerialName(); + void install(QFileInfo fi); + void push(QList src, const QString &dest); void openShell(QString title); + bool isProgressing(); + DisplayBase *getDisplayBase(); + MainWindow *getMainWindow(); + void updateGeometry(QRect rect); + bool isSdbReady(); + +signals: + void geometryChanged(QRect rect); private: QString sdbPath; +#ifdef CONFIG_WIN32 + QString ansiconPath; +#endif + bool progressing; + MainWindow *mainWindow; + QProgressBar *progressBar; + QProcess *process; + DisplayBase *displaybase; + void setProgressing(bool isProgressing); + void installRpm(QFileInfo fi); + +public slots: + void handleThreadStarted(); + void handleThreadFinished(); + void handleGeometryChanged(QRect rect); }; -#endif // SHELLOPENER_H +#endif // SDBHELPER_H diff --git a/tizen/src/ui/menu/sdbhelperthread.cpp b/tizen/src/ui/menu/sdbhelperthread.cpp new file mode 100644 index 0000000000..86b70284e8 --- /dev/null +++ b/tizen/src/ui/menu/sdbhelperthread.cpp @@ -0,0 +1,108 @@ +/* + * Qt UI + * + * Copyright (C) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Munkyu Im + * seokYeon Hwang + * + * 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 "sdbhelperthread.h" +#include "sdbhelper.h" +#include "displaybase.h" +#include "resource/ui_strings.h" + +extern "C" { +#include "emul_state.h" +} + +SdbHelperThread::SdbHelperThread(SdbHelper *parent) +{ + this->parent = parent; + connect(this, SIGNAL(errorOccured(QString, int)), this, SLOT(handleErrorOccured(QString, int))); +} + +void SdbHelperThread::setArguments(int command, QString &program, QList &args) +{ + this->command = command; + this->program = program; + this->arguments = args; +} + +void SdbHelperThread::run() +{ + if (program.isEmpty() || arguments.isEmpty()) + return; + + for (int i = 0; i < arguments.size(); ++i) { + qDebug() << "program: " << program << arguments.at(i); + process = new QProcess(); + process->deleteLater(); + process->start(program, arguments.at(i)); + process->waitForFinished(); + outMsg = QString::fromLocal8Bit(process->readAllStandardOutput()); + //FIXME: (sdb) geneal pushing log may redirect to stderr + errorMsg = QString::fromLocal8Bit(process->readAllStandardError()); + qDebug() << "errorMsg" << errorMsg; + qDebug() << "outMsg" << outMsg; + //FIXME: (sdb) general sdb installation failure message is printed with stdout */ + if (command == SDB_INSTALL_COMMAND && outMsg.contains(SDB_INSTALL_FAILURE)) { + emit errorOccured(outMsg, process->exitCode()); + return; + } + if (process->exitCode() || process->exitStatus()) { + emit errorOccured(errorMsg, process->exitCode()); + return; + } + process->close(); + } +} + +void SdbHelperThread::handleErrorOccured(QString errString, int exitCode) +{ + qDebug() << "exitcode: " << exitCode; + //FIXME: (sdb) cannot returns exit code like "no space left" + showMsgBox(QMessageBox::Warning, MSG_SDB_FAILED_PROCESSING + errString); + if (process) { + process->close(); + } +} + +QMessageBox *SdbHelperThread::showMsgBox( + QMessageBox::Icon iconType, const QString &text, + QMessageBox::StandardButtons buttons, + QMessageBox::StandardButton defaultButton) +{ + qWarning() << text; + + QMessageBox *msgBox = new QMessageBox(iconType, + EMULATOR_TITLE, text, buttons, (QWidget *)parent->getMainWindow()); + if (defaultButton != QMessageBox::NoButton) { + msgBox->setDefaultButton(defaultButton); + } + msgBox->setAttribute(Qt::WA_DeleteOnClose); + msgBox->setModal(false); + msgBox->show(); /* non-blocking */ + + return msgBox; +} diff --git a/tizen/src/ui/menu/sdbhelperthread.h b/tizen/src/ui/menu/sdbhelperthread.h new file mode 100644 index 0000000000..778a0f139c --- /dev/null +++ b/tizen/src/ui/menu/sdbhelperthread.h @@ -0,0 +1,63 @@ +/* + * Qt UI + * + * Copyright (C) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Munkyu Im + * seokYeon Hwang + * + * 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 SDBHELPERTHREAD_H +#define SDBHELPERTHREAD_H + +#include +#include +#include +#include + +class SdbHelper; + +class SdbHelperThread : public QThread +{ + Q_OBJECT +public: + explicit SdbHelperThread(SdbHelper *parent); + void setArguments(int command, QString& program, QList& args); +private: + void run(); + SdbHelper *parent; + QProcess *process; + QString program; + QList arguments; + int command; + QString errorMsg; + QString outMsg; + QMessageBox *showMsgBox(QMessageBox::Icon iconType, const QString &text, + QMessageBox::StandardButtons buttons = QMessageBox::NoButton, + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); +signals: + void errorOccured(QString errString, int exitCode); +public slots: + void handleErrorOccured(QString errString, int exitCode); +}; +#endif // SDBHELPERTHREAD_H diff --git a/tizen/src/ui/menu/shellopener.cpp b/tizen/src/ui/menu/shellopener.cpp deleted file mode 100644 index cd1bc1d62d..0000000000 --- a/tizen/src/ui/menu/shellopener.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * 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() -{ - QString tmpSdbPath = QCoreApplication::applicationDirPath(); -#ifdef CONFIG_WIN32 - tmpSdbPath += "\\..\\..\\..\\..\\..\\tools\\ansicon.exe"; -#else - tmpSdbPath += "/../../../../../tools/sdb"; -#endif - sdbPath = QDir::toNativeSeparators(tmpSdbPath); -} - -QString ShellOpener::getSdbPath() -{ - return sdbPath; -} - -void ShellOpener::openShell(QString title) -{ - qDebug() << "open the shell"; - - QString command; - QStringList arguments; - - QString sdbPort = QString::number(get_vm_device_serial_number()); - QString sdbSerialName; - if (is_netclient_tap_attached()) { - sdbSerialName = QString(get_guest_ip()); - } else { - sdbSerialName = "emulator-" + sdbPort; - } - -#ifdef CONFIG_WIN32 - command = sdbPath; - arguments << "sdb" << "-s" << sdbSerialName << "shell"; -#elif defined CONFIG_DARWIN - command = QDir::toNativeSeparators(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() -{ - /* do nothing */ -} diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h index 5e6b6bd8de..02b6134329 100644 --- a/tizen/src/ui/resource/ui_strings.h +++ b/tizen/src/ui/resource/ui_strings.h @@ -128,6 +128,18 @@ #define ABOUT_BUILD_DATE_TEXT "Build Date" #define ABOUT_VISIT_TEXT "Visit" +/* SDB related */ +#define FILE_EXTENSION_WGT "wgt" +#define FILE_EXTENSION_TPK "tpk" +#define FILE_EXTENSION_RPM "rpm" +#define SDB_PUSH_DEFAULT_PATH "/home/developer/" +#define GUEST_TMP_PATH "/tmp/" +#define SDB_INSTALL_FAILURE "val[fail]" +#define SDB_PUSH_COMMNAD 1 +#define SDB_INSTALL_COMMAND 2 +#define PROGRESSBAR_DEFAULT_WITDH 100 +#define PROGRESSBAR_DEFAULT_HEIGHT 20 + /* style sheet*/ #define STYLE_TOOLTIP "QToolTip {"\ "color: black; background-color: white; border: 1px solid black; }" @@ -147,6 +159,9 @@ #define MSG_FORCE_CLOSE_POPUP "If you force stop an emulator, it may cause some problems.\n"\ "Are you sure you want to continue?" #define MSG_CLOSE_POPUP "Do you really want to quit this program?" +#define MSG_PUSH_POPUP "Are you sure you want to push files or directories\ninto the following path of the emulator?\n" +#define MSG_INSTALL_POPUP "Are you sure you want to install the following package file?\n" +#define MSG_SDB_FAILED_PROCESSING "Failed while processing.\n\nError Message:\n" /* qFatal messages */ #define MSG_INTERNAL_ERR "An internal error occurred : \n\n" -- 2.34.1