static void rtmp_stream_destroy(void *data)
{
	struct rtmp_stream *stream = data;

	if (stopping(stream) && !connecting(stream)) {
		pthread_join(stream->send_thread, NULL);

	} else if (connecting(stream) || active(stream)) {
		if (stream->connecting)
			pthread_join(stream->connect_thread, NULL);

		os_event_signal(stream->stop_event);

		if (active(stream)) {
			os_sem_post(stream->send_sem);
			obs_output_end_data_capture(stream->output);
			pthread_join(stream->send_thread, NULL);
		}
	}

	if (stream) {
		free_packets(stream);
		dstr_free(&stream->path);
		dstr_free(&stream->key);
		dstr_free(&stream->username);
		dstr_free(&stream->password);
		dstr_free(&stream->encoder_name);
		os_event_destroy(stream->stop_event);
		os_sem_destroy(stream->send_sem);
		pthread_mutex_destroy(&stream->packets_mutex);
		circlebuf_free(&stream->packets);
		bfree(stream);
	}
}
void PollServerThread::run()
{
    extern volatile bool gPhoneScreenSyncOn;
    while ( !m_exit && gPhoneScreenSyncOn ) {
        if ( !connecting() ) {
            int n = WaitForMessage(m_rfbClient, 500);
            if ( n < 0 ) {
                m_exit = true;
                break;
            } else if ( n > 0 ) {
                emit messageArrived();
                m_lastMessageReceivedTimer.start();
            } else if ( checkConnection() ) {
                if ( ((ConnectionWindow *)parent())->connected() && m_lastMessageReceivedTimer.elapsed() > QVNCVIEWER_CONNPEND_TIMEOUT ) {
                    setCheckConnection(false);
                    m_rfbClient->updateRect.x = m_rfbClient->updateRect.y = 0;
                    m_rfbClient->updateRect.w = m_rfbClient->width;
                    m_rfbClient->updateRect.h = m_rfbClient->height;
                    SendIncrementalFramebufferUpdateRequest(m_rfbClient);
                }
            }
            QTest::qWait(0);
        } else  if ( connecting() ) {
            setCheckConnection(true);
            qApp->processEvents(QEventLoop::AllEvents, 10);
        }
    }

    emit connectionClosed();
}
Exemple #3
0
Firewall::Firewall() : flood_messages(0), right_after_connection(false)
{
	kdebugf();
	
	loadSecuredList();

	lastMsg.start();
	lastNotify.start();

	pattern.setCaseSensitive(false);
	pattern.setPattern(unicode2std(config_file.readEntry("Firewall", "answer", tr("I want something"))));

	Protocol *gadu = AccountManager::instance()->defaultAccount()->protocol();
	connect(gadu, SIGNAL(rawGaduReceivedMessageFilter(Protocol *, UserListElements, QString&, QByteArray&, bool&)), this, SLOT(messageFiltering(Protocol *, UserListElements, QString&, QByteArray&, bool&)));
	connect(gadu, SIGNAL(sendMessageFiltering(const UserListElements, QByteArray &, bool &)), this, SLOT(sendMessageFilter(const UserListElements, QByteArray &, bool &)));
 	connect(chat_manager, SIGNAL(chatWidgetDestroying(ChatWidget *)), this, SLOT(chatDestroyed(ChatWidget *)));

	connect(userlist, SIGNAL(userDataChanged(UserListElement, QString, QVariant, QVariant, bool, bool)), this, SLOT(userDataChanged(UserListElement, QString, QVariant, QVariant, bool, bool)));
	connect(userlist, SIGNAL(userAdded(UserListElement, bool, bool)), this, SLOT(userAdded(UserListElement, bool, bool)));
	connect(userlist, SIGNAL(userRemoved(UserListElement, bool, bool)), this, SLOT(userRemoved(UserListElement, bool, bool)));

	
	connect(gadu, SIGNAL(connecting()), this, SLOT(connecting()));
	connect(gadu, SIGNAL(connected()), this, SLOT(connected()));

	defaultSettings();
	
	kdebugf2();
	
}
Exemple #4
0
void MainWindow::on_actionConnect_triggered()
{
  ConnectDialog dialog(this);
  dialog.exec();

  if (dialog.result() == QDialog::Accepted) {
    if (m_session != NULL) {
      m_session->close();
      for (int i = m_ui.tabWidget->count() - 1; i > 1; i--) {
        QWidget *widget = m_ui.tabWidget->widget(i);
        m_ui.tabWidget->removeTab(i);
        widget->deleteLater();
      }
      disconnect(m_session, 0, 0, 0);
      disconnect(&inputHandler, 0, m_session, 0);
      m_session->deleteLater();
      m_session = NULL;
    }

    m_session = new Session(this);
    m_session->setHost(dialog.server());
    m_session->setPort(dialog.port());
    m_session->setUserName(dialog.username());
    m_session->setNickName(dialog.nickname());
    m_session->setRealName(dialog.realName());
    m_session->setNickPassword(dialog.nickPassword());
    if (dialog.useSsl()) {
      m_session->useSsl();
    }

    connect(m_session, SIGNAL(serverNumericMessageReceived(IrcNumericMessage *)),
        m_ui.serverTab, SLOT(numericMessageReceived(IrcNumericMessage *)));
    connect(m_session, SIGNAL(serverCapabilityMessageReceived(IrcCapabilityMessage *)),
        m_ui.serverTab, SLOT(capabilityMessageReceived(IrcCapabilityMessage *)));

    connect(m_session, SIGNAL(connecting()),
        m_ui.serverTab, SLOT(connecting()));
    connect(m_session, SIGNAL(connected()),
        m_ui.serverTab, SLOT(connected()));
    connect(m_session, SIGNAL(disconnected()),
        m_ui.serverTab, SLOT(disconnected()));
    connect(m_session, SIGNAL(channelJoined(Channel *)),
        this, SLOT(channelJoined(Channel *)));
    connect(m_session, SIGNAL(queryStarted(Query *)),
        this, SLOT(queryStarted(Query *)));

    connect(&inputHandler, SIGNAL(ircCommandReceived(IrcCommand *)),
        m_session, SLOT(handleCommand(IrcCommand *)));

    connect(m_session, SIGNAL(noticeMessageReceived(IrcNoticeMessage *)),
        this, SLOT(noticeMessageReceived(IrcNoticeMessage *)));

    m_session->open();
  }
}
Exemple #5
0
QTlen::QTlen( QWidget *parent, const char *name )
	: QMainWindow( parent, name ),
	  v_tray( false ),
	  v_quit( false )
{
	QSettings settings;
	settings.setPath( "qtlen.berlios.de", "QTlen" );
	
	settings.beginGroup( "/window" );
	
	setGeometry( settings.readNumEntry( "/main/xpos", 50 ),
		     settings.readNumEntry( "/main/ypos", 50 ),
		     settings.readNumEntry( "/main/width", 225 ),
		     settings.readNumEntry( "/main/height", 450 ) );
	
	settings.resetGroup();
	
	PresenceManager::initModule();
	Tlen::initModule();
	MessageManager::initModule();
	RosterManager::initModule();
	
	PubdirManager::initModule();
	
	SoundManager::initModule();
	
	setCaption( "QTlen: "+tlen_manager->getJid() );
	setIcon( takePixmap("offline") );
	
	settings.beginGroup( "/general" );
	
	roster = new RosterBox( this );
	
	setCentralWidget( roster );
	
	addToolBars();
	
	if( settings.readBoolEntry( "/trayicon/activated" ) )
		activeTrayIcon();
	else
		v_quit = true;
	
	settings.resetGroup();
	
	connect( presence_manager, SIGNAL( statusChanged( PresenceManager::PresenceStatus, const QString& ) ),
			SLOT( statusChanged( PresenceManager::PresenceStatus, const QString& ) ) );
	
	connect( tlen_manager, SIGNAL( connecting() ), SLOT( connecting() ) );
}
NetworkManager::NetworkManager(Game *game, QObject *parent)
    :QObject(parent), game(game), tcpClient()
{
    connect(&tcpClient, SIGNAL(reading(QByteArray)), this, SLOT(applyFrame(QByteArray)));
    connect(&tcpClient, SIGNAL(connecting()), this, SLOT(connected()));
    connect(&tcpClient, SIGNAL(disconnecting()), this, SLOT(disconnected()));
}
void TorProtocolManager::setState(ProtocolManager::State state)
{
    const auto old = state_;
    state_ = state;
    if (old != state_) {

        LFLOG_DEBUG << "TorProtocolManager changing state from " << getName(old)
                 << " to " << getName(state);

        emit stateChanged(old, state_);

        switch(state) {
        case ProtocolManager::State::OFFLINE:
            emit offline();
            break;
        case ProtocolManager::State::CONNECTING:
            emit connecting();
            break;
        case ProtocolManager::State::CONNECTED:
            emit connected();
            break;
        case ProtocolManager::State::ONLINE:
            emit online();
            break;
        case ProtocolManager::State::SHUTTINGDOWN:
            emit shutdown();
            break;
        }
    }
}
Exemple #8
0
void SimpleHttp::download(const QString & url) {
	qDebug("SimpleHttp::download: %s", url.toLatin1().constData());

	downloaded_text.clear();

	QUrl u(url);
	setHost( u.host() );

	/*
	qDebug("u.path: %s", u.path().toLatin1().constData());
	qDebug("u.query: %s", u.encodedQuery().constData());
	*/

	QString p = u.path();
	if (!u.encodedQuery().isEmpty()) p += "?" + u.encodedQuery();

	if (user_agent.isEmpty()) {
		http_get_id = get( p );
	} else {
		QHttpRequestHeader header("GET", p);
		header.setValue("Host", u.host());
		header.setValue("User-Agent", user_agent);
		http_get_id = request(header);
	}

	emit connecting(u.host());
}
int SopoMygga::reconnectToHost()
{
    int r, s;

    r=reconnect_async();

    delete m_notifier_read;
    delete m_notifier_write;

    if (r!=MOSQ_ERR_SUCCESS) {
        qWarning() << "Connection failure";
        return r;
    }

    s=socket();
    if (s==-1) {
        qWarning() << "Failed to get mosquitto connection socket";
    }

    m_notifier_read = new QSocketNotifier(s, QSocketNotifier::Read, this);
    QObject::connect(m_notifier_read, SIGNAL(activated(int)), this, SLOT(loopRead()));

    m_notifier_write = new QSocketNotifier(s, QSocketNotifier::Write, this);
    QObject::connect(m_notifier_write, SIGNAL(activated(int)), this, SLOT(loopWrite()));

    emit connecting();

    return r;
}
Exemple #10
0
void Session::reconnect()
{
    connect(this, SIGNAL(connecting()), &m_reconnectTimer, SLOT(stop()));
    connect(this, SIGNAL(socketError(QAbstractSocket::SocketError)), &m_reconnectTimer, SLOT(start()));

    if (ensureNetwork())
        open();
}
Exemple #11
0
Server::Server(QStandardItem *inMenuItem, Session *parent) : QObject(parent)
{
    messageParser = new MessageParser(this);
    ircSession = new IrcSession(this);
    menuItem = inMenuItem;
    timeoutTimer = new QTimer(this);
    text = QStringList("<span></span>");
    connect(ircSession, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(processMessage(IrcMessage*)));
    connect(ircSession, SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(processError(QAbstractSocket::SocketError)));
    connect(ircSession, SIGNAL(nickNameChanged(const QString&)), this, SLOT(nickNameChanged(const QString&)));
    connect(ircSession, SIGNAL(password(QString*)), this, SLOT(passwordRequested(QString*)));
    connect(ircSession, SIGNAL(connecting()), this, SLOT(connecting()));
    connect(ircSession, SIGNAL(connected()), this, SLOT(connected()));
    connect(ircSession, SIGNAL(disconnected()), this, SLOT(disconnected()));
    connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(serverTimeout()));
    this->disconnected();
}
static void rtmp_stream_destroy(void *data)
{
	struct rtmp_stream *stream = data;

	if (stopping(stream) && !connecting(stream)) {
		pthread_join(stream->send_thread, NULL);

	} else if (connecting(stream) || active(stream)) {
		if (stream->connecting)
			pthread_join(stream->connect_thread, NULL);

		stream->stop_ts = 0;
		os_event_signal(stream->stop_event);

		if (active(stream)) {
			os_sem_post(stream->send_sem);
			obs_output_end_data_capture(stream->output);
			pthread_join(stream->send_thread, NULL);
		}
	}

	free_packets(stream);
	dstr_free(&stream->path);
	dstr_free(&stream->key);
	dstr_free(&stream->username);
	dstr_free(&stream->password);
	dstr_free(&stream->encoder_name);
	dstr_free(&stream->bind_ip);
	os_event_destroy(stream->stop_event);
	os_sem_destroy(stream->send_sem);
	pthread_mutex_destroy(&stream->packets_mutex);
	circlebuf_free(&stream->packets);
#ifdef TEST_FRAMEDROPS
	circlebuf_free(&stream->droptest_info);
#endif

	os_event_destroy(stream->buffer_space_available_event);
	os_event_destroy(stream->buffer_has_data_event);
	os_event_destroy(stream->socket_available_event);
	os_event_destroy(stream->send_thread_signaled_exit);
	pthread_mutex_destroy(&stream->write_buf_mutex);

	if (stream->write_buf)
		bfree(stream->write_buf);
	bfree(stream);
}
Exemple #13
0
void MainWindow::addTab(AbstractTab *tab, const QString &name)
{
  connect(tab, SIGNAL(inputReceived(const QString &, const QString &)),
      &inputHandler, SLOT(handleInput(const QString &, const QString &)));
  connect(m_session, SIGNAL(connecting()),
      tab, SLOT(connecting()));
  connect(m_session, SIGNAL(connected()),
      tab, SLOT(connected()));
  connect(m_session, SIGNAL(disconnected()),
      tab, SLOT(disconnected()));
  connect(this, SIGNAL(fontChanged(const QFont &)),
      tab, SLOT(setFont(const QFont &)));

  m_ui.tabWidget->addTab(tab, name);
  m_ui.tabWidget->setCurrentIndex(m_ui.tabWidget->count() - 1);
  tab->setFocus();
}
Exemple #14
0
void Connector::connect()
{
	// 直接连接
	// 注意:这里是非阻塞connect,一般会立即返回 EINPROGRESS 错误,表示连接操作正在进行中,但是仍未完成,与此同时 TCP 三次握手操作会同时进行
	// 在这之后,我们可以捕获可写事件以及error事件来检查这个链接是否建立成功

	int ret = ::connect(m_sockfd, (struct sockaddr *)&m_peerAddr.getSockAddr(), static_cast<socklen_t>(sizeof m_peerAddr.getSockAddr()));
	// int ret = socktool::connect(m_sockfd, m_peerAddr);

	int err = ((ret == SOCKET_ERROR) ? socktool::geterrno() : 0);
	switch (err) {
	case 0:
		// 连接成功(当客户端和服务器端在同一台主机上的时候,connect会马上返回0)
		LOG_WARN << "warn: socket<" << m_sockfd << "> connect to localhost<" << m_peerAddr.toIpPort() << "> success";
		onConnected();
		break;

#ifdef WIN
	// linux下的EAGAIN和EWOULDBLOCK是同一个值,编译会报错
	case EAGAIN:
#endif
	case EWOULDBLOCK:
	case EINTR:
	case EISCONN:
	case EINPROGRESS:
		// LOG_WARN << "warn: socket <" << m_sockfd << "> starting connecting err = <" << err << ">";

		// 正在连接(tcp三次握手正在进行)
		connecting();
		break;

	case EADDRINUSE:
	case EADDRNOTAVAIL:
	case ECONNREFUSED:
	case ENETUNREACH:
		// 连接失败,重试
		retry();
		break;

	case EACCES:
	case EPERM:
	case EAFNOSUPPORT:
	case EALREADY:
	case EBADF:
	case EFAULT:
	case ENOTSOCK:
		// 连接异常,中断
		retry();
		break;

	default:
		// 发生未识别异常
		// LOG_SOCKET_ERR << "socket<" << m_sockfd << "> connect to peer<" << m_peerAddr.toIpPort() << "> fail, unexpected error = " << err;
		retry();
		break;
	}
}
Exemple #15
0
bool AntiDos::changeIP(const QString &newIp, const QString &oldIp)
{
    connectionsPerIp[oldIp]--;
    //Server::serverIns->printLine(tr("Connections for ip(-change) %1 are %2").arg(oldIp).arg(connectionsPerIp[oldIp]));
    loginsPerIp[oldIp].pop_back(); // remove a login
    if (connectionsPerIp[oldIp] <= 0) {
        connectionsPerIp.remove(oldIp);
    }
    return connecting(newIp);
}
Exemple #16
0
Firewall::~Firewall()
{
	kdebugf();

	Protocol *gadu = AccountManager::instance()->defaultAccount()->protocol();	
	disconnect(gadu, SIGNAL(rawGaduReceivedMessageFilter(Protocol *, UserListElements, QString&, QByteArray&, bool&)), this, SLOT(messageFiltering(Protocol *, UserListElements, QString&, QByteArray&, bool&)));
	disconnect(gadu, SIGNAL(sendMessageFiltering(const UserListElements, QByteArray &, bool &)), this, SLOT(sendMessageFilter(const UserListElements, QByteArray &, bool &)));
	disconnect(chat_manager, SIGNAL(chatWidgetDestroying(ChatWidget *)), this, SLOT(chatDestroyed(ChatWidget *)));

	disconnect(userlist, SIGNAL(userDataChanged(UserListElement, QString, QVariant, QVariant, bool, bool)), this, SLOT(userDataChanged(UserListElement, QString, QVariant, QVariant, bool, bool)));
	disconnect(userlist, SIGNAL(userAdded(UserListElement, bool, bool)), this, SLOT(userAdded(UserListElement, bool, bool)));
	disconnect(userlist, SIGNAL(userRemoved(UserListElement, bool, bool)), this, SLOT(userRemoved(UserListElement, bool, bool)));
	
	disconnect(gadu, SIGNAL(connecting()), this, SLOT(connecting()));
	disconnect(gadu, SIGNAL(connected()), this, SLOT(connected()));
	
	
	kdebugf2();
	
}
/**
 * networkCreate_csocket() \n
 * Function to create a client socket \n
 * @param int portnum with the port number \n
 * @param ip with the ip/hostname of the server \n
 * @param sock_in with the socket structure \n
 * @return HRESULT with the socket descriptor or error code \n
 */
