Browse Source

- Fixing indentation

- Stop catching SIGINT and SIGTERM once the application has exiting
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
99459dc55d
  1. 1636
      src/bittorrent.cpp
  2. 6
      src/bittorrent.h
  3. 50
      src/main.cpp
  4. 86
      src/misc.h

1636
src/bittorrent.cpp

File diff suppressed because it is too large Load Diff

6
src/bittorrent.h

@ -35,10 +35,10 @@ @@ -35,10 +35,10 @@
#include <QUrl>
#include <QStringList>
#ifdef DISABLE_GUI
#include <QCoreApplication>
#include <QCoreApplication>
#else
#include <QApplication>
#include <QPalette>
#include <QApplication>
#include <QPalette>
#endif
#include <QPointer>

50
src/main.cpp

@ -33,23 +33,23 @@ @@ -33,23 +33,23 @@
#include <QFile>
#ifndef DISABLE_GUI
#include <QApplication>
#include <QSplashScreen>
#include <QPlastiqueStyle>
#include "qgnomelook.h"
#include <QMotifStyle>
#include <QCDEStyle>
#ifdef Q_WS_WIN
#include <QWindowsXPStyle>
#endif
#ifdef Q_WS_MAC
#include <QMacStyle>
#endif
#include "GUI.h"
#include "ico.h"
#include <QApplication>
#include <QSplashScreen>
#include <QPlastiqueStyle>
#include "qgnomelook.h"
#include <QMotifStyle>
#include <QCDEStyle>
#ifdef Q_WS_WIN
#include <QWindowsXPStyle>
#endif
#ifdef Q_WS_MAC
#include <QMacStyle>
#endif
#include "GUI.h"
#include "ico.h"
#else
#include <QCoreApplication>
#include "headlessloader.h"
#include <QCoreApplication>
#include "headlessloader.h"
#endif
#include <QSettings>
@ -67,12 +67,17 @@ @@ -67,12 +67,17 @@
#include "preferences.h"
#ifdef DISABLE_GUI
QCoreApplication *app;
QCoreApplication *app;
#else
QApplication *app;
QApplication *app;
#endif
#ifndef Q_WS_WIN
void sigintHandler(int) {
qDebug("Catching SIGINT, exiting cleanly");
app->exit();
}
void sigtermHandler(int) {
qDebug("Catching SIGTERM, exiting cleanly");
app->exit();
@ -246,7 +251,7 @@ int main(int argc, char *argv[]){ @@ -246,7 +251,7 @@ int main(int argc, char *argv[]){
#ifndef Q_WS_WIN
signal(SIGABRT, sigabrtHandler);
signal(SIGTERM, sigtermHandler);
signal(SIGINT, sigtermHandler);
signal(SIGINT, sigintHandler);
signal(SIGSEGV, sigsegvHandler);
#endif
// Read torrents given on command line
@ -264,6 +269,13 @@ int main(int argc, char *argv[]){ @@ -264,6 +269,13 @@ int main(int argc, char *argv[]){
HeadlessLoader *loader = new HeadlessLoader(torrentCmdLine);
#endif
int ret = app->exec();
#ifndef Q_WS_WIN
// Application has exited, stop catching SIGINT and SIGTERM
signal(SIGINT, 0);
signal(SIGTERM, 0);
#endif
#ifndef DISABLE_GUI
delete window;
qDebug("GUI was deleted!");

86
src/misc.h

@ -47,9 +47,9 @@ @@ -47,9 +47,9 @@
#include <boost/date_time/posix_time/conversion.hpp>
#ifdef DISABLE_GUI
#include <QCoreApplication>
#include <QCoreApplication>
#else
#include <QApplication>
#include <QApplication>
#endif
#ifdef Q_WS_WIN
@ -183,68 +183,68 @@ public: @@ -183,68 +183,68 @@ public:
}
#ifdef Q_WS_MAC
static QString getFullPath(const FSRef &ref)
{
static QString getFullPath(const FSRef &ref)
{
QByteArray ba(2048, 0);
if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
return QString();
}
}
#endif
static QString QDesktopServicesDataLocation() {
static QString QDesktopServicesDataLocation() {
#ifdef Q_WS_WIN
#if defined Q_WS_WINCE
if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
#else
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
#endif
result = QString::fromWCharArray(path);
if (!QCoreApplication::applicationName().isEmpty())
result = result + QLatin1String("\\") + qApp->applicationName();
result = QString::fromWCharArray(path);
if (!QCoreApplication::applicationName().isEmpty())
result = result + QLatin1String("\\") + qApp->applicationName();
#else
#ifdef Q_WS_MAC
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
FSRef ref;
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
if (err)
return QString();
QString path = getFullPath(ref);
path += QLatin1Char('/') + qApp->applicationName();
return path;
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
FSRef ref;
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
if (err)
return QString();
QString path = getFullPath(ref);
path += QLatin1Char('/') + qApp->applicationName();
return path;
#else
QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
if (xdgDataHome.isEmpty())
xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
xdgDataHome += QLatin1String("/data/")
+ qApp->applicationName();
return xdgDataHome;
QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
if (xdgDataHome.isEmpty())
xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
xdgDataHome += QLatin1String("/data/")
+ qApp->applicationName();
return xdgDataHome;
#endif
#endif
}
}
static QString QDesktopServicesCacheLocation() {
static QString QDesktopServicesCacheLocation() {
#ifdef Q_WS_WIN
return QDesktopServicesDataLocation() + QLatin1String("\\cache");
return QDesktopServicesDataLocation() + QLatin1String("\\cache");
#else
#ifdef Q_WS_MAC
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
FSRef ref;
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
if (err)
return QString();
QString path = getFullPath(ref);
path += QLatin1Char('/') + qApp->applicationName();
return path;
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
FSRef ref;
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
if (err)
return QString();
QString path = getFullPath(ref);
path += QLatin1Char('/') + qApp->applicationName();
return path;
#else
QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
if (xdgCacheHome.isEmpty())
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
return xdgCacheHome;
QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
if (xdgCacheHome.isEmpty())
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
return xdgCacheHome;
#endif
#endif
}
}
static QString searchEngineLocation() {
QString location = QDir::cleanPath(QDesktopServicesDataLocation()

Loading…
Cancel
Save