@@ -66,7 +66,18 @@ interface
6666
6767 // Console parameter: -U4
6868 // Sort the trackers list by name.
69- tloSort
69+ tloSort,
70+
71+ // Console parameter: -U5
72+ // Append new trackers list BEFORE, the original trackers list inside the torrent file.
73+ // Keep original tracker list unchanged and remove nothing.
74+ tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing,
75+
76+ // Console parameter: -U6
77+ // Append new trackers list AFTER, the original trackers list inside the torrent file.
78+ // Keep original tracker list unchanged and remove nothing.
79+ tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing
80+
7081 );
7182
7283
@@ -86,6 +97,8 @@ TFormTrackerModify = class(TForm)
8697 MenuFileTorrentFolder: TMenuItem;
8798 MenuFileOpenTrackerList: TMenuItem;
8899 MenuHelpReportingIssue: TMenuItem;
100+ MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothing: TMenuItem;
101+ MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothing: TMenuItem;
89102 MenuUpdateTorrentAddBeforeRemoveOriginal: TMenuItem;
90103 MenuUpdateTorrentAddAfterRemoveOriginal: TMenuItem;
91104 MenuUpdateTorrentAddBeforeRemoveNew: TMenuItem;
@@ -144,10 +157,14 @@ TFormTrackerModify = class(TForm)
144157 // Menu trackers
145158 procedure MenuTrackersAllTorrentArePublicPrivateClick (Sender: TObject);
146159 procedure MenuTrackersKeepOrDeleteAllTrackersClick (Sender: TObject);
160+ procedure MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothingClick (Sender: TObject
161+ );
147162
148163 // Menu update torrent
149164 procedure MenuUpdateTorrentAddAfterRemoveNewClick (Sender: TObject);
150165 procedure MenuUpdateTorrentAddAfterRemoveOriginalClick (Sender: TObject);
166+ procedure MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothingClick (Sender: TObject
167+ );
151168 procedure MenuUpdateTorrentAddBeforeRemoveNewClick (Sender: TObject);
152169 procedure MenuUpdateTorrentAddBeforeRemoveOriginalClick (Sender: TObject);
153170 procedure MenuUpdateTorrentSortClick (Sender: TObject);
@@ -239,8 +256,8 @@ implementation
239256 ' udp://tracker.istole.it:80/announce'
240257 // 'udp://open.demonii.com:1337/announce'
241258 );
242- // program name and version
243- FORM_CAPTION = ' Bittorrent tracker editor (1.32 BETA )' ;
259+ // program name and version (http://semver.org/)
260+ FORM_CAPTION = ' Bittorrent tracker editor (1.32.0-RC.2 )' ;
244261 TORRENT_FILES_CONTENTS_FORM_CAPTION =
245262 ' Show all the files inside the torrents. (Use right mouse for popup menu.)' ;
246263
@@ -540,7 +557,7 @@ procedure TFormTrackerModify.UpdateTorrent;
540557 Continue;
541558
542559
543- // tloSort it is already process. But it not tloSort then process it.
560+ // tloSort it is already process. But if not tloSort then process it.
544561 if FTrackerListOrderForUpdatedTorrent <> tloSort then
545562 begin
546563 // Add the new tracker before of after the original trackers inside the torrent.
@@ -612,12 +629,36 @@ procedure TFormTrackerModify.UpdateTorrent;
612629 end
613630 else
614631 begin
615- // Via popup show user how many trackers are inside the torrent after update.
616- PopUpMenuStr := ' All torrent file(s) have now ' + IntToStr(CountTrackers) +
617- ' trackers.' ;
632+
633+ case FTrackerListOrderForUpdatedTorrent of
634+ tloInsertNewBeforeAndKeepNewIntact,
635+ tloInsertNewBeforeAndKeepOriginalIntact,
636+ tloAppendNewAfterAndKeepNewIntact,
637+ tloAppendNewAfterAndKeepOriginalIntact,
638+ tloSort:
639+ begin
640+ // Via popup show user how many trackers are inside the torrent after update.
641+ PopUpMenuStr := ' All torrent file(s) have now ' + IntToStr(CountTrackers) +
642+ ' trackers.' ;
643+ end ;
644+
645+ tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing,
646+ tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing:
647+ begin
648+ // Via popup show user that all the torrent files are updated.
649+ PopUpMenuStr := ' All torrent file(s) are updated.' ;
650+ end ;
651+ else
652+ begin
653+ Assert(True, ' case else: Should never been called. UpdateTorrent' );
654+ end ;
655+ end ;
656+
657+ // Show the MessageBox
618658 Application.MessageBox(
619659 PChar(@PopUpMenuStr[1 ]),
620660 ' ' , MB_ICONINFORMATION + MB_OK);
661+
621662 end ;
622663
623664end ;
@@ -849,6 +890,8 @@ function TFormTrackerModify.DecodeConsoleUpdateParameter(
849890 2 : FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepNewIntact;
850891 3 : FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepOriginalIntact;
851892 4 : FTrackerListOrderForUpdatedTorrent := tloSort;
893+ 5 : FTrackerListOrderForUpdatedTorrent := tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing;
894+ 6 : FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing;
852895 else
853896 begin
854897 // the number is out of range.
@@ -1034,7 +1077,7 @@ procedure TFormTrackerModify.CombineFiveTrackerListToOne(
10341077 TrackerDeselectTempList, TrackerFromInsideOneTorrentFile: TStringList;
10351078
10361079begin
1037- // The new trackers can be added at the begin of end of the list.
1080+ // The new trackers can be added at the begin or at the end of the list.
10381081
10391082 // FTrackerFinalList =
10401083 // (TrackerFromInsideOneTorrentFile
@@ -1152,6 +1195,46 @@ procedure TFormTrackerModify.CombineFiveTrackerListToOne(
11521195 FTrackerFinalList.Sort;
11531196 end ;
11541197
1198+ tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing:
1199+ begin
1200+ // Before
1201+
1202+ // remove duplicate from the list that need to be added.
1203+ RemoveTrackersFromList(TrackerFromInsideOneTorrentFile, FTrackerAddedByUserList);
1204+
1205+ // Must be place as first FTrackerAddedByUserList.
1206+ for TrackerStr in FTrackerAddedByUserList do
1207+ AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1208+
1209+ // original tracker list is second place (Keep original intact)
1210+ for TrackerStr in TrackerFromInsideOneTorrentFile do
1211+ AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1212+
1213+ // Nothing should be removed
1214+ FTrackerManualyDeselectedByUserList.Clear;
1215+ end ;
1216+
1217+
1218+ tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing:
1219+ begin
1220+ // After
1221+
1222+ // remove duplicate from the list that need to be added.
1223+ RemoveTrackersFromList(TrackerFromInsideOneTorrentFile, FTrackerAddedByUserList);
1224+
1225+ // original tracker list is first place (Keep original intact)
1226+ for TrackerStr in TrackerFromInsideOneTorrentFile do
1227+ AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1228+
1229+ // Must be place as second FTrackerAddedByUserList.
1230+ for TrackerStr in FTrackerAddedByUserList do
1231+ AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1232+
1233+ // Nothing should be removed
1234+ FTrackerManualyDeselectedByUserList.Clear;
1235+ end ;
1236+
1237+
11551238 else
11561239 begin
11571240 Assert(True, ' case else: Should never been called. CombineFiveTrackerListToOne' );
@@ -1349,6 +1432,14 @@ procedure TFormTrackerModify.MenuTrackersKeepOrDeleteAllTrackersClick(Sender: TO
13491432 CheckedOnOffAllTrackers(TMenuItem(Sender).Tag = 1 );
13501433end ;
13511434
1435+ procedure TFormTrackerModify.MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothingClick (
1436+ Sender: TObject);
1437+ begin
1438+ // User have selected to add new tracker.
1439+ FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing;
1440+ UpdateTorrent;
1441+ end ;
1442+
13521443procedure TFormTrackerModify.MenuUpdateTorrentAddAfterRemoveNewClick (Sender: TObject);
13531444begin
13541445 // User have selected to add new tracker.
@@ -1364,6 +1455,14 @@ procedure TFormTrackerModify.MenuUpdateTorrentAddAfterRemoveOriginalClick(
13641455 UpdateTorrent;
13651456end ;
13661457
1458+ procedure TFormTrackerModify.MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothingClick (
1459+ Sender: TObject);
1460+ begin
1461+ // User have selected to add new tracker.
1462+ FTrackerListOrderForUpdatedTorrent := tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing;
1463+ UpdateTorrent;
1464+ end ;
1465+
13671466procedure TFormTrackerModify.MenuUpdateTorrentAddBeforeRemoveNewClick (Sender: TObject);
13681467
13691468begin
0 commit comments