summaryrefslogtreecommitdiff
path: root/libgupnp
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2022-08-07 19:14:04 +0200
committerJens Georg <mail@jensge.org>2022-08-07 19:14:04 +0200
commit98da362250dde377939d9d13110e2b5d6a98aee8 (patch)
tree3b397305a3b1832eee9997b08936e790cfb58c2f /libgupnp
parenta585bdffc2581c8d499b8b9890322082a74f2960 (diff)
downloadgupnp-98da362250dde377939d9d13110e2b5d6a98aee8.tar.gz
Context: Add new convenience constructors
Add new constructors that allow to set the new parameters directly, instead of forcing the use of g_object_new
Diffstat (limited to 'libgupnp')
-rw-r--r--libgupnp/gupnp-context.c70
-rw-r--r--libgupnp/gupnp-context.h18
2 files changed, 83 insertions, 5 deletions
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 7b39ed5..236c52d 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -596,9 +596,11 @@ _gupnp_context_get_server_uri (GUPnPContext *context)
* @port: Port to run on, or 0 if you don't care what port is used.
* @error: (inout)(optional)(nullable): A location to store a #GError, or %NULL
*
- * Create a new #GUPnPContext with the specified @main_context, @iface and
+ * Create a new #GUPnPContext with the specified @iface and
* @port.
*
+ * Deprecated: 1.6. Use [ctor@GUPnP.Context.new_for_address] instead
+ *
* Return value: A new #GUPnPContext object, or %NULL on an error
**/
GUPnPContext *
@@ -614,7 +616,71 @@ gupnp_context_new (const char *iface,
NULL);
}
-\
+/**
+ * gupnp_context_new_full:
+ * @iface: (nullable): the name of a network interface
+ * @addr: (nullable): an IP address or %NULL for auto-detection. If you do not
+ * care about the address, but want to specify an address family, use
+ * [ctor@Glib.InetAddress.new_any] with the appropriate family instead.
+ * @port: The network port to use for M-SEARCH requests or 0 for
+ * random.
+ * @uda_version: The UDA version this client will adhere to
+ * @error: (allow-none): Location to store error, or %NULL.
+ *
+ * Creates a GUPnP context with address @addr on network interface @iface. If
+ * neither is specified, GUPnP will chose the address it deems most suitable.
+ *
+ * Since: 1.6.
+ *
+ * Return value: (nullable): A new #GSSDPClient object or %NULL on error.
+ */
+GUPnPContext *
+gupnp_context_new_full (const char *iface,
+ GInetAddress *addr,
+ guint16 port,
+ GSSDPUDAVersion uda_version,
+ GError **error)
+{
+ return g_initable_new (GUPNP_TYPE_CONTEXT,
+ NULL,
+ error,
+ "interface",
+ iface,
+ "address",
+ addr,
+ "port",
+ port,
+ "uda-version",
+ uda_version,
+ NULL);
+}
+
+/**
+ * gupnp_context_new_for_address
+ * @addr: (nullable): an IP address or %NULL for auto-detection. If you do not
+ * care about the address, but want to specify an address family, use
+ * [ctor@Glib.InetAddress.new_any] with the appropriate family instead.
+ * @port: The network port to use for M-SEARCH requests or 0 for
+ * random.
+ * @uda_version: The UDA version this client will adhere to
+ * @error: (allow-none): Location to store error, or %NULL.
+ *
+ * Creates a GUPnP context with address @addr. If none is specified, GUPnP
+ * will chose the address it deems most suitable.
+ *
+ * Since: 1.6.
+ *
+ * Return value: (nullable): A new #GSSDPClient object or %NULL on error.
+ */
+GUPnPContext *
+gupnp_context_new_for_address (GInetAddress *addr,
+ guint16 port,
+ GSSDPUDAVersion uda_version,
+ GError **error)
+{
+ return gupnp_context_new_full (NULL, addr, port, uda_version, error);
+}
+
/**
* gupnp_context_get_port:
* @context: A #GUPnPContext
diff --git a/libgupnp/gupnp-context.h b/libgupnp/gupnp-context.h
index 79b3e30..383a563 100644
--- a/libgupnp/gupnp-context.h
+++ b/libgupnp/gupnp-context.h
@@ -41,10 +41,22 @@ struct _GUPnPContextClass {
void (* _gupnp_reserved4) (void);
};
+G_DEPRECATED_FOR(gupnp_context_new_for_address)
GUPnPContext *
-gupnp_context_new (const char *iface,
- guint port,
- GError **error);
+gupnp_context_new (const char *iface, guint port, GError **error);
+
+GUPnPContext *
+gupnp_context_new_for_address (GInetAddress *addr,
+ guint16 port,
+ GSSDPUDAVersion uda_version,
+ GError **error);
+
+GUPnPContext *
+gupnp_context_new_full (const char *iface,
+ GInetAddress *addr,
+ guint16 port,
+ GSSDPUDAVersion uda_version,
+ GError **error);
guint
gupnp_context_get_port (GUPnPContext *context);