Compare commits

..

1 Commits

33 changed files with 10 additions and 2642 deletions

View File

@@ -4,7 +4,6 @@
[![Downloads](https://img.shields.io/github/downloads/DSheirer/sdrtrunk/total)](https://github.com/DSheirer/sdrtrunk/releases) [![Downloads](https://img.shields.io/github/downloads/DSheirer/sdrtrunk/total)](https://github.com/DSheirer/sdrtrunk/releases)
[![License](https://img.shields.io/github/license/DSheirer/sdrtrunk)](LICENSE) [![License](https://img.shields.io/github/license/DSheirer/sdrtrunk)](LICENSE)
[![Discord](https://img.shields.io/badge/chat-on%20Discord-5865F2?logo=discord&logoColor=white)](https://discord.gg/HJQaKYE) [![Discord](https://img.shields.io/badge/chat-on%20Discord-5865F2?logo=discord&logoColor=white)](https://discord.gg/HJQaKYE)
[![support-google_groups-blue](https://img.shields.io/badge/support-google_groups-blue)](https://groups.google.com/g/sdrtrunk)
# sdrtrunk # sdrtrunk
A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR). A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR).

View File

@@ -1,269 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.alias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import javafx.beans.Observable;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.util.Callback;
/**
* Persisted settings for an alias list. Alias lists are otherwise identified only by the list name that each alias
* carries, so settings that belong to the list itself, like tracking a Radio Reference system, are stored here and
* saved in the playlist.
*
* Radio Reference tracking uses two timestamps from the Radio Reference system's last updated value: the last updated
* value seen by the most recent check, and the last updated value that the aliases were synchronized to. When the
* seen value is newer than the synchronized value, the system changed on Radio Reference and the aliases haven't
* been updated yet.
*/
public class AliasListConfiguration
{
public static final int NO_SYSTEM = 0;
private StringProperty mName = new SimpleStringProperty();
private IntegerProperty mRadioReferenceSystemId = new SimpleIntegerProperty(NO_SYSTEM);
private StringProperty mRadioReferenceSystemName = new SimpleStringProperty();
private BooleanProperty mAutoUpdate = new SimpleBooleanProperty();
private LongProperty mRadioReferenceLastUpdated = new SimpleLongProperty();
private LongProperty mSynchronizedLastUpdated = new SimpleLongProperty();
private LongProperty mLastChecked = new SimpleLongProperty();
/**
* Jackson constructor
*/
public AliasListConfiguration()
{
}
/**
* Constructs an instance
* @param name of the alias list
*/
public AliasListConfiguration(String name)
{
setName(name);
}
/**
* Extractor so that observable lists of configurations report changes to the persisted properties.
*/
public static Callback<AliasListConfiguration,Observable[]> extractor()
{
return (AliasListConfiguration c) -> new Observable[] {c.mName, c.mRadioReferenceSystemId,
c.mRadioReferenceSystemName, c.mAutoUpdate, c.mRadioReferenceLastUpdated, c.mSynchronizedLastUpdated,
c.mLastChecked};
}
/**
* Alias list name
*/
@JacksonXmlProperty(isAttribute = true, localName = "name")
public String getName()
{
return mName.get();
}
public void setName(String name)
{
mName.set(name);
}
@JsonIgnore
public StringProperty nameProperty()
{
return mName;
}
/**
* Indicates if this alias list tracks a Radio Reference system.
*/
@JsonIgnore
public boolean isTrackingRadioReferenceSystem()
{
return getRadioReferenceSystemId() > NO_SYSTEM;
}
/**
* Indicates if this alias list tracks the specified Radio Reference system.
*/
public boolean isTracking(int systemId)
{
return systemId > NO_SYSTEM && getRadioReferenceSystemId() == systemId;
}
/**
* Radio Reference system ID tracked by this alias list, or NO_SYSTEM (0).
*/
@JacksonXmlProperty(isAttribute = true, localName = "rr_system_id")
public int getRadioReferenceSystemId()
{
return mRadioReferenceSystemId.get();
}
public void setRadioReferenceSystemId(int systemId)
{
mRadioReferenceSystemId.set(systemId);
}
@JsonIgnore
public IntegerProperty radioReferenceSystemIdProperty()
{
return mRadioReferenceSystemId;
}
/**
* Radio Reference system name, for display.
*/
@JacksonXmlProperty(isAttribute = true, localName = "rr_system_name")
public String getRadioReferenceSystemName()
{
return mRadioReferenceSystemName.get();
}
public void setRadioReferenceSystemName(String name)
{
mRadioReferenceSystemName.set(name);
}
@JsonIgnore
public StringProperty radioReferenceSystemNameProperty()
{
return mRadioReferenceSystemName;
}
/**
* Indicates if talkgroups are automatically added or updated as aliases when the system changes on Radio Reference.
*/
@JacksonXmlProperty(isAttribute = true, localName = "rr_auto_update")
public boolean isAutoUpdate()
{
return mAutoUpdate.get();
}
public void setAutoUpdate(boolean autoUpdate)
{
mAutoUpdate.set(autoUpdate);
}
@JsonIgnore
public BooleanProperty autoUpdateProperty()
{
return mAutoUpdate;
}
/**
* Radio Reference last updated timestamp (ms since epoch) for the system, as seen by the most recent check.
*/
@JacksonXmlProperty(isAttribute = true, localName = "rr_last_updated")
public long getRadioReferenceLastUpdated()
{
return mRadioReferenceLastUpdated.get();
}
public void setRadioReferenceLastUpdated(long timestamp)
{
mRadioReferenceLastUpdated.set(timestamp);
}
@JsonIgnore
public LongProperty radioReferenceLastUpdatedProperty()
{
return mRadioReferenceLastUpdated;
}
/**
* Radio Reference last updated timestamp (ms since epoch) that the aliases were last synchronized to.
*/
@JacksonXmlProperty(isAttribute = true, localName = "rr_synchronized")
public long getSynchronizedLastUpdated()
{
return mSynchronizedLastUpdated.get();
}
public void setSynchronizedLastUpdated(long timestamp)
{
mSynchronizedLastUpdated.set(timestamp);
}
@JsonIgnore
public LongProperty synchronizedLastUpdatedProperty()
{
return mSynchronizedLastUpdated;
}
/**
* Time (ms since epoch) of the most recent successful check of the system on Radio Reference.
*/
@JacksonXmlProperty(isAttribute = true, localName = "rr_last_checked")
public long getLastChecked()
{
return mLastChecked.get();
}
public void setLastChecked(long timestamp)
{
mLastChecked.set(timestamp);
}
@JsonIgnore
public LongProperty lastCheckedProperty()
{
return mLastChecked;
}
/**
* Indicates if the most recent check saw a system change on Radio Reference that the aliases don't include yet.
*/
@JsonIgnore
public boolean isUpdateAvailable()
{
return isTrackingRadioReferenceSystem() && getRadioReferenceLastUpdated() > getSynchronizedLastUpdated();
}
/**
* Starts tracking the Radio Reference system. Clears timestamps so that the next refresh synchronizes.
*/
public void track(int systemId, String systemName)
{
setRadioReferenceSystemId(systemId);
setRadioReferenceSystemName(systemName);
setRadioReferenceLastUpdated(0);
setSynchronizedLastUpdated(0);
setLastChecked(0);
}
/**
* Stops tracking any Radio Reference system.
*/
public void stopTracking()
{
track(NO_SYSTEM, null);
setAutoUpdate(false);
}
}

View File

@@ -46,8 +46,6 @@ public class AliasModel
private ObservableList<Alias> mAliases = FXCollections.observableArrayList(Alias.extractor()); private ObservableList<Alias> mAliases = FXCollections.observableArrayList(Alias.extractor());
private ObservableList<String> mAliasListNames = FXCollections.observableArrayList(); private ObservableList<String> mAliasListNames = FXCollections.observableArrayList();
private Map<String,AliasList> mAliasListMap = new HashMap<>(); private Map<String,AliasList> mAliasListMap = new HashMap<>();
private ObservableList<AliasListConfiguration> mAliasListConfigurations =
FXCollections.observableArrayList(AliasListConfiguration.extractor());
public AliasModel() public AliasModel()
{ {
@@ -65,99 +63,6 @@ public class AliasModel
return mAliasListNames; return mAliasListNames;
} }
/**
* Observable list of persisted alias list configurations. Only alias lists with settings, like Radio Reference
* system tracking, have a configuration.
*/
public ObservableList<AliasListConfiguration> aliasListConfigurations()
{
return mAliasListConfigurations;
}
/**
* Bulk loading of alias list configurations from a playlist. Ignores configurations without a name and
* duplicates of an earlier configuration's name.
*/
public void addAliasListConfigurations(List<AliasListConfiguration> configurations)
{
if(configurations != null)
{
for(AliasListConfiguration configuration: configurations)
{
String name = configuration.getName();
if(name != null && !name.isEmpty() && getAliasListConfiguration(name) == null)
{
mAliasListConfigurations.add(configuration);
addAliasList(name);
}
}
}
}
/**
* Configuration for the named alias list.
* @param aliasListName to find
* @return configuration or null if the alias list doesn't have one
*/
public AliasListConfiguration getAliasListConfiguration(String aliasListName)
{
if(aliasListName != null)
{
for(AliasListConfiguration configuration: mAliasListConfigurations)
{
if(aliasListName.equals(configuration.getName()))
{
return configuration;
}
}
}
return null;
}
/**
* Configuration for the named alias list, created when the alias list doesn't have one.
* @param aliasListName for the configuration, not null or the (No Alias List) name
* @return configuration
*/
public AliasListConfiguration getOrCreateAliasListConfiguration(String aliasListName)
{
if(aliasListName == null || aliasListName.isEmpty() || aliasListName.equals(NO_ALIAS_LIST))
{
throw new IllegalArgumentException("Invalid alias list name [" + aliasListName + "]");
}
AliasListConfiguration configuration = getAliasListConfiguration(aliasListName);
if(configuration == null)
{
configuration = new AliasListConfiguration(aliasListName);
mAliasListConfigurations.add(configuration);
addAliasList(aliasListName);
}
return configuration;
}
/**
* Name of the first alias list that tracks the Radio Reference system.
* @param systemId of the Radio Reference system
* @return alias list name or null
*/
public String getAliasListNameTracking(int systemId)
{
for(AliasListConfiguration configuration: mAliasListConfigurations)
{
if(configuration.isTracking(systemId))
{
return configuration.getName();
}
}
return null;
}
/** /**
* Clears and reloads the list of alias list names from the current set of aliases. * Clears and reloads the list of alias list names from the current set of aliases.
*/ */
@@ -174,15 +79,6 @@ public class AliasModel
mAliasListNames.add(aliasListName); mAliasListNames.add(aliasListName);
} }
} }
//Alias lists with a configuration exist even before they have any aliases
for(AliasListConfiguration configuration: mAliasListConfigurations)
{
if(!mAliasListNames.contains(configuration.getName()))
{
mAliasListNames.add(configuration.getName());
}
}
} }
/** /**
@@ -197,22 +93,7 @@ public class AliasModel
return; return;
} }
mAliases.stream().filter(alias -> oldName.equals(alias.getAliasListName())).forEach(alias -> alias.setAliasListName(newName)); mAliases.stream().filter(alias -> alias.getAliasListName().equals(oldName)).forEach(alias -> alias.setAliasListName(newName));
AliasListConfiguration configuration = getAliasListConfiguration(oldName);
if(configuration != null)
{
//Merging into an existing list keeps that list's configuration
if(getAliasListConfiguration(newName) == null)
{
configuration.setName(newName);
}
else
{
mAliasListConfigurations.remove(configuration);
}
}
} }
/** /**
@@ -228,7 +109,6 @@ public class AliasModel
mAliases.removeIf(alias -> alias.getAliasListName().equals(aliasListName)); mAliases.removeIf(alias -> alias.getAliasListName().equals(aliasListName));
mAliasListMap.remove(aliasListName); mAliasListMap.remove(aliasListName);
mAliasListConfigurations.removeIf(configuration -> aliasListName.equals(configuration.getName()));
} }
/** /**
@@ -266,7 +146,6 @@ public class AliasModel
removeAlias(alias); removeAlias(alias);
} }
mAliasListConfigurations.clear();
mAliasListNames.clear(); mAliasListNames.clear();
} }

View File

@@ -1,455 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.alias;
import com.google.common.annotations.VisibleForTesting;
import io.github.dsheirer.alias.id.AliasID;
import io.github.dsheirer.alias.id.radio.NXDNTypeDRadio;
import io.github.dsheirer.alias.id.radio.P25FullyQualifiedRadio;
import io.github.dsheirer.alias.id.radio.Radio;
import io.github.dsheirer.identifier.alias.TalkerAliasIdentifier;
import io.github.dsheirer.identifier.radio.FullyQualifiedRadioIdentifier;
import io.github.dsheirer.identifier.radio.RadioIdentifier;
import io.github.dsheirer.module.decode.nxdn.identifier.NXDNRadioIdentifier;
import io.github.dsheirer.protocol.Protocol;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import javafx.application.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Automatically adds decoded talker aliases to an alias list as radio aliases, using the talker alias as the alias name,
* and renames a stored radio alias when the radio's talker alias changes.
*
* Talker aliases span up to 4 messages, so a decoded talker alias can be a fragment (the leading characters) of the
* full alias, even when the decoder reports it as complete. To avoid replacing a full alias with a fragment:
* <ul>
* <li>A decoded alias that is the start of the stored alias name is a fragment and never replaces it.</li>
* <li>A decoded alias that starts with the stored alias name is a longer version of a stored fragment and
* replaces it.</li>
* <li>Any other decoded alias that differs from the stored alias name replaces it only after it is decoded
* {@link #CONFIRMATIONS_REQUIRED} times in a row for the radio.</li>
* </ul>
*
* Only aliases whose only identifier is the radio are created or renamed. An alias that combines the radio with other
* identifiers (e.g. several radios or talkgroups) is left alone.
*
* This class is thread safe. Talker aliases are received on decoder threads and the alias model is updated on the
* JavaFX application thread.
*/
public class TalkerAliasAutoAdder implements BiConsumer<RadioIdentifier,TalkerAliasIdentifier>
{
private static final Logger mLog = LoggerFactory.getLogger(TalkerAliasAutoAdder.class);
/**
* Group assigned to aliases created from talker aliases.
*/
public static final String ALIAS_GROUP = "Talker Alias";
/**
* Number of consecutive times a different talker alias must be decoded for a radio before it replaces the stored
* alias name.
*/
public static final int CONFIRMATIONS_REQUIRED = 2;
/**
* Interval for re-checking the stored alias for a talker alias that was already checked, so that a renamed or
* deleted alias is restored without checking the alias list for every decoded talker alias.
*/
private static final long RECHECK_INTERVAL_MS = 30_000;
/**
* Outcome of comparing a decoded talker alias with the stored alias name.
*/
public enum Decision
{
/**
* The stored alias name matches the talker alias.
*/
UNCHANGED,
/**
* The talker alias is a fragment of the stored alias name.
*/
FRAGMENT,
/**
* The talker alias differs from the stored alias name and is waiting for more decodes.
*/
AWAIT_CONFIRMATION,
/**
* The talker alias replaces the stored alias name.
*/
UPDATE
}
private final AliasModel mAliasModel;
private final String mAliasListName;
//Guarded by this
private final Map<String,Candidate> mCandidates = new HashMap<>();
private final Map<String,Checked> mChecked = new HashMap<>();
/**
* Constructs an instance
* @param aliasModel to add aliases to
* @param aliasListName of the alias list to add aliases to
*/
public TalkerAliasAutoAdder(AliasModel aliasModel, String aliasListName)
{
mAliasModel = aliasModel;
mAliasListName = aliasListName;
}
/**
* Name of the alias list that talker aliases are added to.
*/
public String getAliasListName()
{
return mAliasListName;
}
/**
* Processes a talker alias that is assigned to a radio.
* @param radio that the talker alias belongs to
* @param talkerAlias for the radio
*/
@Override
public void accept(RadioIdentifier radio, TalkerAliasIdentifier talkerAlias)
{
if(radio == null || talkerAlias == null || mAliasListName == null || mAliasListName.isEmpty())
{
return;
}
String value = normalize(talkerAlias.getValue());
Radio aliasId = createAliasId(radio);
if(value == null || aliasId == null || !aliasId.isValid())
{
return;
}
String key = getKey(aliasId);
long now = System.currentTimeMillis();
int confirmations;
synchronized(this)
{
Checked checked = mChecked.get(key);
if(checked != null && checked.value().equals(value) && (now - checked.timestamp()) < RECHECK_INTERVAL_MS)
{
return;
}
confirmations = confirm(key, value);
}
runOnFxThread(() -> apply(radio, aliasId, key, value, confirmations));
}
/**
* Counts the consecutive decodes of the talker alias for the radio. A fragment of the talker alias that is
* waiting for confirmation doesn't interrupt the count, because fragments are decoded while the full alias is
* assembled.
* @return number of consecutive decodes of the value, including this one.
*/
private int confirm(String key, String value)
{
Candidate candidate = mCandidates.get(key);
if(candidate != null && candidate.value().equals(value))
{
candidate = new Candidate(value, candidate.count() + 1);
mCandidates.put(key, candidate);
return candidate.count();
}
if(candidate != null && isFragment(value, candidate.value()))
{
return 1;
}
mCandidates.put(key, new Candidate(value, 1));
return 1;
}
/**
* Creates or updates the alias for the radio. Runs on the JavaFX application thread.
*/
private synchronized void apply(RadioIdentifier radio, Radio aliasId, String key, String value, int confirmations)
{
AliasList aliasList = mAliasModel.getAliasList(mAliasListName);
Alias existing = findExactMatch(aliasList.getAliases(radio), aliasId);
if(existing == null)
{
Alias alias = new Alias(value);
alias.setAliasListName(mAliasListName);
alias.setGroup(ALIAS_GROUP);
alias.addAliasID(aliasId);
mAliasModel.addAlias(alias);
markChecked(key, value);
mLog.info("Talker alias [" + value + "] added for radio [" + aliasId + "] to alias list [" +
mAliasListName + "]");
return;
}
if(getIdentityCount(existing) > 1)
{
//The alias also identifies other radios or talkgroups - leave it alone.
markChecked(key, value);
return;
}
String stored = normalize(existing.getName());
switch(decide(stored, value, confirmations))
{
case UPDATE:
existing.setName(value);
markChecked(key, value);
mLog.info("Talker alias for radio [" + aliasId + "] in alias list [" + mAliasListName +
"] changed from [" + stored + "] to [" + value + "]");
break;
case UNCHANGED:
case FRAGMENT:
markChecked(key, value);
break;
case AWAIT_CONFIRMATION:
default:
break;
}
}
private void markChecked(String key, String value)
{
mChecked.put(key, new Checked(value, System.currentTimeMillis()));
mCandidates.remove(key);
}
/**
* Compares the decoded talker alias with the stored alias name.
* @param stored alias name, normalized, or null
* @param decoded talker alias, normalized
* @param confirmations number of consecutive decodes of the talker alias
* @return decision
*/
@VisibleForTesting
static Decision decide(String stored, String decoded, int confirmations)
{
if(stored == null || stored.isEmpty())
{
return Decision.UPDATE;
}
if(stored.equals(decoded))
{
return Decision.UNCHANGED;
}
if(isFragment(decoded, stored))
{
return Decision.FRAGMENT;
}
//A longer version of a stored fragment.
if(isFragment(stored, decoded) && !hasUndecodableCharacters(decoded))
{
return Decision.UPDATE;
}
//A different alias that may be a corrupted or mis-assembled alias. It's replaced only once confirmed, and an
//alias that has undecodable characters (e.g. a partial multi-byte character) never replaces a stored alias.
if(confirmations >= CONFIRMATIONS_REQUIRED && !hasUndecodableCharacters(decoded))
{
return Decision.UPDATE;
}
return Decision.AWAIT_CONFIRMATION;
}
/**
* Indicates if the value is a fragment (the leading characters) of the full value.
*/
@VisibleForTesting
static boolean isFragment(String value, String full)
{
return value != null && full != null && value.length() < full.length() && full.startsWith(value);
}
private static boolean hasUndecodableCharacters(String value)
{
return value.indexOf('<27>') >= 0;
}
/**
* Removes padding, control characters and trailing undecodable characters (e.g. from a partial multi-byte
* character at the end of an alias fragment) from the talker alias.
* @param value to normalize
* @return normalized value or null if the value is empty.
*/
@VisibleForTesting
static String normalize(String value)
{
if(value == null)
{
return null;
}
StringBuilder sb = new StringBuilder(value.length());
for(int i = 0; i < value.length(); i++)
{
char c = value.charAt(i);
if(!Character.isISOControl(c))
{
sb.append(c);
}
}
int end = sb.length();
while(end > 0 && (sb.charAt(end - 1) == '<27>' || Character.isWhitespace(sb.charAt(end - 1))))
{
end--;
}
String normalized = sb.substring(0, end).trim();
return normalized.isEmpty() ? null : normalized;
}
/**
* Creates a radio alias identifier that exactly matches the radio.
* @param radio identifier
* @return alias identifier or null if the radio protocol isn't known.
*/
@VisibleForTesting
static Radio createAliasId(RadioIdentifier radio)
{
if(radio instanceof FullyQualifiedRadioIdentifier fqri && fqri.getProtocol() == Protocol.APCO25)
{
return new P25FullyQualifiedRadio(fqri.getWacn(), fqri.getSystem(), fqri.getRadio());
}
if(radio instanceof NXDNRadioIdentifier nxdn && nxdn.isTypeD())
{
return new NXDNTypeDRadio(nxdn.getTypeDHomeRepeater(), nxdn.getTypeDRadio());
}
Protocol protocol = radio.getProtocol();
if(protocol == null || protocol == Protocol.UNKNOWN || radio.getValue() == null)
{
return null;
}
return new Radio(protocol, radio.getValue());
}
/**
* Finds the alias that has an identifier that exactly matches the radio (i.e. not a radio range).
*/
@VisibleForTesting
static Alias findExactMatch(List<Alias> aliases, Radio aliasId)
{
if(aliases != null)
{
for(Alias alias: aliases)
{
for(AliasID id: alias.getAliasIdentifiers())
{
if(isExactMatch(id, aliasId))
{
return alias;
}
}
}
}
return null;
}
private static boolean isExactMatch(AliasID id, Radio aliasId)
{
if(aliasId instanceof P25FullyQualifiedRadio target)
{
return id instanceof P25FullyQualifiedRadio fqr && fqr.getHashKey().equals(target.getHashKey());
}
return id instanceof Radio radio && !(id instanceof P25FullyQualifiedRadio) &&
radio.getProtocol() == aliasId.getProtocol() && radio.getValue() == aliasId.getValue();
}
/**
* Number of identifiers (e.g. radios, talkgroups) in the alias, excluding audio settings like priority, record and
* streaming.
*/
private static int getIdentityCount(Alias alias)
{
int count = 0;
for(AliasID id: alias.getAliasIdentifiers())
{
if(!id.isAudioIdentifier())
{
count++;
}
}
return count;
}
private static String getKey(Radio aliasId)
{
if(aliasId instanceof P25FullyQualifiedRadio fqr)
{
return aliasId.getProtocol() + ":" + fqr.getHashKey();
}
return aliasId.getProtocol() + ":" + aliasId.getValue();
}
/**
* Runs on the FX thread, or on this thread when the FX toolkit isn't running (headless).
*/
private static void runOnFxThread(Runnable runnable)
{
if(Platform.isFxApplicationThread())
{
runnable.run();
return;
}
try
{
Platform.runLater(runnable);
}
catch(IllegalStateException ise)
{
runnable.run();
}
}
private record Candidate(String value, int count) {}
private record Checked(String value, long timestamp) {}
}

