connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: connman@lists.linux.dev
Cc: Daniel Wagner <wagi@monom.org>
Subject: [PATCH v1 1/2] service: Move wispr start code into helper
Date: Sun, 29 Aug 2021 21:53:20 +0200	[thread overview]
Message-ID: <20210829195321.23396-2-wagi@monom.org> (raw)
In-Reply-To: <20210829195321.23396-1-wagi@monom.org>

We want to be able to extend the functionally around the
__connman_service_wispr_start() code. Instead having to update the
open code part for IPv4 and IPv6 handling, let's move into a small
helper.
---
 src/service.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/service.c b/src/service.c
index a5a5cfde30fd..237c88e15506 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1595,6 +1595,19 @@ bool __connman_service_index_is_default(int index)
 	return __connman_service_get_index(service) == index;
 }
 
+static void start_wispr_when_connected(struct connman_service *service)
+{
+	if (__connman_service_is_connected_state(service,
+			CONNMAN_IPCONFIG_TYPE_IPV4))
+		__connman_service_wispr_start(service,
+					CONNMAN_IPCONFIG_TYPE_IPV4);
+
+	if (__connman_service_is_connected_state(service,
+			CONNMAN_IPCONFIG_TYPE_IPV6))
+		__connman_service_wispr_start(service,
+					CONNMAN_IPCONFIG_TYPE_IPV6);
+}
+
 static void default_changed(void)
 {
 	struct connman_service *service = connman_service_get_default();
@@ -1619,15 +1632,7 @@ static void default_changed(void)
 				connman_setting_get_bool("AllowDomainnameUpdates"))
 			__connman_utsname_set_domainname(service->domainname);
 
-		if (__connman_service_is_connected_state(service,
-						CONNMAN_IPCONFIG_TYPE_IPV4))
-			__connman_service_wispr_start(service,
-						CONNMAN_IPCONFIG_TYPE_IPV4);
-
-		if (__connman_service_is_connected_state(service,
-						CONNMAN_IPCONFIG_TYPE_IPV6))
-			__connman_service_wispr_start(service,
-						CONNMAN_IPCONFIG_TYPE_IPV6);
+		start_wispr_when_connected(service);
 
 		/*
 		 * Connect VPN automatically when new default service
@@ -3726,13 +3731,7 @@ static DBusMessage *set_property(DBusConnection *conn,
 		nameserver_add_all(service, CONNMAN_IPCONFIG_TYPE_ALL);
 		dns_configuration_changed(service);
 
-		if (__connman_service_is_connected_state(service,
-						CONNMAN_IPCONFIG_TYPE_IPV4))
-			__connman_service_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV4);
-
-		if (__connman_service_is_connected_state(service,
-						CONNMAN_IPCONFIG_TYPE_IPV6))
-			__connman_service_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV6);
+		start_wispr_when_connected(service);
 
 		service_save(service);
 	} else if (g_str_equal(name, "Timeservers.Configuration")) {
-- 
2.32.0


  reply	other threads:[~2021-08-29 19:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-29 19:53 [PATCH v1 0/2] Disable online check for real Daniel Wagner
2021-08-29 19:53 ` Daniel Wagner [this message]
2021-08-29 19:53 ` [PATCH v1 2/2] service: Do not trigger wispr start when EnableOnlineCheck is disabled Daniel Wagner
2021-08-29 20:08   ` Страхиња Радић
2021-08-30  6:44     ` Daniel Wagner
2021-08-30 10:34       ` Страхиња Радић
2021-08-30 11:02         ` Страхиња Радић
2021-08-30 14:29           ` Daniel Wagner
2021-08-30 16:32 ` [PATCH v1 0/2] Disable online check for real Daniel Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210829195321.23396-2-wagi@monom.org \
    --to=wagi@monom.org \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).