GeocodeIpclient

GeocodeIpclient — GeoIP client

Synopsis

#include <geocode-glib/geocode-ipclient.h>

struct              GeocodeIpclient;
struct              GeocodeIpclientClass;
GeocodeIpclient *   geocode_ipclient_new                (void);
GeocodeIpclient *   geocode_ipclient_new_for_ip         (const char *str);
void                geocode_ipclient_search_async       (GeocodeIpclient *ipclient,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GeocodeLocation *   geocode_ipclient_search_finish      (GeocodeIpclient *ipclient,
                                                         GAsyncResult *res,
                                                         GError **error);
GeocodeLocation *   geocode_ipclient_search             (GeocodeIpclient *ipclient,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GeocodeIpclient

Properties

  "compatibility-mode"       gboolean              : Read / Write / Construct
  "server"                   gchar*                : Read / Write / Construct

Description

Contains functions to get the geolocation corresponding to IP addresses from a server.

Details

struct GeocodeIpclient

struct GeocodeIpclient;

All the fields in the GeocodeIpclient structure are private and should never be accessed directly.


struct GeocodeIpclientClass

struct GeocodeIpclientClass {
};

All the fields in the GeocodeIpclientClass structure are private and should never be accessed directly.


geocode_ipclient_new ()

GeocodeIpclient *   geocode_ipclient_new                (void);

Creates a new GeocodeIpclient to fetch the geolocation data. Here the IP address is not provided the by client, hence the server will try to get the IP address from various proxy variables. Use geocode_ipclient_search_async() to query the server

Returns :

a new GeocodeIpclient. Use g_object_unref() when done.

geocode_ipclient_new_for_ip ()

GeocodeIpclient *   geocode_ipclient_new_for_ip         (const char *str);

Creates a new GeocodeIpclient to fetch the geolocation data Use geocode_ipclient_search_async() to query the server

str :

The IP address

Returns :

a new GeocodeIpclient. Use g_object_unref() when done.

geocode_ipclient_search_async ()

void                geocode_ipclient_search_async       (GeocodeIpclient *ipclient,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Asynchronously performs a query to get the geolocation information from the server. Use geocode_ipclient_search() to do the same thing synchronously.

When the operation is finished, callback will be called. You can then call geocode_ipclient_search_finish() to get the result of the operation.

ipclient :

a GeocodeIpclient representing a query

cancellable :

optional GCancellable forward, NULL to ignore.

callback :

a GAsyncReadyCallback to call when the request is satisfied

user_data :

the data to pass to callback function

geocode_ipclient_search_finish ()

GeocodeLocation *   geocode_ipclient_search_finish      (GeocodeIpclient *ipclient,
                                                         GAsyncResult *res,
                                                         GError **error);

Finishes a geolocation search operation. See geocode_ipclient_search_async().

ipclient :

a GeocodeIpclient representing a query

res :

a GAsyncResult

error :

a GError

Returns :

A GeocodeLocation object or NULL in case of errors. Free the returned object with g_object_unref() when done. [transfer full]

geocode_ipclient_search ()

GeocodeLocation *   geocode_ipclient_search             (GeocodeIpclient *ipclient,
                                                         GError **error);

Gets the geolocation data for an IP address from the server.

ipclient :

a GeocodeIpclient representing a query

error :

a GError

Returns :

A GeocodeLocation object or NULL in case of errors. Free the returned object with g_object_unref() when done. [transfer full]

Property Details

The "compatibility-mode" property

  "compatibility-mode"       gboolean              : Read / Write / Construct

Enable this mode if you are using freegeoip's (or a compatible) service.

Default value: FALSE


The "server" property

  "server"                   gchar*                : Read / Write / Construct

server uri.

Default value: "http://127.0.0.1:12345/cgi-bin/geoip-lookup"