Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

core/settings.c File Reference


Detailed Description

gtk-gnutella configuration.

Author:
Raphael Manfredi

Richard Eckart

Date:
2001-2003

#include "common.h"
#include "lib/eval.h"
#include "bsched.h"
#include "downloads.h"
#include "hcache.h"
#include "hosts.h"
#include "inet.h"
#include "search.h"
#include "settings.h"
#include "share.h"
#include "sockets.h"
#include "upload_stats.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "if/core/main.h"
#include "if/core/net_stats.h"
#include "if/bridge/c2ui.h"
#include "lib/bit_array.h"
#include "lib/getphysmemsize.h"
#include "lib/cq.h"
#include "lib/file.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/override.h"

Data Structures

struct  prop_map
 The property maps contain informaiton about which widget should reflect which property. More...

Defines

#define RESET_PROP_TM   (10*60*1000)
 10 minutes in ms
#define PROPERTY_MAP_SIZE   G_N_ELEMENTS(property_map)

Typedefs

typedef prop_map prop_map_t

Functions

void settings_callbacks_init (void)
void settings_callbacks_shutdown (void)
void update_uptimes (void)
 Called at shutdown time to update the average_uptime property before saving the properties to disk.
host_addr_t listen_addr (void)
host_addr_t listen_addr6 (void)
host_addr_t listen_addr_by_net (enum net_type net)
gboolean is_my_address (const host_addr_t addr)
gboolean is_my_address_and_port (const host_addr_t addr, guint16 port)
gint ensure_unicity (const gchar *file, gboolean check_only)
 Look for any existing PID file.
void save_pid (gint fd)
 Write our pid to the pidfile.
void settings_early_init (void)
 Initializes "config_dir" and "home_dir".
gint settings_ensure_unicity (gboolean check_only)
 Tries to ensure that the current process is the only running instance gtk-gnutella for the current value of GTK_GNUTELLA_DIR.
void settings_init (void)
const gchar * settings_config_dir (void)
 Get the config directory.
const gchar * settings_home_dir (void)
 Gets the home dir.
const gchar * settings_ipc_dir (void)
 Gets the IPC directory.
const gchar * settings_local_socket_path (void)
 Gets the path of the local socket.
enum net_type settings_dns_net (void)
void settings_remove_pidfile (void)
 Remove pidfile.
void addr_ipv4_changed (const host_addr_t new_addr, const host_addr_t peer)
void addr_ipv6_changed (const host_addr_t new_addr, const host_addr_t peer)
void settings_addr_changed (const host_addr_t new_addr, const host_addr_t peer)
 This routine is called when we determined that our IP was no longer the one we computed.
guint32 settings_max_msg_size (void)
 Maximum message payload size we are configured to handle.
void settings_shutdown (void)
 Called at exit time to flush the property files.
void settings_save_if_dirty (void)
 Save settings if dirty.
void settings_close (void)
 Finally free all memory allocated.
void bw_stats (gnet_bw_stats_t *s, gboolean enabled, bsched_bws_t bws)
void gnet_get_bw_stats (gnet_bw_source type, gnet_bw_stats_t *s)
guint32 get_average_ip_lifetime (time_t now, enum net_type net)
 Compute the EMA of the IP address lifetime up to now, but do not update the property.
void update_address_lifetime (void)
 Called whenever the IP address we advertise changed.
guint32 get_average_servent_uptime (time_t now)
 Compute the EMA of the averate servent uptime, up to now, but do not update the property.
gboolean up_connections_changed (property_t prop)
gboolean max_connections_changed (property_t prop)
gboolean max_hosts_cached_changed (property_t prop)
gboolean max_ultra_hosts_cached_changed (property_t prop)
gboolean max_bad_hosts_cached_changed (property_t prop)
host_addr_t get_bind_addr (enum net_type net)
gboolean enable_udp_changed (property_t prop)
gboolean enable_local_socket_changed (property_t prop)
void request_new_sockets (guint16 port, gboolean check_firewalled)
gboolean listen_port_changed (property_t prop)
gboolean network_protocol_changed (property_t prop)
gboolean bw_switch (property_t prop, bsched_bws_t bs)
gboolean bw_http_in_enabled_changed (property_t prop)
gboolean bw_http_out_enabled_changed (property_t prop)
gboolean bw_gnet_in_enabled_changed (property_t prop)
gboolean bw_gnet_out_enabled_changed (property_t prop)
gboolean bw_gnet_lin_enabled_changed (property_t prop)
gboolean bw_gnet_lout_enabled_changed (property_t prop)
gboolean node_sendqueue_size_changed (property_t unused_prop)
gboolean scan_extensions_changed (property_t prop)
gboolean file_path_changed (property_t prop)
gboolean shared_dirs_paths_changed (property_t prop)
gboolean local_netmasks_string_changed (property_t prop)
gboolean hard_ttl_limit_changed (property_t prop)
gboolean max_ttl_changed (property_t prop)
gboolean bw_http_in_changed (property_t prop)
gboolean bw_http_out_changed (property_t prop)
gboolean bw_gnet_in_changed (property_t prop)
gboolean bw_gnet_out_changed (property_t prop)
gboolean bw_gnet_lin_changed (property_t prop)
gboolean bw_gnet_lout_changed (property_t prop)
gboolean bw_allow_stealing_changed (property_t prop)
gboolean node_online_mode_changed (property_t prop)
gboolean lib_debug_changed (property_t unused_prop)
gboolean forced_local_ip_changed (property_t prop)
gboolean local_addr_changed (property_t prop)
gboolean configured_peermode_changed (property_t prop)
gboolean current_peermode_changed (property_t prop)
gboolean download_rx_size_changed (property_t prop)
gboolean node_rx_size_changed (property_t prop)
void reset_property_cb (cqueue_t *unused_cq, gpointer obj)
 callout queue callback
