• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hluk / CopyQ / 3996 / 2

Source File

0.0
/src/common/server.h
1
/*
2
    Copyright (c) 2020, Lukas Holecek <hluk@email.cz>
3

4
    This file is part of CopyQ.
5

6
    CopyQ is free software: you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation, either version 3 of the License, or
9
    (at your option) any later version.
10

11
    CopyQ is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
15

16
    You should have received a copy of the GNU General Public License
17
    along with CopyQ.  If not, see <http://www.gnu.org/licenses/>.
18
*/
19

20
#ifndef SERVER_H
21
#define SERVER_H
22

23
#include <QMetaType>
24
#include <QObject>
25

26
#include <memory>
27

28
class ClientSocket;
29
class QEventLoop;
30
class QLocalServer;
31

32
using ClientSocketPtr = std::shared_ptr<ClientSocket>;
33
Q_DECLARE_METATYPE(ClientSocketPtr)
×
34

35
class Server final : public QObject
36
{
37
    Q_OBJECT
38
public:
39
    explicit Server(const QString &name, QObject *parent = nullptr);
40

41
    ~Server();
42

43
    void start();
44

45
    bool isListening() const;
46

47
    void close();
48

49
signals:
50
    void newConnection(const ClientSocketPtr &socket);
51

52
private:
53
    void onNewConnection();
54
    void onSocketDestroyed();
55

56
    QLocalServer *m_server;
57
    QObject *m_systemMutex;
58
    int m_socketCount;
59
    QEventLoop *m_loop = nullptr;
60
};
61

62
#endif // SERVER_H
  • Back to Build 3597
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2024 Coveralls, Inc