示例#1
0
/*!
 * Attempts to register the service on the local network.
 *
 * If noAutoRename is set to true, registration will fail if another service of the same service type
 * is already registered with the same service name. Otherwise, the service name will be updated with
 * a number to make it unique.
 *
 * \sa registered
 * \sa registrationError
 */
void QxtDiscoverableService::registerService(bool noAutoRename)
{
    if(state() != Unknown) {
        qWarning() << "QxtDiscoverableService: Cannot register service while not in Unknown state";
        emit registrationError(0);
        return;
    }

    QStringList subtypes = qxt_d().serviceSubTypes;
    subtypes.prepend(fullServiceType());

    DNSServiceErrorType err;
    err = DNSServiceRegister(&(qxt_d().service),
                             noAutoRename ? kDNSServiceFlagsNoAutoRename : 0,
                             qxt_d().iface,
                             serviceName().isEmpty() ? 0 : serviceName().toUtf8().constData(),
                             subtypes.join(",_").toUtf8().constData(),
                             domain().isEmpty() ? 0 : domain().toUtf8().constData(),
                             host().isEmpty() ? 0 : host().toUtf8().constData(),
                             qxt_d().port,
                             1, // must include null terminator
                             "",
                             QxtDiscoverableServicePrivate::registerServiceCallback,
                             &qxt_d());
    if(err != kDNSServiceErr_NoError) {
        qxt_d().state = Unknown;
        emit registrationError(err);
    } else {
        qxt_d().state = Registering;
        qxt_d().notifier = new QSocketNotifier(DNSServiceRefSockFD(qxt_d().service), QSocketNotifier::Read, this);
        QObject::connect(qxt_d().notifier, SIGNAL(activated(int)), &qxt_d(), SLOT(socketData()));
    }
}
void RegistrationWidget::onCreateAccountResult(Fault fault, AccountResultCode::AccountResultCodeEnum result)
{
	currentRequest = NULL;
	
	if (!fault.isNull())
	{
		emit waitingHide();

		QString str = fault.getDescription();

		UiTools::handleError(this, tr(REGISTRATION_ERROR_TITLE), fault);

		return;
	}
	
	if (result != AccountResultCode::Ok)
	{
		emit waitingHide();
		registrationError(result);	
	}
	else
	{			
		emit registrationSuccess();
	}
}
示例#3
0
 void Wagnis::handleRegisterApplicationError(QNetworkReply::NetworkError error)
 {
     QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
     qWarning() << "Wagnis::handleRegisterApplicationError:" << (int)error << reply->errorString() << reply->readAll();
     if (error == QNetworkReply::ContentConflictError) { // Conflict = Registration already there!
         qDebug() << "[Wagnis] Installation already registered!";
         this->getApplicationRegistration();
     } else {
         emit registrationError(QString::number((int)error) + "Return code: " + " - " + reply->errorString());
     }
 }
示例#4
0
 void Wagnis::handleGetApplicationRegistrationError(QNetworkReply::NetworkError error)
 {
     QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
     qWarning() << "Wagnis::handleGetApplicationRegistrationError:" << (int)error << reply->errorString() << reply->readAll();
     emit registrationError(QString::number((int)error) + "Return code: " + " - " + reply->errorString());
 }