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
|
|
|
|
|
|
|
|
#include <QWeakPointer>
|
2014-07-10 17:50:24 +04:00
|
|
|
#include <QTcpSocket>
|
|
|
|
#include <QTcpServer>
|
|
|
|
|
|
|
|
#include "mirall/syncfileitem.h"
|
2013-10-03 19:04:55 +04:00
|
|
|
|
|
|
|
class QUrl;
|
|
|
|
class QLocalSocket;
|
|
|
|
class QStringList;
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
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:
|
|
|
|
void slotUpdateFolderView(const QString&);
|
|
|
|
|
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-07-25 14:10:45 +04:00
|
|
|
void slotUnregisterPath( const QString& alias );
|
|
|
|
void slotRegisterPath( const QString& alias );
|
2013-10-03 19:04:55 +04:00
|
|
|
|
|
|
|
private:
|
2014-07-10 17:50:24 +04:00
|
|
|
void sendMessage(QTcpSocket* socket, const QString& message);
|
2014-07-25 14:10:45 +04:00
|
|
|
void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
2014-07-10 17:50:24 +04:00
|
|
|
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, QTcpSocket* socket);
|
|
|
|
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, QTcpSocket* socket);
|
2013-10-03 19:04:55 +04:00
|
|
|
|
|
|
|
private:
|
2014-07-10 17:50:24 +04:00
|
|
|
QTcpServer *_localServer;
|
|
|
|
QList<QTcpSocket*> _listeners;
|
2013-10-03 19:04:55 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // SOCKETAPI_H
|