void execute() override
	{
		auto* from_node = m_editor.getNodeByID(m_from);
		auto* to_node = m_editor.getNodeByID(m_to);

		removeConnection(from_node, m_from_pin, false);
		removeConnection(to_node, m_to_pin, true);

		from_node->m_outputs[m_from_pin] = to_node;
		to_node->m_inputs[m_to_pin] = from_node;
	}
Beispiel #2
0
void Server::handleNetworkMessages() {
	RakNet::Packet* pPacket = nullptr;

	while (true) {

		CalculateDeltaTime();

		for (	pPacket = m_pPeerInterface->Receive();
				pPacket;
				m_pPeerInterface->DeallocatePacket(pPacket), pPacket = m_pPeerInterface->Receive()) {

			switch (pPacket->data[0]) {
			case ID_NEW_INCOMING_CONNECTION: {
				addNewConnection(pPacket->systemAddress);
				std::cout << "A connection is incoming.\n";
				break;
			}
			case ID_DISCONNECTION_NOTIFICATION:
				std::cout << "A client has disconnected.\n";
				removeConnection(pPacket->systemAddress);
				break;
			case ID_CONNECTION_LOST:
				std::cout << "A client lost the connection.\n";
				removeConnection(pPacket->systemAddress);
				break;
			case ID_CLIENT_CREATE_OBJECT:
			{
				RakNet::BitStream bsIn(pPacket->data, pPacket->length, false);
				bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
				createNewObject(bsIn, pPacket->systemAddress);
				break;
			}
			case ID_CLIENT_UPDATE_OBJECT_POSITION:
			{
				RakNet::BitStream bsIn(pPacket->data, pPacket->length, false);
				bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
				moveGameObject(bsIn, pPacket->systemAddress);
				break;
			}
			case ID_CLIENT_UPDATE_OBJECT_VELOCITY:
			{
				pPacket->data[0] = ID_SERVER_VELOCITY_OBJECT_DATA;
				RakNet::BitStream bsIn(pPacket->data, pPacket->length, false);
				//bsIn.IgnoreBytes(sizeof(RakNet::MessageID));			
				m_pPeerInterface->Send(&bsIn, IMMEDIATE_PRIORITY, RELIABLE_ORDERED, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true);
				break;
			}
			default:
				std::cout << "Received a message with a unknown ID: " << pPacket->data[0];
				break;
			}
		}
	}
}
Beispiel #3
0
bool KAccelBase::setActionSlot(const QString &sAction, const QObject *pObjSlot, const char *psMethodSlot)
{
    kdDebug(125) << "KAccelBase::setActionSlot( " << sAction << ", " << pObjSlot << ", " << psMethodSlot << " )\n";
    KAccelAction *pAction = m_rgActions.actionPtr(sAction);
    if(pAction)
    {
        // If there was a previous connection, remove it.
        if(m_bAutoUpdate && pAction->isConnected())
        {
            kdDebug(125) << "\tm_pObjSlot = " << pAction->m_pObjSlot << " m_psMethodSlot = " << pAction->m_psMethodSlot << endl;
            removeConnection(pAction);
        }

        pAction->m_pObjSlot = pObjSlot;
        pAction->m_psMethodSlot = psMethodSlot;

        // If we're setting a connection,
        if(m_bAutoUpdate && pObjSlot && psMethodSlot)
            insertConnection(pAction);

        return true;
    }
    else
        return false;
}
Beispiel #4
0
void DownloadManager::checkDownloads(UserConnection* aConn) {
    dcassert(aConn->getDownload() == NULL);

    QueueItem::Priority prio = QueueManager::getInstance()->hasDownload(aConn->getUser());
    if(!startDownload(prio)) {
        removeConnection(aConn);
        return;
    }

    Download* d = QueueManager::getInstance()->getDownload(*aConn, aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL));

    if(!d) {
        Lock l(cs);
        aConn->setState(UserConnection::STATE_IDLE);
        idlers.push_back(aConn);
        return;
    }

    aConn->setState(UserConnection::STATE_SND);

    if(aConn->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST) && d->getType() == Transfer::TYPE_FULL_LIST) {
        d->setFlag(Download::FLAG_XML_BZ_LIST);
    }

    {
        Lock l(cs);
        downloads.push_back(d);
    }
    fire(DownloadManagerListener::Requesting(), d);

    dcdebug("Requesting " I64_FMT "/" I64_FMT "\n", static_cast<long long int>(d->getStartPos()), static_cast<long long int>(d->getSize()));

    aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET)));
}
Beispiel #5
0
void ProcessorGraph::clearConnections()
{

    for (int i = 0; i < getNumConnections(); i++)
    {
        const Connection* connection = getConnection(i);

        if (connection->destNodeId == RESAMPLING_NODE_ID ||
            connection->destNodeId == OUTPUT_NODE_ID)
        {
            ; // leave it
        }
        else
        {
            removeConnection(i);
        }
    }

    for (int i = 0; i < getNumNodes(); i++)
    {
        Node* node = getNode(i);

        if (node->nodeId != OUTPUT_NODE_ID)
        {
            GenericProcessor* p =(GenericProcessor*) node->getProcessor();
            p->resetConnections();
        }
    }
}
Beispiel #6
0
void NetInterface::disconnect(NetConnection *conn, NetConnection::TerminationReason reason, const char *reasonString)
{
   if(conn->getConnectionState() == NetConnection::AwaitingChallengeResponse ||
      conn->getConnectionState() == NetConnection::AwaitingConnectResponse)
   {
      conn->onConnectTerminated(reason, reasonString);
      removePendingConnection(conn);
   }
   else if(conn->getConnectionState() == NetConnection::Connected)
   {
      conn->setConnectionState(NetConnection::Disconnected);
      conn->onConnectionTerminated(reason, reasonString);
      if(conn->isNetworkConnection())
      {
         // send a disconnect packet...
         PacketStream out;
         out.write(U8(Disconnect));
         ConnectionParameters &theParams = conn->getConnectionParameters();
         theParams.mNonce.write(&out);
         theParams.mServerNonce.write(&out);
         U32 encryptPos = out.getBytePosition();
         out.setBytePosition(encryptPos);
         out.writeString(reasonString);

         if(theParams.mUsingCrypto)
         {
            SymmetricCipher theCipher(theParams.mSharedSecret);
            out.hashAndEncrypt(NetConnection::MessageSignatureBytes, encryptPos, &theCipher);
         }
         out.sendto(mSocket, conn->getNetAddress());
      }
      removeConnection(conn);
   }
}
 void SimpleRecurrentNetwork::removeNeuron(int sp)
 {
     removeConnection(NUM_INPUTS + sp);
     --numNeurons;
     delete pop[sp];
     pop.erase(pop.begin() + sp);
 }