HRESULT networkCreate_csocket(int portnum,char *ip,PTR_SOCK_IN sock_in)
{
	// Variables
	int sock = 0; 				// For the Socket Descriptor
	int err = 0; 				// Save status from called functions
	char afnet[max_ip];			// Save Flag for ipvX
	int net = 0;				// AFNET FLAG

	// Set Status of socket timer
	networkSockWaitStatus(1,false);

	//Copy ip for afnet
	if(strlen(ip) > 0)
		strncpy(afnet,ip,max_ip);
	else
		return NO_IP;

	//Create socket
	net = conv_address(afnet);
	err = connecting(&net);

	// Don't can create socket
	if(err == -1)
		return CANT_CREATE_SOCKET;

	// Have a socket
	sock = err;

	// Control for right ip address
	err = conv_address(ip);

	//Set Options for socket
	sock_in->sin_family = net;
	sock_in->sin_port = htons(portnum);
	inet_aton((ip), &sock_in->sin_addr);

	//Connect with server
	if (connect(sock, (struct sockaddr *) sock_in, sizeof(*sock_in))== 0)
	{
		// Make syslog and stdout message
		syslogWriteDebug(ldebug,"Connection established with server.");
	}
	else
	{
		// Make syslog and stdout message
		syslogWriteDebug(lerror,"Error: Can't establish connection to Server");
		// Give back err to calling function
		return CANT_CREATE_CONNECTION;
	}

	// Return the number of the socket descriptor or -1 if failed
	return sock;
}
Exemple #18
0
void MainWindow::initData()
{
    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground);
    ui->stackedWidget->addWidget(&list);

    anticrack=new QLabel(this);
    anticrack->setText("this is anticrack");
    fakeap=new QLabel(this);
    fakeap->setText("this is fakeap");
    ui->stackedWidget->addWidget(&arp_tab);
    ui->stackedWidget->addWidget(anticrack);
    ui->stackedWidget->addWidget(fakeap);

    ui->stackedWidget->addWidget(&network);



    m_menu = new QMenu();
    m_Aactionsetting = new QAction(tr("设置"), this);
    connect(m_Aactionsetting,SIGNAL(triggered()),this,SLOT(connecting()));
    m_menu->addAction(m_Aactionsetting);
    m_menu->addSeparator();
    m_menu->addAction(tr("关于我们"));


    ///背景加载;
    m_pixmapBg.load(":/res/image/frame.png");

    m_vecBtn.push_back(ui->networkButton);
    m_vecBtn.push_back(ui->arpButton);
    m_vecBtn.push_back(ui->anticrackButton);
    m_vecBtn.push_back(ui->fakeapButton);
    m_vecBtn.push_back(ui->devicesButton);
    m_actbtn.push_back(m_Aactionsetting);
    //setwidget();



    for (int i = 0; i != m_vecBtn.size(); ++i)
    {

        ///功能选中判断;
        m_vecBtn[i]->setCheckable(true);
        m_vecBtn[i]->setAutoExclusive(true);
    }

    ///状态栏
    ui->label_CheckLogin->setText(
                tr("<font color=blue>未登录</font></a>"));
    setNomalStyle();
}
Exemple #19
0
bool BaseClient::linkConnector(BaseConnector *c)
{
    bool ok = true;
    ok &= (bool)connect(c, SIGNAL(connecting()),                this, SLOT(UIConnectingState()));
    ok &= (bool)connect(c, SIGNAL(connected()),                 this, SLOT(UIConnectedState()));
    ok &= (bool)connect(c, SIGNAL(disconnecting()),             this, SLOT(UIDisconnectingState()));
    ok &= (bool)connect(c, SIGNAL(disconnected()),              this, SLOT(UIDisconnectedState()));
    ok &= (bool)connect(c, SIGNAL(outMessage(QString)),         this, SLOT(outMessage(QString)));
    ok &= (bool)connect(c, SIGNAL(newFrame(uint)),              this, SLOT(newFrame(uint)));
    ok &= (bool)connect(c, SIGNAL(newFrame(uint)),              this, SLOT(addCount()));
    ok &= (bool)connect(c, SIGNAL(updateSubject(SubjectData*)), this, SLOT(update(SubjectData*)));
    return ok;
}
Exemple #20
0
/*	Initialize the LDAPConnection. */
static int
LDAPConnection_init(LDAPConnection *self, PyObject *args, PyObject *kwds) {
	PyObject *async_obj = NULL;
	PyObject *client = NULL;
	PyObject *ldapclient_type = NULL;
	PyObject *tmp = NULL;
	PyObject *page_size = NULL, *sort_list = NULL;
    static char *kwlist[] = {"client", "async", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O!", kwlist, &client,
    		&PyBool_Type, &async_obj)) {
    	return -1;
    }

    if (async_obj != NULL) self->async = PyObject_IsTrue(async_obj);

    ldapclient_type = load_python_object("pyldap.ldapclient", "LDAPClient");
    if (ldapclient_type == NULL ||
    		!PyObject_IsInstance(client, ldapclient_type)) {
    	return -1;
    }
	Py_DECREF(ldapclient_type);

    if (client) {
    	tmp = self->client;
    	Py_INCREF(client);
    	self->client = client;
    	Py_XDECREF(tmp);

    	/* Get page size from the client. */
    	page_size = PyObject_GetAttrString(self->client, "_LDAPClient__page_size");
    	if (page_size == NULL) return -1;
    	self->page_size = (int)PyLong_AsLong(page_size);
    	Py_DECREF(page_size);
    	if (PyErr_Occurred()) return -1;

    	/* Get sort list from the client. */
    	sort_list = PyObject_GetAttrString(self->client, "_LDAPClient__sort_attrs");
    	if (PyList_Size(sort_list) > 0) {
    		self->sort_list = PyList2LDAPSortKeyList(sort_list);
    		if (self->sort_list == NULL) {
    			PyErr_BadInternalCall();
    			return -1;
    		}
    	}

        return connecting(self);
    }
    return -1;
}
Exemple #21
0
void IrcClient::createConnection()
{
    connection = new IrcConnection(this);
    connect(connection, SIGNAL(connected()), this, SLOT(onConnected()));
    connect(connection, SIGNAL(connecting()), this, SLOT(onConnecting()));
    connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));

    qsrand(QTime::currentTime().msec());

    connection->setHost(SERVER);
    connection->setUserName("communi");
    connection->setNickName(tr("Client%1").arg(qrand() % 9999));
    connection->setRealName(tr("Communi %1 example client").arg(IRC_VERSION_STR));
}
	void ServerClient::send( const std::string& message )
	{
		if(needsToConnect())
		{
			queueMessage(message);
			return;
		}
		if(!connected() && !connecting())
			connect();

		if(connected())
		getClient()->write(message.c_str());
		else
			queueMessage(message);
	}
	bool ServerClient::connect()
	{
        if(m_server == NULL) {
            return false;
        }
        
		if(connected() && !connecting())
		{
			m_needsToConnect = true;
			return false;
		}

		if(connected() || connecting())
			return false;

		m_connecting = true;

		// Record the first client that connects to us so we can pass it to the ping function
		RakNet::SystemAddress clientID=RakNet::UNASSIGNED_SYSTEM_ADDRESS;

		RakNet::ConnectionAttemptResult car = m_server->Connect(m_address.c_str(), m_port, NULL, 0);
		RakAssert(car==RakNet::CONNECTION_ATTEMPT_STARTED);
		return true;
	}
