Enable customizing the save statistics time interval
[qBittorrent.git] / src / base / utils / os.h
blob9dc4df021763a5904ed3da929ec2c25fc6eee60e
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2023 Mike Tzou (Chocobo1)
4 * Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com>
5 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * In addition, as a special exception, the copyright holders give permission to
22 * link this program with the OpenSSL project's "OpenSSL" library (or with
23 * modified versions of it that use the same license as the "OpenSSL" library),
24 * and distribute the linked executables. You must obey the GNU General Public
25 * License in all respects for all of the code used other than "OpenSSL". If you
26 * modify file(s), you may extend this exception to your version of the file(s),
27 * but you are not obligated to do so. If you do not wish to do so, delete this
28 * exception statement from your version.
31 #pragma once
33 #include <QtSystemDetection>
35 #ifdef Q_OS_WIN
36 #include <string>
38 #include <windows.h>
40 #include <QString>
41 #endif
43 #include "base/path.h"
45 enum class ShutdownDialogAction;
47 namespace Utils::OS
49 void shutdownComputer(const ShutdownDialogAction &action);
51 #ifdef Q_OS_MACOS
52 bool isTorrentFileAssocSet();
53 void setTorrentFileAssoc();
54 bool isMagnetLinkAssocSet();
55 void setMagnetLinkAssoc();
56 #endif // Q_OS_MACOS
58 #ifdef Q_OS_WIN
59 Path windowsSystemPath();
61 template <typename T>
62 T loadWinAPI(const QString &source, const char *funcName)
64 const std::wstring path = (windowsSystemPath() / Path(source)).toString().toStdWString();
65 return reinterpret_cast<T>(::GetProcAddress(::LoadLibraryW(path.c_str()), funcName));
67 #endif // Q_OS_WIN
69 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
70 bool applyMarkOfTheWeb(const Path &file, const QString &url = {});
71 #endif // Q_OS_MACOS || Q_OS_WIN