Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcfsocketnotifier_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QCFSOCKETNOTIFIER_P_H
6#define QCFSOCKETNOTIFIER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/private/qglobal_p.h>
20#include <QtCore/qabstracteventdispatcher.h>
21#include <QtCore/qhash.h>
22
23#include <CoreFoundation/CoreFoundation.h>
24
25QT_BEGIN_NAMESPACE
26
27struct MacSocketInfo {
28 MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0),
29 readEnabled(false), writeEnabled(false) {}
30 CFSocketRef socket;
31 CFRunLoopSourceRef runloop;
32 QObject *readNotifier;
33 QObject *writeNotifier;
34 bool readEnabled;
35 bool writeEnabled;
36};
38
39typedef void (*MaybeCancelWaitForMoreEventsFn)(QAbstractEventDispatcher *hostEventDispacher);
40
41// The CoreFoundationSocketNotifier class implements socket notifiers support using
42// CFSocket for event dispatchers running on top of the Core Foundation run loop system.
43// (currently Mac and iOS)
44//
45// The principal functions are registerSocketNotifier() and unregisterSocketNotifier().
46//
47// setHostEventDispatcher() should be called at startup.
48// removeSocketNotifiers() should be called at shutdown.
49//
50class Q_CORE_EXPORT QCFSocketNotifier
51{
52public:
53 QCFSocketNotifier();
54 ~QCFSocketNotifier();
55 void setHostEventDispatcher(QAbstractEventDispatcher *hostEventDispacher);
56 void setMaybeCancelWaitForMoreEventsCallback(MaybeCancelWaitForMoreEventsFn callBack);
57 void registerSocketNotifier(QSocketNotifier *notifier);
58 void unregisterSocketNotifier(QSocketNotifier *notifier);
59 void removeSocketNotifiers();
60
61private:
62 void destroyRunLoopObserver();
63
64 static void unregisterSocketInfo(MacSocketInfo *socketInfo);
65 static void enableSocketNotifiers(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);
66
67 MacSocketHash macSockets;
68 QAbstractEventDispatcher *eventDispatcher;
69 MaybeCancelWaitForMoreEventsFn maybeCancelWaitForMoreEvents;
70 CFRunLoopObserverRef enableNotifiersObserver;
71
72 friend void qt_mac_socket_callback(CFSocketRef, CFSocketCallBackType, CFDataRef, const void *, void *);
73};
74
75QT_END_NAMESPACE
76
77#endif
Combined button and popup list for selecting options.
CFRunLoopSourceRef qt_mac_add_socket_to_runloop(const CFSocketRef socket)
void qt_mac_remove_socket_from_runloop(const CFSocketRef socket, CFRunLoopSourceRef runloop)
QT_BEGIN_NAMESPACE void qt_mac_socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef, const void *data, void *info)
void(* MaybeCancelWaitForMoreEventsFn)(QAbstractEventDispatcher *hostEventDispacher)
QHash< int, MacSocketInfo * > MacSocketHash