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.2.1 by yoffy, Mon Apr 19 22:46:49 2004 UTC revision 1.26 by eggcake, Fri Oct 10 13:41:33 2008 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;
                 procedure SetRoundName(Board: TBoard; RoundName: string); overload;  
                 procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;  
   
41                  procedure LoadRoundBoardFile;                  procedure LoadRoundBoardFile;
42          procedure LoadRoundThreadFile;          procedure LoadRoundThreadFile;
43                  procedure SaveRoundFile;                  procedure SaveRoundFile;
# Line 50  type Line 47  type
47    
48          TRoundItem = class(TObject)          TRoundItem = class(TObject)
49          private          private
50  //              FBBSType: TGikoBBSType;                  FItem           : TObject;
                 FRoundName: string;  
51                  FRoundType: TGikoRoundType;                  FRoundType: TGikoRoundType;
52      //Item                      : TObject;                  FTmpURL : string;
     FURL                        : string;  
                 FBoardTitle: string;  
                 FThreadTitle: string;  
                 FFileName: string;  
53                  FBoolData: Boolean;             //いろいろ使うょぅ                  FBoolData: Boolean;             //いろいろ使うょぅ
54                    function GetBoardTitle : string;
55                    function GetThreadTitle : string;
56                    function GetURL : string;
57                    function GetFileName : string;
58            //! 巡回名取得
59            function GetRoundName : string;
60          public          public
61                    constructor Create;
62          constructor Create;                  property Item : TObject read FItem;
63      //property BBSType: TGikoBBSType read FBBSType write FBBSType;                  property RoundName: string read GetRoundName;
                 property RoundName: string read FRoundName write FRoundName;  
64                  property RoundType: TGikoRoundType read FRoundType write FRoundType;                  property RoundType: TGikoRoundType read FRoundType write FRoundType;
65      //property Item : TObject read FItem write FItem;                  property URL : string read GetURL;
66      property URL : string read FURL write FURL;                  property TmpURL : string read FTmpURL write FTmpURL;
67                  property BoardTitle: string read FBoardTitle write FBoardTitle;                  property BoardTitle: string read GetBoardTitle;
68                  property ThreadTitle: string read FThreadTitle write FThreadTitle;                  property ThreadTitle: string read GetThreadTitle;
69                  property FileName: string read FFileName write FFileName;                  property FileName: string read GEtFileName;
70                  property BoolData: Boolean read FBoolData write FBoolData;                  property BoolData: Boolean read FBoolData write FBoolData;
71          end;          end;
72    
# Line 83  const Line 80  const
80          ROUND_INDEX_VERSION: string = '2.00';          ROUND_INDEX_VERSION: string = '2.00';
81      ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error行を保管する      ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error行を保管する
82      ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error行を保管する      ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error行を保管する
83    //! 巡回アイテムコンストラクタ
84  constructor TRoundItem.Create;  constructor TRoundItem.Create;
85  begin  begin
86          inherited Create;          inherited Create;
87  end;  end;
88    //! 板名取得
89    function TRoundItem.GetBoardTitle : string;
90    begin
91            Result := '';
92            if( Self.FItem <> nil) then begin
93                    if( Self.FItem is TBoard) then begin
94                            Result := TBoard(Self.FItem).Title;
95                    end else if( Self.FItem is TThreadItem) then begin
96                            Result := TThreadItem(Self.FItem).ParentBoard.Title;
97                    end;
98            end;
99    end;
100    //! スレッド名取得
101    function TRoundItem.GetThreadTitle : string;
102    begin
103            Result := '';
104            if( Self.FItem <> nil) then begin
105                    if( Self.FItem is TThreadItem) then begin
106                            Result := TThreadItem(Self.FItem).Title;
107                    end;
108            end;
109    end;
110    //! URL取得
111    function TRoundItem.GetURL      : string;
112    begin
113            Result := '';
114            if( Self.FItem <> nil) then begin
115                    if( Self.FItem is TBoard) then begin
116                            Result := TBoard(Self.FItem).URL;
117                    end else if( Self.FItem is TThreadItem) then begin
118                            Result := TThreadItem(Self.FItem).URL;
119                    end;
120            end;
121    end;
122    //! スレッドのファイ名取得
123    function TRoundItem.GetFileName : string;
124    begin
125            Result := '';
126            if( Self.FItem <> nil) then begin
127                    if( Self.FItem is TThreadItem) then begin
128                            Result := TThreadItem(Self.FItem).FileName;
129                    end;
130            end;
131    end;
132    //! 巡回名取得
133    function TRoundItem.GetRoundName : string;
134    begin
135            Result := '';
136            if( Self.FItem <> nil) then begin
137                    if( Self.FItem is TBoard) then begin
138                            Result := TBoard(Self.FItem).RoundName;
139                    end else if( Self.FItem is TThreadItem) then begin
140                            Result := TThreadItem(Self.FItem).RoundName;
141                    end;
142            end;
143    end;
144    //! 巡回リストコンストラクタ
145  constructor TRoundList.Create;  constructor TRoundList.Create;
146  begin  begin
147          inherited;          inherited;
# Line 97  begin Line 152  begin
152          RoundNameList.Duplicates := dupIgnore;          RoundNameList.Duplicates := dupIgnore;
153      FOldFileRead := false;      FOldFileRead := false;
154  end;  end;
155    //! 巡回リストデストラクタ
156  destructor TRoundList.Destroy;  destructor TRoundList.Destroy;
157  begin  begin
158          RoundNameList.Free;          RoundNameList.Free;
# Line 106  begin Line 161  begin
161          FItemList.Free;          FItemList.Free;
162          //inherited;          //inherited;
163  end;  end;
164    //! 巡回予約追加(板)
165  function TRoundList.Add(Board: TBoard): Integer;  function TRoundList.Add(Board: TBoard): Integer;
166  var  var
167          idx: Integer;          idx: Integer;
# Line 116  begin Line 171  begin
171          idx := Find(Board);          idx := Find(Board);
172          if idx = -1 then begin          if idx = -1 then begin
173                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
174                    Item.FItem := Board;
175  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
176                  Item.RoundType := grtBoard;                  Item.RoundType := grtBoard;
 //      Item.Item := Board;  
         Item.URL := Board.URL;  
                 Item.BoardTitle := Board.Title;  
                 Item.ThreadTitle := '';  
                 Item.FileName := '';  
                 Item.RoundName := Board.RoundName;  
