Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/Favorite.pas

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

revision 1.3 by yoffy, Sun Sep 21 08:46:17 2003 UTC revision 1.3.2.2 by yoffy, Thu Sep 9 16:20:30 2004 UTC
# Line 4  interface Line 4  interface
4    
5  uses  uses
6          Messages, SysUtils, Classes, Contnrs, ComCtrls, {HttpApp,} YofUtils,          Messages, SysUtils, Classes, Contnrs, ComCtrls, {HttpApp,} YofUtils,
7          GikoSystem{, XMLIntf, XMLDoc}, GikoXMLDoc;          GikoSystem{, XMLIntf, XMLDoc}, GikoXMLDoc, BoardGroup, windows,
8        MojuUtils;
9          {SAX, SAXHelpers, SAXComps, SAXKW;}          {SAX, SAXHelpers, SAXComps, SAXKW;}
10    
11  type  type
# Line 13  type Line 14  type
14    
15          TFavoriteBoardItem = class          TFavoriteBoardItem = class
16          private          private
17                  FBBSID: string;                  FItem                           : TBoard;
18                  FBoardName: string;                  FURL                            : string;
19                    FTitle                  : string;
20                    function        GetItem : TBoard;
21          public          public
22                  property BBSID: string read FBBSID write FBBSID;                  constructor Create( inURL : string; inTitle : string = ''; inItem : TBoard = nil );
23                  property BoardName: string read FBoardName write FBoardName;                  constructor CreateWithItem( inItem : TBoard );
24            destructor Destory;
25                    property Item                           : TBoard        read GetItem write FItem;
26                    property URL                            : string        read FURL write FURL;   // Item が取得できなくても URL は常に保持される
27                    property Title                  : string        read FTitle write FTitle;
28          end;          end;
29    
30          TFavoriteThreadItem = class          TFavoriteThreadItem = class
31          private          private
32                  FBBSID: string;                  FItem                           : TThreadItem;
33                  FThreadID: string;                  FURL                            : string;
34                  FThreadName: string;                  FTitle                  : string;
35                    function        GetItem : TThreadItem;
36          public          public
37                  property BBSID: string read FBBSID write FBBSID;                  constructor Create( inURL : string; inTitle : string = ''; inItem : TThreadItem = nil );
38                  property ThreadID: string read FThreadID write FThreadID;                  constructor CreateWithItem( inItem : TThreadItem );
39                  property ThreadName: string read FThreadName write FThreadName;          destructor Destory;
40                    property Item                           : TThreadItem   read GetItem write FItem;
41                    property URL                            : string                        read FURL write FURL;   // Item が取得できなくても URL は常に保持される
42                    property Title                  : string                        read FTitle write FTitle;
43          end;          end;
44    
45          TFavoriteDM = class(TDataModule)          TFavoriteDM = class(TDataModule)
                 procedure DataModuleCreate(Sender: TObject);  
