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.3 by h677, Sat Jun 4 02:51:09 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 38  type Line 38  type
38                  property Count[RoundType: TGikoRoundType]: Integer read GetCount;                  property Count[RoundType: TGikoRoundType]: Integer read GetCount;
39          property OldFileRead: Boolean read FOldFileRead;          property OldFileRead: Boolean read FOldFileRead;
40                  property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;                  property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;
41                  procedure SetRoundName(Board: TBoard; RoundName: string); overload;                  //procedure SetRoundName(Board: TBoard; RoundName: string); overload;
42                  procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;                  //procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;
43    
44                  procedure LoadRoundBoardFile;                  procedure LoadRoundBoardFile;
45          procedure LoadRoundThreadFile;          procedure LoadRoundThreadFile;
# 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 280  begin Line 337  begin
337          end;          end;
338          end;          end;
339  end;  end;
340    {
341  procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);  procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
342  var  var
343          idx: Integer;          idx: Integer;
# Line 292  begin Line 349  begin
349                  Item.RoundName := RoundName;                  Item.RoundName := RoundName;
350          end;          end;
351  end;  end;
352    }
353    {
354  procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);  procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);
355  var  var
356          idx: Integer;          idx: Integer;
# Line 304  begin Line 362  begin
362                  Item.RoundName := RoundName;                  Item.RoundName := RoundName;
363          end;          end;
364  end;  end;
365    }
366  function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;  function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;
367  begin  begin
368          Result := 0;          Result := 0;
# Line 332  var Line 390  var
390          FileName, bFileName: string;          FileName, bFileName: string;
391          errorSl: TStringList;          errorSl: TStringList;
392          errorFileName: string;          errorFileName: string;
393          Item: TRoundItem;          //Item: TRoundItem;
394          delCount: Integer;          delCount: Integer;
395  begin  begin
396          sl := TStringList.Create;          sl := TStringList.Create;
# Line 362  begin Line 420  begin
420              //1行目はバージョン              //1行目はバージョン
421                          if sl[0] = ROUND_INDEX_VERSION then begin                          if sl[0] = ROUND_INDEX_VERSION then begin
422                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
423                                          Item := ParseRoundBoardLine(sl[i - delCount]);                                          if not ParseRoundBoardLine(sl[i - delCount]) then begin
424                      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] );  
425                          sl.Delete(i- delCount);                          sl.Delete(i- delCount);
426                          Inc(delCount);                          Inc(delCount);
427                      end;                      end;
# Line 375  begin Line 429  begin
429              end else begin              end else begin
430                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので
431                                          for i := 1 to sl.Count - 1 do begin                                          for i := 1 to sl.Count - 1 do begin
432                                                  Item := ParseOldRoundBoardLine(sl[i - delCount]);                                                  if not ParseOldRoundBoardLine(sl[i - delCount]) then begin
433                          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] );  
434                                  sl.Delete(i- delCount);                                  sl.Delete(i- delCount);
435                              Inc(delCount);                              Inc(delCount);
436                          end;                          end;
# Line 404  var Line 454  var
454          FileName, bFileName: string;          FileName, bFileName: string;
455      errorSl: TStringList;      errorSl: TStringList;
456      errorFileName: string;      errorFileName: string;
457          Item: TRoundItem;  //      Item: TRoundItem;
458      delCount: Integer;      delCount: Integer;
459  //    boardList : TStringList;  //    boardList : TStringList;
460  begin  begin
# Line 435  begin Line 485  begin
485                          //1行目はバージョン                          //1行目はバージョン
486              if sl[0] = ROUND_INDEX_VERSION then begin              if sl[0] = ROUND_INDEX_VERSION then begin
487                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
488                                          Item := ParseRoundThreadLine(sl[i - delCount]);                                          if not ParseRoundThreadLine(sl[i - delCount]) then begin
489                      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]);  
490                          sl.Delete(i - delCount);                          sl.Delete(i - delCount);
491                          Inc(delCount);                          Inc(delCount);
492                      end;                      end;
493                  end;                  end;
494              end else begin                          end else begin
495                  LoadRoundBoardFile;                                  LoadRoundBoardFile;
496                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
497                                          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  
498                                                  errorSl.Add(sl[i - delCount]);                                                  errorSl.Add(sl[i - delCount]);
499                          sl.Delete(i - delCount);                          sl.Delete(i - delCount);
500                          Inc(delCount);                          Inc(delCount);
# Line 469  begin Line 511  begin
511                  errorSl.SaveToFile(errorFileName);                  errorSl.SaveToFile(errorFileName);
512                  end;                  end;
513          finally          finally
514          errorSl.Free;                  errorSl.Free;
515                  sl.Free;                  sl.Free;
516  //        boardList.Free;  //        boardList.Free;
517          end;          end;
# Line 490  begin Line 532  begin
532                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
533                  for i := 0 to FBoardList.Count - 1 do begin                  for i := 0 to FBoardList.Count - 1 do begin
534                          Item := TRoundItem(FBoardList[i]);                          Item := TRoundItem(FBoardList[i]);
535                          s := Item.URL + #1                          if Item.TmpURL <> '' then begin
536                                   + Item.BoardTitle + #1                                  s := Item.TmpURL + #1
537                                   + Item.RoundName;                                           + Item.BoardTitle + #1
538                                             + Item.RoundName;
539                            end else begin
540                                    s := Item.URL + #1
541                                             + Item.BoardTitle + #1
542                                             + Item.RoundName;
543                            end;
544                          sl.Add(s);                          sl.Add(s);
545                  end;                  end;
546                  sl.SaveToFile(FileName);                  sl.SaveToFile(FileName);
# Line 501  begin Line 549  begin
549                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
550                  for i := 0 to FItemList.Count - 1 do begin                  for i := 0 to FItemList.Count - 1 do begin
551                          Item := TRoundItem(FItemList[i]);                          Item := TRoundItem(FItemList[i]);
552                          s := Item.URL + #1                          if Item.TmpURL <> '' then begin
553                                    s := Item.TmpURL + #1
554                                     + Item.BoardTitle + #1
555                                     + Item.FileName + #1
556                                     + Item.ThreadTitle + #1
557                                     + Item.RoundName;
558                            end else begin
559                                    s := Item.URL + #1
560                                   + Item.BoardTitle + #1                                   + Item.BoardTitle + #1
561                                   + Item.FileName + #1                                   + Item.FileName + #1
562                                   + Item.ThreadTitle + #1                                   + Item.ThreadTitle + #1
563                                   + Item.RoundName;                                   + Item.RoundName;
564                            end;
565                          sl.Add(s);                          sl.Add(s);
566                  end;                  end;
567                  sl.SaveToFile(FileName);                  sl.SaveToFile(FileName);
# Line 513  begin Line 569  begin
569                  sl.Free;                  sl.Free;
570          end;          end;
571  end;  end;
572  function TRoundList.ParseRoundBoardLine(Line: string): TRoundItem;  function TRoundList.ParseRoundBoardLine(Line: string): Boolean;
573  var  var
574          s: string;          s: string;
575            roundname: string;
576            board: TBoard;
577          i: Integer;          i: Integer;
578  begin  begin
579          Result := TRoundItem.Create;          //Result := TRoundItem.Create;
580      Result.ThreadTitle := '';          //Result.ThreadTitle := '';
581      Result.FileName := '';          //Result.FileName := '';
582      Result.RoundType := grtBoard;          //Result.RoundType := grtBoard;
583      for i := 0 to 2 do begin          board := nil;
584          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 2 do begin
585          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
586                  case i of                  try
587                  0:                          case i of
588                  begin                                  0:
589                                  Result.URL := s;                                  begin
590                          end;                                          board := BBSsFindBoardFromURL(s);
591                  1: Result.BoardTitle := s;                                          //Result.URL := s;
592                  2: Result.RoundName := s;                                  end;
593                  end;                                  //1: Result.BoardTitle := s;
594          except                                  2: roundname := s;
595                  Result := nil;                          end;
596              Exit;                  except
597          end;                          Result := false;
598      end;                          Exit;
599                    end;
600            end;
601            if( board <> nil ) then begin
602                    if not board.Round then begin
603                            board.RoundName := roundname;
604                            RoundNameList.Add(roundname);
605                            //RoundNameList.Find(roundname, i);
606                            //board.RoundName := PChar(RoundNameList[i]);
607                            board.Round := true;
608                    end;
609                    Result := true;
610            end else begin
611                    Result := false;
612            end;
613  end;  end;
614    
615  function TRoundList.ParseRoundThreadLine(Line: string): TRoundItem;  function TRoundList.ParseRoundThreadLine(Line: string): Boolean;
616  var  var
617          s: string;          s: string;
618            roundname: string;
619            threadItem: TThreadItem;
620          i: Integer;          i: Integer;
621  //    threadItem: TThreadItem;  //    threadItem: TThreadItem;
622  begin  begin
623      Result := TRoundItem.Create;          //Result := TRoundItem.Create;
624          Result.RoundType := grtItem;          //Result.RoundType := grtItem;
625      for i := 0 to 4 do begin          threadItem := nil;
626          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 4 do begin
627          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
628              case i of                  try
629                  0:                          case i of
630                  begin                                  0:
631                      Result.URL := s;                                  begin
632                      //threadItem := BBSsFindThreadFromURL( s );                                          //Result.URL := s;
633                      //if threadItem <> nil then begin                                          threadItem := BBSsFindThreadFromURL( s );
634                      //    BoardList.Add( threadItem.ParentBoard.URL );                                          //if threadItem <> nil then begin
635                      //end;                                          //    BoardList.Add( threadItem.ParentBoard.URL );
636                  end;                                          //end;
637                  1: Result.BoardTitle := s;                                  end;
638                  2: Result.FileName := s;                                  //1: Result.BoardTitle := s;
639                  3: Result.ThreadTitle := s;                                  //2: Result.FileName := s;
640                  4: Result.RoundName := s;                                  //3: Result.ThreadTitle := s;
641              end;                                  4: roundname := s;
642          except                          end;
643                  Result := nil;                  except
644              Exit;                          Result := false;
645          end;                          Exit;
646      end;                  end;
647            end;
648            if( threadItem <> nil ) then begin
649                    if not threadItem.Round then begin
650                            threadItem.RoundName := roundname;
651                            RoundNameList.Add(roundname);
652                            //RoundNameList.Find(roundname, i);
653                            //threadItem.RoundName := PChar(RoundNameList[i]);
654                            threadItem.Round := True;
655                    end;
656                    Result := true;
657            end else begin
658                    Result := false;
659            end;
660  end;  end;
661    
662  function TRoundList.ParseOldRoundBoardLine(Line: string): TRoundItem;  function TRoundList.ParseOldRoundBoardLine(Line: string): Boolean;
663      var          var
664      i: Integer;          i: Integer;
665          s: string;          s: string;
666      board: TBoard;          roundname: string;
667            board: TBoard;
668  begin  begin
669          Result := TRoundItem.Create;          //Result := TRoundItem.Create;
670      Result.ThreadTitle := '';          //Result.ThreadTitle := '';
671      Result.FileName := '';          //Result.FileName := '';
672      Result.RoundType := grtBoard;          //Result.RoundType := grtBoard;
673      for i := 0 to 2 do begin          board := nil;
674          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 2 do begin
675          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
676                  case i of                  try
677                          0:                          case i of
678                          begin                                  0:
679                          board := BBSs[ 0 ].FindBBSID( s );                                  begin
680                      if board <> nil then begin                                          board := BBSs[ 0 ].FindBBSID( s );
681                                          Result.URL := board.URL;                                          if board = nil then begin
682                      end else begin                                                  raise Exception.Create('この巡回は読み込めないよ(多分外部板)');
683                          raise Exception.Create('この巡回は読み込めないよ(多分外部板)');                                          end;
684                      end;                                  end;
685                          end;                                  //1: Result.FBoardTitle := s;
686                  1: Result.FBoardTitle := s;                                  2: roundname := s;
687                  2: Result.RoundName := s;                          end;
688                  end;                  except
689          except                          Result := false;
690                  Result := nil;                          Exit;
691              Exit;                  end;
692          end;          end;
693      end;          if( board <> nil ) then begin
694                    if not board.Round then begin
695                            board.RoundName := roundname;
696                            RoundNameList.Add(roundname);
697                            //RoundNameList.Find(roundname, i);
698                            //board.RoundName := PChar(RoundNameList[i]);
699                            board.Round := true;
700                    end;
701                    Result := true;
702            end else begin
703                    Result := false;
704            end;
705  end;  end;
706    
707  function TRoundList.ParseOldRoundThreadLine(Line: string): TRoundItem;  function TRoundList.ParseOldRoundThreadLine(Line: string): Boolean;
708      var          var
709      i: Integer;          i: Integer;
710          s: string;          s: string;
711            roundname : string;
712          buf: string;          buf: string;
713      board: TBoard;          board: TBoard;
714  //    threadItem: TThreadItem;          threadItem: TThreadItem;
715      bbsID: string;          bbsID: string;
716  begin  begin
717          Result := TRoundItem.Create;  //      Result := TRoundItem.Create;
718      Result.RoundType := grtItem;  //      Result.RoundType := grtItem;
719      for i := 0 to 4 do begin          threadItem := nil;
720          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 4 do begin
721          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
722                  case i of                  try
723                  0: bbsID := s;                          case i of
724                      1: Result.BoardTitle := s;                                  0: bbsID := s;
725                  2:                                  //1: Result.BoardTitle := s;
726                          begin                                  2:
727                          Result.FileName := s;                                  begin
728                          board := BBSs[ 0 ].FindBBSID(bbsID);                                          //Result.FileName := s;
729                      if board <> nil then begin                                          board := BBSs[ 0 ].FindBBSID(bbsID);
730                          buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);                                          if board <> nil then begin
731                                                  Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';                                                  buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
732                      end else begin                                                  buf := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
733                          raise Exception.Create('この巡回は読み込めないよ');                                                  threadItem := BBSsFindThreadFromURL(buf);
734                      end;                                          end else begin
735                      end;                                                  raise Exception.Create('この巡回は読み込めないよ');
736                  3: Result.ThreadTitle := s;                                          end;
737                      4: Result.RoundName := s;                                  end;
738                  end;                                  //3: Result.ThreadTitle := s;
739          except                                  4: roundname := s;
740                  Result := nil;                          end;
741              break;                  except
742          end;                          Result := false;
743      end;                          Exit;
744                    end;
745            end;
746            if( threadItem <> nil ) then begin
747                    if not threadItem.Round then begin
748                            threadItem.RoundName := roundname;
749                            RoundNameList.Add(roundname);
750                            //RoundNameList.Find(roundname, i);
751                            //threadItem.RoundName := PChar(RoundNameList[i]);
752                            threadItem.Round := true;
753                    end;
754                    Result := true;
755            end else begin
756                    Result := false;
757            end;
758    
759  end;  end;
760  procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);  procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
761  var  var
762          i: Integer;          i: Integer;
763      j: Integer;          j: Integer;
764      tempString: string;          tempString: string;
765      tmpURL: string;          tmpURL: string;
766      oldHost: string;          oldHost: string;
767      oldBoardName: string;          oldBoardName: string;
768      newHost: string;          newHost: string;
769      newBoardName: string;          newBoardName: string;
770  begin  begin
771      if oldURLs.Count <> newURLs.Count then          if oldURLs.Count <> newURLs.Count then
772          Exit;                  Exit;
773      //ここから、BoardのURLの変更          //ここから、BoardのURLの変更
774      for j :=0 to oldURLs.Count - 1 do begin          for j :=0 to oldURLs.Count - 1 do begin
775                  for i :=0 to FBoardList.Count - 1 do begin                  for i :=0 to FBoardList.Count - 1 do begin
776                          if TRoundItem(FBoardList[i]).FURL = oldURLs[j] then                          if TRoundItem(FBoardList[i]).URL = oldURLs[j] then
777                  TRoundItem(FBoardList[i]).FURL := newURLs[j];                                  TRoundItem(FBoardList[i]).TmpURL := newURLs[j];
778          end;                  end;
779      end;          end;
780      //ここまで、BoardのURLの変更          //ここまで、BoardのURLの変更
781    
782      //ここから、ThreadのURLの変更          //ここから、ThreadのURLの変更
783      //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。          //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。
784      for i := 0 to oldURLs.Count - 1 do begin          for i := 0 to oldURLs.Count - 1 do begin
785          tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);                  tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
786          oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                  oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
787          oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                  oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
788          tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);                  tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
789          newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                  newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
790          newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                  newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
791    
792          for j := 0 to FItemList.Count - 1 do begin                  for j := 0 to FItemList.Count - 1 do begin
793              tempString := TRoundItem(FItemList[j]).FURL;                          tempString := TRoundItem(FItemList[j]).URL;
794              if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin                          if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
795                  tempString := StringReplace(tempString, oldHost, newHost,[]);                                  tempString := StringReplace(tempString, oldHost, newHost,[]);
796                  TRoundItem(FItemList[j]).FURL := tempString;                                  TRoundItem(FItemList[j]).TmpURL := tempString;
797              end;                          end;
798          end;                  end;
799      end;          end;
800      //ここまで、ThreadのURLの変更          //ここまで、ThreadのURLの変更
801    
802  end;  end;
803    

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

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