Esempio n. 1
0
File: xmlnode.c Progetto: bcy/muc
xmlnode xmlnode_insert_tag_node(xmlnode parent, xmlnode node)
{
    xmlnode child;

    child = xmlnode_insert_tag(parent, xmlnode_get_name(node));
    if (xmlnode_has_attribs(node))
        xmlnode_insert_node(child, xmlnode_get_firstattrib(node));
    if (xmlnode_has_children(node))
        xmlnode_insert_node(child, xmlnode_get_firstchild(node));

    return child;
}
Esempio n. 2
0
File: xmlnode.c Progetto: bcy/muc
static spool _xmlnode2spool(xmlnode node)
{
    spool s;
    int level=0,dir=0;
    xmlnode tmp;

    if(!node || xmlnode_get_type(node)!=NTYPE_TAG)
        return NULL;

    s = spool_new(xmlnode_pool(node));
    if(!s) return(NULL);

    while(1)
    {
        if(dir==0)
        {
    	    if(xmlnode_get_type(node) == NTYPE_TAG)
            {
                if(xmlnode_has_children(node))
                {
                    _xmlnode_tag2str(s,node,1);
                    node = xmlnode_get_firstchild(node);
                    level++;
                    continue;
                }else{
                    _xmlnode_tag2str(s,node,0);
                }
            }else{
                spool_add(s,strescape(xmlnode_pool(node),xmlnode_get_data(node)));
            }
        }

    	tmp = xmlnode_get_nextsibling(node);
        if(!tmp)
        {
            node = xmlnode_get_parent(node);
            level--;
            if(level>=0) _xmlnode_tag2str(s,node,2);
            if(level<1) break;
            dir = 1;
        }else{
            node = tmp;
            dir = 0;
        }
    }

    return s;
}
Esempio n. 3
0
File: xmlnode.c Progetto: bcy/muc
xmlnode xmlnode_dup_pool(pool p, xmlnode x)
{
    xmlnode x2;

    if(x == NULL)
        return NULL;

    x2 = xmlnode_new_tag_pool(p, xmlnode_get_name(x));

    if (xmlnode_has_attribs(x))
        xmlnode_insert_node(x2, xmlnode_get_firstattrib(x));
    if (xmlnode_has_children(x))
        xmlnode_insert_node(x2, xmlnode_get_firstchild(x));

    return x2;
}
Esempio n. 4
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;
}