Hello,
Please find attached a patch to add oma user-profile and pres-content (avatar) support to the xcap_server module.
To make use of these changes I also had to update my kamailio.cfg (based on the example from http://kb.asipto.com/kamailio:presence:k31-made-simple). In particular I had to update the event_route[xhttp:request] clause so that:
* the xcap-caps response includes the auids and namespace entries for user-profile and pres-content * modify the auth user checking because (unlike the XML documents that were already there) any user can retrieve user-profile and pres-content, but only the owner can update them.
For reference, my updated event_route[xhttp:request] clause is included below.
Regards,
Peter
event_route[xhttp:request] { #!ifdef WITH_PRESENCE xdbg("===== xhttp: request [$rv] $rm => $hu\n"); #!ifdef WITH_XHTTPAUTH if (!www_authorize("xcap", "subscriber")) { www_challenge("xcap", "0"); exit; } #!endif
if($hu=~"^/xcap-root/") { set_reply_close(); set_reply_no_connect(); # xcap ops $xcapuri(u=>data) = $hu; if($xcapuri(u=>xuid)=~"^sip:.+@.+") $var(uri) = $xcapuri(u=>xuid); else if($xcapuri(u=>xuid)=~".+@.+") $var(uri) = "sip:" + $xcapuri(u=>xuid); else $var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri; if($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> <auid>org.openmobilealliance.user-profile</auid> <auid>org.openmobilealliance.pres-conent</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> <namespace>urn:oma:xml:xdm:user-profile</namespace> <namespace>urn:oma:xml:prs:pres-content</namespace> </namespaces> </xcap-caps>"; xhttp_reply("200", "ok", "application/xcap-caps+xml", "$var(xbody)"); exit; }
switch($rm) { case "PUT": #!ifdef WITH_XHTTPAUTH # be sure only auth user updates its documents if ($au!=$(var(uri){uri.user})) { xhttp_reply("403", "Forbidden", "text/html", "<html><body>$si:$sp</body></html>"); exit; } #!endif 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": #!ifdef WITH_XHTTPAUTH if (!($xcapuri(u=>auid)=~"user-profile" || $xcapuri(u=>auid)=~"pres-content")) { # be sure only auth user gets non-profile documents if ($au!=$(var(uri){uri.user})) { xhttp_reply("403", "Forbidden", "text/html", "<html><body>$si:$sp</body></html>"); exit; } } #!endif xcaps_get("$var(uri)", "$hu"); exit; break; case "DELETE": #!ifdef WITH_XHTTPAUTH # be sure only auth user deletes its documents if ($au!=$(var(uri){uri.user})) { xhttp_reply("403", "Forbidden", "text/html", "<html><body>$si:$sp</body></html>"); exit; } #!endif 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; } }
# http ops xhttp_reply("200", "ok", "text/html", "<html><body>OK: $si:$sp</body></html>"); exit; #!endif }