#
# configuration for Jabber module testing
#
# $ID: daniel $
#
#
# sample of Jabber module usage
#

debug=9          # debug level (cmd line: -dddddddddd)
#fork=yes          # (cmd. line: -D)
fork=no
log_stderror=yes  # (cmd line: -E)
#log_stderror=no   # (cmd line: -E)


children=2
check_via=no      # (cmd. line: -v)
dns=off           # (cmd. line: -r)
rev_dns=off       # (cmd. line: -R)
port=5060
listen=10.0.0.1

# for more info: sip_router -h

#modules
loadmodule "modules/print/print.so"
loadmodule "modules/textops/textops.so"
loadmodule "modules/tm/tm.so"

loadmodule "modules/im/im.so"
loadmodule "modules/maxfwd/maxfwd.so"
loadmodule "modules/sl/sl.so"
loadmodule "modules/mysql/mysql.so"
loadmodule "modules/jabber/jabber.so"

modparam("jabber","db_url","mysql://user:***@127.0.0.1/sip_jab")
modparam("jabber","jaddress","127.0.0.1")
modparam("jabber","jport",5222)
modparam("jabber","workers",2)
modparam("jabber","max_jobs",10)
modparam("jabber","aliases","3;icq.domain.com;msn.domain.com;yahoo.domain.com;")
modparam("jabber","jdomain","jabber.domain.com")

route{

	if ((search("To:.*@icq\.domain\.com"))
	    || (search("To:.*@jabber\.domain\.de"))
	    || (search("To:.*@msn\.domain\.com"))
	    || (search("To:.*@yahoo\.domain\.com")))
	{
		if (method=="MESSAGE")
		{
			log("MESSAGE received -> manage it with XJAB\n");
			if(search("\n:online"))
			{
				if (jab_go_online())
				{
					sl_send_reply("200","Accepted");
				}else{
					sl_send_reply("404","Not found");
				};
				break;
			};
			if(search("\n:offline"))
			{
				if (jab_go_offline())
				{
					sl_send_reply("200","Accepted");
				}else{
					sl_send_reply("404","Not found");
				};
				break;
			};
			if(search("\n:join"))
			{
				if (jab_join_jconf())
				{
					sl_send_reply("200","Accepted");
				}else{
					sl_send_reply("404","Not Found");
				};
				break;
			};
			if(search("\n:exit"))
			{
				if (jab_exit_jconf())
				{
					sl_send_reply("200","Accepted");
				}else{
					sl_send_reply("404","Not Found");
				};
				break;
			};
			if (jab_send_message())
			{
				sl_send_reply("200","Accepted");
			}else{
				sl_send_reply("503","Service Unavailable");
			};
			break;
		};
	};
	forward(uri:host,uri:port);
}