Beispiel #8
0
void QuickInterpreter::clear()
{
//     printf("QuickInterpreter::clear()\n");
    // Clear all connections
    while (m_script_connections.size()) {
        QHash<int, QSAConnection>::Iterator it = m_script_connections.begin();
//         printf(" -> removing connection: %d\n", it.key());
        removeConnection(it->sender, it->signal.toLatin1(), it->function_ref);
    }

    // clean out slots
    delete m_dynamic_slots;
    m_dynamic_slots = 0;

    sourceIdNames.clear();
    debuggerEngine()->clear();
    qsKillTimers(env());
    invalidateWrappers();

    if(toplevel)
	toplevel->clear();
    QSEngine::clear();
    QSEngine::init();
    init();
}
Beispiel #9
0
bool Database::removeBase(QString filename)
{
    emit toDebug(objectName(),
            QString("Удаляем старую базу '%1'.").arg(filename));

    removeConnection();
    QFile f(filename);
    if(f.exists())
    {
        if(f.remove())
        {
            emit toDebug(objectName(),
                         QString("База '%1' успешно удалена.").arg(filename));
            return true;
        }
        else
        {
            emit toDebug(objectName(),
                         QString("Невозможно удалить файл '%1'. Ошибка: %2")
                         .arg(filename)
                         .arg(f.errorString()));
            return false;
        }
    }
    else
    {
        emit toDebug(objectName(),
                QString("Невозможно удалить файл '%1'. Файл не существует.")
                     .arg(filename));
        return true;
    }
}
Beispiel #10
0
	virtual void internalTransition(const vle::devs::Time& /*time*/)
	{
		if (mSended == false) {
			// Ajout des connexions mod�le coupl� -> mod�le sum
			const vle::vpz::ConnectionList& inputs = coupledmodel().getInputPortList();
			vle::vpz::ConnectionList::const_iterator it;
			
			/* DEBUG : affiche les connections
			for (it = inputs.begin(); it != inputs.end(); ++it) {
				std::cout << "model: " << getModel().getParentName() << it->first << std::endl;
			}*/
			
			for (it = inputs.begin(); it != inputs.end(); ++it) {
				if (it->first.size() >= 5 and it->first.compare(0, 5, "node-") == 0) {
					addInputPort("Deposition", it->first);
					addConnection(coupledmodelName(), it->first, "Deposition", it->first);
					mPortList.push_back(it->first);
				}
			}

			// Pour les mod�les sans d�pendances
			if (mPortList.empty()){
				createModelFromClass("node-init", "node-init");
				//delModel("Deposition");
				removeConnection("Deposition", "update", "Unit", "in");	
				addConnection("node-init", "update", "Unit", "in");
			}
			mSended = true;
		} else {
			mSended = false;
		}
    }
