NetworkManager/shared/nm-libnm-aux/nm-libnm-aux.h
Thomas Haller 9e10b4f699 shared: add nmc_client_new_waitsync() and nmc_client_new_async*() helpers
Benefits:

- nmc_client_new_async*() allows to set properties on the NMClient
  instance before calling g_async_initable_init_async().
  It also allows to subscribe to any signals (like NM_CLIENT_DEVICE_ADDED)
  before actually iterating the GMainContext. This is a sensible and
  supported thing to do!

- nmc_client_new_waitsync() iterates the GMainContext until the (async)
  initialization is complete. That is different from synchronous nm_client_new(),
  which does not iterate the caller's GMainContext, and hence needs an
  internal context to ensure the order of events is honored.

- nmc_client_new_waitsync() always returns the NMClient instance, even
  if initialization fails.
  That is useful if you need the nm_client_get_context_busy_watcher() instance
  to ensure all pending messages are completed.
2019-12-10 09:17:17 +01:00

24 lines
995 B
C

// SPDX-License-Identifier: LGPL-2.1+
#ifndef __NM_LIBNM_AUX_H__
#define __NM_LIBNM_AUX_H__
NMClient *nmc_client_new_async_valist (GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
const char *first_property_name,
va_list ap);
NMClient *nmc_client_new_async (GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
const char *first_property_name,
...);
gboolean nmc_client_new_waitsync (GCancellable *cancellable,
NMClient **out_nmc,
GError **error,
const char *first_property_name,
...);
#endif /* __NM_LIBNM_AUX_H__ */