[rygel] core,rygel,doc: Use multiple interfaces
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,rygel,doc: Use multiple interfaces
- Date: Fri, 10 May 2013 14:38:07 +0000 (UTC)
commit c27665d201675142476df72c8567587c72e7e559
Author: Jens Georg <jensg openismus com>
Date: Fri May 10 16:21:03 2013 +0200
core,rygel,doc: Use multiple interfaces
Rygel may now bind to more than any or just one interface.
data/rygel.conf | 7 ++++---
doc/man/rygel.conf.xml | 2 +-
doc/man/rygel.xml | 4 ++--
src/librygel-core/rygel-base-configuration.vala | 5 +++++
src/librygel-core/rygel-configuration.vala | 4 ++++
src/librygel-core/rygel-meta-config.vala | 22 +++++++++++++++++++++-
src/rygel/rygel-cmdline-config.vala | 23 +++++++++++++++++------
src/rygel/rygel-environment-config.vala | 5 +++++
src/rygel/rygel-main.vala | 10 +++++-----
src/rygel/rygel-user-config.vala | 5 +++++
src/ui/rygel-network-pref-section.vala | 2 +-
11 files changed, 70 insertions(+), 19 deletions(-)
---
diff --git a/data/rygel.conf b/data/rygel.conf
index 47803f8..307da12 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -26,10 +26,11 @@ picture-upload-folder= PICTURES@
# searched recursively and the first engine found is loaded.
media-engine=librygel-media-engine-gst.so
-# The network interface to attach rygel to. You can also use network IP or even
-# ESSID for wireless networks if you are using NetworkManager. Leave it blank
-# for dynamic configuration.
+# List of network interfaces to attach rygel to. You can also use network IP or
+# even ESSID for wireless networks on Linux. Leave it blank for dynamic
+# configuration.
interface=
+
# The port to run HTTP server on. 0 means dynamic.
port=0
diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml
index 1193a88..5b4e438 100644
--- a/doc/man/rygel.conf.xml
+++ b/doc/man/rygel.conf.xml
@@ -124,7 +124,7 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<option>interface=<replaceable>INTERFACE</replaceable></option>
</term>
<listitem>
- <para>Set the network-interface <application>&dhpackage;</application> listens on.</para>
+ <para>A list of the network interfaces <application>&dhpackage;</application> listens on. May be
an IP, an interface name or on Linux even the ESSID of a wireless network.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/doc/man/rygel.xml b/doc/man/rygel.xml
index d3e591f..b9f8095 100644
--- a/doc/man/rygel.xml
+++ b/doc/man/rygel.xml
@@ -151,7 +151,7 @@ handling.</para>
<option>--network-interface=<replaceable>INTERFACE</replaceable></option>
</term>
<listitem>
- <para>Set the network-interface rygel listens on.</para>
+ <para>Set the network interfaces rygel listens on. Can be used multiple times for to configure
multiple interfaces. <userinput>INTERFACE</userinput> can be an IP, a device name or an ESSID (Linux
only).</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -333,7 +333,7 @@ handling.</para>
<envar>RYGEL_IFACE</envar>
</term>
<listitem>
- <para>Set the network interface to bind to.</para>
+ <para>Set the network interfaces to bind to.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/src/librygel-core/rygel-base-configuration.vala b/src/librygel-core/rygel-base-configuration.vala
index 4be5395..830783f 100644
--- a/src/librygel-core/rygel-base-configuration.vala
+++ b/src/librygel-core/rygel-base-configuration.vala
@@ -34,6 +34,11 @@ public class Rygel.BaseConfiguration : Rygel.Configuration, Object {
throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
}
+ [CCode (array_length=false, array_null_terminated = true)]
+ public virtual string[] get_interfaces () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
+ }
+
public virtual int get_port () throws GLib.Error {
throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
}
diff --git a/src/librygel-core/rygel-configuration.vala b/src/librygel-core/rygel-configuration.vala
index 3da01e1..7f994de 100644
--- a/src/librygel-core/rygel-configuration.vala
+++ b/src/librygel-core/rygel-configuration.vala
@@ -75,8 +75,12 @@ public interface Rygel.Configuration : GLib.Object {
public abstract bool get_upnp_enabled () throws GLib.Error;
+ [Deprecated (since="0.19.2", replacement="get_interfaces")]
public abstract string get_interface () throws GLib.Error;
+ [CCode (array_length=false, array_null_terminated = true)]
+ public abstract string[] get_interfaces () throws GLib.Error;
+
public abstract int get_port () throws GLib.Error;
public abstract bool get_transcoding () throws GLib.Error;
diff --git a/src/librygel-core/rygel-meta-config.vala b/src/librygel-core/rygel-meta-config.vala
index 88d07e8..ec447a5 100644
--- a/src/librygel-core/rygel-meta-config.vala
+++ b/src/librygel-core/rygel-meta-config.vala
@@ -111,6 +111,26 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
return val;
}
+ [CCode (array_length=false, array_null_terminated = true)]
+ public string[] get_interfaces () throws GLib.Error {
+ string[] val = null;
+ bool unavailable = true;
+
+ foreach (var config in MetaConfig.configs) {
+ try {
+ val = config.get_interfaces ();
+ unavailable = false;
+ break;
+ } catch (GLib.Error error) {}
+ }
+
+ if (unavailable) {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ return val;
+ }
+
public int get_port () throws GLib.Error {
int val = 0;
bool unavailable = true;
@@ -471,7 +491,7 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
break;
case ConfigurationEntry.INTERFACE:
- config.get_interface ();
+ config.get_interfaces ();
break;
case ConfigurationEntry.PORT:
diff --git a/src/rygel/rygel-cmdline-config.vala b/src/rygel/rygel-cmdline-config.vala
index 86b0f05..acf236f 100644
--- a/src/rygel/rygel-cmdline-config.vala
+++ b/src/rygel/rygel-cmdline-config.vala
@@ -34,7 +34,9 @@ public errordomain Rygel.CmdlineConfigError {
* Manages configuration from Commandline arguments.
*/
public class Rygel.CmdlineConfig : GLib.Object, Configuration {
- private static string iface;
+ [CCode (array_length = false, array_null_terminated = true)]
+ [NoArrayLength]
+ private static string[] ifaces;
private static int port;
private static bool no_upnp;
@@ -66,10 +68,10 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
private static CmdlineConfig config;
// Command-line options
- const OptionEntry[] OPTIONS = {
+ const OptionEntry[] OPTIONS = {
{ "version", 0, 0, OptionArg.NONE, ref version,
"Display version number", null },
- { "network-interface", 'n', 0, OptionArg.STRING, ref iface,
+ { "network-interface", 'n', 0, OptionArg.STRING_ARRAY, ref ifaces,
"Network Interface", "INTERFACE" },
{ "port", 'p', 0, OptionArg.INT, ref port,
"Port", "PORT" },
@@ -102,7 +104,7 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
{ "config", 'c', 0, OptionArg.FILENAME, ref config_file,
"Use configuration file instead of user configuration", "FILE" },
{ null }
- };
+ };
public static CmdlineConfig get_default () {
if (config == null) {
@@ -145,11 +147,20 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
}
public string get_interface () throws GLib.Error {
- if (iface == null) {
+ if (ifaces == null) {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ return ifaces[0];
+ }
+
+ [CCode (array_length=false, array_null_terminated = true)]
+ public string[] get_interfaces () throws GLib.Error {
+ if (ifaces == null) {
throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
}
- return iface;
+ return ifaces;
}
public int get_port () throws GLib.Error {
diff --git a/src/rygel/rygel-environment-config.vala b/src/rygel/rygel-environment-config.vala
index 5fd5c31..c0f0249 100644
--- a/src/rygel/rygel-environment-config.vala
+++ b/src/rygel/rygel-environment-config.vala
@@ -64,6 +64,11 @@ internal class Rygel.EnvironmentConfig : GLib.Object, Configuration {
return this.get_string_variable (INTERFACE_ENV);
}
+ [CCode (array_length=false, array_null_terminated = true)]
+ public string[] get_interfaces () throws GLib.Error {
+ return this.get_string_variable (INTERFACE_ENV).split (",");
+ }
+
public int get_port () throws GLib.Error {
return this.get_int_variable (PORT_ENV, 0, int16.MAX);
}
diff --git a/src/rygel/rygel-main.vala b/src/rygel/rygel-main.vala
index ad35717..cc43ad0 100644
--- a/src/rygel/rygel-main.vala
+++ b/src/rygel/rygel-main.vala
@@ -136,7 +136,7 @@ internal class Rygel.Main : Object {
private void on_context_available (GUPnP.ContextManager manager,
GUPnP.Context context) {
- string iface = null;
+ string[] ifaces = null;
debug ("New network %s (%s) context available. IP: %s",
context.network,
@@ -144,12 +144,12 @@ internal class Rygel.Main : Object {
context.host_ip);
try {
- iface = this.config.get_interface ();
+ ifaces = this.config.get_interfaces ();
} catch (GLib.Error err) {}
- if (iface == null ||
- iface == context.interface ||
- iface == context.network) {
+ if (ifaces == null ||
+ context.interface in ifaces||
+ context.network in ifaces) {
try {
var factory = new RootDeviceFactory (context);
this.factories.add (factory);
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 1b113cd..83c6dc0 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -153,6 +153,11 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
return this.get_bool (GENERAL_SECTION, UPNP_ENABLED_KEY);
}
+ [CCode (array_length=false, array_null_terminated = true)]
+ public string[] get_interfaces () throws GLib.Error {
+ return this.get_string_list (GENERAL_SECTION, IFACE_KEY).to_array ();
+ }
+
public string get_interface () throws GLib.Error {
return this.get_string (GENERAL_SECTION, IFACE_KEY);
}
diff --git a/src/ui/rygel-network-pref-section.vala b/src/ui/rygel-network-pref-section.vala
index f6dc1a0..a7a1e36 100644
--- a/src/ui/rygel-network-pref-section.vala
+++ b/src/ui/rygel-network-pref-section.vala
@@ -40,7 +40,7 @@ public class Rygel.NetworkPrefSection : PreferencesSection {
this.context_manager = ContextManager.create (0);
try {
- this.iface_entry.append_text (config.get_interface ());
+ this.iface_entry.append_text (config.get_interfaces ()[0]);
// TODO: Set the current interface to be active.
this.iface_entry.set_active (0);
} catch (GLib.Error err) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]