@@ -193,41 +193,24 @@ void MainWindow::openDefaultWindows() {
193
193
}
194
194
195
195
void MainWindow::OpenConnection () {
196
- this ->connected (true );
197
196
198
197
Startup su (this );
199
198
su.setModal (true );
200
199
int ret = su.exec ();
201
200
if (ret == QDialog::Accepted) {
202
201
203
202
if (su.getremote () == true ) {
204
- qCDebug (ozwadmin) << " Doing Remote Connection:" << su.getremoteHost () << su.getremotePort ();
205
203
QUrl server;
206
204
server.setHost (su.getremoteHost ());
207
205
server.setPort (su.getremotePort ());
208
206
server.setScheme (" ws" );
209
- qCDebug (ozwadmin) << " Connecting to " << server;
210
- startupprogress *sup = new startupprogress (true , this );
211
- sup->setWindowFlags (Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
212
- sup->setQTOZWManager (OZWCore::get ()->getQTOZWManager ());
213
- sup->show ();
214
- OZWCore::get ()->getQTOZWManager ()->setClientAuth (su.getauthKey ());
215
- OZWCore::get ()->getQTOZWManager ()->initilizeReplica (server);
216
- OZWCore::get ()->settings .setValue (" connection/remotehost" , su.getremoteHost ());
217
- OZWCore::get ()->settings .setValue (" connection/remoteport" , su.getremotePort ());
218
- OZWCore::get ()->settings .setValue (" connection/authKey" , su.getauthKey ());
207
+ connectToRemote (server, su.getauthKey ());
219
208
return ;
220
209
}
221
210
else
222
211
{
223
- qCDebug (ozwadmin) << " Doing Local Connection: " << su.getserialPort () << su.getstartServer ();
224
- startupprogress *sup = new startupprogress (false , this );
225
- sup->setQTOZWManager (OZWCore::get ()->getQTOZWManager ());
226
- sup->show ();
227
- OZWCore::get ()->getQTOZWManager ()->initilizeSource (OZWCore::get ()->settings .value (" StartServer" ).toBool ());
228
- OZWCore::get ()->getQTOZWManager ()->open (su.getserialPort ());
229
- OZWCore::get ()->settings .setValue (" connection/serialport" , su.getserialPort ());
230
212
OZWCore::get ()->settings .setValue (" connection/startserver" , su.getstartServer ());
213
+ connectToLocal (su.getserialPort ());
231
214
return ;
232
215
}
233
216
} else {
@@ -236,6 +219,29 @@ void MainWindow::OpenConnection() {
236
219
}
237
220
238
221
}
222
+
223
+ void MainWindow::connectToLocal (QString serial) {
224
+ this ->connected (true );
225
+ OZWCore::get ()->settings .setValue (" connection/serialport" , serial);
226
+ qCDebug (ozwadmin) << " Doing Local Connection: " << serial << OZWCore::get ()->settings .value (" StartServer" ).toBool ();
227
+ startupprogress *sup = new startupprogress (false , this );
228
+ sup->show ();
229
+ OZWCore::get ()->getQTOZWManager ()->initilizeSource (OZWCore::get ()->settings .value (" connection/startserver" ).toBool ());
230
+ OZWCore::get ()->getQTOZWManager ()->open (serial);
231
+ }
232
+
233
+ void MainWindow::connectToRemote (QUrl server, QString key) {
234
+ this ->connected (true );
235
+ OZWCore::get ()->settings .setValue (" connection/remotehost" , server);
236
+ OZWCore::get ()->settings .setValue (" connection/authKey" , key);
237
+ qCDebug (ozwadmin) << " Doing Remote Connection:" << server;
238
+ startupprogress *sup = new startupprogress (true , this );
239
+ sup->setWindowFlags (Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
240
+ sup->show ();
241
+ OZWCore::get ()->getQTOZWManager ()->setClientAuth (key);
242
+ OZWCore::get ()->getQTOZWManager ()->initilizeReplica (server);
243
+ }
244
+
239
245
void MainWindow::CloseConnection () {
240
246
if (OZWCore::get ()->getQTOZWManager ()->getConnectionType () == QTOZWManager::connectionType::Local) {
241
247
OZWCore::get ()->getQTOZWManager ()->close ();
@@ -325,13 +331,13 @@ void MainWindow::setStatusBarMsg(QString Msg) {
325
331
}
326
332
327
333
void MainWindow::remoteConnectionStatus (QTOZWManager::connectionStatus status, QAbstractSocket::SocketError error) {
328
- Q_UNUSED (error) ;
334
+ qCDebug (ozwadmin) << " Remote Connection Status: " << status << error ;
329
335
if (status == QTOZWManager::connectionStatus::ConnectionErrorState) {
330
- openCriticalDialog (" Connection Error" , " Connection Error" );
336
+ QString errorstr (" Connection Error: %1" );
337
+ openCriticalDialog (" Connection Error" , errorstr.arg (SockErrorToString (error)));
331
338
CloseConnection ();
332
339
} else if (status == QTOZWManager::connectionStatus::VersionMisMatchError) {
333
340
openCriticalDialog (" Version MisMatch" , " The ozwdaemon version is not compatible with this version of ozw-admin" );
334
341
CloseConnection ();
335
342
}
336
-
337
343
}
0 commit comments