diff options
Diffstat (limited to 'synchronizer/listener.h')
-rw-r--r-- | synchronizer/listener.h | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/synchronizer/listener.h b/synchronizer/listener.h deleted file mode 100644 index 560f052..0000000 --- a/synchronizer/listener.h +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QLocalServer> | ||
23 | #include <QLocalSocket> | ||
24 | #include <QObject> | ||
25 | |||
26 | #include <flatbuffers/flatbuffers.h> | ||
27 | |||
28 | #include "common/pipeline.h" | ||
29 | |||
30 | namespace Akonadi2 | ||
31 | { | ||
32 | class Resource; | ||
33 | } | ||
34 | |||
35 | class QTimer; | ||
36 | |||
37 | class Client | ||
38 | { | ||
39 | public: | ||
40 | Client() | ||
41 | : socket(nullptr) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | Client(const QString &n, QLocalSocket *s) | ||
46 | : name(n), | ||
47 | socket(s) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | QString name; | ||
52 | QPointer<QLocalSocket> socket; | ||
53 | QByteArray commandBuffer; | ||
54 | }; | ||
55 | |||
56 | class QLockFile; | ||
57 | |||
58 | class Listener : public QObject | ||
59 | { | ||
60 | Q_OBJECT | ||
61 | |||
62 | public: | ||
63 | Listener(const QByteArray &resourceName, QObject *parent = 0); | ||
64 | ~Listener(); | ||
65 | |||
66 | Q_SIGNALS: | ||
67 | void noClients(); | ||
68 | |||
69 | public Q_SLOTS: | ||
70 | void closeAllConnections(); | ||
71 | |||
72 | private Q_SLOTS: | ||
73 | void acceptConnection(); | ||
74 | void clientDropped(); | ||
75 | void checkConnections(); | ||
76 | void onDataAvailable(); | ||
77 | void processClientBuffers(); | ||
78 | void refreshRevision(); | ||
79 | void quit(); | ||
80 | |||
81 | private: | ||
82 | void processCommand(int commandId, uint messageId, const QByteArray &commandBuffer, Client &client, const std::function<void()> &callback); | ||
83 | bool processClientBuffer(Client &client); | ||
84 | void sendCurrentRevision(Client &client); | ||
85 | void sendCommandCompleted(QLocalSocket *socket, uint messageId); | ||
86 | void updateClientsWithRevision(); | ||
87 | void loadResource(); | ||
88 | void readFromSocket(QLocalSocket *socket); | ||
89 | |||
90 | QLocalServer *m_server; | ||
91 | QVector<Client> m_connections; | ||
92 | flatbuffers::FlatBufferBuilder m_fbb; | ||
93 | const QByteArray m_resourceName; | ||
94 | const QByteArray m_resourceInstanceIdentifier; | ||
95 | Akonadi2::Resource *m_resource; | ||
96 | Akonadi2::Pipeline *m_pipeline; | ||
97 | QTimer *m_clientBufferProcessesTimer; | ||
98 | QTimer *m_checkConnectionsTimer; | ||
99 | int m_messageId; | ||
100 | QLockFile *m_lockfile; | ||
101 | }; | ||