OSDN Git Service

・OnAcceptURL の戻り値で URL の種類が判別できるようになった。
authoryoffy <yoffy>
Fri, 21 Nov 2003 06:15:11 +0000 (06:15 +0000)
committeryoffy <yoffy>
Fri, 21 Nov 2003 06:15:11 +0000 (06:15 +0000)
res/ExternalBoardPlugIn/ExternalBoardPlugIn.dpr
res/ExternalBoardPlugIn/MachiBBSPlugIn.dpr
res/ExternalBoardPlugIn/PlugInMain.pas
res/ExternalBoardPlugIn/ShitarabaPlugIn.dpr

index 859bf7d..436af69 100644 (file)
@@ -79,7 +79,7 @@ const
        MAJOR_VERSION                   = 1;
        MINOR_VERSION                   = 0;
        RELEASE_VERSION         = 'beta';
-       REVISION_VERSION        = 2;
+       REVISION_VERSION        = 3;
 
 // =========================================================================
 // \8eG\97p\8aÖ\90\94
@@ -247,22 +247,41 @@ 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 OnAcceptURL(
-       inURL : PChar                                           // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
-): Boolean; stdcall;                   // \8eó\82¯\95t\82¯\82é\82È\82ç True
+       inURL                   : PChar                         // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
+): TAcceptType; stdcall;       // URL \82Ì\8eí\97Þ
 var
-       URI : TIdURI;
-       foundPos : Integer;
+       uri                             : TIdURI;
+  uriList              : TStringList;
+       foundPos        : Integer;
 const
-       BBS_HOST = '2ch.net';
+       BBS_HOST                = '2ch.net';
+  THREAD_MARK  = '/test/read.cgi/';
 begin
 
-       // \97á\82Æ\82µ\82Ä\83z\83X\83g\96¼\82ª 2ch.net \82Å\8fI\82í\82é\8fê\8d\87\82Í\8eó\82¯\95t\82¯\82é\82æ\82¤\82É\82µ\82Ä\82¢\82é
-       URI := TIdURI.Create( inURL );
        try
-               foundPos := Pos( BBS_HOST, URI.Host );
-               Result := (foundPos > 0) and (Length( URI.Host ) - foundPos + 1 = Length( BBS_HOST ))
-       finally
-               URI.Free;
+               // \97á\82Æ\82µ\82Ä\83z\83X\83g\96¼\82ª 2ch.net \82Å\8fI\82í\82é\8fê\8d\87\82Í\8eó\82¯\95t\82¯\82é\82æ\82¤\82É\82µ\82Ä\82¢\82é
+               uri                     := TIdURI.Create( inURL );
+               uriList := TStringList.Create;
+               try
+                       ExtractHttpFields( ['/'], [], uri.Path, uriList );
+                       foundPos := Pos( BBS_HOST, uri.Host );
+                       if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
+                               foundPos := Pos( THREAD_MARK, uri.Path );
+                               if foundPos > 0 then
+                                       Result := atThread
+                               else if (uriList.Count > 1) and (uri.Path <> '/') then  // \8dÅ\8cã\82ª '/' \82Å\95Â\82ß\82ç\82ê\82Ä\82é\82È\82ç 3
+                                       Result := atBoard
+                               else
+                                       Result := atBBS;
+                       end else begin
+                               Result := atNoAccept;
+                       end;
+               finally
+                       uri.Free;
+                       uriList.Free;
+               end;
+       except
+               Result := atNoAccept;
        end;
 
 end;
index 386886d..0051422 100644 (file)
@@ -79,7 +79,7 @@ const
        MAJOR_VERSION                   = 1;
        MINOR_VERSION                   = 0;
        RELEASE_VERSION         = 'beta';
-       REVISION_VERSION        = 8;
+       REVISION_VERSION        = 9;
 
 // =========================================================================
 // \8eG\97p\8aÖ\90\94
@@ -255,26 +255,41 @@ 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 OnAcceptURL(
-       inURL : PChar                                           // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
-): Boolean; stdcall;                   // \8eó\82¯\95t\82¯\82é\82È\82ç True
+       inURL                   : PChar                         // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
+): TAcceptType; stdcall;       // URL \82Ì\8eí\97Þ
 var
-       URI : TIdURI;
-       foundPos : Integer;
+       uri                             : TIdURI;
+       uriList         : TStringList;
+       foundPos        : Integer;
 const
-       BBS_HOST = 'machi.to';
+       BBS_HOST                = 'machi.to';
+       THREAD_MARK     = '/bbs/read.pl';
 begin
 
        try
-               // \97á\82Æ\82µ\82Ä\83z\83X\83g\96¼\82ª machi.to \82Å\8fI\82í\82é\8fê\8d\87\82Í\8eó\82¯\95t\82¯\82é\82æ\82¤\82É\82µ\82Ä\82¢\82é
-               URI := TIdURI.Create( inURL );
+               // \83z\83X\83g\96¼\82ª machi.to \82Å\8fI\82í\82é\8fê\8d\87\82Í\8eó\82¯\95t\82¯\82é\82æ\82¤\82É\82µ\82Ä\82¢\82é
+               uri                     := TIdURI.Create( inURL );
+               uriList := TStringList.Create;
                try