46                  procedure DataModuleDestroy(Sender: TObject);                  procedure DataModuleDestroy(Sender: TObject);
47          private          private
48                  { Private 宣言 }                  { Private 宣言 }
# Line 49  type Line 59  type
59  //              procedure SAXCharacters(Sender: TObject; const PCh: SAXString);  //              procedure SAXCharacters(Sender: TObject; const PCh: SAXString);
60          public          public
61                  { Public 宣言 }                  { Public 宣言 }
62            procedure Clear;
63                                    function GetFavoriteFilePath() : String;
64                                    function SaveFavoriteFile(FileName: String) : Boolean;
65                  procedure SetFavTreeView(TreeView: TTreeView);                  procedure SetFavTreeView(TreeView: TTreeView);
66                  procedure ReadFavorite;                  procedure ReadFavorite;
67                  procedure WriteFavorite;                  procedure WriteFavorite;
68            procedure URLReplace(oldURLs: TStringList; newURLs: TStringList);
69                  property TreeView: TTreeView read FTreeView;                  property TreeView: TTreeView read FTreeView;
70          end;          end;
71    
# Line 62  const Line 76  const
76    
77  implementation  implementation
78    
79    uses    ExternalBoardManager, ExternalBoardPlugInMain;
80    
81  const  const
82          FAVORITE_ROOT_NAME = 'お気に入り';          FAVORITE_ROOT_NAME = 'お気に入り';
83          FAVORITE_FILE_NAME = 'Favorite.xml';          FAVORITE_FILE_NAME = 'Favorite.xml';
84    
85  {$R *.dfm}  {$R *.dfm}
86    
87  procedure TFavoriteDM.DataModuleCreate(Sender: TObject);  constructor TFavoriteBoardItem.Create(
88            inURL           : string;
89            inTitle : string = '';
90            inItem  : TBoard = nil
91    );
92  begin  begin
93          //FTreeView := TreeView;  
94          //FTreeView := GikoForm.FavoriteTreeView;          inherited Create;
95    
96            URL             := inURL;
97            Title   := inTitle;
98            Item    := inItem;
99    
100  end;  end;
101    
102  procedure TFavoriteDM.DataModuleDestroy(Sender: TObject);  constructor TFavoriteBoardItem.CreateWithItem(
103            inItem  : TBoard
104    );
105    begin
106    
107            Create( inItem.URL, inItem.Title, inItem );
108    
109    end;
110    destructor TFavoriteBoardItem.Destory;
111    begin
112            if FItem <> nil then
113                    FItem.Free;
114            inherited;
115    end;
116    function        TFavoriteBoardItem.GetItem : TBoard;
117  var  var
118          i: Integer;          protocol, host, path, document, port, bookmark : string;
119            BBSID{, BBSKey} : string;
120            tmpURL                          : string;
121    //      category : TCategory;
122    begin
123    
124            if FItem = nil then begin
125                    FItem := BBSsFindBoardFromURL( URL );
126                    if FItem = nil then begin
127                            tmpURL := URL;
128                            GikoSys.ParseURI( tmpURL, protocol, host, path, document, port, bookmark );
129                            if GikoSys.Is2chHost( host ) then begin
130                                    BBSID := GikoSys.URLToID( tmpURL );
131                                    FItem := BBSs[ 0 ].FindBBSID( BBSID );
132                                    if FItem <> nil then
133                                            URL := FItem.URL;
134                            end else if AnsiPos('jbbs.shitaraba.com', host) <> 0 then begin
135                                    // したらばJBBSのhttp://jbbs.shitaraba.com/ → http://jbbs.livedoor.com/ 置換
136                                    URL := CustomStringReplace(URL, 'http://jbbs.shitaraba.com/', 'http://jbbs.livedoor.com/', false);
137                                    FItem := BBSsFindBoardFromURL( URL );
138                                    if FItem <> nil then
139                                            URL := FItem.URL;
140                            end;
141                            {
142                            // ※作っても、追加するカテゴリが無いので激しく保留
143                            FItem                           := GikoSys.GetUnknownBoard( nil, URL );
144                            FItem.Title     := Title;
145                            }
146                    end;
147            end;
148    
149            Result := FItem;
150    
151    end;
152    
153    constructor TFavoriteThreadItem.Create(
154            inURL           : string;
155            inTitle : string = '';
156            inItem  : TThreadItem = nil
157    );
158    begin
159    
160            inherited Create;
161            URL             := inURL;
162    
163            Title   := inTitle;
164            Item    := inItem;
165    
166    end;
167    
168    constructor TFavoriteThreadItem.CreateWithItem(
169            inItem  : TThreadItem
170    );
171  begin  begin
172          for i := 0 to TreeView.Items.Count - 1 do begin  
173                  TObject(TreeView.Items[i].Data).Free;          Create( inItem.URL, inItem.Title, inItem );
174    
175    end;
176    destructor TFavoriteThreadItem.Destory;
177    begin
178            if FItem <> nil then
179            FItem.Free;
180        inherited;
181    end;
182    
183    function        TFavoriteThreadItem.GetItem : TThreadItem;
184    var
185            board                                   : TBoard;
186            boardURL                        : string;
187            browsableURL    : string;
188            protocol, host, path, document, port, bookmark : string;
189            BBSID, BBSKey   : string;
190            tmpURL                          : string;
191    begin
192    
193            Result := nil;
194            if FItem = nil then begin
195                    browsableURL    := GikoSys.GetBrowsableThreadURL( URL );
196                    boardURL                        := GikoSys.GetThreadURL2BoardURL( browsableURL );
197                    board                                   := BBSsFindBoardFromURL( boardURL );
198    
199                    if board = nil then begin
200                            tmpURL := URL;
201                            GikoSys.ParseURI( tmpURL, protocol, host, path, document, port, bookmark );
202                            if GikoSys.Is2chHost( host ) then begin
203                                    GikoSys.Parse2chURL( tmpURL, path, document, BBSID, BBSKey );
204                                    board := BBSs[ 0 ].FindBBSID( BBSID );
205                            end;
206    
207                            if board = nil then begin
208                                    Exit;
209                                    // ※作っても、追加するカテゴリが無いので激しく保留
210                                    //board := GikoSys.GetUnknownBoard( nil, boardURL )
211                            end;
212                    end;
213    
214                    FItem := board.FindThreadFromURL( browsableURL );
215    
216                    if FItem = nil then begin
217                            tmpURL := URL;
218                            GikoSys.ParseURI( tmpURL, protocol, host, path, document, port, bookmark );
219                            if GikoSys.Is2chHost( host ) then begin
220                                    GikoSys.Parse2chURL( tmpURL, path, document, BBSID, BBSKey );
221                                    FItem := BBSs[ 0 ].FindThreadItem( BBSID, BBSKey + '.dat' );
222                                    if FItem <> nil then
223                                            URL := FItem.URL;
224                            end;
225                    end;
226    
227                    if FItem = nil then begin
228                            FItem := TThreadItem.Create( board.BoardPlugIn, browsableURL );
229    
230                            FItem.Title := Title;
231                            board.Add( FItem );
232                    end;
233          end;          end;
234    
235            Result := FItem;
236    
237    end;
238    
239    procedure TFavoriteDM.DataModuleDestroy(Sender: TObject);
240    //var
241    //      i: Integer;
242    begin
243    {    TreeView.Items.BeginUpdate;
244            for i := TreeView.Items.Count - 1 downto 0 do begin
245               //   if TObject(TreeView.Items[i].Data) <> nil then
246           //       TObject(TreeView.Items[i].Data).Free;
247            end;
248        TreeView.Items.Clear;
249        TreeView.Items.EndUpdate;
250    }    //TreeView.Free;
251    end;
252    procedure TFavoriteDM.Clear;
253    var
254            Node    : TTreeNode;
255    begin
256            TreeView.Items.BeginUpdate;
257            Node    := TreeView.Items.GetFirstNode;
258            while Node <> nil do begin
259                    if TObject(Node.Data) <> nil then
260                                    TObject(Node.Data).Free;
261                    Node := Node.GetNext;
262            end;
263                    TreeView.Items.Clear;
264                    TreeView.Items.EndUpdate;
265        //TreeView.Free;
266  end;  end;
267    
268  procedure TFavoriteDM.SetFavTreeView(TreeView: TTreeView);  procedure TFavoriteDM.SetFavTreeView(TreeView: TTreeView);
# Line 108  begin Line 290  begin
290    
291          if FileExists(FileName) then begin          if FileExists(FileName) then begin
292                  try                  try
293                          XMLDoc := LoadXMLDocument(FileName);              XMLDoc := IXMLDocument.Create;
294                            //XMLDoc := LoadXMLDocument(FileName);
295                LoadXMLDocument(FileName, XMLDoc);
296                          XMLNode := XMLDoc.DocumentElement;                          XMLNode := XMLDoc.DocumentElement;
297    
298                          FStack := TStack.Create;                          FStack := TStack.Create;
# Line 132  begin Line 316  begin
316                                  end;                                  end;
317                          finally                          finally
318                                  FStack.Free;                                  FStack.Free;
319                    XMLDoc.Free;
320                          end;                          end;
321                  except                  except
322                  end;                  end;
# Line 168  var Line 353  var
353          FavFolder: TFavoriteFolder;          FavFolder: TFavoriteFolder;
354          FavBoard: TFavoriteBoardItem;          FavBoard: TFavoriteBoardItem;
355          FavThread: TFavoriteThreadItem;          FavThread: TFavoriteThreadItem;
356            board                           : TBoard;
357            threadItem      : TThreadItem;
358  begin  begin
359          if Node.NodeName = 'folder' then begin          if Node.NodeName = 'folder' then begin
360                  ParentNode := FStack.Peek;                  ParentNode := FStack.Peek;
# Line 176  begin Line 363  begin
363                          CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder);                          CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder);
364                          CurrentNode.ImageIndex := 14;                          CurrentNode.ImageIndex := 14;
365                          CurrentNode.SelectedIndex := 14;                          CurrentNode.SelectedIndex := 14;
366                            CurrentNode.Expanded := Node.Attributes[ 'expanded' ] = 'true';
367                          FStack.Push(CurrentNode);                          FStack.Push(CurrentNode);
368                  end;                  end;
369                  for i := 0 to Node.ChildNodes.Count - 1 do begin                  for i := 0 to Node.ChildNodes.Count - 1 do begin
# Line 184  begin Line 372  begin
372                  if FStack.Count <> 0 then                  if FStack.Count <> 0 then
373                          FStack.Pop;                          FStack.Pop;
374          end else if Node.NodeName = 'favitem' then begin          end else if Node.NodeName = 'favitem' then begin
375                  ParentNode := FStack.Peek;                  try
376                  if TObject(ParentNode.Data) is TFavoriteFolder then begin                          ParentNode := FStack.Peek;
377                          if Node.Attributes['favtype'] = 'board' then begin                          if TObject(ParentNode.Data) is TFavoriteFolder then begin
378                                  FavBoard := TFavoriteBoardItem.Create;                                  if Node.Attributes['favtype'] = 'board' then begin
379                                  FavBoard.BBSID := Node.Attributes['bbs'];                                          FavBoard := nil;
380                                  FavBoard.BoardName := Node.Attributes['boardname'];                                          // 旧式のお気に入りとの互換性のため
381                                  CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard);                                          if Length( Node.Attributes[ 'bbs' ] ) > 0 then begin
382                                  CurrentNode.ImageIndex := 15;                                                  board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
383                                  CurrentNode.SelectedIndex := 15;                                                  if board <> nil then
384                          end else if Node.Attributes['favtype'] = 'thread' then begin                                                          FavBoard := TFavoriteBoardItem.Create(
385                                  FavThread := TFavoriteThreadItem.Create;                                                                  board.URL, Node.Attributes[ 'title' ], board );
386                                  FavThread.BBSID := Node.Attributes['bbs'];                                          end else begin
387                                  FavThread.ThreadID := Node.Attributes['thread'];                                                  FavBoard := TFavoriteBoardItem.Create(
388                                  FavThread.ThreadName := Node.Attributes['threadname'];                                                          Node.Attributes[ 'url' ], Node.Attributes[ 'title' ], nil );
389                                  CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread);                                          end;
390                                  CurrentNode.ImageIndex := 16;                                          CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard);
391                                  CurrentNode.SelectedIndex := 16;                                          CurrentNode.ImageIndex := 15;
392                                            CurrentNode.SelectedIndex := 15;
393                                    end else if Node.Attributes['favtype'] = 'thread' then begin
394                                            // 旧式のお気に入りとの互換性のため
395                                            if Length( Node.Attributes[ 'bbs' ] ) > 0 then begin
396                                                    board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
397                                                    if board = nil then
398                                                            Exit;
399    
400                                                    if not board.IsThreadDatRead then
401                                                            GikoSys.ReadSubjectFile( board );
402                                                    threadItem := board.FindThreadFromFileName( Node.Attributes[ 'thread' ] );
403                                                    if threadItem = nil then begin
404                                                            threadItem := TThreadItem.Create(
405                                                                    board.BoardPlugIn,
406                                                                    GikoSys.Get2chBoard2ThreadURL( board, ChangeFileExt( Node.Attributes[ 'thread' ], '' ) ) );
407                                                            threadItem.Title := Node.Attributes[ 'title' ];
408                                                            board.Add( threadItem );
409                                                    end;
410                                                    FavThread := TFavoriteThreadItem.Create(
411                                                            threadItem.URL, Node.Attributes[ 'title' ], threadItem );
412                            threadItem.Free;
413                                            end else begin
414                                                    FavThread := TFavoriteThreadItem.Create(
415                                                            Node.Attributes[ 'url' ], Node.Attributes[ 'title' ], nil );
416                                            end;
417                                            CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread);
418                                            CurrentNode.ImageIndex := 16;
419                                            CurrentNode.SelectedIndex := 16;
420                                    end;
421                          end;                          end;
422                    except
423                            // このアイテムで問題が起きても他のアイテムに影響を与えたくないので
424                  end;                  end;
425          end;          end;
426  end;  end;
# Line 218  var Line 437  var
437          XMLNode: IXMLNode;          XMLNode: IXMLNode;
438  //      FavoNode: IXMLNode;  //      FavoNode: IXMLNode;
439  begin  begin
440          XMLDoc :=  NewXMLDocument;          XMLDoc :=       NewXMLDocument;
441          XMLDoc.Encoding := 'Shift_JIS';          XMLDoc.Encoding := 'Shift_JIS';
442          XMLDoc.StandAlone := 'yes';          XMLDoc.StandAlone := 'yes';
443          XMLNode := XMLDoc.AddChild('favorite');          XMLNode := XMLDoc.AddChild('favorite');
# Line 227  begin Line 446  begin
446          XMLDoc.SaveToFile(FileName);          XMLDoc.SaveToFile(FileName);
447  }  }
448  var  var
449          FileName: string;          FileName, tmpFileName: string;
450          SaveList: TStringList;          SaveList: TStringList;
451    
452  begin  begin
453          FileName := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;          FileName := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;
454            if FileExists(FileName) then begin
455                    tmpFileName := GikoSys.GetConfigDir + '~' + FAVORITE_FILE_NAME;
456                    if FileExists(tmpFileName) then
457                            SysUtils.DeleteFile(tmpFileName); //SysUtils.をつけないとWinAPIと区別できないので
458                    RenameFile(FileName, tmpFileName);
459            end;
460          SaveList := TStringList.Create;          SaveList := TStringList.Create;
461          try          try
462                  SaveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');                  SaveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');
463                  SaveList.Add('<favorite>');                  SaveList.Add('<favorite>');
464                  AddSaveString(TreeView.Items.GetFirstNode, SaveList);                  AddSaveString(TreeView.Items.GetFirstNode.getFirstChild, SaveList);
465                  SaveList.Add('</favorite>');                  SaveList.Add('</favorite>');
466                  SaveList.SaveToFile(FileName);                  SaveList.SaveToFile(FileName);
467          finally          finally
# Line 281  end; Line 507  end;
507    
508  procedure TFavoriteDM.AddSaveString(Node: TTreeNode; SaveList: TStringList);  procedure TFavoriteDM.AddSaveString(Node: TTreeNode; SaveList: TStringList);
509  var  var
         i: Integer;  
