OSDN Git Service

・TBoardPlugIns に AcceptURL, CreateThreadItem, DisposeThreadItem を追加。
authoryoffy <yoffy>
Wed, 5 Nov 2003 15:18:40 +0000 (15:18 +0000)
committeryoffy <yoffy>
Wed, 5 Nov 2003 15:18:40 +0000 (15:18 +0000)
・ユニットに InitializeBoardPlugIns を追加。
・ThreadItemSetLong で文字列をセットする際に戻り値ではなく引数に対して DisposeResultString を呼んでしまっていたので修正。

ExternalBoardManager.pas

index 6514991..0d319b3 100644 (file)
@@ -5,7 +5,7 @@ interface
 uses
        Windows, Classes, SysUtils,
        IdHTTP, IdComponent, IdGlobal, IdException,
-       GikoSystem, BoardGroup, AbonUnit;
+       AbonUnit;
 
 type
        // TThreadItem \82Ì\83v\83\8d\83p\83e\83B\90Ý\92è\81^\8eæ\93¾ ID
@@ -30,7 +30,8 @@ type
                tipScrollTop,                                           // : Integer            // \83X\83N\83\8d\81[\83\8b\88Ê\92u
                tipDownloadHost,                                // : string                     // \8d¡\82Ì\83z\83X\83g\82Æ\88á\82¤\8fê\8d\87\82Ì\83z\83X\83g
                tipAgeSage,                                                     // : TThreadAgeSage     // \83A\83C\83e\83\80\82Ì\8fã\82°\89º\82°
-               tipURL                                                                  // : string                     // \83X\83\8c\83b\83h\82ð\83u\83\89\83E\83U\82Å\95\\8e¦\82·\82é\8dÛ\82Ì URL
+               tipURL,                                                                 // : string                     // \83X\83\8c\83b\83h\82ð\83u\83\89\83E\83U\82Å\95\\8e¦\82·\82é\8dÛ\82Ì URL
+       tipFilePath                                                     // : string                     // \82±\82Ì\83X\83\8c\82ª\95Û\91\82³\82ê\82Ä\82¢\82é\83p\83X
        );
 
        // *************************************************************************
@@ -44,15 +45,41 @@ type
                var outRevision : DWORD         // \83\8a\83r\83W\83\87\83\93\83i\83\93\83o\81[
        ); stdcall;
 
+  // *************************************************************************
+  // \8ew\92è\82µ\82½ URL \82ð\82±\82Ì\83v\83\89\83O\83C\83\93\82Å\8eó\82¯\95t\82¯\82é\82©\82Ç\82¤\82©
+  // *************************************************************************
+  TOnAcceptURL = function(
+       inURL : PChar                                           // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
+  ): Boolean; stdcall;                 // \8eó\82¯\95t\82¯\82é\82È\82ç True
+
+  // *************************************************************************
+  // TThreadItem \82ª\90\90¬\82³\82ê\82½
+  // *************************************************************************
+  TThreadItemCreate = procedure(
+       inInstance : DWORD
+  ); stdcall;
+
+  // *************************************************************************
+  // TThreadItem \82ª\94j\8aü\82³\82ê\82½
+  // *************************************************************************
+  TThreadItemDispose = procedure(
+       inInstance : DWORD
+  ); stdcall;
+
+
+
        // =========================================================================
        // \83v\83\89\83O\83C\83\93\82ð\8aÇ\97\9d\82·\82é TBoardPlugin \83N\83\89\83X
        // =========================================================================
        TBoardPlugIn = class( TObject )
        private
-               FFilePath                       : string;               // \83v\83\89\83O\83C\83\93\82ð\8e¦\82·\83p\83X
-               FModule                         : HMODULE;      // \83v\83\89\83O\83C\83\93\82Ì\83\82\83W\83\85\81[\83\8b\83n\83\93\83h\83\8b
+               FFilePath                                               : string;               // \83v\83\89\83O\83C\83\93\82ð\8e¦\82·\83p\83X
+               FModule                                                 : HMODULE;      // \83v\83\89\83O\83C\83\93\82Ì\83\82\83W\83\85\81[\83\8b\83n\83\93\83h\83\8b
 
