void ConnectionDiagnosticThread::run()
    {
        boost::scoped_ptr<mongo::DBClientConnection> connection;

        try {
            connection.reset(new mongo::DBClientConnection);
            connection->connect(_connection->info());
            emit connectionStatus("", true);
        }
        catch(const mongo::UserException &ex) {
            const char *what = ex.what();
            emit connectionStatus(QString(what), false);
            emit completed();
            return;
        }

        try {
            if (_connection->hasEnabledPrimaryCredential())
            {
                CredentialSettings *credential = _connection->primaryCredential();
                std::string database = credential->databaseName();
                std::string username = credential->userName();
                std::string password = credential->userPassword();

                std::string errmsg;
                bool ok = connection->auth(database, username, password, errmsg);
                emit authStatus("", ok);
            }
        } catch (const mongo::UserException &) {
            emit authStatus("", false);
        }

        emit completed();
    }
	void report(FILE* fp, const char* conn_type, void* handle, bool buffered)
	{
		int error, conn_error;
		CNVConnectionStatus status;
		fprintf(fp, "  Connection type: %s", conn_type);
		if (handle == 0)
		{
		    fprintf(fp, " Status: <not being used>\n");
		    return;
		}
		error = CNVGetConnectionAttribute(handle, CNVConnectionStatusAttribute, &status);
		ERROR_CHECK("CNVGetConnectionAttribute", error);
		fprintf(fp, " status: %s", connectionStatus(status));
		error = CNVGetConnectionAttribute(handle, CNVConnectionErrorAttribute, &conn_error);
		ERROR_CHECK("CNVGetConnectionAttribute", error);
		if (conn_error < 0)
		{
			fprintf(fp, " error present: %s", CNVGetErrorDescription(conn_error));
		}
		if (buffered)
		{
			int nitems, maxitems;
			error = CNVGetConnectionAttribute(handle, CNVClientBufferNumberOfItemsAttribute, &nitems);
			ERROR_CHECK("CNVGetConnectionAttribute", error);
			error = CNVGetConnectionAttribute(handle, CNVClientBufferMaximumItemsAttribute, &maxitems);
			ERROR_CHECK("CNVGetConnectionAttribute", error);
			fprintf(fp, " Client buffer: %d items (buffer size = %d)", nitems, maxitems);
		}
		fprintf(fp, "\n");
	}
예제 #3
0
void Network::onError(QAbstractSocket::SocketError error)
{
    QString errorType = (error == QAbstractSocket::HostNotFoundError? "Host not found" :
                         error == QAbstractSocket::ConnectionRefusedError? "Connection timed out" :
                         error == QAbstractSocket::RemoteHostClosedError? "Connection refused" : "Unknown error");

    QString errorText = QString("Error: %1").arg(errorType);

    emit connectionStatus(false, errorText);
}
/// called by StatusCallback() when status of a network shared variable changes
void NetShrVarInterface::statusCallback (void * handle, CNVConnectionStatus status, int error, CallbackData* cb_data)
{
	if (error < 0)
	{
		std::cerr << "StatusCallback: " << cb_data->nv_name << ": " << CNVGetErrorDescription(error) << std::endl;
	}
	else
	{
		std::cerr << "StatusCallback: " << cb_data->nv_name << " is " << connectionStatus(status) << std::endl;
	}
}
    void ConnectionDiagnosticDialog::completed()
    {
        if (!_connectionStatusReceived)
            connectionStatus("", false);

        if (!_authStatusReceived)
            authStatus("", false);

        // seems that it is wrong to call any method on thread,
        // because thread already can be disposed.
        // QThread *thread = static_cast<QThread *>(sender());
        // thread->quit();
    }
예제 #6
0
파일: gpsd.cpp 프로젝트: buelowp/startrac
void Gpsd::connectToServer(const QString &h, quint16 p, Gpsd::StreamMode m)
{
    if (isConnected()) {          // We're connected
        disconnectFromServer();   // disconnect first
    }

    host = h;
    port = p;
    if (gps_open(h.toLatin1().data(), QString().setNum(p).toLatin1().data(), &gpsdata) == 0) {
        notifier = new QSocketNotifier(gpsdata.gps_fd, QSocketNotifier::Read);
        notifier->setEnabled(true);
        connect(notifier, SIGNAL(activated(int)), this, SLOT(handleInput(int)));
        emit connectionStatus(true);

        gps_stream(&gpsdata, WATCH_ENABLE|m, NULL);
    } else {
bool GlobalPresence::isChangingPresence() const
{
    return connectionStatus() == Tp::ConnectionStatusConnecting;
}
예제 #8
0
void Network::onConnect()
{
    emit message("Connected to server");
    emit connectionStatus(true);
}