Hi Peter,
thanks for the patches. I will add them to the module.
Also, I will start a new wiki page for the presence+xcap sever config
that should be valid for development version (to be released 3.2.0), in
order to make it easy for those willing to play with latest additions in
this regard.
Cheers,
Daniel
On 5/12/11 12:32 PM, Peter Dunkley wrote:
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).
<http://kb.asipto.com/kamailio:presence:k31-made-simple%29.%A0> 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
}
--
Peter Dunkley
Technical Director
Crocodile RCS Ltd
user_profile_avatar.patch
diff -ru kamailio-orig/modules_k/xcap_client/xcap_callbacks.h
kamailio-updated/modules_k/xcap_client/xcap_callbacks.h
--- kamailio-orig/modules_k/xcap_client/xcap_callbacks.h 2011-03-07 13:43:33.914172000
+0000
+++ kamailio-updated/modules_k/xcap_client/xcap_callbacks.h 2011-05-11 17:37:13.067141000
+0100
@@ -36,6 +36,8 @@
#define RLS_SERVICE 1<<3
#define PIDF_MANIPULATION 1<<4
#define XCAP_CAPS 1<<5
+#define USER_PROFILE 1<<6
+#define PRES_CONTENT 1<<7
/* callback function prototype */
diff -ru kamailio-orig/modules_k/xcap_server/xcap_misc.c
kamailio-updated/modules_k/xcap_server/xcap_misc.c
--- kamailio-orig/modules_k/xcap_server/xcap_misc.c 2011-03-07 13:43:33.914172000 +0000
+++ kamailio-updated/modules_k/xcap_server/xcap_misc.c 2011-05-11 17:37:13.067141000
+0100
@@ -153,6 +153,14 @@
LM_DBG("matched xcap-caps\n");
xuri->type = XCAP_CAPS;
xuri->auid.len = 9;
+ } else if(s.len> 36&& strncmp(s.s,
"org.openmobilealliance.user-profile/", 36)==0) {
+ LM_DBG("matched oma user-profile\n");
+ xuri->type = USER_PROFILE;
+ xuri->auid.len = 35;
+ } else if(s.len> 36&& strncmp(s.s,
"org.openmobilealliance.pres-content/", 36)==0) {
+ LM_DBG("matched oma pres-content\n");
+ xuri->type = PRES_CONTENT;
+ xuri->auid.len = 35;
} else {
LM_ERR("unsupported auid in [%.*s]\n", xuri->uri.len,
xuri->uri.s);
diff -ru kamailio-orig/modules_k/xcap_server/xcap_server.c
kamailio-updated/modules_k/xcap_server/xcap_server.c
--- kamailio-orig/modules_k/xcap_server/xcap_server.c 2011-05-05 12:59:29.739128000
+0100
+++ kamailio-updated/modules_k/xcap_server/xcap_server.c 2011-05-11 17:37:13.067141000
+0100
@@ -410,6 +410,8 @@
static str xcaps_str_appxcxml = {"application/xcap-caps+xml", 25};
#endif
static str xcaps_str_appapxml = {"application/auth-policy+xml", 27};
+static str xcaps_str_appupxml = {"application/vnd.oma.user-profile+xml", 36};
+static str xcaps_str_apppcxml = {"application/vnd.oma.pres-content+xml", 36};
/**
@@ -787,6 +789,10 @@
ctype =&xcaps_str_appapxml;
else if(xuri.type==RLS_SERVICE)
ctype =&xcaps_str_apprsxml;
+ else if(xuri.type==USER_PROFILE)
+ ctype =&xcaps_str_appupxml;
+ else if(xuri.type==PRES_CONTENT)
+ ctype =&xcaps_str_apppcxml;
xcaps_send_reply(msg, 200,&xcaps_str_ok,&etag,
ctype,&body);
} else {
@@ -1004,38 +1010,62 @@
c = s.s[s.len];
s.s[s.len] = '\0';
- if(s.len>12
- && strstr(s.s, "/pres-rules/")!=NULL)
+ if(s.len>12&& strstr(s.s, "/pres-rules/")!=NULL)
{
LM_DBG("matched pres-rules\n");
ret = PRES_RULES;
goto done;
}
- if(s.len>14
- && strstr(s.s, "/rls-services/")!=NULL)
+ if(s.len>35&& strstr(s.s,
"/org.openmobilealliance.pres-rules/")!=NULL)
+ {
+ LM_DBG("matched oma pres-rules\n");
+ ret = PRES_RULES;
+ goto done;
+ }
+
+ if(s.len>14&& strstr(s.s, "/rls-services/")!=NULL)
{
LM_DBG("matched rls-services\n");
ret = RLS_SERVICE;
goto done;
}
- if(s.len>19
- && strstr(s.s, "pidf-manipulation")!=NULL)
+ if(s.len>19&& strstr(s.s, "pidf-manipulation")!=NULL)
{
LM_DBG("matched pidf-manipulation\n");
ret = PIDF_MANIPULATION;
goto done;
}
- if(s.len>16
- && strstr(s.s, "/resource-lists/")!=NULL)
+ if(s.len>16&& strstr(s.s, "/resource-lists/")!=NULL)
{
LM_DBG("matched resource-lists\n");
ret = RESOURCE_LIST;
goto done;
}
+ if(s.len>11&& strstr(s.s, "/xcap-caps/")!=NULL)
+ {
+ LM_DBG("matched xcap-caps\n");
+ ret = XCAP_CAPS;
+ goto done;
+ }
+
+ if(s.len> 37&& strstr(s.s,
"/org.openmobilealliance.user-profile/")!=NULL)
+ {
+ LM_DBG("matched oma user-profile\n");
+ ret = USER_PROFILE;
+ goto done;
+ }
+
+ if(s.len> 37&& strstr(s.s,
"/org.openmobilealliance.pres-content/")!=NULL)
+ {
+ LM_DBG("matched oma pres-content\n");
+ ret = PRES_CONTENT;
+ goto done;
+ }
+
done:
s.s[s.len] = c;
return ret;
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev