Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/SambaTimer.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Mon Aug 14 14:21:28 2006 UTC (17 years, 8 months ago) by h677
Branch: MAIN
File MIME type: text/x-pascal
レスエディタのSambaの処理用のクラスを新設

1 unit SambaTimer;
2
3 interface
4
5 uses
6 Windows, SysUtils, Classes, ExtCtrls,
7 BoardGroup, GikoSystem;
8
9 type
10 {
11 \brief Samba24絲丞??帥?ゃ???若??????/span>
12 }
13 TSambaTimer = class(TTimer)
14 private
15 FBoard : TBoard;
16 FKey : string;
17 FWriteDeta : TDateTime;
18 FSambaInterval : Integer;
19 procedure ReadSambaTime;
20 procedure ReadSettingTime();
21 public
22 function SetBoard(Board : TBoard): integer;
23 function CheckSambaTime(ATime: TDateTime): Boolean;
24 procedure WriteSambaTime(ATime: TDateTime);
25 procedure UpdateSambaSetting(Interval : Integer);
26 function Update : TDateTime;
27 property WriteDeta : TDateTime read FWriteDeta;
28 property SambaInterval : Integer read FSambaInterval;
29 end;
30
31 implementation
32
33 uses
34 IniFiles, DateUtils;
35 {
36 \brief ?泣?潟???帥?ゃ???惹?炊???沿┃絎?
37 \param Board ???鴻?????c?帥????/span>
38 \return Samba??┃絎???/span>
39 }
40 function TSambaTimer.SetBoard(Board : TBoard): Integer;
41 begin
42 Result := 0;
43 Enabled := False;
44 if (Board <> nil) then begin
45 FBoard := Board;
46 // ?帥??2ch????????????翫??鐚??帥?ゃ???若?????鴻??????
47 if (FBoard.Is2ch) then begin
48 ReadSettingTime;
49 ReadSambaTime;
50 Interval := 500;
51 Result := FSambaInterval;
52 end;
53 end;
54 end;
55 {
56 \brief Samba???絎??ゃ??茯??粋昭??
57 }
58 procedure TSambaTimer.ReadSettingTime();
59 var
60 ini :TMemIniFile;
61 Protocol, Host, Path, Document, Port, Bookmark : string;
62 begin
63 Enabled := false; //腟?????域;腓?imer??Off??????
64 ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
65 try
66 // ?障??BBSID?у???ャ??┃絎???????????????腆肴?????
67 FKey := '@' + FBoard.BBSID;
68 FSambaInterval := ini.ReadInteger('Setting', FKey, -1);
69 if (FSambaInterval = -1) then begin
70 // 荐?????????????????с???鴻??????┃絎??????c?????
71 GikoSys.ParseURI( FBoard.URL, Protocol, Host, Path, Document, Port, Bookmark );
72 FKey := Copy(Host, 1, AnsiPos('.', Host) - 1);
73 FSambaInterval := ini.ReadInteger('Setting', FKey, -1);
74 //荐?????????????????????????<?ゃ?????吾????????
75 if FSambaInterval = -1 then begin
76 FSambaInterval := 0;
77 ini.WriteInteger('Setting', FKey, 0);
78 ini.UpdateFile;
79 end;
80 end;
81 finally
82 ini.Free;
83 end;
84 Enabled := true; //腟?????域;腓?imer??On??????
85 end;
86
87 {
88 \brief Samba.ini???吾??莨若?炊??????茯??粋昭??
89 }
90 procedure TSambaTimer.ReadSambaTime;
91 var
92 ini :TMemIniFile;
93 begin
94 Enabled := false; //腟?????域;腓?imer??Off??????
95 ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
96 try
97 //??絖????ц??水??c????紊????∽?違??DateTime??/span>
98 FWriteDeta := ConvertDateTimeString(
99 ini.ReadString('Send', FKey, ''));
100 finally
101 ini.Free;
102 end;
103 Enabled := true; //腟?????域;腓?imer??On??????
104 end;
105 {
106 \brief Samba.ini????腟??吾??莨若?炊???????吾??莨若??
107 }
108 procedure TSambaTimer.WriteSambaTime(ATime: TDateTime);
109 var
110 ini :TMemIniFile;
111 begin
112 ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
113 try
114 ini.WriteDateTime('Send', FKey, ATime);
115 ini.UpdateFile;
116 finally
117 ini.Free;
118 end;
119 end;
120
121 {
122 \brief ??腟??吾??莨若?炊??????憜??????罸?莠?????
123 \return ??鐚?荀鎘??や札筝????緒?荀鎘??ゆ???
124 }
125 function TSambaTimer.CheckSambaTime(ATime: TDateTime): Boolean;
126 var
127 pastsec: double;
128 begin
129 pastsec := SecondSpan(ATime, FWriteDeta);
130 Result := (pastsec > FSambaInterval);
131 end;
132 {
133 \breif ?帥?ゃ???惹???掩?贋??/span>
134 }
135 function TSambaTimer.Update : TDateTime;
136 begin
137 ReadSettingTime;
138 ReadSambaTime;
139 Result := Now();
140 end;
141 {
142 \biref Samba荐???ゆ?贋??/span>
143 \param Interval 荐????/span>
144 }
145 procedure TSambaTimer.UpdateSambaSetting(Interval : Integer);
146 var
147 ini :TMemIniFile;
148 begin
149 Enabled := false; //腟?????域;腓?imer??Off??????
150 ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
151 try
152 FSambaInterval := Interval;
153 ini.WriteInteger('Setting', FKey, FSambaInterval);
154 ini.UpdateFile;
155 finally
156 ini.Free;
157 end;
158 Enabled := true; //腟?????域;腓?imer??On??????
159 end;
160
161 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26