mirror of
https://github.com/YACReader/yacreader
synced 2025-09-15 17:55:12 -04:00
a?adido guid para identificar a YACReaderLibrary
a?adidas las clases server y client para los mecanismos IPC que permitir?n la integraci?n entre YACReader y YACReaderLibrary a?adido check que permite ejecutar YACReaderLibray como una aplicaci?n stand alone a?adidos ficheros de clases POCO para gesti?nar los objetos de las bibliotecas eliminado c?digo muerto en LibraryWindow y c?digo comentado en LibraryCreator
This commit is contained in:
@ -60,7 +60,8 @@ HEADERS += comic.h \
|
|||||||
../common/qnaturalsorting.h \
|
../common/qnaturalsorting.h \
|
||||||
../common/yacreader_flow_gl.h \
|
../common/yacreader_flow_gl.h \
|
||||||
../common/yacreader_global.h \
|
../common/yacreader_global.h \
|
||||||
../common/onstart_flow_selection_dialog.h
|
../common/onstart_flow_selection_dialog.h \
|
||||||
|
yacreader_local_client.h
|
||||||
|
|
||||||
SOURCES += comic.cpp \
|
SOURCES += comic.cpp \
|
||||||
configuration.cpp \
|
configuration.cpp \
|
||||||
@ -88,7 +89,8 @@ SOURCES += comic.cpp \
|
|||||||
../common/check_new_version.cpp \
|
../common/check_new_version.cpp \
|
||||||
../common/qnaturalsorting.cpp \
|
../common/qnaturalsorting.cpp \
|
||||||
../common/yacreader_flow_gl.cpp \
|
../common/yacreader_flow_gl.cpp \
|
||||||
../common/onstart_flow_selection_dialog.cpp
|
../common/onstart_flow_selection_dialog.cpp \
|
||||||
|
yacreader_local_client.cpp
|
||||||
|
|
||||||
include(../custom_widgets/custom_widgets.pri)
|
include(../custom_widgets/custom_widgets.pri)
|
||||||
|
|
||||||
|
31
YACReader/yacreader_local_client.cpp
Normal file
31
YACReader/yacreader_local_client.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "yacreader_local_client.h"
|
||||||
|
#include "yacreader_comic_library.h"
|
||||||
|
#include "yacreader_comic_info_library.h"
|
||||||
|
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
|
YACReaderLocalClient::YACReaderLocalClient(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
localSocket = new QLocalSocket(this);
|
||||||
|
|
||||||
|
connect(localSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
|
||||||
|
/*connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
|
||||||
|
this, SLOT(displayError(QLocalSocket::LocalSocketError)));*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//información de comic recibida...
|
||||||
|
void YACReaderLocalClient::readMessage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLocalClient::requestComicInfo(QString library, YACReaderComicLibrary & comic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLocalClient::sendComicInfo(QString library, YACReaderComicLibrary & comic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
27
YACReader/yacreader_local_client.h
Normal file
27
YACReader/yacreader_local_client.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef YACREADER_LOCAL_CLIENT_H
|
||||||
|
#define YACREADER_LOCAL_CLIENT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class QLocalSocket;
|
||||||
|
class YACReaderComicLibrary;
|
||||||
|
|
||||||
|
class YACReaderLocalClient : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit YACReaderLocalClient(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void readMessage();
|
||||||
|
void requestComicInfo(QString library, YACReaderComicLibrary & comic);
|
||||||
|
void sendComicInfo(QString library, YACReaderComicLibrary & comic);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLocalSocket * localSocket;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YACREADER_LOCAL_CLIENT_H
|
@ -73,7 +73,10 @@ HEADERS += comic_flow.h \
|
|||||||
../common/yacreader_global.h \
|
../common/yacreader_global.h \
|
||||||
../common/onstart_flow_selection_dialog.h \
|
../common/onstart_flow_selection_dialog.h \
|
||||||
no_libraries_widget.h \
|
no_libraries_widget.h \
|
||||||
import_widget.h
|
import_widget.h \
|
||||||
|
yacreader_local_server.h \
|
||||||
|
../common/yacreader_comic_library.h \
|
||||||
|
../common/yacreader_comic_info_library.h
|
||||||
|
|
||||||
SOURCES += comic_flow.cpp \
|
SOURCES += comic_flow.cpp \
|
||||||
create_library_dialog.cpp \
|
create_library_dialog.cpp \
|
||||||
@ -110,6 +113,9 @@ SOURCES += comic_flow.cpp \
|
|||||||
../common/onstart_flow_selection_dialog.cpp \
|
../common/onstart_flow_selection_dialog.cpp \
|
||||||
no_libraries_widget.cpp \
|
no_libraries_widget.cpp \
|
||||||
import_widget.cpp \
|
import_widget.cpp \
|
||||||
|
yacreader_local_server.cpp \
|
||||||
|
../common/yacreader_comic_library.cpp \
|
||||||
|
../common/yacreader_comic_info_library.cpp
|
||||||
|
|
||||||
|
|
||||||
include(./server/server.pri)
|
include(./server/server.pri)
|
||||||
|
@ -11,16 +11,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//QMutex mutex;
|
|
||||||
#include "poppler-qt4.h"
|
#include "poppler-qt4.h"
|
||||||
|
|
||||||
|
|
||||||
/*int numThreads = 0;
|
|
||||||
QWaitCondition waitCondition;
|
|
||||||
QMutex mutex;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
LibraryCreator::LibraryCreator()
|
LibraryCreator::LibraryCreator()
|
||||||
:creation(false)
|
:creation(false)
|
||||||
@ -143,39 +135,6 @@ qulonglong LibraryCreator::insertFolders()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*qulonglong LibraryCreator::insertFolder(qulonglong parentId,const Folder & folder)
|
|
||||||
{
|
|
||||||
QSqlQuery query(_database);
|
|
||||||
query.prepare("INSERT INTO folder (parentId, name, path) "
|
|
||||||
"VALUES (:parentId, :name, :path)");
|
|
||||||
query.bindValue(":parentId", parentId);
|
|
||||||
query.bindValue(":name", folder.name);
|
|
||||||
query.bindValue(":path", folder.path);
|
|
||||||
query.exec();
|
|
||||||
return query.lastInsertId().toULongLong();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*qulonglong LibraryCreator::insertComic(const Comic & comic)
|
|
||||||
{
|
|
||||||
//TODO comprobar si ya hay comic info con ese hash
|
|
||||||
QSqlQuery comicInfoInsert(_database);
|
|
||||||
comicInfoInsert.prepare("INSERT INTO comic_info (hash) "
|
|
||||||
"VALUES (:hash)");
|
|
||||||
comicInfoInsert.bindValue(":hash", comic.hash);
|
|
||||||
comicInfoInsert.exec();
|
|
||||||
qulonglong comicInfoId =comicInfoInsert.lastInsertId().toULongLong();
|
|
||||||
|
|
||||||
QSqlQuery query(_database);
|
|
||||||
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
|
|
||||||
"VALUES (:parentId,:comicInfoId,:name, :path)");
|
|
||||||
query.bindValue(":parentId", comic.parentId);
|
|
||||||
query.bindValue(":comicInfoId", comicInfoId);
|
|
||||||
query.bindValue(":name", comic.name);
|
|
||||||
query.bindValue(":path", comic.path);
|
|
||||||
query.exec();
|
|
||||||
return query.lastInsertId().toULongLong();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void LibraryCreator::create(QDir dir)
|
void LibraryCreator::create(QDir dir)
|
||||||
{
|
{
|
||||||
dir.setNameFilters(_nameFilter);
|
dir.setNameFilters(_nameFilter);
|
||||||
@ -525,26 +484,3 @@ void ThumbnailCreator::create()
|
|||||||
delete _7z;
|
delete _7z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void ThumbnailCreator::openingError(QProcess::ProcessError error)
|
|
||||||
{
|
|
||||||
//TODO : move to the gui thread
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case QProcess::FailedToStart:
|
|
||||||
QMessageBox::critical(NULL,tr("7z not found"),tr("7z wasn't found in your PATH."));
|
|
||||||
break;
|
|
||||||
case QProcess::Crashed:
|
|
||||||
QMessageBox::critical(NULL,tr("7z crashed"),tr("7z crashed."));
|
|
||||||
break;
|
|
||||||
case QProcess::ReadError:
|
|
||||||
QMessageBox::critical(NULL,tr("7z reading"),tr("problem reading from 7z"));
|
|
||||||
break;
|
|
||||||
case QProcess::UnknownError:
|
|
||||||
QMessageBox::critical(NULL,tr("7z problem"),tr("Unknown error 7z"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
@ -234,7 +234,7 @@ void LibraryWindow::doLayout()
|
|||||||
comics = new QWidget;
|
comics = new QWidget;
|
||||||
QVBoxLayout * comicsLayout = new QVBoxLayout;
|
QVBoxLayout * comicsLayout = new QVBoxLayout;
|
||||||
comicsLayout->setSpacing(0);
|
comicsLayout->setSpacing(0);
|
||||||
comicsLayout->setContentsMargins(2,2,0,0);
|
comicsLayout->setContentsMargins(0,0,0,0);
|
||||||
comicsLayout->addWidget(editInfoToolBar = new QToolBar(comics));
|
comicsLayout->addWidget(editInfoToolBar = new QToolBar(comics));
|
||||||
comicsLayout->addWidget(comicView);
|
comicsLayout->addWidget(comicView);
|
||||||
comics->setLayout(comicsLayout);
|
comics->setLayout(comicsLayout);
|
||||||
@ -308,19 +308,13 @@ void LibraryWindow::doDialogs()
|
|||||||
|
|
||||||
void LibraryWindow::doModels()
|
void LibraryWindow::doModels()
|
||||||
{
|
{
|
||||||
//dirmodels
|
//folders
|
||||||
dm = new TreeModel();
|
dm = new TreeModel();
|
||||||
|
//comics
|
||||||
dmCV = new TableModel();
|
dmCV = new TableModel();
|
||||||
|
//comics selection
|
||||||
sm = new QItemSelectionModel(dm);
|
sm = new QItemSelectionModel(dm);
|
||||||
|
|
||||||
|
|
||||||
/*proxyFilter = new YACReaderTreeSearch();
|
|
||||||
proxyFilter->setSourceModel(dm);
|
|
||||||
proxyFilter->setFilterRole(Qt::DisplayRole);*/
|
|
||||||
|
|
||||||
/*proxySort = new YACReaderSortComics();
|
|
||||||
proxySort->setSourceModel(dmCV);
|
|
||||||
proxySort->setFilterRole(Qt::DisplayRole);*/
|
|
||||||
setFoldersFilter("");
|
setFoldersFilter("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,12 +1156,6 @@ void LibraryWindow::updateLibrary()
|
|||||||
|
|
||||||
void LibraryWindow::deleteCurrentLibrary()
|
void LibraryWindow::deleteCurrentLibrary()
|
||||||
{
|
{
|
||||||
//QSqlDatabase db = dm->getDatabase();
|
|
||||||
//db.commit();
|
|
||||||
//db.close();
|
|
||||||
//QSqlDatabase::removeDatabase(db.connectionName());
|
|
||||||
//if(!dm->getDatabase().isOpen())
|
|
||||||
//{
|
|
||||||
QString path = libraries.value(selectedLibrary->currentText());
|
QString path = libraries.value(selectedLibrary->currentText());
|
||||||
libraries.remove(selectedLibrary->currentText());
|
libraries.remove(selectedLibrary->currentText());
|
||||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||||
@ -1184,7 +1172,6 @@ void LibraryWindow::deleteCurrentLibrary()
|
|||||||
comicFlow->clear();
|
comicFlow->clear();
|
||||||
}
|
}
|
||||||
saveLibraries();
|
saveLibraries();
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::removeLibrary()
|
void LibraryWindow::removeLibrary()
|
||||||
@ -1337,21 +1324,10 @@ void LibraryWindow::showProperties()
|
|||||||
ComicDB c = comics[0];
|
ComicDB c = comics[0];
|
||||||
_comicIdEdited = c.id;//static_cast<TableItem*>(indexList[0].internalPointer())->data(4).toULongLong();
|
_comicIdEdited = c.id;//static_cast<TableItem*>(indexList[0].internalPointer())->data(4).toULongLong();
|
||||||
|
|
||||||
//QModelIndex mi = comicView->currentIndex();
|
|
||||||
//QString path = QDir::cleanPath(currentPath()+dmCV->getComicPath(mi));
|
|
||||||
|
|
||||||
//ThumbnailCreator tc(path,"");
|
|
||||||
//tc.create();
|
|
||||||
propertiesDialog->databasePath = dm->getDatabase();
|
propertiesDialog->databasePath = dm->getDatabase();
|
||||||
propertiesDialog->basePath = currentPath();
|
propertiesDialog->basePath = currentPath();
|
||||||
propertiesDialog->setComics(comics);
|
propertiesDialog->setComics(comics);
|
||||||
|
|
||||||
/*propertiesDialog->setCover(tc.getCover());
|
|
||||||
propertiesDialog->setFilename(path.split("/").last());
|
|
||||||
propertiesDialog->setNumpages(tc.getNumPages());
|
|
||||||
QFile file(path);
|
|
||||||
propertiesDialog->setSize(file.size()/(1024.0*1024));
|
|
||||||
file.close();*/
|
|
||||||
propertiesDialog->show();
|
propertiesDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1468,76 +1444,6 @@ void LibraryWindow::showImportComicsInfo()
|
|||||||
importComicsInfoDialog->show();
|
importComicsInfoDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LibraryItem *> LibraryWindow::getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId)
|
|
||||||
{
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
|
||||||
|
|
||||||
QList<LibraryItem *> list = Folder::getFoldersFromParent(folderId,db,false);
|
|
||||||
|
|
||||||
db.close();
|
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
|
||||||
return list;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<LibraryItem *> LibraryWindow::getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId)
|
|
||||||
{
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
|
||||||
|
|
||||||
QList<LibraryItem *> list = ComicDB::getComicsFromParent(folderId,db,false);
|
|
||||||
|
|
||||||
db.close();
|
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
qulonglong LibraryWindow::getParentFromComicFolderId(const QString & libraryName, qulonglong id)
|
|
||||||
{
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
|
||||||
|
|
||||||
Folder f(id,db);
|
|
||||||
|
|
||||||
db.close();
|
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
|
||||||
return f.parentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComicDB LibraryWindow::getComicInfo(const QString & libraryName, qulonglong id)
|
|
||||||
{
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
|
||||||
|
|
||||||
ComicDB comic;
|
|
||||||
comic.load(id,db);
|
|
||||||
|
|
||||||
db.close();
|
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
|
||||||
return comic;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString LibraryWindow::getFolderName(const QString & libraryName, qulonglong id)
|
|
||||||
{
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
|
||||||
|
|
||||||
QString name="";
|
|
||||||
|
|
||||||
{
|
|
||||||
QSqlQuery selectQuery(db); //TODO check
|
|
||||||
selectQuery.prepare("SELECT name FROM folder WHERE id = :id");
|
|
||||||
selectQuery.bindValue(":id", id);
|
|
||||||
selectQuery.exec();
|
|
||||||
|
|
||||||
if(selectQuery.next())
|
|
||||||
{
|
|
||||||
QSqlRecord record = selectQuery.record();
|
|
||||||
name = record.value(0).toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db.close();
|
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LibraryWindow::closeEvent ( QCloseEvent * event )
|
void LibraryWindow::closeEvent ( QCloseEvent * event )
|
||||||
{
|
{
|
||||||
settings->setValue(MAIN_WINDOW_GEOMETRY, saveGeometry());
|
settings->setValue(MAIN_WINDOW_GEOMETRY, saveGeometry());
|
||||||
|
@ -233,14 +233,6 @@ public:
|
|||||||
void manageCreatingError(const QString & error);
|
void manageCreatingError(const QString & error);
|
||||||
void manageUpdatingError(const QString & error);
|
void manageUpdatingError(const QString & error);
|
||||||
void manageOpeningLibraryError(const QString & error);
|
void manageOpeningLibraryError(const QString & error);
|
||||||
|
|
||||||
//server interface
|
|
||||||
QMap<QString,QString> getLibraries(){return libraries;};
|
|
||||||
QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
|
|
||||||
QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
|
|
||||||
qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
|
|
||||||
ComicDB getComicInfo(const QString & libraryName, qulonglong id);
|
|
||||||
QString getFolderName(const QString & libraryName, qulonglong id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,44 +1,53 @@
|
|||||||
#include "library_window.h"
|
#include "library_window.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
#include "startup.h"
|
#include "startup.h"
|
||||||
#define PICTUREFLOW_QT4 1
|
#include "yacreader_local_server.h"
|
||||||
|
#define PICTUREFLOW_QT4 1
|
||||||
//interfaz al servidor
|
|
||||||
Startup * s;
|
//interfaz al servidor
|
||||||
|
Startup * s;
|
||||||
int main( int argc, char ** argv )
|
|
||||||
{
|
int main( int argc, char ** argv )
|
||||||
QApplication app( argc, argv );
|
{
|
||||||
|
QApplication app( argc, argv );
|
||||||
QTranslator translator;
|
|
||||||
QString sufix = QLocale::system().name();
|
QTranslator translator;
|
||||||
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
QString sufix = QLocale::system().name();
|
||||||
app.installTranslator(&translator);
|
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
||||||
app.setApplicationName("YACReaderLibrary");
|
app.installTranslator(&translator);
|
||||||
|
app.setApplicationName("YACReaderLibrary");
|
||||||
#ifdef SERVER_RELEASE
|
|
||||||
|
#ifdef SERVER_RELEASE
|
||||||
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
||||||
settings->beginGroup("libraryConfig");
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
s = new Startup();
|
s = new Startup();
|
||||||
|
|
||||||
if(settings->value(SERVER_ON,true).toBool())
|
if(settings->value(SERVER_ON,true).toBool())
|
||||||
{
|
{
|
||||||
|
|
||||||
s->start();
|
s->start();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LibraryWindow * mw = new LibraryWindow();
|
if(YACReaderLocalServer::isRunning()) //s<>lo se permite una instancia de YACReaderLibrary
|
||||||
mw->show();
|
return 0;
|
||||||
/*mw->resize(800,480);
|
|
||||||
mw->showMaximized();*/
|
YACReaderLocalServer * localServer = new YACReaderLocalServer();
|
||||||
|
|
||||||
return app.exec();
|
LibraryWindow * mw = new LibraryWindow();
|
||||||
}
|
|
||||||
|
//connections to localServer
|
||||||
|
|
||||||
|
mw->show();
|
||||||
|
/*mw->resize(800,480);
|
||||||
|
mw->showMaximized();*/
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
77
YACReaderLibrary/yacreader_local_server.cpp
Normal file
77
YACReaderLibrary/yacreader_local_server.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include "yacreader_local_server.h"
|
||||||
|
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
YACReaderLocalServer::YACReaderLocalServer(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
localServer = new QLocalServer(this);
|
||||||
|
if (!localServer->listen(YACREADERLIBRARY_GUID)) {
|
||||||
|
//error...........
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(localServer, SIGNAL(newConnection()), this, SLOT(sendResponse()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderLocalServer::isListening()
|
||||||
|
{
|
||||||
|
return localServer->isListening();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLocalServer::sendResponse()
|
||||||
|
{
|
||||||
|
/*QLocalSocket *clientConnection = localServer->nextPendingConnection();
|
||||||
|
|
||||||
|
connect(clientConnection, SIGNAL(disconnected()),
|
||||||
|
clientConnection, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
QDataStream in(clientConnection);
|
||||||
|
in.setVersion(QDataStream::Qt_4_0);
|
||||||
|
|
||||||
|
if (clientConnection->bytesAvailable() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (in.atEnd())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString message;
|
||||||
|
in >> message;
|
||||||
|
|
||||||
|
QByteArray block;
|
||||||
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
|
out.setVersion(QDataStream::Qt_4_0);
|
||||||
|
out << QString("OK");
|
||||||
|
|
||||||
|
clientConnection->write(block);
|
||||||
|
clientConnection->flush();
|
||||||
|
clientConnection->disconnectFromServer();*/
|
||||||
|
|
||||||
|
QByteArray block;
|
||||||
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
|
out.setVersion(QDataStream::Qt_4_0);
|
||||||
|
out << (quint16)0;
|
||||||
|
out << QString("ok");
|
||||||
|
out.device()->seek(0);
|
||||||
|
out << (quint16)(block.size() - sizeof(quint16));
|
||||||
|
|
||||||
|
QLocalSocket *clientConnection = localServer->nextPendingConnection();
|
||||||
|
connect(clientConnection, SIGNAL(disconnected()),
|
||||||
|
clientConnection, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
clientConnection->write(block);
|
||||||
|
clientConnection->flush();
|
||||||
|
clientConnection->disconnectFromServer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderLocalServer::isRunning()
|
||||||
|
{
|
||||||
|
QLocalSocket socket;
|
||||||
|
socket.connectToServer(YACREADERLIBRARY_GUID);
|
||||||
|
if (socket.waitForConnected(500))
|
||||||
|
return true; // Server is running (another instance of YACReaderLibrary has been launched)
|
||||||
|
return false;
|
||||||
|
}
|
26
YACReaderLibrary/yacreader_local_server.h
Normal file
26
YACReaderLibrary/yacreader_local_server.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef YACREADER_LOCAL_SERVER_H
|
||||||
|
#define YACREADER_LOCAL_SERVER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class QLocalServer;
|
||||||
|
|
||||||
|
class YACReaderLocalServer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit YACReaderLocalServer(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
bool isListening();
|
||||||
|
void sendResponse();
|
||||||
|
static bool isRunning();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLocalServer * localServer;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YACREADER_LOCAL_SERVER_H
|
5
common/yacreader_comic_info_library.cpp
Normal file
5
common/yacreader_comic_info_library.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "yacreader_comic_info_library.h"
|
||||||
|
|
||||||
|
YACReaderComicInfoLibrary::YACReaderComicInfoLibrary()
|
||||||
|
{
|
||||||
|
}
|
10
common/yacreader_comic_info_library.h
Normal file
10
common/yacreader_comic_info_library.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef YACREADER_COMIC_INFO_LIBRARY_H
|
||||||
|
#define YACREADER_COMIC_INFO_LIBRARY_H
|
||||||
|
|
||||||
|
class YACReaderComicInfoLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YACReaderComicInfoLibrary();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YACREADER_COMIC_INFO_LIBRARY_H
|
5
common/yacreader_comic_library.cpp
Normal file
5
common/yacreader_comic_library.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "yacreader_comic_library.h"
|
||||||
|
|
||||||
|
YACReaderComicLibrary::YACReaderComicLibrary()
|
||||||
|
{
|
||||||
|
}
|
10
common/yacreader_comic_library.h
Normal file
10
common/yacreader_comic_library.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef YACREADER_COMIC_LIBRARY_H
|
||||||
|
#define YACREADER_COMIC_LIBRARY_H
|
||||||
|
|
||||||
|
class YACReaderComicLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YACReaderComicLibrary();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YACREADER_COMIC_LIBRARY_H
|
@ -46,6 +46,8 @@
|
|||||||
#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY"
|
#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY"
|
||||||
#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE"
|
#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE"
|
||||||
|
|
||||||
|
#define YACREADERLIBRARY_GUID "ea343ff3-2005-4865-b212-7fa7c43999b8"
|
||||||
|
|
||||||
enum FlowType
|
enum FlowType
|
||||||
{
|
{
|
||||||
CoverFlowLike=0,
|
CoverFlowLike=0,
|
||||||
|
Reference in New Issue
Block a user