- Mac OS X data dir is now ~/Library/Application Support/Quassel and no longer quassel
- cli parser replaces now leading '~' with the homedir
***************************************************************************/
#include "cliparser.h"
+#include <QDir>
#include <QString>
#include <QFileInfo>
#include <QDebug>
bool CliParser::addLongArg(const CliParserArg::CliArgType type, const QString &name, const QString &value) {
if(argsHash.contains(name)){
if(type == CliParserArg::CliArgOption && argsHash.value(name).type == type) {
- argsHash[name].value = value;
+ argsHash[name].value = escapedValue(value);
return true;
}
else if (type == CliParserArg::CliArgSwitch && argsHash.value(name).type == type) {
QString longName = lnameOfShortArg(shortName);
if(!longName.isNull()) {
if(type == CliParserArg::CliArgOption && argsHash.value(longName).type == type) {
- argsHash[longName].value = value;
+ argsHash[longName].value = escapedValue(value);
return true;
}
else if (type == CliParserArg::CliArgSwitch) {
return false;
}
+QString CliParser::escapedValue(const QString &value) {
+ QString escapedValue = value;
+ if(escapedValue.startsWith("~"))
+ escapedValue.replace(0, 1, QDir::homePath());
+
+ return escapedValue;
+}
+
bool CliParser::parse() {
QStringList::const_iterator currentArg;
for (currentArg = argsRaw.constBegin(); currentArg != argsRaw.constEnd(); ++currentArg) {
void addArgument(const QString &longName, const CliParserArg &arg);
bool addLongArg(const CliParserArg::CliArgType type, const QString &name, const QString &value = QString());
bool addShortArg(const CliParserArg::CliArgType type, const char shortName, const QString &value = QString());
+ QString escapedValue(const QString &value);
QString lnameOfShortArg(const char arg);
QStringList argsRaw;
QHash<QString, CliParserArg> argsHash;
Global::parser.addSwitch("norestore", 'n', "Don't restore last core's state");
Global::parser.addOption("logfile",'l',"Path to logfile");
Global::parser.addOption("loglevel",'L',"Loglevel Debug|Info|Warning|Error","Info");
+ Global::parser.addOption("datadir", 0, "Specify the directory holding datafiles like the Sqlite DB and the SSL Cert");
#endif // BUILD_QTUI
#ifndef BUILD_CORE
// put client-only arguments here
qWarning("Warning: Couldn't open logfile '%s' - will log to stdout instead",qPrintable(logFile.fileName()));
else logFile.close();
}
- else qWarning("No logfile set - will log to stdout instead");
}
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
***************************************************************************/
#include "util.h"
+#include "global.h"
#include <QCoreApplication>
#include <QDebug>
}
QDir quasselDir() {
- // kinda ugly, but I currently see no other way to do that
+ QString quasselDir;
+ if(Global::parser.isSet("datadir")) {
+ quasselDir = Global::parser.value("datadir");
+ } else {
#ifdef Q_OS_WIN32
- QString quasselDir = qgetenv("APPDATA") + "/quassel/";
+ quasselDir = qgetenv("APPDATA") + "/quassel/";
+#elif defined Q_WS_MAC
+ quasselDir = QDir::homePath() + "/Library/Application Support/Quassel/";
#else
- QString quasselDir = QDir::homePath() + "/.quassel/";
+ quasselDir = QDir::homePath() + "/.quassel/";
#endif
+ }
QDir qDir(quasselDir);
if(!qDir.exists(quasselDir)) {