| 12 |
} |
} |
| 13 |
TSambaTimer = class(TTimer) |
TSambaTimer = class(TTimer) |
| 14 |
private |
private |
|
FBoard : TBoard; |
|
| 15 |
FKey : string; |
FKey : string; |
| 16 |
FWriteDeta : TDateTime; |
FWriteDeta : TDateTime; |
| 17 |
FSambaInterval : Integer; |
FSambaInterval : Integer; |
| 18 |
procedure ReadSambaTime; |
procedure ReadSambaTime; |
| 19 |
procedure ReadSettingTime(); |
procedure ReadSettingTime(Board: TBoard); |
| 20 |
public |
public |
| 21 |
function SetBoard(Board : TBoard): integer; |
function SetBoard(Board : TBoard): integer; |
| 22 |
function CheckSambaTime(ATime: TDateTime): Boolean; |
function CheckSambaTime(ATime: TDateTime): Boolean; |
| 38 |
} |
} |
| 39 |
function TSambaTimer.SetBoard(Board : TBoard): Integer; |
function TSambaTimer.SetBoard(Board : TBoard): Integer; |
| 40 |
begin |
begin |
| 41 |
Result := 0; |
Result := -1; |
| 42 |
Enabled := False; |
Enabled := False; |
| 43 |
if (Board <> nil) then begin |
if (Board <> nil) then begin |
|
FBoard := Board; |
|
| 44 |
// 板が2chに属している場合,タイマーを有効にする |
// 板が2chに属している場合,タイマーを有効にする |
| 45 |
if (FBoard.Is2ch) then begin |
if (Board.Is2ch) then begin |
| 46 |
ReadSettingTime; |
ReadSettingTime(Board); |
| 47 |
ReadSambaTime; |
ReadSambaTime; |
| 48 |
Interval := 500; |
Interval := 500; |
| 49 |
Result := FSambaInterval; |
Result := FSambaInterval; |
| 53 |
{ |
{ |
| 54 |
\brief Sambaの規定値を読み込む |
\brief Sambaの規定値を読み込む |
| 55 |
} |
} |
| 56 |
procedure TSambaTimer.ReadSettingTime(); |
procedure TSambaTimer.ReadSettingTime(Board: TBoard); |
| 57 |
var |
var |
| 58 |
ini :TMemIniFile; |
ini :TMemIniFile; |
| 59 |
Protocol, Host, Path, Document, Port, Bookmark : string; |
Protocol, Host, Path, Document, Port, Bookmark : string; |
| 61 |
Enabled := false; //経過秒数表示TimerをOffにする |
Enabled := false; //経過秒数表示TimerをOffにする |
| 62 |
ini := TMemIniFile.Create(GikoSys.GetSambaFileName); |
ini := TMemIniFile.Create(GikoSys.GetSambaFileName); |
| 63 |
try |
try |
| 64 |
// まずBBSIDで個別に設定されていないか確認する |
if (Board <> nil) then begin |
| 65 |
FKey := '@' + FBoard.BBSID; |
// まずBBSIDで個別に設定されていないか確認する |
| 66 |
FSambaInterval := ini.ReadInteger('Setting', FKey, -1); |
FKey := '@' + Board.BBSID; |
| 67 |
if (FSambaInterval = -1) then begin |
FSambaInterval := ini.ReadInteger('Setting', FKey, -1); |
| 68 |
// 設定されていないのでホスト名の設定を取ってくる |
if (FSambaInterval = -1) then begin |
| 69 |
GikoSys.ParseURI( FBoard.URL, Protocol, Host, Path, Document, Port, Bookmark ); |
// 設定されていないのでホスト名の設定を取ってくる |
| 70 |
FKey := Copy(Host, 1, AnsiPos('.', Host) - 1); |
GikoSys.ParseURI( Board.URL, Protocol, Host, Path, Document, Port, Bookmark ); |
| 71 |
|
FKey := Copy(Host, 1, AnsiPos('.', Host) - 1); |
| 72 |
|
FSambaInterval := ini.ReadInteger('Setting', FKey, -1); |
| 73 |
|
//設定されていないときは、ファイルに書きたす。 |
| 74 |
|
if FSambaInterval = -1 then begin |
| 75 |
|
FSambaInterval := 0; |
| 76 |
|
ini.WriteInteger('Setting', FKey, 0); |
| 77 |
|
ini.UpdateFile; |
| 78 |
|
end; |
| 79 |
|
end; |
| 80 |
|
end else begin |
| 81 |
FSambaInterval := ini.ReadInteger('Setting', FKey, -1); |
FSambaInterval := ini.ReadInteger('Setting', FKey, -1); |
|
//設定されていないときは、ファイルに書きたす。 |
|
|
if FSambaInterval = -1 then begin |
|
|
FSambaInterval := 0; |
|
|
ini.WriteInteger('Setting', FKey, 0); |
|
|
ini.UpdateFile; |
|
|
end; |
|
| 82 |
end; |
end; |
| 83 |
finally |
finally |
| 84 |
ini.Free; |
ini.Free; |
| 136 |
} |
} |
| 137 |
function TSambaTimer.Update : TDateTime; |
function TSambaTimer.Update : TDateTime; |
| 138 |
begin |
begin |
| 139 |
ReadSettingTime; |
ReadSettingTime( nil ); |
| 140 |
ReadSambaTime; |
ReadSambaTime; |
| 141 |
Result := Now(); |
Result := Now(); |
| 142 |
end; |
end; |