-
Notifications
You must be signed in to change notification settings - Fork 1
/
spywkbridge.cpp
139 lines (109 loc) · 3.52 KB
/
spywkbridge.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include "subversionspy.h"
#include "spywkbridge.h"
namespace Spy{
SpyWkBridge::SpyWkBridge(SubversionSpy *spy, QObject *parent) :
QObject(parent),
spy(spy)
{
}
QString SpyWkBridge::openDirBrowser()
{
return QFileDialog::getExistingDirectory();
}
void SpyWkBridge::sendNotification(QString message, int type)
{
this->spy->displaynotific(message, (SpyNotifications)type);
}
QStringList SpyWkBridge::getAllNotifications()
{
QStringList ret_lst;
QMutex* notiLogMutex = 0;
QVector<NotificationEntry> *noti_logs = spy->get_all_notific(¬iLogMutex);
if (!notiLogMutex)
return ret_lst;
notiLogMutex->lock();
QVectorIterator<NotificationEntry> noti_itr(*noti_logs);
while (noti_itr.hasNext())
{
NotificationEntry nextLogEntry = noti_itr.next();
ret_lst.append(nextLogEntry.msg.append(":" + QString::number((int)nextLogEntry.type)));
}
notiLogMutex->unlock();
return ret_lst;
}
QStringList SpyWkBridge::getListenerPaths()
{
QStringList listenerPathSList; // Compatible string list to be returned.
QMutex* listenerPathsMutex;
QVector<QString> *listenerPaths = spy->get_listen_paths(&listenerPathsMutex);
listenerPathsMutex->lock();
QVectorIterator<QString> listenerPathsIt(*listenerPaths);
while (listenerPathsIt.hasNext())
{
listenerPathSList.append(listenerPathsIt.next());
}
listenerPathsMutex->unlock();
return listenerPathSList;
}
void SpyWkBridge::addListenerPath(QString path)
{
QMutex* listenerPathsMutex;
QVector<QString>* listenerPaths = spy->get_listen_paths(&listenerPathsMutex);
listenerPathsMutex->lock();
listenerPaths->append(path);
listenerPathsMutex->unlock();
}
bool SpyWkBridge::removeListenerPath(QString path)
{
QMutex* listenerPathsMutex;
QVector<QString>* listenerPaths = spy->get_listen_paths(&listenerPathsMutex);
int32_t index = 0;
listenerPathsMutex->lock();
QVectorIterator<QString> listenerPathsIt(*listenerPaths);
while (listenerPathsIt.hasNext()){
if (listenerPathsIt.next() == path){
if (listenerPaths->size() > index) listenerPaths->remove(index); // Check boundary.
listenerPathsMutex->unlock();
return true;
}
index++;
}
listenerPathsMutex->unlock();
return false;
}
void SpyWkBridge::setPollRate(int seconds)
{
spy->setpollrate((uint32_t)seconds);
}
int SpyWkBridge::getPollRate()
{
return spy->getpollrate();
}
QVariantMap SpyWkBridge::getThreadState()
{
return spy->get_threadmonitor()->get_threads_state();
}
QVariantMap SpyWkBridge::getLogs(QString path)
{
QVariantMap fullLogList;
QMutex* vectorMutex = 0;
QVector<SubversionLog>* logs = spy->get_threadmonitor()->get_worker_logs(path, &vectorMutex);
vectorMutex->lock();
// Build our big monster log blob.
QVectorIterator<SubversionLog> logItr(*logs);
while (logItr.hasNext())
{
SubversionLog currentLog = logItr.next();
// Build details.
QVariantMap details;
details["revNumber"] = (uint32_t)currentLog.revNumber;
details["comment"] = currentLog.comment;
details["author"] = currentLog.author;
details["date"] = currentLog.date;
details["files"] = currentLog.files;
fullLogList[QString::number(currentLog.revNumber)] = details;
}
vectorMutex->unlock();
return fullLogList;
}
}