int users_init(){ int r; default_user_locale=config_load_string("default_locale"); spool_dir=config_load_string("spool"); if (!spool_dir) g_error(L_("No <spool/> defined in config file")); r=chdir(spool_dir); if (r) g_error(L_("Couldn't enter %s: %s"),spool_dir,g_strerror(errno)); users_jid=g_hash_table_new(g_str_hash,g_str_equal); if (!users_jid) return -1; users_tick_source=g_timeout_add(60000,users_tick,NULL); return 0; }
int jabber_init(){ xmlnode node; stream_add_destroy_handler(jabber_stream_destroyed); node=xmlnode_get_tag(config,"service"); if (!node) error_exit("%s", L_("No <service/> found in config file")); my_name=xmlnode_get_attrib(node,"jid"); if (!my_name) error_exit("%s", L_("<service/> without \"jid\" in config file")); node=xmlnode_get_tag(config, "bare_domain"); if (node) bare_domain=1; server=config_load_string("connect/ip"); if (!server) error_exit("%s", L_("Jabberd server not found in config file")); port=config_load_int("connect/port",0); if (port<=0) error_exit("%s", L_("Connect port not found in config file")); node=xmlnode_get_tag(config,"connect/secret"); if (node) secret=xmlnode_get_data(node); if (!node || !secret) error_exit("%s", L_("Connect secret not found in config file")); register_instructions=config_load_formatted_string("register/instructions"); if (!register_instructions) error_exit("%s", L_("Registration instructions not not found in config file")); search_instructions=config_load_formatted_string("search/instructions"); if (!search_instructions) error_exit("%s", L_("Search instructions not found in config file")); gateway_desc=config_load_formatted_string("gateway/desc"); if (!gateway_desc) error_exit("%s", L_("Gateway instructions not found in config file")); gateway_prompt=config_load_formatted_string("gateway/prompt"); if (!gateway_prompt) error_exit("%s", L_("Gateway prompt not found in config file")); jabber_state=JS_NONE; return 0; }
int sessions_init(){ char *proxy_ip,*proxy_username,*proxy_password,*proxy_http_only; char *p,*r; int port; int i; xmlnode parent,tag; GgServer *server; stream_add_destroy_handler(sessions_stream_destroyed); sessions_jid=g_hash_table_new(g_str_hash,g_str_equal); if (!sessions_jid) return -1; i=config_load_int("conn_timeout",0); if (i>0) conn_timeout=i; i=config_load_int("pong_timeout",0); if (i>0) pong_timeout=i; i=config_load_int("ping_interval",0); if (i>0) ping_interval=i; i=config_load_int("reconnect",0); if (i>0) reconnect=i; i=config_load_int("server_cutoff",0); if (i>0) cutoff=i; i=config_load_int("server_cutoff_timeout",0); if (i>0) cutoff_timeout=i; tag = xmlnode_get_tag(config, "ignore_system_messages"); if (!tag) { ignore_system_messages = ISM_IGNORE_NONE; } else { r=xmlnode_get_attrib(tag, "which"); if (r && !g_strcasecmp(r,"html")) { ignore_system_messages = ISM_IGNORE_HTML; } else { ignore_system_messages = ISM_IGNORE_ALL; } } parent=xmlnode_get_tag(config,"servers"); if (parent && xmlnode_has_children(parent)){ gg_servers=NULL; for(tag=xmlnode_get_firstchild(parent); tag!=NULL; tag=xmlnode_get_nextsibling(tag)){ if(xmlnode_get_type(tag) != NTYPE_TAG) continue; p=xmlnode_get_name(tag); if (strcmp(p, "hub")==0){ server=g_new(GgServer, 1); server->port=1; gg_servers=g_list_append(gg_servers, server); } else if (strcmp(p, "server")==0){ server=g_new(GgServer, 1); server->error_count=0; r=xmlnode_get_attrib(tag, "port"); if (r) server->port=atoi(r); else server->port=8074; r=xmlnode_get_data(tag); if(inet_aton(r, &server->addr)) gg_servers=g_list_append(gg_servers, server); } else continue; r=xmlnode_get_attrib(tag, "tls"); if (r && !g_strcasecmp(r,"no")) server->tls=0; else server->tls=1; } } else{ server=g_new(GgServer, 1); server->port=1; server->tls=0; gg_servers=g_list_append(gg_servers, server); server=g_new(GgServer, 1); server->error_count=0; inet_aton("217.17.45.145", &server->addr); server->port=8074; server->tls=0; gg_servers=g_list_append(gg_servers, server); } proxy_ip=config_load_string("proxy/ip"); if (!proxy_ip) return 0; port=config_load_int("proxy/port",0); if (port<=0) return 0; proxy_username=config_load_string("proxy/username"); proxy_password=config_load_string("proxy/password"); tag=xmlnode_get_tag(config,"proxy"); proxy_http_only=xmlnode_get_attrib(tag,"http_only"); g_message(L_("Using proxy: http://%s:%i"),proxy_ip,port); gg_proxy_enabled=1; gg_proxy_host=proxy_ip; gg_proxy_port=port; if (proxy_username && proxy_password){ gg_proxy_username=proxy_username; gg_proxy_password=proxy_password; } if (proxy_http_only && strcmp(proxy_http_only,"no")){ gg_proxy_http_only=1; } return 0; }