-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckHostThread.cpp
More file actions
62 lines (58 loc) · 1.63 KB
/
CheckHostThread.cpp
File metadata and controls
62 lines (58 loc) · 1.63 KB
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
#include "CheckHostThread.h"
#include "mainwindow.h"
//construnctor of CheckHostThread
CheckHostThread::CheckHostThread(QString file)
{
have_shared=false;
(this->file)=file;
stopped=false;
}
//destructor of CheckHostThread
CheckHostThread::~CheckHostThread()
{
}
void CheckHostThread::run()
{
while(!stopped){
//this->mutex.lock();
//QSettings *checkini=new QSettings(file,QSettings::IniFormat);
inifile=new QSettings(this->file,QSettings::IniFormat);
check_host(inifile);
if(this->isFinished())
stop();
}
//this->mutex.unlock();
}
//Stop function, set stopped to true
void CheckHostThread::stop()
{
stopped=true;
}
void CheckHostThread::check_host(QSettings* ini)
{
QStringList childGroups=ini->childGroups();
QStringList allKeys=ini->allKeys();
//QMutexLocker locker(&mutex);
//List hosts that have shared files
foreach (const QString &childGroup, childGroups)
{
//Check whether that host has shared anything
ini->beginGroup(childGroup);
if(ini->childKeys().isEmpty())
break;
else
//list1->addItem(childGroup);
this->mutex.lock();
emit send_to_list1(childGroup);
this->mutex.unlock();
ini->endGroup();
}
//list all shared files
foreach (const QString &key, allKeys)
{
this->mutex.lock();
//list2->addItem(ini->value(key).toString());
emit send_to_list2(ini->value(key).toString());
this->mutex.unlock();
}
}