
function network_get_info()
{
	var info, if_iter, prof, defname, ifaces, iface, net;
	info = new Object();
	
	net = beos.binder.service.network;	
	defname = net.dialer.default_profile;
	prof = net.dialer.profiles[defname];
	
	ifaces = beos.binder.service.network.interfaces;
	i = 0;
	if_iter = ifaces[i];
	
	iface = if_iter.value;
	
	
	info.connection = "unknown";
	if(prof.autodial == "1") info.connection = "ppp";
	if(iface.dhcp == "1") info.connection = "dhcp";

	info.ppp = net.pppstatus;
	info.dhcp = "offline";
	
	if(info.ppp != "connected" && net.status == "up")
		info.dhcp = "online";
			
	if(info.connection == "ppp")
	{
		info.user = prof.user;
		info.pass = prof.password;
		info.phone = prof.phone_number;
		info.init = prof.modeminit;
	} else {
		info.ip = iface.address;
		info.gw = net.routes.default_route.address;	

	}
	return info;
}

function network_dial_ppp() 
{
	beos.binder.service.network.PPP_Up();
}

function network_hangup_ppp()
{
	beos.binder.service.network.PPP_Down();
}

function network_use_ppp()
{
	var obj, defname, ifaces, iface, if_iter;
	
	defname = beos.binder.service.network.dialer.default_profile;
	obj = beos.binder.service.network.dialer.profiles[defname];
	obj.autodial = "1";
	
	ifaces = beos.binder.service.network.interfaces;
	i=0;
	if_iter = ifaces[i];
	
	iface = if_iter.value;
	iface.dhcp = "0";
	//beos.binder.service.network.Apply();
}

function network_use_dhcp()
{
	var obj, defname, ifaces, iface, if_iter;
	
	defname = beos.binder.service.network.dialer.default_profile;
	obj = beos.binder.service.network.dialer.profiles[defname];
	obj.autodial = "0";
	
	ifaces = beos.binder.service.network.interfaces;
	i=0;
	if_iter = ifaces[i];
	
	iface = if_iter.value;
	iface.dhcp = "1";
	//beos.binder.service.network.Apply();
}

function network_set_user(user)
{
	var obj, defname;
	
	defname = beos.binder.service.network.dialer.default_profile;
	obj = beos.binder.service.network.dialer.profiles[defname];
	obj.user = user;
}

function network_set_pass(pass)
{
	var obj, defname;
	
	defname = beos.binder.service.network.dialer.default_profile;
	obj = beos.binder.service.network.dialer.profiles[defname];
	obj.password = pass;
}

function network_set_phone(phone)
{
	var obj, defname;
	
	defname = beos.binder.service.network.dialer.default_profile;
	obj = beos.binder.service.network.dialer.profiles[defname];
	obj.phone_number = phone;
}

function network_set_init(str)
{	
	var obj, defname;
	
	defname = beos.binder.service.network.dialer.default_profile;
	obj = beos.binder.service.network.dialer.profiles[defname];
	obj.modeminit = str;
}
