Commit a3925211 authored by Aard's avatar Aard

Move zypper plugin to core library logging

parent 8b7d073e
......@@ -33,8 +33,7 @@ void RndSsuCli::run(){
QStringList arguments = QCoreApplication::arguments();
if (arguments.count() != 2){
if (arguments.count() >= 2){
usage();
return;
}
......@@ -56,6 +55,23 @@ void RndSsuCli::run(){
} else {
ssu.updateCredentials();
}
} else if (arguments.at(1) == "resolve"){
QString repo;
bool rndRepo=false;
if (arguments.count() <= 2){
usage();
return;
}
repo = arguments.at(2);
if (arguments.count() >= 3){
//qout << (arguments.at(3).compare("false")||arguments.at(3).compare("0"));
qout << (arguments.at(3).compare("false"));
}
qout << ssu.repoUrl(arguments.at(2));
QCoreApplication::exit(1);
} else if (arguments.at(1) == "status"){
qout << "Device registration status: "
<< (ssu.isRegistered() ? "registered" : "not registered") << endl;
......
* Mon Mar 11 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.22
- Add systemd logging to core library
- Move zypper plugin logging to core library
- Fix bug where resolverplugin does not return on credentials update
* Mon Mar 11 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.21
- Reduce time before credentials get refreshed
- Add logging for url resolver
......
Name: ssu
Version: 0.21
Version: 0.22
Release: 1
Summary: SSU enabler for RND
Group: System/Base
......
......@@ -16,32 +16,17 @@ SsuUrlResolver::SsuUrlResolver(): QObject(){
Qt::QueuedConnection);
}
void SsuUrlResolver::printJournal(int priority, QString message){
QByteArray ba = message.toUtf8();
const char *ca = ba.constData();
if (sd_journal_print(LOG_INFO, "ssu: %s", ca) < 0){
QFile logfile;
QTextStream logstream;
logfile.setFileName("/tmp/ssu.log");
logfile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
logstream.setDevice(&logfile);
logstream << message << "\n";
logstream.flush();
}
}
bool SsuUrlResolver::writeCredentials(QString filePath, QString credentialsScope){
QFile credentialsFile(filePath);
QPair<QString, QString> credentials = ssu.credentials(credentialsScope);
if (credentials.first == "" || credentials.second == ""){
printJournal(LOG_WARNING, "Returned credentials are empty, skip writing");
ssu.printJournal(LOG_WARNING, "Returned credentials are empty, skip writing");
return false;
}
if (!credentialsFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
printJournal(LOG_WARNING, "Unable to open credentials file for writing");
ssu.printJournal(LOG_WARNING, "Unable to open credentials file for writing");
return false;
}
......@@ -63,7 +48,7 @@ void SsuUrlResolver::run(){
if (in.headerEmpty()){
// FIXME, do something; we need at least repo header
printJournal(LOG_WARNING, "Received empty header list. Most likely your ssu setup is broken");
ssu.printJournal(LOG_WARNING, "Received empty header list. Most likely your ssu setup is broken");
}
PluginFrame::HeaderListIterator it;
......@@ -101,17 +86,16 @@ void SsuUrlResolver::run(){
headerList.append("ssl_verify=no");
if (isRnd || ssu.isRegistered()){
printJournal(LOG_DEBUG, "Attempting credential update");
SignalWait w;
connect(&ssu, SIGNAL(done()), &w, SLOT(finished()));
ssu.updateCredentials();
w.sleep();
} else
printJournal(LOG_DEBUG, "No RnD repository, and device not registered -- skipping credential update");
ssu.printJournal(LOG_DEBUG, "No RnD repository, and device not registered -- skipping credential update");
// TODO: check for credentials scope required for repository; check if the file exists;
// compare with configuration, and dump credentials to file if necessary
printJournal(LOG_DEBUG, QString("Requesting credentials for '%1' with RND status %2...").arg(repo).arg(isRnd));
ssu.printJournal(LOG_DEBUG, QString("Requesting credentials for '%1' with RND status %2...").arg(repo).arg(isRnd));
QString credentialsScope = ssu.credentialsScope(repo, isRnd);
if (!credentialsScope.isEmpty()){
headerList.append(QString("credentials=%1").arg(credentialsScope));
......@@ -120,10 +104,9 @@ void SsuUrlResolver::run(){
if (!credentialsFileInfo.exists() ||
credentialsFileInfo.lastModified() <= ssu.lastCredentialsUpdate()){
writeCredentials(credentialsFileInfo.filePath(), credentialsScope);
}
} else
printJournal(LOG_DEBUG, "Skipping credential update -- file exists and was modified after last update");
} else
printJournal(LOG_DEBUG, "Skipping credential update due to missing credentials scope");
ssu.printJournal(LOG_DEBUG, "Skipping credential update due to missing credentials scope");
if (headerList.isEmpty()){
resolvedUrl = ssu.repoUrl(repo, isRnd, repoParameters);
......@@ -133,7 +116,7 @@ void SsuUrlResolver::run(){
.arg(headerList.join("&"));
}
printJournal(LOG_INFO, QString("%1 resolved to %2").arg(repo).arg(resolvedUrl));
ssu.printJournal(LOG_INFO, QString("%1 resolved to %2").arg(repo).arg(resolvedUrl));
PluginFrame out("RESOLVEDURL");
out.setBody(resolvedUrl.toStdString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment