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.2 by h677, Thu Sep 4 08:22:07 2003 UTC revision 1.2.2.1 by yoffy, Mon Apr 19 22:46:49 2004 UTC
# Line 12  type Line 12  type
12    
13          TRoundList = class(TObject)          TRoundList = class(TObject)
14          private          private
15            FOldFileRead: Boolean;
16                  FBoardList: TList;                  FBoardList: TList;
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 ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;                  function ParseRoundBoardLine(Line: string): TRoundItem;
21            function ParseRoundThreadLine(Line: string): TRoundItem;
22            function ParseOldRoundBoardLine(Line: string): TRoundItem;
23            function ParseOldRoundThreadLine(Line: string): TRoundItem;
24          public          public
25                  RoundNameList: TStringList;                  RoundNameList: TStringList;
26    
# Line 26  type Line 30  type
30                  function Add(ThreadItem: TThreadItem): Integer; overload;                  function Add(ThreadItem: TThreadItem): Integer; overload;
31                  procedure Delete(Board: TBoard); overload;                  procedure Delete(Board: TBoard); overload;
32                  procedure Delete(ThreadItem: TThreadItem); overload;                  procedure Delete(ThreadItem: TThreadItem); overload;
33            procedure Delete(URL: string; RoundType: TGikoRoundType); overload;
34                  procedure Clear;                  procedure Clear;
35                  function Find(Board: TBoard): Integer; overload;                  function Find(Board: TBoard): Integer; overload;
36                  function Find(ThreadItem: TThreadItem): Integer; overload;                  function Find(ThreadItem: TThreadItem): Integer; overload;
37            function Find(URL: string; RoundType: TGikoRoundType): Integer; overload;
38                  property Count[RoundType: TGikoRoundType]: Integer read GetCount;                  property Count[RoundType: TGikoRoundType]: Integer read GetCount;
39            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 LoadRoundFile;                  procedure LoadRoundBoardFile;
45            procedure LoadRoundThreadFile;
46                  procedure SaveRoundFile;                  procedure SaveRoundFile;
47    
48            procedure URLReplace(oldURLs: TStringList; newURLs :TStringList);
49          end;          end;
50    
51          TRoundItem = class(TObject)          TRoundItem = class(TObject)
# Line 43  type Line 53  type
53  //              FBBSType: TGikoBBSType;  //              FBBSType: TGikoBBSType;
54                  FRoundName: string;                  FRoundName: string;
55                  FRoundType: TGikoRoundType;                  FRoundType: TGikoRoundType;
56                  FBBSID: string;      //Item                      : TObject;
57        FURL                        : string;
58                  FBoardTitle: string;                  FBoardTitle: string;
59                  FThreadTitle: string;                  FThreadTitle: string;
60                  FFileName: string;                  FFileName: string;
61                  FBoolData: Boolean;             //いろいろ使うょぅ                  FBoolData: Boolean;             //いろいろ使うょぅ
62          public          public
63  //              property BBSType: TGikoBBSType read FBBSType write FBBSType;  
64            constructor Create;
65        //property BBSType: TGikoBBSType read FBBSType write FBBSType;
66                  property RoundName: string read FRoundName write FRoundName;                  property RoundName: string read FRoundName write FRoundName;
67                  property RoundType: TGikoRoundType read FRoundType write FRoundType;                  property RoundType: TGikoRoundType read FRoundType write FRoundType;
68                  property BBSID: string read FBBSID write FBBSID;      //property Item : TObject read FItem write FItem;
69        property URL : string read FURL write FURL;
70                  property BoardTitle: string read FBoardTitle write FBoardTitle;                  property BoardTitle: string read FBoardTitle write FBoardTitle;
71                  property ThreadTitle: string read FThreadTitle write FThreadTitle;                  property ThreadTitle: string read FThreadTitle write FThreadTitle;
72                  property FileName: string read FFileName write FFileName;                  property FileName: string read FFileName write FFileName;
# Line 66  implementation Line 80  implementation
80  const  const
81          ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch';        //あとでBoardGroupへ移動          ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch';        //あとでBoardGroupへ移動
82          ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //同上          ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //同上
83          ROUND_INDEX_VERSION: string = '1.00';          ROUND_INDEX_VERSION: string = '2.00';
84        ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error行を保管する
85        ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error行を保管する
86    constructor TRoundItem.Create;
87    begin
88            inherited Create;
89    end;
90  constructor TRoundList.Create;  constructor TRoundList.Create;
91  begin  begin
92          inherited;          inherited;
# Line 76  begin Line 95  begin
95          RoundNameList := TStringList.Create;          RoundNameList := TStringList.Create;
96          RoundNameList.Sorted := True;          RoundNameList.Sorted := True;
97          RoundNameList.Duplicates := dupIgnore;          RoundNameList.Duplicates := dupIgnore;
98        FOldFileRead := false;
99  end;  end;
100    
101  destructor TRoundList.Destroy;  destructor TRoundList.Destroy;
# Line 84  begin Line 104  begin
104          Clear;          Clear;
105          FBoardList.Free;          FBoardList.Free;
106          FItemList.Free;          FItemList.Free;
107          inherited;          //inherited;
108  end;  end;
109    
110  function TRoundList.Add(Board: TBoard): Integer;  function TRoundList.Add(Board: TBoard): Integer;
# Line 98  begin Line 118  begin
118                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
119  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
120                  Item.RoundType := grtBoard;                  Item.RoundType := grtBoard;
121                  Item.BBSID := Board.BBSID;  //      Item.Item := Board;
122            Item.URL := Board.URL;
123                  Item.BoardTitle := Board.Title;                  Item.BoardTitle := Board.Title;
124                  Item.ThreadTitle := '';                  Item.ThreadTitle := '';
125                  Item.FileName := '';                  Item.FileName := '';
# Line 118  begin Line 139  begin
139                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
140  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
141                  Item.RoundType := grtItem;                  Item.RoundType := grtItem;
142                  Item.BBSID := ThreadItem.ParentBoard.BBSID;  //              Item.Item := ThreadItem;
143            Item.URL := Threaditem.URL;
144                  Item.BoardTitle := ThreadItem.ParentBoard.Title;                  Item.BoardTitle := ThreadItem.ParentBoard.Title;
145                  Item.ThreadTitle := ThreadItem.Title;                  Item.ThreadTitle := ThreadItem.Title;
146                  Item.FileName := ThreadItem.FileName;                  Item.FileName := ThreadItem.FileName;
# Line 130  end; Line 152  end;
152  procedure TRoundList.Delete(Board: TBoard);  procedure TRoundList.Delete(Board: TBoard);
153  var  var
154          idx: Integer;          idx: Integer;
155          Item: TRoundItem;  //      Item: TRoundItem;
156  begin  begin
157          idx := Find(Board);          idx := Find(Board);
158          if idx <> -1 then begin          if idx <> -1 then begin
159                  Item := TRoundItem(FBoardList[idx]);                  TRoundItem(FBoardList[idx]).Free;
                 Item.Free;  