View File

@@ -49,7 +49,6 @@ public class ChannelMetadata implements Listener<IdentifierUpdateNotification>,
{ {
private final static Logger mLog = LoggerFactory.getLogger(ChannelMetadata.class); private final static Logger mLog = LoggerFactory.getLogger(ChannelMetadata.class);
private AliasListConfigurationIdentifier mAliasListConfigurationIdentifier;
private SystemConfigurationIdentifier mSystemConfigurationIdentifier; private SystemConfigurationIdentifier mSystemConfigurationIdentifier;
private SiteConfigurationIdentifier mSiteConfigurationIdentifier; private SiteConfigurationIdentifier mSiteConfigurationIdentifier;
private ChannelNameConfigurationIdentifier mChannelNameConfigurationIdentifier; private ChannelNameConfigurationIdentifier mChannelNameConfigurationIdentifier;
@@ -129,19 +128,6 @@ public class ChannelMetadata implements Listener<IdentifierUpdateNotification>,
return this; return this;
} }
/**
* Alias list configuration identifier
*/
public AliasListConfigurationIdentifier getAliasListConfigurationIdentifier()
{
return mAliasListConfigurationIdentifier;
}
public boolean hasAliasListConfigurationIdentifier()
{
return mAliasListConfigurationIdentifier != null;
}
/** /**
* System configuration identifier * System configuration identifier
*/ */
@@ -337,15 +323,6 @@ public class ChannelMetadata implements Listener<IdentifierUpdateNotification>,
switch(identifier.getForm()) switch(identifier.getForm())
{ {
case ALIAS_LIST: case ALIAS_LIST:
if(identifier instanceof AliasListConfigurationIdentifier && (update.isAdd() || update.isSilentAdd()))
{
mAliasListConfigurationIdentifier = (AliasListConfigurationIdentifier)identifier;
}
else
{
mAliasListConfigurationIdentifier = null;
}
if(update.isAdd()) if(update.isAdd())
{ {
mAliasList = mAliasModel.getAliasList((AliasListConfigurationIdentifier)identifier); mAliasList = mAliasModel.getAliasList((AliasListConfigurationIdentifier)identifier);
@@ -362,7 +339,6 @@ public class ChannelMetadata implements Listener<IdentifierUpdateNotification>,
} }
} }
} }
broadcastUpdate(ChannelMetadataField.CONFIGURATION_ALIAS_LIST);
break; break;
case CHANNEL: case CHANNEL:
if(identifier instanceof ChannelNameConfigurationIdentifier && (update.isAdd() || update.isSilentAdd())) if(identifier instanceof ChannelNameConfigurationIdentifier && (update.isAdd() || update.isSilentAdd()))

View File

@@ -22,7 +22,6 @@ package io.github.dsheirer.channel.metadata;
public enum ChannelMetadataField public enum ChannelMetadataField
{ {
CONFIGURATION_ALIAS_LIST,
CONFIGURATION_CHANNEL, CONFIGURATION_CHANNEL,
CONFIGURATION_FREQUENCY, CONFIGURATION_FREQUENCY,
CONFIGURATION_SITE, CONFIGURATION_SITE,

View File

@@ -18,7 +18,6 @@
*/ */
package io.github.dsheirer.controller.channel; package io.github.dsheirer.controller.channel;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -84,8 +83,6 @@ public class Channel extends Configuration implements Listener<SourceEvent>
private BooleanProperty mProcessing = new SimpleBooleanProperty(); private BooleanProperty mProcessing = new SimpleBooleanProperty();
private BooleanProperty mAutoStart = new SimpleBooleanProperty(); private BooleanProperty mAutoStart = new SimpleBooleanProperty();
//Enabled for new channels. Channels loaded from a playlist without the setting keep it disabled, see fromXml().
private BooleanProperty mAutoAddTalkerAliases = new SimpleBooleanProperty(true);
private IntegerProperty mAutoStartOrder = new SimpleIntegerProperty(); private IntegerProperty mAutoStartOrder = new SimpleIntegerProperty();
private boolean mSelected; private boolean mSelected;
private List<TunerChannel> mTunerChannels = null; private List<TunerChannel> mTunerChannels = null;
@@ -126,19 +123,6 @@ public class Channel extends Configuration implements Listener<SourceEvent>
mChannelID = UNIQUE_ID++; mChannelID = UNIQUE_ID++;
} }
/**
* Creates a channel for deserialization from a playlist. Settings added after a channel was saved take their
* legacy (disabled) value when the playlist doesn't specify them, instead of the default for new channels, so that
* existing channels don't change behavior.
*/
@JsonCreator
private static Channel fromXml()
{
Channel channel = new Channel();
channel.setAutoAddTalkerAliases(false);
return channel;
}
/** /**
* Creates a (new) deep copy of this channel * Creates a (new) deep copy of this channel
*/ */
@@ -150,7 +134,6 @@ public class Channel extends Configuration implements Listener<SourceEvent>
channel.setAliasListName(mAliasListName.get()); channel.setAliasListName(mAliasListName.get());
channel.setAutoStart(mAutoStart.get()); channel.setAutoStart(mAutoStart.get());
channel.setAutoStartOrder(mAutoStartOrder.get()); channel.setAutoStartOrder(mAutoStartOrder.get());
channel.setAutoAddTalkerAliases(mAutoAddTalkerAliases.get());
AuxDecodeConfiguration auxCopy = new AuxDecodeConfiguration(); AuxDecodeConfiguration auxCopy = new AuxDecodeConfiguration();
@@ -526,36 +509,6 @@ public class Channel extends Configuration implements Listener<SourceEvent>
mAutoStart.set(autoStart); mAutoStart.set(autoStart);
} }
/**
* Auto-add talker aliases property
*/
public BooleanProperty autoAddTalkerAliasesProperty()
{
return mAutoAddTalkerAliases;
}
/**
* Indicates if decoded talker aliases are automatically added to the channel's alias list as radio aliases, using
* the talker alias as the alias name.
*
* @return true if talker aliases are automatically added to the alias list
*/
@JacksonXmlProperty(isAttribute = true, localName = "auto_add_talker_aliases")
public boolean isAutoAddTalkerAliases()
{
return mAutoAddTalkerAliases.get();
}
/**
* Sets automatically adding decoded talker aliases to the channel's alias list.
*
* @param autoAdd true to automatically add talker aliases to the alias list
*/
public void setAutoAddTalkerAliases(boolean autoAdd)
{
mAutoAddTalkerAliases.set(autoAdd);
}
/** /**
* Auto-start order. Specifies an optional ordering for channels so that when the application starts up, * Auto-start order. Specifies an optional ordering for channels so that when the application starts up,
* the channels can be started in a user-specified order. * the channels can be started in a user-specified order.

View File

@@ -375,18 +375,14 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li
columns.add(NowPlayingCells.column("channel.name", "Channel Name", null, Pos.CENTER, columns.add(NowPlayingCells.column("channel.name", "Channel Name", null, Pos.CENTER,
row -> toText(row.getChannelMetadata().getChannelNameConfigurationIdentifier()), Row::revisionProperty)); row -> toText(row.getChannelMetadata().getChannelNameConfigurationIdentifier()), Row::revisionProperty));
//Alias list from the channel configuration
columns.add(NowPlayingCells.column("alias.list", "Alias List", null, Pos.CENTER,
row -> toText(row.getChannelMetadata().getAliasListConfigurationIdentifier()), Row::revisionProperty));
//The channel rows are in channel start order, the same as the Swing version of the table //The channel rows are in channel start order, the same as the Swing version of the table
for(TableColumn<Row,?> column: columns) for(TableColumn<Row,?> column: columns)
{ {
column.setSortable(false); column.setSortable(false);
} }
//Column numbers in the Swing version of the table, for its stored column widths. Talker, Tuner, System, Site and Alias //Column numbers in the Swing version of the table, for its stored column widths. Talker, Tuner, System and Site are new
//List are new columns. //columns.
String[] swingColumns = {"status", "decoder", "from", "from.alias", "to", "to.alias", "channel", "frequency", String[] swingColumns = {"status", "decoder", "from", "from.alias", "to", "to.alias", "channel", "frequency",
"channel.name"}; "channel.name"};

View File

@@ -23,7 +23,6 @@ import com.google.common.eventbus.Subscribe;
import io.github.dsheirer.alias.Alias; import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasFactory; import io.github.dsheirer.alias.AliasFactory;
import io.github.dsheirer.alias.AliasList; import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasListConfiguration;
import io.github.dsheirer.alias.AliasModel; import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.eventbus.MyEventBus; import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.gui.control.MaxLengthUnaryOperator; import io.github.dsheirer.gui.control.MaxLengthUnaryOperator;
@@ -34,11 +33,6 @@ import io.github.dsheirer.icon.Icon;
import io.github.dsheirer.playlist.PlaylistManager; import io.github.dsheirer.playlist.PlaylistManager;
import io.github.dsheirer.preference.PreferenceType; import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.service.radioreference.AliasListSynchronizer;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@@ -55,7 +49,6 @@ import javafx.geometry.Pos;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.MenuButton; import javafx.scene.control.MenuButton;
@@ -69,12 +62,10 @@ import javafx.scene.control.TableView;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter; import javafx.scene.control.TextFormatter;
import javafx.scene.control.TextInputDialog; import javafx.scene.control.TextInputDialog;
import javafx.scene.control.Tooltip;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
@@ -115,13 +106,6 @@ public class AliasConfigurationEditor extends SplitPane implements IAliasListRef
private FilteredList<Alias> mAliasFilteredList; private FilteredList<Alias> mAliasFilteredList;
private SortedList<Alias> mAliasSortedList; private SortedList<Alias> mAliasSortedList;
private AliasPredicate mAliasPredicate; private AliasPredicate mAliasPredicate;
private VBox mRadioReferenceBox;
private Label mRadioReferenceSystemLabel;
private Label mRadioReferenceStatusLabel;
private CheckBox mAutoUpdateCheckBox;
private Button mRefreshAliasListButton;
private boolean mRefreshInProgress;
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
/** /**
* Constructs an instance * Constructs an instance
@@ -136,7 +120,7 @@ public class AliasConfigurationEditor extends SplitPane implements IAliasListRef
VBox leftBox = new VBox(); VBox leftBox = new VBox();
VBox.setVgrow(getAliasTableView(), Priority.ALWAYS); VBox.setVgrow(getAliasTableView(), Priority.ALWAYS);
leftBox.getChildren().addAll(getSearchAndListSelectionBox(), getRadioReferenceBox(), getAliasTableView()); leftBox.getChildren().addAll(getSearchAndListSelectionBox(), getAliasTableView());
HBox topBox = new HBox(); HBox topBox = new HBox();
HBox.setHgrow(leftBox, Priority.ALWAYS); HBox.setHgrow(leftBox, Priority.ALWAYS);
@@ -146,191 +130,9 @@ public class AliasConfigurationEditor extends SplitPane implements IAliasListRef
mCurrentEditor = getAliasItemEditor(); mCurrentEditor = getAliasItemEditor();
getItems().addAll(topBox, getAliasItemEditor()); getItems().addAll(topBox, getAliasItemEditor());
//Configuration changes (e.g. a background Radio Reference check) update the Radio Reference controls
mPlaylistManager.getAliasModel().aliasListConfigurations()
.addListener((ListChangeListener<AliasListConfiguration>)c -> updateRadioReferenceControls());
updateRadioReferenceControls();
MyEventBus.getGlobalEventBus().register(this); MyEventBus.getGlobalEventBus().register(this);
} }
/**
* Configuration for the alias list selected in the combo box, or null.
*/
private AliasListConfiguration getSelectedConfiguration()
{
String aliasListName = getAliasListNameComboBox().getSelectionModel().getSelectedItem();
return mPlaylistManager.getAliasModel().getAliasListConfiguration(aliasListName);
}
/**
* Radio Reference system tracking controls for the selected alias list. Disabled when the alias list doesn't
* track a Radio Reference system.
*/
private VBox getRadioReferenceBox()
{
if(mRadioReferenceBox == null)
{
//Two rows so that a long system name doesn't push the controls and status off the editor
Label label = new Label("Radio Reference:");
label.setLabelFor(getRadioReferenceSystemLabel());
label.setMinWidth(Region.USE_PREF_SIZE);
HBox systemRow = new HBox(10, label, getRadioReferenceSystemLabel());
systemRow.setAlignment(Pos.CENTER_LEFT);
HBox controlsRow = new HBox(10, getAutoUpdateCheckBox(), getRefreshAliasListButton(),
getRadioReferenceStatusLabel());
controlsRow.setAlignment(Pos.CENTER_LEFT);
mRadioReferenceBox = new VBox(5, systemRow, controlsRow);
mRadioReferenceBox.setPadding(new Insets(0, 0, 10, 10));
}
return mRadioReferenceBox;
}
private Label getRadioReferenceSystemLabel()
{
if(mRadioReferenceSystemLabel == null)
{
mRadioReferenceSystemLabel = new Label();
}
return mRadioReferenceSystemLabel;
}
private Label getRadioReferenceStatusLabel()
{
if(mRadioReferenceStatusLabel == null)
{
mRadioReferenceStatusLabel = new Label();
}
return mRadioReferenceStatusLabel;
}
private CheckBox getAutoUpdateCheckBox()
{
if(mAutoUpdateCheckBox == null)
{
mAutoUpdateCheckBox = new CheckBox("Auto-Update Talkgroups");
mAutoUpdateCheckBox.setTooltip(new Tooltip("Automatically add or update talkgroup aliases when the " +
"system changes on Radio Reference. Set how often to check in User Preferences > Radio Reference > Alias Lists."));
mAutoUpdateCheckBox.setOnAction(event -> {
AliasListConfiguration configuration = getSelectedConfiguration();
if(configuration != null && configuration.isTrackingRadioReferenceSystem())
{
configuration.setAutoUpdate(getAutoUpdateCheckBox().isSelected());
}
});
}
return mAutoUpdateCheckBox;
}
private Button getRefreshAliasListButton()
{
if(mRefreshAliasListButton == null)
{
mRefreshAliasListButton = new Button("Refresh Now");
mRefreshAliasListButton.setTooltip(new Tooltip("Add or update talkgroup aliases from Radio Reference now"));
mRefreshAliasListButton.setOnAction(event -> {
AliasListConfiguration configuration = getSelectedConfiguration();
if(configuration == null || !configuration.isTrackingRadioReferenceSystem())
{
return;
}
mRefreshInProgress = true;
updateRadioReferenceControls();
getRadioReferenceStatusLabel().setText("Refreshing from Radio Reference...");
mPlaylistManager.getAliasListSynchronizer().refresh(configuration)
.whenComplete((result, throwable) -> Platform.runLater(() -> {
mRefreshInProgress = false;
updateRadioReferenceControls();
if(throwable != null)
{
Alert alert = new Alert(Alert.AlertType.ERROR, "Unable to refresh alias list [" +
configuration.getName() + "] from Radio Reference.\n\n" +
AliasListSynchronizer.getMessage(throwable), ButtonType.OK);
alert.setTitle("Refresh Alias List");
alert.setHeaderText("Radio Reference Refresh Failed");
alert.initOwner(getRefreshAliasListButton().getScene().getWindow());
alert.show();
}
else if(result != null && result.applied() && configuration == getSelectedConfiguration())
{
getRadioReferenceStatusLabel().setText("Added " + result.added() + ", updated " +
result.updated() + " aliases. " + getStatusText(configuration));
}
}));
});
}
return mRefreshAliasListButton;
}
/**
* Updates the Radio Reference controls for the currently selected alias list.
*/
private void updateRadioReferenceControls()
{
AliasListConfiguration configuration = getSelectedConfiguration();
boolean tracking = configuration != null && configuration.isTrackingRadioReferenceSystem();
getAutoUpdateCheckBox().setDisable(!tracking);
getAutoUpdateCheckBox().setSelected(tracking && configuration.isAutoUpdate());
getRefreshAliasListButton().setDisable(!tracking || mRefreshInProgress);
if(tracking)
{
String name = configuration.getRadioReferenceSystemName();
getRadioReferenceSystemLabel().setText((name != null && !name.isEmpty() ? name : "System") + " [" +
configuration.getRadioReferenceSystemId() + "]");
if(!mRefreshInProgress)
{
getRadioReferenceStatusLabel().setText(getStatusText(configuration));
}
}
else
{
getRadioReferenceSystemLabel().setText("Not tracking a system");
getRadioReferenceStatusLabel().setText(null);
}
}
/**
* Status text for a tracked alias list: Radio Reference last updated and synchronized timestamps.
*/
private static String getStatusText(AliasListConfiguration configuration)
{
StringBuilder sb = new StringBuilder();
sb.append("Updated on Radio Reference: ").append(format(configuration.getRadioReferenceLastUpdated()));
sb.append(" Synchronized: ").append(format(configuration.getSynchronizedLastUpdated()));
if(configuration.isUpdateAvailable())
{
sb.append(" (Update Available)");
}
return sb.toString();
}
private static String format(long timestamp)
{
if(timestamp <= 0)
{
return "never";
}
return DATE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()));
}
/** /**
* Redraws the alias color swatches after a change to the application theme. * Redraws the alias color swatches after a change to the application theme.
*/ */
@@ -529,7 +331,6 @@ public class AliasConfigurationEditor extends SplitPane implements IAliasListRef
{ {
getNewAliasButton().setDisable(newValue == null || newValue.contentEquals(AliasModel.NO_ALIAS_LIST)); getNewAliasButton().setDisable(newValue == null || newValue.contentEquals(AliasModel.NO_ALIAS_LIST));
update(); update();
updateRadioReferenceControls();
}); });
if(mAliasListNameComboBox.getItems().size() > 1) if(mAliasListNameComboBox.getItems().size() > 1)

View File