-               FVersionInfo    : TOnVersionInfo;
+               FVersionInfo                            : TOnVersionInfo;
+       FAcceptURL                                      : TOnAcceptURL;
+       FCreateThreadItem               : TThreadItemCreate;
+       FDisposeThreadItem      : TThreadItemDispose;
 
        public
                // \83v\83\89\83O\83C\83\93\82Ì\83p\83X\82ð\8ew\92è\82µ\82Ä\8dì\90¬
@@ -72,13 +99,17 @@ type
                procedure       VersionInfo(    var outAgent : string;
                        var outMajor : DWORD; var outMinor : DWORD;
                        var outRelease : string; var outRevision : DWORD );
+               // \8ew\92è\82µ\82½ URL \82ð\82±\82Ì\83v\83\89\83O\83C\83\93\82Å\8eó\82¯\95t\82¯\82é\82©\82Ç\82¤\82©
+       function        AcceptURL( inURL : string ) : Boolean;
+       procedure       CreateThreadItem( threadItem : DWORD );
+       procedure       DisposeThreadItem( threadItem : DWORD );
 
        private
                procedure       LoadPlugInAPI;
 
        public
-               property        FilePath : string read FFilePath;
-               property        Module : HMODULE read FModule;
+               property        FilePath        : string        read FFilePath;
+               property        Module          : HMODULE       read FModule;
        end;
 
 var
@@ -88,6 +119,8 @@ var
 
        BoardPlugIns    : array of TBoardPlugIn;
 
+procedure InitializeBoardPlugIns;
+
 function CreateResultString(
        resultStr : string
 ) : PChar; stdcall;
