Commit d39af9f4 authored by Lukas Appelhans's avatar Lukas Appelhans

Little constification and add --root option to akabei-key

parent d29fab48
...@@ -415,11 +415,11 @@ void SyncOperation::updateNextDatabase() ...@@ -415,11 +415,11 @@ void SyncOperation::updateNextDatabase()
db->update(forceDbUpdate); db->update(forceDbUpdate);
} }
void SyncOperation::databaseErrorTriggered(Akabei::Error::List errors) void SyncOperation::databaseErrorTriggered(const Akabei::Error::List &errors)
{ {
QTextStream err(stderr); QTextStream err(stderr);
QString message = Akabei::errorPrefix + QObject::tr("There has been an error while updating %1:").arg( static_cast<AkabeiClient::DatabaseHandler*>(QObject::sender())->name() ); QString message = Akabei::errorPrefix + QObject::tr("There has been an error while updating %1:").arg( static_cast<AkabeiClient::DatabaseHandler*>(QObject::sender())->name() );
foreach (Akabei::Error error, errors) foreach (const Akabei::Error &error, errors)
message.append(' ' + error.description()); message.append(' ' + error.description());
err << m_bar.replaceMessage(message) << endl; err << m_bar.replaceMessage(message) << endl;
......
...@@ -34,7 +34,7 @@ private slots: ...@@ -34,7 +34,7 @@ private slots:
void showGroup(QUuid,QList<Akabei::Group*>); void showGroup(QUuid,QList<Akabei::Group*>);
void databaseStatusChanged(AkabeiClient::DatabaseHandler::Status); void databaseStatusChanged(AkabeiClient::DatabaseHandler::Status);
void databaseProgressChanged(int); void databaseProgressChanged(int);
void databaseErrorTriggered(Akabei::Error::List); void databaseErrorTriggered(const Akabei::Error::List &);
void install(QUuid,QList<Akabei::Package*>); void install(QUuid,QList<Akabei::Package*>);
void nextOperation(); void nextOperation();
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define YESNO(x) ((x) == 1 ? QObject::tr("yes") : QObject::tr("no")) #define YESNO(x) ((x) == 1 ? QObject::tr("yes") : QObject::tr("no"))
/* Keyring directory */ /* Keyring directory */
const QString AkabeiKeyringDir( "/etc/akabei.d/keyring" ); QString AkabeiKeyringDir( "/etc/akabei.d/keyring" );
using namespace std; using namespace std;
...@@ -41,7 +41,7 @@ void printHelp() ...@@ -41,7 +41,7 @@ void printHelp()
QTextStream out(stdout); QTextStream out(stdout);
out << QObject::tr(":: akabei-key v2.0 (Akabei).") << endl; out << QObject::tr(":: akabei-key v2.0 (Akabei).") << endl;
out << QObject::tr("usage: akabei-key [op] [args]") << endl; out << QObject::tr("usage: akabei-key [op] [--root /path/to/root] [args]") << endl;
out << endl; out << endl;
out << "help, -h, --help" << endl; out << "help, -h, --help" << endl;
...@@ -323,9 +323,24 @@ void getFromServer(gpgme_ctx_t ctx, QString id) ...@@ -323,9 +323,24 @@ void getFromServer(gpgme_ctx_t ctx, QString id)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
QDir keyring(AkabeiKeyringDir);
QTextStream out( stdout ); QTextStream out( stdout );
QTextStream err( stderr ); QTextStream err( stderr );
QStringList args = QCoreApplication::arguments();
if (args.contains("--root")) {
int index = args.indexOf("--root");
if (index + 1 >= args.count()) {
printHelp();
exit(-1);
}
AkabeiKeyringDir = args[index + 1] + "/etc/akabei.d/keyring";
args.removeAt(index);
args.removeAt(index);
}
QDir keyring(AkabeiKeyringDir);
if (!keyring.exists()) { if (!keyring.exists()) {
out << QObject::tr(":: akabei-key v2.0 (akabei)") << endl; out << QObject::tr(":: akabei-key v2.0 (akabei)") << endl;
...@@ -347,8 +362,8 @@ int main(int argc, char **argv) ...@@ -347,8 +362,8 @@ int main(int argc, char **argv)
err << QObject::tr("Cannot access keyring files for writing. Run again this script with higher permissions.") << endl; err << QObject::tr("Cannot access keyring files for writing. Run again this script with higher permissions.") << endl;
exit(-1); exit(-1);
} }
QStringList args = QCoreApplication::arguments();
if (args.size() <= 1) { if (args.size() <= 1) {
printHelp(); printHelp();
......
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