-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUDataDNet.pas
165 lines (143 loc) · 3.56 KB
/
UDataDNet.pas
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
unit UDataDNet;
{$MODE Delphi}
interface
uses
DataThread;
type
TDNetDataThread = class(TDataThread)
private
replline2, replline1: String;
procedure UpdateDNetStats;
protected
procedure DoUpdate; override;
public
constructor Create;
destructor Destroy; override;
procedure ResolveVariables(var Line : string); override;
end;
implementation
uses
SysUtils,UConfig;
constructor TDNetDataThread.Create;
begin
replline2 := '';
replline1 := '';
inherited Create(100000); // this is probably way too often, but just duplicating past functionality
end;
destructor TDNetDataThread.Destroy;
begin
inherited;
end;
procedure TDNetDataThread.UpdateDNetStats;
var
fFile: textfile;
x,counter: Integer;
line: String;
replline: String;
sTemp: String;
begin
x := 0;
replline := 'File not found';
if FileExists(config.distLog) = true then
begin
assignfile(fFile, config.distLog);
reset (fFile);
while not eof(fFile) do
begin
readln (fFile);
x := x + 1;
end;
reset(fFile);
for counter := 1 to x-50 do
begin
readln(fFile);
end;
while not eof(fFile) do
begin
readln(fFile, line);
replline := replline + ' ' + line;
end;
closefile(fFile);
end;
replline := copy(replline, pos('Completed', replline)-5,
length(replline));
for x := 1 to 9 do
begin
if pos('Completed', replline) <> 0 then
begin
replline := copy(replline, pos('Completed', replline)-5,
length(replline));
replline := StringReplace(replline, 'Completed', '-', []);
end;
end;
if copy(replline, 1, 3) = 'RC5' then
begin
sTemp := copy(replline, pos('- [', replline) + 3, pos(' keys',
replline)-pos('- [', replline));
if length(sTemp) > 7 then
begin
sTemp := copy(sTemp, 1, pos(',', copy(sTemp, 3,
length(sTemp))) + 1);
end;
fDataLock.Enter();
replline1 := sTemp;
fDataLock.Leave();
replline := copy(replline, pos('completion', replline) + 30, 200);
sTemp := copy(replline, pos('(', replline) + 1, pos('.',
replline)-pos('(', replline)-1);
fDataLock.Enter();
replline2 := sTemp;
fDataLock.Leave();
end;
if copy(replline, 1, 3) = 'OGR' then
begin
sTemp := copy(replline, pos('- [', replline) + 3, pos(' nodes',
replline)-pos('- [', replline));
if length(sTemp) > 7 then
begin
sTemp := copy(sTemp, 1, pos(',', copy(sTemp, 3,
length(sTemp))) + 1);
end;
fDataLock.Enter();
replline1 := sTemp;
fDataLock.Leave();
replline := copy(replline, pos('remain', replline) + 8, 100);
sTemp := copy(replline, pos('(', replline) + 1, pos('stats',
replline)-pos('(', replline)-3);
fDataLock.Enter();
replline2 := sTemp;
fDataLock.Leave();
end;
end;
procedure TDNetDataThread.DoUpdate;
var
bReplz: Boolean;
ScreenCount, LineCount: Integer;
screenline: String;
begin
bReplz := false;
for ScreenCount := 1 to MaxScreens do
begin
for LineCount := 1 to config.height do
begin
screenline := config.screen[ScreenCount].line[LineCount].text;
if (not bReplz) and (pos('$Dnet', screenline) <> 0) then bReplz := true;
end;
end;
if bReplz then
UpdateDNetStats;
end;
procedure TDNetDataThread.ResolveVariables(var Line : string);
begin
if (pos('$Dnet', line) <> 0) then
begin
fDataLock.Enter();
try
line := StringReplace(line, '$DnetDone', replline2, [rfReplaceAll]);
line := StringReplace(line, '$DnetSpeed', replline1, [rfReplaceAll]);
finally
fDataLock.Leave();
end;
end;
end;
end.