From d263670724f4ba741dee610fde15d293099561e8 Mon Sep 17 00:00:00 2001 From: naru Date: Fri, 11 Oct 2002 06:43:10 +0000 Subject: [PATCH] Ghost stats now use IdHTTP instead of FastNet --- bottleclient/MainForm.dfm | 18 ------ bottleclient/MainForm.pas | 160 +++++++++++++++++++++------------------------- 2 files changed, 73 insertions(+), 105 deletions(-) diff --git a/bottleclient/MainForm.dfm b/bottleclient/MainForm.dfm index 00772f0..2ad47a0 100755 --- a/bottleclient/MainForm.dfm +++ b/bottleclient/MainForm.dfm @@ -1957,24 +1957,6 @@ object frmSender: TfrmSender OnClick = mnWarnPostClick end end - object NMHTTPGhost: TNMHTTP - Port = 0 - TimeOut = 20000 - ReportLevel = 0 - Body = 'Default.htm' - Header = 'Head.txt' - HeaderInfo.LocalProgram = 'BottleClient' - HeaderInfo.Referer = 'http://bottle.mikage.to/' - InputFileMode = False - OutputFileMode = True - ProxyPort = 0 - Left = 328 - Top = 106 - end - object NMURL: TNMURL - Left = 328 - Top = 136 - end object SakuraSeeker: TSakuraSeeker OnDetectResultChanged = SakuraSeekerDetectResultChanged FileMappingTarget.Strings = ( diff --git a/bottleclient/MainForm.pas b/bottleclient/MainForm.pas index 673968a..7dc77cc 100755 --- a/bottleclient/MainForm.pas +++ b/bottleclient/MainForm.pas @@ -8,9 +8,9 @@ uses IniFiles, ExtCtrls, ShellAPI, StdActns, ActnList, ConstList, ConstEditor, AppEvnts, TaskTray, ImgList, ToolWin, Buttons, MenuBar, RichEdit, Clipbrd, ColorCBX, SsParser, MPlayer, SakuraSeeker, - HeadValue, OleCtrls, SHDocVw, SakuraAPI, NMURL, Logs, + HeadValue, OleCtrls, SHDocVw, SakuraAPI, Logs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdSLPP20, - IdException; + IdException, HttpThread, IdHTTP, IdURI; type TfrmSender = class(TForm) @@ -128,8 +128,6 @@ type mnPopUpChannelTab: TPopupMenu; mnLeaveThisChannel: TMenuItem; mnCanAutoAdd: TMenuItem; - NMHTTPGhost: TNMHTTP; - NMURL: TNMURL; N4: TMenuItem; mnGotoVote: TMenuItem; mnGotoGLog: TMenuItem; @@ -200,7 +198,6 @@ type procedure actSleepExecute(Sender: TObject); procedure tabChannelDrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean); - procedure Button1Click(Sender: TObject); procedure actVoteMessageExecute(Sender: TObject); procedure tabChannelContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean); @@ -222,6 +219,7 @@ type procedure mnWarnPostClick(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure actAgreeMessageExecute(Sender: TObject); + procedure Button1Click(Sender: TObject); private FSleeping: boolean; FStatusText: String; @@ -273,6 +271,7 @@ type procedure UpdateChannelInfo(Dat: THeadValue); procedure UpdateJoinChannelList(Dat: THeadValue); procedure NoLuidError; + procedure UpdateIfGhostBox; public function GetChannelPrefs(const ChannelName: String): TChannelPrefs; function DoTrans(var Script: String; @@ -531,13 +530,10 @@ begin IdSlpp20.Host := Pref.ProxyAddress; IdSlpp20.Port := Pref.ProxyPort; IdSlpp20.ProxyMode := true; - NMHTTPGhost.Proxy := Pref.ProxyAddress; - NMHTTPGhost.ProxyPort := Pref.ProxyPort; end else begin IdSlpp20.Host := 'bottle.mikage.to'; IdSlpp20.Port := 9871; IdSlpp20.ProxyMode := false; - NMHTTPGhost.Proxy := ''; end; IdSlpp20.Connect; except @@ -1344,58 +1340,31 @@ end; procedure TfrmSender.SakuraSeekerDetectResultChanged(Sender: TObject); var i: integer; GhostList: String; - TmpStr: TFileStream; - Selected: String; + Http: THTTPDownloadThread; + SendOk: boolean; begin - Selected := cbxTargetGhost.Text; - with cbxTargetGhost do begin - Items.BeginUpdate; - Items.Clear; - Items.Add('(CH„§)'); - for i := 0 to SakuraSeeker.Count-1 do begin - if cbxTargetGhost.Items.IndexOf(SakuraSeeker[i].Name) < 0 then - cbxTargetGhost.Items.Add(SakuraSeeker[i].Name); - end; - Items.EndUpdate; - cbxTargetGhost.ItemIndex := 0; - if (Length(Selected) > 0) and (Selected <> '(CH„§)') then begin - with cbxTargetGhost do begin - for i := 1 to Items.Count-1 do begin - if Items[i] = Selected then - ItemIndex := i; - end; - //ƒS[ƒXƒg‚ª“Ë‘R‘¶Ý‚µ‚È‚­‚È‚Á‚½ê‡‘΍ô - if ItemIndex = 0 then begin - Items.Add(Selected); - ItemIndex := Items.Count - 1; - end; - end; - end; - end; + UpdateIfGhostBox; // ƒhƒƒbƒvƒ_ƒEƒ“‚Ì’†g‚ð‘‚«Š·‚¦‚é //‘¨’²¸‚ÉŽQ‰Á if FBooted and not Pref.NoSendGhostList and (SakuraSeeker.Count > 0) then begin - NMURL.InputString := 'ˆ¤'; - GhostList := 'CCC=' + NMURL.Encode; + GhostList := 'CCC=' + TIdURI.ParamsEncode('ˆ¤'); GhostList := GhostList + '&LUID=' + Pref.LUID; + SendOk := false; for i := 0 to SakuraSeeker.Count-1 do begin - NMURL.InputString := SakuraSeeker[i].SetName; - if SakuraSeeker[i].Name <> '' then - GhostList := GhostList + '&GHOST=' + NMURL.Encode; + if SakuraSeeker[i].Name <> '' then begin//‚±‚ꂪ‚È‚¢‚Æ‚½‚Ü‚ÉFMO‰ó‚ê‚Å‹ó‚̃S[ƒXƒg‚ð‘—‚Á‚Ä‚µ‚Ü‚¤ + GhostList := GhostList + '&GHOST=' + TIdURI.ParamsEncode(SakuraSeeker[i].SetName); + SendOk := true; + end; end; - TmpStr := nil; - try - TmpStr := TFileStream.Create( - ExtractFilePath(Application.ExeName)+'ghost.tmp', - fmCreate or fmShareDenyWrite - ); - for i := 1 to Length(GhostList) do - TmpStr.Write(GhostList[i], 1); - finally - TmpStr.Free; + if SendOk then begin + Http := THTTPDownloadThread.Create(BottleServer, Pref.CgiNameGhost, GhostList); + { TODO : Proxy OK? } + if Pref.UseHttpProxy then begin + Http.ProxyServer := Pref.ProxyAddress; + Http.ProxyPort := Pref.ProxyPort; + end; + Http.FreeOnTerminate := true; + Http.Resume; end; - NMHTTPGhost.Disconnect; - NMHTTPGhost.Post(Pref.CgiNameGhost, - ExtractFilePath(Application.ExeName)+'ghost.tmp'); end; end; @@ -1531,10 +1500,8 @@ end; procedure TfrmSender.cbxTargetGhostDropDown(Sender: TObject); begin - SakuraSeeker.OnDetectResultChanged := nil; SakuraSeeker.BeginDetect; - SakuraSeekerDetectResultChanged(nil); - SakuraSeeker.OnDetectResultChanged := SakuraSeekerDetectResultChanged; + UpdateIfGhostBox; end; procedure TfrmSender.FastSstpResendTrying(Sender: TObject; ID: Integer; @@ -1774,37 +1741,6 @@ begin end; end; -procedure TfrmSender.Button1Click(Sender: TObject); -begin - {SetHWndToFavoriteGhost('ˆÀŽq'); - FastSSTP.SstpSEND('hogehoge', [soNoTranslate], SakuraSeeker.ProcessByName['ˆÀŽq'].SetName); - ShowMessage(FastSstp.SentLog); - ShowMessage(FastSSTP.RecvLog);} - {Ghost := FastSstp.SstpExGetName; - ShowMessage(Ghost); - ShowMessage(FastSstp.SentLog);} - //FastSstp.SstpSEND('hogehoge', [], Ghost); - //ShowMessage(FastSstp.RecvLog); - {Str := nil; - try - Str := TStringList.Create; - with Str do begin - Add('SEND SSTP/1.4'); - Add('Sender: ƒJ[ƒhƒLƒƒƒvƒ^['); - Add('IfGhost: ‚³‚­‚ç,‚¤‚ɂイ'); - Add('Script: \h\s0‚³‚­‚炾[B\w8\n\n%j'); - Add('Charset: Shift_JIS'); - Add('Option: nodescript'); - Add('HWnd: ' + IntToStr(FastSstp.Handle)); - end; - FastSstp.ConnectSstp(Str); - ShowMessage(FastSstp.SentLog); - ShowMessage(FastSstp.RecvLog); - finally - Str.Free; - end;} -end; - procedure TfrmSender.actVoteMessageExecute(Sender: TObject); var Log: TLogItem; begin @@ -2039,4 +1975,54 @@ begin end; +procedure TfrmSender.Button1Click(Sender: TObject); +var Th: THTTPDownloadThread; +begin + if Sender is TButton then begin + Th := THTTPDownloadThread.Create('bottle.mikage.to', '/paro.cgi', ''); + Th.FreeOnTerminate := true; + Th.OnSuccess := Button1Click; + Th.Resume; + end else if Sender is THTTPDownloadThread then begin + Th := Sender as THTTPDownloadThread; + SysUtils.Beep; + memScript.Text := 'RECV=' + Th.RecvString; + end; +end; + +procedure TfrmSender.UpdateIfGhostBox; +var + Selected: String; + i: integer; +begin + Selected := cbxTargetGhost.Text; + with cbxTargetGhost do begin + Items.BeginUpdate; + Items.Clear; + Items.Add('(CH„§)'); + for i := 0 to SakuraSeeker.Count-1 do begin + // ”j‘¹FMO‘΍ôBHWND‚Ì’f•Ð‚ªŽc‚Á‚Ä‚¢‚邪Name‚ªÁ‚¦‚Ä‚¢‚éê‡‚ª‚ ‚é + if Length(SakuraSeeker[i].Name) = 0 then Continue; + if cbxTargetGhost.Items.IndexOf(SakuraSeeker[i].Name) < 0 then + cbxTargetGhost.Items.Add(SakuraSeeker[i].Name); + end; + Items.EndUpdate; + cbxTargetGhost.ItemIndex := 0; + if (Length(Selected) > 0) and (Selected <> '(CH„§)') then begin + with cbxTargetGhost do begin + for i := 1 to Items.Count-1 do begin + if Items[i] = Selected then + ItemIndex := i; + end; + //ƒS[ƒXƒg‚ª“Ë‘R‘¶Ý‚µ‚È‚­‚È‚Á‚½ê‡‘΍ô + if ItemIndex = 0 then begin + Items.Add(Selected); + ItemIndex := Items.Count - 1; + end; + end; + end; + end; + +end; + end. -- 2.11.0