X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fquassel.cpp;h=33b6cbd4c9bc2267df6441ac44a3aca8a16841a6;hb=0a1c1ff4f99a7eb53ff6cdd95ce5d7ac263e77d2;hp=35c674b002da345fcb04f2a348426bd223023ff6;hpb=8ec4a861065b8a037ea6af58b2916800007ed61f;p=quassel.git diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index 35c674b0..33b6cbd4 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -20,7 +20,11 @@ #include "quassel.h" +#include #include +#if !defined Q_OS_WIN32 && !defined Q_OS_MAC +# include +#endif #include #include @@ -54,13 +58,23 @@ Quassel::Quassel() { // we have crashhandler for win32 and unix (based on execinfo). // on mac os we use it's integrated backtrace generator #if defined(Q_OS_WIN32) || (defined(HAVE_EXECINFO) && !defined(Q_OS_MAC)) - signal(SIGABRT, handleSignal); - signal(SIGSEGV, handleSignal); -# ifndef Q_OS_WIN32 - signal(SIGBUS, handleSignal); -# endif -#endif +# ifndef Q_OS_WIN32 + // we only handle crashes ourselves if coredumps are disabled + struct rlimit *limit = (rlimit *) malloc(sizeof(struct rlimit)); + int rc = getrlimit(RLIMIT_CORE, limit); + + if(rc == -1 || !((long)limit->rlim_cur > 0 || limit->rlim_cur == RLIM_INFINITY)) { +# endif + signal(SIGABRT, handleSignal); + signal(SIGSEGV, handleSignal); +# ifndef Q_OS_WIN32 + signal(SIGBUS, handleSignal); + } + free(limit); +# endif + +#endif } Quassel::~Quassel() { @@ -85,6 +99,11 @@ bool Quassel::init() { return false; } + if(isOptionSet("version")) { + std::cout << qPrintable("Quassel IRC: " + Quassel::buildInfo().plainVersionString) << std::endl; + return false; + } + DEBUG = isOptionSet("debug"); return true; } @@ -219,7 +238,8 @@ void Quassel::logFatalMessage(const char *msg) { const QString &Quassel::coreDumpFileName() { if(_coreDumpFileName.isEmpty()) { - _coreDumpFileName = QString("Quassel-Crash-%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm")); + QDir configDir(configDirPath()); + _coreDumpFileName = configDir.absoluteFilePath(QString("Quassel-Crash-%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm"))); QFile dumpFile(_coreDumpFileName); dumpFile.open(QIODevice::Append); QTextStream dumpStream(&dumpFile); @@ -336,10 +356,17 @@ QString Quassel::findDataFilePath(const QString &fileName) { return QString(); } -void Quassel::loadTranslation(const QLocale &locale) { +QStringList Quassel::scriptDirPaths() { + QStringList res(configDirPath() + "scripts/"); + foreach(QString path, dataDirPaths()) + res << path + "scripts/"; + return res; +} + +QString Quassel::translationDirPath() { if(_translationDirPath.isEmpty()) { // We support only one translation dir; fallback mechanisms wouldn't work else. - // This means that if we have a $data/i18n dir, the internal :/i18n resource won't be considered. + // This means that if we have a $data/translations dir, the internal :/i18n resource won't be considered. foreach(const QString &dir, dataDirPaths()) { if(QFile::exists(dir + "translations/")) { _translationDirPath = dir + "translations/"; @@ -349,7 +376,10 @@ void Quassel::loadTranslation(const QLocale &locale) { if(_translationDirPath.isEmpty()) _translationDirPath = ":/i18n/"; } + return _translationDirPath; +} +void Quassel::loadTranslation(const QLocale &locale) { QTranslator *qtTranslator = QCoreApplication::instance()->findChild("QtTr"); QTranslator *quasselTranslator = QCoreApplication::instance()->findChild("QuasselTr"); @@ -369,8 +399,8 @@ void Quassel::loadTranslation(const QLocale &locale) { if(locale.language() == QLocale::C) return; - bool success = qtTranslator->load(QString("qt_%1").arg(locale.name()), _translationDirPath); + bool success = qtTranslator->load(QString("qt_%1").arg(locale.name()), translationDirPath()); if(!success) qtTranslator->load(QString("qt_%1").arg(locale.name()), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - quasselTranslator->load(QString("quassel_%1").arg(locale.name()), _translationDirPath); + quasselTranslator->load(QString("quassel_%1").arg(locale.name()), translationDirPath()); }