|
|
@ -28,34 +28,18 @@ |
|
|
|
* Contact : chris@qbittorrent.org |
|
|
|
* Contact : chris@qbittorrent.org |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <QUrl> |
|
|
|
#include "misc.h" |
|
|
|
#include <QDir> |
|
|
|
|
|
|
|
#include <QFileInfo> |
|
|
|
|
|
|
|
#include <QDateTime> |
|
|
|
|
|
|
|
#include <QByteArray> |
|
|
|
|
|
|
|
#include <QDebug> |
|
|
|
|
|
|
|
#include <QProcess> |
|
|
|
|
|
|
|
#include <QRegularExpression> |
|
|
|
|
|
|
|
#include <QSysInfo> |
|
|
|
|
|
|
|
#include <boost/version.hpp> |
|
|
|
#include <boost/version.hpp> |
|
|
|
#include <libtorrent/version.hpp> |
|
|
|
#include <libtorrent/version.hpp> |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DISABLE_GUI |
|
|
|
|
|
|
|
#include <QCoreApplication> |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
#include <QApplication> |
|
|
|
|
|
|
|
#include <QDesktopWidget> |
|
|
|
|
|
|
|
#include <QStyle> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#include <windows.h> |
|
|
|
#include <windows.h> |
|
|
|
#include <powrprof.h> |
|
|
|
#include <powrprof.h> |
|
|
|
#include <Shlobj.h> |
|
|
|
#include <Shlobj.h> |
|
|
|
const int UNLEN = 256; |
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
#include <unistd.h> |
|
|
|
|
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/types.h> |
|
|
|
|
|
|
|
#include <unistd.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MAC |
|
|
@ -63,25 +47,38 @@ const int UNLEN = 256; |
|
|
|
#include <Carbon/Carbon.h> |
|
|
|
#include <Carbon/Carbon.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
#include <QByteArray> |
|
|
|
|
|
|
|
#include <QDateTime> |
|
|
|
|
|
|
|
#include <QDebug> |
|
|
|
|
|
|
|
#include <QDir> |
|
|
|
|
|
|
|
#include <QFileInfo> |
|
|
|
|
|
|
|
#include <QProcess> |
|
|
|
|
|
|
|
#include <QRegularExpression> |
|
|
|
|
|
|
|
#include <QSysInfo> |
|
|
|
|
|
|
|
#include <QUrl> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DISABLE_GUI |
|
|
|
|
|
|
|
#include <QCoreApplication> |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
#include <QApplication> |
|
|
|
|
|
|
|
#include <QDesktopServices> |
|
|
|
|
|
|
|
#include <QDesktopWidget> |
|
|
|
|
|
|
|
#include <QProcess> |
|
|
|
|
|
|
|
#include <QStyle> |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) |
|
|
|
#include <QDBusInterface> |
|
|
|
#include <QDBusInterface> |
|
|
|
#include <QDBusMessage> |
|
|
|
#include <QDBusMessage> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif // DISABLE_GUI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
|
|
|
|
#include <QDesktopServices> |
|
|
|
|
|
|
|
#include <QProcess> |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include "base/utils/string.h" |
|
|
|
#include "base/utils/string.h" |
|
|
|
#include "base/unicodestrings.h" |
|
|
|
#include "base/unicodestrings.h" |
|
|
|
#include "base/logger.h" |
|
|
|
#include "base/logger.h" |
|
|
|
#include "misc.h" |
|
|
|
|
|
|
|
#include "fs.h" |
|
|
|
#include "fs.h" |
|
|
|
|
|
|
|
|
|
|
|
static struct { const char *source; const char *comment; } units[] = { |
|
|
|
namespace |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const struct { const char *source; const char *comment; } units[] = { |
|
|
|
QT_TRANSLATE_NOOP3("misc", "B", "bytes"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "B", "bytes"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "KiB", "kibibytes (1024 bytes)"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "KiB", "kibibytes (1024 bytes)"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "MiB", "mebibytes (1024 kibibytes)"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "MiB", "mebibytes (1024 kibibytes)"), |
|
|
@ -90,6 +87,7 @@ static struct { const char *source; const char *comment; } units[] = { |
|
|
|
QT_TRANSLATE_NOOP3("misc", "PiB", "pebibytes (1024 tebibytes)"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "PiB", "pebibytes (1024 tebibytes)"), |
|
|
|
QT_TRANSLATE_NOOP3("misc", "EiB", "exbibytes (1024 pebibytes)") |
|
|
|
QT_TRANSLATE_NOOP3("misc", "EiB", "exbibytes (1024 pebibytes)") |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) |
|
|
|
void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -474,6 +472,7 @@ QString Utils::Misc::getUserIDString() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString uid = "0"; |
|
|
|
QString uid = "0"; |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
|
|
|
|
const int UNLEN = 256; |
|
|
|
WCHAR buffer[UNLEN + 1] = {0}; |
|
|
|
WCHAR buffer[UNLEN + 1] = {0}; |
|
|
|
DWORD buffer_len = sizeof(buffer) / sizeof(*buffer); |
|
|
|
DWORD buffer_len = sizeof(buffer) / sizeof(*buffer); |
|
|
|
if (GetUserNameW(buffer, &buffer_len)) |
|
|
|
if (GetUserNameW(buffer, &buffer_len)) |
|
|
|