[ejabberd] First shot at result set management (XEP-0059)

Badlop badlop at gmail.com
Tue Nov 25 19:12:46 MSK 2008


On Mon, Nov 24, 2008 at 1:53 PM, Eric Cestari <eric at ohmforce.com> wrote:
> https://support.process-one.net/browse/EJAB-807
> Now the 2€ question is "are there clients supporting XEP-0059 ?"

I couldn't find client implementations, at least according to those pages:

Psi: http://psi-im.org/wiki/Supported_Protocols

Tkabber: http://tkabber.jabber.ru/protocols

Gajim: http://trac.gajim.org/wiki/GajimXEPSupport

Coccinella: http://coccinella.svn.sourceforge.net/viewvc/coccinella/trunk/coccinella/READMEs/README-xmpp

Jabbim: the page doesn't include protocols in development version
http://dev.jabbim.cz/jabbim/wiki/en/JabbimXEPSupport

> Send in your remarks.
> I'd feel that the rsm module should be merged with the jlib module.

I didn't review your code at this state, as maybe you still want to
make more changes when you read all my emal :)

I only performed some cosmetic changes to your code:
* Moved namespace definition to rsm.hrl, and change related code.
* Improved code style: fixed indentation and removed unneeded
blankspaces using emacs.
* Replaced the deprecated integer/1 with is_integer/1, and list/1 with
is_list/1
  (see http://www.erlang.org/doc/man/erlang.html )

The updated patch that I recommend you use to continue your
development is attached in the ticket.

> TODO :
> I am not too happy with the way I compute the index, so maybe someone can
> come up with something better.

Do you mean the function mod_muc:get_vh_rooms/2 may not be efficient/robust?
You can add a 'TODO' comment in the code ;)

For this testing I created 10 persistent rooms with names room0,
room1, ..., room9 in conference.localhost. I describe some misfeatures
that you probably are aware, and some problems that maybe are bugs
that you can fix.

http://xmpp.org/extensions/xep-0059.html

2.1 Limiting the Number of Items

Works.


2.2 Paging Forwards Through a Result Set

Works.


2.3 Paging Backwards Through a Result Set

Works.


2.4 Page Not Found

Query of a page after nonexistent element:
    <iq type='get' to='conference.localhost' id='ex2'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <max>3</max>
	  <after>badroom</after>
	</set>
      </query>
    </iq>
ejabberd returns valid elements:
    <iq from='conference.localhost'
	    id='ex2'
	    type='result'
	    to='badlop3 at localhost/Tka'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<item name='room0 (0)'
	    jid='room0 at conference.localhost'/>
	<item name='room1 (0)'
	    jid='room1 at conference.localhost'/>
	<item name='room2 (0)'
	    jid='room2 at conference.localhost'/>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <first index='0'>room0</first>
	  <last>room2</last>
	  <count>10</count>
	</set>
      </query>
    </iq>
I am not sure if this is intended by the protocol or not. Let's
imagine that is how you wanted it to work.

Query of a page before nonexistent element:
    <iq type='get' to='conference.localhost' id='ex2'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <max>3</max>
	  <before>badroom</before>
	</set>
      </query>
    </iq>
In this case no response is received because it crashes:
    Error in process <0.424.0> on node 'ejabberd at localhost' with exit
value: {badarg,[{erlang,hd,[[]]},{mod_muc,get_vh_rooms,2},{mod_muc,iq_disco_items,4},{mod_muc,process_iq_disco_items,4}]}


2.5 Requesting the Last Page in a Result Set

Query of last page:
    <iq type='get' to='conference.localhost' id='ex2'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <max>3</max>
	  <before />
	</set>
      </query>
    </iq>
No response is received because it crashes:
    Error in process <0.440.0> on node 'ejabberd at localhost' with exit
value: {badarg,[{erlang,hd,[[]]},{mod_muc,get_vh_rooms,2},{mod_muc,iq_disco_items,4},{mod_muc,process_iq_disco_items,4}]}


2.6 Retrieving a Page Out of Order

Doesn't work properly. Notice that room0 has index = 0, room1 has index = 1, ...

The query:
    <iq type='get' to='conference.localhost' id='ex2'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <max>2</max>
	  <index>5</index>
	</set>
      </query>
    </iq>
should get room5 and room6, as explained in the protocol:
    "including in its request the index of the first item to be returned".

However, the response includes room4 and room5:
    <iq from='conference.localhost'
	    id='ex2'
	    type='result'
	    to='badlop3 at localhost/Tka'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<item name='room4 (0)'
	    jid='room4 at conference.localhost'/>
	<item name='room5 (0)'
	    jid='room5 at conference.localhost'/>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <first index='4'>room4</first>
	  <last>room5</last>
	  <count>10</count>
	</set>
      </query>
    </iq>

This problem also means that a query starting in index 0:
    <iq type='get' to='conference.localhost' id='ex2'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <max>2</max>
	  <index>0</index>
	</set>
      </query>
    </iq>
leads to a crash:
    Error in process <0.470.0> on node 'ejabberd at localhost' with exit
value: {function_clause,[{lists,nthtail,[-1,[{muc_online_room,{"room0","conference.localhost"},<0.454.0>},{muc_online_room,{"room1","conference.localhost"},<0.289.0>},{muc_online_room,{"room2","conference.localhost"},<0.291.0>},{muc_online_room,{"room3","c...


2.7 Getting the Item Count

A query to get the item count:
    <iq type='get' to='conference.localhost' id='ex2'>
      <query xmlns='http://jabber.org/protocol/disco#items'>
	<set xmlns='http://jabber.org/protocol/rsm'>
	  <max>0</max>
	</set>
      </query>
    </iq>
crashes:
    Error in process <0.473.0> on node 'ejabberd at localhost' with exit
value: {badarg,[{erlang,hd,[[]]},{mod_muc,get_vh_rooms,2},{mod_muc,iq_disco_items,4},{mod_muc,process_iq_disco_items,4}]}


3. Examples

Works.


4. Determining Support

Works.


---


More information about the ejabberd mailing list