KWin
Loading...
Searching...
No Matches
client_machine.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include <QObject>
12#include <memory>
13#include <xcb/xcb.h>
14
15// forward declaration
16struct addrinfo;
17template<typename T>
19
20namespace KWin
21{
22
23class GetAddrInfo : public QObject
24{
25 Q_OBJECT
26public:
27 explicit GetAddrInfo(const QString &hostName, QObject *parent = nullptr);
28 ~GetAddrInfo() override;
29
30 void resolve();
31
32Q_SIGNALS:
33 void local();
34
35private Q_SLOTS:
36 void slotResolved();
37 void slotOwnAddressResolved();
38
39private:
40 void compare();
41 bool resolved(QFutureWatcher<int> *watcher);
42 bool m_resolving;
43 bool m_resolved;
44 bool m_ownResolved;
45 QString m_hostName;
46 std::unique_ptr<addrinfo> m_addressHints;
47 addrinfo *m_address;
48 addrinfo *m_ownAddress;
49 std::unique_ptr<QFutureWatcher<int>> m_watcher;
50 std::unique_ptr<QFutureWatcher<int>> m_ownAddressWatcher;
51};
52
53class ClientMachine : public QObject
54{
55 Q_OBJECT
56public:
57 explicit ClientMachine(QObject *parent = nullptr);
58 ~ClientMachine() override;
59
60 void resolve(xcb_window_t window, xcb_window_t clientLeader);
61 const QString &hostName() const;
62 bool isLocal() const;
63 static QString localhost();
64 bool isResolving() const;
65
66Q_SIGNALS:
68
69private Q_SLOTS:
70 void setLocal();
71 void resolveFinished();
72
73private:
74 void checkForLocalhost();
75 QString m_hostName;
76 bool m_localhost;
77 bool m_resolved;
78 bool m_resolving;
79};
80
81inline bool ClientMachine::isLocal() const
82{
83 return m_localhost;
84}
85
86inline const QString &ClientMachine::hostName() const
87{
88 return m_hostName;
89}
90
92{
93 return QStringLiteral("localhost");
94}
95
96inline bool ClientMachine::isResolving() const
97{
98 return m_resolving;
99}
100
101} // namespace
bool isResolving() const
void resolve(xcb_window_t window, xcb_window_t clientLeader)
const QString & hostName() const
ClientMachine(QObject *parent=nullptr)
static QString localhost()
GetAddrInfo(const QString &hostName, QObject *parent=nullptr)