blob: 80db4ab4cc30180d765a91ee2ad1af7da9ef37e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2010-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_MUMBLE_SOCKETRPC_H_
#define MUMBLE_MUMBLE_SOCKETRPC_H_
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QVariant>
#include <QtCore/QXmlStreamReader>
#include <QtNetwork/QLocalSocket>
class QBuffer;
class QLocalServer;
class SocketRPCClient : public QObject {
private:
Q_OBJECT
Q_DISABLE_COPY(SocketRPCClient)
protected:
QLocalSocket *qlsSocket;
QXmlStreamReader qxsrReader;
QXmlStreamWriter qxswWriter;
QBuffer *qbBuffer;
QByteArray qbaOutput;
void processXml();
public:
SocketRPCClient(QLocalSocket *s, QObject *p = nullptr);
public slots:
void disconnected();
void error(QLocalSocket::LocalSocketError);
void readyRead();
};
class SocketRPC : public QObject {
private:
Q_OBJECT
Q_DISABLE_COPY(SocketRPC)
protected:
QLocalServer *qlsServer;
public:
typedef QMap< QString, QVariant > ParameterMap;
SocketRPC(const QString &basename, QObject *p = nullptr);
static bool send(const QString &basename, const QString &request, const ParameterMap ¶m = ParameterMap());
public slots:
void newConnection();
};
#endif
|