void AutomatableModelViewSlots::execConnectionDialog()
{
	// TODO[pg]: Display a dialog with list of controllers currently in the song
	// in addition to any system MIDI controllers
	AutomatableModel* m = m_amv->modelUntyped();

	m->displayName();
	ControllerConnectionDialog d( (QWidget*) engine::mainWindow(), m );

	if( d.exec() == 1 )
	{
		// Actually chose something
		if( d.chosenController() )
		{
			// Update
			if( m->controllerConnection() )
			{
				m->controllerConnection()->setController( d.chosenController() );
			}
			// New
			else
			{
				ControllerConnection* cc = new ControllerConnection( d.chosenController() );
				m->setControllerConnection( cc );
				//cc->setTargetName( m->displayName() );
			}
		}
		// no controller, so delete existing connection
		else
		{
			removeConnection();
		}
	}
}
Beispiel #12
0
void NetInterface::handleDisconnect(const Address &address, BitStream *stream)
{
   NetConnection *conn = findConnection(address);
   if(!conn)
      return;

   ConnectionParameters &theParams = conn->getConnectionParameters();

   Nonce nonce, serverNonce;
   char reason[256];

   nonce.read(stream);
   serverNonce.read(stream);

   if(nonce != theParams.mNonce || serverNonce != theParams.mServerNonce)
      return;

   U32 decryptPos = stream->getBytePosition();
   stream->setBytePosition(decryptPos);

   if(theParams.mUsingCrypto)
   {
      SymmetricCipher theCipher(theParams.mSharedSecret);
      if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, decryptPos, &theCipher))
         return;
   }
   stream->readString(reason);

   conn->setConnectionState(NetConnection::Disconnected);
   conn->onConnectionTerminated(NetConnection::ReasonRemoteDisconnectPacket, reason);
   removeConnection(conn);
}
void ConnectionManager::removePoint(Connection *c, int point) {
	c->points.erase(c->points.begin() + point);
	if (c->points.size() < 2) {
		removeConnection(c);
	}
	movePins(c->from);
	movePins(c->to);
}
Beispiel #14
0
void NetHandler::doCloseConnection(int fd)
{
    if (fd > 0)
    {
        FD_CLR(fd, &master);
        shutdown(fd, SD_BOTH);
        removeConnection(fd);
    }
}
void WindowSystem::handleConnection()
{
    qDebug() << "SERVER: client connected";
    if (QTcpSocket *connection = m_server->nextPendingConnection()) {
        connect(connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleConnectionError()));
        connect(connection, SIGNAL(readyRead()), this, SLOT(handleRequest()));
        connect(connection, SIGNAL(disconnected()), this, SLOT(removeConnection()));
    }
}
Beispiel #16
0
void Network::adminStop(){
  ConnMap::iterator itcurr = connections.begin();
  while (itcurr != connections.end()) {
    if ( itcurr->second->getType() == Connection::ADMIN || 
         itcurr->second->getType() == Connection::LISTENADMIN )
      removeConnection(itcurr->first);
    ++itcurr;
  }
}
Beispiel #17
0
void ManaChatServer::addConnection()
{
    qDebug() <<"new connect";
	QTcpSocket* connection = nextPendingConnection();
	connections.append(connection);
	QBuffer* buffer = new QBuffer(this);
	buffer->open(QIODevice::ReadWrite);
	buffers.insert(connection, buffer);
	connect(connection, SIGNAL(disconnected()), SLOT(removeConnection()));
	connect(connection, SIGNAL(readyRead()),	SLOT(receiveMessage()));
}
void OutgoingStreamTubeChannel::onContactsRetrieved(
        const QUuid &uuid,
        const QList<Tp::ContactPtr> &contacts)
{
    if (!isValid()) {
        debug() << "Invalidated OutgoingStreamTubeChannel not emitting queued connection event";
        return;
    }

    if (!mPriv->pendingNewConnections.contains(uuid)) {
        if (mPriv->pendingClosedConnections.contains(uuid)) {
            // closed connection
            Private::ClosedConnection conn = mPriv->pendingClosedConnections.take(uuid);

            // First, do removeConnection() so connectionClosed is emitted, and anybody connected to it
            // (like StreamTubeServer) has a chance to recover the source address / contact
            removeConnection(conn.id, conn.error, conn.message);

            // Remove stuff from our hashes
            mPriv->contactsForConnections.remove(conn.id);

            QHash<QPair<QHostAddress, quint16>, uint>::iterator srcAddrIter =
                mPriv->connectionsForSourceAddresses.begin();
            while (srcAddrIter != mPriv->connectionsForSourceAddresses.end()) {
                if (srcAddrIter.value() == conn.id) {
                    srcAddrIter = mPriv->connectionsForSourceAddresses.erase(srcAddrIter);
                } else {
                    ++srcAddrIter;
                }
            }

            QHash<uchar, uint>::iterator credIter = mPriv->connectionsForCredentials.begin();
            while (credIter != mPriv->connectionsForCredentials.end()) {
                if (credIter.value() == conn.id) {
                    credIter = mPriv->connectionsForCredentials.erase(credIter);
                } else {
                    ++credIter;
                }
            }
        } else {
            warning() << "No pending connections found in OSTC" << objectPath() << "for contacts"
                << contacts;
        }

        return;
    }

    // new connection
    QPair<uint, QDBusVariant> connectionProperties = mPriv->pendingNewConnections.take(uuid);

    // Add it to our connections hash
    foreach (const Tp::ContactPtr &contact, contacts) {
        mPriv->contactsForConnections.insert(connectionProperties.first, contact);
    }
void DownloadManager::on(UserConnectionListener::Failed, UserConnection* aSource, const string& aError) throw() {
	Download* d = aSource->getDownload();

	if(d == NULL) {
		removeConnection(aSource);
		return;
	}
	
	fire(DownloadManagerListener::Failed(), d, aError);

	string target = d->getTarget();
	aSource->setDownload(NULL);
	removeDownload(d, true);
	
	if(aError.find("File Not Available") != string::npos || aError.find(" no more exists") != string::npos) { //solved DCTC
		QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_FILE_NOT_AVAILABLE, false);
	}

	removeConnection(aSource);
}
void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const u_int8_t* aData, size_t aLen) throw() {
	Download* d = aSource->getDownload();
	dcassert(d != NULL);

	try {
		d->addPos(d->getFile()->write(aData, aLen), aLen);

		if(d->getPos() > d->getSize()) {
			throw Exception(STRING(TOO_MUCH_DATA));
		} else if(d->getPos() == d->getSize()) {
			handleEndData(aSource);
			aSource->setLineMode();
		}
	} catch(const RollbackException& e) {
		string target = d->getTarget();
		QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_ROLLBACK_INCONSISTENCY);
		fire(DownloadManagerListener::Failed(), d, e.getError());

		d->resetPos();
		aSource->setDownload(NULL);
		removeDownload(d, true);
		removeConnection(aSource);
		return;
	} catch(const FileException& e) {
		fire(DownloadManagerListener::Failed(), d, e.getError());

		d->resetPos();
		aSource->setDownload(NULL);
		removeDownload(d, true);
		removeConnection(aSource);
		return;
	} catch(const Exception& e) {
		fire(DownloadManagerListener::Failed(), d, e.getError());
		// Nuke the bytes we have written, this is probably a compression error
		d->resetPos();
		aSource->setDownload(NULL);
		removeDownload(d, true);
		removeConnection(aSource);
		return;
	}
}
/*!
 * Disconnects the connection with the specified \a clientID.
 *
 * Implementations should invoke this function when the connection should no longer be
 * used; for instance, when the QIODevice object is destroyed or the connection has been
 * closed. Code that uses the connection manager service should invoke this function to
 * close a connection on demand.
 */