gboolean file_descriptor_x_changed (property_t prop)

Variables

const gchar config_file [] = "config_gnet"
const gchar ul_stats_file [] = "upload_stats"
const mode_t IPC_DIR_MODE = S_IRUSR | S_IWUSR | S_IXUSR
const mode_t PID_FILE_MODE = S_IRUSR | S_IWUSR
const mode_t CONFIG_DIR_MODE
gchar * home_dir = NULL
gchar * config_dir = NULL
prop_set_tproperties = NULL
const gchar pidfile [] = "gtk-gnutella.pid"
gboolean settings_init_running
cevent_tev_file_descriptor_shortage
cevent_tev_file_descriptor_runout
prop_map_t property_map []
gboolean init_list [GNET_PROPERTY_NUM]


Define Documentation

#define PROPERTY_MAP_SIZE   G_N_ELEMENTS(property_map)
 

#define RESET_PROP_TM   (10*60*1000)
 

10 minutes in ms


Typedef Documentation

typedef struct prop_map prop_map_t
 


Function Documentation

void addr_ipv4_changed const host_addr_t  new_addr,
const host_addr_t  peer
[static]
 

void addr_ipv6_changed const host_addr_t  new_addr,
const host_addr_t  peer
[static]
 

gboolean bw_allow_stealing_changed property_t  prop  )  [static]
 

gboolean bw_gnet_in_changed property_t  prop  )  [static]
 

gboolean bw_gnet_in_enabled_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lin_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lin_enabled_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lout_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lout_enabled_changed property_t  prop  )  [static]
 

gboolean bw_gnet_out_changed property_t  prop  )  [static]
 

gboolean bw_gnet_out_enabled_changed property_t  prop  )  [static]
 

gboolean bw_http_in_changed property_t  prop  )  [static]
 

gboolean bw_http_in_enabled_changed property_t  prop  )  [static]
 

gboolean bw_http_out_changed property_t  prop  )  [static]
 

gboolean bw_http_out_enabled_changed property_t  prop  )  [static]
 

void bw_stats gnet_bw_stats_t s,
gboolean  enabled,
bsched_bws_t  bws
[static]
 

gboolean bw_switch property_t  prop,
bsched_bws_t  bs
[static]
 

gboolean configured_peermode_changed property_t  prop  )  [static]
 

gboolean current_peermode_changed property_t  prop  )  [static]
 

gboolean download_rx_size_changed property_t  prop  )  [static]
 

gboolean enable_local_socket_changed property_t  prop  )  [static]
 

gboolean enable_udp_changed property_t  prop  )  [static]
 

gint ensure_unicity const gchar *  file,
gboolean  check_only
[static]
 

Look for any existing PID file.

If found, look at the pid recorded there and make sure it has died. Abort operations if it hasn't...

Returns:
On success a non-negative value is returned. If check_only was FALSE, the file descriptor of the pidfile is returned, if check_only was TRUE, zero is returned on success. On failure errno is set to EEXIST, if the PID file was already locked. Other errno values imply that the PID file could not be created.

gboolean file_descriptor_x_changed property_t  prop  )  [static]
 

gboolean file_path_changed property_t  prop  )  [static]
 

gboolean forced_local_ip_changed property_t  prop  )  [static]
 

guint32 get_average_ip_lifetime time_t  now,
enum net_type  net
 

Compute the EMA of the IP address lifetime up to now, but do not update the property.

guint32 get_average_servent_uptime time_t  now  ) 
 

Compute the EMA of the averate servent uptime, up to now, but do not update the property.

host_addr_t get_bind_addr enum net_type  net  )  [static]
 

void gnet_get_bw_stats gnet_bw_source  type,
gnet_bw_stats_t s
 

gboolean hard_ttl_limit_changed property_t  prop  )  [static]
 

gboolean is_my_address const host_addr_t  addr  ) 
 

gboolean is_my_address_and_port const host_addr_t  addr,
guint16  port
 

gboolean lib_debug_changed property_t  unused_prop  )  [static]
 

host_addr_t listen_addr void   ) 
 

Returns:
the currently used local listening address.

