<div>Hello Klaus,</div>
<div>thanks a lot for your answer.</div>
<div>Please, see my comment (<span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">BOB:&gt;</span>) below .<br></div>
<div class="gmail_quote">
<div lang="IT" vlink="purple" link="blue">
<div>
<p class="MsoNormal"> </p>
<div>
<div class="h5">
<div>
<p class="MsoNormal">Message: 8<br>Date: Mon, 23 May 2011 09:47:23 +0200<br>From: Klaus Darilion &lt;<a href="mailto:klaus.mailinglists@pernau.at" target="_blank">klaus.mailinglists@pernau.at</a>&gt;<br>Subject: Re: [sr-dev] kamailio 3.1.3 Presence + XCAP problem, is it a<br>
       bug?<br>To: <a href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a><br>Message-ID: &lt;<a href="mailto:4DDA110B.2020907@pernau.at" target="_blank">4DDA110B.2020907@pernau.at</a>&gt;<br>
Content-Type: text/plain; charset=windows-1252</p></div>
<p> </p>
<p>Am 20.05.2011 17:00, schrieb laura testi:<br>&gt; Hello,<br>&gt;<br>&gt;<br>&gt;<br>&gt; I?m wring you again about the Presence = xcap Problem on Kamailio<br>&gt; related with the deleting of a contact.<br>&gt;<br>&gt; Here a detailed description we have observed:<br>
&gt; User Case:<br>&gt; ------------------<br>&gt;   - user A is a contact of B and viceversa.<br>&gt;   - then user A removes B from PC client<br>&gt;<br>&gt;<br>&gt; 1) A sends SUBSCRIBE B to Kamail Presence Server (PS) with even type:<br>
&gt; presence and Expire:0 without body<br>&gt;     a) PS removes A as wacther of B from the active_watchers table<br>&gt;     b) PS sends NOTIFY to B (from B to B) with event type:<br>&gt; presence.winfo and Subscription State:active,expire=570<br>
&gt;     c) PS sends NOTIFY to A (from B to A) with event type: Presence and<br>&gt; Subscription State: terminated,reason=timeout<br>&gt;<br>&gt; 2) A sends XCAP PUT to PS with updated pres-rules without B in<br>&gt; presence_allow rule<br>
&gt;     a) PS update xcap table the pres-rules record of A (without B)<br>&gt;<br>&gt;<br>&gt; 3) A sends XCAP PUT to PS with updated resource-lists without B<br>&gt;     a) PS update xcap table the resource-lists record of A(without B)<br>
&gt;<br>&gt; 4)  the script kamailio.cfg calls pres_update_watchers<br>&gt;     a) PS updates watcher table by setting the status = 2(pending) for<br>&gt; the record of B is watcher of A (presentity), while the status remains<br>
&gt; active (1) for the record of A is watcher of B<br>&gt;     b) PS sends NOTIFY to B(from A to B) with event type: presence and<br>&gt; subscription state: pending<br>&gt;<br>&gt; 5) the script kamailio.cfg calls pres_refresh_watchers<br>
&gt;      a) PS sends NOTIFY to B(from A to B) with event type: presence and<br>&gt; content type:application:pdif+xml (open, online, pdif entity:A,...)<br>&gt;      b) the PC client of B shows a popup by saying 5has authorized the B<br>
&gt; adds A as contact request<br>&gt;<br>&gt;<br>&gt; Test environments:<br>&gt; --------------------------<br>&gt; - server: kamailio 3.1.3 with presence, xcap and mysql in Redhat5.6_x64<br>&gt; - transport: tcp<br>&gt; - db: mysql<br>
&gt; - client: jitsi (ex SIP communicator)<br>&gt; - kamailio.cfg: please see the attached file kamailio.zip<br>&gt;<br>&gt; Questions:<br>&gt; -----------------<br>&gt; 1) is it correct the first SUBSCRIBE from the PC client of A?</p>

<p>Strictly said: subscribing someones presence and allowing someone to<br>subscribe its own presence are 2 different things. But, usually they<br>come together.</p>
<p>Thus, by removing someone from the buddy list Jitsi does:<br>- unsubscribe the presentity<br>- remove the presentity from the allowed watchers</p>
<p>IMO this is fine.</p>
<p>&gt; 2) are the over all call flows correct (see the attached wireshark trace)<br>&gt; 3) are the steps 2 and 3 correct?</p>
<p>IMO yes.</p>
<p>&gt; 4) the steps 4 and 5 are very strange, is it the bug of xcap module<br>&gt; or/and presence module?</p>
<p>I think 4 is OK. But step 5 seems buggy as.</p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"></span></p></div></div>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">BOB:&gt;</span></p>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">I think the step 4a) may be a bug:</span></p>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">the subscription STATUS of  B (watcher of A) to A should remain ACTIVE (1) instead of PENDING(2). this state is very strange and that causes the strange step 4b) after A having removed B. Because B does still subscribe A’s presentity! And probably do this causes the incorrect behavior of step 5)? </span></p>

<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">Should the presence server also remove the record of the subscription from A(watcher) to B(presentity)  from both active_watchers and watchers tables instead of only from active_wtachers table? Because if A remove B (unsubscribe B), that mean A don’t want to see the presentity of B. Or maybe it’s correct put A’s subscription status of B in TERMINATED(3) instead of removing the record (actually remains in ACTIVE(1)).</span></p>

<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">When the presence server is doing pres_refresh_watchers in step 5), I think it checks the xcap table and see A is watcher of B  (A is in B’s presence_allow rule) and is in B’s resource-list, and B is also active_watcher of A in the active_watchers table, A’s subscription status of B is ACTIVE(1) in watchers table, B’s subscription status of A is in Pending(2), it send a NOTIFY to B. That’s really strange! Probabely the step 4) also causes this strange behavior.</span></p>

<div class="im">
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d"></span></p>
<p> </p>
<p>What do you think would be the correct behavior?</p>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">BOB:&gt;</span></p></div>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">I think in step 1, in addition to remove the record of A’s subscription of B from active_watchers table, the PS should also remove the record of A’s subscription of B from the watchers table or put the STATUS=TERMINATED. That’s because A is not interested the B’s presentity anymore.</span></p>

<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">In step 4, the PS should not change watchers table, because B’s subscription of A is still active (should not becomes pending), and should not send the Pending notify too.</span></p>

<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">Same for step 5.</span></p>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d"> thanks,</span></p>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d">laura</span></p>
<p><span lang="EN-US" style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span><span lang="EN-US">regards<br>klaus</span></p></div></div></div><br>