Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/socket/qlocalserver.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | QLocalServer::QLocalServer(QObject *parent) | - | ||||||
4 | : QObject(*new QLocalServerPrivate, parent) | - | ||||||
5 | { | - | ||||||
6 | QLocalServerPrivate * const d = d_func(); | - | ||||||
7 | d->init(); | - | ||||||
8 | } executed 57 times by 3 tests: end of block Executed by:
| 57 | ||||||
9 | QLocalServer::~QLocalServer() | - | ||||||
10 | { | - | ||||||
11 | if (isListening()
| 17-40 | ||||||
12 | close(); executed 40 times by 3 tests: close(); Executed by:
| 40 | ||||||
13 | } executed 57 times by 3 tests: end of block Executed by:
| 57 | ||||||
14 | void QLocalServer::setSocketOptions(SocketOptions options) | - | ||||||
15 | { | - | ||||||
16 | QLocalServerPrivate * const d = d_func(); | - | ||||||
17 | - | |||||||
18 | d->socketOptions = options; | - | ||||||
19 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
20 | - | |||||||
21 | - | |||||||
22 | - | |||||||
23 | - | |||||||
24 | - | |||||||
25 | - | |||||||
26 | - | |||||||
27 | QLocalServer::SocketOptions QLocalServer::socketOptions() const | - | ||||||
28 | { | - | ||||||
29 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
30 | return never executed: d->socketOptions;return d->socketOptions; never executed: return d->socketOptions; | 0 | ||||||
31 | } | - | ||||||
32 | - | |||||||
33 | - | |||||||
34 | - | |||||||
35 | - | |||||||
36 | - | |||||||
37 | - | |||||||
38 | - | |||||||
39 | void QLocalServer::close() | - | ||||||
40 | { | - | ||||||
41 | QLocalServerPrivate * const d = d_func(); | - | ||||||
42 | if (!isListening()
| 5-50 | ||||||
43 | return; executed 5 times by 1 test: return; Executed by:
| 5 | ||||||
44 | qDeleteAll(d->pendingConnections); | - | ||||||
45 | d->pendingConnections.clear(); | - | ||||||
46 | d->closeServer(); | - | ||||||
47 | d->serverName.clear(); | - | ||||||
48 | d->fullServerName.clear(); | - | ||||||
49 | d->errorString.clear(); | - | ||||||
50 | d->error = QAbstractSocket::UnknownSocketError; | - | ||||||
51 | } executed 50 times by 3 tests: end of block Executed by:
| 50 | ||||||
52 | QString QLocalServer::errorString() const | - | ||||||
53 | { | - | ||||||
54 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
55 | return executed 42 times by 2 tests: d->errorString;return d->errorString; Executed by:
executed 42 times by 2 tests: return d->errorString; Executed by:
| 42 | ||||||
56 | } | - | ||||||
57 | - | |||||||
58 | - | |||||||
59 | - | |||||||
60 | - | |||||||
61 | - | |||||||
62 | - | |||||||
63 | - | |||||||
64 | bool QLocalServer::hasPendingConnections() const | - | ||||||
65 | { | - | ||||||
66 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
67 | return executed 79 times by 2 tests: !(d->pendingConnections.isEmpty());return !(d->pendingConnections.isEmpty()); Executed by:
executed 79 times by 2 tests: return !(d->pendingConnections.isEmpty()); Executed by:
| 79 | ||||||
68 | } | - | ||||||
69 | void QLocalServer::incomingConnection(quintptr socketDescriptor) | - | ||||||
70 | { | - | ||||||
71 | QLocalServerPrivate * const d = d_func(); | - | ||||||
72 | QLocalSocket *socket = new QLocalSocket(this); | - | ||||||
73 | socket->setSocketDescriptor(socketDescriptor); | - | ||||||
74 | d->pendingConnections.enqueue(socket); | - | ||||||
75 | newConnection(); | - | ||||||
76 | } executed 77 times by 3 tests: end of block Executed by:
| 77 | ||||||
77 | - | |||||||
78 | - | |||||||
79 | - | |||||||
80 | - | |||||||
81 | - | |||||||
82 | - | |||||||
83 | - | |||||||
84 | bool QLocalServer::isListening() const | - | ||||||
85 | { | - | ||||||
86 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
87 | return executed 277 times by 3 tests: !(d->serverName.isEmpty());return !(d->serverName.isEmpty()); Executed by:
executed 277 times by 3 tests: return !(d->serverName.isEmpty()); Executed by:
| 277 | ||||||
88 | } | - | ||||||
89 | bool QLocalServer::listen(const QString &name) | - | ||||||
90 | { | - | ||||||
91 | QLocalServerPrivate * const d = d_func(); | - | ||||||
92 | if (isListening()
| 2-54 | ||||||
93 | QMessageLogger(__FILE__, 290, __PRETTY_FUNCTION__).warning("QLocalServer::listen() called when already listening"); | - | ||||||
94 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||
95 | } | - | ||||||
96 | - | |||||||
97 | if (name.isEmpty()
| 6-48 | ||||||
98 | d->error = QAbstractSocket::HostNotFoundError; | - | ||||||
99 | QString function = QLatin1String("QLocalServer::listen"); | - | ||||||
100 | d->errorString = tr("%1: Name error").arg(function); | - | ||||||
101 | return executed 6 times by 1 test: false;return false; Executed by:
executed 6 times by 1 test: return false; Executed by:
| 6 | ||||||
102 | } | - | ||||||
103 | - | |||||||
104 | if (!d->listen(name)
| 2-46 | ||||||
105 | d->serverName.clear(); | - | ||||||
106 | d->fullServerName.clear(); | - | ||||||
107 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||
108 | } | - | ||||||
109 | - | |||||||
110 | d->serverName = name; | - | ||||||
111 | return executed 46 times by 3 tests: true;return true; Executed by:
executed 46 times by 3 tests: return true; Executed by:
| 46 | ||||||
112 | } | - | ||||||
113 | bool QLocalServer::listen(qintptr socketDescriptor) | - | ||||||
114 | { | - | ||||||
115 | QLocalServerPrivate * const d = d_func(); | - | ||||||
116 | if (isListening()
| 0-4 | ||||||
117 | QMessageLogger(__FILE__, 331, __PRETTY_FUNCTION__).warning("QLocalServer::listen() called when already listening"); | - | ||||||
118 | return never executed: false;return false; never executed: return false; | 0 | ||||||
119 | } | - | ||||||
120 | - | |||||||
121 | d->serverName.clear(); | - | ||||||
122 | d->fullServerName.clear(); | - | ||||||
123 | - | |||||||
124 | if (!d->listen(socketDescriptor)
| 0-4 | ||||||
125 | return never executed: false;return false; never executed: return false; | 0 | ||||||
126 | } | - | ||||||
127 | - | |||||||
128 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||
129 | } | - | ||||||
130 | - | |||||||
131 | - | |||||||
132 | - | |||||||
133 | - | |||||||
134 | - | |||||||
135 | - | |||||||
136 | - | |||||||
137 | int QLocalServer::maxPendingConnections() const | - | ||||||
138 | { | - | ||||||
139 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
140 | return executed 8 times by 1 test: d->maxPendingConnections;return d->maxPendingConnections; Executed by:
executed 8 times by 1 test: return d->maxPendingConnections; Executed by:
| 8 | ||||||
141 | } | - | ||||||
142 | QLocalSocket *QLocalServer::nextPendingConnection() | - | ||||||
143 | { | - | ||||||
144 | QLocalServerPrivate * const d = d_func(); | - | ||||||
145 | if (d->pendingConnections.isEmpty()
| 10-71 | ||||||
146 | return executed 10 times by 1 test: 0;return 0; Executed by:
executed 10 times by 1 test: return 0; Executed by:
| 10 | ||||||
147 | QLocalSocket *nextSocket = d->pendingConnections.dequeue(); | - | ||||||
148 | - | |||||||
149 | if (d->pendingConnections.size() <= d->maxPendingConnections
| 0-71 | ||||||
150 | - | |||||||
151 | d->socketNotifier->setEnabled(true); executed 71 times by 3 tests: d->socketNotifier->setEnabled(true); Executed by:
| 71 | ||||||
152 | - | |||||||
153 | - | |||||||
154 | - | |||||||
155 | - | |||||||
156 | return executed 71 times by 3 tests: nextSocket;return nextSocket; Executed by:
executed 71 times by 3 tests: return nextSocket; Executed by:
| 71 | ||||||
157 | } | - | ||||||
158 | bool QLocalServer::removeServer(const QString &name) | - | ||||||
159 | { | - | ||||||
160 | return executed 35 times by 2 tests: QLocalServerPrivate::removeServer(name);return QLocalServerPrivate::removeServer(name); Executed by:
executed 35 times by 2 tests: return QLocalServerPrivate::removeServer(name); Executed by:
| 35 | ||||||
161 | } | - | ||||||
162 | - | |||||||
163 | - | |||||||
164 | - | |||||||
165 | - | |||||||
166 | - | |||||||
167 | - | |||||||
168 | - | |||||||
169 | QString QLocalServer::serverName() const | - | ||||||
170 | { | - | ||||||
171 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
172 | return executed 21 times by 1 test: d->serverName;return d->serverName; Executed by:
executed 21 times by 1 test: return d->serverName; Executed by:
| 21 | ||||||
173 | } | - | ||||||
174 | QString QLocalServer::fullServerName() const | - | ||||||
175 | { | - | ||||||
176 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
177 | return executed 21 times by 1 test: d->fullServerName;return d->fullServerName; Executed by:
executed 21 times by 1 test: return d->fullServerName; Executed by:
| 21 | ||||||
178 | } | - | ||||||
179 | - | |||||||
180 | - | |||||||
181 | - | |||||||
182 | - | |||||||
183 | - | |||||||
184 | - | |||||||
185 | QAbstractSocket::SocketError QLocalServer::serverError() const | - | ||||||
186 | { | - | ||||||
187 | const QLocalServerPrivate * const d = d_func(); | - | ||||||
188 | return executed 40 times by 1 test: d->error;return d->error; Executed by:
executed 40 times by 1 test: return d->error; Executed by:
| 40 | ||||||
189 | } | - | ||||||
190 | void QLocalServer::setMaxPendingConnections(int numConnections) | - | ||||||
191 | { | - | ||||||
192 | QLocalServerPrivate * const d = d_func(); | - | ||||||
193 | d->maxPendingConnections = numConnections; | - | ||||||
194 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||
195 | bool QLocalServer::waitForNewConnection(int msec, bool *timedOut) | - | ||||||
196 | { | - | ||||||
197 | QLocalServerPrivate * const d = d_func(); | - | ||||||
198 | if (timedOut
| 25-63 | ||||||
199 | * executed 63 times by 1 test: timedOut = false;*timedOut = false; Executed by:
executed 63 times by 1 test: *timedOut = false; Executed by:
| 63 | ||||||
200 | - | |||||||
201 | if (!isListening()
| 9-79 | ||||||
202 | return executed 9 times by 1 test: false;return false; Executed by:
executed 9 times by 1 test: return false; Executed by:
| 9 | ||||||
203 | - | |||||||
204 | d->waitForNewConnection(msec, timedOut); | - | ||||||
205 | - | |||||||
206 | return executed 79 times by 3 tests: !d->pendingConnections.isEmpty();return !d->pendingConnections.isEmpty(); Executed by:
executed 79 times by 3 tests: return !d->pendingConnections.isEmpty(); Executed by:
| 79 | ||||||
207 | } | - | ||||||
208 | - | |||||||
209 | - | |||||||
210 | - | |||||||
211 | - | |||||||
212 | - | |||||||
Switch to Source code | Preprocessed file |