160                  FBoardList.Delete(idx);                  FBoardList.Delete(idx);
161          end;          end;
162  end;  end;
# Line 143  end; Line 164  end;
164  procedure TRoundList.Delete(ThreadItem: TThreadItem);  procedure TRoundList.Delete(ThreadItem: TThreadItem);
165  var  var
166          idx: Integer;          idx: Integer;
167          Item: TRoundItem;  //      Item: TRoundItem;
168  begin  begin
169          idx := Find(ThreadItem);          idx := Find(ThreadItem);
170          if idx <> -1 then begin          if idx <> -1 then begin
171                  Item := TRoundItem(FItemList[idx]);                  TRoundItem(FItemList[idx]).Free;
                 Item.Free;  
172                  FItemList.Delete(idx);                  FItemList.Delete(idx);
173          end;          end;
174  end;  end;
# Line 158  var Line 178  var
178          i: Integer;          i: Integer;
179  begin  begin
180          for i := FBoardList.Count - 1 downto 0 do begin          for i := FBoardList.Count - 1 downto 0 do begin
181                  TRoundItem(FBoardList[i]).Free;          if FBoardList[i] <> nil then
182                            TRoundItem(FBoardList[i]).Free;
183                  FBoardList.Delete(i);                  FBoardList.Delete(i);
184          end;          end;
185        FBoardList.Capacity := FBoardList.Count;
186          for i := FItemList.Count - 1 downto 0 do begin          for i := FItemList.Count - 1 downto 0 do begin
187                  TRoundItem(FItemList[i]).Free;          if FItemList[i] <> nil then
188                            TRoundItem(FItemList[i]).Free;
189                  FItemList.Delete(i);                  FItemList.Delete(i);
190          end;          end;
191        FItemList.Capacity := FItemList.Count;
192  end;  end;
193    
194  function TRoundList.Find(Board: TBoard): Integer;  function TRoundList.Find(Board: TBoard): Integer;
# Line 176  begin Line 200  begin
200          for i := 0 to FBoardList.Count - 1 do begin          for i := 0 to FBoardList.Count - 1 do begin
201                  Item := TRoundItem(FBoardList[i]);                  Item := TRoundItem(FBoardList[i]);
202                  if Item.FRoundType <> grtBoard then Continue;                  if Item.FRoundType <> grtBoard then Continue;
203                  if Item.FBBSID = Board.BBSID then begin                  if Item.FURL = Board.URL then begin
204                          Result := i;                          Result := i;
205                          Exit;                          Exit;
206                  end;                  end;
# Line 192  begin Line 216  begin
216          for i := 0 to FItemList.Count - 1 do begin          for i := 0 to FItemList.Count - 1 do begin
217                  Item := TRoundItem(FItemList[i]);                  Item := TRoundItem(FItemList[i]);
218                  if Item.FRoundType <> grtItem then Continue;                  if Item.FRoundType <> grtItem then Continue;
219                  if (Item.FBBSID = ThreadItem.ParentBoard.BBSID) and (Item.FFileName = ThreadItem.FileName) then begin                  if Item.FURL = ThreadItem.URL then begin
220                          Result := i;                          Result := i;
221                          Exit;                          Exit;
222                  end;                  end;
223          end;          end;
224  end;  end;
225    function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer;
226    var
227            i: Integer;
228            Item: TRoundItem;
229    begin
230            Result := -1;
231        if RoundType = grtItem then begin
232                    for i := 0 to FItemList.Count - 1 do begin
233                            Item := TRoundItem(FItemList[i]);
234                            if Item.FRoundType <> RoundType then Continue;
235                            if Item.FURL = URL then begin
236                                    Result := i;
237                                    Exit;
238                            end;
239                    end;
240        end else begin
241            for i := 0 to FBoardList.Count - 1 do begin
242                            Item := TRoundItem(FBoardList[i]);
243                            if Item.FRoundType <> RoundType then Continue;
244                            if Item.FURL = URL then begin
245                                    Result := i;
246                                    Exit;
247                            end;
248                    end;
249        end;
250    end;
251    procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
252    var
253            idx: Integer;
254            Item: TRoundItem;
255        board: TBoard;
256        threadItem: TThreadItem;
257    begin
258            idx := Find(URL, RoundType);
259            if idx <> -1 then begin
260    
261            if RoundType = grtBoard then begin
262                            Item := TRoundItem(FBoardList[idx]);
263                            Item.Free;
264                            FBoardList.Delete(idx);
265                    board := BBSsFindBoardFromURL(URL);
266                if board <> nil then begin
267                    board.Round := False;
268                    board.RoundName := '';
269                end;
270            end else begin
271                            Item := TRoundItem(FItemList[idx]);
272                            Item.Free;
273                            FItemList.Delete(idx);
274    
275                threadItem := BBSsFindThreadFromURL(URL);
276                if threadItem <> nil then begin
277                        threadItem.Round := false;
278                    threadItem.RoundName := '';
279                end;
280            end;
281            end;
282    end;
283    
284  procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);  procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
285  var  var
# Line 243  begin Line 325  begin
325                          Result := TRoundItem(FItemList[Index]);                          Result := TRoundItem(FItemList[Index]);
326          end;          end;
327  end;  end;
328    procedure TRoundList.LoadRoundBoardFile;
 procedure TRoundList.LoadRoundFile;  
