Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/RoundData.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.19 by h677, Wed Nov 10 14:27:36 2004 UTC revision 1.19.2.1 by h677, Wed May 18 14:36:10 2005 UTC
# Line 17  type Line 17  type
17                  FItemList: TList;                  FItemList: TList;
18                  function GetCount(RoundType: TGikoRoundType): Integer;                  function GetCount(RoundType: TGikoRoundType): Integer;
19                  function GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;                  function GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
20                  function ParseRoundBoardLine(Line: string): TRoundItem;                  function ParseRoundBoardLine(Line: string):             Boolean;
21          function ParseRoundThreadLine(Line: string): TRoundItem;                  function ParseRoundThreadLine(Line: string):    Boolean;
22          function ParseOldRoundBoardLine(Line: string): TRoundItem;                  function ParseOldRoundBoardLine(Line: string):  Boolean;
23          function ParseOldRoundThreadLine(Line: string): TRoundItem;                  function ParseOldRoundThreadLine(Line: string): Boolean;
24          public          public
25                  RoundNameList: TStringList;                  RoundNameList: TStringList;
26    
# Line 50  type Line 50  type
50    
51          TRoundItem = class(TObject)          TRoundItem = class(TObject)
52          private          private
53  //              FBBSType: TGikoBBSType;  //
54                    FItem           : TObject;
55                    FBBSType: TGikoBBSType;
56                  FRoundName: string;                  FRoundName: string;
57                  FRoundType: TGikoRoundType;                  FRoundType: TGikoRoundType;
58      //Item                      : TObject;          //Item                  : TObject;
59      FURL                        : string;                  //FURL          : string;
60                  FBoardTitle: string;                  //FBoardTitle: string;
61                  FThreadTitle: string;                  //FThreadTitle: string;
62                  FFileName: string;                  //FFileName: string;
63                    FTmpURL : string;
64                  FBoolData: Boolean;             //いろいろ使うょぅ                  FBoolData: Boolean;             //いろいろ使うょぅ
65                    function GetBoardTitle : string;
66                    function GetThreadTitle : string;
67                    function GetURL : string;
68                    function GetFileName : string;
69          public          public
70    
71          constructor Create;                  constructor Create;
72      //property BBSType: TGikoBBSType read FBBSType write FBBSType;                  property Item : TObject read FItem;
73            //property BBSType: TGikoBBSType read FBBSType write FBBSType;
74                  property RoundName: string read FRoundName write FRoundName;                  property RoundName: string read FRoundName write FRoundName;
75                  property RoundType: TGikoRoundType read FRoundType write FRoundType;                  property RoundType: TGikoRoundType read FRoundType write FRoundType;
76      //property Item : TObject read FItem write FItem;          //property Item : TObject read FItem write FItem;
77      property URL : string read FURL write FURL;                  property URL : string read GetURL;
78                  property BoardTitle: string read FBoardTitle write FBoardTitle;                  property TmpURL : string read FTmpURL write FTmpURL;
79                  property ThreadTitle: string read FThreadTitle write FThreadTitle;                  property BoardTitle: string read GetBoardTitle;
80                  property FileName: string read FFileName write FFileName;                  property ThreadTitle: string read GetThreadTitle;
81                    property FileName: string read GEtFileName;
82                  property BoolData: Boolean read FBoolData write FBoolData;                  property BoolData: Boolean read FBoolData write FBoolData;
83          end;          end;
84    
# Line 87  constructor TRoundItem.Create; Line 96  constructor TRoundItem.Create;
96  begin  begin
97          inherited Create;          inherited Create;
98  end;  end;
99    function TRoundItem.GetBoardTitle : string;
100    begin
101            Result := '';
102            if( Self.FItem <> nil) then begin
103                    if( Self.FItem is TBoard) then begin
104                            Result := TBoard(Self.FItem).Title;
105                    end else if( Self.FItem is TThreadItem) then begin
106                            Result := TThreadItem(Self.FItem).ParentBoard.Title;
107                    end;
108            end;
109    end;
110    function TRoundItem.GetThreadTitle : string;
111    begin
112            Result := '';
113            if( Self.FItem <> nil) then begin
114                    if( Self.FItem is TThreadItem) then begin
115                            Result := TThreadItem(Self.FItem).Title;
116                    end;
117            end;
118    end;
119    function TRoundItem.GetURL      : string;
120    begin
121            Result := '';
122            if( Self.FItem <> nil) then begin
123                    if( Self.FItem is TBoard) then begin
124                            Result := TBoard(Self.FItem).URL;
125                    end else if( Self.FItem is TThreadItem) then begin
126                            Result := TThreadItem(Self.FItem).URL;
127                    end;
128            end;
129    end;
130    function TRoundItem.GetFileName : string;
131    begin
132            Result := '';
133            if( Self.FItem <> nil) then begin
134                    if( Self.FItem is TThreadItem) then begin
135                            Result := TThreadItem(Self.FItem).FileName;
136                    end;
137            end;
138    end;
139  constructor TRoundList.Create;  constructor TRoundList.Create;
140  begin  begin
141          inherited;          inherited;
# Line 114  var Line 163  var
163  begin  begin
164      Result := -1;      Result := -1;
165          idx := Find(Board);          idx := Find(Board);
166            RoundNameList.Add(Board.RoundName);
167          if idx = -1 then begin          if idx = -1 then begin
168                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
169                    Item.FItem := Board;
170  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
171                  Item.RoundType := grtBoard;                  Item.RoundType := grtBoard;
172  //      Item.Item := Board;  //      Item.Item := Board;
173          Item.URL := Board.URL;                  //Item.URL := Board.URL;
174                  Item.BoardTitle := Board.Title;                  //Item.BoardTitle := Board.Title;
175                  Item.ThreadTitle := '';                  //Item.ThreadTitle := '';
176                  Item.FileName := '';                  //Item.FileName := '';
177                  Item.RoundName := Board.RoundName;                  Item.RoundName := Board.RoundName;
178                  Result := FBoardList.Add(Item);                  Result := FBoardList.Add(Item);
179          end;          end;
# Line 135  var Line 186  var
186  begin  begin
187      Result := -1;      Result := -1;
188          idx := Find(ThreadItem);          idx := Find(ThreadItem);
189            RoundNameList.Add(ThreadItem.RoundName);
190          if idx = -1 then begin          if idx = -1 then begin
191                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
192                    Item.FItem := ThreadItem;
193  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
194                  Item.RoundType := grtItem;                  Item.RoundType := grtItem;
195  //              Item.Item := ThreadItem;  //              Item.Item := ThreadItem;
196          Item.URL := Threaditem.URL;                  //Item.URL := Threaditem.URL;
197                  Item.BoardTitle := ThreadItem.ParentBoard.Title;                  //Item.BoardTitle := ThreadItem.ParentBoard.Title;
198                  Item.ThreadTitle := ThreadItem.Title;                  //Item.ThreadTitle := ThreadItem.Title;
199                  Item.FileName := ThreadItem.FileName;                  //Item.FileName := ThreadItem.FileName;
200                  Item.RoundName := ThreadItem.RoundName;                  Item.RoundName := ThreadItem.RoundName;
201                  Result := FItemList.Add(Item);                  Result := FItemList.Add(Item);
202          end;          end;
# Line 156  var Line 209  var
209  begin  begin
210          idx := Find(Board);          idx := Find(Board);
211          if idx <> -1 then begin          if idx <> -1 then begin
212                    TBoard(TRoundItem(FBoardList[idx]).FItem).RoundName := '';
213                  TRoundItem(FBoardList[idx]).Free;                  TRoundItem(FBoardList[idx]).Free;
214                  FBoardList.Delete(idx);                  FBoardList.Delete(idx);
215          end;          end;
# Line 168  var Line 222  var
222  begin  begin
223          idx := Find(ThreadItem);          idx := Find(ThreadItem);
224          if idx <> -1 then begin          if idx <> -1 then begin
225            TThreadItem(TRoundItem(FItemList[idx]).FItem).RoundName := '';
226                  TRoundItem(FItemList[idx]).Free;                  TRoundItem(FItemList[idx]).Free;
227                  FItemList.Delete(idx);                  FItemList.Delete(idx);
228          end;          end;
# Line 200  begin Line 255  begin
255          for i := 0 to FBoardList.Count - 1 do begin          for i := 0 to FBoardList.Count - 1 do begin
256                  Item := TRoundItem(FBoardList[i]);                  Item := TRoundItem(FBoardList[i]);
257                  if Item.FRoundType <> grtBoard then Continue;                  if Item.FRoundType <> grtBoard then Continue;
258                  if Item.FURL = Board.URL then begin                  if Item.FItem = Board then begin
259                          Result := i;                          Result := i;
260                          Exit;                          Exit;
261                  end;                  end;
# Line 216  begin Line 271  begin
271          for i := 0 to FItemList.Count - 1 do begin          for i := 0 to FItemList.Count - 1 do begin
272                  Item := TRoundItem(FItemList[i]);                  Item := TRoundItem(FItemList[i]);
273                  if Item.FRoundType <> grtItem then Continue;                  if Item.FRoundType <> grtItem then Continue;
274                  if Item.FURL = ThreadItem.URL then begin                  if Item.FItem = ThreadItem then begin
275                          Result := i;                          Result := i;
276                          Exit;                          Exit;
277                  end;                  end;
# Line 232  begin Line 287  begin
287                  for i := 0 to FItemList.Count - 1 do begin                  for i := 0 to FItemList.Count - 1 do begin
288                          Item := TRoundItem(FItemList[i]);                          Item := TRoundItem(FItemList[i]);
289                          if Item.FRoundType <> RoundType then Continue;                          if Item.FRoundType <> RoundType then Continue;
290                          if Item.FURL = URL then begin                          if Item.URL = URL then begin
291                                  Result := i;                                  Result := i;
292                                  Exit;                                  Exit;
293                          end;                          end;
294                  end;                  end;
295      end else begin          end else begin
296          for i := 0 to FBoardList.Count - 1 do begin                  for i := 0 to FBoardList.Count - 1 do begin
297                          Item := TRoundItem(FBoardList[i]);                          Item := TRoundItem(FBoardList[i]);
298                          if Item.FRoundType <> RoundType then Continue;                          if Item.FRoundType <> RoundType then Continue;
299                          if Item.FURL = URL then begin                          if Item.URL = URL then begin
300                                  Result := i;                                  Result := i;
301                                  Exit;                                  Exit;
302                          end;                          end;
# Line 260  begin Line 315  begin
315    
316          if RoundType = grtBoard then begin          if RoundType = grtBoard then begin
317                          Item := TRoundItem(FBoardList[idx]);                          Item := TRoundItem(FBoardList[idx]);
318                            board := TBoard(Item);
319                          Item.Free;                          Item.Free;
320                          FBoardList.Delete(idx);                          FBoardList.Delete(idx);
321                  board := BBSsFindBoardFromURL(URL);                          //board := BBSsFindBoardFromURL(URL);
322              if board <> nil then begin                          if board <> nil then begin
323                  board.Round := False;                                  board.Round := False;
324                  board.RoundName := '';                                  board.RoundName := '';
325              end;                          end;
326          end else begin                  end else begin
327                          Item := TRoundItem(FItemList[idx]);                          Item := TRoundItem(FItemList[idx]);
328                            threadItem := TThreadItem(Item.FItem);
329                          Item.Free;                          Item.Free;
330                          FItemList.Delete(idx);                          FItemList.Delete(idx);
331    
332              threadItem := BBSsFindThreadFromURL(URL);                          //threadItem := BBSsFindThreadFromURL(URL);
333              if threadItem <> nil then begin              if threadItem <> nil then begin
334                      threadItem.Round := false;                      threadItem.Round := false;
335                  threadItem.RoundName := '';                  threadItem.RoundName := '';
# Line 332  var Line 389  var
389          FileName, bFileName: string;          FileName, bFileName: string;
390          errorSl: TStringList;          errorSl: TStringList;
391          errorFileName: string;          errorFileName: string;
392          Item: TRoundItem;          //Item: TRoundItem;
393          delCount: Integer;          delCount: Integer;
394  begin  begin
395          sl := TStringList.Create;          sl := TStringList.Create;
# Line 362  begin Line 419  begin
419              //1行目はバージョン              //1行目はバージョン
420                          if sl[0] = ROUND_INDEX_VERSION then begin                          if sl[0] = ROUND_INDEX_VERSION then begin
421                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
422                                          Item := ParseRoundBoardLine(sl[i - delCount]);                                          if not ParseRoundBoardLine(sl[i - delCount]) then begin
423                      if Item <> nil then begin                                                  errorSl.Add( sl[i - delCount] );
                                                 FBoardList.Add(Item);  
                                                 RoundNameList.Add(Item.RoundName);  
                     end else begin  
                         errorSl.Add( sl[i - delCount] );  