177                  Result := FBoardList.Add(Item);                  Result := FBoardList.Add(Item);
178          end;          end;
179  end;  end;
180    //! 巡回予約追加(スレッド)
181  function TRoundList.Add(ThreadItem: TThreadItem): Integer;  function TRoundList.Add(ThreadItem: TThreadItem): Integer;
182  var  var
183          idx: Integer;          idx: Integer;
# Line 137  begin Line 187  begin
187          idx := Find(ThreadItem);          idx := Find(ThreadItem);
188          if idx = -1 then begin          if idx = -1 then begin
189                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
190                    Item.FItem := ThreadItem;
191  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
192                  Item.RoundType := grtItem;                  Item.RoundType := grtItem;
 //              Item.Item := ThreadItem;  
         Item.URL := Threaditem.URL;  
                 Item.BoardTitle := ThreadItem.ParentBoard.Title;  
                 Item.ThreadTitle := ThreadItem.Title;  
                 Item.FileName := ThreadItem.FileName;  
                 Item.RoundName := ThreadItem.RoundName;  
193                  Result := FItemList.Add(Item);                  Result := FItemList.Add(Item);
194          end;          end;
195  end;  end;
196    //! 巡回予約削除(板)
197  procedure TRoundList.Delete(Board: TBoard);  procedure TRoundList.Delete(Board: TBoard);
198  var  var
199          idx: Integer;          idx: Integer;
 //      Item: TRoundItem;  
200  begin  begin
201          idx := Find(Board);          idx := Find(Board);
202          if idx <> -1 then begin          if idx <> -1 then begin
203                    TBoard(TRoundItem(FBoardList[idx]).FItem).RoundName := '';
204                  TRoundItem(FBoardList[idx]).Free;                  TRoundItem(FBoardList[idx]).Free;
205                  FBoardList.Delete(idx);                  FBoardList.Delete(idx);
206          end;          end;
207  end;  end;
208    //! 巡回予約削除(スレッド)
209  procedure TRoundList.Delete(ThreadItem: TThreadItem);  procedure TRoundList.Delete(ThreadItem: TThreadItem);
210  var  var
211          idx: Integer;          idx: Integer;
 //      Item: TRoundItem;  
