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-07-11 02:31:24 +04:00
|
|
|
#include "syncfileitem.h"
|
2016-03-24 20:20:49 +03:00
|
|
|
#include "syncfilestatus.h"
|
2014-10-22 12:20:38 +04:00
|
|
|
#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;
|
2017-01-11 20:27:22 +03:00
|
|
|
class SocketListener;
|
2014-10-13 17:38:57 +04:00
|
|
|
|
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
|
|
|
|
{
|
2017-05-17 11:55:42 +03:00
|
|
|
Q_OBJECT
|
2013-10-03 19:04:55 +04:00
|
|
|
|
|
|
|
public:
|
2017-05-17 11:55:42 +03:00
|
|
|
explicit SocketApi(QObject *parent = 0);
|
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);
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotUnregisterPath(const QString &alias);
|
|
|
|
void slotRegisterPath(const QString &alias);
|
2014-09-03 18:12:21 +04:00
|
|
|
|
|
|
|
signals:
|
2017-05-10 10:37:10 +03:00
|
|
|
void shareCommandReceived(const QString &sharePath, const QString &localPath);
|
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();
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotSocketDestroyed(QObject *obj);
|
2014-06-02 14:08:06 +04:00
|
|
|
void slotReadSocket();
|
2017-05-17 11:55:42 +03:00
|
|
|
void broadcastStatusPushMessage(const QString &systemPath, SyncFileStatus fileStatus);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
|
|
|
private:
|
2017-05-17 11:55:42 +03:00
|
|
|
void broadcastMessage(const QString &msg, bool doWait = false);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString &argument, SocketListener *listener);
|
|
|
|
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString &argument, SocketListener *listener);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
Q_INVOKABLE void command_VERSION(const QString &argument, SocketListener *listener);
|
2014-08-27 14:02:47 +04:00
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
Q_INVOKABLE void command_SHARE_STATUS(const QString &localFile, SocketListener *listener);
|
|
|
|
Q_INVOKABLE void command_SHARE_MENU_TITLE(const QString &argument, SocketListener *listener);
|
2017-05-10 10:37:10 +03:00
|
|
|
|
|
|
|
// The context menu actions
|
|
|
|
Q_INVOKABLE void command_SHARE(const QString &localFile, SocketListener *listener);
|
|
|
|
Q_INVOKABLE void command_COPY_PRIVATE_LINK(const QString &localFile, SocketListener *listener);
|
|
|
|
Q_INVOKABLE void command_EMAIL_PRIVATE_LINK(const QString &localFile, SocketListener *listener);
|
|
|
|
|
|
|
|
/** Sends translated/branded strings that may be useful to the integration */
|
|
|
|
Q_INVOKABLE void command_GET_STRINGS(const QString &argument, SocketListener *listener);
|
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
QString buildRegisterPathMessage(const QString &path);
|
2017-05-10 10:37:10 +03:00
|
|
|
QUrl getPrivateLinkUrl(const QString &localFile) const;
|
2015-01-23 18:09:38 +03:00
|
|
|
|
2016-04-28 23:43:53 +03:00
|
|
|
QSet<QString> _registeredAliases;
|
2017-01-11 20:27:22 +03:00
|
|
|
QList<SocketListener> _listeners;
|
2015-06-15 15:51:11 +03:00
|
|
|
SocketApiServer _localServer;
|
2013-10-03 19:04:55 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // SOCKETAPI_H
|