@@ -96,7 +96,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
private TextField mNameField; private TextField mNameField;
private ComboBox<String> mAliasListComboBox; private ComboBox<String> mAliasListComboBox;
private Button mNewAliasListButton; private Button mNewAliasListButton;
private CheckBox mAutoAddTalkerAliasesCheckBox;
private GridPane mTextFieldPane; private GridPane mTextFieldPane;
private Button mSaveButton; private Button mSaveButton;
private Button mResetButton; private Button mResetButton;
@@ -188,7 +187,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
getNameField().setDisable(disable); getNameField().setDisable(disable);
getAliasListComboBox().setDisable(disable); getAliasListComboBox().setDisable(disable);
getNewAliasListButton().setDisable(disable); getNewAliasListButton().setDisable(disable);
getAutoAddTalkerAliasesCheckBox().setDisable(disable);
getAutoStartSwitch().setDisable(disable); getAutoStartSwitch().setDisable(disable);
if(channel != null) if(channel != null)
@@ -212,7 +210,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
getAliasListComboBox().getSelectionModel().select(null); getAliasListComboBox().getSelectionModel().select(null);
} }
getAutoAddTalkerAliasesCheckBox().setSelected(channel.isAutoAddTalkerAliases());
getAutoStartSwitch().selectedProperty().set(channel.isAutoStart()); getAutoStartSwitch().selectedProperty().set(channel.isAutoStart());
getAutoStartOrderSpinner().setDisable(!channel.isAutoStart()); getAutoStartOrderSpinner().setDisable(!channel.isAutoStart());
Integer order = channel.getAutoStartOrder(); Integer order = channel.getAutoStartOrder();
@@ -254,7 +251,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
getSiteField().setText(null); getSiteField().setText(null);
getNameField().setText(null); getNameField().setText(null);
getAliasListComboBox().getSelectionModel().select(null); getAliasListComboBox().getSelectionModel().select(null);
getAutoAddTalkerAliasesCheckBox().setSelected(false);
getAutoStartSwitch().selectedProperty().set(false); getAutoStartSwitch().selectedProperty().set(false);
getAutoStartOrderSpinner().setDisable(true); getAutoStartOrderSpinner().setDisable(true);
getAutoStartOrderSpinner().getValueFactory().setValue(0); getAutoStartOrderSpinner().getValueFactory().setValue(0);
@@ -281,12 +277,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
getItem().setName(" "); getItem().setName(" ");
getItem().setName(getNameField().getText()); getItem().setName(getNameField().getText());
getItem().setAliasListName(getAliasListComboBox().getSelectionModel().getSelectedItem()); getItem().setAliasListName(getAliasListComboBox().getSelectionModel().getSelectedItem());
if(providesTalkerAlias())
{
getItem().setAutoAddTalkerAliases(getAutoAddTalkerAliasesCheckBox().isSelected());
}
getItem().setAutoStart(getAutoStartSwitch().isSelected()); getItem().setAutoStart(getAutoStartSwitch().isSelected());
Integer order = getAutoStartOrderSpinner().getValue(); Integer order = getAutoStartOrderSpinner().getValue();
@@ -608,12 +598,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
GridPane.setConstraints(getNewAliasListButton(), 4, row); GridPane.setConstraints(getNewAliasListButton(), 4, row);
mTextFieldPane.getChildren().add(getNewAliasListButton()); mTextFieldPane.getChildren().add(getNewAliasListButton());
if(providesTalkerAlias())
{
GridPane.setConstraints(getAutoAddTalkerAliasesCheckBox(), 3, ++row, 2, 1);
mTextFieldPane.getChildren().add(getAutoAddTalkerAliasesCheckBox());
}
} }
return mTextFieldPane; return mTextFieldPane;
@@ -676,32 +660,6 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
return mAliasListComboBox; return mAliasListComboBox;
} }
/**
* Indicates if the decoder for this editor produces talker aliases.
*/
private boolean providesTalkerAlias()
{
return getDecoderType() != null && getDecoderType().providesTalkerAlias();
}
/**
* Check box to automatically add decoded talker aliases to the selected alias list.
*/
private CheckBox getAutoAddTalkerAliasesCheckBox()
{
if(mAutoAddTalkerAliasesCheckBox == null)
{
mAutoAddTalkerAliasesCheckBox = new CheckBox("Auto-Add Talker Aliases");
mAutoAddTalkerAliasesCheckBox.setDisable(true);
mAutoAddTalkerAliasesCheckBox.setTooltip(new Tooltip("Adds a radio alias for each talker alias decoded " +
"on this system, named with the talker alias, and renames the radio alias when its talker alias " +
"changes. Applies when the channel is (re)started."));
mAutoAddTalkerAliasesCheckBox.setOnAction(event -> modifiedProperty().set(true));
}
return mAutoAddTalkerAliasesCheckBox;
}
private Button getNewAliasListButton() private Button getNewAliasListButton()
{ {
if(mNewAliasListButton == null) if(mNewAliasListButton == null)

View File

@@ -19,7 +19,6 @@
package io.github.dsheirer.gui.playlist.radioreference; package io.github.dsheirer.gui.playlist.radioreference;
import io.github.dsheirer.alias.AliasListConfiguration;
import io.github.dsheirer.alias.AliasModel; import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.controller.channel.Channel; import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.eventbus.MyEventBus; import io.github.dsheirer.eventbus.MyEventBus;
@@ -46,7 +45,6 @@ import io.github.dsheirer.rrapi.type.Site;
import io.github.dsheirer.rrapi.type.SiteFrequency; import io.github.dsheirer.rrapi.type.SiteFrequency;
import io.github.dsheirer.rrapi.type.System; import io.github.dsheirer.rrapi.type.System;
import io.github.dsheirer.rrapi.type.SystemInformation; import io.github.dsheirer.rrapi.type.SystemInformation;
import io.github.dsheirer.service.radioreference.AliasListSynchronizer;
import io.github.dsheirer.source.config.SourceConfigTuner; import io.github.dsheirer.source.config.SourceConfigTuner;
import io.github.dsheirer.source.config.SourceConfigTunerMultipleFrequency; import io.github.dsheirer.source.config.SourceConfigTunerMultipleFrequency;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@@ -57,7 +55,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Predicate; import java.util.function.Predicate;
import javafx.animation.RotateTransition; import javafx.animation.RotateTransition;
import javafx.application.Platform;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
@@ -78,7 +75,6 @@ import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter; import javafx.scene.control.TextFormatter;
import javafx.scene.control.TextInputDialog; import javafx.scene.control.TextInputDialog;
import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleButton;
import javafx.scene.control.Tooltip;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@@ -124,7 +120,6 @@ public class SiteEditor extends GridPane
private SystemInformation mCurrentSystemInformation; private SystemInformation mCurrentSystemInformation;
private ComboBox mAliasListNameComboBox; private ComboBox mAliasListNameComboBox;
private Button mNewAliasListButton; private Button mNewAliasListButton;
private Button mNewSystemAliasListButton;
private Label mP25ControlLabel; private Label mP25ControlLabel;
private SegmentedButton mP25ControlSegmentedButton; private SegmentedButton mP25ControlSegmentedButton;
private ToggleButton mFdmaControlToggleButton; private ToggleButton mFdmaControlToggleButton;
@@ -227,12 +222,8 @@ public class SiteEditor extends GridPane
GridPane.setHgrow(getAliasListNameComboBox(), Priority.ALWAYS); GridPane.setHgrow(getAliasListNameComboBox(), Priority.ALWAYS);
getChildren().add(getAliasListNameComboBox()); getChildren().add(getAliasListNameComboBox());
HBox aliasListButtonsBox = new HBox(); GridPane.setConstraints(getNewAliasListButton(), 2, ++row);
aliasListButtonsBox.setAlignment(Pos.CENTER_LEFT); getChildren().add(getNewAliasListButton());
aliasListButtonsBox.setSpacing(10);
aliasListButtonsBox.getChildren().addAll(getNewAliasListButton(), getNewSystemAliasListButton());
GridPane.setConstraints(aliasListButtonsBox, 2, ++row);
getChildren().add(aliasListButtonsBox);
HBox createBox = new HBox(); HBox createBox = new HBox();
createBox.setAlignment(Pos.CENTER_LEFT); createBox.setAlignment(Pos.CENTER_LEFT);
@@ -287,18 +278,6 @@ public class SiteEditor extends GridPane
getGoToChannelEditorCheckBox().setDisable(disable || !supported); getGoToChannelEditorCheckBox().setDisable(disable || !supported);
getAliasListNameComboBox().setDisable(disable || !supported); getAliasListNameComboBox().setDisable(disable || !supported);
getNewAliasListButton().setDisable(disable || !supported); getNewAliasListButton().setDisable(disable || !supported);
getNewSystemAliasListButton().setDisable(disable || !supported || system == null);
//Select an alias list that tracks this site's system, if there is one
if(system != null)
{
String trackingAliasList = mPlaylistManager.getAliasModel().getAliasListNameTracking(system.getSystemId());
if(trackingAliasList != null)
{
getAliasListNameComboBox().getSelectionModel().select(trackingAliasList);
}
}
getCreateChannelConfigurationButton().setVisible(false); getCreateChannelConfigurationButton().setVisible(false);
getGoToChannelEditorCheckBox().setVisible(false); getGoToChannelEditorCheckBox().setVisible(false);
@@ -899,97 +878,6 @@ public class SiteEditor extends GridPane
return mNewAliasListButton; return mNewAliasListButton;
} }
/**
* Button to create an alias list that tracks the talkgroups of the current system on Radio Reference.
*/
private Button getNewSystemAliasListButton()
{
if(mNewSystemAliasListButton == null)
{
mNewSystemAliasListButton = new Button("New Alias List For System");
mNewSystemAliasListButton.setTooltip(new Tooltip("Create an alias list with the system's talkgroups " +
"that tracks the system on Radio Reference and automatically adds or updates talkgroup aliases"));
mNewSystemAliasListButton.setDisable(true);
mNewSystemAliasListButton.setOnAction(event -> createSystemAliasList());
}
return mNewSystemAliasListButton;
}
/**
* Prompts for a name and creates an alias list that tracks the current system, then imports the talkgroups.
*/
private void createSystemAliasList()
{
if(mCurrentSystem == null)
{
return;
}
String systemName = mCurrentSystem.getName() != null ? mCurrentSystem.getName().trim() : "";
if(systemName.length() > 25)
{
systemName = systemName.substring(0, 25).trim();
}
TextInputDialog dialog = new TextInputDialog(systemName);
dialog.setTitle("Create New Alias List For System");
dialog.setHeaderText("Create an alias list that tracks the talkgroups for " + mCurrentSystem.getName() +
".\nPlease enter an alias list name (max 25 chars).");
dialog.setContentText("Name:");
dialog.getEditor().setTextFormatter(new TextFormatter<String>(new MaxLengthUnaryOperator(25)));
dialog.initOwner(getNewSystemAliasListButton().getScene().getWindow());
Optional<String> result = dialog.showAndWait();
if(result.isEmpty() || result.get().trim().isEmpty())
{
return;
}
String name = result.get().trim();
AliasModel aliasModel = mPlaylistManager.getAliasModel();
if(name.equals(AliasModel.NO_ALIAS_LIST) || aliasModel.aliasListNames().contains(name))
{
Alert alert = new Alert(Alert.AlertType.ERROR, "An alias list named [" + name +
"] already exists. Please choose another name.", ButtonType.OK);
alert.setTitle("Create New Alias List For System");
alert.setHeaderText("Alias List Exists");
alert.initOwner(getNewSystemAliasListButton().getScene().getWindow());
alert.showAndWait();
return;
}
AliasListConfiguration configuration = aliasModel.getOrCreateAliasListConfiguration(name);
configuration.track(mCurrentSystem.getSystemId(), mCurrentSystem.getName());
configuration.setAutoUpdate(true);
getAliasListNameComboBox().getSelectionModel().select(name);
getNewSystemAliasListButton().setDisable(true);
mPlaylistManager.getAliasListSynchronizer().refresh(configuration)
.whenComplete((syncResult, throwable) -> Platform.runLater(() -> {
getNewSystemAliasListButton().setDisable(mCurrentSystem == null);
if(throwable != null)
{
Alert alert = new Alert(Alert.AlertType.ERROR, "Alias list [" + name + "] was created, but the " +
"talkgroups couldn't be imported from Radio Reference. Use Refresh Now in the Aliases tab " +
"to try again.\n\n" + AliasListSynchronizer.getMessage(throwable), ButtonType.OK);
alert.setTitle("Create New Alias List For System");
alert.setHeaderText("Talkgroup Import Failed");
if(getScene() != null)
{
alert.initOwner(getScene().getWindow());
}
alert.show();
}
}));
}
private Label getProtocolNotSupportedLabel() private Label getProtocolNotSupportedLabel()
{ {
if(mProtocolNotSupportedLabel == null) if(mProtocolNotSupportedLabel == null)

View File

@@ -27,7 +27,6 @@ import io.github.dsheirer.gui.preference.decoder.JmbeLibraryPreferenceEditor;
import io.github.dsheirer.gui.preference.directory.DirectoryPreferenceEditor; import io.github.dsheirer.gui.preference.directory.DirectoryPreferenceEditor;
import io.github.dsheirer.gui.preference.mp3.MP3PreferenceEditor; import io.github.dsheirer.gui.preference.mp3.MP3PreferenceEditor;
import io.github.dsheirer.gui.preference.playback.PlaybackPreferenceEditor; import io.github.dsheirer.gui.preference.playback.PlaybackPreferenceEditor;
import io.github.dsheirer.gui.preference.radioreference.RadioReferencePreferenceEditor;
import io.github.dsheirer.gui.preference.record.RecordPreferenceEditor; import io.github.dsheirer.gui.preference.record.RecordPreferenceEditor;
import io.github.dsheirer.gui.preference.tuner.TunerPreferenceEditor; import io.github.dsheirer.gui.preference.tuner.TunerPreferenceEditor;
import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.preference.UserPreferences;
@@ -60,8 +59,6 @@ public class PreferenceEditorFactory
return new DirectoryPreferenceEditor(userPreferences); return new DirectoryPreferenceEditor(userPreferences);
case JMBE_LIBRARY: case JMBE_LIBRARY:
return new JmbeLibraryPreferenceEditor(userPreferences); return new JmbeLibraryPreferenceEditor(userPreferences);
case RADIO_REFERENCE_ALIAS_LISTS:
return new RadioReferencePreferenceEditor(userPreferences);
case SOURCE_TUNERS: case SOURCE_TUNERS:
return new TunerPreferenceEditor(userPreferences); return new TunerPreferenceEditor(userPreferences);
case TALKGROUP_FORMAT: case TALKGROUP_FORMAT:

View File

@@ -29,7 +29,6 @@ public enum PreferenceEditorType
CHANNEL_EVENT("Channel Events"), CHANNEL_EVENT("Channel Events"),
DIRECTORY("Directories"), DIRECTORY("Directories"),
JMBE_LIBRARY("JMBE Audio Library"), JMBE_LIBRARY("JMBE Audio Library"),
RADIO_REFERENCE_ALIAS_LISTS("Alias Lists"),
AUDIO_MP3("MP3"), AUDIO_MP3("MP3"),
AUDIO_RECORD("Record"), AUDIO_RECORD("Record"),
AUDIO_OUTPUT("Playback/Tones"), AUDIO_OUTPUT("Playback/Tones"),

View File

@@ -200,11 +200,6 @@ public class UserPreferencesEditor extends BorderPane
treeRoot.getChildren().add(storageItem); treeRoot.getChildren().add(storageItem);
storageItem.setExpanded(true); storageItem.setExpanded(true);
TreeItem<String> radioReferenceItem = new TreeItem<>("Radio Reference");
radioReferenceItem.getChildren().add(new TreeItem(PreferenceEditorType.RADIO_REFERENCE_ALIAS_LISTS));
treeRoot.getChildren().add(radioReferenceItem);
radioReferenceItem.setExpanded(true);
TreeItem<String> sourceItem = new TreeItem<>("Source"); TreeItem<String> sourceItem = new TreeItem<>("Source");
sourceItem.getChildren().add(new TreeItem(PreferenceEditorType.SOURCE_TUNERS)); sourceItem.getChildren().add(new TreeItem(PreferenceEditorType.SOURCE_TUNERS));
treeRoot.getChildren().add(sourceItem); treeRoot.getChildren().add(sourceItem);

View File

@@ -1,80 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.gui.preference.radioreference;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.preference.radioreference.AliasListUpdateInterval;
import io.github.dsheirer.preference.radioreference.RadioReferencePreference;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
/**
* Preference settings for alias lists that track a Radio Reference system.
*/
public class RadioReferencePreferenceEditor extends VBox
{
private RadioReferencePreference mRadioReferencePreference;
private ComboBox<AliasListUpdateInterval> mUpdateIntervalComboBox;
public RadioReferencePreferenceEditor(UserPreferences userPreferences)
{
mRadioReferencePreference = userPreferences.getRadioReferencePreference();
setPadding(new Insets(10, 10, 10, 10));
setSpacing(10);
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
gridPane.setVgap(10);
Label intervalLabel = new Label("Check Tracked Systems For Talkgroup Changes:");
intervalLabel.setLabelFor(getUpdateIntervalComboBox());
GridPane.setHalignment(intervalLabel, HPos.RIGHT);
gridPane.add(intervalLabel, 0, 0);
gridPane.add(getUpdateIntervalComboBox(), 1, 0);
Label help = new Label("Alias lists that track a Radio Reference system check the system on this schedule " +
"while sdrtrunk is running and a Radio Reference login is stored. Alias lists with Auto-Update enabled " +
"add or update talkgroup aliases when the system changed. Use Refresh Now in the playlist editor's " +
"Aliases tab to update an alias list immediately.");
help.setWrapText(true);
help.setMaxWidth(500);
getChildren().addAll(gridPane, help);
}
private ComboBox<AliasListUpdateInterval> getUpdateIntervalComboBox()
{
if(mUpdateIntervalComboBox == null)
{
mUpdateIntervalComboBox = new ComboBox<>();
mUpdateIntervalComboBox.getItems().addAll(AliasListUpdateInterval.values());
mUpdateIntervalComboBox.getSelectionModel().select(mRadioReferencePreference.getAliasListUpdateInterval());
mUpdateIntervalComboBox.setOnAction(event -> mRadioReferencePreference
.setAliasListUpdateInterval(mUpdateIntervalComboBox.getSelectionModel().getSelectedItem()));
}
return mUpdateIntervalComboBox;
}
}

View File

@@ -502,10 +502,10 @@ public class ThemeManager
.append("-fx-background-color: ").append(accent).append(";") .append("-fx-background-color: ").append(accent).append(";")
.append("}"); .append("}");
//URL-encode the body; java.net.URLEncoder is fine for our restricted charset. //Base64-encode the body. Don't use URLEncoder: it is form encoding and turns spaces
String encoded = java.net.URLEncoder.encode(css.toString(), //into '+', which a data URL doesn't decode, so JavaFX silently drops the whole sheet.
java.nio.charset.StandardCharsets.UTF_8); return "data:text/css;base64," + java.util.Base64.getEncoder().encodeToString(
return "data:text/css," + encoded; css.toString().getBytes(java.nio.charset.StandardCharsets.UTF_8));
} }
catch(Throwable t) catch(Throwable t)
{ {

View File

@@ -31,7 +31,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
/** /**
* Talker alias cache manager. Collects observed talker aliases and inserts them into an identifier collection when * Talker alias cache manager. Collects observed talker aliases and inserts them into an identifier collection when
@@ -42,7 +41,6 @@ import java.util.function.BiConsumer;
public class TalkerAliasManager public class TalkerAliasManager
{ {
private Map<Integer,TalkerAliasIdentifier> mAliasMap = new ConcurrentHashMap<>(); private Map<Integer,TalkerAliasIdentifier> mAliasMap = new ConcurrentHashMap<>();
private volatile BiConsumer<RadioIdentifier,TalkerAliasIdentifier> mTalkerAliasListener;
/** /**
* Constructs an instance * Constructs an instance
@@ -51,16 +49,6 @@ public class TalkerAliasManager
{ {
} }
/**
* Sets an optional listener to receive each talker alias that is assigned to a radio, e.g. to automatically add
* talker aliases to an alias list. The listener is invoked on the calling decoder thread.
* @param listener to receive radio and talker alias updates, or null to clear the listener.
*/
public void setTalkerAliasListener(BiConsumer<RadioIdentifier,TalkerAliasIdentifier> listener)
{
mTalkerAliasListener = listener;
}
/** /**
* Updates the alias for the radio identifier * Updates the alias for the radio identifier
* *
@@ -72,13 +60,6 @@ public class TalkerAliasManager
if(identifier.getRole() == Role.FROM) if(identifier.getRole() == Role.FROM)
{ {
mAliasMap.put(identifier.getValue(), alias); mAliasMap.put(identifier.getValue(), alias);
BiConsumer<RadioIdentifier,TalkerAliasIdentifier> listener = mTalkerAliasListener;
if(listener != null && alias != null)
{
listener.accept(identifier, alias);
}
} }
} }

View File

@@ -20,7 +20,6 @@ package io.github.dsheirer.module.decode;
import io.github.dsheirer.alias.AliasList; import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel; import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.alias.TalkerAliasAutoAdder;
import io.github.dsheirer.alias.action.AliasActionManager; import io.github.dsheirer.alias.action.AliasActionManager;
import io.github.dsheirer.audio.*; import io.github.dsheirer.audio.*;
import io.github.dsheirer.audio.codec.mbe.JmbeAudioModule; import io.github.dsheirer.audio.codec.mbe.JmbeAudioModule;
@@ -211,37 +210,9 @@ public class DecoderFactory
throw new IllegalArgumentException("Unknown decoder type [" + decodeConfig.getDecoderType().toString() + "]"); throw new IllegalArgumentException("Unknown decoder type [" + decodeConfig.getDecoderType().toString() + "]");
} }
configureTalkerAliasAutoAdd(channel, modules, aliasModel);
return modules; return modules;
} }
/**
* Configures the traffic channel manager of a standard (control) channel to automatically add talker aliases to
* the channel's alias list, when the channel is configured for it. Traffic channels share the talker alias manager
* of their control channel, so they use the control channel's setting.
* @param channel configuration
* @param modules for the channel
* @param aliasModel to add aliases to
*/
private static void configureTalkerAliasAutoAdd(Channel channel, List<Module> modules, AliasModel aliasModel)
{
if(channel.isStandardChannel() && channel.isAutoAddTalkerAliases() &&
channel.getDecodeConfiguration().getDecoderType().providesTalkerAlias() &&
channel.getAliasListName() != null && !channel.getAliasListName().isEmpty())
{
TalkerAliasAutoAdder autoAdder = new TalkerAliasAutoAdder(aliasModel, channel.getAliasListName());
for(Module module: modules)
{
if(module instanceof TrafficChannelManager tcm && tcm.getTalkerAliasManager() != null)
{
tcm.getTalkerAliasManager().setTalkerAliasListener(autoAdder);
}
}
}
}
/** /**
* Creates decoder modules for APCO-25 Phase 2 decoder * Creates decoder modules for APCO-25 Phase 2 decoder
* @param channel configuration * @param channel configuration

View File

@@ -78,11 +78,6 @@ public enum DecoderType
*/ */
public static final EnumSet<DecoderType> MBE_AUDIO_CODEC_DECODERS = EnumSet.of(DMR, NXDN, P25_PHASE1, P25_PHASE2); public static final EnumSet<DecoderType> MBE_AUDIO_CODEC_DECODERS = EnumSet.of(DMR, NXDN, P25_PHASE1, P25_PHASE2);
/**
* Decoders that produce talker aliases
*/
public static final EnumSet<DecoderType> TALKER_ALIAS_DECODERS = EnumSet.of(DMR, NXDN, P25_PHASE1, P25_PHASE2);
public Protocol getProtocol() public Protocol getProtocol()
{ {
return mProtocol; return mProtocol;
@@ -119,12 +114,4 @@ public enum DecoderType
{ {
return MBE_AUDIO_CODEC_DECODERS.contains(this); return MBE_AUDIO_CODEC_DECODERS.contains(this);
} }
/**
* Indicates if the decoder type produces talker aliases
*/
public boolean providesTalkerAlias()
{
return TALKER_ALIAS_DECODERS.contains(this);
}
} }

View File

@@ -135,7 +135,6 @@ public class DMRTrafficChannelManager extends TrafficChannelManager implements I
/** /**
* Talker alias manager * Talker alias manager
*/ */
@Override
public TalkerAliasManager getTalkerAliasManager() public TalkerAliasManager getTalkerAliasManager()
{ {
return mTalkerAliasManager; return mTalkerAliasManager;

View File

@@ -148,7 +148,6 @@ public class NXDNTrafficChannelManager extends TrafficChannelManager implements
/** /**
* Talker alias manager * Talker alias manager
*/ */
@Override
public TalkerAliasManager getTalkerAliasManager() public TalkerAliasManager getTalkerAliasManager()
{ {
return mTalkerAliasManager; return mTalkerAliasManager;

View File

@@ -165,7 +165,6 @@ public class P25TrafficChannelManager extends TrafficChannelManager implements I
* Talker alias manager * Talker alias manager
* @return manager * @return manager
*/ */
@Override
public TalkerAliasManager getTalkerAliasManager() public TalkerAliasManager getTalkerAliasManager()
{ {
return mTalkerAliasManager; return mTalkerAliasManager;

View File

@@ -20,7 +20,6 @@
package io.github.dsheirer.module.decode.traffic; package io.github.dsheirer.module.decode.traffic;
import io.github.dsheirer.controller.channel.Channel; import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.identifier.alias.TalkerAliasManager;
import io.github.dsheirer.module.Module; import io.github.dsheirer.module.Module;
/** /**
@@ -37,15 +36,6 @@ public abstract class TrafficChannelManager extends Module
{ {
} }
/**
* Talker alias manager shared by the control and traffic channels of the system.
* @return talker alias manager, or null if the protocol doesn't have talker aliases.
*/
public TalkerAliasManager getTalkerAliasManager()
{
return null;
}
/** /**
* Current control frequency * Current control frequency
* @return frequency in hertz * @return frequency in hertz

View File

@@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.github.dsheirer.alias.Alias; import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasListConfiguration;
import io.github.dsheirer.alias.AliasModel; import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.BroadcastModel; import io.github.dsheirer.audio.broadcast.BroadcastModel;
import io.github.dsheirer.controller.channel.Channel.ChannelType; import io.github.dsheirer.controller.channel.Channel.ChannelType;
@@ -40,7 +39,6 @@ import io.github.dsheirer.module.log.EventLogManager;
import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.preference.playlist.PlaylistPreference; import io.github.dsheirer.preference.playlist.PlaylistPreference;
import io.github.dsheirer.sample.Listener; import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.service.radioreference.AliasListSynchronizer;
import io.github.dsheirer.service.radioreference.RadioReference; import io.github.dsheirer.service.radioreference.RadioReference;
import io.github.dsheirer.source.tuner.manager.TunerManager; import io.github.dsheirer.source.tuner.manager.TunerManager;
import io.github.dsheirer.util.ThreadPool; import io.github.dsheirer.util.ThreadPool;
@@ -78,7 +76,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
private TunerManager mTunerManager; private TunerManager mTunerManager;
private UserPreferences mUserPreferences; private UserPreferences mUserPreferences;
private RadioReference mRadioReference; private RadioReference mRadioReference;
private AliasListSynchronizer mAliasListSynchronizer;
private AtomicBoolean mPlaylistSavePending = new AtomicBoolean(); private AtomicBoolean mPlaylistSavePending = new AtomicBoolean();
private ScheduledFuture<?> mPlaylistSaveFuture; private ScheduledFuture<?> mPlaylistSaveFuture;
private boolean mPlaylistLoading = false; private boolean mPlaylistLoading = false;
@@ -106,7 +103,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
mBroadcastModel = new BroadcastModel(mAliasModel, mIconModel, userPreferences); mBroadcastModel = new BroadcastModel(mAliasModel, mIconModel, userPreferences);
mRadioReference = new RadioReference(mUserPreferences); mRadioReference = new RadioReference(mUserPreferences);
mAliasListSynchronizer = new AliasListSynchronizer(mAliasModel, mRadioReference, mUserPreferences);
mChannelModel = new ChannelModel(mAliasModel); mChannelModel = new ChannelModel(mAliasModel);
mChannelProcessingManager = new ChannelProcessingManager(mChannelMapModel, eventLogManager, mTunerManager, mChannelProcessingManager = new ChannelProcessingManager(mChannelMapModel, eventLogManager, mTunerManager,
@@ -124,8 +120,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
mChannelModel.addListener(this); mChannelModel.addListener(this);
mAliasModel.aliasList().addListener((ListChangeListener<Alias>)c -> schedulePlaylistSave()); mAliasModel.aliasList().addListener((ListChangeListener<Alias>)c -> schedulePlaylistSave());
mAliasModel.aliasListConfigurations()
.addListener((ListChangeListener<AliasListConfiguration>)c -> schedulePlaylistSave());
mChannelMapModel.getChannelMaps().addListener((ListChangeListener<ChannelMap>)c -> schedulePlaylistSave()); mChannelMapModel.getChannelMaps().addListener((ListChangeListener<ChannelMap>)c -> schedulePlaylistSave());
@@ -254,14 +248,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
return mBroadcastModel; return mBroadcastModel;
} }
/**
* Synchronizer for alias lists that track a Radio Reference system.
*/
public AliasListSynchronizer getAliasListSynchronizer()
{
return mAliasListSynchronizer;
}
/** /**
* Channel Map model managed by this playlist manager * Channel Map model managed by this playlist manager
*/ */
@@ -278,7 +264,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
{ {
PlaylistV2 playlist = load(); PlaylistV2 playlist = load();
transferPlaylistToModels(playlist); transferPlaylistToModels(playlist);
mAliasListSynchronizer.start();
} }
/** /**
@@ -416,7 +401,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
mPlaylistLoading = true; mPlaylistLoading = true;
mAliasModel.addAliases(playlist.getAliases()); mAliasModel.addAliases(playlist.getAliases());
mAliasModel.addAliasListConfigurations(playlist.getAliasListConfigurations());
mBroadcastModel.addBroadcastConfigurations(playlist.getBroadcastConfigurations()); mBroadcastModel.addBroadcastConfigurations(playlist.getBroadcastConfigurations());
@@ -461,7 +445,6 @@ public class PlaylistManager implements Listener<ChannelEvent>
PlaylistV2 playlist = new PlaylistV2(); PlaylistV2 playlist = new PlaylistV2();
playlist.setAliases(new ArrayList(mAliasModel.getAliases())); playlist.setAliases(new ArrayList(mAliasModel.getAliases()));
playlist.setAliasListConfigurations(new ArrayList<>(mAliasModel.aliasListConfigurations()));
playlist.setBroadcastConfigurations(new ArrayList(mBroadcastModel.getBroadcastConfigurations())); playlist.setBroadcastConfigurations(new ArrayList(mBroadcastModel.getBroadcastConfigurations()));
playlist.setChannels(new ArrayList(mChannelModel.getChannels())); playlist.setChannels(new ArrayList(mChannelModel.getChannels()));
playlist.setChannelMaps(new ArrayList(mChannelMapModel.getChannelMaps())); playlist.setChannelMaps(new ArrayList(mChannelMapModel.getChannelMaps()));

View File

@@ -24,7 +24,6 @@ package io.github.dsheirer.playlist;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.alias.Alias; import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasListConfiguration;
import io.github.dsheirer.audio.broadcast.BroadcastConfiguration; import io.github.dsheirer.audio.broadcast.BroadcastConfiguration;
import io.github.dsheirer.controller.channel.Channel; import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.controller.channel.map.ChannelMap; import io.github.dsheirer.controller.channel.map.ChannelMap;
@@ -37,7 +36,6 @@ public class PlaylistV2
{ {
private int mVersion = PlaylistManager.PLAYLIST_CURRENT_VERSION; private int mVersion = PlaylistManager.PLAYLIST_CURRENT_VERSION;
private List<Alias> mAliases = new ArrayList<>(); private List<Alias> mAliases = new ArrayList<>();
private List<AliasListConfiguration> mAliasListConfigurations = new ArrayList<>();
private List<BroadcastConfiguration> mBroadcastConfigurations = new ArrayList<>(); private List<BroadcastConfiguration> mBroadcastConfigurations = new ArrayList<>();
private List<Channel> mChannels = new ArrayList<>(); private List<Channel> mChannels = new ArrayList<>();
private List<ChannelMap> mChannelMaps = new ArrayList<>(); private List<ChannelMap> mChannelMaps = new ArrayList<>();
@@ -74,20 +72,6 @@ public class PlaylistV2
mAliases = aliases; mAliases = aliases;
} }
/**
* Alias list settings, like Radio Reference system tracking. Older playlists don't have these.
*/
@JacksonXmlProperty(isAttribute = false, localName = "alias_list")
public List<AliasListConfiguration> getAliasListConfigurations()
{
return mAliasListConfigurations;
}
public void setAliasListConfigurations(List<AliasListConfiguration> configurations)
{
mAliasListConfigurations = configurations != null ? configurations : new ArrayList<>();
}
@JacksonXmlProperty(isAttribute = false, localName = "channel") @JacksonXmlProperty(isAttribute = false, localName = "channel")
public List<Channel> getChannels() public List<Channel> getChannels()
{ {

View File

@@ -1,56 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.preference.radioreference;
import java.time.Duration;
/**
* How often alias lists that track a Radio Reference system check the system for changes.
*/
public enum AliasListUpdateInterval
{
TWELVE_HOURS("Every 12 Hours", Duration.ofHours(12)),
DAILY("Every Day", Duration.ofDays(1)),
WEEKLY("Once a Week", Duration.ofDays(7)),
MONTHLY("Once a Month", Duration.ofDays(30));
private final String mLabel;
private final Duration mInterval;
AliasListUpdateInterval(String label, Duration interval)
{
mLabel = label;
mInterval = interval;
}
/**
* Time between checks
*/
public Duration getInterval()
{
return mInterval;
}
@Override
public String toString()
{
return mLabel;
}
}

View File

@@ -60,7 +60,6 @@ public class RadioReferencePreference extends Preference
private static final String ENCRYPTED_TALKGROUP_DO_NOT_MONITOR = "encrypted.talkgroup.import.do.not.monitor"; private static final String ENCRYPTED_TALKGROUP_DO_NOT_MONITOR = "encrypted.talkgroup.import.do.not.monitor";
private static final String CREATE_AND_SHOW_CHANNEL_EDITOR = "create.and.show.channel.editor"; private static final String CREATE_AND_SHOW_CHANNEL_EDITOR = "create.and.show.channel.editor";
private static final String LOCATION = "location"; private static final String LOCATION = "location";
private static final String ALIAS_LIST_UPDATE_INTERVAL = "alias.list.update.interval";
private static final String LOCATION_LABEL = "location.label"; private static final String LOCATION_LABEL = "location.label";
private String mUserName; private String mUserName;
@@ -72,7 +71,6 @@ public class RadioReferencePreference extends Preference
private Boolean mShowChannelEditorCounty; private Boolean mShowChannelEditorCounty;
private Boolean mEncryptedTalkgroupImport; private Boolean mEncryptedTalkgroupImport;
private Boolean mCreateAndShowChannelEditor; private Boolean mCreateAndShowChannelEditor;
private AliasListUpdateInterval mAliasListUpdateInterval;
private int mPreferredCountryId = INVALID_ID; private int mPreferredCountryId = INVALID_ID;
private int mPreferredStateId = INVALID_ID; private int mPreferredStateId = INVALID_ID;
private int mPreferredCountyId = INVALID_ID; private int mPreferredCountyId = INVALID_ID;
@@ -496,41 +494,6 @@ public class RadioReferencePreference extends Preference
} }
/**
* How often alias lists that track a Radio Reference system check the system for changes.
*/
public AliasListUpdateInterval getAliasListUpdateInterval()
{
if(mAliasListUpdateInterval == null)
{
String name = mPreferences.get(ALIAS_LIST_UPDATE_INTERVAL, AliasListUpdateInterval.DAILY.name());
try
{
mAliasListUpdateInterval = AliasListUpdateInterval.valueOf(name);
}
catch(IllegalArgumentException iae)
{
mAliasListUpdateInterval = AliasListUpdateInterval.DAILY;
}
}
return mAliasListUpdateInterval;
}
/**
* Sets how often alias lists that track a Radio Reference system check the system for changes.
*/
public void setAliasListUpdateInterval(AliasListUpdateInterval interval)
{
if(interval != null)
{
mAliasListUpdateInterval = interval;
mPreferences.put(ALIAS_LIST_UPDATE_INTERVAL, interval.name());
notifyPreferenceUpdated();
}
}
/** /**
* Indicates if should show channel editor after trunked channel configuration create * Indicates if should show channel editor after trunked channel configuration create
*/ */

View File

@@ -1,510 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.service.radioreference;
import com.google.common.annotations.VisibleForTesting;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasListConfiguration;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.alias.id.AliasID;
import io.github.dsheirer.gui.playlist.radioreference.RadioReferenceDecoder;
import io.github.dsheirer.gui.playlist.radioreference.TalkgroupEncryption;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.preference.radioreference.AliasListUpdateInterval;
import io.github.dsheirer.rrapi.RadioReferenceException;
import io.github.dsheirer.rrapi.RadioReferenceService;
import io.github.dsheirer.rrapi.type.System;
import io.github.dsheirer.rrapi.type.SystemInformation;
import io.github.dsheirer.rrapi.type.Talkgroup;
import io.github.dsheirer.rrapi.type.TalkgroupCategory;
import io.github.dsheirer.util.ThreadPool;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javafx.application.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Keeps alias lists that track a Radio Reference system up to date. Checks each tracked system on the interval from
* the user's Radio Reference preferences, records the system's Radio Reference last updated timestamp, and when the
* alias list is set to auto-update and the system changed, adds an alias for each new talkgroup and updates the name
* and group of aliases for talkgroups that changed on Radio Reference since the last synchronization.
*
* Aliases for talkgroups that are removed from Radio Reference are left in place, and alias settings other than the
* name and group (color, icon, priority, record, stream, etc.) are never changed.
*/
public class AliasListSynchronizer
{
private static final Logger mLog = LoggerFactory.getLogger(AliasListSynchronizer.class);
private static final long CHECK_PERIOD_MINUTES = 30;
private static final long INITIAL_DELAY_MINUTES = 2;
private static final long RETRY_AFTER_FAILURE_MS = TimeUnit.HOURS.toMillis(1);
private final AliasModel mAliasModel;
private final RadioReference mRadioReference;
private final UserPreferences mUserPreferences;
private final Object mSynchronizationLock = new Object();
private final Map<Integer,Long> mFailedAttempts = new HashMap<>();
private RadioReferenceDecoder mRadioReferenceDecoder;
private ScheduledFuture<?> mScheduledCheck;
/**
* Constructs an instance
* @param aliasModel containing aliases and alias list configurations
* @param radioReference for access to the web service
* @param userPreferences for the update interval and encrypted talkgroup import preferences
*/
public AliasListSynchronizer(AliasModel aliasModel, RadioReference radioReference, UserPreferences userPreferences)
{
mAliasModel = aliasModel;
mRadioReference = radioReference;
mUserPreferences = userPreferences;
}
/**
* Starts periodic checks of tracked alias lists.
*/
public synchronized void start()
{
if(mScheduledCheck == null)
{
mScheduledCheck = ThreadPool.SCHEDULED.scheduleAtFixedRate(this::checkDueAliasLists,
INITIAL_DELAY_MINUTES, CHECK_PERIOD_MINUTES, TimeUnit.MINUTES);
}
}
/**
* Stops periodic checks.
*/
public synchronized void stop()
{
if(mScheduledCheck != null)
{
mScheduledCheck.cancel(false);
mScheduledCheck = null;
}
}
/**
* Checks each tracked alias list whose last check is older than the preferred update interval. Runs on a
* scheduler thread.
*/
private void checkDueAliasLists()
{
if(!mUserPreferences.getRadioReferencePreference().hasStoredCredentials())
{
return;
}
AliasListUpdateInterval interval = mUserPreferences.getRadioReferencePreference().getAliasListUpdateInterval();
long now = java.lang.System.currentTimeMillis();
for(AliasListConfiguration configuration: getTrackedConfigurations())
{
boolean due = now - configuration.getLastChecked() >= interval.getInterval().toMillis();
Long failed;
synchronized(mFailedAttempts)
{
failed = mFailedAttempts.get(configuration.getRadioReferenceSystemId());
}
boolean retryWait = failed != null && now - failed < RETRY_AFTER_FAILURE_MS;
if(due && !retryWait)
{
try
{
synchronize(configuration, false).join();
}
catch(Exception e)
{
mLog.warn("Unable to check Radio Reference system [" + configuration.getRadioReferenceSystemId() +
"] for alias list [" + configuration.getName() + "] - " + getMessage(e));
}
}
}
}
/**
* Snapshot of the alias list configurations that track a Radio Reference system.
*/
private List<AliasListConfiguration> getTrackedConfigurations()
{
List<AliasListConfiguration> tracked = new ArrayList<>();
//The configuration list is modified on the FX thread, so retry on a concurrent change
for(int attempt = 0; attempt < 3; attempt++)
{
try
{
tracked.clear();
for(AliasListConfiguration configuration: new ArrayList<>(mAliasModel.aliasListConfigurations()))
{
if(configuration.isTrackingRadioReferenceSystem())
{
tracked.add(configuration);
}
}
return tracked;
}
catch(Exception e)
{
//Try again
}
}
return tracked;
}
/**
* Refreshes the alias list now: reads the current system and talkgroups from Radio Reference and adds or updates
* aliases, regardless of the alias list's auto-update setting.
* @param configuration of a tracked alias list
* @return future result, completed after the aliases are updated on the FX thread
*/
public CompletableFuture<Result> refresh(AliasListConfiguration configuration)
{
return synchronize(configuration, true);
}
/**
* Checks the tracked system and, when forced or when the alias list auto-updates and the system changed,
* synchronizes the talkgroup aliases.
* @param configuration of the tracked alias list
* @param force true to synchronize regardless of the auto-update setting or the last updated timestamps
* @return future result
*/
private CompletableFuture<Result> synchronize(AliasListConfiguration configuration, boolean force)
{
CompletableFuture<Result> future = new CompletableFuture<>();
if(configuration == null || !configuration.isTrackingRadioReferenceSystem())
{
future.completeExceptionally(new IllegalArgumentException("Alias list doesn't track a Radio Reference system"));
return future;
}
ThreadPool.CACHED.execute(() -> {
//One synchronization at a time so that a manual refresh and a scheduled check can't both add aliases
synchronized(mSynchronizationLock)
{
int systemId = configuration.getRadioReferenceSystemId();
try
{
RadioReferenceService service = mRadioReference.getService();
if(service instanceof CachingRadioReferenceService caching)
{
caching.invalidateSystem(systemId);
}
SystemInformation systemInformation = service.getSystemInformation(systemId);
if(systemInformation == null)
{
throw new RadioReferenceException("Radio Reference didn't provide system [" + systemId + "]");
}
long lastUpdated = getTime(systemInformation.getLastUpdated());
boolean changed = lastUpdated > configuration.getSynchronizedLastUpdated();
boolean synchronize = force || (configuration.isAutoUpdate() && changed);
List<Talkgroup> talkgroups = null;
Map<Integer,String> categoryNames = new HashMap<>();
System system = null;
RadioReferenceDecoder decoder = null;
if(synchronize)
{
decoder = getRadioReferenceDecoder();
system = toSystem(systemId, systemInformation);
talkgroups = service.getTalkgroups(systemId);
List<TalkgroupCategory> categories = service.getTalkgroupCategories(systemId);
if(categories != null)
{
for(TalkgroupCategory category: categories)
{
categoryNames.put(category.getTalkgroupCategoryId(), category.getName());
}
}
}
synchronized(mFailedAttempts)
{
mFailedAttempts.remove(systemId);
}
List<Talkgroup> talkgroupsToApply = talkgroups;
System systemToApply = system;
RadioReferenceDecoder decoderToApply = decoder;
String systemName = systemInformation.getName();
runOnFxThread(() -> {
try
{
future.complete(apply(configuration, systemId, systemName, lastUpdated, talkgroupsToApply,
categoryNames, systemToApply, decoderToApply));
}
catch(Throwable t)
{
future.completeExceptionally(t);
}
});
}
catch(Throwable t)
{
synchronized(mFailedAttempts)
{
mFailedAttempts.put(systemId, java.lang.System.currentTimeMillis());
}
future.completeExceptionally(t);
}
}
});
return future;
}
/**
* Records the check and applies the talkgroups to the alias list. Runs on the FX thread.
* @param talkgroups to apply, or null when only recording the check
*/
@VisibleForTesting
Result apply(AliasListConfiguration configuration, int systemId, String systemName, long lastUpdated,
List<Talkgroup> talkgroups, Map<Integer,String> categoryNames, System system,
RadioReferenceDecoder decoder)
{
//The user may have deleted the alias list or stopped tracking while the request was in progress
if(!mAliasModel.aliasListConfigurations().contains(configuration) || !configuration.isTracking(systemId))
{
return new Result(false, 0, 0, lastUpdated);
}
configuration.setLastChecked(java.lang.System.currentTimeMillis());
configuration.setRadioReferenceLastUpdated(lastUpdated);
if(systemName != null && !systemName.isEmpty())
{
configuration.setRadioReferenceSystemName(systemName);
}
if(talkgroups == null)
{
return new Result(false, 0, 0, lastUpdated);
}
String aliasListName = configuration.getName();
long previousSynchronization = configuration.getSynchronizedLastUpdated();
boolean encryptedDoNotMonitor = mUserPreferences.getRadioReferencePreference().isEncryptedTalkgroupDoNotMonitor();
List<Alias> listAliases = new ArrayList<>();
for(Alias alias: mAliasModel.getAliases())
{
if(aliasListName.equals(alias.getAliasListName()))
{
listAliases.add(alias);
}
}
List<Alias> created = new ArrayList<>();
int updated = 0;
for(Talkgroup talkgroup: talkgroups)
{
io.github.dsheirer.alias.id.talkgroup.Talkgroup aliasId = decoder.getTalkgroupAliasId(talkgroup, system);
String group = categoryNames.get(talkgroup.getTalkgroupCategoryId());
List<Alias> matches = getMatches(listAliases, aliasId);
if(matches.isEmpty())
{
Alias alias = decoder.createAlias(talkgroup, system, aliasListName, group);
if(encryptedDoNotMonitor &&
TalkgroupEncryption.lookup(talkgroup.getEncryptionState()) == TalkgroupEncryption.FULL)
{
alias.addAliasID(new io.github.dsheirer.alias.id.priority.Priority(
io.github.dsheirer.alias.id.priority.Priority.DO_NOT_MONITOR));
}
created.add(alias);
listAliases.add(alias);
}
//Only update aliases for talkgroups that changed on Radio Reference after the previous synchronization, so
//that the first synchronization and unchanged talkgroups keep any names the user has edited.
else if(previousSynchronization > 0 && getTime(talkgroup.getLastUpdated()) > previousSynchronization)
{
for(Alias alias: matches)
{
boolean aliasUpdated = false;
String name = talkgroup.getAlphaTag();
if(name != null && !name.isEmpty() && !Objects.equals(name, alias.getName()))
{
alias.setName(name);
aliasUpdated = true;
}
if(group != null && !group.isEmpty() && !Objects.equals(group, alias.getGroup()))
{
alias.setGroup(group);
aliasUpdated = true;
}
if(aliasUpdated)
{
updated++;
}
}
}
}
if(!created.isEmpty())
{
mAliasModel.addAliases(created);
}
configuration.setSynchronizedLastUpdated(lastUpdated);
mLog.info("Alias list [" + aliasListName + "] synchronized with Radio Reference system [" +
configuration.getRadioReferenceSystemId() + "] - added [" + created.size() + "] updated [" + updated +
"] aliases");
return new Result(true, created.size(), updated, lastUpdated);
}
/**
* Aliases with a talkgroup alias identifier that matches the talkgroup.
*/
private static List<Alias> getMatches(List<Alias> aliases, io.github.dsheirer.alias.id.talkgroup.Talkgroup aliasId)
{
List<Alias> matches = new ArrayList<>();
for(Alias alias: aliases)
{
for(AliasID id: alias.getAliasIdentifiers())
{
if(aliasId.matches(id))
{
matches.add(alias);
break;
}
}
}
return matches;
}
/**
* Decoder for talkgroup values and protocols, created on first use from the cached Radio Reference maps.
*/
private RadioReferenceDecoder getRadioReferenceDecoder() throws RadioReferenceException
{
if(mRadioReferenceDecoder == null)
{
RadioReferenceService service = mRadioReference.getService();
mRadioReferenceDecoder = new RadioReferenceDecoder(mUserPreferences, service.getTypesMap(),
service.getFlavorsMap(), service.getVoicesMap(), service.getTagsMap());
}
return mRadioReferenceDecoder;
}
/**
* Creates a system from the system information, for the decoder's protocol lookup.
*/
private static System toSystem(int systemId, SystemInformation systemInformation)
{
System system = new System();
system.setSystemId(systemId);
system.setName(systemInformation.getName());
system.setTypeId(systemInformation.getTypeId());
system.setFlavorId(systemInformation.getFlavorId());
system.setVoiceId(systemInformation.getVoiceId());
system.setCity(systemInformation.getCity());
system.setLastUpdated(systemInformation.getLastUpdated());
return system;
}
private static long getTime(Date date)
{
return date != null ? date.getTime() : 0;
}
/**
* Runs on the FX thread, or on this thread when the FX toolkit isn't running (headless).
*/
private static void runOnFxThread(Runnable runnable)
{
if(Platform.isFxApplicationThread())
{
runnable.run();
return;
}
try
{
Platform.runLater(runnable);
}
catch(IllegalStateException ise)
{
runnable.run();
}
}
/**
* Message for an exception, unwrapping completion exceptions.
*/
public static String getMessage(Throwable throwable)
{
Throwable cause = throwable;
while(cause.getCause() != null && (cause instanceof java.util.concurrent.CompletionException ||
cause instanceof java.util.concurrent.ExecutionException))
{
cause = cause.getCause();
}
return cause.getMessage() != null ? cause.getMessage() : cause.getClass().getSimpleName();
}
/**
* Synchronization result
* @param applied true if the talkgroups were applied to the alias list
* @param added alias count
* @param updated alias count
* @param lastUpdated Radio Reference system last updated timestamp
*/
public record Result(boolean applied, int added, int updated, long lastUpdated) {}
}

View File

@@ -148,17 +148,6 @@ public class CachingRadioReferenceService extends RadioReferenceService
return get(mTalkgroupCache, systemId); return get(mTalkgroupCache, systemId);
} }
/**
* Discards the cached system information and talkgroups for the system so that the next request reads current
* values from the web service.
* @param systemId to discard
*/
public void invalidateSystem(int systemId)
{
mSystemInfoCache.invalidate(systemId);
mTalkgroupCache.invalidate(systemId);
}
/** /**
* Loads a value from the web service * Loads a value from the web service
*/ */

View File

@@ -1,119 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.alias;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.github.dsheirer.playlist.PlaylistV2;
import java.util.List;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Alias list configuration persistence and alias model rename/delete handling.
*/
public class AliasListConfigurationTest
{
private static ObjectMapper mapper()
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
return new XmlMapper(xmlModule).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
@Test
void playlistRoundTrip() throws Exception
{
AliasListConfiguration configuration = new AliasListConfiguration("County P25");
configuration.track(1234, "County Public Safety");
configuration.setAutoUpdate(true);
configuration.setRadioReferenceLastUpdated(2000L);
configuration.setSynchronizedLastUpdated(1000L);
configuration.setLastChecked(3000L);
Alias alias = new Alias("Fire Dispatch");
alias.setAliasListName("County P25");
PlaylistV2 playlist = new PlaylistV2();
playlist.getAliases().add(alias);
playlist.getAliasListConfigurations().add(configuration);
String xml = mapper().writeValueAsString(playlist);
PlaylistV2 read = mapper().readValue(xml, PlaylistV2.class);
assertEquals(1, read.getAliasListConfigurations().size(), xml);
AliasListConfiguration readConfiguration = read.getAliasListConfigurations().get(0);
assertEquals("County P25", readConfiguration.getName());
assertEquals(1234, readConfiguration.getRadioReferenceSystemId());
assertEquals("County Public Safety", readConfiguration.getRadioReferenceSystemName());
assertTrue(readConfiguration.isAutoUpdate());
assertEquals(2000L, readConfiguration.getRadioReferenceLastUpdated());
assertEquals(1000L, readConfiguration.getSynchronizedLastUpdated());
assertEquals(3000L, readConfiguration.getLastChecked());
assertTrue(readConfiguration.isUpdateAvailable());
assertEquals(1, read.getAliases().size());
}
@Test
void legacyPlaylistWithoutConfigurations() throws Exception
{
String xml = "<playlist version=\"4\"><alias name=\"A\" list=\"L\"/></playlist>";
PlaylistV2 read = mapper().readValue(xml, PlaylistV2.class);
assertTrue(read.getAliasListConfigurations().isEmpty());
assertEquals(1, read.getAliases().size());
}
@Test
void trackingLookupRenameAndDelete()
{
AliasModel model = new AliasModel();
model.addAliasListConfigurations(List.of(new AliasListConfiguration("Plain")));
AliasListConfiguration tracked = model.getOrCreateAliasListConfiguration("Tracked");
tracked.track(42, "System 42");
//Configured alias lists are listed before they have any aliases
assertTrue(model.aliasListNames().contains("Tracked"));
assertEquals("Tracked", model.getAliasListNameTracking(42));
assertNull(model.getAliasListNameTracking(7));
assertFalse(model.getAliasListConfiguration("Plain").isTrackingRadioReferenceSystem());
Alias alias = new Alias("TG 1");
alias.setAliasListName("Tracked");
model.addAlias(alias);
model.renameAliasList("Tracked", "Renamed");
assertEquals("Renamed", model.getAliasListNameTracking(42));
assertEquals("Renamed", alias.getAliasListName());
assertNull(model.getAliasListConfiguration("Tracked"));
model.refreshAliasListNames();
assertTrue(model.aliasListNames().contains("Plain"));
model.deleteAliasList("Renamed");
assertNull(model.getAliasListNameTracking(42));
assertTrue(model.getAliases().isEmpty());
}
}

View File

@@ -1,215 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.alias;
import io.github.dsheirer.alias.TalkerAliasAutoAdder.Decision;
import io.github.dsheirer.alias.id.radio.P25FullyQualifiedRadio;
import io.github.dsheirer.alias.id.radio.Radio;
import io.github.dsheirer.alias.id.talkgroup.Talkgroup;
import io.github.dsheirer.identifier.alias.P25TalkerAliasIdentifier;
import io.github.dsheirer.identifier.alias.TalkerAliasManager;
import io.github.dsheirer.identifier.radio.RadioIdentifier;
import io.github.dsheirer.module.decode.p25.identifier.radio.APCO25FullyQualifiedRadioIdentifier;
import io.github.dsheirer.module.decode.p25.identifier.radio.APCO25RadioIdentifier;
import io.github.dsheirer.protocol.Protocol;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for automatically adding talker aliases to an alias list. The JavaFX toolkit isn't running, so the alias model
* updates run on the calling thread.
*/
public class TalkerAliasAutoAdderTest
{
private static final String LIST = "Test List";
private static final RadioIdentifier RADIO = (RadioIdentifier)APCO25RadioIdentifier.createFrom(1234);
private AliasModel mAliasModel;
private TalkerAliasManager mManager;
@BeforeEach
public void setup()
{
mAliasModel = new AliasModel();
mManager = new TalkerAliasManager();
mManager.setTalkerAliasListener(new TalkerAliasAutoAdder(mAliasModel, LIST));
}
private void decode(RadioIdentifier radio, String alias)
{
mManager.update(radio, P25TalkerAliasIdentifier.create(alias));
}
private List<Alias> aliases()
{
return mAliasModel.getAliases().stream().filter(a -> LIST.equals(a.getAliasListName())).toList();
}
private Alias alias(RadioIdentifier radio)
{
return TalkerAliasAutoAdder.findExactMatch(aliases(), TalkerAliasAutoAdder.createAliasId(radio));
}
@Test
public void createsAliasForRadio()
{
decode(RADIO, "ENGINE 12");
assertEquals(1, aliases().size());
Alias alias = alias(RADIO);
assertEquals("ENGINE 12", alias.getName());
assertEquals(TalkerAliasAutoAdder.ALIAS_GROUP, alias.getGroup());
assertTrue(alias.getAliasIdentifiers().get(0) instanceof Radio radio && radio.getValue() == 1234 &&
radio.getProtocol() == Protocol.APCO25);
decode(RADIO, "ENGINE 12");
assertEquals(1, aliases().size(), "no duplicate alias");
}
@Test
public void fragmentNeverReplacesFullAlias()
{
decode(RADIO, "ENGINE 12 OFFICER");
for(int x = 0; x < 5; x++)
{
decode(RADIO, "ENGINE 12 OFF");
decode(RADIO, "ENG");
}
assertEquals("ENGINE 12 OFFICER", alias(RADIO).getName());
}
@Test
public void fullAliasReplacesStoredFragment()
{
decode(RADIO, "ENGINE 1");
assertEquals("ENGINE 1", alias(RADIO).getName());
decode(RADIO, "ENGINE 12 OFFICER");
assertEquals("ENGINE 12 OFFICER", alias(RADIO).getName());
}
@Test
public void differentAliasRequiresConfirmation()
{
decode(RADIO, "ENGINE 12");
decode(RADIO, "LADDER 3");
assertEquals("ENGINE 12", alias(RADIO).getName(), "a single decode doesn't rename");
decode(RADIO, "LADDER 3");
assertEquals("LADDER 3", alias(RADIO).getName(), "confirmed decode renames");
}
@Test
public void fragmentsOfNewAliasDontInterruptConfirmation()
{
decode(RADIO, "ENGINE 12");
decode(RADIO, "LADDER 3 CAPTAIN");
decode(RADIO, "LADDER");
decode(RADIO, "LADDER 3 CAPTAIN");
assertEquals("LADDER 3 CAPTAIN", alias(RADIO).getName());
}
@Test
public void interleavedDifferentAliasesDontConfirm()
{
decode(RADIO, "ENGINE 12");
decode(RADIO, "LADDER 3");
decode(RADIO, "RESCUE 5");
decode(RADIO, "LADDER 3");
assertEquals("ENGINE 12", alias(RADIO).getName());
}
@Test
public void multiIdentifierAliasIsLeftAlone()
{
Alias alias = new Alias("Portables");
alias.setAliasListName(LIST);
alias.addAliasID(new Radio(Protocol.APCO25, 1234));
alias.addAliasID(new Radio(Protocol.APCO25, 5678));
mAliasModel.addAlias(alias);
decode(RADIO, "ENGINE 12");
decode(RADIO, "ENGINE 12");
assertEquals(1, aliases().size());
assertEquals("Portables", alias.getName());
}
@Test
public void userAliasForRadioIsRenamed()
{
Alias alias = new Alias("Old Name");
alias.setAliasListName(LIST);
alias.addAliasID(new Radio(Protocol.APCO25, 1234));
alias.addAliasID(new io.github.dsheirer.alias.id.priority.Priority(1));
mAliasModel.addAlias(alias);
decode(RADIO, "ENGINE 12");
decode(RADIO, "ENGINE 12");
assertEquals(1, aliases().size());
assertEquals("ENGINE 12", alias.getName());
}
@Test
public void talkgroupAliasWithSameValueIsIgnored()
{
Alias alias = new Alias("Dispatch");
alias.setAliasListName(LIST);
alias.addAliasID(new Talkgroup(Protocol.APCO25, 1234));
mAliasModel.addAlias(alias);
decode(RADIO, "ENGINE 12");
assertEquals(2, aliases().size());
assertEquals("Dispatch", alias.getName());
}
@Test
public void fullyQualifiedRadio()
{
RadioIdentifier roaming = APCO25FullyQualifiedRadioIdentifier.createFrom(1234, 0xBEE00, 0x123, 777);
decode(roaming, "ROAMER");
Alias alias = alias(roaming);
assertTrue(alias.getAliasIdentifiers().get(0) instanceof P25FullyQualifiedRadio);
assertNull(alias(RADIO), "local radio with the same value isn't aliased");
}
@Test
public void decide()
{
assertEquals(Decision.UPDATE, TalkerAliasAutoAdder.decide(null, "A", 1));
assertEquals(Decision.UNCHANGED, TalkerAliasAutoAdder.decide("ABC", "ABC", 1));
assertEquals(Decision.FRAGMENT, TalkerAliasAutoAdder.decide("ABCDEF", "ABC", 5));
assertEquals(Decision.UPDATE, TalkerAliasAutoAdder.decide("ABC", "ABCDEF", 1));
assertEquals(Decision.AWAIT_CONFIRMATION, TalkerAliasAutoAdder.decide("ABC", "XYZ", 1));
assertEquals(Decision.UPDATE, TalkerAliasAutoAdder.decide("ABC", "XYZ", 2));
assertEquals(Decision.AWAIT_CONFIRMATION, TalkerAliasAutoAdder.decide("ABC", "X<EFBFBD>Z", 5));
}
@Test
public void normalize()
{
assertEquals("JOS", TalkerAliasAutoAdder.normalize("JOS<EFBFBD>"));
assertEquals("ENGINE 12", TalkerAliasAutoAdder.normalize(" ENGINE 12\u0000\u0000 "));
assertNull(TalkerAliasAutoAdder.normalize("\u0000 "));
}
}

View File

@@ -1,49 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.controller.channel;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.github.dsheirer.playlist.PlaylistV2;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* Tests channel auto-add talker aliases default and playlist persistence.
*/
public class ChannelAutoAddTalkerAliasesTest {
@Test public void newChannelsDefaultOnLegacyChannelsStayOff() throws Exception {
JacksonXmlModule m = new JacksonXmlModule(); m.setDefaultUseWrapper(false);
XmlMapper mapper = new XmlMapper(m);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
assertTrue(new Channel().isAutoAddTalkerAliases(), "new channel default on");
assertTrue(new Channel("n").isAutoAddTalkerAliases(), "new named channel default on");
Channel off = new Channel("x"); off.setAutoAddTalkerAliases(false);
assertFalse(mapper.readValue(mapper.writeValueAsString(off), Channel.class).isAutoAddTalkerAliases());
assertTrue(mapper.readValue(mapper.writeValueAsString(new Channel("y")), Channel.class).isAutoAddTalkerAliases());
String legacy = mapper.writeValueAsString(new Channel("z")).replace(" auto_add_talker_aliases=\"true\"", "");
assertFalse(legacy.contains("auto_add"));
Channel legacyChannel = mapper.readValue(legacy, Channel.class);
assertFalse(legacyChannel.isAutoAddTalkerAliases(), "legacy channel stays off");
assertEquals("z", legacyChannel.getName());
PlaylistV2 pl = new PlaylistV2(); pl.getChannels().add(new Channel("p"));
String plXml = mapper.writeValueAsString(pl).replace(" auto_add_talker_aliases=\"true\"", "");
assertFalse(mapper.readValue(plXml, PlaylistV2.class).getChannels().get(0).isAutoAddTalkerAliases(), "legacy playlist off");
off.setAutoAddTalkerAliases(false); assertFalse(off.copyOf().isAutoAddTalkerAliases());
}
}

View File

@@ -1,164 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.service.radioreference;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasListConfiguration;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.alias.id.AliasIDType;
import io.github.dsheirer.gui.playlist.radioreference.RadioReferenceDecoder;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.protocol.Protocol;
import io.github.dsheirer.rrapi.type.System;
import io.github.dsheirer.rrapi.type.Talkgroup;
import io.github.dsheirer.rrapi.type.Type;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Applying Radio Reference talkgroups to a tracked alias list, without the web service.
*/
public class AliasListSynchronizerTest
{
private static final int SYSTEM_ID = 42;
private static final String LIST = "Tracked";
private AliasModel mAliasModel;
private AliasListSynchronizer mSynchronizer;
private RadioReferenceDecoder mDecoder;
private System mSystem;
private AliasListConfiguration mConfiguration;
@BeforeEach
void setup()
{
UserPreferences userPreferences = new UserPreferences();
mAliasModel = new AliasModel();
mSynchronizer = new AliasListSynchronizer(mAliasModel, null, userPreferences);
Type p25 = new Type();
p25.setTypeId(1);
p25.setName("Project 25");
mDecoder = new RadioReferenceDecoder(userPreferences, Map.of(1, p25), Map.of(), Map.of(), Map.of());
mSystem = new System();
mSystem.setSystemId(SYSTEM_ID);
mSystem.setTypeId(1);
mConfiguration = mAliasModel.getOrCreateAliasListConfiguration(LIST);
mConfiguration.track(SYSTEM_ID, "System");
}
private static Talkgroup talkgroup(int value, String alphaTag, int categoryId, long lastUpdated)
{
Talkgroup talkgroup = new Talkgroup();
talkgroup.setDecimalValue(value);
talkgroup.setAlphaTag(alphaTag);
talkgroup.setTalkgroupCategoryId(categoryId);
talkgroup.setLastUpdated(new Date(lastUpdated));
return talkgroup;
}
private AliasListSynchronizer.Result apply(long lastUpdated, List<Talkgroup> talkgroups)
{
return mSynchronizer.apply(mConfiguration, SYSTEM_ID, "System", lastUpdated, talkgroups,
Map.of(1, "Fire", 2, "Police"), mSystem, mDecoder);
}
private Alias alias(int value)
{
return mAliasModel.getAliases(LIST, AliasIDType.TALKGROUP).stream()
.filter(a -> a.getAliasIdentifiers().stream().anyMatch(id ->
new io.github.dsheirer.alias.id.talkgroup.Talkgroup(Protocol.APCO25, value).matches(id)))
.findFirst().orElseThrow();
}
@Test
void firstSynchronizationAddsMissingAndKeepsExistingNames()
{
//The user already has an alias for talkgroup 100 with their own name
Alias existing = new Alias("My Name");
existing.setAliasListName(LIST);
existing.addAliasID(new io.github.dsheirer.alias.id.talkgroup.Talkgroup(Protocol.APCO25, 100));
mAliasModel.addAlias(existing);
AliasListSynchronizer.Result result = apply(5000,
List.of(talkgroup(100, "FD Dispatch", 1, 4000), talkgroup(200, "PD Main", 2, 4000)));
assertTrue(result.applied());
assertEquals(1, result.added());
assertEquals(0, result.updated());
assertEquals("My Name", alias(100).getName());
assertEquals("PD Main", alias(200).getName());
assertEquals("Police", alias(200).getGroup());
assertEquals(5000, mConfiguration.getSynchronizedLastUpdated());
assertEquals(5000, mConfiguration.getRadioReferenceLastUpdated());
assertTrue(mConfiguration.getLastChecked() > 0);
assertFalse(mConfiguration.isUpdateAvailable());
}
@Test
void laterSynchronizationUpdatesOnlyChangedTalkgroups()
{
apply(5000, List.of(talkgroup(100, "FD Dispatch", 1, 4000), talkgroup(200, "PD Main", 2, 4000)));
alias(200).setName("User Edited");
//Talkgroup 100 was renamed on Radio Reference after the first synchronization; 200 didn't change
AliasListSynchronizer.Result result = apply(9000, List.of(talkgroup(100, "FD Dispatch 1", 2, 8000),
talkgroup(200, "PD Main", 2, 4000), talkgroup(300, "EMS", 1, 8000)));
assertEquals(1, result.added());
assertEquals(1, result.updated());
assertEquals("FD Dispatch 1", alias(100).getName());
assertEquals("Police", alias(100).getGroup());
assertEquals("User Edited", alias(200).getName());
assertEquals("EMS", alias(300).getName());
assertEquals(9000, mConfiguration.getSynchronizedLastUpdated());
}
@Test
void checkOnlyRecordsTimestamps()
{
AliasListSynchronizer.Result result = apply(7000, null);
assertFalse(result.applied());
assertEquals(7000, mConfiguration.getRadioReferenceLastUpdated());
assertEquals(0, mConfiguration.getSynchronizedLastUpdated());
assertTrue(mConfiguration.isUpdateAvailable());
assertTrue(mAliasModel.getAliases().isEmpty());
}
@Test
void deletedAliasListIsIgnored()
{
mAliasModel.deleteAliasList(LIST);
AliasListSynchronizer.Result result = apply(5000, List.of(talkgroup(100, "FD Dispatch", 1, 4000)));
assertFalse(result.applied());
assertTrue(mAliasModel.getAliases().isEmpty());
}
}