212  begin  begin
213          idx := Find(ThreadItem);          idx := Find(ThreadItem);
214          if idx <> -1 then begin          if idx <> -1 then begin
215            TThreadItem(TRoundItem(FItemList[idx]).FItem).RoundName := '';
216                  TRoundItem(FItemList[idx]).Free;                  TRoundItem(FItemList[idx]).Free;
217                  FItemList.Delete(idx);                  FItemList.Delete(idx);
218          end;          end;
219  end;  end;
220    //! 巡回予約消去
221  procedure TRoundList.Clear;  procedure TRoundList.Clear;
222  var  var
223          i: Integer;          i: Integer;
# Line 190  begin Line 235  begin
235          end;          end;
236      FItemList.Capacity := FItemList.Count;      FItemList.Capacity := FItemList.Count;
237  end;  end;
238    //! 巡回予約検索(板)
239  function TRoundList.Find(Board: TBoard): Integer;  function TRoundList.Find(Board: TBoard): Integer;
240  var  var
241          i: Integer;          i: Integer;
# Line 200  begin Line 245  begin
245          for i := 0 to FBoardList.Count - 1 do begin          for i := 0 to FBoardList.Count - 1 do begin
246                  Item := TRoundItem(FBoardList[i]);                  Item := TRoundItem(FBoardList[i]);
247                  if Item.FRoundType <> grtBoard then Continue;                  if Item.FRoundType <> grtBoard then Continue;
248                  if Item.FURL = Board.URL then begin                  if Item.FItem = Board then begin
249                          Result := i;                          Result := i;
250                          Exit;                          Exit;
251                  end;                  end;
252          end;          end;
253  end;  end;
254    //! 巡回予約検索(スレッド)
255  function TRoundList.Find(ThreadItem: TThreadItem): Integer;  function TRoundList.Find(ThreadItem: TThreadItem): Integer;
256  var  var
257          i: Integer;          i: Integer;
# Line 216  begin Line 261  begin
261          for i := 0 to FItemList.Count - 1 do begin          for i := 0 to FItemList.Count - 1 do begin
262                  Item := TRoundItem(FItemList[i]);                  Item := TRoundItem(FItemList[i]);
263                  if Item.FRoundType <> grtItem then Continue;                  if Item.FRoundType <> grtItem then Continue;
264                  if Item.FURL = ThreadItem.URL then begin                  if Item.FItem = ThreadItem then begin
265                          Result := i;                          Result := i;
266                          Exit;                          Exit;
267                  end;                  end;
268          end;          end;
269  end;  end;
270    //! 巡回予約検索(URL+アイテムタイプ)
271  function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer;  function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer;
272  var  var
273          i: Integer;          i: Integer;
# Line 232  begin Line 278  begin
278                  for i := 0 to FItemList.Count - 1 do begin                  for i := 0 to FItemList.Count - 1 do begin
279                          Item := TRoundItem(FItemList[i]);                          Item := TRoundItem(FItemList[i]);
280                          if Item.FRoundType <> RoundType then Continue;                          if Item.FRoundType <> RoundType then Continue;
281                          if Item.FURL = URL then begin                          if Item.URL = URL then begin
282                                  Result := i;                                  Result := i;
283                                  Exit;                                  Exit;
284                          end;                          end;
285                  end;                  end;
286      end else begin          end else begin
287          for i := 0 to FBoardList.Count - 1 do begin                  for i := 0 to FBoardList.Count - 1 do begin
288                          Item := TRoundItem(FBoardList[i]);                          Item := TRoundItem(FBoardList[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;      end;
296  end;  end;
297    //! 巡回予約削除(URL+アイテムタイプ)
298  procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);  procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
299  var  var
300          idx: Integer;          idx: Integer;
# Line 260  begin Line 307  begin
307    
308          if RoundType = grtBoard then begin          if RoundType = grtBoard then begin
309                          Item := TRoundItem(FBoardList[idx]);                          Item := TRoundItem(FBoardList[idx]);
310                            board := TBoard(Item);
311                          Item.Free;                          Item.Free;
312                          FBoardList.Delete(idx);                          FBoardList.Delete(idx);
313                  board := BBSsFindBoardFromURL(URL);                          if board <> nil then begin
314              if board <> nil then begin                                  board.Round := False;
315                  board.Round := False;                                  board.RoundName := '';
316                  board.RoundName := '';                          end;
317              end;                  end else begin
         end else begin  
318                          Item := TRoundItem(FItemList[idx]);                          Item := TRoundItem(FItemList[idx]);
319                            threadItem := TThreadItem(Item.FItem);
320                          Item.Free;                          Item.Free;
321                          FItemList.Delete(idx);                          FItemList.Delete(idx);
322    
             threadItem := BBSsFindThreadFromURL(URL);  
323              if threadItem <> nil then begin              if threadItem <> nil then begin
324                      threadItem.Round := false;                      threadItem.Round := false;
325                  threadItem.RoundName := '';                  threadItem.RoundName := '';
# Line 280  begin Line 327  begin
327          end;          end;
328          end;          end;
329  end;  end;
330    //! 巡回予約数取得
 procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);  
 var  
         idx: Integer;  
         Item: TRoundItem;  
 begin  
         idx := Find(Board);  
         if idx <> -1 then begin  
                 Item := TRoundItem(FBoardList[idx]);  
                 Item.RoundName := RoundName;  
         end;  
 end;  
   
 procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);  
 var  
         idx: Integer;  
         Item: TRoundItem;  
 begin  
         idx := Find(ThreadItem);  
         if idx <> -1 then begin  
                 Item := TRoundItem(FItemList[idx]);  
                 Item.RoundName := RoundName;  
         end;  
 end;  
   