424                          sl.Delete(i- delCount);                          sl.Delete(i- delCount);
425                          Inc(delCount);                          Inc(delCount);
426                      end;                      end;
# Line 375  begin Line 428  begin
428              end else begin              end else begin
429                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので
430                                          for i := 1 to sl.Count - 1 do begin                                          for i := 1 to sl.Count - 1 do begin
431                                                  Item := ParseOldRoundBoardLine(sl[i - delCount]);                                                  if not ParseOldRoundBoardLine(sl[i - delCount]) then begin
432                          if Item <> nil then begin                                                          errorSl.Add( sl[i- delCount] );
                                                         FBoardList.Add(Item);  
                                                         RoundNameList.Add(Item.RoundName);  
                         end else begin  
                                 errorSl.Add( sl[i- delCount] );  
433                                  sl.Delete(i- delCount);                                  sl.Delete(i- delCount);
434                              Inc(delCount);                              Inc(delCount);
435                          end;                          end;
# Line 404  var Line 453  var
453          FileName, bFileName: string;          FileName, bFileName: string;
454      errorSl: TStringList;      errorSl: TStringList;
455      errorFileName: string;      errorFileName: string;
456          Item: TRoundItem;  //      Item: TRoundItem;
457      delCount: Integer;      delCount: Integer;
458  //    boardList : TStringList;  //    boardList : TStringList;
459  begin  begin
# Line 435  begin Line 484  begin
484                          //1行目はバージョン                          //1行目はバージョン
485              if sl[0] = ROUND_INDEX_VERSION then begin              if sl[0] = ROUND_INDEX_VERSION then begin
486                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
487                                          Item := ParseRoundThreadLine(sl[i - delCount]);                                          if not ParseRoundThreadLine(sl[i - delCount]) then begin
488                      if Item <> nil then begin                                                  errorSl.Add(sl[i - delCount]);
                                                 FItemList.Add(Item);  
                                                 RoundNameList.Add(Item.RoundName);  
                                         end else begin  
                         errorSl.Add(sl[i - delCount]);  
