void MainWindow::doClientStateChanged( int status) { // qDebug() << "ClientStateChanged: state=" << status; if ((status == ArnClient::ConnectStat::Negotiating) && !_arnClient->isReContact()) { //// Initialy connected for negotiation and login // qDebug() << "ClientStateChanged Negotiating (!reContact):"; _wasContact = true; _arnClient->setAutoConnect( true, 2); disconnect( _arnClient, SIGNAL(tcpError(QString,QAbstractSocket::SocketError)), this, SLOT(clientError(QString))); _appSettings->setValue("connect/host", _ui->hostEdit->text()); _appSettings->setValue("connect/port", _ui->portEdit->value()); } else if ((status == ArnClient::ConnectStat::Connected) && !_arnClient->isReConnect()) { //// Fully connected also after any negotiation and login, but not reconnected // qDebug() << "ClientStateChanged Connected (!reConnect):"; _wasConnect = true; if (_ui->arnView->model()) { // model already set, just reset viewer _arnModel->clear(); // Needed after a canceled login (why?) _ui->arnView->reset(); } else // model has not been set, do it now _ui->arnView->setModel( _arnModel); _arnModel->setHideBidir( _ui->hideBidir->isChecked()); _ui->releaseButton->setEnabled( true); _ui->vcsButton->setEnabled( true); _ui->connectButton->setEnabled( true); _ui->manageButton->setEnabled( true); _delegate = qobject_cast<MultiDelegate*>( _ui->arnView->itemDelegate()); if (!_delegate) { _delegate = new MultiDelegate; connect( _delegate, SIGNAL(itemEditTrigged(QModelIndex)), this, SLOT(onItemEditTrigg(QModelIndex))); } _ui->arnView->setItemDelegate( _delegate); _ui->arnView->setEnabled( true); _ui->arnView->setColumnWidth(0, _pathWidth); _ui->arnView->setColumnWidth(1, 10); _chatServWin->reset(); setCurItemPath(); } else if ((status == ArnClient::ConnectStat::Disconnected) && !_isConnect) { //// Manual disconnection from user // qDebug() << "ClientStateChanged Manual Disconnect:"; setConnectOffGui(); } _ui->connectStat->setChecked( (status == ArnClient::ConnectStat::Connected) || ((status == ArnClient::ConnectStat::Negotiating) && _isLoginCancel)); _ui->connectStat->setVisible( _wasContact); _ui->chatButton->setVisible( _wasConnect); }
OpenNIC::OpenNIC(QWidget *parent) : inherited(parent) , mActionSettings(NULL) , mActionAbout(NULL) , mActionQuit(NULL) , mTrayIcon(NULL) , mTrayIconMenu(NULL) , ui(new Ui::OpenNICSettings) , mRefreshTimer(0) , mPacketState(0) , mPacketLength(0) , mTcpListenPort(0) , mInitialized(false) , mBalloonIcon(QSystemTrayIcon::Information) , mActiveState(false) , mScoreRulesTextChanged(false) { ui->setupUi(this); createActions(); createTrayIcon(); QObject::connect(this,SIGNAL(accepted()),this,SLOT(writeSettings())); mTcpSocket.close(); mBalloonStatus = tr("Initializing..."); mRefreshTimer = startTimer(DEFAULT_REFRESH); mLocalNet = new OpenNICNet(&mTcpSocket); QObject::connect(mLocalNet,SIGNAL(dataReady(OpenNICNet*)),this,SLOT(dataReady(OpenNICNet*))); QObject::connect(&mTcpSocket,SIGNAL(connected()),this,SLOT(tcpConnected())); QObject::connect(&mTcpSocket,SIGNAL(disconnected()),this,SLOT(tcpDisconnected())); QObject::connect(&mTcpSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(tcpError(QAbstractSocket::SocketError))); QObject::connect(&mTcpSocket,SIGNAL(stateChanged(QAbstractSocket::SocketState)),this,SLOT(tcpStateChanged(QAbstractSocket::SocketState))); QObject::connect(&mTcpSocket,SIGNAL(hostFound()),this,SLOT(tcpHostFound())); QObject::connect(this,SIGNAL(accepted()),this,SLOT(update())); QObject::connect(ui->saveT1List,SIGNAL(clicked()),this,SLOT(updateT1List())); QObject::connect(ui->buttonBox,SIGNAL(clicked(QAbstractButton*)),this,SLOT(clicked(QAbstractButton*))); QObject::connect(ui->refreshNow,SIGNAL(clicked()),this,SLOT(updateDNS())); QObject::connect(ui->tabs,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int))); QObject::connect(ui->saveDomains,SIGNAL(clicked()),this,SLOT(updateDomains())); QObject::connect(ui->resolverPoolTable,SIGNAL(cellClicked(int,int)),this,SLOT(cellClicked(int,int))); QObject::connect(ui->resolverPoolTable,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(cellDoubleClicked(int,int))); QObject::connect(ui->scoreRuleEditor,SIGNAL(textChanged()),this,SLOT(scoreRuleEditorTextChanged())); setDisabledState(); }
int SocketManager::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: showMessage((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 1: displayMbkImage((*reinterpret_cast< const MbkImage(*)>(_a[1]))); break; case 2: displayYzmImage((*reinterpret_cast< const YzmImage(*)>(_a[1]))); break; case 3: connected((*reinterpret_cast< SocketManager*(*)>(_a[1]))); break; case 4: loginResult((*reinterpret_cast< eLoginResult(*)>(_a[1]))); break; case 5: readyRead(); break; case 6: tcpError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break; case 7: doConnected(); break; case 8: doDisconnected(); break; default: ; } _id -= 9; } return _id; }
void MainWindow::connection( bool isConnect) { bool wasConnect = _wasConnect; setConnectionState( isConnect); _isLoginCancel = false; _ui->connectButton->setEnabled( false); if (isConnect) { connect( _arnClient, SIGNAL(tcpError(QString,QAbstractSocket::SocketError)), this, SLOT(clientError(QString))); //// Setup WhoIAm Arn::XStringMap wimXsm; wimXsm.add("Agent", "Arn Browser - " + ver); wimXsm.add("UserName", _settings->d.userName); wimXsm.add("Contact", _settings->d.contact); wimXsm.add("Location", _settings->d.location); _arnClient->setWhoIAm( wimXsm); _arnClient->connectToArn( _ui->hostEdit->text(), _ui->portEdit->value()); _connector->setCurHost( _ui->hostEdit->text()); _ui->discoverButton->setVisible( false); _ui->hostEdit->setEnabled( false); _ui->portEdit->setEnabled( false); } else if (wasConnect) { _arnModel->clear(); ArnClient::ConnectStat stat = _arnClient->connectStatus(); if ((stat != ArnClient::ConnectStat::Connected) // No contact with server && (stat != ArnClient::ConnectStat::Negotiating)) setConnectOffGui(); _arnClient->close(); } else { // Never got connected but got contact, model not dirty _arnClient->close(); setConnectOffGui(); } }