331  function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;  function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;
332  begin  begin
333          Result := 0;          Result := 0;
# Line 313  begin Line 336  begin
336          else if RoundType = grtItem then          else if RoundType = grtItem then
337                  Result := FItemList.Count;                  Result := FItemList.Count;
338  end;  end;
339    //! 巡回予約取得
340  function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;  function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
341  begin  begin
342          Result := nil;          Result := nil;
# Line 325  begin Line 348  begin
348                          Result := TRoundItem(FItemList[Index]);                          Result := TRoundItem(FItemList[Index]);
349          end;          end;
350  end;  end;
351    //! ボード巡回予約ファイル読み込み
352  procedure TRoundList.LoadRoundBoardFile;  procedure TRoundList.LoadRoundBoardFile;
353  var  var
354          i: Integer;          i: Integer;
355          sl: TStringList;          sl: TStringList;
356          FileName: string;          FileName, bFileName: string;
357      errorSl: TStringList;          errorSl: TStringList;
358      errorFileName: string;          errorFileName: string;
359          Item: TRoundItem;          delCount: Integer;
     delCount: Integer;  
360  begin  begin
361          sl := TStringList.Create;          sl := TStringList.Create;
362      errorSl := TStringList.Create;          errorSl := TStringList.Create;
363          errorSl.Duplicates := dupIgnore;          errorSl.Duplicates := dupIgnore;
364          try          try
365                  //ボード巡回ファイル読み込み                  //ボード巡回ファイル読み込み
366                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
367          //エラー行保存ファイル読み込み                  bFileName := GikoSys.GetConfigDir + '~' + ROUND_BOARD_FILENAME;
368          errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME;                  //エラー行保存ファイル読み込み
369                    errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME;
370    
371                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
372                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
373              if FileExists(errorFileName) then begin                          if FileExists(bFileName) then
374                  try                                  DeleteFile(bFileName);
375                            //バックアップ用のファイルを作成する
376                            sl.SaveToFile(bFileName);
377                            if FileExists(errorFileName) then begin
378                                    try
379                          errorSl.LoadFromFile(errorFileName);                          errorSl.LoadFromFile(errorFileName);
380                  except                  except
381                  end;                  end;
382              end;              end;
383              //Item := TRoundItem.Create;              //Item := TRoundItem.Create;
384    
385                if sl.Count = 0 then begin
386                    //エラー落ちするなどしてファイルの内容が空だとエラーになる対策
387                    sl.Add(ROUND_INDEX_VERSION);
388                end;
389    
390              delCount := 0;              delCount := 0;
391              //1行目はバージョン              //1行目はバージョン
392                          if sl[0] = ROUND_INDEX_VERSION then begin                          if sl[0] = ROUND_INDEX_VERSION then begin
393                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
394                                          Item := ParseRoundBoardLine(sl[i - delCount]);                                          if not ParseRoundBoardLine(sl[i - delCount]) then begin
395                      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] );  
396                          sl.Delete(i- delCount);                          sl.Delete(i- delCount);
397                          Inc(delCount);                          Inc(delCount);
398                      end;                      end;
# Line 369  begin Line 400  begin
400              end else begin              end else begin
401                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので
402                                          for i := 1 to sl.Count - 1 do begin                                          for i := 1 to sl.Count - 1 do begin
403                                                  Item := ParseOldRoundBoardLine(sl[i - delCount]);                                                  if not ParseOldRoundBoardLine(sl[i - delCount]) then begin
404                          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] );  
405                                  sl.Delete(i- delCount);                                  sl.Delete(i- delCount);
406                              Inc(delCount);                              Inc(delCount);
407                          end;                          end;
# Line 390  begin Line 417  begin
417                  sl.Free;                  sl.Free;
418          end;          end;
419  end;  end;
420    //! スレッド巡回予約ファイル読み込み
421  procedure TRoundList.LoadRoundThreadFile;  procedure TRoundList.LoadRoundThreadFile;
422  var  var
423          i: Integer;          i: Integer;
 //    j: Integer;  
