ICd2 D-Bus API implementation
[ICd internal functions]


Classes

struct  icd_dbus_api_listeners
struct  icd_dbus_api_scan_helper
struct  icd_dbus_api_foreach_data
struct  icd_dbus_api_statistics_data
struct  icd_dbus_api_addrinfo_data

Typedefs

typedef gboolean(* icd_dbus_api_foreach_send_fn )(struct icd_iap *iap, struct icd_dbus_api_foreach_data *foreach_data)

Functions

static void icd_dbus_api_scan_result (enum icd_scan_status status, const struct icd_scan_srv_provider *srv_provider, const struct icd_scan_cache *cache_entry, gpointer user_data)
static gboolean icd_dbus_api_scan_append (gchar *network_type, struct icd_dbus_api_scan_helper *scan_start)
static gboolean icd_dbus_api_scan_all_types (struct icd_network_module *module, gpointer user_data)
static gboolean icd_dbus_api_scan_sender_exists (GSList *sender_list, const gchar *sender)
static struct
icd_dbus_api_listeners ** 
icd_dbus_api_listeners_get (void)
static DBusHandlerResult icd_dbus_api_scan_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
static DBusHandlerResult icd_dbus_api_scan_cancel (DBusConnection *conn, DBusMessage *msg, void *user_data)
static gboolean icd_dbus_api_send_connect_sig (enum icd_connect_status status, const gchar *sender, struct icd_iap *iap)
void icd_dbus_api_send_ack (GSList *tracklist, struct icd_iap *iap)
void icd_dbus_api_send_nack (GSList *tracklist, struct icd_iap *iap)
static DBusHandlerResult icd_dbus_api_connect_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
static DBusHandlerResult icd_dbus_api_select_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
static gboolean icd_dbus_api_disconnect_last (struct icd_iap *iap, gpointer user_data)
static DBusHandlerResult icd_dbus_api_disconnect_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
gboolean icd_dbus_api_update_state (struct icd_iap *iap, const gchar *destination, const enum icd_connection_state state)
gboolean icd_dbus_api_update_search (const gchar *network_type, const gchar *destination, const enum icd_connection_state state)
static gboolean icd_dbus_api_foreach_iap_all (struct icd_iap *iap, gpointer user_data)
static gboolean icd_dbus_api_foreach_iap_req (struct DBusMessage *msg, struct icd_dbus_api_foreach_data *foreach_data)
static enum icd_connection_state icd_dbus_api_state_get (struct icd_iap *iap)
static gboolean icd_dbus_api_state_send (struct icd_iap *iap, struct icd_dbus_api_foreach_data *foreach_data)
static gboolean icd_dbus_api_state_scan_send (const gchar *network_type, struct icd_dbus_api_foreach_data *foreach_data)
static gboolean icd_dbus_api_state_scanning (struct icd_network_module *module, gpointer user_data)
static DBusHandlerResult icd_dbus_api_state_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
static void icd_dbus_api_statistics_data_free (struct icd_dbus_api_statistics_data *stats)
static void icd_dbus_api_statistics_ip_cb (const gpointer ip_stats_cb_token, const gchar *network_type, const guint network_attrs, const gchar *network_id, guint time_active, guint rx_bytes, guint tx_bytes)
static void icd_dbus_api_statistics_link_post_cb (const gpointer link_post_stats_cb_token, const gchar *network_type, const guint network_attrs, const gchar *network_id, guint time_active, guint rx_bytes, guint tx_bytes)
static void icd_dbus_api_statistics_link_cb (const gpointer link_stats_cb_token, const gchar *network_type, const guint network_attrs, const gchar *network_id, guint time_active, gint signal, gchar *station_id, gint dB, guint rx_bytes, guint tx_bytes)
static gboolean icd_dbus_api_statistics_send (struct icd_iap *iap, struct icd_dbus_api_foreach_data *foreach_data)
static DBusHandlerResult icd_dbus_api_statistics_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
static void icd_dbus_api_addrinfo_cb (const gpointer addr_info_cb_token, const gchar *network_type, const guint network_attrs, const gchar *network_id, gchar *ip_address, gchar *ip_netmask, gchar *ip_gateway, gchar *ip_dns1, gchar *ip_dns2, gchar *ip_dns3)
static gboolean icd_dbus_api_addrinfo_send (struct icd_iap *iap, struct icd_dbus_api_foreach_data *foreach_data)
static DBusHandlerResult icd_dbus_api_addrinfo_req (DBusConnection *conn, DBusMessage *msg, void *user_data)
static
DBusObjectPathMessageFunction 
icd_dbus_api_find_handler (DBusMessage *message, struct icd_dbus_mcall_table *table)
static DBusHandlerResult icd_dbus_api_request (DBusConnection *connection, DBusMessage *message, void *user_data)
gboolean icd_dbus_api_app_exit (const gchar *dbus_dest)
void icd_dbus_api_deinit (void)
gboolean icd_dbus_api_init (void)