489                          sl.Delete(i - delCount);                          sl.Delete(i - delCount);
490                          Inc(delCount);                          Inc(delCount);
491                      end;                      end;
492                  end;                  end;
493              end else begin                          end else begin
494                  LoadRoundBoardFile;                                  LoadRoundBoardFile;
495                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
496                                          Item := ParseOldRoundThreadLine(sl[i - delCount]);                                          if not ParseOldRoundThreadLine(sl[i - delCount]) then begin
                     if Item <> nil then begin  
                                                 FItemList.Add(Item);  
                                                 RoundNameList.Add(Item.RoundName);  
                     end else begin  
497                                                  errorSl.Add(sl[i - delCount]);                                                  errorSl.Add(sl[i - delCount]);
498                          sl.Delete(i - delCount);                          sl.Delete(i - delCount);
499                          Inc(delCount);                          Inc(delCount);
# Line 469  begin Line 510  begin
510                  errorSl.SaveToFile(errorFileName);                  errorSl.SaveToFile(errorFileName);
511                  end;                  end;
512          finally          finally
513          errorSl.Free;                  errorSl.Free;
514                  sl.Free;                  sl.Free;
515  //        boardList.Free;  //        boardList.Free;
516          end;          end;
# Line 490  begin Line 531  begin
531                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
532                  for i := 0 to FBoardList.Count - 1 do begin                  for i := 0 to FBoardList.Count - 1 do begin
533                          Item := TRoundItem(FBoardList[i]);                          Item := TRoundItem(FBoardList[i]);
534                          s := Item.URL + #1                          if Item.TmpURL <> '' then begin
535                                   + Item.BoardTitle + #1                                  s := Item.TmpURL + #1
536                                   + Item.RoundName;                                           + Item.BoardTitle + #1
537                                             + Item.RoundName;
538                            end else begin
539                                    s := Item.URL + #1
540                                             + Item.BoardTitle + #1
541                                             + Item.RoundName;
542                            end;
543                          sl.Add(s);                          sl.Add(s);
544                  end;                  end;
545                  sl.SaveToFile(FileName);                  sl.SaveToFile(FileName);
# Line 501  begin Line 548  begin
548                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
549                  for i := 0 to FItemList.Count - 1 do begin                  for i := 0 to FItemList.Count - 1 do begin
550                          Item := TRoundItem(FItemList[i]);                          Item := TRoundItem(FItemList[i]);
551                          s := Item.URL + #1                          if Item.TmpURL <> '' then begin
552                                    s := Item.TmpURL + #1
553                                   + Item.BoardTitle + #1                                   + Item.BoardTitle + #1
554                                   + Item.FileName + #1                                   + Item.FileName + #1
555                                   + Item.ThreadTitle + #1                                   + Item.ThreadTitle + #1
556                                   + Item.RoundName;                                   + Item.RoundName;
557                            end else begin
558                                    s := Item.URL + #1
559                                     + Item.BoardTitle + #1
560                                     + Item.FileName + #1
561                                     + Item.ThreadTitle + #1
562                                     + Item.RoundName;
563                            end;
564                          sl.Add(s);                          sl.Add(s);
565                  end;                  end;
566                  sl.SaveToFile(FileName);                  sl.SaveToFile(FileName);
# Line 513  begin Line 568  begin
568                  sl.Free;                  sl.Free;
569          end;          end;
570  end;  end;
571  function TRoundList.ParseRoundBoardLine(Line: string): TRoundItem;  function TRoundList.ParseRoundBoardLine(Line: string): Boolean;
572  var  var
573          s: string;          s: string;
574            roundname: string;
575            board: TBoard;
576          i: Integer;          i: Integer;
577  begin  begin
578          Result := TRoundItem.Create;          //Result := TRoundItem.Create;
579      Result.ThreadTitle := '';          //Result.ThreadTitle := '';
580      Result.FileName := '';          //Result.FileName := '';
581      Result.RoundType := grtBoard;          //Result.RoundType := grtBoard;
582      for i := 0 to 2 do begin          board := nil;
583          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 2 do begin
584          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
585                  case i of                  try
586                  0:                          case i of
587                  begin                                  0:
588                                  Result.URL := s;                                  begin
589                          end;                                          board := BBSsFindBoardFromURL(s);
590                  1: Result.BoardTitle := s;                                          //Result.URL := s;
591                  2: Result.RoundName := s;                                  end;
592                  end;                                  //1: Result.BoardTitle := s;
593          except                                  2: roundname := s;
594                  Result := nil;                          end;
595              Exit;                  except
596          end;                          Result := false;
597      end;                          Exit;
598                    end;
599            end;
600            if( board <> nil ) then begin
601                    if not board.Round then begin
602                            board.RoundName := roundname;
603                            board.Round := true;
604                    end;
605                    Result := true;
606            end else begin
607                    Result := false;
608            end;
609  end;  end;
610    
611  function TRoundList.ParseRoundThreadLine(Line: string): TRoundItem;  function TRoundList.ParseRoundThreadLine(Line: string): Boolean;
612  var  var
613          s: string;          s: string;
614            roundname: string;
615            threadItem: TThreadItem;
616          i: Integer;          i: Integer;
617  //    threadItem: TThreadItem;  //    threadItem: TThreadItem;
618  begin  begin
619      Result := TRoundItem.Create;          //Result := TRoundItem.Create;
620          Result.RoundType := grtItem;          //Result.RoundType := grtItem;
621      for i := 0 to 4 do begin          threadItem := nil;
622          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 4 do begin
623          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
624              case i of                  try
625                  0:                          case i of
626                  begin                                  0:
627                      Result.URL := s;                                  begin
628                      //threadItem := BBSsFindThreadFromURL( s );                                          //Result.URL := s;
629                      //if threadItem <> nil then begin                                          threadItem := BBSsFindThreadFromURL( s );
630                      //    BoardList.Add( threadItem.ParentBoard.URL );                                          //if threadItem <> nil then begin
631                      //end;                                          //    BoardList.Add( threadItem.ParentBoard.URL );
632                  end;                                          //end;
633                  1: Result.BoardTitle := s;                                  end;
634                  2: Result.FileName := s;                                  //1: Result.BoardTitle := s;
635                  3: Result.ThreadTitle := s;                                  //2: Result.FileName := s;
636                  4: Result.RoundName := s;                                  //3: Result.ThreadTitle := s;
637              end;                                  4: roundname := s;
638          except                          end;
639                  Result := nil;                  except
640              Exit;                          Result := false;
641          end;                          Exit;
642      end;                  end;
643            end;
644            if( threadItem <> nil ) then begin
645                    if not threadItem.Round then begin
646                            threadItem.RoundName := roundname;
647                            threadItem.Round := True;
648                    end;
649                    Result := true;
650            end else begin
651                    Result := false;
652            end;
653  end;  end;
654    
655  function TRoundList.ParseOldRoundBoardLine(Line: string): TRoundItem;  function TRoundList.ParseOldRoundBoardLine(Line: string): Boolean;
656      var          var
657      i: Integer;          i: Integer;
658          s: string;          s: string;
659      board: TBoard;          roundname: string;
660            board: TBoard;
661  begin  begin
662          Result := TRoundItem.Create;          //Result := TRoundItem.Create;
663      Result.ThreadTitle := '';          //Result.ThreadTitle := '';
664      Result.FileName := '';          //Result.FileName := '';
665      Result.RoundType := grtBoard;          //Result.RoundType := grtBoard;
666      for i := 0 to 2 do begin          board := nil;
667          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 2 do begin
668          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
669                  case i of                  try
670                          0:                          case i of
671                          begin                                  0:
672                          board := BBSs[ 0 ].FindBBSID( s );                                  begin
673                      if board <> nil then begin                                          board := BBSs[ 0 ].FindBBSID( s );
674                                          Result.URL := board.URL;                                          if board = nil then begin
675                      end else begin                                                  raise Exception.Create('この巡回は読み込めないよ(多分外部板)');
676                          raise Exception.Create('この巡回は読み込めないよ(多分外部板)');                                          end;
677                      end;                                  end;
678                          end;                                  //1: Result.FBoardTitle := s;
679                  1: Result.FBoardTitle := s;                                  2: roundname := s;
680                  2: Result.RoundName := s;                          end;
681                  end;                  except
682          except                          Result := false;
683                  Result := nil;                          Exit;
684              Exit;                  end;
685          end;          end;
686      end;          if( board <> nil ) then begin
687                    if not board.Round then begin
688                            board.RoundName := roundname;
689                            board.Round := true;
690                    end;
691                    Result := true;
692            end else begin
693                    Result := false;
694            end;
695  end;  end;
696    
697  function TRoundList.ParseOldRoundThreadLine(Line: string): TRoundItem;  function TRoundList.ParseOldRoundThreadLine(Line: string): Boolean;
698      var          var
699      i: Integer;          i: Integer;
700          s: string;          s: string;
701            roundname : string;
702          buf: string;          buf: string;
703      board: TBoard;          board: TBoard;
704  //    threadItem: TThreadItem;          threadItem: TThreadItem;
705      bbsID: string;      bbsID: string;
706  begin  begin
707          Result := TRoundItem.Create;  //      Result := TRoundItem.Create;
708      Result.RoundType := grtItem;  //      Result.RoundType := grtItem;
709      for i := 0 to 4 do begin          threadItem := nil;
710            for i := 0 to 4 do begin
711          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
712          try          try
713                  case i of                  case i of
714                  0: bbsID := s;                  0: bbsID := s;
715                      1: Result.BoardTitle := s;                                  //1: Result.BoardTitle := s;
716                  2:                                  2:
717                          begin                                  begin
718                          Result.FileName := s;                                          //Result.FileName := s;
719                          board := BBSs[ 0 ].FindBBSID(bbsID);                                          board := BBSs[ 0 ].FindBBSID(bbsID);
720                      if board <> nil then begin                                          if board <> nil then begin
721                          buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);                                                  buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
722                                                  Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';                                                  buf := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
723                      end else begin                                                  threadItem := BBSsFindThreadFromURL(buf);
724                          raise Exception.Create('この巡回は読み込めないよ');                                          end else begin
725                      end;                                                  raise Exception.Create('この巡回は読み込めないよ');
726                      end;                                          end;
727                  3: Result.ThreadTitle := s;                                  end;
728                      4: Result.RoundName := s;                                  //3: Result.ThreadTitle := s;
729                  end;                                  4: roundname := s;
730          except                          end;
731                  Result := nil;                  except
732              break;                          Result := false;
733          end;                          Exit;
734      end;                  end;
735            end;
736            if( threadItem <> nil ) then begin
737                    if not threadItem.Round then begin
738                            threadItem.RoundName := roundname;
739                            threadItem.Round := true;
740                    end;
741                    Result := true;
742            end else begin
743                    Result := false;
744            end;
745    
746  end;  end;
747  procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);  procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
748  var  var
749          i: Integer;          i: Integer;
750      j: Integer;          j: Integer;
751      tempString: string;          tempString: string;
752      tmpURL: string;          tmpURL: string;
753      oldHost: string;          oldHost: string;
754      oldBoardName: string;          oldBoardName: string;
755      newHost: string;          newHost: string;
756      newBoardName: string;          newBoardName: string;
757  begin  begin
758      if oldURLs.Count <> newURLs.Count then          if oldURLs.Count <> newURLs.Count then
759          Exit;                  Exit;
760      //ここから、BoardのURLの変更          //ここから、BoardのURLの変更
761      for j :=0 to oldURLs.Count - 1 do begin          for j :=0 to oldURLs.Count - 1 do begin
762                  for i :=0 to FBoardList.Count - 1 do begin                  for i :=0 to FBoardList.Count - 1 do begin
763                          if TRoundItem(FBoardList[i]).FURL = oldURLs[j] then                          if TRoundItem(FBoardList[i]).URL = oldURLs[j] then
764                  TRoundItem(FBoardList[i]).FURL := newURLs[j];                                  TRoundItem(FBoardList[i]).TmpURL := newURLs[j];
765          end;                  end;
766      end;          end;
767      //ここまで、BoardのURLの変更          //ここまで、BoardのURLの変更
768    
769      //ここから、ThreadのURLの変更          //ここから、ThreadのURLの変更
770      //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。          //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。
771      for i := 0 to oldURLs.Count - 1 do begin          for i := 0 to oldURLs.Count - 1 do begin
772          tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);                  tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
773          oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                  oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
774          oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                  oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
775          tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);                  tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
776          newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                  newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
777          newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                  newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
778    
779          for j := 0 to FItemList.Count - 1 do begin                  for j := 0 to FItemList.Count - 1 do begin
780              tempString := TRoundItem(FItemList[j]).FURL;                          tempString := TRoundItem(FItemList[j]).URL;
781              if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin                          if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
782                  tempString := StringReplace(tempString, oldHost, newHost,[]);                                  tempString := StringReplace(tempString, oldHost, newHost,[]);
783                  TRoundItem(FItemList[j]).FURL := tempString;                                  TRoundItem(FItemList[j]).TmpURL := tempString;
784              end;                          end;
785          end;                  end;
786      end;          end;
787      //ここまで、ThreadのURLの変更          //ここまで、ThreadのURLの変更
788    
789  end;  end;
790    

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.19.2.1

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26