Use GUPnP 1.6 API

This commit is contained in:
David King 2022-12-09 23:36:53 +00:00
parent 40aff6c375
commit 3a1474fb76
2 changed files with 927 additions and 16 deletions

View File

@ -0,0 +1,910 @@
From d0ecd7812b5c99e5f31fba0a707724c1dce1f94a Mon Sep 17 00:00:00 2001
From: Andre Klapper <a9016009@gmx.de>
Date: Thu, 24 Dec 2020 23:55:43 +0100
Subject: [PATCH 01/12] DOAP: Replace non-working email address of rburton
---
gupnp-igd.doap | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gupnp-igd.doap b/gupnp-igd.doap
index 2640b7a..99f7b01 100644
--- a/gupnp-igd.doap
+++ b/gupnp-igd.doap
@@ -33,7 +33,7 @@ This is a library to handle UPnP IGD port mapping.</description>
<maintainer>
<foaf:Person>
<foaf:name>Ross Burton</foaf:name>
- <foaf:mbox rdf:resource="mailto:ross.burton@intel.com" />
+ <foaf:mbox rdf:resource="mailto:ross@burtonini.com" />
<gnome:userid>rburton</gnome:userid>
</foaf:Person>
</maintainer>
--
2.38.1
From bd6b38956ef22cba2cb0f1c49a87915fff1addcf Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Wed, 17 Mar 2021 23:51:51 +0100
Subject: [PATCH 02/12] Retire Ross as maintainer
Thanks for all the fish
---
gupnp-igd.doap | 7 -------
1 file changed, 7 deletions(-)
diff --git a/gupnp-igd.doap b/gupnp-igd.doap
index 99f7b01..dd321eb 100644
--- a/gupnp-igd.doap
+++ b/gupnp-igd.doap
@@ -30,13 +30,6 @@ This is a library to handle UPnP IGD port mapping.</description>
<gnome:userid>zeeshanak</gnome:userid>
</foaf:Person>
</maintainer>
- <maintainer>
- <foaf:Person>
- <foaf:name>Ross Burton</foaf:name>
- <foaf:mbox rdf:resource="mailto:ross@burtonini.com" />
- <gnome:userid>rburton</gnome:userid>
- </foaf:Person>
- </maintainer>
<maintainer>
<foaf:Person>
<foaf:name>Olivier Crête</foaf:name>
--
2.38.1
From 2c413bbd8b9afc41648f21ad173f0caf81a5f98b Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Thu, 13 Jan 2022 07:40:09 +0100
Subject: [PATCH 03/12] Test: Interact with service in its context
Otherwise it there is a data race in notification handling since GUPnP
instances are not safe to be used from multiple threads at the same time.
---
tests/gtest/gupnp-simple-igd.c | 37 +++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/tests/gtest/gupnp-simple-igd.c b/tests/gtest/gupnp-simple-igd.c
index 6e62fea..4e689ef 100644
--- a/tests/gtest/gupnp-simple-igd.c
+++ b/tests/gtest/gupnp-simple-igd.c
@@ -182,12 +182,28 @@ delete_port_mapping_cb (GUPnPService *service,
g_source_attach (src, g_main_context_get_thread_default ());
}
+typedef struct _MappedData {
+ GMainContext *context;
+ const char *ip_address;
+ guint port;
+} MappedData;
+
+gboolean service_notify (gpointer user_data) {
+ MappedData *d = (MappedData *) user_data;
+ gupnp_service_notify (GUPNP_SERVICE (ipservice),
+ "ExternalIPAddress", G_TYPE_STRING, d->ip_address, NULL);
+
+ return G_SOURCE_REMOVE;
+}
+
static void
mapped_external_port_cb (GUPnPSimpleIgd *igd, gchar *proto,
gchar *external_ip, gchar *replaces_external_ip, guint external_port,
gchar *local_ip, guint local_port, gchar *description, gpointer user_data)
{
- guint requested_external_port = GPOINTER_TO_UINT (user_data);
+
+ MappedData *d = (MappedData *) user_data;
+ guint requested_external_port = d->port;
g_assert (invalid_ip == NULL);
@@ -218,13 +234,13 @@ mapped_external_port_cb (GUPnPSimpleIgd *igd, gchar *proto,
}
else
{
- if (!strcmp (external_ip, IP_ADDRESS_FIRST))
- gupnp_service_notify (GUPNP_SERVICE (ipservice),
- "ExternalIPAddress", G_TYPE_STRING, IP_ADDRESS_SECOND, NULL);
- else if (!strcmp (external_ip, PPP_ADDRESS_FIRST))
- gupnp_service_notify (GUPNP_SERVICE (pppservice),
- "ExternalIPAddress", G_TYPE_STRING, PPP_ADDRESS_SECOND, NULL);
- else
+ if (!strcmp (external_ip, IP_ADDRESS_FIRST)) {
+ d->ip_address = IP_ADDRESS_SECOND;
+ g_main_context_invoke(d->context, service_notify, d);
+ } else if (!strcmp (external_ip, PPP_ADDRESS_FIRST)) {
+ d->ip_address = PPP_ADDRESS_SECOND;
+ g_main_context_invoke(d->context, service_notify, d);
+ } else
g_assert_not_reached ();
}
}
@@ -333,9 +349,12 @@ run_gupnp_simple_igd_test (GMainContext *mainctx, GUPnPSimpleIgd *igd,
gupnp_root_device_set_available (dev, TRUE);
+ MappedData d;
+ d.context = mainctx;
+ d.port = requested_port;
g_signal_connect (igd, "mapped-external-port",
- G_CALLBACK (mapped_external_port_cb), GUINT_TO_POINTER (requested_port));
+ G_CALLBACK (mapped_external_port_cb), &d);
g_signal_connect (igd, "error-mapping-port",
G_CALLBACK (error_mapping_port_cb), NULL);
--
2.38.1
From bbe36b279e247cd8ec4ab00bcdf02178af8a99af Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Thu, 13 Jan 2022 07:42:31 +0100
Subject: [PATCH 04/12] Remove obsolete host_path in test
gupnp_root_device_new will do this automatically, actually does for
quite some time now (pre 1.0)
---
tests/gtest/gupnp-simple-igd.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/tests/gtest/gupnp-simple-igd.c b/tests/gtest/gupnp-simple-igd.c
index 4e689ef..593c46e 100644
--- a/tests/gtest/gupnp-simple-igd.c
+++ b/tests/gtest/gupnp-simple-igd.c
@@ -302,13 +302,6 @@ run_gupnp_simple_igd_test (GMainContext *mainctx, GUPnPSimpleIgd *igd,
if (g_getenv ("XML_PATH"))
xml_path = g_getenv ("XML_PATH");
- gupnp_context_host_path (context, xml_path, "");
-
- /*
- gupnp_context_host_path (context, "InternetGatewayDevice.xml", "/InternetGatewayDevice.xml");
- gupnp_context_host_path (context, "WANIPConnection.xml", "/WANIPConnection.xml");
- gupnp_context_host_path (context, "WANPPPConnection.xml", "/WANPPPConnection.xml");
- */
dev = gupnp_root_device_new (context, "InternetGatewayDevice.xml", xml_path, &error);
g_assert (dev);
--
2.38.1
From 649b7100339c57531a8e31f69220f8e17f0860e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@collabora.com>
Date: Tue, 24 May 2022 17:40:34 -0400
Subject: [PATCH 05/12] Add subproject for gupnp itself
---
subprojects/.gitignore | 3 +++
subprojects/gupnp-1.2.wrap | 4 ++++
2 files changed, 7 insertions(+)
create mode 100644 subprojects/.gitignore
create mode 100644 subprojects/gupnp-1.2.wrap
diff --git a/subprojects/.gitignore b/subprojects/.gitignore
new file mode 100644
index 0000000..357f586
--- /dev/null
+++ b/subprojects/.gitignore
@@ -0,0 +1,3 @@
+gupnp-1.2
+gi-docgen*
+gssdp-1.2*
diff --git a/subprojects/gupnp-1.2.wrap b/subprojects/gupnp-1.2.wrap
new file mode 100644
index 0000000..7fa58e1
--- /dev/null
+++ b/subprojects/gupnp-1.2.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+url = https://gitlab.gnome.org/GNOME/gupnp.git
+revision = gupnp-1.4
+depth = 1
--
2.38.1
From 7ea89a4cf94feadfb6ed49381502f5484346fdf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@collabora.com>
Date: Tue, 24 May 2022 17:44:37 -0400
Subject: [PATCH 06/12] Add gitlab-ci copied from gupnp
---
.gitlab-ci.yml | 195 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
create mode 100644 .gitlab-ci.yml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..bb38f26
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,195 @@
+include:
+ - remote: "https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/290b79e0e78eab67a83766f4e9691be554fc4afd/templates/ci-fairy.yml"
+ - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/290b79e0e78eab67a83766f4e9691be554fc4afd/templates/fedora.yml'
+
+variables:
+ MESON_TEST_TIMEOUT_MULTIPLIER: 3
+
+stages:
+ - review
+ - prepare
+ - build
+ - test
+ - analysis
+ - website
+
+.check-template: &check
+ extends:
+ - .fdo.ci-fairy
+ artifacts:
+ expire_in: 1 week
+ paths:
+ - check-junit-report.xml
+ reports:
+ junit: check-junit-report.xml
+
+check-commit-log:
+ variables:
+ GIT_DEPTH: "100"
+ stage: review
+ script:
+ - if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ;
+ then
+ ci-fairy check-commits --junit-xml=check-junit-report.xml ;
+ else
+ echo "Not a merge request" ;
+ fi
+ <<: *check
+
+check-merge-request:
+ variables:
+ GIT_STRATEGY: none
+ stage: review
+ script:
+ - if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ;
+ then
+ ci-fairy check-merge-request --require-allow-collaboration --junit-xml=check-junit-report.xml ;
+ else
+ echo "Not a merge request" ;
+ fi
+ <<: *check
+
+.build-template: &build
+ stage: build
+ script:
+ - meson . build --prefix=/usr -Db_coverage=true
+ - ninja -C build
+ artifacts:
+ expire_in: 1 day
+ paths:
+ - build
+
+.gupnp.fedora@common:
+ variables:
+ BASE_TAG: '2021-08-14.0'
+ FDO_UPSTREAM_REPO: GNOME/gupnp-igd
+ FDO_DISTRIBUTION_PACKAGES: 'clang clang-analyzer gcovr git libasan libubsan python3-gobject python3-pip xmlto gobject-introspection-devel gtk-doc libsoup-devel libuuid-devel libxml2-devel vala ninja-build'
+ FDO_DISTRIBUTION_EXEC: |
+ dnf clean all &&
+ pip3 install meson markdown toml typogrify
+
+.gupnp.fedora:34@x86_64:
+ extends: .gupnp.fedora@common
+ variables:
+ FDO_DISTRIBUTION_VERSION: 34
+ FDO_DISTRIBUTION_TAG: "x86_64-${BASE_TAG}"
+
+build-fedora-container@x86_64:
+ extends:
+ - .fdo.container-build@fedora
+ - .gupnp.fedora:34@x86_64
+ stage: prepare
+ variables:
+ GIT_STRATEGY: none
+
+
+build-fedora@x86_64:
+ extends:
+ - .fdo.distribution-image@fedora
+ - .gupnp.fedora:34@x86_64
+ needs:
+ - build-fedora-container@x86_64
+ <<: *build
+
+
+.test-template: &test
+ stage: test
+ variables:
+ G_SLICE: "always-malloc"
+ MALLOC_CHECK_: "3"
+ script:
+ - cd build
+ - |
+ # Remove the many "CI_" variables from the environment. Meson dumps the
+ # whole environment for every failed test, and that gives a whole
+ # screenful of junk each time unless we strip these.
+ unset $(env|grep -o '^CI_[^=]*')
+ env LANG=C.UTF-8 LC_ALL=C.UTF-8 meson test --print-errorlogs ${MESON_TEST_EXTRA_ARGS}
+ after_script:
+ - |
+ echo "Distribution: "
+ echo
+ egrep '^NAME=|^VERSION=' /etc/os-release
+ echo
+ echo "Test suite settings:"
+ echo
+ echo "G_MESSAGES_DEBUG: ${G_MESSAGES_DEBUG}"
+ echo "MESON_TEST_EXTRA_ARGS: ${MESON_TEST_EXTRA_ARGS}"
+ echo
+ echo "These values can be set at https://gitlab.gnome.org/GNOME/gupnp-igd/pipelines/new"
+ artifacts:
+ expire_in: 1 day
+ when: always
+ paths:
+ - build
+ reports:
+ junit: "build/meson-logs/testlog.junit.xml"
+
+test-fedora@x86_64:
+ extends:
+ - .fdo.distribution-image@fedora
+ - .gupnp.fedora:34@x86_64
+ needs:
+ - build-fedora@x86_64
+ <<: *test
+
+ #trigger-rygel:
+ #stage: analysis
+ #needs:
+ # - test-fedora@x86_64
+ #trigger: GNOME/rygel
+ #only:
+ # - master
+
+coverage-analysis:
+ extends:
+ - .fdo.distribution-image@fedora
+ - .gupnp.fedora:34@x86_64
+ stage: analysis
+ allow_failure: true
+ script:
+ - cd build
+ - mkdir -p coveragereport
+ - gcovr --html-details --print-summary --root=.. --exclude=../build --exclude=../subprojects --exclude=../docs/reference --exclude=../tests --exclude=../tools --exclude=../examples --output coveragereport/index.html
+ coverage: '/^lines: (\d+\.\d+\%)/'
+ artifacts:
+ when: always
+ paths:
+ - build/coveragereport
+ needs:
+ - test-fedora@x86_64
+
+static-scan:
+ extends:
+ - .fdo.distribution-image@fedora
+ - .gupnp.fedora:34@x86_64
+ stage: analysis
+ needs:
+ - build-fedora-container@x86_64
+ script:
+ - meson --buildtype=debug _scan_build
+ - ninja -C _scan_build scan-build
+ artifacts:
+ paths:
+ - _scan_build/meson-logs
+ allow_failure: true
+
+pages:
+ extends:
+ - .fdo.distribution-image@fedora
+ - .gupnp.fedora:34@x86_64
+ stage: website
+ script:
+ - meson doc-build -Dgtk_doc=true
+ - ninja -C doc-build gupnp-igd-doc
+ - mkdir -p public
+ - mv doc-build/doc/html public/docs
+ artifacts:
+ paths:
+ - public
+ needs:
+ - build-fedora-container@x86_64
+ only:
+ - master
+ - /^wip\/.*\/ci.*$/
+
--
2.38.1
From bb1e3ded40d346f5180831dc28e857d0d89d1f7b Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Wed, 25 May 2022 12:59:22 +0200
Subject: [PATCH 07/12] ci: Bump base image to Fedore 36
---
.gitlab-ci.yml | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bb38f26..2186c11 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,6 @@
include:
- - remote: "https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/290b79e0e78eab67a83766f4e9691be554fc4afd/templates/ci-fairy.yml"
- - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/290b79e0e78eab67a83766f4e9691be554fc4afd/templates/fedora.yml'
+ - remote: "https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/0c312d9c7255f46e741d43bcd1930f09cd12efe7/templates/ci-fairy.yml"
+ - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/0c312d9c7255f46e741d43bcd1930f09cd12efe7/templates/fedora.yml'
variables:
MESON_TEST_TIMEOUT_MULTIPLIER: 3
@@ -61,23 +61,23 @@ check-merge-request:
.gupnp.fedora@common:
variables:
- BASE_TAG: '2021-08-14.0'
+ BASE_TAG: '2022-05-25.0'
FDO_UPSTREAM_REPO: GNOME/gupnp-igd
- FDO_DISTRIBUTION_PACKAGES: 'clang clang-analyzer gcovr git libasan libubsan python3-gobject python3-pip xmlto gobject-introspection-devel gtk-doc libsoup-devel libuuid-devel libxml2-devel vala ninja-build'
+ FDO_DISTRIBUTION_PACKAGES: 'clang clang-analyzer gcovr git libasan libubsan python3-gobject python3-pip xmlto gobject-introspection-devel gtk-doc libsoup3-devel libuuid-devel libxml2-devel vala ninja-build python3-setuptools'
FDO_DISTRIBUTION_EXEC: |
dnf clean all &&
- pip3 install meson markdown toml typogrify
+ pip3 install meson markdown gi-docgen jinja2 Markdown markupsafe pygments toml typogrify
-.gupnp.fedora:34@x86_64:
+.gupnp.fedora:36@x86_64:
extends: .gupnp.fedora@common
variables:
- FDO_DISTRIBUTION_VERSION: 34
+ FDO_DISTRIBUTION_VERSION: 36
FDO_DISTRIBUTION_TAG: "x86_64-${BASE_TAG}"
build-fedora-container@x86_64:
extends:
- .fdo.container-build@fedora
- - .gupnp.fedora:34@x86_64
+ - .gupnp.fedora:36@x86_64
stage: prepare
variables:
GIT_STRATEGY: none
@@ -86,7 +86,7 @@ build-fedora-container@x86_64:
build-fedora@x86_64:
extends:
- .fdo.distribution-image@fedora
- - .gupnp.fedora:34@x86_64
+ - .gupnp.fedora:36@x86_64
needs:
- build-fedora-container@x86_64
<<: *build
@@ -104,7 +104,7 @@ build-fedora@x86_64:
# whole environment for every failed test, and that gives a whole
# screenful of junk each time unless we strip these.
unset $(env|grep -o '^CI_[^=]*')
- env LANG=C.UTF-8 LC_ALL=C.UTF-8 meson test --print-errorlogs ${MESON_TEST_EXTRA_ARGS}
+ env LANG=C.UTF-8 LC_ALL=C.UTF-8 meson test --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER} --print-errorlogs ${MESON_TEST_EXTRA_ARGS}
after_script:
- |
echo "Distribution: "
@@ -128,7 +128,7 @@ build-fedora@x86_64:
test-fedora@x86_64:
extends:
- .fdo.distribution-image@fedora
- - .gupnp.fedora:34@x86_64
+ - .gupnp.fedora:36@x86_64
needs:
- build-fedora@x86_64
<<: *test
@@ -144,7 +144,7 @@ test-fedora@x86_64:
coverage-analysis:
extends:
- .fdo.distribution-image@fedora
- - .gupnp.fedora:34@x86_64
+ - .gupnp.fedora:36@x86_64
stage: analysis
allow_failure: true
script:
@@ -162,7 +162,7 @@ coverage-analysis:
static-scan:
extends:
- .fdo.distribution-image@fedora
- - .gupnp.fedora:34@x86_64
+ - .gupnp.fedora:36@x86_64
stage: analysis
needs:
- build-fedora-container@x86_64
@@ -177,7 +177,7 @@ static-scan:
pages:
extends:
- .fdo.distribution-image@fedora
- - .gupnp.fedora:34@x86_64
+ - .gupnp.fedora:36@x86_64
stage: website
script:
- meson doc-build -Dgtk_doc=true
--
2.38.1
From 79a1e4cf8c256132978a1d8ab718c8ad132386de Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Tue, 3 May 2022 22:39:16 +0200
Subject: [PATCH 08/12] Port to GUPnP 1.6 API
And thus to libsoup3. The code changes are even compatible with GUPnP
1.4.3 so the gupnp version could be a configure option
---
NEWS | 2 +-
README | 4 ++--
libgupnp-igd/meson.build | 2 +-
meson.build | 6 +++---
subprojects/.gitignore | 4 ++--
subprojects/{gupnp-1.2.wrap => gupnp-1.6.wrap} | 2 +-
tests/gtest/gupnp-simple-igd.c | 6 +++---
7 files changed, 13 insertions(+), 13 deletions(-)
rename subprojects/{gupnp-1.2.wrap => gupnp-1.6.wrap} (76%)
diff --git a/NEWS b/NEWS
index 5979f6d..eabb318 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,5 @@
*******************
-* GUPnP IGD 1.20 *
+* GUPnP IGD 1.2.0 *
*******************
- Switch to GUPnP 1.2.0 API
diff --git a/README b/README
index 4b74b6f..09884d2 100644
--- a/README
+++ b/README
@@ -1,9 +1,9 @@
This is a library to handle UPnP IGD port mapping.
-It was written by Olivier Crête <olivier.crete@collabora.co.uk>.
+It was written by Olivier Crête <olivier.crete@collabora.com>.
It is supposed to have a very simple API. Read the gtk-doc.
The only dependencies are:
- - GUPnP 1.2
+ - GUPnP 1.6
- GLib 2.38
diff --git a/libgupnp-igd/meson.build b/libgupnp-igd/meson.build
index c37ef3d..6dcd394 100644
--- a/libgupnp-igd/meson.build
+++ b/libgupnp-igd/meson.build
@@ -38,7 +38,7 @@ pkg.generate(
subdirs : 'gupnp-igd-1.0',
filebase : 'gupnp-igd-1.0',
description: 'GUPnP Simple IGD library',
- requires_private : 'gupnp-1.2'
+ requires_private : 'gupnp-1.6'
)
diff --git a/meson.build b/meson.build
index df2fb24..8377d01 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,4 @@
-project('gupnp-igd', 'c', version: '1.2.0')
+project('gupnp-igd', 'c', version: '1.5.0')
gnome = import('gnome')
pkg = import('pkgconfig')
@@ -7,8 +7,8 @@ glib_req = '>= 2.38'
dependencies = [
dependency('glib-2.0', version: glib_req, required: true),
dependency('gobject-2.0', version: glib_req, required: true),
- dependency('gupnp-1.2', version : '>= 1.2.0'),
- dependency('gssdp-1.2', version : '>= 1.2.0'),
+ dependency('gupnp-1.6', version : '>= 1.5.0'),
+ dependency('gssdp-1.6', version : '>= 1.5.0'),
dependency('gthread-2.0', required: true)
]
diff --git a/subprojects/.gitignore b/subprojects/.gitignore
index 357f586..34d47ed 100644
--- a/subprojects/.gitignore
+++ b/subprojects/.gitignore
@@ -1,3 +1,3 @@
-gupnp-1.2
+gupnp-1.6
gi-docgen*
-gssdp-1.2*
+gssdp-1.6*
diff --git a/subprojects/gupnp-1.2.wrap b/subprojects/gupnp-1.6.wrap
similarity index 76%
rename from subprojects/gupnp-1.2.wrap
rename to subprojects/gupnp-1.6.wrap
index 7fa58e1..937e841 100644
--- a/subprojects/gupnp-1.2.wrap
+++ b/subprojects/gupnp-1.6.wrap
@@ -1,4 +1,4 @@
[wrap-git]
url = https://gitlab.gnome.org/GNOME/gupnp.git
-revision = gupnp-1.4
+revision = master
depth = 1
diff --git a/tests/gtest/gupnp-simple-igd.c b/tests/gtest/gupnp-simple-igd.c
index 593c46e..ec770ca 100644
--- a/tests/gtest/gupnp-simple-igd.c
+++ b/tests/gtest/gupnp-simple-igd.c
@@ -88,7 +88,7 @@ get_external_ip_address_cb (GUPnPService *service,
else
g_assert_not_reached ();
- gupnp_service_action_return (action);
+ gupnp_service_action_return_success (action);
}
@@ -139,7 +139,7 @@ add_port_mapping_cb (GUPnPService *service,
if (return_conflict && external_port == INTERNAL_PORT)
gupnp_service_action_return_error (action, 718, "ConflictInMappingEntry");
else
- gupnp_service_action_return (action);
+ gupnp_service_action_return_success (action);
}
static gboolean
@@ -172,7 +172,7 @@ delete_port_mapping_cb (GUPnPService *service,
g_assert (external_port != INTERNAL_PORT);
g_assert (proto && !strcmp (proto, "UDP"));
- gupnp_service_action_return (action);
+ gupnp_service_action_return_success (action);
g_free (remote_host);
g_free (proto);
--
2.38.1
From 14ebe219f7279d6101fe415a32c3f2a189ba5785 Mon Sep 17 00:00:00 2001
From: Sonny Piers <sonny@fastmail.net>
Date: Sun, 14 Feb 2021 15:28:02 +0100
Subject: [PATCH 09/12] add JavaScript example
---
examples/map-port.js | 89 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
create mode 100755 examples/map-port.js
diff --git a/examples/map-port.js b/examples/map-port.js
new file mode 100755
index 0000000..f78a1be
--- /dev/null
+++ b/examples/map-port.js
@@ -0,0 +1,89 @@
+#!/usr/bin/env gjs
+//
+// Copyright (c) 2021, Sonny Piers <sonny@fastmail.net>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+
+const { GUPnPIgd, GLib } = imports.gi;
+const { system } = imports;
+
+const { SimpleIgd } = GUPnPIgd;
+const { MainLoop } = GLib;
+
+const mainloop = new MainLoop(null, false);
+
+const protocol = "TCP";
+const external_port = 0; // 0 means local_port if available otherwise random port
+const local_ip = ARGV[0];
+const local_port = ARGV[1];
+const lease_duration = 3000; // auto-renewed until port mapping is removed or process exits
+const description = "gupnp-igd JavaScript example";
+
+let exit_code = 0;
+
+if (!local_ip || !local_port) {
+ print("Usage: ./map-port.js IP PORT");
+ system.exit(1);
+}
+
+const simpleIgd = new SimpleIgd();
+simpleIgd.connect(
+ "error-mapping-port",
+ (self, error, proto, external_port, local_ip, local_port, description) => {
+ printerr(error);
+ exit_code = 1;
+ mainloop.quit();
+ }
+);
+
+simpleIgd.connect(
+ "mapped-external-port",
+ (
+ self,
+ proto,
+ external_ip,
+ replaces_external_ip,
+ external_port,
+ local_ip,
+ local_port,
+ description
+ ) => {
+ print(
+ `success ${external_ip}:${external_port} -> ${local_ip}:${local_port}`
+ );
+ }
+);
+
+simpleIgd.add_port(
+ protocol,
+ external_port,
+ local_ip,
+ local_port,
+ lease_duration,
+ description
+);
+
+mainloop.run();
+system.exit(exit_code);
--
2.38.1
From fa1546614190942ab266832e7470a6debf8c32cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@collabora.com>
Date: Sun, 6 Nov 2022 16:12:29 -0500
Subject: [PATCH 10/12] test: Port to g_inet_address_new_loopback
---
tests/gtest/gupnp-simple-igd.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/gtest/gupnp-simple-igd.c b/tests/gtest/gupnp-simple-igd.c
index ec770ca..1f30b27 100644
--- a/tests/gtest/gupnp-simple-igd.c
+++ b/tests/gtest/gupnp-simple-igd.c
@@ -290,13 +290,16 @@ run_gupnp_simple_igd_test (GMainContext *mainctx, GUPnPSimpleIgd *igd,
GUPnPDeviceInfo *subdev2;
const gchar *xml_path = ".";
GError *error = NULL;
+ GInetAddress *loopback = NULL;
g_signal_connect (igd, "context-available",
G_CALLBACK (ignore_non_localhost), NULL);
if (mainctx)
g_main_context_push_thread_default (mainctx);
- context = gupnp_context_new ("lo", 0, NULL);
+ loopback = g_inet_address_new_loopback (G_SOCKET_FAMILY_IPV4);
+ context = gupnp_context_new_for_address (loopback, 0, GSSDP_UDA_VERSION_1_0, NULL);
+ g_object_unref (loopback);
g_assert (context);
if (g_getenv ("XML_PATH"))
--
2.38.1
From 306851f79bbe9a912aad02e7fdd1c37ff6936b63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@collabora.com>
Date: Sun, 6 Nov 2022 16:05:53 -0500
Subject: [PATCH 11/12] meson: Update introspection version to 1.6
---
.gitignore | 4 ++--
libgupnp-igd/meson.build | 14 +++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/libgupnp-igd/meson.build b/libgupnp-igd/meson.build
index 6dcd394..f021221 100644
--- a/libgupnp-igd/meson.build
+++ b/libgupnp-igd/meson.build
@@ -9,7 +9,7 @@ headers = files(
'gupnp-simple-igd-thread.h'
)
-install_headers(headers, subdir: 'gupnp-igd-1.0/libgupnp-igd')
+install_headers(headers, subdir: 'gupnp-igd-1.6/libgupnp-igd')
sources = files(
'gupnp-enum-types.c',
@@ -18,7 +18,7 @@ sources = files(
)
libgupnp_igd = library(
- 'gupnp-igd-1.0',
+ 'gupnp-igd-1.6',
sources + marshal,
version: '4.2.1',
include_directories: include_directories('..'),
@@ -34,9 +34,9 @@ gupnp_igd = declare_dependency(
pkg.generate(
libraries : libgupnp_igd,
- name : 'gupnp-igd-1.0',
- subdirs : 'gupnp-igd-1.0',
- filebase : 'gupnp-igd-1.0',
+ name : 'gupnp-igd-1.6',
+ subdirs : 'gupnp-igd-1.6',
+ filebase : 'gupnp-igd-1.6',
description: 'GUPnP Simple IGD library',
requires_private : 'gupnp-1.6'
)
@@ -47,11 +47,11 @@ if get_option('introspection')
libgupnp_igd,
sources : headers + sources,
namespace : 'GUPnPIgd',
- nsversion : '1.0',
+ nsversion : '1.6',
symbol_prefix: ['gupnp'],
identifier_prefix : 'GUPnP',
install: true,
- export_packages : 'gupnp-1.0',
+ export_packages : 'gupnp-1.6',
includes : ['GObject-2.0']
)
endif
--
2.38.1
From a10bc3732e978f364319cbf7e67b71efa6b0b504 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@ocrete.ca>
Date: Tue, 22 Nov 2022 09:13:20 -0500
Subject: [PATCH 12/12] meson: Reset library version to 0
---
libgupnp-igd/meson.build | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libgupnp-igd/meson.build b/libgupnp-igd/meson.build
index f021221..158e0cb 100644
--- a/libgupnp-igd/meson.build
+++ b/libgupnp-igd/meson.build
@@ -17,10 +17,13 @@ sources = files(
'gupnp-simple-igd-thread.c'
)
+
+# Don't forget to update the 'version'
+
libgupnp_igd = library(
'gupnp-igd-1.6',
sources + marshal,
- version: '4.2.1',
+ version: '0.0.0',
include_directories: include_directories('..'),
dependencies : dependencies,
c_args : ['-D_LOG_DOMAIN=GUPnP-IGD'],
--
2.38.1

View File

@ -1,25 +1,21 @@
Name: gupnp-igd
Version: 1.2.0
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Library to handle UPnP IGD port mapping
License: LGPLv2+
URL: https://wiki.gnome.org/Projects/GUPnP
Source0: https://download.gnome.org/sources/%{name}/1.2/%{name}-%{version}.tar.xz
# https://gitlab.gnome.org/GNOME/gupnp-igd/-/merge_requests/7
# https://gitlab.gnome.org/GNOME/gupnp-igd/-/merge_requests/9
Patch0: gupnp-igd-1.2.0-gupnp-1.6.patch
BuildRequires: glib2-devel
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gupnp-1.6)
BuildRequires: gobject-introspection-devel
BuildRequires: gtk-doc
BuildRequires: gupnp-devel
BuildRequires: meson
Provides: %{name}-python = %{version}-%{release}
Provides: %{name}-python%{?_isa} = %{version}-%{release}
Obsoletes: %{name}-python < %{version}-%{release}
Provides: %{name}-python2 = %{version}-%{release}
Provides: %{name}-python2%{?_isa} = %{version}-%{release}
Obsoletes: %{name}-python2 < %{version}-%{release}
%description
%{name} is a library to handle UPnP IGD port mapping.
@ -48,24 +44,29 @@ developing applications that use %{name}.
%files
%license COPYING
%doc README
%{_libdir}/libgupnp-igd-1.0.so.4*
%doc NEWS README
%{_libdir}/libgupnp-igd-1.6.so.0*
%dir %{_libdir}/girepository-1.0
%{_libdir}/girepository-1.0/GUPnPIgd-1.0.typelib
%{_libdir}/girepository-1.0/GUPnPIgd-1.6.typelib
%files devel
%{_includedir}/*
%{_libdir}/libgupnp-igd-1.0.so
%{_libdir}/pkgconfig/%{name}-1.0*.pc
%{_libdir}/libgupnp-igd-1.6.so
%{_libdir}/pkgconfig/%{name}-1.6*.pc
%dir %{_datadir}/gtk-doc
%dir %{_datadir}/gtk-doc/html
%{_datadir}/gtk-doc/html/%{name}/
%dir %{_datadir}/gir-1.0
%{_datadir}/gir-1.0/GUPnPIgd-1.0.gir
%{_datadir}/gir-1.0/GUPnPIgd-1.6.gir
%changelog
* Tue Nov 22 2022 David King <amigadave@amigadave.com> - 1.2.0-7
- Use pkgconfig for BuildRequires
- Remove old python provides and obsoletes
- Use GUPnP 1.6 API
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild