Do not use net-config to launch mdnsd 99/279899/1
authorAnjali Nijhara <a.nijhara@samsung.com>
Thu, 18 Aug 2022 05:36:55 +0000 (11:06 +0530)
committerAnjali Nijhara <a.nijhara@samsung.com>
Thu, 18 Aug 2022 05:36:55 +0000 (11:06 +0530)
Change-Id: I2aa58a2fa6072ad55d589ffce6aeb522b4856377

packaging/capi-network-nsd.spec
src/dns-sd/dns-sd.c
tests/include/nsd-mock-switch.h [deleted file]
tests/mock/nsd-mock-gdbus.c [deleted file]

index bad8279d0ee4bfdea00a8ffc62a0581796c0ea60..a158c3e3b1158f11f47f41d83d8c7bb6a4e66f30 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-network-nsd
 Summary:    A Network Service Discovery libraries in Native API
-Version:    0.1.2
+Version:    0.1.3
 Release:    2
 Group:      System/Network
 License:    Apache-2.0
index c455f1a1355af6a20fb69b5ce4d02ee794745334..2506e032fa568f24b40cd25013a0800071778974 100644 (file)
@@ -63,7 +63,6 @@
 static GSList *dnssd_handle_list = NULL;
 static GSList *resolve_handle_list = NULL;
 static bool g_is_init = false;
-static GDBusConnection *netconfig_bus = NULL;
 
 static pthread_mutex_t dnssd_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 
@@ -248,60 +247,6 @@ static void __dnssd_set_initialized(bool initialized)
        g_is_init = initialized;
 }
 
-static int __connect_netconfig_gdbus(void)
-{
-       GError *g_error = NULL;
-       GVariant *params;
-       GVariant *result = NULL;
-       const gchar *name;
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
-       g_type_init();
-#endif
-       netconfig_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &g_error);
-       if (netconfig_bus == NULL) {
-               if (g_error != NULL) {
-                       DNSSD_LOGE("Couldn't connect to system bus "
-                                       "error [%d: %s]", g_error->code, g_error->message);
-                       g_error_free(g_error);
-               }
-               return DNSSD_ERROR_OPERATION_FAILED;
-       }
-
-       name = g_dbus_connection_get_unique_name(netconfig_bus);
-       DNSSD_LOGD("Unique DBUS Name %s", name);
-       params = g_variant_new("(s)", name);
-       result = g_dbus_connection_call_sync(netconfig_bus,
-                       NETCONFIG_SERVICE,
-                       NETCONFIG_NETWORK_PATH,
-                       NETCONFIG_NETWORK_INTERFACE,
-                       NETCONFIG_NETWORK_LAUNCHMDNS,
-                       params,
-                       NULL,
-                       G_DBUS_CALL_FLAGS_NONE,
-                       DBUS_REPLY_TIMEOUT,
-                       NULL,
-                       &g_error);
-
-       g_variant_unref(result);
-
-       if (g_error != NULL) {
-               DNSSD_LOGE("g_dbus_connection_call_sync() failed. "
-                               "error [%d: %s]", g_error->code, g_error->message);
-               g_error_free(g_error);
-               return DNSSD_ERROR_OPERATION_FAILED;
-       }
-
-       DNSSD_LOGD("Successfully launched mdnsresponder");
-       return DNSSD_ERROR_NONE;
-}
-
-static void __disconnect_netconfig_gdbus(void)
-{
-       g_object_unref(netconfig_bus);
-       netconfig_bus = NULL;
-}
-
 static gboolean __dnssd_process_result(GIOCondition condition, DNSServiceRef sd_ref)
 {
        DNSServiceErrorType err;
@@ -415,7 +360,6 @@ static void __dnssd_resolve_data_add_event_handler(guint *watch_id, resolve_repl
 EXPORT_API int dnssd_initialize(void)
 {
        __DNSSD_LOG_FUNC_ENTER__;
-       int res = 0;
 
        CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE);
        DNSSD_LOCK;
@@ -427,14 +371,6 @@ EXPORT_API int dnssd_initialize(void)
                return DNSSD_ERROR_INVALID_OPERATION;
        }
 
-       res = __connect_netconfig_gdbus();
-       if (res != DNSSD_ERROR_NONE) {
-               DNSSD_LOGE("Failed to launch mdnsresponder");
-               DNSSD_UNLOCK;
-               __DNSSD_LOG_FUNC_EXIT__;
-               return res;
-       }
-
        __dnssd_set_initialized(true);
 
        DNSSD_UNLOCK;
@@ -453,8 +389,6 @@ EXPORT_API int dnssd_deinitialize(void)
 
        __dnssd_set_initialized(false);
 
-       __disconnect_netconfig_gdbus();
-
        DNSSD_UNLOCK;
        __DNSSD_LOG_FUNC_EXIT__;
        return DNSSD_ERROR_NONE;
diff --git a/tests/include/nsd-mock-switch.h b/tests/include/nsd-mock-switch.h
deleted file mode 100644 (file)
index 1a47fbf..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright (c) 2020 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-#ifndef _NSD_MOCK_SWTICH_H_
-#define _NSD_MOCK_SWTICH_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void nsd_mock_dnssd_register_set_g_dbus_get_sync_failure(gboolean failure);
-gboolean nsd_mock_dnssd_register_get_g_dbus_get_sync_failure(void);
-void nsd_mock_dnssd_register_set_g_dbus_connection_call_sync_failure(gboolean failure);
-gboolean nsd_mock_dnssd_register_get_g_dbus_connection_call_sync_failure(void);
-#ifdef __cplusplus
-}
-#endif
-#endif //  _ASSERT_H_
diff --git a/tests/mock/nsd-mock-gdbus.c b/tests/mock/nsd-mock-gdbus.c
deleted file mode 100644 (file)
index 1c0182e..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// Copyright (c) 2020 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-const gchar *netconfig_mock_gdbus_unique_name = "temporal_name";
-
-static GDBusConnection *get_uninitialized_connection(GBusType bus_type,
-               GCancellable  *cancellable,
-               GError **error)
-{
-       GDBusConnection *ret;
-       ret = NULL;
-
-       ret = g_object_new(G_TYPE_DBUS_CONNECTION,
-                       "address", "temporal_address",
-                       "flags", G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
-                       G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
-                       "exit-on-close", TRUE,
-                       NULL);
-
-       return ret;
-}
-
-API GDBusConnection *g_bus_get_sync(GBusType bus_type, GCancellable *cancellable, GError **error)
-{
-               return get_uninitialized_connection(bus_type, cancellable, error);
-}
-
-API const gchar *g_dbus_connection_get_unique_name(GDBusConnection *connection)
-{
-       return netconfig_mock_gdbus_unique_name;
-}
-
-API GVariant *g_dbus_connection_call_sync(GDBusConnection *connection,
-               const gchar *bus_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *method_name,
-               GVariant *parameters,
-               const GVariantType *reply_type,
-               GDBusCallFlags flags,
-               gint timeout_msec,
-               GCancellable *cancellable,
-               GError **error)
-{
-       *error = NULL;
-       return g_variant_new_string("Haha this is mockup\n");
-}