329  var  var
330          i: Integer;          i: Integer;
331          sl: TStringList;          sl: TStringList;
332          FileName: string;          FileName: string;
333        errorSl: TStringList;
334        errorFileName: string;
335          Item: TRoundItem;          Item: TRoundItem;
336        delCount: Integer;
337  begin  begin
338          sl := TStringList.Create;          sl := TStringList.Create;
339        errorSl := TStringList.Create;
340            errorSl.Duplicates := dupIgnore;
341          try          try
342                  //ボード巡回ファイル読み込み                  //ボード巡回ファイル読み込み
343                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
344            //エラー行保存ファイル読み込み
345            errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME;
346                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
347                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
348                          //1行目はバージョンなので無視              if FileExists(errorFileName) then begin
349                          for i := 1 to sl.Count - 1 do begin                  try
350                                  Item := ParseRoundLine(sl[i], grtBoard);                          errorSl.LoadFromFile(errorFileName);
351                                  FBoardList.Add(Item);                  except
352                                  RoundNameList.Add(Item.RoundName);                  end;
353                          end;              end;
354                //Item := TRoundItem.Create;
355                delCount := 0;
356                //1行目はバージョン
357                            if sl[0] = ROUND_INDEX_VERSION then begin
358                                    for i := 1 to sl.Count - 1 do begin
359                                            Item := ParseRoundBoardLine(sl[i - delCount]);
360                        if Item <> nil then begin
361                                                    FBoardList.Add(Item);
362                                                    RoundNameList.Add(Item.RoundName);
363                        end else begin
364                            errorSl.Add( sl[i - delCount] );
365                            sl.Delete(i- delCount);
366                            Inc(delCount);
367                        end;
368                                    end;
369                end else begin
370                    if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので
371                                            for i := 1 to sl.Count - 1 do begin
372                                                    Item := ParseOldRoundBoardLine(sl[i - delCount]);
373                            if Item <> nil then begin
374                                                            FBoardList.Add(Item);
375                                                            RoundNameList.Add(Item.RoundName);
376                            end else begin
377                                    errorSl.Add( sl[i- delCount] );
378                                    sl.Delete(i- delCount);
379                                Inc(delCount);
380                            end;
381                                            end;
382                    end else
383                            FOldFileRead := true;
384                end;
385                  end;                  end;
386            if errorSl.Count > 0 then
387                    errorSl.SaveToFile(errorFileName);
388            finally
389            errorSl.Free;
390                    sl.Free;
391            end;
392    end;
393    procedure TRoundList.LoadRoundThreadFile;
394    var
395            i: Integer;
396    //    j: Integer;
397            sl: TStringList;
398            FileName: string;
399        errorSl: TStringList;
400        errorFileName: string;
401            Item: TRoundItem;
402        delCount: Integer;
403    //    boardList : TStringList;
404    begin
405    //    boardList := TStringList.Create;
406    //    boardList.Duplicates := dupIgnore;
407        errorSl := TStringList.Create;
408            errorSl.Duplicates := dupIgnore;
409            sl := TStringList.Create;
410            try
411                  //スレ巡回ファイル読み込み                  //スレ巡回ファイル読み込み
412                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
413            //エラー行保存ファイル読み込み
414            errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME;
415                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
416                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
417                          //1行目はバージョンなので無視              if FileExists(errorFileName) then begin
418                          for i := 1 to sl.Count - 1 do begin                  try
419                                  Item := ParseRoundLine(sl[i], grtItem);                          errorSl.LoadFromFile(errorFileName);
420                                  FItemList.Add(Item);                  except
421                                  RoundNameList.Add(Item.RoundName);                  end;
422                          end;              end;
423                //Item := TRoundItem.Create;
424                delCount := 0;
425                            //1行目はバージョン
426                if sl[0] = ROUND_INDEX_VERSION then begin
427                                    for i := 1 to sl.Count - 1 do begin
428                                            Item := ParseRoundThreadLine(sl[i - delCount]);
429                        if Item <> nil then begin
430                                                    FItemList.Add(Item);
431                                                    RoundNameList.Add(Item.RoundName);
432                                            end else begin
433                            errorSl.Add(sl[i - delCount]);
434                            sl.Delete(i - delCount);
435                            Inc(delCount);
436                        end;
437                    end;
438                end else begin
439                    LoadRoundBoardFile;
440                    for i := 1 to sl.Count - 1 do begin
441                                            Item := ParseOldRoundThreadLine(sl[i - delCount]);
442                        if Item <> nil then begin
443                                                    FItemList.Add(Item);
444                                                    RoundNameList.Add(Item.RoundName);
445                        end else begin
446                                                    errorSl.Add(sl[i - delCount]);
447                            sl.Delete(i - delCount);
448                            Inc(delCount);
449                        end;
450                                    end;
451                end;
452    //              j := boardList.Count - 1;
453    //          while j >= 0 do begin
454    //                      GikoSys.ReadSubjectFile( BBSsFindBoardFromURL( boardList[j] ) );
455    //                  boardList.Delete(j);
456    //              Dec(j);
457    //              end;
458                if errorSl.Count > 0 then
459                    errorSl.SaveToFile(errorFileName);
460                  end;                  end;
461          finally          finally
462            errorSl.Free;
463                  sl.Free;                  sl.Free;
464    //        boardList.Free;
465          end;          end;
466  end;  end;
   
