## NMClient

NMClient

## Synopsis

    #define             NM_CLIENT_STATE
    #define             NM_CLIENT_MANAGER_RUNNING
    #define             NM_CLIENT_WIRELESS_ENABLED
    #define             NM_CLIENT_WIRELESS_HARDWARE_ENABLED
    #define             NM_CLIENT_ACTIVE_CONNECTIONS
                        NMClient;
    NMClient*           nm_client_new                       (void);
    const GPtrArray*    nm_client_get_devices               (NMClient *client);
    NMDevice*           nm_client_get_device_by_path        (NMClient *client,
                                                             const char *object_path);
    void                (*NMClientActivateDeviceFn)         (gpointer user_data,
                                                             const char *object_path,
                                                             GError *error);
    void                nm_client_activate_connection       (NMClient *client,
                                                             const char *service_name,
                                                             const char *connection_path,
                                                             NMDevice *device,
                                                             const char *specific_object,
                                                             NMClientActivateDeviceFn callback,
                                                             gpointer user_data);
    void                nm_client_deactivate_connection     (NMClient *client,
                                                             NMActiveConnection *active);
    gboolean            nm_client_wireless_get_enabled      (NMClient *client);
    void                nm_client_wireless_set_enabled      (NMClient *client,
                                                             gboolean enabled);
    gboolean            nm_client_wireless_hardware_get_enabled
                                                            (NMClient *client);
    NMState             nm_client_get_state                 (NMClient *client);
    gboolean            nm_client_get_manager_running       (NMClient *client);
    const GPtrArray*    nm_client_get_active_connections    (NMClient *client);
    void                nm_client_sleep                     (NMClient *client,
                                                             gboolean sleep);

## Object Hierarchy

      GObject
       +----NMObject
             +----NMClient

## Properties

      "active-connections"       nm-object-array       : Read
      "manager-running"          gboolean              : Read
      "state"                    guint                 : Read
      "wireless-enabled"         gboolean              : Read / Write
      "wireless-hardware-enabled" gboolean              : Read

## Signals

      "device-added"                                   : Run First
      "device-removed"                                 : Run First

## Description

## Details

### NM_CLIENT_STATE

    #define NM_CLIENT_STATE "state"

### NM_CLIENT_MANAGER_RUNNING

    #define NM_CLIENT_MANAGER_RUNNING "manager-running"

### NM_CLIENT_WIRELESS_ENABLED

    #define NM_CLIENT_WIRELESS_ENABLED "wireless-enabled"

### NM_CLIENT_WIRELESS_HARDWARE_ENABLED

    #define NM_CLIENT_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"

### NM_CLIENT_ACTIVE_CONNECTIONS

    #define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections"

### NMClient

    typedef struct _NMClient NMClient;

### nm_client_new ()

    NMClient*           nm_client_new                       (void);

Creates a new NMClient.

Returns : | a new NMClient

### nm_client_get_devices ()

    const GPtrArray*    nm_client_get_devices               (NMClient *client);

Gets all the detected devices.

`client` : | a NMClient
Returns : | a GPtrArray containing all the NMDevices. The returned array is owned by the client and should not be modified.

### nm_client_get_device_by_path ()

    NMDevice*           nm_client_get_device_by_path        (NMClient *client,
                                                             const char *object_path);

Gets a NMDevice from a NMClient.

`client` : | a NMClient
`object_path` : | the object path to search for
Returns : | the NMDevice for the given `object_path` or `NULL` if none is found.

### NMClientActivateDeviceFn ()

    void                (*NMClientActivateDeviceFn)         (gpointer user_data,
                                                             const char *object_path,
                                                             GError *error);

`user_data` : |
`object_path` : |
`error` : |

### nm_client_activate_connection ()

    void                nm_client_activate_connection       (NMClient *client,
                                                             const char *service_name,
                                                             const char *connection_path,
                                                             NMDevice *device,
                                                             const char *specific_object,
                                                             NMClientActivateDeviceFn callback,
                                                             gpointer user_data);

Activates a connection with the given NMDevice.

`client` : | a NMClient
`service_name` : | the connection's service name
`connection_path` : | the connection's DBus path
`device` : | the NMDevice
`specific_object` : | the device specific object (currently used only for activating wireless devices and should be the NMAccessPoint's path.
`callback` : | the function to call when the call is done
`user_data` : | user data to pass to the callback function

### nm_client_deactivate_connection ()

    void                nm_client_deactivate_connection     (NMClient *client,
                                                             NMActiveConnection *active);

Deactivates an active NMActiveConnection.

`client` : | a NMClient
`active` : | the NMActiveConnection to deactivate

### nm_client_wireless_get_enabled ()

    gboolean            nm_client_wireless_get_enabled      (NMClient *client);

Determines whether the wireless is enabled.

`client` : | a NMClient
Returns : | `TRUE` if wireless is enabled

### nm_client_wireless_set_enabled ()

    void                nm_client_wireless_set_enabled      (NMClient *client,
                                                             gboolean enabled);

Enables or disables wireless devices.

`client` : | a NMClient
`enabled` : | `TRUE` to enable wireless

### nm_client_wireless_hardware_get_enabled ()

    gboolean            nm_client_wireless_hardware_get_enabled
                                                            (NMClient *client);

Determines whether the wireless hardware is enabled.

`client` : | a NMClient
Returns : | `TRUE` if the wireless hardware is enabled

### nm_client_get_state ()

    NMState             nm_client_get_state                 (NMClient *client);

Gets the current daemon state.

`client` : | a NMClient
Returns : | the current `NMState`

### nm_client_get_manager_running ()

    gboolean            nm_client_get_manager_running       (NMClient *client);

Determines whether the daemon is running.

`client` : | a NMClient
Returns : | `TRUE` if the daemon is running

### nm_client_get_active_connections ()

    const GPtrArray*    nm_client_get_active_connections    (NMClient *client);

Gets the active connections.

`client` : | a NMClient
Returns : | a GPtrArray containing all the active NMActiveConnections. The returned array is owned by the client and should not be modified.

### nm_client_sleep ()

    void                nm_client_sleep                     (NMClient *client,
                                                             gboolean sleep);

Enables or disables networking. When the daemon is put to sleep, it'll deactivate and disable all the active devices.

`client` : | a NMClient
`sleep` : | `TRUE` to put the daemon to sleep

## Property Details

### The `"active-connections"` property

      "active-connections"       nm-object-array       : Read

Active connections.

### The `"manager-running"` property

      "manager-running"          gboolean              : Read

Whether NetworkManager is running.

Default value: FALSE

### The `"state"` property

      "state"                    guint                 : Read

The current daemon state.

Allowed values: <= 4

Default value: 0

### The `"wireless-enabled"` property

      "wireless-enabled"         gboolean              : Read / Write

Is wireless enabled.

Default value: TRUE

### The `"wireless-hardware-enabled"` property

      "wireless-hardware-enabled" gboolean              : Read

Is wireless hardware enabled.

Default value: TRUE

## Signal Details

### The `"device-added"` signal

    void                user_function                      (NMClient *client,
                                                            GObject  *device,
                                                            gpointer  user_data)      : Run First

Notifies that a NMDevice is added.

`client` : | the client that received the signal
`device` : | the new device
`user_data` : | user data set when the signal handler was connected.

### The `"device-removed"` signal

    void                user_function                      (NMClient *widget,
                                                            GObject  *device,
                                                            gpointer  user_data)      : Run First

Notifies that a NMDevice is removed.

`widget` : | the client that received the signal
`device` : | the removed device
`user_data` : | user data set when the signal handler was connected.