mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#786 Updates Broadcastify Calls api for new test endpoint and editor changes. Updates Icecast and Shoutcast configurations to correctly show configuration validation status. (#787)
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -91,8 +91,6 @@ public abstract class AbstractStreamEditor<T extends BroadcastConfiguration> ext
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
super.save();
|
||||
|
||||
BroadcastConfiguration configuration = getItem();
|
||||
|
||||
if(configuration != null)
|
||||
@@ -104,7 +102,7 @@ public abstract class AbstractStreamEditor<T extends BroadcastConfiguration> ext
|
||||
configuration.setMaximumRecordingAge(getMaxAgeTextField().get() * 1000); //Convert seconds to millis
|
||||
}
|
||||
|
||||
modifiedProperty().set(false);
|
||||
super.save();
|
||||
}
|
||||
|
||||
protected abstract GridPane getEditorPane();
|
||||
|
||||
@@ -30,6 +30,7 @@ import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -43,6 +44,8 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
private IntegerTextField mSystemIdTextField;
|
||||
private Button mTestButton;
|
||||
private IntegerTextField mMaxAgeTextField;
|
||||
private TextField mApiKeyTextField;
|
||||
private TextField mHostTextField;
|
||||
private GridPane mEditorPane;
|
||||
|
||||
/**
|
||||
@@ -60,14 +63,23 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
super.setItem(item);
|
||||
|
||||
getSystemIdTextField().setDisable(item == null);
|
||||
getApiKeyTextField().setDisable(item == null);
|
||||
getHostTextField().setDisable(item == null);
|
||||
getMaxAgeTextField().setDisable(item == null);
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
getSystemIdTextField().set(item.getSystemID());
|
||||
getApiKeyTextField().setText(item.getApiKey());
|
||||
getHostTextField().setText(item.getHost());
|
||||
getMaxAgeTextField().set((int)(item.getMaximumRecordingAge() / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
getSystemIdTextField().set(0);
|
||||
getApiKeyTextField().setText(null);
|
||||
getHostTextField().setText(null);
|
||||
getMaxAgeTextField().set(0);
|
||||
}
|
||||
|
||||
modifiedProperty().set(false);
|
||||
@@ -85,6 +97,9 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
{
|
||||
int systemID = getSystemIdTextField().get() != null ? getSystemIdTextField().get() : 0;
|
||||
getItem().setSystemID(systemID);
|
||||
getItem().setHost(getHostTextField().getText());
|
||||
getItem().setApiKey(getApiKeyTextField().getText());
|
||||
getItem().setMaximumRecordingAge(getMaxAgeTextField().get() * 1000);
|
||||
}
|
||||
|
||||
super.save();
|
||||
@@ -130,6 +145,14 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
GridPane.setConstraints(getNameTextField(), 1, row);
|
||||
mEditorPane.getChildren().add(getNameTextField());
|
||||
|
||||
Label apiKeyLabel = new Label("API Key");
|
||||
GridPane.setHalignment(apiKeyLabel, HPos.RIGHT);
|
||||
GridPane.setConstraints(apiKeyLabel, 0, ++row);
|
||||
mEditorPane.getChildren().add(apiKeyLabel);
|
||||
|
||||
GridPane.setConstraints(getApiKeyTextField(), 1, row);
|
||||
mEditorPane.getChildren().add(getApiKeyTextField());
|
||||
|
||||
Label systemIdLabel = new Label("System ID");
|
||||
GridPane.setHalignment(systemIdLabel, HPos.RIGHT);
|
||||
GridPane.setConstraints(systemIdLabel, 0, ++row);
|
||||
@@ -138,6 +161,14 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
GridPane.setConstraints(getSystemIdTextField(), 1, row);
|
||||
mEditorPane.getChildren().add(getSystemIdTextField());
|
||||
|
||||
Label hostLabel = new Label("Broadcastify URL");
|
||||
GridPane.setHalignment(hostLabel, HPos.RIGHT);
|
||||
GridPane.setConstraints(hostLabel, 0, ++row);
|
||||
mEditorPane.getChildren().add(hostLabel);
|
||||
|
||||
GridPane.setConstraints(getHostTextField(), 1, row);
|
||||
mEditorPane.getChildren().add(getHostTextField());
|
||||
|
||||
Label maxAgeLabel = new Label("Max Recording Age (seconds)");
|
||||
GridPane.setHalignment(maxAgeLabel, HPos.RIGHT);
|
||||
GridPane.setConstraints(maxAgeLabel, 0, ++row);
|
||||
@@ -153,7 +184,7 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
return mEditorPane;
|
||||
}
|
||||
|
||||
protected IntegerTextField getMaxAgeTextField()
|
||||
private IntegerTextField getMaxAgeTextField()
|
||||
{
|
||||
if(mMaxAgeTextField == null)
|
||||
{
|
||||
@@ -165,6 +196,30 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
return mMaxAgeTextField;
|
||||
}
|
||||
|
||||
private TextField getHostTextField()
|
||||
{
|
||||
if(mHostTextField == null)
|
||||
{
|
||||
mHostTextField = new TextField();
|
||||
mHostTextField.setDisable(true);
|
||||
mHostTextField.textProperty().addListener(mEditorModificationListener);
|
||||
}
|
||||
|
||||
return mHostTextField;
|
||||
}
|
||||
|
||||
private TextField getApiKeyTextField()
|
||||
{
|
||||
if(mApiKeyTextField == null)
|
||||
{
|
||||
mApiKeyTextField = new TextField();
|
||||
mApiKeyTextField.setDisable(true);
|
||||
mApiKeyTextField.textProperty().addListener(mEditorModificationListener);
|
||||
}
|
||||
|
||||
return mApiKeyTextField;
|
||||
}
|
||||
|
||||
private IntegerTextField getSystemIdTextField()
|
||||
{
|
||||
if(mSystemIdTextField == null)
|
||||
@@ -184,6 +239,19 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
mTestButton = new Button("Test Connection");
|
||||
mTestButton.setOnAction(event -> {
|
||||
int systemID = getSystemIdTextField().get();
|
||||
String apiKey = getApiKeyTextField().getText();
|
||||
String host = getHostTextField().getText();
|
||||
|
||||
if(apiKey == null || apiKey.isEmpty())
|
||||
{
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR, "Please enter an API Key",
|
||||
ButtonType.OK);
|
||||
alert.setTitle("Test Connection");
|
||||
alert.setHeaderText("A valid API Key is required");
|
||||
alert.initOwner(getTestButton().getScene().getWindow());
|
||||
alert.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(systemID < 1)
|
||||
{
|
||||
@@ -196,15 +264,29 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
return;
|
||||
}
|
||||
|
||||
if(host == null || host.isEmpty())
|
||||
{
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR, "Please enter a Broadcastify URL",
|
||||
ButtonType.OK);
|
||||
alert.setTitle("Test Connection");
|
||||
alert.setHeaderText("A valid URL for Broadcastify is required");
|
||||
alert.initOwner(getTestButton().getScene().getWindow());
|
||||
alert.show();
|
||||
return;
|
||||
}
|
||||
|
||||
BroadcastifyCallConfiguration configToTest = new BroadcastifyCallConfiguration();
|
||||
configToTest.setSystemID(systemID);
|
||||
configToTest.setApiKey(apiKey);
|
||||
configToTest.setHost(host);
|
||||
|
||||
String result = BroadcastifyCallBroadcaster.testConnection(configToTest);
|
||||
|
||||
if(result == null)
|
||||
if(result != null && result.toLowerCase().startsWith("ok"))
|
||||
{
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Test successful.",
|
||||
ButtonType.OK);
|
||||
alert.setTitle("Test Connection");
|
||||
alert.setTitle("Test Result");
|
||||
alert.setHeaderText("Success!");
|
||||
alert.initOwner(getTestButton().getScene().getWindow());
|
||||
alert.show();
|
||||
@@ -212,9 +294,19 @@ public class BroadcastifyCallEditor extends AbstractBroadcastEditor<Broadcastify
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR, "Error: " + result,
|
||||
ButtonType.OK);
|
||||
alert.setTitle("Test Connection");
|
||||
String message = null;
|
||||
|
||||
if(result != null && result.toLowerCase().startsWith("1 invalid-api-key"))
|
||||
{
|
||||
message = "Invalid API Key";
|
||||
}
|
||||
else if(result != null && result.toLowerCase().startsWith("1 api-key-access-denied"))
|
||||
{
|
||||
message = "Invalid System ID";
|
||||
}
|
||||
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR, "Error: " + message, ButtonType.OK);
|
||||
alert.setTitle("Test Result");
|
||||
alert.setHeaderText("Test Failed.");
|
||||
alert.initOwner(getTestButton().getScene().getWindow());
|
||||
alert.show();
|
||||
|
||||
@@ -51,8 +51,6 @@ public abstract class IcecastStreamEditor extends AbstractStreamEditor<IcecastCo
|
||||
@Override
|
||||
public void setItem(IcecastConfiguration item)
|
||||
{
|
||||
super.setItem(item);
|
||||
|
||||
getMountPointTextField().setDisable(item == null);
|
||||
getUserNameTextField().setDisable(item == null);
|
||||
getDescriptionTextField().setDisable(item == null);
|
||||
@@ -76,7 +74,7 @@ public abstract class IcecastStreamEditor extends AbstractStreamEditor<IcecastCo
|
||||
getURLTextField().setText(null);
|
||||
}
|
||||
|
||||
modifiedProperty().set(false);
|
||||
super.setItem(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -476,9 +476,6 @@ public class StreamingEditor extends SplitPane
|
||||
setText(type.toString());
|
||||
mBroadcastServerType = type;
|
||||
|
||||
//Temporary disable until we receive a production API key for broadcastify calls api
|
||||
setDisable(mBroadcastServerType == BroadcastServerType.BROADCASTIFY_CALL);
|
||||
|
||||
setOnAction(event -> {
|
||||
BroadcastConfiguration config = BroadcastFactory.getConfiguration(mBroadcastServerType, BroadcastFormat.MP3);
|
||||
ConfiguredBroadcast configuredBroadcast = mPlaylistManager.getBroadcastModel()
|
||||
|
||||
Reference in New Issue
Block a user