-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguiupdater.cpp
81 lines (64 loc) · 1.79 KB
/
guiupdater.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "guiupdater.h"
guiUpdater::guiUpdater(QObject *parent) : QObject(parent)
{
Q_UNUSED(parent);
startUpdate();
}
guiUpdater::guiUpdater(const guiUpdater& other) : QObject(Q_NULLPTR)
{
this->m_update_is_on = other.m_update_is_on;
}
void guiUpdater::run_update()
{
QThread::currentThread()->setPriority(QThread::LowPriority);
QString password_to_gui;
while (true)
{
if (keepAlive() == false)
{
emit signal_updateFinished();
return;
}
// wait for start attacks
if (collisionAttackTask_CPU::attackStatus() != 1)
{
QThread::sleep(2);
}
else // attack has been started
{
// retrieve found passwords from the attack's buffer
while (true)
{
if (keepAlive() == false)
{
emit signal_updateFinished();
return;
}
// update GUI "busy" spinning
emit signal_computing();
password_to_gui = collisionAttackTask_CPU::getHit();
if (password_to_gui == QString(""))
{
// attack stopped
if (collisionAttackTask_CPU::attackStatus() != 1)
break;
QThread::sleep(1);
} else
{
// update the GUI with a new find
emit signal_pwfound(password_to_gui);
}
}
}
}
}
bool guiUpdater::keepAlive()
{
// check stop request
if (updateStatus() == false)
return false;
// keep GUI more responsive during heavyload computations
emit signal_repaint();
qApp->processEvents();
return true;
}