Skip to content

Commit 49d9d94

Browse files
committed
Added tag constraint function "pluginOption"
1 parent 3a55a42 commit 49d9d94

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed

core/src/com/biglybt/core/download/DownloadManagerState.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
public static final String AT_SWARM_TAGS = "stag"; // list
9595
public static final String AT_MASK_DL_COMP_OPTIONAL = "mdlc"; // Boolean (optional)
9696
public static final String AT_REAL_DM_MAGNET_TIME = "rdmmt"; // long
97-
public static final String AT_PLUGIN_OPTIONS = "pluginoptions"; // Map; enabled=boolean
97+
public static final String AT_PLUGIN_OPTIONS = "pluginoptions"; // Map
98+
public static final String AT_PO_ENABLE_ANNOUNCE = "enableannounce"; // boolean, def=true
9899

99100
public static final String AT_TRANSIENT_FLAGS = "t_flags";
100101
public static final String AT_TRANSIENT_TAG_SORT = "t_tagsort";

core/src/com/biglybt/core/tag/impl/TagPropertyConstraintHandler.java

+56-4
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,7 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
27882788
private static final int FT_COUNT = 61;
27892789
private static final int FT_TRACKER_PEERS = 62;
27902790
private static final int FT_TRACKER_SEEDS = 63;
2791+
private static final int FT_PLUGIN_OPTION = 64;
27912792

27922793
static{
27932794
fn_map.put( "hastag", FT_HAS_TAG );
@@ -2867,6 +2868,8 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
28672868

28682869
fn_map.put( "trackerpeers", FT_TRACKER_PEERS );
28692870
fn_map.put( "trackerseeds", FT_TRACKER_SEEDS );
2871+
2872+
fn_map.put( "pluginoption", FT_PLUGIN_OPTION );
28702873
}
28712874

28722875
private static final int DEP_STATIC = 0;
@@ -3582,6 +3585,12 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
35823585

35833586
break;
35843587
}
3588+
case FT_PLUGIN_OPTION:{
3589+
3590+
params_ok = num_params == 2 && getStringLiteral( params, 0 ) && getStringLiteral( params, 1 );
3591+
3592+
break;
3593+
}
35853594
default:{
35863595

35873596
throw( new RuntimeException( "Unsupported function '" + fn_type + "'" ));
@@ -4622,15 +4631,15 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
46224631
return( -1 );
46234632
}
46244633

4625-
String tracker = getStringParam( params, 0, debug ).toLowerCase();
4634+
String tracker = getStringParam( params, 0, debug ).toLowerCase( Locale.US );
46264635

46274636
String target = null;
46284637

46294638
String app_name = Constants.APP_NAME;
46304639

4631-
if ( tracker.equals( app_name.toLowerCase() + "dht")){
4640+
if ( tracker.equals( app_name.toLowerCase( Locale.US ) + "dht") || tracker.equals( "dht" )){
46324641

4633-
target = app_name;
4642+
target = "dht";
46344643

46354644
}else if ( tracker.equals( "mldht" )){
46364645

@@ -4653,7 +4662,7 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
46534662

46544663
int type = tps.getType();
46554664

4656-
if ( type == TrackerPeerSource.TP_DHT && target == app_name ){
4665+
if ( type == TrackerPeerSource.TP_DHT && target.equals( "dht" )){
46574666

46584667
if ( fn_type == FT_TRACKER_PEERS ){
46594668

@@ -4688,6 +4697,49 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
46884697

46894698
return( -1 );
46904699
}
4700+
case FT_PLUGIN_OPTION:{
4701+
4702+
String plugin_id = getStringParam( params, 0, debug ).toLowerCase();
4703+
4704+
if ( plugin_id.equalsIgnoreCase( "dht" )){
4705+
4706+
plugin_id = "azbpdhdtracker";
4707+
4708+
}else if ( plugin_id.equalsIgnoreCase( "I2P" )){
4709+
4710+
plugin_id = "azneti2phelper";
4711+
}
4712+
4713+
String attr = getStringParam( params, 1, debug ).toLowerCase();
4714+
4715+
if ( !attr.equals( DownloadManagerState.AT_PO_ENABLE_ANNOUNCE )){
4716+
4717+
setError( "Unsupported plugin option attribute type: " + attr );
4718+
4719+
return( null );
4720+
}
4721+
4722+
boolean value = true; // default
4723+
4724+
Map all_opts = dm.getDownloadState().getMapAttribute( DownloadManagerState.AT_PLUGIN_OPTIONS );
4725+
4726+
if ( all_opts != null ){
4727+
4728+
Map opts = (Map)all_opts.get( plugin_id.toLowerCase( Locale.US ));
4729+
4730+
if ( opts != null ){
4731+
4732+
Number e = (Number)opts.get( DownloadManagerState.AT_PO_ENABLE_ANNOUNCE );
4733+
4734+
if ( e != null ){
4735+
4736+
value = e.intValue() != 0;
4737+
}
4738+
}
4739+
}
4740+
4741+
return( value );
4742+
}
46914743
}
46924744

46934745
return( false );

core/src/com/biglybt/pifimpl/local/download/DownloadImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ void announceTrackerResultsToListener(DownloadTrackerListener l) {
17051705

17061706
if ( opts != null ){
17071707

1708-
Number e = (Number)opts.get( "enableannounce" );
1708+
Number e = (Number)opts.get( DownloadManagerState.AT_PO_ENABLE_ANNOUNCE );
17091709

17101710
if ( e != null && e.intValue() == 0 ){
17111711

core/src/com/biglybt/plugin/simpleapi/SimpleAPIPlugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@
886886
opts_map.put( plugin_id, opt_map );
887887
}
888888

889-
opt_map.put( "enableannounce", enable_announce?1:0 );
889+
opt_map.put( DownloadManagerState.AT_PO_ENABLE_ANNOUNCE, enable_announce?1:0 );
890890

891891
dm.getDownloadState().setMapAttribute( DownloadManagerState.AT_PLUGIN_OPTIONS, opts_map );
892892

0 commit comments

Comments
 (0)