467  procedure TRoundList.SaveRoundFile;  procedure TRoundList.SaveRoundFile;
468  var  var
469          i: integer;          i: integer;
# Line 296  begin Line 480  begin
480                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
481                  for i := 0 to FBoardList.Count - 1 do begin                  for i := 0 to FBoardList.Count - 1 do begin
482                          Item := TRoundItem(FBoardList[i]);                          Item := TRoundItem(FBoardList[i]);
483                          s := Item.BBSID + #1                          s := Item.URL + #1
484                                   + Item.BoardTitle + #1                                   + Item.BoardTitle + #1
485                                   + Item.RoundName;                                   + Item.RoundName;
486                          sl.Add(s);                          sl.Add(s);
# Line 307  begin Line 491  begin
491                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
492                  for i := 0 to FItemList.Count - 1 do begin                  for i := 0 to FItemList.Count - 1 do begin
493                          Item := TRoundItem(FItemList[i]);                          Item := TRoundItem(FItemList[i]);
494                          s := Item.BBSID + #1                          s := Item.URL + #1
495                                   + Item.BoardTitle + #1                                   + Item.BoardTitle + #1
496                                   + Item.FileName + #1                                   + Item.FileName + #1
497                                   + Item.ThreadTitle + #1                                   + Item.ThreadTitle + #1
# Line 319  begin Line 503  begin
503                  sl.Free;                  sl.Free;
504          end;          end;
505  end;  end;
506    function TRoundList.ParseRoundBoardLine(Line: string): TRoundItem;
507    var
508            s: string;
509            i: Integer;
510    begin
511            Result := TRoundItem.Create;
512        Result.ThreadTitle := '';
513        Result.FileName := '';
514        Result.RoundType := grtBoard;
515        for i := 0 to 2 do begin
516            s := GikoSys.GetTokenIndex(Line, #1, i);
517            try
518                    case i of
519                    0:
520                    begin
521                                    Result.URL := s;
522                            end;
523                    1: Result.BoardTitle := s;
524                    2: Result.RoundName := s;
525                    end;
526            except
527                    Result := nil;
528                Exit;
529            end;
530        end;
531    end;
532    
533  function TRoundList.ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;  function TRoundList.ParseRoundThreadLine(Line: string): TRoundItem;
534  var  var
535          s: string;          s: string;
536          i: Integer;          i: Integer;
537    //    threadItem: TThreadItem;
538    begin
539        Result := TRoundItem.Create;
540            Result.RoundType := grtItem;
541        for i := 0 to 4 do begin
542            s := GikoSys.GetTokenIndex(Line, #1, i);
543            try
544                case i of
545                    0:
546                    begin
547                        Result.URL := s;
548                        //threadItem := BBSsFindThreadFromURL( s );
549                        //if threadItem <> nil then begin
550                        //    BoardList.Add( threadItem.ParentBoard.URL );
551                        //end;
552                    end;
553                    1: Result.BoardTitle := s;
554                    2: Result.FileName := s;
555                    3: Result.ThreadTitle := s;
556                    4: Result.RoundName := s;
557                end;
558            except
559                    Result := nil;
560                Exit;
561            end;
562        end;
563    end;
564    
565    function TRoundList.ParseOldRoundBoardLine(Line: string): TRoundItem;
566        var
567        i: Integer;
568            s: string;
569        board: TBoard;
570  begin  begin
571          Result := TRoundItem.Create;          Result := TRoundItem.Create;
572          if RoundType = grtBoard then begin      Result.ThreadTitle := '';
573                  Result.ThreadTitle := '';      Result.FileName := '';
574                  Result.FileName := '';      Result.RoundType := grtBoard;
575                  Result.RoundType := grtBoard;      for i := 0 to 2 do begin
576                  for i := 0 to 2 do begin          s := GikoSys.GetTokenIndex(Line, #1, i);
577                          s := GikoSys.GetTokenIndex(Line, #1, i);          try
578                          case i of                  case i of
579                                  0: Result.BBSID := s;                          0:
580                                  1: Result.BoardTitle := s;                          begin
581                                  2: Result.RoundName := s;                          board := BBSs[ 0 ].FindBBSID( s );
582                          end;                      if board <> nil then begin
583                  end;                                          Result.URL := board.URL;
584          end else if RoundType = grtItem then begin                      end else begin
585                  Result.RoundType := grtItem;                          raise Exception.Create('この巡回は読み込めないよ(多分外部板)');
586                  for i := 0 to 4 do begin                      end;
587                          s := GikoSys.GetTokenIndex(Line, #1, i);                          end;
588                          case i of                  1: Result.FBoardTitle := s;
589                                  0: Result.BBSID := s;                  2: Result.RoundName := s;
590                                  1: Result.BoardTitle := s;                  end;
591                                  2: Result.FileName := s;          except
592                                  3: Result.ThreadTitle := s;                  Result := nil;
593                                  4: Result.RoundName := s;              Exit;
594                          end;          end;
595                  end;      end;
596          end;  end;
597    
598    function TRoundList.ParseOldRoundThreadLine(Line: string): TRoundItem;
599        var
600        i: Integer;
601            s: string;
602            buf: string;
603        board: TBoard;
604    //    threadItem: TThreadItem;
605        bbsID: string;
606    begin
607            Result := TRoundItem.Create;
608        Result.RoundType := grtItem;
609        for i := 0 to 4 do begin
610            s := GikoSys.GetTokenIndex(Line, #1, i);
611            try
612                    case i of
613                    0: bbsID := s;
614                        1: Result.BoardTitle := s;
615                    2:
616                            begin
617                            Result.FileName := s;
618                            board := BBSs[ 0 ].FindBBSID(bbsID);
619                        if board <> nil then begin
620                            buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
621                                                    Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
622                        end else begin
623                            raise Exception.Create('この巡回は読み込めないよ');
624                        end;
625                        end;
626                    3: Result.ThreadTitle := s;
627                        4: Result.RoundName := s;
628                    end;
629            except
630                    Result := nil;
631                break;
632            end;
633        end;
634    end;
635    procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
636    var
637            i: Integer;
638        j: Integer;
639        tempString: string;
640        tmpURL: string;
641        oldHost: string;
642        oldBoardName: string;
643        newHost: string;
644        newBoardName: string;
645    begin
646        if oldURLs.Count <> newURLs.Count then
647            Exit;
648        //ここから、BoardのURLの変更
649        for j :=0 to oldURLs.Count - 1 do begin
650                    for i :=0 to FBoardList.Count - 1 do begin
651                            if TRoundItem(FBoardList[i]).FURL = oldURLs[j] then
652                    TRoundItem(FBoardList[i]).FURL := newURLs[j];
653            end;
654        end;
655        //ここまで、BoardのURLの変更
656    
657        //ここから、ThreadのURLの変更
658        //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。
659        for i := 0 to oldURLs.Count - 1 do begin
660            tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
661            oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
662            oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
663            tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
664            newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
665            newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
666    
667            for j := 0 to FItemList.Count - 1 do begin
668                tempString := TRoundItem(FItemList[j]).FURL;
669                if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
670                    tempString := StringReplace(tempString, oldHost, newHost,[]);
671                    TRoundItem(FItemList[j]).FURL := tempString;
672                end;
673            end;
674        end;
675        //ここまで、ThreadのURLの変更
676    
677  end;  end;
678    
679  end.  end.

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.2.2.1

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