2017-09-02 08:07:07 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQuick.Controls 2.2
|
2017-09-02 10:17:51 +00:00
|
|
|
import com.fortfirewall 1.0
|
2017-09-02 08:07:07 +00:00
|
|
|
|
|
|
|
BasePage {
|
|
|
|
|
2017-09-04 11:39:15 +00:00
|
|
|
readonly property DriverManager driverManager: fortManager.driverManager
|
|
|
|
|
|
|
|
property bool enableLogReading: false
|
|
|
|
|
|
|
|
property var appPaths: []
|
|
|
|
property var appPathsMap: ({})
|
|
|
|
|
|
|
|
function readLogAsync() {
|
|
|
|
driverManager.readLogAsync(logBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancelDeviceIo() {
|
|
|
|
driverManager.cancelDeviceIo();
|
|
|
|
}
|
|
|
|
|
|
|
|
function switchLogReading(enable) {
|
|
|
|
enableLogReading = enable;
|
|
|
|
|
|
|
|
fortManager.setAppLogBlocked(enable);
|
|
|
|
|
|
|
|
if (enable) {
|
|
|
|
readLogAsync();
|
|
|
|
} else {
|
|
|
|
cancelDeviceIo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearAppPaths() {
|
|
|
|
appPaths = ([]);
|
|
|
|
appPathsMap = ({});
|
|
|
|
}
|
|
|
|
|
|
|
|
function processLogBuffer() {
|
|
|
|
while (logBuffer.read(logEntry)) {
|
|
|
|
var path = logEntry.path;
|
|
|
|
var ipText = logEntry.ipText;
|
|
|
|
console.log(">", path, ipText);
|
|
|
|
|
|
|
|
var ipTextsMap = appPathsMap[path];
|
|
|
|
if (!ipTextsMap) {
|
|
|
|
ipTextsMap = ({});
|
|
|
|
appPathsMap[path] = ipTextsMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipTextsMap[ipText] = (ipTextsMap[ipText] || 0) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: mainPage
|
|
|
|
onClosed: switchLogReading(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: driverManager
|
|
|
|
onReadLogResult: {
|
|
|
|
if (success) {
|
|
|
|
processLogBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enableLogReading) {
|
|
|
|
readLogAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LogBuffer {
|
|
|
|
id: logBuffer
|
|
|
|
}
|
|
|
|
LogEntry {
|
|
|
|
id: logEntry
|
|
|
|
}
|
|
|
|
|
2017-09-02 13:48:33 +00:00
|
|
|
ColumnLayout {
|
2017-09-02 14:36:38 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2017-09-04 11:39:15 +00:00
|
|
|
RowLayout {
|
|
|
|
Button {
|
|
|
|
text: QT_TRANSLATE_NOOP("qml", "Clear")
|
|
|
|
onClicked: clearAppPaths()
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
text: QT_TRANSLATE_NOOP("qml", "Show Blocked Applications and Addresses")
|
|
|
|
onToggled: switchLogReading(checked)
|
2017-09-02 13:48:33 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-02 14:36:38 +00:00
|
|
|
|
2017-09-04 11:39:15 +00:00
|
|
|
ListView {
|
2017-09-02 14:36:38 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2017-09-02 13:48:33 +00:00
|
|
|
}
|
2017-09-02 08:07:07 +00:00
|
|
|
}
|