Variables

struct icd_dbus_mcall_table icd_dbus_api_mcalls []
struct icd_dbus_sig_table icd_dbus_api_signals []

Typedef Documentation

typedef gboolean(* icd_dbus_api_foreach_send_fn)(struct icd_iap *iap, struct icd_dbus_api_foreach_data *foreach_data)

Template for the D-Bus data sending function

Parameters:
iap the IAP
foreach_data foreach data structure
Returns:
TRUE on success, FALSE on error


Function Documentation

static void icd_dbus_api_addrinfo_cb ( const gpointer  addr_info_cb_token,
const gchar *  network_type,
const guint  network_attrs,
const gchar *  network_id,
gchar *  ip_address,
gchar *  ip_netmask,
gchar *  ip_gateway,
gchar *  ip_dns1,
gchar *  ip_dns2,
gchar *  ip_dns3 
) [static]

Receive IP address configuration information based on network type, attributes and id.

Parameters:
addr_info_cb_token token passed to the request function
network_type network type
network_attrs attributes, such as type of network_id, security, etc.
network_id IAP name or local id, e.g. SSID
private a reference to the icd_nw_api private memeber
ip_address IP address string or NULL if no such value
ip_netmask IP netmask string which or NULL if no such value
ip_gateway IP gateway string which or NULL if no such value
ip_dns1 DNS server IP address string or NULL if no such value
ip_dns2 DNS server IP address string or NULL if no such value
ip_dns3 DNS server IP address string or NULL if no such value
Returns:
TRUE if some of the values are returned, FALSE if no values assigned

References icd_dbus_send_system_msg(), and ILOG_DEBUG.

Referenced by icd_dbus_api_addrinfo_send().

static DBusHandlerResult icd_dbus_api_addrinfo_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

Handle addrinfo requests

Parameters:
conn D-Bus connection
msg D-Bus message
user_data dbus client data

References icd_dbus_api_foreach_data::connections, icd_dbus_api_addrinfo_send(), icd_dbus_send_system_msg(), ILOG_ERR, icd_dbus_api_foreach_data::send_fn, and icd_dbus_api_foreach_data::sender.

static gboolean icd_dbus_api_addrinfo_send ( struct icd_iap iap,
struct icd_dbus_api_foreach_data foreach_data 
) [static]

gboolean icd_dbus_api_app_exit ( const gchar *  dbus_dest  ) 

Notify ICd2 D-Bus API when an app goes away

Parameters:
dbus_dest D-Bus sender id
TRUE if D-Bus sender was removed, FALSE otherwise

References icd_dbus_api_listeners_get(), icd_dbus_api_scan_result(), icd_name_owner_remove_filter(), icd_scan_results_unregister(), and ILOG_INFO.

Referenced by icd_dbus_api_scan_cancel(), and icd_name_owner_filter().

static DBusHandlerResult icd_dbus_api_connect_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

void icd_dbus_api_deinit ( void   ) 

Unregister ICD2_DBUS_API

References ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, and icd_dbus_unregister_system_service().

