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
Bu işleme şunda yer alıyor:
ebeveyn
830226ae59
işleme
fe29641d0a
@ -12,9 +12,6 @@
|
||||
|
||||
IpcServer::IpcServer()
|
||||
{
|
||||
this->dbFactory = QSharedPointer<DatabaseFactory>(new DatabaseFactory(Common::databasePath()));
|
||||
this->dbService = QSharedPointer<SqliteDbService>(new SqliteDbService(*this->dbFactory.get()));
|
||||
this->fileSaver = QSharedPointer<FileSaver>(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<QLocalSocket> 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<RenderTarget> targets;
|
||||
stream >> renderConfig;
|
||||
stream >> targets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,7 @@ class IpcServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QSharedPointer<DatabaseFactory> dbFactory;
|
||||
QSharedPointer<SqliteDbService> dbService;
|
||||
QSharedPointer<FileSaver> fileSaver;
|
||||
QLocalServer spawningServer;
|
||||
bool docOpen(QString path, int pagenum);
|
||||
bool fileOpen(QString path);
|
||||
SaveFileResult addFile(QString file);
|
||||
private slots:
|
||||
void spawnerNewConnection();
|
||||
|
Yükleniyor…
Yeni konuda referans
Bir kullanıcı engelle