Debian Codegraph @

src/ConnectDialog.cpp

raw symbols SCIP
1 #cxx . . $ `<file>/src/ConnectDialog.cpp`/include "ConnectDialog.h"cxx . . $ `<file>/src/ConnectDialog.h`/
2 #include "ranges.h"cxx . . $ `<file>/src/ranges.h`/
3 #include <QProcess>
4 #include <QString>
5 #include <QDir>
6 #include <QFileInfo>
7 #include <QTcpSocket>
8 #include <QtAlgorithms>
9 #include <cassert>
10
11 #ifdef _WIN32
12 #include "SspiNegotiateClient.h"
13 #include "QAbstractSocketStreamWrapper.h"
14 #include <QHostAddress>
15 #include <fstream>
16 #include <winsock2.h>
17 using namespace openmsx;
18 #else
19 #include <pwd.h>
20 #include <sys/socket.h>
21 #include <sys/un.h>
22 #include <cstring>
23 #include <unistd.h>
24 #endif
25
26
27 // Helper functions to setup a connection
28
29 static QStringcxx . . $ QString# getUserNamecxx . . $ getUserName(4365c3963150523e).()
30 {
31 #ifdef _WIN32
32 return "default";
33 #else
34 struct passwd* pw = getpwuid(getuid());
35 return pwcxx . . $ QString#QString(85c52e162fed56f9).->pw_name ? pw->pw_name : "";
36 #endif
37 }
38
39 static bool checkSocketDircxx . . $ checkSocketDir(4a7c9e196a4f7dee).(const QDircxx . . $ QDir#& dir)
40 {
41 if (!dir.existscxx . . $ QDir#exists(50ce9a9e25b4a850).()) {
42 return false;
43 }
44 #ifndef _WIN32
45 // only do permission and owner checks on *nix
46 QFileInfocxx . . $ QFileInfo# infocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(dir.absolutePathcxx . . $ QDir#absolutePath(6ef7b6c27b00b43d).());
47 if (info.ownerIdcxx . . $ QFileInfo#ownerId(ddd8539a2fcdd4ce).() != getuid()) {
48 return false;
49 }
50 int all = QFilecxx . . $ QFile#::ReadOwnercxx . . $ QFileDevice#ReadOwner. |cxx . . $ `operator|`(2d520c7bd59561d4). QFilecxx . . $ QFile#::WriteOwnercxx . . $ QFileDevice#WriteOwner. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeOwnercxx . . $ QFileDevice#ExeOwner. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e).
51 QFilecxx . . $ QFile#::ReadGroupcxx . . $ QFileDevice#ReadGroup. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::WriteGroupcxx . . $ QFileDevice#WriteGroup. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeGroupcxx . . $ QFileDevice#ExeGroup. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e).
52 QFilecxx . . $ QFile#::ReadOthercxx . . $ QFileDevice#ReadOther. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::WriteOthercxx . . $ QFileDevice#WriteOther. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeOthercxx . . $ QFileDevice#ExeOther.;
53 QFilecxx . . $ QFile#::Permissionscxx . . $ QFileDevice#Permissions# needed = QFilecxx . . $ QFile#::ReadOwnercxx . . $ QFileDevice#ReadOwner. |cxx . . $ `operator|`(2d520c7bd59561d4). QFilecxx . . $ QFile#::WriteOwnercxx . . $ QFileDevice#WriteOwner. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeOwnercxx . . $ QFileDevice#ExeOwner.;
54 if ((info.permissionscxx . . $ QFileInfo#permissions(82176f88d78e622a).() &cxx . . $ QFlags#`operator&`(dc38392ed707d4f). all) != needed) {
55 return false;
56 }
57 #endif
58 return true;
59 }
60
61 static bool checkSocketcxx . . $ checkSocket(106f46682d8d3287).(const QFileInfocxx . . $ QFileInfo#& info)
62 {
63 if (!info.fileNamecxx . . $ QFileInfo#fileName(6ef7b6c27b00b43d).().startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("socket."cxx . . $ QString#QString(85c52e162fed56f9).)) {
64 // wrong name
65 return false;
66 }
67 #ifndef _WIN32
68 // only do permission and owner checks on *nix
69 int all = QFilecxx . . $ QFile#::ReadOwnercxx . . $ QFileDevice#ReadOwner. |cxx . . $ `operator|`(2d520c7bd59561d4). QFilecxx . . $ QFile#::WriteOwnercxx . . $ QFileDevice#WriteOwner. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeOwnercxx . . $ QFileDevice#ExeOwner. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e).
70 QFilecxx . . $ QFile#::ReadGroupcxx . . $ QFileDevice#ReadGroup. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::WriteGroupcxx . . $ QFileDevice#WriteGroup. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeGroupcxx . . $ QFileDevice#ExeGroup. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e).
71 QFilecxx . . $ QFile#::ReadOthercxx . . $ QFileDevice#ReadOther. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::WriteOthercxx . . $ QFileDevice#WriteOther. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QFilecxx . . $ QFile#::ExeOthercxx . . $ QFileDevice#ExeOther.;
72 QFilecxx . . $ QFile#::Permissionscxx . . $ QFileDevice#Permissions# needed = QFilecxx . . $ QFile#::ReadOwnercxx . . $ QFileDevice#ReadOwner. |cxx . . $ `operator|`(2d520c7bd59561d4). QFilecxx . . $ QFile#::WriteOwnercxx . . $ QFileDevice#WriteOwner.;
73 if ((info.permissionscxx . . $ QFileInfo#permissions(82176f88d78e622a).() &cxx . . $ QFlags#`operator&`(dc38392ed707d4f). all) != needed) {
74 return false;
75 }
76 if (info.ownerIdcxx . . $ QFileInfo#ownerId(ddd8539a2fcdd4ce).() != getuid()) {
77 return false;
78 }
79 #endif
80 return true;
81 }
82
83 static void deleteSocketcxx . . $ deleteSocket(208c3155c9413262).(const QFileInfocxx . . $ QFileInfo#& info)
84 {
85 QFilecxx . . $ QFile#::removecxx . . $ QFile#remove(e1defb592416720d).(info.absoluteFilePathcxx . . $ QFileInfo#absoluteFilePath(6ef7b6c27b00b43d).()); // ignore errors
86 QDircxx . . $ QDir# dircxx . . $ QDir#QDir(3520e46b33348bf6).;
87 dir.rmdircxx . . $ QDir#rmdir(f3b39adf77d9c36c).(info.absolutePathcxx . . $ QFileInfo#absolutePath(6ef7b6c27b00b43d).()); // ignore errors
88 }
89
90 static std::unique_ptrcxx . . $ std/unique_ptr#<OpenMSXConnectioncxx . . $ OpenMSXConnection#> createConnectioncxx . . $ createConnection(f5eb4142fc421d43).(const QDircxx . . $ QDir#& dir, const QStringcxx . . $ QString#& socketName)
91 {
92 QFileInfocxx . . $ QFileInfo# infocxx . . $ QFileInfo#QFileInfo(8a05b6733fa7835a).(dir, socketName);
93 if (!checkSocketcxx . . $ checkSocket(106f46682d8d3287).(info)) {
94 // invalid socket
95 return nullptrcxx . . $ std/unique_ptr#unique_ptr(6d988fd07f070dfc).;
96 }
97
98 QAbstractSocketcxx . . $ QAbstractSocket#* socket = nullptr;
99 #ifdef _WIN32
100 int port = -1;
101 std::ifstream in(info.absoluteFilePath().toLatin1().data());
102 in >> port;
103 if (port != -1) {
104 QHostAddress localhost(QHostAddress::LocalHost);
105 socket = new QTcpSocket();
106 socket->connectToHost(localhost, port);
107
108 QAbstractSocketStreamWrapper stream(socket);
109 SspiNegotiateClient client(stream);
110
111 if (!socket->waitForConnected(1000) ||
112 !client.Authenticate()) {
113 delete socket;
114 socket = nullptr;
115 }
116 }
117 #else
118 int sd = ::socket(AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, 0);
119 if (sd != -1) {
120 sockaddr_un addr;
121 addr.sun_family = AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!;
122 strcpy(addr.sun_path, info.absoluteFilePathcxx . . $ QFileInfo#absoluteFilePath(6ef7b6c27b00b43d).().toLatin1cxx . . $ QString#toLatin1(7c2073558a834e49).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).());
123 if (connect(sd, (sockaddr*)&addr, sizeof(addr)) != -1) {
124 socket = new QTcpSocketcxx . . $ QTcpSocket#();
125 if (!socket->setSocketDescriptorcxx . . $ QAbstractSocket#setSocketDescriptor(ddcdfa077c948809).(sd)) {
126 // failed to wrap socket in QTcpSocket
127 delete socket;
128 socket = nullptr;
129 close(sd);
130 }
131 } else {
132 // failed to connect to UNIX socket
133 close(sd);
134 }
135 }
136
137 #endif
138 if (socket) {
139 return std::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<OpenMSXConnectioncxx . . $ OpenMSXConnection#>(socket);
140 } else {
141 // cannot connect, must be a stale socket, try to clean it up
142 deleteSocketcxx . . $ deleteSocket(208c3155c9413262).(socketNamecxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).);
143 return {cxx . . $ std/unique_ptr#unique_ptr(ced63f7c635d850d).};
144 }
145 }
146
147 static std::vectorcxx . . $ std/vector#<std::unique_ptrcxx . . $ std/unique_ptr#<OpenMSXConnectioncxx . . $ OpenMSXConnection#>> collectServerscxx . . $ collectServers(513aff86fb05de5f).()
148 {
149 #ifdef _WIN32
150 DWORD len = GetTempPathW(0, nullptr);
151 assert(len > 0); // nothing we can do to recover this
152 //VLA(wchar_t, bufW, (len+1));
153 //wchar_t bufW[len+1];
154 auto bufW = static_cast<wchar_t*>(_alloca(sizeof(wchar_t) * (len+1)));
155
156 len = GetTempPathW(len, bufW);
157 assert(len > 0); // nothing we can do to recover this
158 QDir dir(QString::fromWCharArray(bufW, len));
159 #else
160 QDircxx . . $ QDir# dircxx . . $ QDir#QDir(3520e46b33348bf6).((getenv("TMPDIR")) ? getenvcxx . . $ QString#QString(85c52e162fed56f9).("TMPDIR") : QDircxx . . $ QDir#::tempPathcxx . . $ QDir#tempPath(4365c3963150523e).());
161 #endif
162 dir.cdcxx . . $ QDir#cd(e1defb592416720d).("openmsx-" +cxx . . $ operator+(c75c3ae4eb9af1a8). getUserNamecxx . . $ getUserName(4365c3963150523e).());
163 if (!checkSocketDircxx . . $ checkSocketDir(4a7c9e196a4f7dee).(dir)) {
164 // no correct socket directory
165 return {cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).};
166 }
167 QDircxx . . $ QDir#::Filterscxx . . $ QDir#Filters# filters =
168 #ifdef _WIN32
169 QDir::Files; // regular files for win32
170 #else
171 QDircxx . . $ QFlags#QFlags(93d577a3e9528307).::Systemcxx . . $ QDir#System.; // sockets for *nix
172 #endif
173 std::vectorcxx . . $ std/vector#<std::unique_ptrcxx . . $ std/unique_ptr#<OpenMSXConnectioncxx . . $ OpenMSXConnection#>> serverscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
174 for (const auto& name : dir.entryListcxx . . $ QDir#entryList(648720ae7e049ebe).(filters)) {
175 if (auto connection = createConnectioncxx . . $ createConnection(f5eb4142fc421d43).(dir, name)) {
176 servers.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(std::movecxx . . $ std/move(e35c19a1ba7baa26).(connection));
177 }
178 }
179 return serverscxx . . $ std/vector#vector(6f559d22b039ccdb).;
180 }
181
182
183 // ConnectionInfoRequest class
184
185 ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#ConnectionInfoRequest(2be82e0c2bffd3e4).(
186 ConnectDialogcxx . . $ ConnectDialog#& dialog_, OpenMSXConnectioncxx . . $ OpenMSXConnection#& connection_)
187 : dialogcxx . . $ ConnectionInfoRequest#dialog.(dialog_), connectioncxx . . $ ConnectionInfoRequest#connection.(connection_)
188 {
189 statecxx . . $ ConnectionInfoRequest#state. = GET_MACHINEcxx . . $ ConnectionInfoRequest#GET_MACHINE.;
190 connectioncxx . . $ ConnectionInfoRequest#connection..sendCommandcxx . . $ OpenMSXConnection#sendCommand(6fe5d9dff2ed3a64).(this);
191 }
192
193 QStringcxx . . $ QString# ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::getCommandcxx . . $ ConnectionInfoRequest#getCommand(6ef7b6c27b00b43d).() const
194 {
195 switch (statecxx . . $ ConnectionInfoRequest#state.) {
196 case GET_MACHINEcxx . . $ ConnectionInfoRequest#GET_MACHINE.:
197 return "machine_info config_name"cxx . . $ QString#QString(85c52e162fed56f9).;
198 case GET_TITLEcxx . . $ ConnectionInfoRequest#GET_TITLE.:
199 return "guess_title"cxx . . $ QString#QString(85c52e162fed56f9).;
200 default:
201 assertcxx . . $ `/usr/include/assert.h:102:11`!(false);
202 return ""cxx . . $ QString#QString(85c52e162fed56f9).;
203 }
204 }
205
206 void ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::replyOkcxx . . $ ConnectionInfoRequest#replyOk(3520e46b33348bf6).(const QStringcxx . . $ QString#& message)
207 {
208 switch (statecxx . . $ ConnectionInfoRequest#state.) {
209 case GET_MACHINEcxx . . $ ConnectionInfoRequest#GET_MACHINE.:
210 titlecxx . . $ ConnectionInfoRequest#title. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). message;
211 statecxx . . $ ConnectionInfoRequest#state. = GET_TITLEcxx . . $ ConnectionInfoRequest#GET_TITLE.;
212 connectioncxx . . $ ConnectionInfoRequest#connection..sendCommandcxx . . $ OpenMSXConnection#sendCommand(6fe5d9dff2ed3a64).(this);
213 break;
214 case GET_TITLEcxx . . $ ConnectionInfoRequest#GET_TITLE.: {
215 if (!message.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) {
216 titlecxx . . $ ConnectionInfoRequest#title. +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). " (" +cxx . . $ operator+(c75c3ae4eb9af1a8). message +cxx . . $ operator+(3d22f08efddf8107). ")";
217 }
218 dialogcxx . . $ ConnectionInfoRequest#dialog..connectionOkcxx . . $ ConnectDialog#connectionOk(a1ca1cb98e356a15).(connectioncxx . . $ ConnectionInfoRequest#connection., titlecxx . . $ ConnectionInfoRequest#title.);
219 statecxx . . $ ConnectionInfoRequest#state. = DONEcxx . . $ ConnectionInfoRequest#DONE.;
220 connectcxx . . $ QObject#connect(835f87066c895669).(&connectioncxx . . $ ConnectionInfoRequest#connection., &OpenMSXConnectioncxx . . $ OpenMSXConnection#::disconnectedcxx . . $ OpenMSXConnection#disconnected(49f6e7a06ebc5aa8).,
221 this, &ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::terminatecxx . . $ ConnectionInfoRequest#terminate(49f6e7a06ebc5aa8).);
222 break;
223 }
224 default:
225 assertcxx . . $ `/usr/include/assert.h:102:11`!(false);
226 }
227 }
228
229 void ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::replyNokcxx . . $ ConnectionInfoRequest#replyNok(3520e46b33348bf6).(const QStringcxx . . $ QString#& /*message*/)
230 {
231 cancelcxx . . $ ConnectionInfoRequest#cancel(49f6e7a06ebc5aa8).();
232 }
233
234 void ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::cancelcxx . . $ ConnectionInfoRequest#cancel(49f6e7a06ebc5aa8).()
235 {
236 dialogcxx . . $ ConnectionInfoRequest#dialog..connectionBadcxx . . $ ConnectDialog#connectionBad(b9dca5a207e4253a).(connectioncxx . . $ ConnectionInfoRequest#connection.);
237 }
238
239 void ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#::terminatecxx . . $ ConnectionInfoRequest#terminate(49f6e7a06ebc5aa8).()
240 {
241 cancelcxx . . $ ConnectionInfoRequest#cancel(49f6e7a06ebc5aa8).();
242 }
243
244 // class ConnectDialog
245
246 std::unique_ptrcxx . . $ std/unique_ptr#<OpenMSXConnectioncxx . . $ OpenMSXConnection#> ConnectDialogcxx . . $ ConnectDialog#::getConnectioncxx . . $ ConnectDialog#getConnection(9b2344118b04506e).(QWidgetcxx . . $ QWidget#* parent)
247 {
248 ConnectDialogcxx . . $ ConnectDialog# dialogcxx . . $ ConnectDialog#ConnectDialog(108f35f7aa7f3cf9).(parent);
249
250 // delay for at most 500ms while checking the connections
251 dialog.delaycxx . . $ ConnectDialog#delay. = 1;
252 dialog.startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(500);
253 while (!dialog.pendingConnectionscxx . . $ ConnectDialog#pendingConnections..emptycxx . . $ std/vector#empty(3482b152b9333168).() && dialog.delaycxx . . $ ConnectDialog#delay.) {
254 qAppcxx . . $ `<external>/6022697617041041825/qapplication.h:70:9`!->processEventscxx . . $ QCoreApplication#processEvents(2a6be7cf0625f73b).(QEventLoopcxx . . $ QFlags#QFlags(93d577a3e9528307).::AllEventscxx . . $ QEventLoop#AllEvents., 200);
255 }
256
257 // if there is only one valid connection, use it immediately,
258 // otherwise execute the dialog.
259 if (dialog.pendingConnectionscxx . . $ ConnectDialog#pendingConnections..emptycxx . . $ std/vector#empty(3482b152b9333168).() && dialog.confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() == 1) {
260 dialog.on_connectButton_clickedcxx . . $ ConnectDialog#on_connectButton_clicked(49f6e7a06ebc5aa8).();
261 } else {
262 dialog.execcxx . . $ QDialog#exec(b126dc7c1de90089).();
263 }
264 return stdcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).::movecxx . . $ std/move(e35c19a1ba7baa26).(dialog.resultcxx . . $ ConnectDialog#result.);
265 }
266
267 ConnectDialogcxx . . $ ConnectDialog#::ConnectDialogcxx . . $ ConnectDialog#ConnectDialog(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent)
268 : QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).(parent)
269 , resultcxx . . $ ConnectDialog#result.(nullptr)
270 {
271 uicxx . . $ ConnectDialog#ui..setupUicxx . . $ Ui_ConnectDialog#setupUi(d194de0c0f68c28b).(this);
272 connectcxx . . $ QObject#connect(835f87066c895669).(uicxx . . $ ConnectDialog#ui..connectButtoncxx . . $ Ui_ConnectDialog#connectButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &ConnectDialogcxx . . $ ConnectDialog#::on_connectButton_clickedcxx . . $ ConnectDialog#on_connectButton_clicked(49f6e7a06ebc5aa8).);
273 connectcxx . . $ QObject#connect(835f87066c895669).(uicxx . . $ ConnectDialog#ui..rescanButtoncxx . . $ Ui_ConnectDialog#rescanButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &ConnectDialogcxx . . $ ConnectDialog#::on_rescanButton_clickedcxx . . $ ConnectDialog#on_rescanButton_clicked(49f6e7a06ebc5aa8).);
274 on_rescanButton_clickedcxx . . $ ConnectDialog#on_rescanButton_clicked(49f6e7a06ebc5aa8).();
275 }
276
277 ConnectDialogcxx . . $ ConnectDialog#::~cxx . . $ ConnectDialog#`~ConnectDialog`(ced63f7c635d850d).ConnectDialogcxx . . $ ConnectDialog#()
278 {
279 clearcxx . . $ ConnectDialog#clear(49f6e7a06ebc5aa8).();
280 }
281
282 void ConnectDialogcxx . . $ ConnectDialog#::timerEventcxx . . $ ConnectDialog#timerEvent(b9e57d1150f23bf5).(QTimerEventcxx . . $ QTimerEvent#* event)
283 {
284 killTimercxx . . $ QObject#killTimer(d4f767463ce0a6b3).(event->timerIdcxx . . $ QTimerEvent#timerId(455f465bc33b4cdf).());
285 delaycxx . . $ ConnectDialog#delay. = 0;
286 }
287
288 void ConnectDialogcxx . . $ ConnectDialog#::clearcxx . . $ ConnectDialog#clear(49f6e7a06ebc5aa8).()
289 {
290 uicxx . . $ ConnectDialog#ui..listConnectionscxx . . $ Ui_ConnectDialog#listConnections.->clearcxx . . $ QListWidget#clear(49f6e7a06ebc5aa8).();
291
292 // First kill the infos. That will remove the disconnect signals.
293 qDeleteAllcxx . . $ qDeleteAll(77d9f17553126ecb).(connectionInfoscxx . . $ ConnectDialog#connectionInfos.);
294 connectionInfoscxx . . $ ConnectDialog#connectionInfos..clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).();
295 pendingConnectionscxx . . $ ConnectDialog#pendingConnections..clearcxx . . $ std/vector#clear(ced63f7c635d850d).();
296 confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..clearcxx . . $ std/vector#clear(ced63f7c635d850d).();
297 }
298
299 void ConnectDialogcxx . . $ ConnectDialog#::on_connectButton_clickedcxx . . $ ConnectDialog#on_connectButton_clicked(49f6e7a06ebc5aa8).()
300 {
301 if (int row = uicxx . . $ ConnectDialog#ui..listConnectionscxx . . $ Ui_ConnectDialog#listConnections.->currentRowcxx . . $ QListWidget#currentRow(455f465bc33b4cdf).();
302 row != -1) {
303 assertcxx . . $ `/usr/include/assert.h:102:11`!((0 <= row) && (row < int(confirmedConnections.size())));
304 resultcxx . . $ ConnectDialog#result. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). std::movecxx . . $ std/move(e35c19a1ba7baa26).(confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).row]);
305 confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..erasecxx . . $ std/vector#erase(351407f384f345bc).(confirmedConnectionscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640)..begincxx . . $ std/vector#begin(55a6de06420d4903).() +cxx . . $ __gnu_cxx/__normal_iterator#operator+(192bf940fa7bb3b2). row);
306 }
307 acceptcxx . . $ QDialog#accept(49f6e7a06ebc5aa8).();
308 }
309
310 void ConnectDialogcxx . . $ ConnectDialog#::on_rescanButton_clickedcxx . . $ ConnectDialog#on_rescanButton_clicked(49f6e7a06ebc5aa8).()
311 {
312 clearcxx . . $ ConnectDialog#clear(49f6e7a06ebc5aa8).();
313 pendingConnectionscxx . . $ ConnectDialog#pendingConnections. =cxx . . $ std/vector#`operator=`(1104576815caab1a). collectServerscxx . . $ collectServers(513aff86fb05de5f).();
314 for (auto& connection : pendingConnectionscxx . . $ ConnectDialog#pendingConnections.) {
315 connectionInfoscxx . . $ ConnectDialog#connectionInfos..appendcxx . . $ QList#append(77d9f17553126ecb).(new ConnectionInfoRequestcxx . . $ ConnectionInfoRequest#ConnectionInfoRequest(2be82e0c2bffd3e4).(*this, *cxx . . $ std/unique_ptr#`operator*`(26c95836c1e8ca05).connection));
316 }
317 }
318
319 void ConnectDialogcxx . . $ ConnectDialog#::connectionOkcxx . . $ ConnectDialog#connectionOk(a1ca1cb98e356a15).(OpenMSXConnectioncxx . . $ OpenMSXConnection#& connection,
320 const QStringcxx . . $ QString#& title)
321 {
322 auto it = rangescxx . . $ ranges/::findcxx . . $ ranges/find(c6b1973d0ee1b721).(pendingConnectionscxx . . $ ConnectDialog#pendingConnections., &connection, [](auto& e) { return e.get(); });
323 if (it ==cxx . . $ __gnu_cxx/`operator==`(30ee64f2df4eef8b). pendingConnectionscxx . . $ ConnectDialog#pendingConnections..endcxx . . $ std/vector#end(55a6de06420d4903).()) {
324 // connection is already being destoyed
325 return;
326 }
327 confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(std::movecxx . . $ std/move(e35c19a1ba7baa26).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it));
328 pendingConnectionscxx . . $ ConnectDialog#pendingConnections..erasecxx . . $ std/vector#erase(351407f384f345bc).(itcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640).);
329
330 new QListWidgetItemcxx . . $ QListWidgetItem#(title, uicxx . . $ ConnectDialog#ui..listConnectionscxx . . $ Ui_ConnectDialog#listConnections.);
331
332 if (uicxx . . $ ConnectDialog#ui..listConnectionscxx . . $ Ui_ConnectDialog#listConnections.->countcxx . . $ QListWidget#count(455f465bc33b4cdf).() == 1) {
333 // automatically select first row
334 uicxx . . $ ConnectDialog#ui..listConnectionscxx . . $ Ui_ConnectDialog#listConnections.->setCurrentRowcxx . . $ QListWidget#setCurrentRow(d4f767463ce0a6b3).(0);
335 }
336 }
337
338 void ConnectDialogcxx . . $ ConnectDialog#::connectionBadcxx . . $ ConnectDialog#connectionBad(b9dca5a207e4253a).(OpenMSXConnectioncxx . . $ OpenMSXConnection#& connection)
339 {
340 auto find = [](auto& coll, auto& conn) {
341 return rangescxx . . $ ranges/::findcxx . . $ ranges/find(9e10fecdb7a9cf11).(coll, &cxx . . $ `operator&`(400e300191122050).conn, [](auto& e) { return e.get(); });
342 };
343
344 if (auto it = find(cxx . . $ ConnectDialog#connectionBad(b9dca5a207e4253a).$anonymous_type_0#`operator()`(1097621cbe24e9b6).pendingConnectionscxx . . $ ConnectDialog#pendingConnections., connection);
345 it !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). pendingConnectionscxx . . $ ConnectDialog#pendingConnections..endcxx . . $ std/vector#end(55a6de06420d4903).()) {
346 pendingConnectionscxx . . $ ConnectDialog#pendingConnections..erasecxx . . $ std/vector#erase(351407f384f345bc).(itcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640).);
347 } else if (auto it2 = find(cxx . . $ ConnectDialog#connectionBad(b9dca5a207e4253a).$anonymous_type_0#`operator()`(1097621cbe24e9b6).confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections., connection);
348 it2 !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..endcxx . . $ std/vector#end(55a6de06420d4903).()) {
349 // Was this connection established but terminated?
350 int id = std::distancecxx . . $ std/distance(4883b9d540cf40e9).(confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..begincxx . . $ std/vector#begin(55a6de06420d4903).(), it2);
351 QListWidgetItemcxx . . $ QListWidgetItem#* item = uicxx . . $ ConnectDialog#ui..listConnectionscxx . . $ Ui_ConnectDialog#listConnections.->takeItemcxx . . $ QListWidget#takeItem(ffbac97cfc278ea8).(id);
352 delete item;
353
354 confirmedConnectionscxx . . $ ConnectDialog#confirmedConnections..erasecxx . . $ std/vector#erase(351407f384f345bc).(it2cxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640).);
355 }
356 }