510          s: string;          s: string;
511          FavBoard: TFavoriteBoardItem;          FavBoard: TFavoriteBoardItem;
512          FavThread: TFavoriteThreadItem;          FavThread: TFavoriteThreadItem;
513            data : Pointer;
514  begin  begin
515          for i := 0 to Node.Count - 1 do begin          while Node <> nil do begin
516                  if TObject(Node.Item[i].Data) is TFavoriteFolder then begin                  data := Node.Data;
517                          s := Format('<folder title="%s">', [HtmlEncode(Node.Item[i].Text)]);                  if TObject(data) is TFavoriteFolder then begin
518                            if Node.Expanded then
519                                    s := Format('<folder title="%s" expanded="true">', [HtmlEncode(Node.Text)])
520                            else
521                                    s := Format('<folder title="%s" expanded="false">', [HtmlEncode(Node.Text)]);
522                          SaveList.Add(s);                          SaveList.Add(s);
523                          AddSaveString(Node.Item[i], SaveList);                          AddSaveString(Node.getFirstChild, SaveList);
524                          SaveList.Add('</folder>');                          SaveList.Add('</folder>');
525                  end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin                  end else if TObject(data) is TFavoriteBoardItem then begin
526                          FavBoard := TFavoriteBoardItem(Node.Item[i].Data);                          FavBoard := TFavoriteBoardItem(data);
527                          s := Format('<favitem type="2ch" favtype="board" bbs="%s" title="%s" boardname="%s"/>',                          s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>',
528                                                                          [FavBoard.BBSID, HtmlEncode(Node.Item[i].Text), HtmlEncode(FavBoard.BoardName)]);                                                                          [HtmlEncode( FavBoard.URL ), HtmlEncode(Node.Text)]);
529                          SaveList.Add(s);                          SaveList.Add(s);
530                  end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin                  end else if TObject(data) is TFavoriteThreadItem then begin
531                          FavThread := TFavoriteThreadItem(Node.Item[i].Data);                          FavThread := TFavoriteThreadItem(data);
532                          s := Format('<favitem type="2ch" favtype="thread" bbs="%s" thread="%s" title="%s" threadname="%s"/>',                          s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>',
533                                                                          [FavThread.BBSID, FavThread.ThreadID, HtmlEncode(Node.Item[i].Text), HtmlEncode(FavThread.ThreadName)]);                                                                          [HtmlEncode( FavThread.URL ), HtmlEncode(Node.Text)]);
534                          SaveList.Add(s);                          SaveList.Add(s);
535                  end;                  end;
536                    Node := Node.getNextSibling;
537          end;          end;
538  end;  end;
539    
# Line 374  begin Line 605  begin
605  //  //
606  end;  end;
607  }  }
608    function TFavoriteDM.SaveFavoriteFile(FileName: String) : Boolean;
609    var
610            FavoriteFilePath: string;
611                    tempStringList: TStringList;
612    begin
613            WriteFavorite;
614            FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;
615    
616            if FileExists( FavoriteFilePath ) then begin
617                    tempStringList := TStringList.Create;
618                    try
619                            tempStringList.LoadFromFile( FavoriteFilePath );
620                            tempStringList.SaveToFile( FileName );
621                    finally
622                            tempStringList.Free;
623                    end;
624                    Result := true;
625            end else begin
626                    Result := false;
627            end;
628    end;
629    
630    procedure TFavoriteDM.URLReplace(oldURLs: TStringList; newURLs: TStringList);
631    var
632            i                                       : Integer;
633                    tmpURL: string;
634        oldHost: string;
635        oldBoardName: string;
636        newHost: string;
637        newBoardName: string;
638                    tempString: string;
639            favBoard        : TFavoriteBoardItem;
640            favThread       : TFavoriteThreadItem;
641            favorites       : TTreeNodes;
642            Node                    : TTreeNode;
643    begin
644    
645            // 面倒だけどthreadはそれぞれURLをチェックしながらやってかなきゃいけない。
646            favorites := FavoriteDM.FTreeView.Items;
647            for i := 0 to oldURLs.Count - 1 do begin
648                    try
649                            tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
650                            oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
651                            oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
652                            tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
653                            newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
654                            newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
655    
656                            Node := favorites.GetFirstNode.getFirstChild;
657                            while Node <> nil do begin
658                                    try
659                                            if TObject( Node.Data ) is TFavoriteBoardItem then begin
660                                                    favBoard := TFavoriteBoardItem( Node.Data );
661                                                    if favBoard = nil then continue;
662                                                    tempString := favBoard.URL;
663                                                    if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
664                                                            tempString              := StringReplace(tempString, oldHost, newHost,[]);
665                                                            favBoard.URL    := tempString;
666                                                    end;
667                                            end else if TObject( Node.Data ) is TFavoriteThreadItem then begin
668                                                    favThread := TFavoriteThreadItem( Node.Data );
669                                                    if favThread = nil then continue;
670                                                    tempString := favThread.URL;
671                                                    if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
672                                                            tempString              := StringReplace(tempString, oldHost, newHost,[]);
673                                                            favThread.URL   := tempString;
674                                                    end;
675                                            end;
676                                    except
677                                    end;
678                                    Node := Node.GetNext;
679                            end;
680                    except
681                    end;
682            end;
683    
684    end;
685    
686    function TFavoriteDM.GetFavoriteFilePath() : String;
687    begin
688            Result := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;
689    end;
690    
691  end.  end.

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.2.2

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