void QxtAbstractConnectionManager::disconnect(quint64 clientID)
{
    QIODevice* device = qxt_d().clients.value(clientID, 0);
    if (!device)
    {
        qWarning() << "QxtAbstractConnectionManager::disconnect: client ID not in use";
        return;
    }
    qxt_d().clients.remove(clientID);
    emit disconnected(device, clientID);
    removeConnection(device, clientID);
}
void UploadManager::on(UserConnectionListener::Failed, UserConnection* aSource, const string& aError) throw() {
	Upload* u = aSource->getUpload();

	if(u) {
		fire(UploadManagerListener::Failed(), u, aError);

		dcdebug("UM::onFailed: Removing upload\n");
		removeUpload(u);
	}

	removeConnection(aSource);
}
Beispiel #23
0
void NetHandler::doCloseConnection(int fd)
{
    if (fd > 0)
    {
        struct epoll_event ev;
        epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &ev);
        shutdown(fd, SHUT_RDWR);
        close(fd);
        LOG4CXX_DEBUG(logger_, "Connection with fd " << fd << " is really closed >_<");
        removeConnection(fd);
    }
}
// ---------------------------------------------------------------------------
// PosSettingsForm::~PosSettingsForm
// Destructor
// ---------------------------------------------------------------------------
PosSettingsForm::~PosSettingsForm()
{
    qDebug() << "+ PosSettingsForm::PosSettingsForm()";
    // Remove custom layouts
    HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);

    //TODO Disconnect of mSettingsEngine positionTechnologyChange

    removeConnection( mAdvancedSettings, SIGNAL(clicked()),
                      this, SLOT(onPressedAdvanced()) );
    removeConnection( mGpsPosType, SIGNAL(released),
                      this, SLOT(onPressedGps()) );
    removeConnection( mWirelessPosType, SIGNAL(released),
                      this, SLOT(onPressedWireless()) );
    removeConnection( mBgPosType, SIGNAL(released),
                      this, SLOT(onPressedBackground()) );

    //ToDo: removeAllConnection crashes with Kern-Exec3 error
    //removeAllConnection();
    qDebug() << "- PosSettingsForm::PosSettingsForm()";
}
Beispiel #25
0
void DownloadManager::failDownload(UserConnection* aSource, const string& reason) {

    Download* d = aSource->getDownload();

    if(d) {
        removeDownload(d);
        fire(DownloadManagerListener::Failed(), d, reason);

        QueueManager::getInstance()->putDownload(d, false);
    }

    removeConnection(aSource);
}
Beispiel #26
0
void MainWindow::addConnection()
{
    QTcpSocket * s;
    s = server.nextPendingConnection();
    stUserInfo user;
    user.pTcpSocket = s;
    list.append(user);
    connect(s,SIGNAL(disconnected()),this,SLOT(removeConnection()));
    connect(s,SIGNAL(readyRead()),this,
            SLOT(recvMsg()));
    ui->textEdit->append(QString("새로운 사용자입장"));

}
/**
 * Disconnect a pin.
 */
