libnm: remove nm_utils_init() from the public API
Remove nm_utils_init() from the public API, and just do it as a constructor instead.
This commit is contained in:
@@ -164,7 +164,6 @@ inline static void
|
|||||||
__nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains)
|
__nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains)
|
||||||
{
|
{
|
||||||
static gsize atexit_registered = 0;
|
static gsize atexit_registered = 0;
|
||||||
GError *error = NULL;
|
|
||||||
const char *nmtst_debug;
|
const char *nmtst_debug;
|
||||||
gboolean is_debug = FALSE;
|
gboolean is_debug = FALSE;
|
||||||
char *c_log_level = NULL, *c_log_domains = NULL;
|
char *c_log_level = NULL, *c_log_domains = NULL;
|
||||||
@@ -300,10 +299,6 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_
|
|||||||
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
|
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nm_utils_init (&error))
|
|
||||||
g_error ("failed to initialize libnm-util: %s", error->message);
|
|
||||||
g_assert (!error);
|
|
||||||
|
|
||||||
/* Delay messages until we setup logging. */
|
/* Delay messages until we setup logging. */
|
||||||
for (i = 0; i < debug_messages->len; i++)
|
for (i = 0; i < debug_messages->len; i++)
|
||||||
__NMTST_LOG (g_message, "%s", g_array_index (debug_messages, const char *, i));
|
__NMTST_LOG (g_message, "%s", g_array_index (debug_messages, const char *, i));
|
||||||
|
@@ -212,41 +212,29 @@ get_encodings_for_lang (const char *lang,
|
|||||||
|
|
||||||
/* init libnm */
|
/* init libnm */
|
||||||
|
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
|
||||||
static void __attribute__((constructor))
|
static void __attribute__((constructor))
|
||||||
_check_symbols (void)
|
_nm_utils_init (void)
|
||||||
{
|
{
|
||||||
GModule *self;
|
GModule *self;
|
||||||
gpointer func;
|
gpointer func;
|
||||||
|
|
||||||
|
if (initialized)
|
||||||
|
return;
|
||||||
|
initialized = TRUE;
|
||||||
|
|
||||||
self = g_module_open (NULL, 0);
|
self = g_module_open (NULL, 0);
|
||||||
if (g_module_symbol (self, "nm_util_get_private", &func))
|
if (g_module_symbol (self, "nm_util_get_private", &func))
|
||||||
g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported");
|
g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported");
|
||||||
g_module_close (self);
|
g_module_close (self);
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean initialized = FALSE;
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
|
||||||
/**
|
g_type_init ();
|
||||||
* nm_utils_init:
|
|
||||||
* @error: location to store error, or %NULL
|
|
||||||
*
|
|
||||||
* Initializes libnm; should be called when starting and program that
|
|
||||||
* uses libnm. This function can be called more than once.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if the initialization was successful, %FALSE on failure.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
nm_utils_init (GError **error)
|
|
||||||
{
|
|
||||||
if (!initialized) {
|
|
||||||
initialized = TRUE;
|
|
||||||
|
|
||||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
_nm_dbus_errors_init ();
|
||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
||||||
|
|
||||||
_nm_dbus_errors_init ();
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean _nm_utils_is_manager_process;
|
gboolean _nm_utils_is_manager_process;
|
||||||
|
@@ -39,9 +39,6 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* init libnm */
|
|
||||||
gboolean nm_utils_init (GError **error);
|
|
||||||
|
|
||||||
/* SSID helpers */
|
/* SSID helpers */
|
||||||
gboolean nm_utils_is_empty_ssid (const guint8 *ssid, gsize len);
|
gboolean nm_utils_is_empty_ssid (const guint8 *ssid, gsize len);
|
||||||
const char *nm_utils_escape_ssid (const guint8 *ssid, gsize len);
|
const char *nm_utils_escape_ssid (const guint8 *ssid, gsize len);
|
||||||
|
@@ -302,21 +302,15 @@ test_dcb_bandwidth_sums (void)
|
|||||||
|
|
||||||
#define TPATH "/libnm/settings/dcb/"
|
#define TPATH "/libnm/settings/dcb/"
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
|
||||||
gboolean success;
|
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
success = nm_utils_init (&error);
|
|
||||||
g_assert_no_error (error);
|
|
||||||
g_assert (success);
|
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION(2,34,0)
|
#if !GLIB_CHECK_VERSION(2,34,0)
|
||||||
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
|
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -101,18 +101,15 @@ test_defaults (GType type, const char *name)
|
|||||||
g_object_unref (setting);
|
g_object_unref (setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
|
||||||
char *base;
|
char *base;
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!nm_utils_init (&error))
|
|
||||||
FAIL ("nm-utils-init", "failed to initialize libnm: %s", error->message);
|
|
||||||
|
|
||||||
/* The tests */
|
/* The tests */
|
||||||
test_defaults (NM_TYPE_SETTING_CONNECTION, NM_SETTING_CONNECTION_SETTING_NAME);
|
test_defaults (NM_TYPE_SETTING_CONNECTION, NM_SETTING_CONNECTION_SETTING_NAME);
|
||||||
test_defaults (NM_TYPE_SETTING_802_1X, NM_SETTING_802_1X_SETTING_NAME);
|
test_defaults (NM_TYPE_SETTING_802_1X, NM_SETTING_802_1X_SETTING_NAME);
|
||||||
|
@@ -159,8 +159,6 @@ args = parser.parse_args()
|
|||||||
if args.gir is None or args.output is None:
|
if args.gir is None or args.output is None:
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
NM.utils_init()
|
|
||||||
|
|
||||||
girxml = ET.parse(args.gir).getroot()
|
girxml = ET.parse(args.gir).getroot()
|
||||||
outfile = open(args.output, mode='w')
|
outfile = open(args.output, mode='w')
|
||||||
|
|
||||||
|
@@ -770,7 +770,6 @@ global:
|
|||||||
nm_utils_iface_valid_name;
|
nm_utils_iface_valid_name;
|
||||||
nm_utils_inet4_ntop;
|
nm_utils_inet4_ntop;
|
||||||
nm_utils_inet6_ntop;
|
nm_utils_inet6_ntop;
|
||||||
nm_utils_init;
|
|
||||||
nm_utils_ip4_addresses_from_variant;
|
nm_utils_ip4_addresses_from_variant;
|
||||||
nm_utils_ip4_addresses_to_variant;
|
nm_utils_ip4_addresses_to_variant;
|
||||||
nm_utils_ip4_dns_from_variant;
|
nm_utils_ip4_dns_from_variant;
|
||||||
|
@@ -1788,13 +1788,6 @@ init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
{
|
{
|
||||||
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (initable);
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (initable);
|
||||||
NMClientInitData *init_data;
|
NMClientInitData *init_data;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (!nm_utils_init (&error)) {
|
|
||||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (initable),
|
|
||||||
callback, user_data, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_data = g_slice_new0 (NMClientInitData);
|
init_data = g_slice_new0 (NMClientInitData);
|
||||||
init_data->client = NM_CLIENT (initable);
|
init_data->client = NM_CLIENT (initable);
|
||||||
|
@@ -1306,9 +1306,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||||||
{
|
{
|
||||||
NMManager *manager = NM_MANAGER (initable);
|
NMManager *manager = NM_MANAGER (initable);
|
||||||
|
|
||||||
if (!nm_utils_init (error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!nm_manager_parent_initable_iface->init (initable, cancellable, error))
|
if (!nm_manager_parent_initable_iface->init (initable, cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -1380,13 +1377,6 @@ init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
NMManagerInitData *init_data;
|
NMManagerInitData *init_data;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (!nm_utils_init (&error)) {
|
|
||||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (initable),
|
|
||||||
callback, user_data, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_data = g_slice_new0 (NMManagerInitData);
|
init_data = g_slice_new0 (NMManagerInitData);
|
||||||
init_data->manager = NM_MANAGER (initable);
|
init_data->manager = NM_MANAGER (initable);
|
||||||
|
@@ -242,9 +242,6 @@ nm_main_utils_early_setup (const char *progname,
|
|||||||
|
|
||||||
/* Ensure gettext() gets the right environment (bgo #666516) */
|
/* Ensure gettext() gets the right environment (bgo #666516) */
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR);
|
|
||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
if (getuid () != 0) {
|
if (getuid () != 0) {
|
||||||
|
@@ -847,14 +847,10 @@ test20_source_stanza (const char *path)
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!nm_utils_init (&error))
|
|
||||||
FAIL ("nm-utils-init", "failed to initialize libnm: %s", error->message);
|
|
||||||
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
|
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
Reference in New Issue
Block a user