From fe29641d0ae808c6c7ee05d11bf712566a1a09fe Mon Sep 17 00:00:00 2001 From: Albert S Date: Tue, 17 May 2022 19:22:59 +0200 Subject: [PATCH] IpcServer: Remove docOpen(), fileOpen(). MainWindow will do it As it is no longer subject to sandboxing as a whole, it is not restricted and thus, should call these functions itself --- gui/ipcserver.cpp | 74 ++++------------------------------------------- gui/ipcserver.h | 5 ---- 2 files changed, 5 insertions(+), 74 deletions(-) diff --git a/gui/ipcserver.cpp b/gui/ipcserver.cpp index a92dc30..e4140b8 100644 --- a/gui/ipcserver.cpp +++ b/gui/ipcserver.cpp @@ -12,9 +12,6 @@ IpcServer::IpcServer() { - this->dbFactory = QSharedPointer(new DatabaseFactory(Common::databasePath())); - this->dbService = QSharedPointer(new SqliteDbService(*this->dbFactory.get())); - this->fileSaver = QSharedPointer(new FileSaver(*this->dbService.get())); connect(&this->spawningServer, &QLocalServer::newConnection, this, &IpcServer::spawnerNewConnection); } @@ -24,49 +21,6 @@ bool IpcServer::startSpawner(QString socketPath) return this->spawningServer.listen(socketPath); } -bool IpcServer::docOpen(QString path, int pagenum) -{ - - QSettings settings; - QString command = settings.value("pdfviewer").toString(); - if(path.endsWith(".pdf") && command != "" && command.contains("%p") && command.contains("%f")) - { - QStringList splitted = command.split(" "); - if(splitted.size() > 1) - { - QString cmd = splitted[0]; - QStringList args = splitted.mid(1); - args.replaceInStrings("%f", path); - args.replaceInStrings("%p", QString::number(pagenum)); - - QProcess::startDetached(cmd, args); - } - } - else - { - QDesktopServices::openUrl(QUrl::fromLocalFile(path)); - } - return true; -} - -bool IpcServer::fileOpen(QString path) -{ - return QDesktopServices::openUrl(QUrl::fromLocalFile(path)); -} - -SaveFileResult IpcServer::addFile(QString file) -{ - try - { - return this->fileSaver->addFile(file); - } - catch(std::exception &e) - { - Logger::error() << e.what() << Qt::endl; - return PROCESSFAIL; - } -} - void IpcServer::spawnerNewConnection() { QScopedPointer socket{this->spawningServer.nextPendingConnection()}; @@ -78,31 +32,13 @@ void IpcServer::spawnerNewConnection() } QDataStream stream(socket.get()); IPCCommand command; - QStringList args; stream >> command; - stream >> args; - if(args.size() < 1) + if(command == GeneratePreviews) { - stream << "invalid"; - return; - } - if(command == DocOpen) - { - if(args.size() < 2) - { - stream << "invalid"; - return; - } - docOpen(args[0], args[1].toInt()); - } - if(command == FileOpen) - { - if(args.size() < 1) - { - stream << "invalid"; - return; - } - fileOpen(args[0]); + RenderConfig renderConfig; + QVector targets; + stream >> renderConfig; + stream >> targets; } } } diff --git a/gui/ipcserver.h b/gui/ipcserver.h index 239afde..8274e2a 100644 --- a/gui/ipcserver.h +++ b/gui/ipcserver.h @@ -8,12 +8,7 @@ class IpcServer : public QObject { Q_OBJECT private: - QSharedPointer dbFactory; - QSharedPointer dbService; - QSharedPointer fileSaver; QLocalServer spawningServer; - bool docOpen(QString path, int pagenum); - bool fileOpen(QString path); SaveFileResult addFile(QString file); private slots: void spawnerNewConnection();