Exemple #24
0
// Connection primitive.
bool qjackctlConnect::connectPortsEx (
	qjackctlPortItem *pOPort, qjackctlPortItem *pIPort )
{
	if (pOPort->findConnectPtr(pIPort) != NULL)
		return false;
	
	emit connecting(pOPort, pIPort);

	if (!connectPorts(pOPort, pIPort))
		return false;

	pOPort->addConnect(pIPort);
	pIPort->addConnect(pOPort);
	return true;
}
Exemple #25
0
void Session::quit(const QString& reason)
{
    disconnect(this, SIGNAL(connecting()), &m_reconnectTimer, SLOT(stop()));
    disconnect(this, SIGNAL(socketError(QAbstractSocket::SocketError)), &m_reconnectTimer, SLOT(start()));

    QString message = reason;
    if (message.isEmpty())
        message = tr("%1 %2").arg(QApplication::applicationName())
                             .arg(QApplication::applicationVersion());

    if (isConnected())
        sendCommand(IrcCommand::createQuit(message));
    socket()->waitForDisconnected(1000);
    close();
    m_quit = true;
}
Exemple #26
0
void SMTP::sendBurl(const QByteArray &from, const QList<QByteArray> &to, const QByteArray &imapUrl)
{
    this->from = from;
    this->to = to;
    this->data = imapUrl;
    this->sendingMode = MODE_SMTP_BURL;
    this->isWaitingForPassword = true;
    emit progressMax(1);
    emit progress(0);
    emit connecting();
    if (!auth || !pass.isEmpty()) {
        sendContinueGotPassword();
        return;
    }
    emit passwordRequested(user, host);
}
Exemple #27
0
void SMTP::sendMail(const QByteArray &from, const QList<QByteArray> &to, const QByteArray &data)
{
    this->from = from;
    this->to = to;
    this->data = data;
    this->sendingMode = MODE_SMTP_DATA;
    this->isWaitingForPassword = true;
    emit progressMax(data.size());
    emit progress(0);
    emit connecting();
    if (!auth || !pass.isEmpty()) {
        sendContinueGotPassword();
        return;
    }
    emit passwordRequested(user, host);
}
static void rtmp_stream_stop(void *data)
{
	struct rtmp_stream *stream = data;

	if (stopping(stream))
		return;

	if (connecting(stream))
		pthread_join(stream->connect_thread, NULL);

	os_event_signal(stream->stop_event);

	if (active(stream)) {
		os_sem_post(stream->send_sem);
		obs_output_end_data_capture(stream->output);
	}
}
Exemple #29
0
void MainWindow::on_pushButton_6_clicked()
{

    nn=QMessageBox::warning(this, "Funny Game","Connect to my friend, His  ip is : " , QMessageBox::Yes);
    QString ipAddr="192.168.0.1";
    QMessageBox::warning(this, tr("Funny Game"),
                         tr("与好友连接, 他的地址 : ") + ipAddr, QMessageBox::Yes);
    tcpClient.abort();//取消已有连接
   tcpClient.connectToHost(QHostAddress::LocalHost, 6665);
    //tcpClient.connectToHost(ipAddr,
             //               6666);

    //Tcp客户端槽函数
    connect(&tcpClient, SIGNAL(connected()), this, SLOT(connecting()));//连接成功返回的connected信号

    //mConnectBtn->setText(tr("连接中.."));

}
Exemple #30
0
static void rtmp_stream_stop(void *data, uint64_t ts)
{
	struct rtmp_stream *stream = data;

	if (stopping(stream))
		return;

	if (connecting(stream))
		pthread_join(stream->connect_thread, NULL);

	stream->stop_ts = ts / 1000ULL;
	os_event_signal(stream->stop_event);

	if (active(stream)) {
		if (stream->stop_ts == 0)
			os_sem_post(stream->send_sem);
	}
}