Hello,
xcap does not work with subscriber table and you cannot download the
list of subscribers. It uses xcap table from database, where it can
store contact list or other presence related records/rules.
I am pasting the routing blocks related to xcap that I have in one of my
configs (planned to be used for updating the tutorial online that I
wrote a while ago:
http://kb.asipto.com/kamailio:presence:k31-made-simple -- but due to
lack of spare time, I kept postponing).
Hope it is useful.
Cheers,
Daniel
event_route[xhttp:request] {
xdbg("===== xhttp: request [$rv] $rm => $hu\n");
set_reply_no_connect();
if ($Rp != 80
#!ifdef WITH_TLS
&& $Rp != 443
#!endif
) {
set_reply_close();
xlog("L_WARN", "HTTP request received on $Rp\n");
xhttp_reply("403", "Forbidden", "", "");
exit;
}
if (!www_authorize("domain.com", "subscriber"))
{
www_challenge("domain.com", "0");
exit;
}
set_reply_close();
route(XCAPSRV);
# other http access
xhttp_reply("200", "ok", "text/html",
"<html><body>OK:
$si:$sp</body></html>");
exit;
}
route[XCAPSRV] {
#!ifdef WITH_XCAPSRV
if(! ($hu=~"^/xcap-root/")) {
return;
}
# xcap ops - break down http uri to get xcap user id
route(XCAPURI);
$xcapuri(u=>data) = $var(hu);
if($xcapuri(u=>uri)==$null) {
xlog("==== xhttp failed uri => [$hu] ~ [$var(hu)]\n");
xhttp_reply("404", "Not Found", "text/html",
"unsupported xcap uri");
exit;
}
if($xcapuri(u=>xuid)=~"^sip:.+@.+")
$var(uri) = $xcapuri(u=>xuid);
else
$var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri;
# handle XCAP capability request
if($xcapuri(u=>auid)=="xcap-caps") {
if ($rm == "GET") {
$var(xbody) =
"<?xml version='1.0' encoding='UTF-8'?>
<xcap-caps xmlns='urn:ietf:params:xml:ns:xcap-caps'>
<auids>
" +
#!ifdef WITH_RLS
" <auid>rls-services</auid>
" +
#!endif
" <auid>pidf-manipulation</auid>
<auid>xcap-caps</auid>
<auid>resource-lists</auid>
<auid>pres-rules</auid>
<auid>org.openmobilealliance.pres-rules</auid>
<auid>org.openmobilealliance.user-profile</auid>
<auid>org.openmobilealliance.pres-content</auid>
<auid>org.openmobilealliance.search</auid>
<auid>org.openmobilealliance.xcap-directory</auid>
</auids>
<extensions>
</extensions>
<namespaces>
" +
#!ifdef WITH_RLS
" <namespace>urn:ietf:params:xml:ns:rls-services</namespace>
" +
#!endif
" <namespace>urn:ietf:params:xml:ns:pidf</namespace>
<namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>
<namespace>urn:ietf:params:xml:ns:resource-lists</namespace>
<namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
<namespace>urn:oma:xml:xdm:user-profile</namespace>
<namespace>urn:oma:xml:prs:pres-content</namespace>
<namespace>urn:oma:xml:xdm:search</namespace>
<namespace>urn:oma:xml:xdm:xcap-directory</namespace>
</namespaces>
</xcap-caps>";
xhttp_reply("200", "ok",
"application/xcap-caps+xml",
"$var(xbody)");
} else {
append_to_reply("Allow: GET\r\n");
xhttp_reply("405", "Method Not Allowed", "",
"");
}
exit;
}
# be sure auth user access only its documents
if ($rm!="GET" && $au!=$(var(uri){uri.user})) {
xlog("==== xhttp forbidden => [$au] != [$(var(uri){uri.user})]\n");
xhttp_reply("403", "Forbidden", "text/html",
"operation not allowed");
exit;
}
xdbg("SCRIPT: xcap service $xcapuri(u=>auid) for
$xcapuri(u=>xuid)\n");
switch($rm) {
case "PUT":
xcaps_put("$var(uri)", "$var(hu)", "$rb");
if($xcapuri(u=>auid)=~"pres-rules")
{
pres_update_watchers("$var(uri)", "presence");
pres_refresh_watchers("$var(uri)", "presence", 1);
#!ifdef WITH_RLS
} else if($xcapuri(u=>auid)=~"rls-services"
|| $xcapuri(u=>auid)=~"resource-lists") {
rls_update_subs("$var(uri)", "presence");
#!endif
} else if($xcapuri(u=>auid)=~"pidf-manipulation") {
pres_refresh_watchers("$var(uri)", "presence", 2,
"$xcapuri(u=>uri_adoc)",
"$xcapuri(u=>file)");
}
exit;
break;
case "GET":
$var(furi) = "sip:" + $au + "@" + $ar;
if ($au!=$(var(uri){uri.user})) {
# be sure only auth user gets its non-profile documents
if (!($xcapuri(u=>auid)=~"user-profile"
|| $xcapuri(u=>auid)=~"pres-content")) {
xhttp_reply("403", "Forbidden", "",
"");
exit;
} else {
# be sure only permitted user gets others profile
documents
pres_auth_status("$var(furi)", "$var(uri)");
$var(rc) = $rc;
if ($var(rc) != 1) {
xhttp_reply("403", "Forbidden", "",
"");
exit;
}
}
}
xcaps_get("$var(uri)", "$var(hu)");
exit;
break;
case "DELETE":
xcaps_del("$var(uri)", "$var(hu)");
if($xcapuri(u=>auid)=~"pres-rules") {
pres_update_watchers("$var(uri)", "presence");
pres_refresh_watchers("$var(uri)", "presence", 1);
#!ifdef WITH_RLS
} else if($xcapuri(u=>auid)=~"rls-services"
|| $xcapuri(u=>auid)=~"resource-lists") {
rls_update_subs("$var(uri)", "presence");
#!endif
} else if($xcapuri(u=>auid)=~"pidf-manipulation") {
pres_refresh_watchers("$var(uri)", "presence", 2,
"$xcapuri(u=>uri_adoc)",
"$xcapuri(u=>file)");
}
exit;
break;
case "POST":
if($xcapuri(u=>auid)=~"search") {
xhttp_reply("501", "Not Implemented", "",
"");
} else {
if($xcapuri(u=>auid)=~"xcap-directory") {
append_to_reply("Allow: GET\r\n");
} else {
append_to_reply("Allow: DELETE, GET, PUT\r\n");
}
xhttp_reply("405", "Method Not Allowed",
"", "");
}
exit;
break;
}
#!endif
return;
}
# Return fixed XCAP URI in $var(hu)
route[XCAPURI] {
#!ifdef WITH_XCAPSRV
# Jitsi...
if ($hu=~"^/xcap-root/resource-lists/users/.*/index$") {
$var(hu) =
$(hu{re.subst,!(^/xcap-root/resource-lists/users/.*/).*$!\1generallist.xml!});
} else if ($hu=~"^/xcap-root/pres-rules/users/.*/presrules$") {
$var(hu) =
$(hu{re.subst,!(^/xcap-root/)pres-rules(/users/.*/)presrules!\1org.openmobilealliance.pres-rules\2pres-rules!});
} else if ($hu=~"^/xcap-root/oma_status-icon/users/.*/.*$") {
$var(hu) =
$(hu{re.subst,!(^/xcap-root/)oma_status-icon(/users/.*/).*$!\1org.openmobilealliance.pres-content\2oma_status-icon/icon_document!});
# Bria...
} else if
($hu=~"^/xcap-root/resource-lists/users/.*/contacts-resource-list.xml$") {
$var(hu) =
$(hu{re.subst,!(^/xcap-root/resource-lists/users/.*/).*$!\1generallist.xml!});
} else if
($hu=~"^/xcap-root/resource-lists/users/.*/resource-list.xml$") {
$var(doc_uri) =
$(hu{re.subst,!(^/xcap-root/resource-lists/users/.*/).*$!\1generallist.xml!});
# No modification required...
} else {
$var(hu) = $hu;
}
#!endif
return;
}
On 7/18/13 5:54 PM, Kethzer Docteur wrote:
Im trying to run Xcap_server support on Kamailio but I
got no luck in
the configuration I load all module necessary for the operation to
succeed but nothing. I guess I'm missing something but I can't tell
cause I install all dependencies in order to get it running. Here is
my set up please let me know if you can give me a hand with this I'd
like that cause I'm stuck here
# *** Value defines - IDs used later in config
#!define WITH_AUTH
#!define WITH_PRESENCE
#!define WITH_XCAPSRV
#!define WITH_NAT
#!define WITH_TLS
#!define WITH_ANTIFLOOD
#!define WITH_MYSQL
#!ifdef WITH_XCAPSRV
tcp_accept_no_cl=yes
#!endif
#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!ifdef WITH_IPAUTH
loadmodule "permissions.so"
#!endif
#!endif
#!ifdef WITH_PRESENCE
loadmodule "presence.so"
loadmodule "presence_xml.so"
#!endif
#!ifdef WITH_XCAPSRV
loadmodule "xhttp.so"
loadmodule "xcap_server.so"
#!endif
# ----- xcap_server params -----
modparam("xcap_server", "db_url",
"mysql://kamailio:kamailiorw@localhost/kamailio")
event_route[xhttp:request] {
if (!www_authorize("xcap", "subscriber"))
{
www_challenge("xcap", "0");
exit;
}
if($hu=~"^/xcap-root/")
{
set_reply_close();
set_reply_no_connect();
# xcap ops - break down http uri to get xcap user id
$xcapuri(u=>data) = $hu;
if($xcapuri(u=>xuid)=~"^sip:.+@.+")
$var(uri) = $xcapuri(u=>xuid);
else
$var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri;
# handle XCAP capability request
if($rm=="GET" && $xcapuri(u=>auid)=="xcap-caps")
{
$var(xbody) =
"<?xml version='1.0' encoding='UTF-8'?>
<xcap-caps xmlns='urn:ietf:params:xml:ns:xcap-caps'>
<auids>
<auid>rls-services</auid>
<auid>pidf-manipulation</auid>
<auid>xcap-caps</auid>
<auid>resource-lists</auid>
<auid>pres-rules</auid>
<auid>org.openmobilealliance.pres-rules</auid>
</auids>
<extensions>
</extensions>
<namespaces>
<namespace>urn:ietf:params:xml:ns:rls-services</namespace>
<namespace>urn:ietf:params:xml:ns:pidf</namespace>
<namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>
<namespace>urn:ietf:params:xml:ns:resource-lists</namespace>
<namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
</namespaces>
</xcap-caps>";
xhttp_reply("200", "ok",
"application/xcap-caps+xml",
"$var(xbody)");
exit;
}
# be sure auth user access only its documents
if ($au!=$(var(uri){uri.user})) {
xhttp_reply("403", "Forbidden", "text/html",
"operation not allowed");
exit;
}
xdbg("SCRIPT: xcap service $xcapuri(u=>auid) for
$xcapuri(u=>xuid)\n");
switch($rm) {
case "PUT":
xcaps_put("$var(uri)", "$hu", "$rb");
if($xcapuri(u=>auid)=~"pres-rules")
{
pres_update_watchers("$var(uri)", "presence");
pres_refresh_watchers("$var(uri)", "presence",
1);
}
exit;
break;
case "GET":
xcaps_get("$var(uri)", "$hu");
exit;
break;
case "DELETE":
xcaps_del("$var(uri)", "$hu");
if($xcapuri(u=>auid)=~"pres-rules")
{
pres_update_watchers("$var(uri)", "presence");
pres_refresh_watchers("$var(uri)", "presence",
1);
}
exit;
break;
}
}
# other http requests
xhttp_reply("200", "OK", "text/html",
"<html><body>OK: $si:$sp</body></html>");
exit;
}
On Thu, Jul 18, 2013 at 11:22 AM, Edson - Lists <4lists(a)gmail.com
<mailto:4lists@gmail.com>> wrote:
Did you try it? What you got? What happened? What is your scenario?
Tell, and maybe someone would help you...
Edson.
Em 18/07/2013 11:51, Kethzer Docteur escreveu:
Hello
Im trying to get xcap service working to be able to download my
subscriber list form the subscriber table. I hope that you
could help me
with this in anyway possible
Thank you
--
Kethzer Docteur
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
mailing list
sr-users(a)lists.sip-router.org
<mailto:sr-users@lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
list
sr-users(a)lists.sip-router.org <mailto:sr-users@lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Kethzer Docteur
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla -
http://www.asipto.com
http://twitter.com/#!/miconda -
http://www.linkedin.com/in/miconda