void SocketInitiator::onDisconnect( SocketConnector&, int s ) { QF_STACK_PUSH(SocketInitiator::onDisconnect) SocketConnections::iterator i = m_connections.find( s ); SocketConnections::iterator j = m_pendingConnections.find( s ); SocketConnection* pSocketConnection = 0; if( i != m_connections.end() ) pSocketConnection = i->second; if( j != m_pendingConnections.end() ) pSocketConnection = j->second; if( !pSocketConnection ) return; setDisconnected( pSocketConnection->getSession()->getSessionID() ); Session* pSession = pSocketConnection->getSession(); if ( pSession ) { pSession->disconnect(); setDisconnected( pSession->getSessionID() ); } delete pSocketConnection; m_connections.erase( s ); m_pendingConnections.erase( s ); QF_STACK_POP }
AMCPDevice::AMCPDevice(QObject* parent) : QObject(parent), command(AMCPDevice::NONE), state(AMCPDevice::ExpectingHeader), connected(false) { this->socket = new QTcpSocket(this); QObject::connect(this->socket, SIGNAL(readyRead()), this, SLOT(readMessage())); QObject::connect(this->socket, SIGNAL(connected()), this, SLOT(setConnected())); QObject::connect(this->socket, SIGNAL(disconnected()), this, SLOT(setDisconnected())); }
void MainWindow::connected() { ui->Ustawienia_status->setText("Połączony"); ui->Ustawienia_b_zaloguj->setText("Wyloguj"); ui->Ustawienia_b_zaloguj->setEnabled(true); //trayIconMenu->addAction(wiadomosciAction); disconnect (ui->Ustawienia_b_zaloguj, SIGNAL(clicked()), this, SLOT(zalogujButtonClicked())); connect (ui->Ustawienia_b_zaloguj, SIGNAL(clicked()), this, SLOT(setDisconnected())); }
AMCPDevice::AMCPDevice(const QString& address, int port, QObject* parent) : QObject(parent), command(AMCPDevice::NONE), port(port), state(AMCPDevice::ExpectingHeader), connected(false), address(address) { this->socket = new QTcpSocket(this); connect(this->socket, SIGNAL(readyRead()), this, SLOT(readMessage())); connect(this->socket, SIGNAL(connected()), this, SLOT(setConnected())); connect(this->socket, SIGNAL(disconnected()), this, SLOT(setDisconnected())); }
NTFCDevice::NTFCDevice(const QString& address, int port, QObject* parent) : QObject(parent), command(NTFCDevice::NONE), port(port), connected(false), address(address) { this->socket = new QTcpSocket(this); //QObject::connect(this->socket, SIGNAL(readyRead()), this, SLOT(readMessage())); QObject::connect(this->socket, SIGNAL(connected()), this, SLOT(setConnected())); QObject::connect(this->socket, SIGNAL(disconnected()), this, SLOT(setDisconnected())); }
MtpMediaDevice::MtpMediaDevice() : MediaDevice() { m_name = i18n("MTP Media Device"); m_device = 0; m_folders = 0; m_playlistItem = 0; setDisconnected(); m_hasMountPoint = false; m_syncStats = false; m_transcode = false; m_transcodeAlways = false; m_transcodeRemove = false; m_configure = false; m_customButton = true; m_transfer = true; KToolBarButton *customButton = MediaBrowser::instance()->getToolBar()->getButton( MediaBrowser::CUSTOM ); customButton->setText( i18n("Special device functions") ); QToolTip::remove( customButton ); QToolTip::add( customButton, i18n( "Special functions of your device" ) ); mtpFileTypes[LIBMTP_FILETYPE_WAV] = "wav"; mtpFileTypes[LIBMTP_FILETYPE_MP3] = "mp3"; mtpFileTypes[LIBMTP_FILETYPE_WMA] = "wma"; mtpFileTypes[LIBMTP_FILETYPE_OGG] = "ogg"; mtpFileTypes[LIBMTP_FILETYPE_AUDIBLE] = "aa"; // audible mtpFileTypes[LIBMTP_FILETYPE_MP4] = "mp4"; mtpFileTypes[LIBMTP_FILETYPE_UNDEF_AUDIO] = "undef-audio"; mtpFileTypes[LIBMTP_FILETYPE_WMV] = "wmv"; mtpFileTypes[LIBMTP_FILETYPE_AVI] = "avi"; mtpFileTypes[LIBMTP_FILETYPE_MPEG] = "mpg"; mtpFileTypes[LIBMTP_FILETYPE_ASF] = "asf"; mtpFileTypes[LIBMTP_FILETYPE_QT] = "mov"; mtpFileTypes[LIBMTP_FILETYPE_UNDEF_VIDEO] = "undef-video"; mtpFileTypes[LIBMTP_FILETYPE_JPEG] = "jpg"; mtpFileTypes[LIBMTP_FILETYPE_JFIF] = "jpg"; mtpFileTypes[LIBMTP_FILETYPE_TIFF] = "tiff"; mtpFileTypes[LIBMTP_FILETYPE_BMP] = "bmp"; mtpFileTypes[LIBMTP_FILETYPE_GIF] = "gif"; mtpFileTypes[LIBMTP_FILETYPE_PICT] = "pict"; mtpFileTypes[LIBMTP_FILETYPE_PNG] = "png"; mtpFileTypes[LIBMTP_FILETYPE_VCALENDAR1] = "vcs"; // vcal1 mtpFileTypes[LIBMTP_FILETYPE_VCALENDAR2] = "vcs"; // vcal2 mtpFileTypes[LIBMTP_FILETYPE_VCARD2] = "vcf"; // vcard2 mtpFileTypes[LIBMTP_FILETYPE_VCARD3] = "vcf"; // vcard3 mtpFileTypes[LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT] = "wim"; // windows image format mtpFileTypes[LIBMTP_FILETYPE_WINEXEC] = "exe"; mtpFileTypes[LIBMTP_FILETYPE_TEXT] = "txt"; mtpFileTypes[LIBMTP_FILETYPE_HTML] = "html"; mtpFileTypes[LIBMTP_FILETYPE_UNKNOWN] = "unknown"; m_newTracks = new QPtrList<MediaItem>; }
squeeze::squeeze() : KXmlGuiWindow( ), m_view(new squeezeView(this)), m_printer(0) { setObjectName(QLatin1String("squeeze")); // accept dnd setAcceptDrops(false); // tell the KXmlGuiWindow that this is indeed the main widget setCentralWidget(m_view); // then, setup our actions setupActions(); //Add some widgets to status bar led = new KLed; led->off(); statusBar()->addWidget(led); //FIXME: Que cuando se escriba algo en la barra de status, quede el LED ahi tambien. // add a status bar statusBar()->show(); // Add typical actions and save size/toolbars/statusbar setupGUI(); disableUI(); // allow the view to change the statusbar and caption connect(m_view, SIGNAL(signalChangeStatusbar(const QString&)), this, SLOT(changeStatusbar(const QString&))); connect(m_view, SIGNAL(signalChangeCaption(const QString&)), this, SLOT(changeCaption(const QString&))); connect(m_view, SIGNAL(signalDisconnected()), this, SLOT(setDisconnected())); connect(m_view, SIGNAL(signalConnected()), this, SLOT(setConnected())); connect(m_view, SIGNAL(signalShowPrefs()), SLOT(optionsPreferences()) ); connect(m_view, SIGNAL(signalSalir() ), SLOT(salir() )); connect(m_view, SIGNAL(signalShowDbConfig()), this, SLOT(showDBConfigDialog())); connect(m_view, SIGNAL(signalAdminLoggedOn()), this, SLOT(enableUI())); connect(m_view, SIGNAL(signalAdminLoggedOff()), this, SLOT(disableUI())); connect(m_view, SIGNAL(signalSupervisorLoggedOn()), this, SLOT(enableUI())); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(fixGeom())); timer->setInterval(5000); timer->start(); loadStyle(); }
void ThreadedSocketInitiator::doConnect( const SessionID& s, const Dictionary& d ) { try { Session* session = Session::lookupSession( s ); if( !session->isSessionTime(UtcTimeStamp()) ) return; Log* log = session->getLog(); std::string address; short port = 0; std::string sourceAddress; short sourcePort = 0; getHost( s, d, address, port, sourceAddress, sourcePort ); socket_handle socket = socket_createConnector(); if( m_noDelay ) socket_setsockopt( socket, TCP_NODELAY ); if( m_sendBufSize ) socket_setsockopt( socket, SO_SNDBUF, m_sendBufSize ); if( m_rcvBufSize ) socket_setsockopt( socket, SO_RCVBUF, m_rcvBufSize ); setPending( s ); log->onEvent( "Connecting to " + address + " on port " + IntConvertor::convert((unsigned short)port) + " (Source " + sourceAddress + ":" + IntConvertor::convert((unsigned short)sourcePort) + ")"); ThreadedSocketConnection* pConnection = new ThreadedSocketConnection( s, socket, address, port, getLog(), sourceAddress, sourcePort ); ThreadPair* pair = new ThreadPair( this, pConnection ); { Locker l( m_mutex ); thread_id thread; if ( thread_spawn( &socketThread, pair, thread ) ) { addThread( socket, thread ); } else { delete pair; pConnection->disconnect(); delete pConnection; setDisconnected( s ); } } } catch ( std::exception& ) {} }
void MainWindow::disconnected() { ui->Ustawienia_status->setText("Rozłączony"); ui->Ustawienia_login_input->setEnabled(true); ui->Ustawienia_haslo_input->setEnabled(true); ui->Ustawienia_b_zaloguj->setText("Zaloguj"); ui->Ustawienia_b_zaloguj->setEnabled(true); ui->OMnie->setEnabled(false); ui->Grupy->setEnabled(false); ui->Grupy_list->clear(); ui->Grupy_Czlonkowie_list->clear(); //trayIconMenu->removeAction(wiadomosciAction); disconnect (ui->Ustawienia_b_zaloguj, SIGNAL(clicked()), this, SLOT(setDisconnected())); connect (ui->Ustawienia_b_zaloguj, SIGNAL(clicked()), this, SLOT(zalogujButtonClicked())); }
// Constructor for the SenoCAD class. rc_client::rc_client(QObject *parent) : QObject(parent) { buffer = new QBuffer(this); socket = new QTcpSocket(this); buffer->open(QIODevice::ReadWrite); ///////////////////// /// SIGNALS & SLOTS ///////////////////// connect(socket, SIGNAL(connected()), SLOT(setConnected())); // connect(socket, SIGNAL(disconnected()), SLOT(setDisconnected())); connect(socket, SIGNAL(readyRead()), SLOT(receiveMessage())); setDisconnected(); }
MatlabControlWidget::MatlabControlWidget(QWidget *_parent) : QWidget(_parent) { setupUi(this); connect(connectButton, SIGNAL(clicked()), this, SLOT(connectClicked())); connect(disconnectButton, SIGNAL(clicked()), this, SIGNAL(requestDisconnect())); connect(setPathButton, SIGNAL(clicked()), this, SLOT(showPathDialog())); pathEdit->setEnabled(false); QSettings settings(QApplication::organizationName(), QApplication::applicationName()); QString lastDir = settings.value("matlab/path", QApplication::applicationDirPath()).toString(); pathEdit->setText(lastDir); setDisconnected(); }
void LoginManager::processPasswordState(const QString& aLine, Client &aClient) { auto account = getAccountOrDie(aClient); if(!account) return; //aLine is a password QByteArray passwordBytes; passwordBytes.append(aLine); QString hash = QString(QCryptographicHash::hash(passwordBytes,QCryptographicHash::Md5).toHex()); if(account->getPasswordHash() != hash) { aClient.printRawLine("Wrong password. Disconnecting..."); aClient.setState(EClientStateQuit); return; } //password is correct account->confirmCreation(); aClient.printRawLine("Password is correct. Welcome back, " + account->name() + "."); QVector<unsigned long> characterUids = account->characters(); auto characters = world::objects<Person>(characterUids); if(characters.count() == 1) { //login to the character immediately auto person = characters[0]; if(person) { person->setDisconnected(false); aClient.setState(EClientStateNormal); aClient.linkToPerson(world::World::instance()->objectFactory()->getPtr<Person>(person->uid())); auto clientPtr = world::World::instance()->getClientPtr(aClient.id()); if(!clientPtr) qDebug() << "Bad client ptr for person " << person->name() << " " << QString::number(person->uid()); else person->attachClient(clientPtr); auto room = person->getRoom(); if(room) room->printDescription(*person, aClient); return; } //otherwise show account menu state_ = ELoginStateAccountMenu; } }
void Initiator::stop( bool force ) { if( isStopped() ) return; HttpServer::stopGlobal(); std::vector<Session*> enabledSessions; SessionIDs connected = m_connected; SessionIDs::iterator i = connected.begin(); for ( ; i != connected.end(); ++i ) { Session* pSession = Session::lookupSession(*i); if( pSession && pSession->isEnabled() ) { enabledSessions.push_back( pSession ); pSession->logout(); } } if( !force ) { for ( int second = 1; second <= 10 && isLoggedOn(); ++second ) process_sleep( 1 ); } { Locker l(m_mutex); for ( i = connected.begin(); i != connected.end(); ++i ) setDisconnected( Session::lookupSession(*i)->getSessionID() ); } m_stop = true; onStop(); if( m_threadid ) thread_join( m_threadid ); m_threadid = 0; std::vector<Session*>::iterator session = enabledSessions.begin(); for( ; session != enabledSessions.end(); ++session ) (*session)->logon(); }
void Initiator::initialize() throw ( ConfigError ) { std::set < SessionID > sessions = m_settings.getSessions(); std::set < SessionID > ::iterator i; if ( !sessions.size() ) throw ConfigError( "No sessions defined" ); SessionFactory factory( m_application, m_messageStoreFactory, m_pLogFactory ); for ( i = sessions.begin(); i != sessions.end(); ++i ) { if ( m_settings.get( *i ).getString( "ConnectionType" ) == "initiator" ) { m_sessionIDs.insert( *i ); m_sessions[ *i ] = factory.create( *i, m_settings.get( *i ) ); setDisconnected( *i ); } } if ( !m_sessions.size() ) throw ConfigError( "No sessions defined for initiator" ); }
void clientMessage(std::string command, std::string option, std::string data, IClientSocket *socket) { if(command == "message") insertMessage(option,data); // Client command: connect to a server if(command == "connect"){ clientMessage("/info,connect:"+data); if(state.enableClient == false){ state.client = fusion->Network->CreateSocket(); if(state.client->Connect(data.c_str(),state.port) == true){ state.enableClient = true; // You are connected to the server with a socket // Set your nick, to what it is now // (results not in an update of username, but an // update of the clients username on the server) remoteMessage("/newClient,"+state.username); }else{ clientMessage("/error,connect"); } }else{ clientMessage("/error,connectionPresent"); } } // Client command: disconnect from a server if(command == "disconnect"){ state.client->Disconnect(); state.enableClient = false; setDisconnected(); } // Client command: server accepted your connection if(command == "accepted"){ if(getConnected() == "Connect"){ // Inform the client it has connected successfully clientMessage("/info,accepted"); // Set the identifying code for this client state.id = data; // Set the gui to show connected to a server setConnected(); } } // Client command: informs the client a new user has entered the server if(command == "userConnect") { clientMessage("/info,userConnect:"+option+";"+data); // If the user being added, is you, then set the state.id if(addUser(option,data) == false){ // Error adding the user to the client clientMessage("/error,invalidUsername",socket); }else{ // Should the client do something if addUser succeeded? clientMessage("/info,userConnect"); } } // Client command: informs the client a user has disconnected from the server if(command == "userDisconnect"){} // Client command: show information to the interface if(command == "info") { if(option == "connect") data = "Lets connect to: " + data; if(data == "accepted") data = "connection accepted!"; if(data == "userConnect") data = option + " has entered the room"; if(data == "userDisconnect")data = option + " has left the room"; insertMessage("info",data); } if(command == "error") { // The client failed to connect to the server if(data == "connect") data = "Failed to connect, sorry"; // The connect address was invalid (the network couldnt resolve or understand the address given if(data == "invalidAddress") data = "Try to use a correct hostname/address please"; // The app is running as a server, or the client is already connected // therefore you cannot make another connection until the server is deactivated // or the client, disconnected. if(data == "connectionPresent") data = "Cannot connect, Server running, or client already connected"; // The username is invalid (you entered a semi colon?) if(data == "invalidUsername"){ data = "the username requested is invalid, please attempt to choose another"; updateUsername(); } // This is sent from the server in response to an attempt to use an username which already exists there // it says userFound, so you can choose another username and attempt again if(data == "userFound"){ data = "Server reported this username is not available"; updateUsername(); } insertMessage("error",data); } }
DwarfClipboard::DwarfClipboard() { setupUi(this); createActions(); createTrayIcon(); trayIcon->setIcon(QIcon(":/icons/images/DwarfClipboard.png")); trayIcon->show(); setWindowTitle(tr("DwarfClipboard")); inputDelay = 100; thumbnailSize = 64; prevCursor.x = -30000; createShortcuts(); heartbeatTimer = new QTimer(this); connectedLabel = new QLabel(); createConnections(); recentModel = new DwarfClipboardModel(); tableViewRecent->setModel(recentModel); libraryModel = new DwarfClipboardModel(); treeViewLibrary->setModel(libraryModel); DFMgr = NULL; DF = NULL; Pos = NULL; connected = connectToDF(); loadConfig(); thumbnailSizeLineEdit->setText(QString("%1").arg(thumbnailSize)); inputDelayMsLineEdit->setText(QString("%1").arg(inputDelay)); tilesetPathButton->setText(DwarfClipboardPng::getTileSetPath()); colorPathButton->setText(DwarfClipboardPng::getColorPath()); copyShortcutButton->setText(copyShortcut->shortcut()); pasteDesignationShortcutButton->setText(pasteDesignationShortcut->shortcut()); pasteBuildingShortcutButton->setText(pasteBuildingShortcut->shortcut()); setCursorToPreviousPasteShortcutButton->setText(setCursorToPreviousPasteShortcut->shortcut()); heartbeatTimer->start(1000); Ui_MainWindow::statusBar->addPermanentWidget(connectedLabel); connectedIcon = QPixmap(":/icons/images/connect.png"); //This mess just converts the disconnected icon to look the same as a disabled one //It is the same code used in the icon object disconnectedIcon = QPixmap(":/icons/images/disconnect.png"); QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap generated = QApplication::style()->generatedIconPixmap(QIcon::Disabled, disconnectedIcon, &opt); disconnectedIcon = generated; loadDirectory(); loadBuildCommands(); if(connected){ connected = false; //this is ugly, but just ensures everything will be set proprly setConnected(); } else{ connected = true; setDisconnected(); } setupViews(); }
void ThreadedSSLSocketInitiator::doConnect(const SessionID &s, const Dictionary &d) { try { Session *session = Session::lookupSession(s); if (!session->isSessionTime(UtcTimeStamp())) return; Log *log = session->getLog(); std::string address; short port = 0; getHost(s, d, address, port); int socket = socket_createConnector(); if (m_noDelay) socket_setsockopt(socket, TCP_NODELAY); if (m_sendBufSize) socket_setsockopt(socket, SO_SNDBUF, m_sendBufSize); if (m_rcvBufSize) socket_setsockopt(socket, SO_RCVBUF, m_rcvBufSize); setPending(s); log->onEvent("Connecting to " + address + " on port " + IntConvertor::convert((unsigned short)port)); SSL *ssl = SSL_new(m_ctx); if (ssl == 0) { log->onEvent("Failed to create ssl object"); return; } SSL_clear(ssl); BIO *sbio = BIO_new_socket(socket, BIO_CLOSE); SSL_set_bio(ssl, sbio, sbio); ThreadedSSLSocketConnection *pConnection = new ThreadedSSLSocketConnection( s, socket, ssl, address, port, getLog()); ThreadPair *pair = new ThreadPair(this, pConnection); { Locker l(m_mutex); thread_id thread; if (thread_spawn(&socketThread, pair, thread)) { addThread(SocketKey(socket, ssl), thread); } else { delete pair; pConnection->disconnect(); delete pConnection; SSL_free(ssl); setDisconnected(s); } } } catch (std::exception &) { } }
NetStats::NetStats(QWidget *parent) : QDialog(parent), _ui(new Ui_NetStats) { _ui->setupUi(this); setDisconnected(); }