Referenced by icd_exec_shutdown().

static gboolean icd_dbus_api_disconnect_last ( struct icd_iap iap,
gpointer  user_data 
) [static]

Stop iterating at the first IAP

Parameters:
iap the IAP struct
user_data user data
Returns:
FALSE

Referenced by icd_dbus_api_disconnect_req().

static DBusHandlerResult icd_dbus_api_disconnect_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

static DBusObjectPathMessageFunction icd_dbus_api_find_handler ( DBusMessage *  message,
struct icd_dbus_mcall_table table 
) [static]

Find the handler function for the method call

Parameters:
message D-Bus message
table method call table
Returns:
function that handles this method call or NULL

References icd_dbus_mcall_table::handler_fn, icd_dbus_mcall_table::mcall_sig, and icd_dbus_mcall_table::name.

Referenced by icd_dbus_api_request().

static gboolean icd_dbus_api_foreach_iap_all ( struct icd_iap iap,
gpointer  user_data 
) [static]

Iterator function calling the given send function

Parameters:
iap the IAP
user_data foreach data
TRUE to go through all IAPs

References icd_dbus_api_foreach_data::connections, and icd_dbus_api_foreach_data::send_fn.

gboolean icd_dbus_api_init ( void   ) 

Register ICD2_DBUS_API

Returns:
TRUE on success, FALSE on failure

References ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, icd_dbus_api_request(), icd_dbus_api_update_state(), icd_dbus_register_system_service(), and ICD_STATE_DISCONNECTED.

Referenced by main().

static struct icd_dbus_api_listeners** icd_dbus_api_listeners_get ( void   )  [static, read]

Get the dbus api data structure

Returns:
the dbus api data structure

Referenced by icd_dbus_api_app_exit(), and icd_dbus_api_scan_req().

static DBusHandlerResult icd_dbus_api_request ( DBusConnection *  connection,
DBusMessage *  message,
void *  user_data 
) [static]

Receive registered method calls and find a handler for them

Parameters:
connection D-Bus connection
message D-Bus message
user_data dbus api data structure

References icd_dbus_api_find_handler(), ICD_DBUS_API_INTERFACE, icd_dbus_send_system_msg(), and ILOG_INFO.

Referenced by icd_dbus_api_init().

static gboolean icd_dbus_api_scan_all_types ( struct icd_network_module module,
gpointer  user_data 
) [static]

Start scan for each each given network module

Parameters:
module network module
user_data scan helper structure

References icd_dbus_api_scan_append(), icd_network_module::network_types, icd_network_module::nw, and icd_nw_api::start_search.

Referenced by icd_dbus_api_scan_req().

static gboolean icd_dbus_api_scan_append ( gchar *  network_type,
struct icd_dbus_api_scan_helper scan_start 
) [static]

Append a the network type of the successfully started network scan to the iterator position

Parameters:
network_type network type to start scan for
str_iter scan helper structure
Returns:
TRUE on success, FALSE if the scan was not started

Todo:
UI designer does not want to have the "scanning" icon blinking in this case

References icd_dbus_api_scan_helper::dbus_dest, icd_dbus_api_scan_result(), ICD_NW_SEARCH_SCOPE_ALL, ICD_NW_SEARCH_SCOPE_SAVED, ICD_SCAN_REQUEST_ACTIVE_SAVED, icd_scan_results_request(), ILOG_INFO, icd_dbus_api_scan_helper::reply_str_iter, and icd_dbus_api_scan_helper::scan_type.

Referenced by icd_dbus_api_scan_all_types(), and icd_dbus_api_scan_req().

static DBusHandlerResult icd_dbus_api_scan_cancel ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

Handle cancelling of scans

Parameters:
conn D-Bus connection
msg D-Bus message
user_data not used

References icd_dbus_api_scan_helper::dbus_dest, icd_dbus_api_app_exit(), and icd_dbus_send_system_msg().

static DBusHandlerResult icd_dbus_api_scan_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