424          sl: TStringList;          sl: TStringList;
425          FileName: string;          FileName, bFileName: string;
426      errorSl: TStringList;      errorSl: TStringList;
427      errorFileName: string;      errorFileName: string;
         Item: TRoundItem;  
428      delCount: Integer;      delCount: Integer;
 //    boardList : TStringList;  
429  begin  begin
 //    boardList := TStringList.Create;  
 //    boardList.Duplicates := dupIgnore;  
430      errorSl := TStringList.Create;      errorSl := TStringList.Create;
431          errorSl.Duplicates := dupIgnore;          errorSl.Duplicates := dupIgnore;
432          sl := TStringList.Create;          sl := TStringList.Create;
433          try          try
434                  //スレ巡回ファイル読み込み                  //スレ巡回ファイル読み込み
435                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
436          //エラー行保存ファイル読み込み                  bFileName := GikoSys.GetConfigDir + '~' + ROUND_ITEM_FILENAME;
437                    //エラー行保存ファイル読み込み
438          errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME;          errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME;
439                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
440                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
441              if FileExists(errorFileName) then begin                          if FileExists(bFileName) then
442                                    DeleteFile(bFileName);
443                            sl.SaveToFile(bFileName);
444                            if FileExists(errorFileName) then begin
445                  try                  try
446                          errorSl.LoadFromFile(errorFileName);                          errorSl.LoadFromFile(errorFileName);
447                  except                  except
448                  end;                  end;
449              end;              end;
450              //Item := TRoundItem.Create;              //Item := TRoundItem.Create;
451                if sl.Count = 0 then begin
452                    //エラー落ちするなどしてファイルの内容が空だとエラーになる対策
453                    sl.Add(ROUND_INDEX_VERSION);
454                end;
455    
456              delCount := 0;              delCount := 0;
457                          //1行目はバージョン                          //1行目はバージョン
458              if sl[0] = ROUND_INDEX_VERSION then begin              if sl[0] = ROUND_INDEX_VERSION then begin
459                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
460                                          Item := ParseRoundThreadLine(sl[i - delCount]);                                          if not ParseRoundThreadLine(sl[i - delCount]) then begin
461                      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]);  
462                          sl.Delete(i - delCount);                          sl.Delete(i - delCount);
463                          Inc(delCount);                          Inc(delCount);
464                      end;                      end;
465                  end;                  end;
466              end else begin                          end else begin
467                  LoadRoundBoardFile;                                  LoadRoundBoardFile;
468                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
469                                          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  
470                                                  errorSl.Add(sl[i - delCount]);                                                  errorSl.Add(sl[i - delCount]);
471                          sl.Delete(i - delCount);                          sl.Delete(i - delCount);
472                          Inc(delCount);                          Inc(delCount);
473                      end;                      end;
474                                  end;                                  end;
475              end;              end;
 //              j := boardList.Count - 1;  
 //          while j >= 0 do begin  
 //                      GikoSys.ReadSubjectFile( BBSsFindBoardFromURL( boardList[j] ) );  
 //                  boardList.Delete(j);  
 //              Dec(j);  
 //              end;  
476              if errorSl.Count > 0 then              if errorSl.Count > 0 then
477                  errorSl.SaveToFile(errorFileName);                  errorSl.SaveToFile(errorFileName);
478                  end;                  end;
479          finally          finally
480          errorSl.Free;                  errorSl.Free;
481                  sl.Free;                  sl.Free;
 //        boardList.Free;  
