2013-10-03 19:04:55 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Dominik Schmidt <dev@dominik-schmidt.de>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SOCKETAPI_H
|
|
|
|
#define SOCKETAPI_H
|
|
|
|
|
2014-08-21 14:43:04 +04:00
|
|
|
extern "C" {
|
|
|
|
#include <std/c_string.h>
|
|
|
|
}
|
|
|
|
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "syncfileitem.h"
|
2014-10-22 12:20:38 +04:00
|
|
|
#include "syncjournalfilerecord.h"
|
|
|
|
#include "ownsql.h"
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2015-06-15 15:51:11 +03:00
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
#include "socketapisocket_mac.h"
|
|
|
|
#else
|
|
|
|
#include <QLocalServer>
|
|
|
|
typedef QLocalServer SocketApiServer;
|
|
|
|
#endif
|
|
|
|
|
2013-10-03 19:04:55 +04:00
|
|
|
class QUrl;
|
|
|
|
class QLocalSocket;
|
|
|
|
class QStringList;
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2014-10-13 17:38:57 +04:00
|
|
|
class SyncFileStatus;
|
|
|
|
class Folder;
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The SocketApi class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2013-10-03 19:04:55 +04:00
|
|
|
class SocketApi : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-07-17 17:00:21 +04:00
|
|
|
SocketApi(QObject* parent);
|
2013-10-03 19:04:55 +04:00
|
|
|
virtual ~SocketApi();
|
|
|
|
|
2014-07-15 15:34:32 +04:00
|
|
|
public slots:
|
2015-05-12 16:50:38 +03:00
|
|
|
void slotUpdateFolderView(Folder *f);
|
2014-07-25 14:20:38 +04:00
|
|
|
void slotUnregisterPath( const QString& alias );
|
|
|
|
void slotRegisterPath( const QString& alias );
|
2014-08-21 14:43:04 +04:00
|
|
|
void slotReadExcludes();
|
|
|
|
void slotClearExcludesList();
|
2014-09-03 18:12:21 +04:00
|
|
|
|
|
|
|
signals:
|
2015-03-11 16:09:31 +03:00
|
|
|
void shareCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
2014-09-03 18:12:21 +04:00
|
|
|
|
2013-10-03 19:04:55 +04:00
|
|
|
private slots:
|
2014-06-02 14:08:06 +04:00
|
|
|
void slotNewConnection();
|
2013-10-03 19:04:55 +04:00
|
|
|
void onLostConnection();
|
2014-06-02 14:08:06 +04:00
|
|
|
void slotReadSocket();
|
2014-06-06 17:52:55 +04:00
|
|
|
void slotJobCompleted(const QString &, const SyncFileItem &);
|
2014-08-27 21:05:26 +04:00
|
|
|
void slotSyncItemDiscovered(const QString &, const SyncFileItem &);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
|
|
|
private:
|
2014-10-13 17:38:57 +04:00
|
|
|
SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName, c_strlist_t *excludes );
|
|
|
|
SyncJournalFileRecord dbFileRecord_capi( Folder *folder, QString fileName );
|
2014-10-20 18:54:51 +04:00
|
|
|
SqlQuery *getSqlQuery( Folder *folder );
|
2014-10-13 17:38:57 +04:00
|
|
|
|
2015-06-15 15:51:11 +03:00
|
|
|
void sendMessage(QIODevice* socket, const QString& message, bool doWait = false);
|
2014-08-20 18:24:06 +04:00
|
|
|
void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2015-06-15 15:51:11 +03:00
|
|
|
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, QIODevice* socket);
|
|
|
|
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, QIODevice* socket);
|
|
|
|
Q_INVOKABLE void command_SHARE(const QString& localFile, QIODevice* socket);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2015-06-15 15:51:11 +03:00
|
|
|
Q_INVOKABLE void command_VERSION(const QString& argument, QIODevice* socket);
|
2014-08-27 14:02:47 +04:00
|
|
|
|
2015-06-15 15:51:11 +03:00
|
|
|
Q_INVOKABLE void command_SHARE_MENU_TITLE(const QString& argument, QIODevice* socket);
|
2015-03-13 20:30:45 +03:00
|
|
|
QString buildRegisterPathMessage(const QString& path);
|
2015-01-23 18:09:38 +03:00
|
|
|
|
2015-06-15 15:51:11 +03:00
|
|
|
QList<QIODevice*> _listeners;
|
|
|
|
SocketApiServer _localServer;
|
2014-08-21 14:43:04 +04:00
|
|
|
c_strlist_t *_excludes;
|
2015-06-08 16:49:37 +03:00
|
|
|
QHash<Folder*, QSharedPointer<SqlQuery>> _dbQueries;
|
|
|
|
QHash<Folder*, QSharedPointer<SqlDatabase>> _openDbs;
|
2013-10-03 19:04:55 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // SOCKETAPI_H
|