-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloudlistener.cpp
More file actions
54 lines (47 loc) · 1.76 KB
/
cloudlistener.cpp
File metadata and controls
54 lines (47 loc) · 1.76 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
#include "cloudlistener.h"
void CloudListener::setTasks(const QVector<SyncTask> &tasks)
{
myTasks=tasks;
}
CloudListener::CloudListener() {
computerName = QSysInfo::machineHostName();
}
void CloudListener::run()
{
while (true) {
for (auto const &x: myTasks){
if(x.getSyncStatus()==2||x.getSyncStatus()==-1){
continue;
}
QMap<QString,QString> map;
map = cosclient->getObjectTagging(x.getRemotePath(),"");
if(map.contains("computerName")){
if(map["computerName"]!=computerName){
if(map.contains("lastSyncTime")){
bool timeOut=false;
if(lastSyncTimeMap.contains(x.getRemotePath())){
if(lastSyncTimeMap[x.getRemotePath()].secsTo(QDateTime::currentDateTime())>12){
emit cloudDirectoryChanged(x,0);
otherDeviceMap[x.getRemotePath()]=map["computerName"];
lastSyncTimeMap[x.getRemotePath()]=QDateTime::currentDateTime();
continue;
}
}
else{
lastSyncTimeMap[x.getRemotePath()]=QDateTime::currentDateTime();
}
if(otherDeviceMap[x.getRemotePath()]!=map["computerName"]){
emit cloudDirectoryChanged(x,1);
otherDeviceMap[x.getRemotePath()]=map["computerName"];
lastSyncTimeMap[x.getRemotePath()]=QDateTime::currentDateTime();
}
}
}
}
}
QThread::sleep(5);
}
}
CloudListener::CloudListener(COSConfig configi) : config(configi) {
cosclient = new COSClient(config);
};