-                       foundPos := Pos( BBS_HOST, URI.Host );
-                       Result := (foundPos > 0) and (Length( URI.Host ) - foundPos + 1 = Length( BBS_HOST ))
+                       ExtractHttpFields( ['/'], [], uri.Path, uriList );
+                       foundPos := Pos( BBS_HOST, uri.Host );
+                       if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
+                               foundPos := Pos( THREAD_MARK, uri.Path );
+                               if foundPos > 0 then
+                                       Result := atThread
+                               else if (uriList.Count > 1) and (uri.Path <> '/') then  // \8dÅ\8cã\82ª '/' \82Å\95Â\82ß\82ç\82ê\82Ä\82é\82È\82ç 3
+                                       Result := atBoard
+                               else
+                                       Result := atBBS;
+                       end else begin
+                               Result := atNoAccept;
+                       end;
                finally
-                       URI.Free;
+                       uri.Free;
+                       uriList.Free;
                end;
        except
-               Result := False;
+               Result := atNoAccept;
        end;
 
 end;
index ea1d495..55c13e1 100644 (file)
@@ -15,6 +15,9 @@ type
        // \83_\83E\83\93\83\8d\81[\83h\82ª\90¬\8c÷\82µ\82½\82©\82Ç\82¤\82©
        TDownloadState = (dsWait, dsWork, dsComplete, dsDiffComplete, dsNotModify, dsAbort, dsError);
 
+       // \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©
+       TAcceptType = (atNoAccept, atBBS, atBoard, atThread);
+
        // *************************************************************************
        // CreateResultString
        // \96ß\82è\92l\82ª PChar \82Å\82 \82é API \82Ì\83\81\83\82\83\8a\82ð\8am\95Û\82·\82é
index e690ed2..dc69562 100644 (file)
@@ -73,7 +73,7 @@ const
        MAJOR_VERSION                   = 1;
        MINOR_VERSION                   = 0;
        RELEASE_VERSION         = 'beta';
-       REVISION_VERSION        = 8;
+       REVISION_VERSION        = 9;
 
 // =========================================================================
 // \8eG\97p\8aÖ\90\94
@@ -249,26 +249,41 @@ 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 OnAcceptURL(
-       inURL : PChar                                           // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
-): Boolean; stdcall;                   // \8eó\82¯\95t\82¯\82é\82È\82ç True
+       inURL                   : PChar                         // \94»\92f\82ð\8bÂ\82¢\82Å\82¢\82é URL
+): TAcceptType; stdcall;       // URL \82Ì\8eí\97Þ
 var
-       URI : TIdURI;
-       foundPos : Integer;
+       uri                             : TIdURI;
+       uriList         : TStringList;
+       foundPos        : Integer;
 const
-       BBS_HOST = 'shitaraba.com';
+       BBS_HOST                = 'jbbs.shitaraba.com';
+       THREAD_MARK     = '/bbs/read.cgi/';
 begin
 
        try
-               // \97á\82Æ\82µ\82Ä\83z\83X\83g\96¼\82ª shitaraba.com \82Å\8fI\82í\82é\8fê\8d\87\82Í\8eó\82¯\95t\82¯\82é\82æ\82¤\82É\82µ\82Ä\82¢\82é
-               URI := TIdURI.Create( inURL );
+               // \83z\83X\83g\96¼\82ª jbbs.shitaraba.com \82Å\8fI\82í\82é\8fê\8d\87\82Í\8eó\82¯\95t\82¯\82é\82æ\82¤\82É\82µ\82Ä\82¢\82é
+               uri                     := TIdURI.Create( inURL );
+               uriList := TStringList.Create;
                try
-                       foundPos := Pos( BBS_HOST, URI.Host );
-                       Result := (foundPos > 0) and (Length( URI.Host ) - foundPos + 1 = Length( BBS_HOST ))
+                       ExtractHttpFields( ['/'], [], uri.Path, uriList );
+                       foundPos := Pos( BBS_HOST, uri.Host );
+                       if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
+                               foundPos := Pos( THREAD_MARK, uri.Path );
+                               if foundPos > 0 then
+                                       Result := atThread
+                               else if uriList.Count > 2 then  // \8dÅ\8cã\82ª '/' \82Å\95Â\82ß\82ç\82ê\82Ä\82é\82È\82ç 4
+                                       Result := atBoard
+                               else
+                                       Result := atBBS;
+                       end else begin
+                               Result := atNoAccept;
+                       end;
                finally
-                       URI.Free;
+                       uri.Free;
+                       uriList.Free;
                end;
        except
-               Result := False;
+               Result := atNoAccept;
        end;
 
 end;