IpcServer: Add addFile()
Šī revīzija ir iekļauta:
vecāks
d73674937d
revīzija
629c1efba5
@ -4,6 +4,7 @@
|
||||
enum IPCCommand
|
||||
{
|
||||
DocOpen,
|
||||
FileOpen
|
||||
FileOpen,
|
||||
AddFile,
|
||||
};
|
||||
#endif // IPC_H
|
||||
|
@ -6,9 +6,15 @@
|
||||
#include <QLocalSocket>
|
||||
#include <QDataStream>
|
||||
#include "ipcserver.h"
|
||||
#include "common.h"
|
||||
#include "databasefactory.h"
|
||||
#include "../shared/logger.h"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -20,9 +26,10 @@ bool IpcServer::startSpawner(QString socketPath)
|
||||
|
||||
bool IpcServer::docOpen(QString path, int pagenum)
|
||||
{
|
||||
|
||||
QSettings settings;
|
||||
QString command = settings.value("pdfviewer").toString();
|
||||
if(command != "" && command.contains("%p") && command.contains("%f"))
|
||||
if(path.endsWith(".pdf") && command != "" && command.contains("%p") && command.contains("%f"))
|
||||
{
|
||||
QStringList splitted = command.split(" ");
|
||||
if(splitted.size() > 1)
|
||||
@ -47,6 +54,19 @@ 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()};
|
||||
|
@ -3,13 +3,18 @@
|
||||
#include <QString>
|
||||
#include <QLocalServer>
|
||||
#include "ipc.h"
|
||||
#include "filesaver.h"
|
||||
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();
|
||||
|
||||
|
Notiek ielāde…
Atsaukties uz šo jaunā problēmā
Block a user