コード例 #1
0
ファイル: irc.cpp プロジェクト: neiko/bottie
void Irc::connected() {
  emit gotConnection();
  if(!passwd.isEmpty())
    sendData("PASS :"******"NICK " + ownNick + "\nUSER " + ident + " " + ownNick + " " + \
    server + " :" + realname);
  status = STATUS_AUTOJOINING;
}
コード例 #2
0
ファイル: ctcpclient.cpp プロジェクト: jonas-amr/IWM_Prakt
bool cTcpClient::setConnection(QString address, quint16 port)
{
    bool ok;
    if(DEB_TCPCLIENT_METHODEN) qDebug() << "<cTcpClient::setConnection("<<address<<","<<port<<")>";



    if((hostAddr == address) && (hostPort == port) && isConnected())
        return true;

    hostAddr = address;
    hostPort = port;


    if(DEB_TCPCLIENT_METHODEN) qDebug() << QHostAddress(hostAddr);
    try
    {
        client.connectToHost(QHostAddress(hostAddr), hostPort);
        ok = client.waitForConnected(1000); // 1s auf Verbindung warten
    }
    catch(...)
    {
        qDebug() << "client.connectToHost("<<hostAddr<<","<<hostPort<<") failed";
        ok = false;
    }


    qDebug() << "ok="<<ok;

    if(ok)
    {
        emit sigConncetDisconnectMsg("Verbunden mit "+hostAddr);
        emit gotConnection(true);
    }
    else
    {
        emit sigConncetDisconnectMsg("Verbindung getrennt");
        emit gotConnection(false);
    }

    if(DEB_TCPCLIENT_METHODEN) qDebug() << "</cTcpClient::setConnection>";
    return ok;
}
コード例 #3
0
int Login::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: gotConnection((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: validate(); break;
        case 2: loadForm((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 3: showForm((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 4: connectDB((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])),(*reinterpret_cast< const QString(*)>(_a[4])),(*reinterpret_cast< const QString(*)>(_a[5])),(*reinterpret_cast< const QString(*)>(_a[6]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
コード例 #4
0
ファイル: xclient.cpp プロジェクト: dsvensson/promoe
bool
XClient::connect (const char *ipcpath, const bool &sync, QWidget *parent)
{
	bool tried_once = false;
try_again:

	try {
		delete m_client;
		m_client = new Xmms::Client (m_name);
		if (!ipcpath || ipcpath == QLatin1String (""))
			m_client->connect (NULL);
		else
			m_client->connect (ipcpath);
	}
	catch (Xmms::connection_error& e) {
		if (ipcpath == NULL && !tried_once) {
			QSettings s;
			if (s.value ("core/autostart", true).toBool ()) {
				if (!system ("xmms2-launcher")) {
					tried_once = true;
					goto try_again;
				}
			}
		}

		QErrorMessage *err = new QErrorMessage (parent);
		err->showMessage ("Couldn't connect to XMMS2, please try again.");
		err->exec ();
		delete err;
		return false;
	}

	m_client->setMainloop (new XmmsQT4 (m_client->getConnection ()));

	m_isconnected = true;
	// useing normal disconnect callback, if that causes problems,
	// an own method schould be created
    setDisconnectCallback (boost::bind (&XClient::disconnect, this));
	emit gotConnection (this);

	return true;
}
コード例 #5
0
ファイル: network.cpp プロジェクト: gkernel/supercomputer_lab
void NetworkDomain::check(fd_set* set)
{
    if (FD_ISSET(fd, set)) gotConnection();
}
コード例 #6
0
ファイル: ctcpclient.cpp プロジェクト: jonas-amr/IWM_Prakt
void cTcpClient::clientError(QAbstractSocket::SocketError socketError)
{
    QString errStr;

    if(DEB_TCPCLIENT_METHODEN) qDebug() << "<cTcpClient::clientError>";

    if(errZeigen || socketError!=errAlt)
    {
        switch (socketError)
        {
        case QAbstractSocket::ConnectionRefusedError:
            errStr = "ConnectionRefusedError (0): The connection was refused by the peer (or timed out).";
            break;
        case QAbstractSocket::RemoteHostClosedError:
            errStr = "RemoteHostClosedError: The remote host closed the connection. Note that the client socket (i.e., this socket) will be closed after the remote close notification has been sent.";
            break;
        case QAbstractSocket::HostNotFoundError:
            errStr = "HostNotFoundError (2): The host address was not found.";
            break;
        case QAbstractSocket::SocketAccessError:
            errStr = "SocketAccessError (3): The socket operation failed because the application lacked the required privileges.";
            break;
        case QAbstractSocket::SocketResourceError:
            errStr = "SocketResourceError (4): The local system ran out of resources (e.g., too many sockets).";
            break;
        case QAbstractSocket::SocketTimeoutError:
            errStr = "SocketTimeoutError (5): The socket operation timed out.";
            break;
        case QAbstractSocket::DatagramTooLargeError:
            errStr = "DatagramTooLargeError (6): The datagram was larger than the operating system's limit (which can be as low as 8192 bytes).";
            break;
        case QAbstractSocket::NetworkError:
            errStr = "NetworkError (7): An error occurred with the network (e.g., the network cable was accidentally plugged out).";
            break;
        case QAbstractSocket::AddressInUseError:
            errStr = "AddressInUseError (8): The address specified to QUdpSocket::bind() is already in use and was set to be exclusive.";
            break;
        case QAbstractSocket::SocketAddressNotAvailableError:
            errStr = "SocketAddressNotAvailableError (9): The address specified to QUdpSocket::bind() does not belong to the host.";
            break;
        case QAbstractSocket::UnsupportedSocketOperationError:
            errStr = "UnsupportedSocketOperationError (10): The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support).";
            break;
        case QAbstractSocket::ProxyAuthenticationRequiredError:
            errStr = "ProxyAuthenticationRequiredError (12): The socket is using a proxy, and the proxy requires authentication.";
            break;
        case QAbstractSocket::SslHandshakeFailedError:
            errStr = "SslHandshakeFailedError (13): The SSL/TLS handshake failed, so the connection was closed (only used in QSslSocket)";
            break;
        case QAbstractSocket::UnfinishedSocketOperationError:
            errStr = "UnfinishedSocketOperationError (11): Used by QAbstractSocketEngine only, The last operation attempted has not finished yet (still in progress in the background).";
            break;
        case 14: //QAbstractSocket::ProxyConnectionRefusedError:
            errStr = "ProxyConnectionRefusedError (14): Could not contact the proxy server because the connection to that server was denied";
            break;
        case 15: //QAbstractSocket::ProxyConnectionClosedError:
            errStr = "ProxyConnectionClosedError (15): The connection to the proxy server was closed unexpectedly (before the connection to the final peer was established)";
            break;
        case 16://QAbstractSocket::ProxyConnectionTimeoutError:
            errStr = "ProxyConnectionTimeoutError (16): The connection to the proxy server timed out or the proxy server stopped responding in the authentication phase.";
            break;
        case 17: // QAbstractSocket::ProxyNotFoundError:
            errStr = "ProxyNotFoundError (17): The proxy address set with setProxy() (or the application proxy) was not found.";
            break;
        case 18:// QAbstractSocket::ProxyProtocolError:
            errStr = "ProxyProtocolError (18): The connection negotiation with the proxy server because the response from the proxy server could not be understood.";
            break;
        case -1://QAbstractSocket::UnknownSocketError:
            errStr = "UnknownSocketError (-1): An unidentified error occurred.";
            break;
        default:
            errStr = "clientError: default..)";
        }

        errZeigen = false;

        qDebug() << errStr;
        emit gotConnection(false);
        emit sigConncetDisconnectMsg(errStr);
    }

    errAlt = socketError;
}