@@ -105,6 +138,37 @@ procedure DisposeResultString(
 
 implementation
 
+uses GikoSystem, BoardGroup;
+
+// =========================================================================
+// \83v\83\89\83O\83C\83\93\82ð\8aÇ\97\9d\82·\82é TBoardPlugin \83N\83\89\83X
+// =========================================================================
+
+// *************************************************************************
+// BoardPlugin \83t\83H\83\8b\83_\82É\82 \82é\83v\83\89\83O\83C\83\93\82ð\91S\82Ä\83\8d\81[\83h
+// *************************************************************************
+procedure InitializeBoardPlugIns;
+var
+       i, bound                : Integer;
+  pluginNames  : TStringList;
+begin
+
+       pluginNames := TStringList.Create;
+  try
+       GikoSys.GetFileList( GikoSys.Setting.GetBoardPlugInDir, '*', pluginNames, False, False );
+       SetLength( BoardPlugIns, pluginNames.Count );
+
+       bound := pluginNames.Count - 1;
+       for i := 0 to bound do
+               BoardPlugIns[ i ] := TBoardPlugIn.CreateFromName( pluginNames.Strings[ i ] );
+  finally
+       pluginNames.Free;
+  end;
+
+end;
+
+
+
 // =========================================================================
 // \83v\83\89\83O\83C\83\93\82ð\8aÇ\97\9d\82·\82é TBoardPlugin \83N\83\89\83X
 // =========================================================================
@@ -225,6 +289,47 @@ begin
 end;
 
 // *************************************************************************
+// \8ew\92è\82µ\82½ URL \82ð\82±\82Ì\83v\83\89\83O\83C\83\93\82Å\8eó\82¯\95t\82¯\82é\82©\82Ç\82¤\82©
+// *************************************************************************
+function       TBoardPlugIn.AcceptURL(
+       inURL : string
+) : Boolean;
+begin
+
+       if Assigned( FAcceptURL ) then
+       Result := FAcceptURL( PChar( inURL ) )
+  else
+       Result := False;
+
+end;
+
+// *************************************************************************
+// TThreadItem \82ª\90\90¬\82³\82ê\82½
+// *************************************************************************
+procedure      TBoardPlugIn.CreateThreadItem(
+       threadItem : DWORD
+);
+begin
+
+       if Assigned( FCreateThreadItem ) then
+       FCreateThreadItem( threadItem );
+
+end;
+
+// *************************************************************************
+// TThreadItem \82ª\94j\8aü\82³\82ê\82½
+// *************************************************************************
+procedure      TBoardPlugIn.DisposeThreadItem(
+       threadItem : DWORD
+);
+begin
+
+       if Assigned( FDisposeThreadItem ) then
+       FDisposeThreadItem( threadItem );
+
+end;
+
+// *************************************************************************
 // \83v\83\89\83O\83C\83\93\82Ì API \82ð\8eæ\93¾
 // *************************************************************************
 procedure TBoardPlugIn.LoadPlugInAPI;
@@ -232,7 +337,10 @@ begin
 
        try
                if Assigned( Pointer( FModule ) ) then begin
-                       FVersionInfo := GetProcAddress( FModule, 'OnVersionInfo' );
+                       FVersionInfo                            := GetProcAddress( FModule, 'OnVersionInfo' );
+                       FAcceptURL                                      := GetProcAddress( FModule, 'OnAcceptURL' );
+                       FCreateThreadItem               := GetProcAddress( FModule, 'ThreadItemCreate' );
+                       FDisposeThreadItem      := GetProcAddress( FModule, 'ThreadItemDispose' );
                end;
        except
        end;
@@ -313,7 +421,6 @@ begin
 
        httpSocket := TIdHTTP.Create( nil );
        try
-
                // \83C\83x\83\93\83g\82Ì\90Ý\92è
                if Assigned( OnWork ) then
                        httpSocket.OnWork                               := OnWork;
@@ -322,7 +429,48 @@ begin
                if Assigned( OnWorkEnd ) then
                        httpSocket.OnWorkEnd            := OnWorkEnd;
 
+       // \92Ê\90M\82É\8aÖ\82·\82é\90Ý\92è
                httpSocket.Request.CustomHeaders.Clear;
+               httpSocket.Response.Clear;
+               httpSocket.Request.Clear;
+
+               httpSocket.Request.UserAgent    := GikoSys.GetUserAgent;
+               httpSocket.RecvBufferSize                       := Gikosys.Setting.RecvBufferSize;
+               httpSocket.ProxyParams.BasicAuthentication := False;
+               {$IFDEF DEBUG}
+               Writeln('------------------------------------------------------------');
+               {$ENDIF}
+               //httpSocket.AllowCookies := False;
+               if GikoSys.Setting.ReadProxy then begin
+                       if GikoSys.Setting.ProxyProtocol then
+                               httpSocket.ProtocolVersion := pv1_1
+                       else
+                               httpSocket.ProtocolVersion := pv1_0;
+                       httpSocket.ProxyParams.ProxyServer              := GikoSys.Setting.ReadProxyAddress;
+                       httpSocket.ProxyParams.ProxyPort                        := GikoSys.Setting.ReadProxyPort;
+                       httpSocket.ProxyParams.ProxyUsername    := GikoSys.Setting.ReadProxyUserID;
+                       httpSocket.ProxyParams.ProxyPassword    := GikoSys.Setting.ReadProxyPassword;
+                       if GikoSys.Setting.ReadProxyUserID <> '' then
+                               httpSocket.ProxyParams.BasicAuthentication := True;
+                       {$IFDEF DEBUG}
+                       Writeln('\83v\83\8d\83L\83V\90Ý\92è\82 \82è');
+                       Writeln('\83z\83X\83g: ' + GikoSys.Setting.ReadProxyAddress);
+                       Writeln('\83|\81[\83g: ' + IntToStr( GikoSys.Setting.ReadProxyPort ));
+                       {$ENDIF}
+               end else begin
+                       if GikoSys.Setting.Protocol then
+                               httpSocket.ProtocolVersion := pv1_1
+                       else
+                               httpSocket.ProtocolVersion := pv1_0;
+                       httpSocket.ProxyParams.ProxyServer              := '';
+                       httpSocket.ProxyParams.ProxyPort                        := 80;
+                       httpSocket.ProxyParams.ProxyUsername    := '';
+                       httpSocket.ProxyParams.ProxyPassword    := '';
+                       {$IFDEF DEBUG}
+                       Writeln('\83v\83\8d\83L\83V\90Ý\92è\82È\82µ');
+                       {$ENDIF}
+               end;
+
                httpSocket.Request.ContentRangeStart    := inRangeStart;
                httpSocket.Request.ContentRangeEnd              := inRangeEnd;
                if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
@@ -585,6 +733,8 @@ begin
                        Result := DWORD( threadItem.AgeSage );
                tipURL:                                                                 // : string                     // \83X\83\8c\83b\83h\82ð\83u\83\89\83E\83U\82Å\95\\8e¦\82·\82é\8dÛ\82Ì URL
                        Result := DWORD( CreateResultString( threadItem.URL ) );
+       tipFilePath:                                                                                                            // \82±\82Ì\83X\83\8c\82ª\95Û\91\82³\82ê\82Ä\82¢\82é\83p\83X
+               Result := DWORD( CreateResultString( threadItem.FilePath ) );
        else
                Result := 0;
        end;
@@ -609,15 +759,9 @@ begin
                tipNo:                                                                  // : Integer            // \94Ô\8d\86
                        threadItem.No                                           := param;
                tipFileName:                                            // : string                     // \83X\83\8c\83b\83h\83t\83@\83C\83\8b\96¼
-               begin
                        threadItem.FileName                     := string( PChar( param ) );
-                       DisposeResultString( PChar( param ) );
-               end;
                tipTitle:                                                               // : string                     // \83X\83\8c\83b\83h\83^\83C\83g\83\8b
-               begin
                        threadItem.Title                                := string( PChar( param ) );
-                       DisposeResultString( PChar( param ) );
-               end;
                tipCount:                                                               // : Integer            // \83X\83\8c\83b\83h\83J\83E\83\93\83g\81i\83\8d\81[\83J\83\8b\81j
                        threadItem.Count                                := param;
                tipAllResCount:                                 // : Integer            // \83X\83\8c\83b\83h\83J\83E\83\93\83g\81i\83T\81[\83o\81j
@@ -629,10 +773,7 @@ begin
                tipRound:                                                               // : Boolean            // \8f\84\89ñ\83t\83\89\83O
                        threadItem.Round                                := Boolean( param );
                tipRoundName:                                           // : string                     // \8f\84\89ñ\96¼
-               begin
                        threadItem.RoundName            := string( PChar( param ) );
-                       DisposeResultString( PChar( param ) );
-               end;
                tipIsLogFile:                                           // : Boolean            // \83\8d\83O\91\8dÝ\83t\83\89\83O
                        threadItem.IsLogFile            := Boolean( param );
                tipKokomade:                                            // : Integer            // \83R\83R\82Ü\82Å\93Ç\82ñ\82¾\94Ô\8d\86
@@ -646,17 +787,13 @@ begin
                tipScrollTop:                                           // : Integer            // \83X\83N\83\8d\81[\83\8b\88Ê\92u
                        threadItem.ScrollTop             := param;
                tipDownloadHost:                                // : string                     // \8d¡\82Ì\83z\83X\83g\82Æ\88á\82¤\8fê\8d\87\82Ì\83z\83X\83g
-               begin
                        threadItem.DownloadHost := string( PChar( param ) );
-                       DisposeResultString( PChar( param ) );
-               end;
                tipAgeSage:                                                     // : TThreadAgeSage     // \83A\83C\83e\83\80\82Ì\8fã\82°\89º\82°
                        threadItem.AgeSage                      := TGikoAgeSage( param );
                tipURL:                                                                 // : string                     // \83X\83\8c\83b\83h\82ð\83u\83\89\83E\83U\82Å\95\\8e¦\82·\82é\8dÛ\82Ì URL
-               begin
                        threadItem.URL                                  := string( PChar( param ) );
-                       DisposeResultString( PChar( param ) );
-               end;
+       tipFilePath:                                            // : string                     // \82±\82Ì\83X\83\8c\82ª\95Û\91\82³\82ê\82Ä\82¢\82é\83p\83X
+               threadItem.FilePath                     := string( PChar( param ) );
        end;
 
 end;