static void icd_dbus_api_scan_result ( enum icd_scan_status  status,
const struct icd_scan_srv_provider srv_provider,
const struct icd_scan_cache cache_entry,
gpointer  user_data 
) [static]

Receive scan results and send them via D-Bus

Parameters:
status status of this network
srv_provider service provider entry; guaranteed to exist only for the lifetime of this callback function
cache_entry scan results; guaranteed to exist only for the lifetime of this callback function
user_data D-Bus app that requested the scan

References icd_scan_cache::dB, ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_SCAN_SIG, icd_dbus_send_system_msg(), ILOG_CRIT, icd_scan_cache::last_seen, icd_scan_cache::network_attrs, icd_scan_cache::network_id, icd_scan_cache::network_name, icd_scan_cache::network_priority, icd_scan_cache::network_type, icd_scan_srv_provider::service_attrs, icd_scan_srv_provider::service_id, icd_scan_srv_provider::service_name, icd_scan_srv_provider::service_priority, icd_scan_srv_provider::service_type, icd_scan_cache::signal, and icd_scan_cache::station_id.

Referenced by icd_dbus_api_app_exit(), and icd_dbus_api_scan_append().

static gboolean icd_dbus_api_scan_sender_exists ( GSList *  sender_list,
const gchar *  sender 
) [static]

Check wheter a sender already exists in the sender list

Parameters:
sender_list list to examine
sender sender to look for
Returns:
TRUE if found, FALSE otherwise

References ILOG_WARN.

Referenced by icd_dbus_api_scan_req().

static DBusHandlerResult icd_dbus_api_select_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

void icd_dbus_api_send_ack ( GSList *  tracklist,
struct icd_iap iap 
)

Send an ACK on successful connection creation to D-Bus applications

Parameters:
tracklist the list of tracked applications
iap IAP that got connected

References ICD_CONNECTION_SUCCESSFUL, icd_dbus_api_send_connect_sig(), ICD_TRACKING_INFO_ICD2, icd_tracking_info::interface, and icd_tracking_info::sender.

Referenced by icd_request_send_ack().

static gboolean icd_dbus_api_send_connect_sig ( enum icd_connect_status  status,
const gchar *  sender,
struct icd_iap iap 
) [static]

Create and send an (N)ACK to a listener

Parameters:
status status
sender D-Bus sender id
iap IAP in question or NULL if none
Returns:
TRUE if signal is sent, FALSE otherwise

References icd_iap::connection, ICD_DBUS_API_CONNECT_SIG, ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, icd_dbus_send_system_msg(), ILOG_ERR, icd_policy_request::network_attrs, icd_policy_request::network_id, icd_policy_request::network_type, icd_policy_request::service_attrs, icd_policy_request::service_id, and icd_policy_request::service_type.

Referenced by icd_dbus_api_send_ack(), and icd_dbus_api_send_nack().

void icd_dbus_api_send_nack ( GSList *  tracklist,
struct icd_iap iap 
)

Send a NACK on disconnect or unsuccessful connection creation to D-Bus applications; free tracking info

Parameters:
tracklist the list of tracked applications
iap if non-NULL send ICD_CONNECTION_DISCONNECTED; if NULL send ICD_CONNECTION_NOT_CONNECTED

References ICD_CONNECTION_DISCONNECTED, ICD_CONNECTION_NOT_CONNECTED, icd_dbus_api_send_connect_sig(), ICD_TRACKING_INFO_ICD2, icd_tracking_info::interface, icd_tracking_info::request, and icd_tracking_info::sender.

Referenced by icd_request_send_ack(), and icd_request_send_nack().

static enum icd_connection_state icd_dbus_api_state_get ( struct icd_iap iap  )  [static]

static DBusHandlerResult icd_dbus_api_state_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

static gboolean icd_dbus_api_state_scan_send ( const gchar *  network_type,
struct icd_dbus_api_foreach_data foreach_data 
) [static]

Send network scan status

Parameters:
network_type network type
foreach_data foreach data structure

References ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_STATE_SIG, icd_dbus_send_system_msg(), ICD_STATE_SEARCH_START, ILOG_ERR, and icd_dbus_api_foreach_data::sender.

Referenced by icd_dbus_api_state_scanning().

static gboolean icd_dbus_api_state_scanning ( struct icd_network_module module,
gpointer  user_data 
) [static]

Network module callback function for scanning status

Parameters:
module the network module
user_data foreach data structure
Returns:
TRUE

References icd_dbus_api_foreach_data::connections, icd_dbus_api_state_scan_send(), icd_network_module::network_types, and icd_network_module::scan_progress.

Referenced by icd_dbus_api_state_req().

static gboolean icd_dbus_api_state_send ( struct icd_iap iap,
struct icd_dbus_api_foreach_data foreach_data 
) [static]

Function for sending state data to listeners

Parameters:
iap the IAP
foreach_data foreach data structure
Returns:
TRUE on successful signal sending, FALSE on error

References icd_dbus_api_state_get(), icd_dbus_api_update_state(), and icd_dbus_api_foreach_data::sender.

Referenced by icd_dbus_api_state_req().

static void icd_dbus_api_statistics_data_free ( struct icd_dbus_api_statistics_data stats  )  [static]

Free a statistics data structure

Parameters:
stats the statistics data structure

References icd_dbus_api_statistics_data::sender, and icd_dbus_api_statistics_data::station_id.

Referenced by icd_dbus_api_statistics_ip_cb(), icd_dbus_api_statistics_link_cb(), and icd_dbus_api_statistics_link_post_cb().

static void icd_dbus_api_statistics_ip_cb ( const gpointer  ip_stats_cb_token,
const gchar *  network_type,
const guint  network_attrs,
const gchar *  network_id,
guint  time_active,
guint  rx_bytes,
guint  tx_bytes 
) [static]

Receive ip statistics based on network type, attributes and id. Values are set to zero or NULL if statistics are not available or applicable

Parameters:
ip_stats_cb_token token passed to the request function
network_type network type
network_attrs attributes, such as type of network_id, security, etc.
network_id network id
time_active time active, if applicable
signal signal level
station_id base station id, e.g. WLAN access point MAC address
dB raw signal strength; depends on the type of network
rx_bytes bytes received on the link, if applicable
tx_bytes bytes sent on the link, if applicable
private a reference to the icd_nw_api private memeber

References icd_iap::connection, ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, icd_dbus_api_statistics_data_free(), ICD_DBUS_API_STATISTICS_SIG, icd_dbus_send_system_msg(), icd_iap_find(), ILOG_ERR, ILOG_WARN, icd_policy_request::network_attrs, icd_policy_request::network_id, icd_policy_request::network_type, icd_dbus_api_statistics_data::rx_bytes, icd_dbus_api_statistics_data::sender, icd_policy_request::service_attrs, icd_policy_request::service_id, icd_policy_request::service_type, icd_dbus_api_statistics_data::signal, icd_dbus_api_statistics_data::time_active, and icd_dbus_api_statistics_data::tx_bytes.

Referenced by icd_dbus_api_statistics_link_post_cb().

static void icd_dbus_api_statistics_link_cb ( const gpointer  link_stats_cb_token,
const gchar *  network_type,
const guint  network_attrs,
const gchar *  network_id,
guint  time_active,
gint  signal,
gchar *  station_id,
gint  dB,
guint  rx_bytes,
guint  tx_bytes 
) [static]

Receive link statistics based on network type, attributes and id. Values are set to zero or NULL if statistics are not available or applicable

Parameters:
link_stats_cb_token token passed to the request function
network_type network type
network_attrs attributes, such as type of network_id, security, etc.
network_id network id
time_active time active, if applicable
signal signal level
station_id base station id, e.g. WLAN access point MAC address
dB raw signal strength; depends on the type of network
rx_bytes bytes received on the link, if applicable
tx_bytes bytes sent on the link, if applicable
private a reference to the icd_nw_api private memeber

