Revert Taskbar class.

This commit is contained in:
XMRig 2022-08-16 17:31:39 +07:00
parent 9a4558561f
commit d862ba853f
No known key found for this signature in database
GPG Key ID: 446A53638BE94409
4 changed files with 187 additions and 11 deletions

View File

@ -41,7 +41,7 @@ add_definitions(-DXMRIG_MINER_PROJECT)
set(WITH_SODIUM OFF) set(WITH_SODIUM OFF)
set(WITH_CRYPTONOTE ON) set(WITH_CRYPTONOTE ON)
set(WITH_CRYPTO_OPS ON) set(WITH_CRYPTO_OPS ON)
set(WITH_COM ON) set(WITH_COM OFF)
set(WITH_EVENTS OFF) set(WITH_EVENTS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/base/cmake" "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/base/cmake" "${CMAKE_SOURCE_DIR}/cmake")
@ -63,6 +63,7 @@ set(HEADERS
src/core/config/usage.h src/core/config/usage.h
src/core/Controller.h src/core/Controller.h
src/core/Miner.h src/core/Miner.h
src/core/Taskbar.h
src/crypto/cn/asm/CryptonightR_template.h src/crypto/cn/asm/CryptonightR_template.h
src/crypto/cn/c_blake256.h src/crypto/cn/c_blake256.h
src/crypto/cn/c_groestl.h src/crypto/cn/c_groestl.h
@ -105,6 +106,7 @@ set(SOURCES
src/core/config/ConfigTransform.cpp src/core/config/ConfigTransform.cpp
src/core/Controller.cpp src/core/Controller.cpp
src/core/Miner.cpp src/core/Miner.cpp
src/core/Taskbar.cpp
src/crypto/cn/c_blake256.c src/crypto/cn/c_blake256.c
src/crypto/cn/c_groestl.c src/crypto/cn/c_groestl.c
src/crypto/cn/c_jh.c src/crypto/cn/c_jh.c

View File

@ -30,12 +30,12 @@
#include "base/io/log/Tags.h" #include "base/io/log/Tags.h"
#include "base/kernel/OS.h" #include "base/kernel/OS.h"
#include "base/kernel/Process.h" #include "base/kernel/Process.h"
#include "base/kernel/Taskbar.h"
#include "base/net/stratum/Job.h" #include "base/net/stratum/Job.h"
#include "base/tools/Object.h" #include "base/tools/Object.h"
#include "base/tools/Timer.h" #include "base/tools/Timer.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "core/Controller.h"
#include "core/Taskbar.h"
#include "crypto/common/Nonce.h" #include "crypto/common/Nonce.h"
#include "version.h" #include "version.h"
@ -358,21 +358,18 @@ public:
Algorithms algorithms; Algorithms algorithms;
bool active = false; bool active = false;
bool battery_power = false; bool battery_power = false;
bool user_active = false;
bool enabled = true; bool enabled = true;
int32_t auto_pause = 0;
bool reset = true; bool reset = true;
bool user_active = false;
Controller *controller; Controller *controller;
int32_t auto_pause = 0;
Job job; Job job;
mutable std::map<Algorithm::Id, double> maxHashrate; mutable std::map<Algorithm::Id, double> maxHashrate;
std::vector<IBackend *> backends; std::vector<IBackend *> backends;
String userJobId; String userJobId;
Taskbar taskbar;
Timer *timer = nullptr; Timer *timer = nullptr;
uint64_t ticks = 0; uint64_t ticks = 0;
# ifdef XMRIG_FEATURE_COM
Taskbar m_taskbar;
# endif
}; };
@ -496,7 +493,7 @@ void xmrig::Miner::execCommand(char command)
void xmrig::Miner::pause() void xmrig::Miner::pause()
{ {
d_ptr->active = false; d_ptr->active = false;
// d_ptr->m_taskbar.setActive(false); // FIXME d_ptr->taskbar.setActive(false);
Nonce::pause(true); Nonce::pause(true);
Nonce::touch(); Nonce::touch();
@ -516,7 +513,7 @@ void xmrig::Miner::setEnabled(bool enabled)
} }
d_ptr->enabled = enabled; d_ptr->enabled = enabled;
// d_ptr->m_taskbar.setEnabled(enabled); // FIXME d_ptr->taskbar.setEnabled(enabled);
if (enabled) { if (enabled) {
LOG_INFO("%s " GREEN_BOLD("resumed"), Tags::miner()); LOG_INFO("%s " GREEN_BOLD("resumed"), Tags::miner());
@ -586,7 +583,7 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
mutex.unlock(); mutex.unlock();
d_ptr->active = true; d_ptr->active = true;
// d_ptr->m_taskbar.setActive(true); // FIXME d_ptr->taskbar.setActive(true);
if (ready) { if (ready) {
d_ptr->handleJobChange(); d_ptr->handleJobChange();

126
src/core/Taskbar.cpp Normal file
View File

@ -0,0 +1,126 @@
/* XMRig
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/Taskbar.h"
#ifdef _WIN32
#include <Shobjidl.h>
#include <Objbase.h>
namespace xmrig {
struct TaskbarPrivate
{
TaskbarPrivate()
{
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if (hr < 0) {
return;
}
hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_taskbar));
if (hr < 0) {
return;
}
hr = m_taskbar->HrInit();
if (hr < 0) {
m_taskbar->Release();
m_taskbar = nullptr;
return;
}
m_consoleWnd = GetConsoleWindow();
}
~TaskbarPrivate()
{
if (m_taskbar) {
m_taskbar->Release();
}
CoUninitialize();
}
ITaskbarList3* m_taskbar = nullptr;
HWND m_consoleWnd = nullptr;
};
Taskbar::Taskbar() : d_ptr(new TaskbarPrivate())
{
}
Taskbar::~Taskbar()
{
delete d_ptr;
}
void Taskbar::setActive(bool active)
{
m_active = active;
updateTaskbarColor();
}
void Taskbar::setEnabled(bool enabled)
{
m_enabled = enabled;
updateTaskbarColor();
}
void Taskbar::updateTaskbarColor()
{
if (d_ptr->m_taskbar) {
if (m_active) {
d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, m_enabled ? TBPF_NOPROGRESS : TBPF_PAUSED);
d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, m_enabled ? 0 : 1, 1);
}
else {
d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, TBPF_ERROR);
d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, 1, 1);
}
}
}
} // namespace xmrig
#else // _WIN32
namespace xmrig {
Taskbar::Taskbar() {}
Taskbar::~Taskbar() {}
void Taskbar::setActive(bool) {}
void Taskbar::setEnabled(bool) {}
} // namespace xmrig
#endif // _WIN32

51
src/core/Taskbar.h Normal file
View File

@ -0,0 +1,51 @@
/* XMRig
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_TASKBAR_H
#define XMRIG_TASKBAR_H
namespace xmrig {
struct TaskbarPrivate;
class Taskbar
{
public:
Taskbar();
~Taskbar();
void setActive(bool active);
void setEnabled(bool enabled);
private:
bool m_active = false;
bool m_enabled = true;
TaskbarPrivate* d_ptr = nullptr;
void updateTaskbarColor();
};
} // namespace xmrig
#endif /* XMRIG_TASKBAR_H */