host_addr_t listen_addr6 void   ) 
 

Returns:
the currently used local listening address.

host_addr_t listen_addr_by_net enum net_type  net  ) 
 

gboolean listen_port_changed property_t  prop  )  [static]
 

gboolean local_addr_changed property_t  prop  )  [static]
 

gboolean local_netmasks_string_changed property_t  prop  )  [static]
 

gboolean max_bad_hosts_cached_changed property_t  prop  )  [static]
 

gboolean max_connections_changed property_t  prop  )  [static]
 

gboolean max_hosts_cached_changed property_t  prop  )  [static]
 

gboolean max_ttl_changed property_t  prop  )  [static]
 

gboolean max_ultra_hosts_cached_changed property_t  prop  )  [static]
 

gboolean network_protocol_changed property_t  prop  )  [static]
 

gboolean node_online_mode_changed property_t  prop  )  [static]
 

gboolean node_rx_size_changed property_t  prop  )  [static]
 

gboolean node_sendqueue_size_changed property_t  unused_prop  )  [static]
 

void request_new_sockets guint16  port,
gboolean  check_firewalled
[static]
 

void reset_property_cb cqueue_t unused_cq,
gpointer  obj
[static]
 

callout queue callback

Reset the property.

void save_pid gint  fd  )  [static]
 

Write our pid to the pidfile.

gboolean scan_extensions_changed property_t  prop  )  [static]
 

void settings_addr_changed const host_addr_t  new_addr,
const host_addr_t  peer
 

This routine is called when we determined that our IP was no longer the one we computed.

We base this on some headers sent back when we handshake with other nodes, and as a result, cannot trust the information.

What we do henceforth is trust 3 successive indication that our IP changed, provided we get the same information each time.

--RAM, 13/01/2002

Parameters:
`new_addr' the newly suggested address.
`peer' the IP address of peer which reported the new IP address.
There must be 3 peers from 3 different /16 networks before a change is accepted. Otherwise, it would be very easy to confuse GTKG by connecting 3 times in a row and submitting a *wrong* IP address.

--cbiere, 2004-08-01

void settings_callbacks_init void   )  [static]
 

void settings_callbacks_shutdown void   )  [static]
 

void settings_close void   ) 
 

Finally free all memory allocated.

Call after settings_shutdown.

const gchar* settings_config_dir void   ) 
 

Get the config directory.

enum net_type settings_dns_net void   ) 
 

Returns:
The "net" parameter to use for name_to_host_addr() according to the current configuration.

void settings_early_init void   ) 
 

Initializes "config_dir" and "home_dir".

gint settings_ensure_unicity gboolean  check_only  ) 
 

Tries to ensure that the current process is the only running instance gtk-gnutella for the current value of GTK_GNUTELLA_DIR.

Parameters:
check_only If TRUE, no warnings are emitted and a possibly created PID file is automagically removed.
Returns:
On success zero is returned, otherwise a non-zero is returned and errno is set.

const gchar* settings_home_dir void   ) 
 

Gets the home dir.

void settings_init void   ) 
 

const gchar* settings_ipc_dir void   ) 
 

Gets the IPC directory.

const gchar* settings_local_socket_path void   ) 
 

Gets the path of the local socket.

guint32 settings_max_msg_size void   ) 
 

Maximum message payload size we are configured to handle.

void settings_remove_pidfile void   )  [static]
 

Remove pidfile.

void settings_save_if_dirty void   ) 
 

Save settings if dirty.

void settings_shutdown void   ) 
 

Called at exit time to flush the property files.

gboolean shared_dirs_paths_changed property_t  prop  )  [static]
 

gboolean up_connections_changed property_t  prop  )  [static]
 

void update_address_lifetime void   )  [static]
 

Called whenever the IP address we advertise changed.

Update the average uptime for a given IP address.

void update_uptimes void   )  [static]
 

Called at shutdown time to update the average_uptime property before saving the properties to disk.


Variable Documentation

gchar* config_dir = NULL [static]
 

const mode_t CONFIG_DIR_MODE [static]
 

Initial value:

    S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP

const gchar config_file[] = "config_gnet" [static]
 

cevent_t* ev_file_descriptor_runout [static]
 

cevent_t* ev_file_descriptor_shortage [static]
 

gchar* home_dir = NULL [static]
 

gboolean init_list[GNET_PROPERTY_NUM] [static]
 

const mode_t IPC_DIR_MODE = S_IRUSR | S_IWUSR | S_IXUSR [static]
 

const mode_t PID_FILE_MODE = S_IRUSR | S_IWUSR [static]
 

const gchar pidfile[] = "gtk-gnutella.pid" [static]
 

prop_set_t* properties = NULL [static]
 

prop_map_t property_map[] [static]
 

gboolean settings_init_running [static]
 

const gchar ul_stats_file[] = "upload_stats" [static]
 


Generated on Sat Jun 30 17:53:30 2007 for gtk-gnutella by  doxygen 1.3.9.1