/**
 * nm_act_request_new:
 *
 * @connection: the connection to activate @device with
 * @specific_object: the object path of the specific object (ie, WiFi access point,
 *    etc) that will be used to activate @connection and @device
 * @user_requested: pass %TRUE if the activation was requested via D-Bus,
 *    otherwise %FALSE if requested internally by NM (ie, autoconnect)
 * @user_uid: if @user_requested is %TRUE, the Unix UID of the user that requested
 * @dbus_sender: if @user_requested is %TRUE, the D-BUS sender that requested
 *    the activation
 * @assumed: pass %TRUE if the activation should "assume" (ie, taking over) an
 *    existing connection made before this instance of NM started
 * @device: the device/interface to configure according to @connection
 * @master: if the activation depends on another device (ie, bond or bridge
 *    master to which this device will be enslaved) pass the #NMDevice that this
 *    activation request be enslaved to
 *
 * Begins activation of @device using the given @connection and other details.
 *
 * Returns: the new activation request on success, %NULL on error.
 */
NMActRequest *
nm_act_request_new (NMConnection *connection,
                    const char *specific_object,
                    gboolean user_requested,
                    gulong user_uid,
                    const char *dbus_sender,
                    gboolean assumed,
                    NMDevice *device,
                    NMDevice *master)
{
	GObject *object;

	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
	g_return_val_if_fail (NM_DEVICE (device), NULL);

	object = g_object_new (NM_TYPE_ACT_REQUEST,
	                       NM_ACTIVE_CONNECTION_INT_CONNECTION, connection,
	                       NM_ACTIVE_CONNECTION_INT_DEVICE, device,
	                       NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object,
	                       NM_ACTIVE_CONNECTION_INT_USER_REQUESTED, user_requested,
	                       NM_ACTIVE_CONNECTION_INT_USER_UID, user_uid,
	                       NM_ACTIVE_CONNECTION_INT_ASSUMED, assumed,
	                       NM_ACTIVE_CONNECTION_INT_MASTER, master,
	                       NULL);
	if (object) {
		nm_active_connection_export (NM_ACTIVE_CONNECTION (object));
		NM_ACT_REQUEST_GET_PRIVATE (object)->dbus_sender = g_strdup (dbus_sender);
	}

	return (NMActRequest *) object;
}
/**
 * nm_act_request_new:
 *
 * @connection: the connection to activate @device with
 * @specific_object: the object path of the specific object (ie, WiFi access point,
 *    etc) that will be used to activate @connection and @device
 * @user_requested: pass %TRUE if the activation was requested via D-Bus,
 *    otherwise %FALSE if requested internally by NM (ie, autoconnect)
 * @user_uid: if @user_requested is %TRUE, the Unix UID of the user that requested
 * @dbus_sender: if @user_requested is %TRUE, the D-BUS sender that requested
 *    the activation
 * @assumed: pass %TRUE if the activation should "assume" (ie, taking over) an
 *    existing connection made before this instance of NM started
 * @device: the device/interface to configure according to @connection
 * @dependency: if the activation depends on another device (ie, VLAN slave,
 *    bond slave, etc) pass the #NMActiveConnection that this activation request
 *    should wait for before proceeding
 *
 * Begins activation of @device using the given @connection and other details.
 *
 * Returns: the new activation request on success, %NULL on error.
 */
NMActRequest *
nm_act_request_new (NMConnection *connection,
                    const char *specific_object,
                    gboolean user_requested,
                    gulong user_uid,
                    const char *dbus_sender,
                    gboolean assumed,
                    gpointer *device,
                    NMActiveConnection *dependency)
{
	GObject *object;
	NMActRequestPrivate *priv;

	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
	g_return_val_if_fail (NM_DEVICE (device), NULL);

	object = g_object_new (NM_TYPE_ACT_REQUEST,
	                       NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object,
	                       NULL);
	if (!object)
		return NULL;

	priv = NM_ACT_REQUEST_GET_PRIVATE (object);

	priv->connection = g_object_ref (connection);
	priv->device = NM_DEVICE (device);
	g_signal_connect (device, "state-changed",
	                  G_CALLBACK (device_state_changed),
	                  NM_ACT_REQUEST (object));

	priv->user_uid = user_uid;
	priv->user_requested = user_requested;
	priv->dbus_sender = g_strdup (dbus_sender);
	priv->assumed = assumed;

	if (dependency) {
		priv->dep = dependency;
		g_object_weak_ref (G_OBJECT (dependency), (GWeakNotify) dep_gone, object);
		priv->dep_state_id = g_signal_connect (dependency,
		                                       "notify::" NM_ACTIVE_CONNECTION_STATE,
		                                       G_CALLBACK (dep_state_changed),
		                                       object);
	}

	if (!nm_active_connection_export (NM_ACTIVE_CONNECTION (object),
	                                  connection,
	                                  nm_device_get_path (NM_DEVICE (device)))) {
		g_object_unref (object);
		object = NULL;
	}

	return (NMActRequest *) object;
}