References icd_dbus_api_statistics_data::dB, icd_dbus_api_statistics_data_free(), icd_dbus_api_statistics_link_post_cb(), icd_iap_find(), icd_iap_get_link_post_stats(), ILOG_ERR, ILOG_WARN, icd_dbus_api_statistics_data::rx_bytes, icd_dbus_api_statistics_data::signal, icd_dbus_api_statistics_data::station_id, icd_dbus_api_statistics_data::time_active, and icd_dbus_api_statistics_data::tx_bytes.

Referenced by icd_dbus_api_statistics_send().

static void icd_dbus_api_statistics_link_post_cb ( const gpointer  link_post_stats_cb_token,
const gchar *  network_type,
const guint  network_attrs,
const gchar *  network_id,
guint  time_active,
guint  rx_bytes,
guint  tx_bytes 
) [static]

Receive link post up statistics based on network type, attributes and id. Values are set to zero or NULL if statistics are not available or applicable

Parameters:
link_post_stats_cb_token token passed to the request function
network_type network type
network_attrs attributes, such as type of network_id, security, etc.
network_id network id
time_active time active, if applicable
rx_bytes bytes received on the link, if applicable
tx_bytes bytes sent on the link, if applicable
private a reference to the icd_nw_api private memeber

References icd_dbus_api_statistics_data_free(), icd_dbus_api_statistics_ip_cb(), icd_iap_find(), icd_iap_get_ip_stats(), ILOG_ERR, ILOG_WARN, icd_dbus_api_statistics_data::rx_bytes, icd_dbus_api_statistics_data::time_active, and icd_dbus_api_statistics_data::tx_bytes.

Referenced by icd_dbus_api_statistics_link_cb().

static DBusHandlerResult icd_dbus_api_statistics_req ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

Handle statistics requests

Parameters:
conn D-Bus connection
msg D-Bus message
user_data dbus client data

References icd_dbus_api_foreach_data::connections, icd_dbus_api_statistics_send(), icd_dbus_send_system_msg(), ILOG_ERR, icd_dbus_api_foreach_data::send_fn, and icd_dbus_api_foreach_data::sender.

static gboolean icd_dbus_api_statistics_send ( struct icd_iap iap,
struct icd_dbus_api_foreach_data foreach_data 
) [static]

Function for sending statistics data to listeners

Parameters:
iap the IAP
foreach_data foreach data structure
Returns:
TRUE on successful signal sending, FALSE on error

References icd_dbus_api_statistics_link_cb(), icd_iap_get_link_stats(), ILOG_ERR, icd_dbus_api_foreach_data::sender, and icd_dbus_api_statistics_data::sender.

Referenced by icd_dbus_api_statistics_req().

gboolean icd_dbus_api_update_search ( const gchar *  network_type,
const gchar *  destination,
const enum icd_connection_state  state 
)

Send network type search start/stop

Parameters:
iap the network type
destination D-Bus destination or NULL if broadcasted to all
state the state to send

References ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_STATE_SIG, icd_dbus_send_system_msg(), and ILOG_ERR.

Referenced by icd_status_scan_start(), and icd_status_scan_stop().

gboolean icd_dbus_api_update_state ( struct icd_iap iap,
const gchar *  destination,
const enum icd_connection_state  state 
)


Variable Documentation

Initial value:

 {
  {ICD_DBUS_API_SCAN_SIG, "uussusissuayiisi"},
  {ICD_DBUS_API_CONNECT_SIG, "sussuayu"},
  {ICD_DBUS_API_STATE_SIG, "sussuaysu"},
  {ICD_DBUS_API_STATE_SIG, "u"},
  {ICD_DBUS_API_STATE_SIG, "su"},
  {ICD_DBUS_API_STATISTICS_SIG, "sussuayuiuu"},
  {ICD_DBUS_API_ADDRINFO_SIG, "sussuaya(sssssss)"},

  {NULL}
}
signals sent


Generated on Thu Mar 11 09:04:50 2010 for ICd2 by  doxygen 1.5.6