bool Ssu::setCredentials(QDomDocument *response){ SsuCoreConfig *settings = SsuCoreConfig::instance(); // generate list with all scopes for generic section, add sections QDomNodeList credentialsList = response->elementsByTagName("credentials"); QStringList credentialScopes; for (int i=0;i<credentialsList.size();i++){ QDomNode node = credentialsList.at(i); QString scope; QDomNamedNodeMap attributes = node.attributes(); if (attributes.contains("scope")){ scope = attributes.namedItem("scope").toAttr().value(); } else { setError(tr("Credentials element does not have scope")); return false; } if (node.hasChildNodes()){ QDomElement username = node.firstChildElement("username"); QDomElement password = node.firstChildElement("password"); if (username.isNull() || password.isNull()){ setError(tr("Username and/or password not set")); return false; } else { settings->beginGroup("credentials-" + scope); settings->setValue("username", username.text()); settings->setValue("password", password.text()); settings->endGroup(); settings->sync(); credentialScopes.append(scope); } } else { setError(""); return false; } } settings->setValue("credentialScopes", credentialScopes); settings->setValue("lastCredentialsUpdate", QDateTime::currentDateTime()); settings->sync(); emit credentialsChanged(); return true; }
void ServiceManagerModelPrivate::connectService(Service * service) { connect(service, SIGNAL(descriptionChanged(QString)), this, SLOT(onServiceDescriptionChanged(QString))); connect(service, SIGNAL(serviceStateChanged(Kend::Service::ServiceState)), this, SLOT(onServiceStateChanged(Kend::Service::ServiceState))); connect(service, SIGNAL(credentialsChanged(QVariantMap)), this, SLOT(onServiceCredentialsChanged(QVariantMap))); }