482          end;          end;
483  end;  end;
484    //! 巡回予約ファイル保存
485  procedure TRoundList.SaveRoundFile;  procedure TRoundList.SaveRoundFile;
486  var  var
487          i: integer;          i: integer;
# Line 480  begin Line 498  begin
498                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
499                  for i := 0 to FBoardList.Count - 1 do begin                  for i := 0 to FBoardList.Count - 1 do begin
500                          Item := TRoundItem(FBoardList[i]);                          Item := TRoundItem(FBoardList[i]);
501                          s := Item.URL + #1                          try
502                                   + Item.BoardTitle + #1                                  if Item.TmpURL <> '' then begin
503                                   + Item.RoundName;                                          s := Item.TmpURL + #1
504                          sl.Add(s);                                                   + Item.BoardTitle + #1
505                                                     + Item.RoundName;
506                                    end else begin
507                                            s := Item.URL + #1
508                                                     + Item.BoardTitle + #1
509                                                     + Item.RoundName;
510                                    end;
511                                    sl.Add(s);
512                            except
513                            end;
514                  end;                  end;
515                  sl.SaveToFile(FileName);                  sl.SaveToFile(FileName);
516                  sl.Clear;                  sl.Clear;
# Line 491  begin Line 518  begin
518                  sl.Add(ROUND_INDEX_VERSION);                  sl.Add(ROUND_INDEX_VERSION);
519                  for i := 0 to FItemList.Count - 1 do begin                  for i := 0 to FItemList.Count - 1 do begin
520                          Item := TRoundItem(FItemList[i]);                          Item := TRoundItem(FItemList[i]);
521                          s := Item.URL + #1                          try
522                                   + Item.BoardTitle + #1                                  if Item.TmpURL <> '' then begin
523                                   + Item.FileName + #1                                          s := Item.TmpURL + #1
524                                   + Item.ThreadTitle + #1                                           + Item.BoardTitle + #1
525                                   + Item.RoundName;                                           + Item.FileName + #1
526                          sl.Add(s);                                           + Item.ThreadTitle + #1
527                                             + Item.RoundName;
528                                    end else begin
529                                            s := Item.URL + #1
530                                             + Item.BoardTitle + #1
531                                             + Item.FileName + #1
532                                             + Item.ThreadTitle + #1
533                                             + Item.RoundName;
534                                    end;
535                                    sl.Add(s);
536                            except
537                            end;
538                  end;                  end;
539                  sl.SaveToFile(FileName);                  sl.SaveToFile(FileName);
540          finally          finally
541                  sl.Free;                  sl.Free;
542          end;          end;
543  end;  end;
544  function TRoundList.ParseRoundBoardLine(Line: string): TRoundItem;  function TRoundList.ParseRoundBoardLine(Line: string): Boolean;
545  var  var
546          s: string;          s: string;
547            roundname: string;
548            board: TBoard;
549          i: Integer;          i: Integer;
550  begin  begin
551          Result := TRoundItem.Create;          //Result := TRoundItem.Create;
552      Result.ThreadTitle := '';          //Result.ThreadTitle := '';
553      Result.FileName := '';          //Result.FileName := '';
554      Result.RoundType := grtBoard;          //Result.RoundType := grtBoard;
555      for i := 0 to 2 do begin          board := nil;
556          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 2 do begin
557          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
558                  case i of                  try
559                  0:                          case i of
560                  begin                                  0:
561                                  Result.URL := s;                                  begin
562                          end;                                          board := BBSsFindBoardFromURL(s);
563                  1: Result.BoardTitle := s;                                          //Result.URL := s;
564                  2: Result.RoundName := s;                                  end;
565                  end;                                  //1: Result.BoardTitle := s;
566          except                                  2: roundname := s;
567                  Result := nil;                          end;
568              Exit;                  except
569          end;                          Result := false;
570      end;                          Exit;
571                    end;
572            end;
573            if( board <> nil ) then begin
574                    if not board.Round then begin
575                            board.RoundName := roundname;
576                            RoundNameList.Add(roundname);
577                            //RoundNameList.Find(roundname, i);
578                            //board.RoundName := PChar(RoundNameList[i]);
579                            board.Round := true;
580                    end;
581                    Result := true;
582            end else begin
583                    Result := false;
584            end;
585  end;  end;
586    
587  function TRoundList.ParseRoundThreadLine(Line: string): TRoundItem;  function TRoundList.ParseRoundThreadLine(Line: string): Boolean;
588  var  var
589          s: string;          s: string;
590            roundname: string;
591            threadItem: TThreadItem;
592          i: Integer;          i: Integer;
593  //    threadItem: TThreadItem;  //    threadItem: TThreadItem;
594  begin  begin
595      Result := TRoundItem.Create;          //Result := TRoundItem.Create;
596          Result.RoundType := grtItem;          //Result.RoundType := grtItem;
597      for i := 0 to 4 do begin          threadItem := nil;
598          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 4 do begin
599          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
600              case i of                  try
601                  0:                          case i of
602                  begin                                  0:
603                      Result.URL := s;                                  begin
604                      //threadItem := BBSsFindThreadFromURL( s );                                          //Result.URL := s;
605                      //if threadItem <> nil then begin                                          threadItem := BBSsFindThreadFromURL( s );
606                      //    BoardList.Add( threadItem.ParentBoard.URL );                                          //if threadItem <> nil then begin
607                      //end;                                          //    BoardList.Add( threadItem.ParentBoard.URL );
608                  end;                                          //end;
609                  1: Result.BoardTitle := s;                                  end;
610                  2: Result.FileName := s;                                  //1: Result.BoardTitle := s;
611                  3: Result.ThreadTitle := s;                                  //2: Result.FileName := s;
612                  4: Result.RoundName := s;                                  //3: Result.ThreadTitle := s;
613              end;                                  4: roundname := s;
614          except                          end;
615                  Result := nil;                  except
616              Exit;                          Result := false;
617          end;                          Exit;
618      end;                  end;
619            end;
620            if( threadItem <> nil ) then begin
621                    if not threadItem.Round then begin
622                            threadItem.RoundName := roundname;
623                            RoundNameList.Add(roundname);
624                            //RoundNameList.Find(roundname, i);
625                            //threadItem.RoundName := PChar(RoundNameList[i]);
626                            threadItem.Round := True;
627                    end;
628                    Result := true;
629            end else begin
630                    Result := false;
631            end;
632  end;  end;
633    
634  function TRoundList.ParseOldRoundBoardLine(Line: string): TRoundItem;  function TRoundList.ParseOldRoundBoardLine(Line: string): Boolean;
635      var          var
636      i: Integer;          i: Integer;
637          s: string;          s: string;
638      board: TBoard;          roundname: string;
639            board: TBoard;
640  begin  begin
641          Result := TRoundItem.Create;          //Result := TRoundItem.Create;
642      Result.ThreadTitle := '';          //Result.ThreadTitle := '';
643      Result.FileName := '';          //Result.FileName := '';
644      Result.RoundType := grtBoard;          //Result.RoundType := grtBoard;
645      for i := 0 to 2 do begin          board := nil;
646          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 2 do begin
647          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
648                  case i of                  try
649                          0:                          case i of
650                          begin                                  0:
651                          board := BBSs[ 0 ].FindBBSID( s );                                  begin
652                      if board <> nil then begin                                          board := BBSs[ 0 ].FindBBSID( s );
653                                          Result.URL := board.URL;                                          if board = nil then begin
654                      end else begin                                                  raise Exception.Create('この巡回は読み込めないよ(多分外部板)');
655                          raise Exception.Create('この巡回は読み込めないよ(多分外部板)');                                          end;
656                      end;                                  end;
657                          end;                                  //1: Result.FBoardTitle := s;
658                  1: Result.FBoardTitle := s;                                  2: roundname := s;
659                  2: Result.RoundName := s;                          end;
660                  end;                  except
661          except                          Result := false;
662                  Result := nil;                          Exit;
663              Exit;                  end;
664          end;          end;
665      end;          if( board <> nil ) then begin
666                    if not board.Round then begin
667                            board.RoundName := roundname;
668                            RoundNameList.Add(roundname);
669                            //RoundNameList.Find(roundname, i);
670                            //board.RoundName := PChar(RoundNameList[i]);
671                            board.Round := true;
672                    end;
673                    Result := true;
674            end else begin
675                    Result := false;
676            end;
677  end;  end;
678    
679  function TRoundList.ParseOldRoundThreadLine(Line: string): TRoundItem;  function TRoundList.ParseOldRoundThreadLine(Line: string): Boolean;
680      var          var
681      i: Integer;          i: Integer;
682          s: string;          s: string;
683            roundname : string;
684          buf: string;          buf: string;
685      board: TBoard;          board: TBoard;
686  //    threadItem: TThreadItem;          threadItem: TThreadItem;
687      bbsID: string;          bbsID: string;
688  begin  begin
689          Result := TRoundItem.Create;  //      Result := TRoundItem.Create;
690      Result.RoundType := grtItem;  //      Result.RoundType := grtItem;
691      for i := 0 to 4 do begin          threadItem := nil;
692          s := GikoSys.GetTokenIndex(Line, #1, i);          for i := 0 to 4 do begin
693          try                  s := GikoSys.GetTokenIndex(Line, #1, i);
694                  case i of                  try
695                  0: bbsID := s;                          case i of
696                      1: Result.BoardTitle := s;                                  0: bbsID := s;
697                  2:                                  //1: Result.BoardTitle := s;
698                          begin                                  2:
699                          Result.FileName := s;                                  begin
700                          board := BBSs[ 0 ].FindBBSID(bbsID);                                          //Result.FileName := s;
701                      if board <> nil then begin                                          board := BBSs[ 0 ].FindBBSID(bbsID);
702                          buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);                                          if board <> nil then begin
703                                                  Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';                                                  buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
704                      end else begin                                                  buf := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
705                          raise Exception.Create('この巡回は読み込めないよ');                                                  threadItem := BBSsFindThreadFromURL(buf);
706                      end;                                          end else begin
707                      end;                                                  raise Exception.Create('この巡回は読み込めないよ');
708                  3: Result.ThreadTitle := s;                                          end;
709                      4: Result.RoundName := s;                                  end;
710                  end;                                  //3: Result.ThreadTitle := s;
711          except                                  4: roundname := s;
712                  Result := nil;                          end;
713              break;                  except
714          end;                          Result := false;
715      end;                          Exit;
716                    end;
717            end;
718            if( threadItem <> nil ) then begin
719                    if not threadItem.Round then begin
720                            threadItem.RoundName := roundname;
721                            RoundNameList.Add(roundname);
722                            //RoundNameList.Find(roundname, i);
723                            //threadItem.RoundName := PChar(RoundNameList[i]);
724                            threadItem.Round := true;
725                    end;
726                    Result := true;
727            end else begin
728                    Result := false;
729            end;
730    
731  end;  end;
732  procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);  procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
733  var  var
734          i: Integer;          i: Integer;
735      j: Integer;          j: Integer;
736      tempString: string;          tempString: string;
737      tmpURL: string;          tmpURL: string;
738      oldHost: string;          oldHost: string;
739      oldBoardName: string;          oldBoardName: string;
740      newHost: string;          newHost: string;
741      newBoardName: string;          newBoardName: string;
742  begin  begin
743      if oldURLs.Count <> newURLs.Count then          if oldURLs.Count <> newURLs.Count then
744          Exit;                  Exit;
745      //ここから、BoardのURLの変更          //ここから、BoardのURLの変更
746      for j :=0 to oldURLs.Count - 1 do begin          for j :=0 to oldURLs.Count - 1 do begin
747                  for i :=0 to FBoardList.Count - 1 do begin                  for i :=0 to FBoardList.Count - 1 do begin
748                          if TRoundItem(FBoardList[i]).FURL = oldURLs[j] then                          if TRoundItem(FBoardList[i]).URL = oldURLs[j] then
749                  TRoundItem(FBoardList[i]).FURL := newURLs[j];                                  TRoundItem(FBoardList[i]).TmpURL := newURLs[j];
750          end;                  end;
751      end;          end;
752      //ここまで、BoardのURLの変更          //ここまで、BoardのURLの変更
753    
754      //ここから、ThreadのURLの変更          //ここから、ThreadのURLの変更
755      //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。          //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。
756      for i := 0 to oldURLs.Count - 1 do begin          for i := 0 to oldURLs.Count - 1 do begin
757          tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);                  tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
758          oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                  oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
759          oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                  oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
760          tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);                  tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
761          newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                  newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
762          newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                  newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
763    
764          for j := 0 to FItemList.Count - 1 do begin                  for j := 0 to FItemList.Count - 1 do begin
765              tempString := TRoundItem(FItemList[j]).FURL;                          tempString := TRoundItem(FItemList[j]).URL;
766              if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin                          if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
767                  tempString := StringReplace(tempString, oldHost, newHost,[]);                                  tempString := StringReplace(tempString, oldHost, newHost,[]);
768                  TRoundItem(FItemList[j]).FURL := tempString;                                  TRoundItem(FItemList[j]).TmpURL := tempString;
769              end;                          end;
770          end;                  end;
771      end;          end;
772      //ここまで、ThreadのURLの変更          //ここまで、ThreadのURLの変更
773    
774  end;  end;
775    

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

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