Search in sources :

Example 1 with DeviceConfiguration

use of net.pms.configuration.DeviceConfiguration in project UniversalMediaServer by UniversalMediaServer.

the class UPNPHelper method rendererFound.

@Override
protected Renderer rendererFound(Device d, String uuid) {
    // Create or retrieve an instance
    try {
        InetAddress socket = InetAddress.getByName(getURL(d).getHost());
        DeviceConfiguration r = (DeviceConfiguration) RendererConfiguration.getRendererConfigurationBySocketAddress(socket);
        RendererConfiguration ref = configuration.isRendererForceDefault() ? null : RendererConfiguration.getRendererConfigurationByUPNPDetails(getDeviceDetailsString(d));
        if (r != null && !r.isUpnpAllowed()) {
            LOGGER.debug("Upnp service is {} for \"{}\"", r.getUpnpModeString(), r);
            return null;
        } else if (r == null && ref != null && !ref.isUpnpAllowed()) {
            LOGGER.debug("Upnp service is {} for {} devices", ref.getUpnpModeString(), ref);
            return null;
        }
        // FIXME: when UpnpDetailsSearch is missing from the conf a upnp-advertising
        // renderer could register twice if the http server sees it first
        boolean distinct = r != null && StringUtils.isNotBlank(r.getUUID()) && !uuid.equals(r.getUUID());
        if (!distinct && r != null && (r.matchUPNPDetails(getDeviceDetailsString(d)) || !r.loaded)) {
            // Already seen by the http server
            if (ref != null && !ref.getUpnpDetailsString().equals(r.getUpnpDetailsString()) && ref.getLoadingPriority() >= r.getLoadingPriority()) {
                // The upnp-matched reference conf is different from the previous
                // http-matched conf and has equal or higher priority, so update.
                LOGGER.debug("Switching to preferred renderer: " + ref);
                r.inherit(ref);
            }
            // Update if we have a custom configuration for this uuid
            r.setUUID(uuid);
            // Make sure it's mapped
            rendererMap.put(uuid, "0", r);
            r.details = getDeviceDetails(d);
            // Update gui
            PMS.get().updateRenderer(r);
            LOGGER.debug("Found upnp service for \"{}\" with dlna details: {}", r, r.details);
        } else {
            // It's brand new
            r = (DeviceConfiguration) rendererMap.get(uuid, "0");
            if (ref != null) {
                r.inherit(ref);
            } else {
                // It's unrecognized: temporarily assign the default renderer but mark it as unloaded
                // so actual recognition can happen later once the http server receives a request.
                // This is to allow initiation of upnp playback before http recognition has occurred.
                r.inherit(r.getDefaultConf());
                r.loaded = false;
                LOGGER.debug("Marking upnp renderer \"{}\" at {} as unrecognized", r, socket);
            }
            if (r.associateIP(socket)) {
                r.details = getDeviceDetails(d);
                PMS.get().setRendererFound(r);
                LOGGER.debug("New renderer found: \"{}\" with dlna details: {}", r, r.details);
            }
        }
        return r;
    } catch (Exception e) {
        LOGGER.debug("Error initializing device " + getFriendlyName(d) + ": " + e);
        e.printStackTrace();
    }
    return null;
}
Also used : RendererConfiguration(net.pms.configuration.RendererConfiguration) DeviceConfiguration(net.pms.configuration.DeviceConfiguration) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with DeviceConfiguration

use of net.pms.configuration.DeviceConfiguration in project UniversalMediaServer by UniversalMediaServer.

the class DbgPacker method poll.

private void poll() {
    // call the client callbacks
    for (ExternalListener listener : ExternalFactory.getExternalListeners()) {
        if (listener instanceof DebugPacker) {
            LOGGER.debug("Found client {}", listener.name());
            Object obj = ((DebugPacker) listener).dbgpack_cb();
            if (obj instanceof String) {
                add(((String) obj).split(","));
            } else if (obj instanceof String[]) {
                add((String[]) obj);
            }
        }
    }
    PmsConfiguration configuration = PMS.getConfiguration();
    // check dbgpack property in UMS.conf
    LOGGER.debug("Checking dbgpack property in UMS.conf");
    String f = (String) configuration.getCustomProperty("dbgpack");
    if (f != null) {
        add(f.split(","));
    }
    // add confs of connected renderers
    for (RendererConfiguration r : RendererConfiguration.getConnectedRenderersConfigurations()) {
        add(r.getFile());
        if (((DeviceConfiguration) r).isCustomized()) {
            add(((DeviceConfiguration) r).getParentFile());
        }
    }
    // add core items with the default logfile last (LinkedHashMap preserves insertion order)
    String profileDirectory = configuration.getProfileDirectory();
    // add virtual folders file if it exists
    String vfolders = configuration.getVirtualFoldersFile(null);
    if (StringUtils.isNotEmpty(vfolders)) {
        add(new File(profileDirectory, vfolders));
    }
    add(new File(profileDirectory, "WEB.conf"));
    add(new File(configuration.getProfilePath()));
    if (defaultLogFile != null && !defaultLogFile.isEmpty()) {
        add(new File(defaultLogFile + ".prev"));
        add(new File(defaultLogFile));
    }
}
Also used : PmsConfiguration(net.pms.configuration.PmsConfiguration) RendererConfiguration(net.pms.configuration.RendererConfiguration) DebugPacker(net.pms.external.DebugPacker) ExternalListener(net.pms.external.ExternalListener) DeviceConfiguration(net.pms.configuration.DeviceConfiguration) File(java.io.File)

Example 3 with DeviceConfiguration

use of net.pms.configuration.DeviceConfiguration in project UniversalMediaServer by UniversalMediaServer.

the class RendererPanel method customizeButton.

public JButton customizeButton() {
    final CustomJButton open = new CustomJButton("+", MetalIconFactory.getTreeLeafIcon());
    open.setHorizontalTextPosition(JButton.CENTER);
    open.setForeground(Color.lightGray);
    open.setToolTipText(Messages.getString("RendererPanel.5"));
    open.setFocusPainted(false);
    open.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            DeviceConfiguration d = (DeviceConfiguration) renderer;
            File f = chooseConf(d.getDeviceDir(), d.getDefaultFilename(d));
            if (f != null) {
                File file = DeviceConfiguration.createDeviceFile(d, f.getName(), true);
                buildEditBar(true);
                try {
                    java.awt.Desktop.getDesktop().open(file);
                } catch (IOException ioe) {
                    LOGGER.debug("Failed to open default desktop application: " + ioe);
                }
            }
        }
    });
    return open;
}
Also used : CustomJButton(net.pms.newgui.components.CustomJButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IOException(java.io.IOException) DeviceConfiguration(net.pms.configuration.DeviceConfiguration) File(java.io.File)

Aggregations

DeviceConfiguration (net.pms.configuration.DeviceConfiguration)3 File (java.io.File)2 IOException (java.io.IOException)2 RendererConfiguration (net.pms.configuration.RendererConfiguration)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 PmsConfiguration (net.pms.configuration.PmsConfiguration)1 DebugPacker (net.pms.external.DebugPacker)1 ExternalListener (net.pms.external.ExternalListener)1 CustomJButton (net.pms.newgui.components.CustomJButton)1