void VimusGUIPin::disconnect(VimusGUIPin *pin)
{
    for (int i=0; i<numConnections; i++)
    {
        // check if it is really connected.
        if ((connections[i]->indexOnParent == pin->indexOnParent)
            && (connections[i]->parentIndex == pin->parentIndex))
        {
            removeConnection(i);
            pin->disconnect(this);
            return;
        }
    }
}
Beispiel #28
0
//! remove all connections to and from ports to a module
void PortManager::removeConnections(const int moduleID) {

   typedef std::map<std::string, Port *> PortMap;
   typedef std::map<int, PortMap *> ModulePortMap;

   ModulePortMap::const_iterator mports = m_ports.find(moduleID);
   if (mports == m_ports.end())
      return;

   const PortMap &portmap = *mports->second;
   for(PortMap::const_iterator it = portmap.begin();
         it != portmap.end();
         ++it) {

      Port *port = it->second;
      const Port::PortSet &cl = port->connections();
      while (!cl.empty()) {
         size_t oldsize = cl.size();
         const Port *other = *cl.begin();
         removeConnection(port, other);
         removeConnection(other, port);
         message::Disconnect d1(port->getModuleID(), port->getName(), other->getModuleID(), other->getName());
         m_clusterManager->sendAll(d1);
         m_clusterManager->sendUi(d1);
         message::Disconnect d2(other->getModuleID(), other->getName(), port->getModuleID(), port->getName());
         m_clusterManager->sendAll(d2);
         m_clusterManager->sendUi(d2);
         if (cl.size() == oldsize) {
            std::cerr << "failed to remove all connections for module " << moduleID << ", still left: " << cl.size() << std::endl;
            for (size_t i=0; i<cl.size(); ++i) {
               std::cerr << "   " << port->getModuleID() << ":" << port->getName() << " <--> " << other->getModuleID() << ":" << other->getName() << std::endl;
            }
            break;
         }
      }
   }
}
Beispiel #29
0
void rc_server::addConnection()
{
    QTcpSocket* connection = nextPendingConnection();
    qDebug() << "<rc_server>: I have accepted a new connection request.";
    connections.append(connection);
    QBuffer* buffer = new QBuffer(this);
    buffer->open(QIODevice::ReadWrite);

    /* buffers is of <QHash> datatype, ie. with connection object used as the key.
     This is a good idea to store information from different connected clients in an organized way.*/
    buffers.insert(connection, buffer);

    connect(connection, SIGNAL(disconnected()), SLOT(removeConnection()));
    connect(connection, SIGNAL(readyRead()),	SLOT(receiveMessage()));
}
void DownloadManager::on(UserConnectionListener::MaxedOut, UserConnection* aSource) throw() { 
	if(aSource->getState() != UserConnection::STATE_FILELENGTH && aSource->getState() != UserConnection::STATE_TREE) {
		dcdebug("DM::onMaxedOut Bad state, ignoring\n");
		return;
	}

	Download* d = aSource->getDownload();
	dcassert(d != NULL);

	fire(DownloadManagerListener::Failed(), d, STRING(NO_SLOTS_AVAILABLE));

	aSource->setDownload(NULL);
	removeDownload(d, true);
	removeConnection(aSource);
}