<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Peter,<br>
<br>
thanks for the patches. I will add them to the module.<br>
<br>
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.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
On 5/12/11 12:32 PM, Peter Dunkley wrote:
<blockquote cite="mid:1305196362.3248.21.camel@pd-laptop-linux"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="GENERATOR" content="GtkHTML/3.32.2">
Hello,<br>
<br>
Please find attached a patch to add oma user-profile and
pres-content (avatar) support to the xcap_server module.<br>
<br>
To make use of these changes I also had to update my kamailio.cfg
(based on the example from <a moz-do-not-send="true"
href="http://kb.asipto.com/kamailio:presence:k31-made-simple%29.%A0">http://kb.asipto.com/kamailio:presence:k31-made-simple). </a>
In particular I had to update the event_route[xhttp:request]
clause so that:
<ul>
<li>the xcap-caps response includes the auids and namespace
entries for user-profile and pres-content </li>
<li>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.
</li>
</ul>
<br>
For reference, my updated event_route[xhttp:request] clause is
included below.<br>
<br>
Regards,<br>
<br>
Peter<br>
<br>
<pre>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)=~"^<a class="moz-txt-link-freetext" href="sip:.+@.+">sip:.+@.+</a>")
$var(uri) = $xcapuri(u=>xuid);
else if($xcapuri(u=>xuid)=~<a class="moz-txt-link-rfc2396E" href="mailto:.+@.+">".+@.+"</a>)
$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
}
</pre>
<br>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<pre>--
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</pre>
</td>
</tr>
</tbody>
</table>
<br>
<fieldset class="mimeAttachmentHeader"><legend
class="mimeAttachmentHeaderName">user_profile_avatar.patch</legend></fieldset>
<br>
<pre wrap="">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;
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
</body>
</html>