## TrackerNetworkProvider

TrackerNetworkProvider — Network status interface for cross platform backends

## Synopsis

    #include <libtracker-miner/tracker-miner.h>

    #define             TRACKER_NETWORK_PROVIDER_GET_INTERFACE(o)
    typedef             TrackerNetworkProvider;
                        TrackerNetworkProviderIface;
    enum                TrackerNetworkProviderStatus;
    TrackerNetworkProvider * tracker_network_provider_get   (void);
    gchar *             tracker_network_provider_get_name   (TrackerNetworkProvider *provider);
    TrackerNetworkProviderStatus  tracker_network_provider_get_status
                                                            (TrackerNetworkProvider *provider);

## Description

The TrackerNetworkProvider allows different backends to be written for retrieving network connectivity status information. This can be used to avoid heavy transfers when on a slow connection, or on a connection where costs may apply. Currently, there are two implementations. The NetworkManager one uses NetworkManager, and the Dummy one will always expose the network as connected, no matter what the connectivity status actually is.

## Details

### TRACKER_NETWORK_PROVIDER_GET_INTERFACE()

    #define TRACKER_NETWORK_PROVIDER_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TRACKER_TYPE_NETWORK_PROVIDER, TrackerNetworkProviderIface))

### TrackerNetworkProvider

    typedef struct TrackerNetworkProvider TrackerNetworkProvider;

### TrackerNetworkProviderIface

    typedef struct {
    	GTypeInterface parent_iface;

    	TrackerNetworkProviderStatus (* get_status) (TrackerNetworkProvider *provider);
    } TrackerNetworkProviderIface;

GTypeInterface `parent_iface`; | parent object interface
`get_status` () | get the network status

Since 0.10

### enum TrackerNetworkProviderStatus

    typedef enum {
    	TRACKER_NETWORK_PROVIDER_DISCONNECTED,
    	TRACKER_NETWORK_PROVIDER_UNKNOWN,
    	TRACKER_NETWORK_PROVIDER_GPRS,
    	TRACKER_NETWORK_PROVIDER_EDGE,
    	TRACKER_NETWORK_PROVIDER_3G,
    	TRACKER_NETWORK_PROVIDER_LAN
    } TrackerNetworkProviderStatus;

Enumerates the different types of connections that the device might use when connected to internet. Note that not all providers might provide this information.

`TRACKER_NETWORK_PROVIDER_DISCONNECTED` | Network is disconnected
`TRACKER_NETWORK_PROVIDER_UNKNOWN` | Network status is unknown
`TRACKER_NETWORK_PROVIDER_GPRS` | Network is connected over a GPRS connection
`TRACKER_NETWORK_PROVIDER_EDGE` | Network is connected over an EDGE connection
`TRACKER_NETWORK_PROVIDER_3G` | Network is connected over a 3G or faster (HSDPA, UMTS, ...) connection
`TRACKER_NETWORK_PROVIDER_LAN` | Network is connected over a local network connection. This can be ethernet, wifi, etc.

Since 0.10

### tracker_network_provider_get ()

    TrackerNetworkProvider * tracker_network_provider_get   (void);

This function MUST be defined by the implementation of TrackerNetworkProvider.

For example, tracker-network-provider-network-manager.c should include this function for a NetworkManager implementation.

Only one implementation can exist at once.

Returns : | a `TrackerNetworkProvider`.

Since 0.10

### tracker_network_provider_get_name ()

    gchar *             tracker_network_provider_get_name   (TrackerNetworkProvider *provider);

At the moment there are only two providers, "Dummy" and "NetworkManager". Either of these is what will be returned unless new providers are written.

`provider` : | a TrackerNetworkProvider
Returns : | a newly allocated string representing the name which must be freed with `g_free()`. [transfer full]

Since 0.10

### tracker_network_provider_get_status ()

    TrackerNetworkProviderStatus  tracker_network_provider_get_status
                                                            (TrackerNetworkProvider *provider);

This function calls the network provider's "get_status" implementation.

`provider` : | a TrackerNetworkProvider
Returns : | a TrackerNetworkProviderStatus decribing the current network status.

Since 0.10