--- /dev/null
+object ShitarabaJBBSAcquireBoardDialog: TShitarabaJBBSAcquireBoardDialog
+ Left = 194
+ Top = 160
+ Width = 305
+ Height = 267
+ Caption = #12375#12383#12425#12400'JBBS'#26495#21462#24471
+ Color = clBtnFace
+ Constraints.MinHeight = 267
+ Constraints.MinWidth = 305
+ Font.Charset = SHIFTJIS_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -12
+ Font.Name = #65325#65331' '#65328#12468#12471#12483#12463
+ Font.Style = []
+ OldCreateOrder = False
+ DesignSize = (
+ 297
+ 233)
+ PixelsPerInch = 96
+ TextHeight = 12
+ object CategoryLabel: TLabel
+ Left = 16
+ Top = 16
+ Width = 73
+ Height = 17
+ Alignment = taRightJustify
+ BiDiMode = bdLeftToRight
+ Caption = #12459#12486#12468#12522':'
+ ParentBiDiMode = False
+ Layout = tlCenter
+ end
+ object BoardNameLabel: TLabel
+ Left = 16
+ Top = 48
+ Width = 73
+ Height = 17
+ Alignment = taRightJustify
+ Caption = #21462#24471#12377#12427#26495#21517':'
+ Layout = tlCenter
+ end
+ object SaveCategoryLabel: TLabel
+ Left = 22
+ Top = 80
+ Width = 67
+ Height = 20
+ Alignment = taRightJustify
+ Caption = #20445#23384#12459#12486#12468#12522':'
+ Layout = tlCenter
+ end
+ object CategoryComboBox: TComboBox
+ Left = 96
+ Top = 16
+ Width = 185
+ Height = 20
+ Style = csDropDownList
+ Anchors = [akLeft, akTop, akRight]
+ ItemHeight = 12
+ ItemIndex = 0
+ TabOrder = 0
+ Text = #33258#21205#36554#12539#12496#12452#12463#12539#20055#12426#29289
+ Items.Strings = (
+ #33258#21205#36554#12539#12496#12452#12463#12539#20055#12426#29289
+ #12467#12531#12500#12517#12540#12479#12540#12539#12452#12531#12479#12540#12493#12483#12488
+ #12466#12540#12512#12539#22258#30849#12539#23558#26827
+ #12486#12524#12499#12539#26144#30011#12539#26412#12539#12469#12502#12459#12523#12481#12515#12540
+ #33464#33021#12539#33464#34899#12539#38899#27005#12539#12501#12449#12483#12471#12519#12531
+ #12471#12519#12483#12500#12531#12464#12539#27969#36890
+ #36259#21619#12539#20581#24247#12539#12473#12509#12540#12484
+ #26053#34892#12539#22320#22495
+ #12499#12472#12493#12473#12539#32076#28168
+ #23398#21839#12539#20154#25991#12539#31185#23398
+ #12510#12473#12513#12487#12451#12450#12539#12491#12517#12540#12473#12539#25919#27835
+ #21516#20154#12539#12467#12511#12465#12539#20108#27425#21109#20316
+ #12450#12491#12513#12539#12450#12491#12513#12464#12483#12474
+ #12510#12531#12460
+ #23398#26657#12539#21463#39443#12539#23398#29983#12467#12511#12517#12491#12486#12451#12540)
+ end
+ object BoardNameEdit: TEdit
+ Left = 96
+ Top = 48
+ Width = 185
+ Height = 20
+ Anchors = [akLeft, akTop, akRight]
+ TabOrder = 1
+ end
+ object AcquireButton: TButton
+ Left = 124
+ Top = 192
+ Width = 75
+ Height = 25
+ Anchors = [akRight, akBottom]
+ Caption = #21462#24471'(&A)'
+ TabOrder = 2
+ OnClick = AcquireButtonClick
+ end
+ object SaveButton: TButton
+ Left = 204
+ Top = 192
+ Width = 75
+ Height = 25
+ Anchors = [akRight, akBottom]
+ Caption = #20445#23384'(&S)'
+ Default = True
+ Enabled = False
+ TabOrder = 3
+ OnClick = SaveButtonClick
+ end
+ object LogEdit: TMemo
+ Left = 16
+ Top = 112
+ Width = 265
+ Height = 65
+ Anchors = [akLeft, akTop, akRight, akBottom]
+ ReadOnly = True
+ TabOrder = 4
+ end
+ object SaveCategoryComboBox: TComboBox
+ Left = 96
+ Top = 80
+ Width = 185
+ Height = 20
+ Anchors = [akLeft, akTop, akRight]
+ ItemHeight = 12
+ TabOrder = 5
+ end
+end
--- /dev/null
+unit ShitarabaJBBSAcquireBoard;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, StdCtrls;
+
+type
+ TShitarabaJBBSAcquireBoardDialog = class(TForm)
+ CategoryLabel: TLabel;
+ CategoryComboBox: TComboBox;
+ BoardNameLabel: TLabel;
+ BoardNameEdit: TEdit;
+ AcquireButton: TButton;
+ SaveButton: TButton;
+ LogEdit: TMemo;
+ SaveCategoryLabel: TLabel;
+ SaveCategoryComboBox: TComboBox;
+ procedure SaveButtonClick(Sender: TObject);
+ procedure AcquireButtonClick(Sender: TObject);
+ private
+ { Private \90é\8c¾ }
+ FBoardList : TStringList; //!< \8eæ\93¾\8dÏ\82Ý\82Ì\94Â\83\8a\83X\83g
+ public
+ { Public \90é\8c¾ }
+ constructor Create( AOwner : TComponent ); override;
+ destructor Destroy; override;
+ end;
+
+var
+ ShitarabaJBBSAcquireBoardDialog: TShitarabaJBBSAcquireBoardDialog;
+
+implementation
+
+uses Math, IniFiles,
+ PlugInMain, FilePath, Y_TextConverter;
+
+const
+ SYNCRONIZE_MENU_CAPTION = '\82µ\82½\82ç\82ÎJBBS\94Â\8dX\90V';
+
+{$R *.dfm}
+
+function HttpEncode(
+\r const strValue : string
+) : string;
+var
+ i : Integer;
+ strLen : Integer;
+ strResult : string;
+ b : Integer;
+const
+ kHexCode : array [0..15] of char = (
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' );
+begin
+
+ strLen := Length( strValue );
+ i := 1;
+
+ while i <= strLen do
+ begin
+
+ case strValue[ i ] of
+ '0' .. '9', 'a' .. 'z', 'A' .. 'Z', '*', '-', '.', '@', '_':
+ begin
+ strResult := strResult + strValue[ i ];
+ end;
+ else
+ begin
+ b := Integer( strValue[ i ] );
+ strResult := strResult + '%'
+ + kHexCode[ b div $10 ]
+ + kHexCode[ b mod $10 ];
+ end;
+ end;
+
+ i := i + 1;
+
+ end;
+
+ Result := strResult;
+
+end;
+
+function BoardFileName : string;
+var
+ savepath : string;
+ success : Boolean;
+ initdir : string;
+ filter : string;
+
+ agent : PChar;
+ major : DWORD;
+ minor : DWORD;
+ release : PChar;
+ revision : DWORD;
+const
+ SAVEPATH_SELECT = '\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\93ü\97Í\82µ\82Ä\82\82¾\82³\82¢';
+ BOARD_FILE_NAME = '\82µ\82½\82ç\82ÎJBBS';
+begin
+
+ VersionInfo( agent, major, minor, release, revision );
+ try
+ initdir := PreferencesFolder;
+ if agent = 'gikoNavi' then begin
+ savepath := initdir + 'Board\' + BOARD_FILE_NAME + '.txt';
+ end else begin
+ filter := '\82·\82Ä\82×\82Ì\83t\83@\83C\83\8b (*.*)|*.*';
+ savepath := BOARD_FILE_NAME;
+ success := PromptForFileName(
+ savepath, filter, 'txt', SYNCRONIZE_MENU_CAPTION, initdir, True );
+ end;
+ finally
+ DisposeResultString( agent );
+ DisposeResultString( release );
+ end;
+
+ Result := savepath;
+
+end;
+
+constructor TShitarabaJBBSAcquireBoardDialog.Create( AOwner : TComponent );
+var
+ ini : TMemIniFile;
+ saveCategories : TStringList;
+ i : Integer;
+begin
+
+ inherited;
+
+ FBoardList := TStringList.Create;
+ FBoardList.Duplicates := dupIgnore;
+
+
+ ini := TMemIniFile.Create( BoardFileName );
+ saveCategories := TStringList.Create;
+ try
+ ini.ReadSections( saveCategories );
+ for i := 0 to saveCategories.Count - 1 do
+ SaveCategoryComboBox.AddItem( saveCategories[ i ], nil );
+ SaveCategoryComboBox.ItemIndex := 0;
+ finally
+ saveCategories.Free;
+ ini.Free;
+ end;
+
+end;
+
+destructor TShitarabaJBBSAcquireBoardDialog.Destroy;
+begin
+
+ FBoardList.Free;
+
+ inherited;
+
+end;
+
+procedure TShitarabaJBBSAcquireBoardDialog.SaveButtonClick(
+ Sender: TObject);
+var
+ ini : TMemIniFile;
+ i : Integer;
+ name : string;
+ saveCategory : string;
+begin
+
+ saveCategory := SaveCategoryComboBox.Text;
+ if saveCategory = '' then
+ saveCategory := CategoryComboBox.Text;
+ ini := TMemIniFile.Create( BoardFileName );
+ try
+ ini.CaseSensitive := False;
+ for i := 0 to FBoardList.Count - 1 do begin
+ name := FBoardList.Names[ i ];
+ ini.WriteString( saveCategory, name, FBoardList.Values[ name ] );
+ end;
+ ini.UpdateFile;
+ finally
+ ini.Free;
+ end;
+
+ Close;
+
+end;
+
+procedure TShitarabaJBBSAcquireBoardDialog.AcquireButtonClick(
+ Sender: TObject);
+var
+ boardName : string;
+ category : string;
+
+ url : string;
+ modified : Double;
+ tmp : PChar;
+ downResult : string;
+ responseCode : Longint;
+
+ found : Integer;
+ found2 : Integer;
+ pos : Integer;
+ board : string;
+
+ key : string;
+const
+ BBS_HOST = 'http://jbbs.livedoor.jp/';
+ CATEGORIES : array[0..14] of string = (
+ 'auto', 'computer', 'game', 'movie', 'music', 'shop', 'sports', 'travel',
+ 'buisiness', 'study', 'news', 'otaku', 'anime', 'comic', 'school' );
+label
+ NextBoard;
+begin
+
+ category := CATEGORIES[ CategoryComboBox.ItemIndex ];
+ boardname := BoardNameEdit.Text;
+
+ LogEdit.SelLength := 0;
+ LogEdit.SelStart := Length( LogEdit.Text );
+ LogEdit.SelText :=
+ '\94Â\8fî\95ñ\82ð\8eæ\93¾\92\86\82Å\82·( "' + category + '", "' + boardname + '" )' + #13#10;
+ try
+ url :=
+ BBS_HOST + 'bbs/left_menu.cgi?CATEGORY=' + category +
+ '&WORD=' + HttpEncode( SJIStoEUC( boardname ) );
+
+ responseCode := InternalDownload( PChar( url ), modified, tmp );
+ try
+ if (responseCode = 200) or (responseCode = 206) then begin
+ downResult := EUCtoSJIS( tmp );
+ found := AnsiPos( '<a ', downResult );
+ while found > 0 do begin
+ downResult := Copy( downResult, found + 3, MaxInt ); // 3 = Length( '<a ' )
+ found := AnsiPos( 'href=', downResult );
+ if found = 0 then
+ Break;
+
+ if downResult[ found + 5 ] = '"' then begin // 5 = Length( 'href=' )
+ downResult := Copy( downResult, found + 6, MaxInt ); // 6 = Length( 'href="' )
+ found := AnsiPos( '"', downResult );
+ end else begin
+ downResult := Copy( downResult, found + 5, MaxInt ); // 5 = Length( 'href=' )
+ found := AnsiPos( ' ', downResult );
+ found2 := AnsiPos( '>', downResult );
+ if (found = 0) or (found2 = 0) then
+ found := Max( found, found2 )
+ else
+ found := Min( found, found2 );
+ end;
+ board := Copy( downResult, 1, found - 1 );
+ downResult := Copy( downResult, found, MaxInt );
+
+ if board = BBS_HOST then
+ goto NextBoard;
+ if AnsiPos( '../', board ) = 1 then
+ board := BBS_HOST + Copy( board, 1 + 3, MaxInt ); // 3 = Length( '../' )
+
+ found := AnsiPos( '>', downResult );
+ if found = 0 then
+ Break;
+ downResult := Copy( downResult, found + 1, MaxInt ); // 1 = Length( '>' )
+
+ found := AnsiPos( '</a>', downResult );
+ if found = 0 then
+ Break;
+ key := Copy( downResult, 1, found - 1 );
+ key := StringReplace( key, '=', '', [rfReplaceAll] );
+{
+ key := StringReplace( key, ' ', '', [rfReplaceAll] );
+ key := StringReplace( key, '[', '', [rfReplaceAll] );
+ key := StringReplace( key, ']', '', [rfReplaceAll] );
+}
+ board := key + '=' + board;
+ downResult := Copy( downResult, found + 4, MaxInt ); // 4 = Length( '</a>' )
+
+ LogEdit.SelText := board + #13#10;
+ FBoardList.Add( board );
+NextBoard:
+ found := AnsiPos( '<a ', downResult );
+ end;
+ pos := FBoardList.IndexOf('JBBS=/');
+ if pos >= 0 then
+ FBoardList.Delete(pos);
+ end else begin
+ LogEdit.SelText :=
+ '\94Â\8fî\95ñ\82Ì\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½(' +
+ IntToStr( responseCode ) + ')' + #13#10;
+ end;
+ finally
+ DisposeResultString( tmp );
+ end;
+ LogEdit.SelText := '\94Â\8fî\95ñ\82ð\8eæ\93¾\8a®\97¹' + #13#10;
+ SaveButton.Enabled := True;
+ except
+ LogEdit.SelText :=
+ '\94Â\8fî\95ñ\82Ì\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½(' + IntToStr( responseCode ) + ')' + #13#10;
+ end;
+
+end;
+
+end.
{
ShitarabaJBBSPlugIn
\82µ\82½\82ç\82Î\8f\88\97\9d\83\86\83j\83b\83g
- $Id: ShitarabaJBBSPlugIn.dpr,v 1.36 2004/09/30 11:49:44 h677 Exp $
+ $Id: ShitarabaJBBSPlugIn.dpr,v 1.37 2004/10/14 03:49:44 yoffy Exp $
}
uses
- Windows, SysUtils, Classes, Math, DateUtils, Dialogs,
- IdURI,
- PlugInMain in 'PlugInMain.pas',
- ThreadItem in 'ThreadItem.pas',
- BoardItem in 'BoardItem.pas',
+ Windows,
+ SysUtils,
+ Classes,
+ Math,
+ DateUtils,
+ Dialogs,
+ IdURI,
+ PlugInMain in 'PlugInMain.pas',
+ ThreadItem in 'ThreadItem.pas',
+ BoardItem in 'BoardItem.pas',
FilePath in 'FilePath.pas',
- Y_TextConverter in 'Y_TextConverter.pas',
- MojuUtils in '..\..\MojuUtils.pas';
+ Y_TextConverter in 'Y_TextConverter.pas',
+ MojuUtils in '..\..\MojuUtils.pas',
+ ShitarabaJBBSAcquireBoard in 'ShitarabaJBBSAcquireBoard.pas' {ShitarabaJBBSAcquireBoardDialog};
{$R *.res}
inHandle : HMENU // \83\81\83j\83\85\81[\83n\83\93\83h\83\8b
); stdcall;
var
- category : string;
- keyword : string;
- savepath : string;
- success : Boolean;
- initdir : string;
- filter : string;
-
- agent : PChar;
- major : DWORD;
- minor : DWORD;
- release : PChar;
- revision : DWORD;
-
- url : string;
- modified : Double;
- tmp : PChar;
- downResult : string;
- saveText : TStringList;
- responseCode : Longint;
-
- found : Integer;
- found2 : Integer;
- pos : Integer;
- board : string;
-const
- CATEGORY_INPUT = '\83J\83e\83S\83\8a\82ð\93ü\97Í\82µ\82Ä\82\82¾\82³\82¢';
- KEYWORD_INPUT = '\8c\9f\8dõ\82·\82é\94Â\96¼\82ð\93ü\97Í\82µ\82Ä\82\82¾\82³\82¢';
- SAVEPATH_SELECT = '\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\93ü\97Í\82µ\82Ä\82\82¾\82³\82¢';
- BBS_HOST = 'http://jbbs.livedoor.jp/';
-label
- NextBoard;
+ dialog : TShitarabaJBBSAcquireBoardDialog;
begin
- category := 'computer';
- success := InputQuery( SYNCRONIZE_MENU_CAPTION, CATEGORY_INPUT, category );
- if not success then
- Exit;
- keyword := InputBox( SYNCRONIZE_MENU_CAPTION, KEYWORD_INPUT, '' );
- if keyword = '' then
- Exit;
-
- VersionInfo( agent, major, minor, release, revision );
- try
- initdir := PreferencesFolder;
- filter := '\82·\82Ä\82×\82Ì\83t\83@\83C\83\8b (*.*)|*.*';
- if agent = 'gikoNavi' then begin
- if DirectoryExists( initdir + 'Board\' ) then
- initdir := initdir + 'Board\';
- filter := '\94Â\83t\83@\83C\83\8b (*.txt)|*.txt';
- end;
- finally
- DisposeResultString( agent );
- DisposeResultString( release );
- end;
- savepath := keyword;
- success := PromptForFileName( savepath, filter, 'txt', SYNCRONIZE_MENU_CAPTION, initdir, True );
- if not success then
- Exit;
-
- InternalPrint( '\94Â\8fî\95ñ\82ð\8eæ\93¾\92\86\82Å\82·' );
- try
- url :=
- BBS_HOST + 'bbs/left_menu.cgi?CATEGORY=' + category +
- '&WORD=' + HttpEncode( SJIStoEUC( keyword ) );
-
- responseCode := InternalDownload( PChar( url ), modified, tmp );
- try
- if (responseCode = 200) or (responseCode = 206) then begin
- saveText := TStringList.Create;
- saveText.Add( '[' + keyword + ']' );
- downResult := EUCtoSJIS( tmp );
- found := AnsiPos( '<a ', downResult );
- while found > 0 do begin
- downResult := Copy( downResult, found + 3, MaxInt ); // 3 = Length( '<a ' )
- found := AnsiPos( 'href=', downResult );
- if found = 0 then
- Break;
-
- if downResult[ found + 5 ] = '"' then begin // 5 = Length( 'href=' )
- downResult := Copy( downResult, found + 6, MaxInt ); // 6 = Length( 'href="' )
- found := AnsiPos( '"', downResult );
- end else begin
- downResult := Copy( downResult, found + 5, MaxInt ); // 5 = Length( 'href=' )
- found := AnsiPos( ' ', downResult );
- found2 := AnsiPos( '>', downResult );
- if (found = 0) or (found2 = 0) then
- found := Max( found, found2 )
- else
- found := Min( found, found2 );
- end;
- board := Copy( downResult, 1, found - 1 );
- downResult := Copy( downResult, found, MaxInt );
-
- if board = BBS_HOST then
- goto NextBoard;
- if AnsiPos( '../', board ) = 1 then
- board := BBS_HOST + Copy( board, 1 + 3, MaxInt ); // 3 = Length( '../' )
-
- found := AnsiPos( '>', downResult );
- if found = 0 then
- Break;
- downResult := Copy( downResult, found + 1, MaxInt ); // 1 = Length( '>' )
-
- found := AnsiPos( '</a>', downResult );
- if found = 0 then
- Break;
- board := Copy( downResult, 1, found - 1 ) + '=' + board;
- downResult := Copy( downResult, found + 4, MaxInt ); // 4 = Length( '</a>' )
-
- saveText.Add( board );
-NextBoard:
- found := AnsiPos( '<a ', downResult );
- end;
- pos := saveText.IndexOf('JBBS=/');
- if pos > 0 then
- saveText.Delete(pos);
-
- saveText.SaveToFile( savepath );
- saveText.Free;
- end else begin
- InternalPrint( PChar( '\94Â\8fî\95ñ\82Ì\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½(' + IntToStr( responseCode ) + ')' ) );
- end;
- finally
- DisposeResultString( tmp );
- end;
- InternalPrint( '\94Â\8fî\95ñ\82ð\8eæ\93¾\8a®\97¹' );
- except
- InternalPrint( '\94Â\8fî\95ñ\82Ì\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½' );
- end;
+ dialog := TShitarabaJBBSAcquireBoardDialog.Create( nil );
+ dialog.ShowModal;
end;