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
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;
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;
EXPORT_API int dnssd_initialize(void)
{
__DNSSD_LOG_FUNC_ENTER__;
- int res = 0;
CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE);
DNSSD_LOCK;
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;
__dnssd_set_initialized(false);
- __disconnect_netconfig_gdbus();
-
DNSSD_UNLOCK;
__DNSSD_LOG_FUNC_EXIT__;
return DNSSD_ERROR_NONE;
+++ /dev/null
-//
-// 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_
+++ /dev/null
-//
-// 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");
-}