diff -Naur psi-0.10-test3-orig/iris/include/im.h psi-0.10-test3/iris/include/im.h --- psi-0.10-test3-orig/iris/include/im.h 2005-12-04 13:24:20.000000000 +0000 +++ psi-0.10-test3/iris/include/im.h 2005-12-04 13:28:29.000000000 +0000 @@ -53,7 +53,10 @@ Private *d; }; + class RosterItem; + typedef QValueList UrlList; + typedef QValueList RosterItemList; typedef QMap StringMap; typedef enum { OfflineEvent, DeliveredEvent, DisplayedEvent, ComposingEvent, CancelEvent } MsgEvent; @@ -112,6 +115,12 @@ void urlsClear(); void setUrlList(const UrlList &list); + // JEP-0093 + RosterItemList rosterItemList() const; + void rosterItemAdd(const RosterItem &ri); + void rosterItemsClear(); + void setRosterItemList(const RosterItemList &list); + // JEP-0022 QString eventId() const; void setEventId(const QString& id); diff -Naur psi-0.10-test3-orig/iris/xmpp-im/types.cpp psi-0.10-test3/iris/xmpp-im/types.cpp --- psi-0.10-test3-orig/iris/xmpp-im/types.cpp 2005-12-04 13:24:21.000000000 +0000 +++ psi-0.10-test3/iris/xmpp-im/types.cpp 2005-12-04 13:33:14.000000000 +0000 @@ -129,6 +129,7 @@ UrlList urlList; QValueList eventList; QString eventId; + RosterItemList rosterItemList; QString xencrypted, invitationReason, invitationPword; Jid invitationTo, invitationFrom; @@ -425,6 +426,34 @@ } } +//! \brief Return list of roster items attached to message. +RosterItemList Message::rosterItemList() const +{ + return d->rosterItemList; +} + +//! \brief Add RosterItem to the Roster Item list. +//! +//! \param ri - roster item to append +void Message::rosterItemAdd(const RosterItem &ri) +{ + d->rosterItemList += ri; +} + +//! \brief clear out the roster item list. +void Message::rosterItemsClear() +{ + d->rosterItemList.clear(); +} + +//! \brief Set roster items to send +//! +//! \param list - list of roster items to send +void Message::setRosterItemList(const RosterItemList &list) +{ + d->rosterItemList = list; +} + QString Message::xencrypted() const { return d->xencrypted; @@ -579,6 +608,33 @@ s.appendChild(x); } + // roster items + if (!d->rosterItemList.isEmpty()) { + QDomElement x = s.createElement("jabber:x:roster", "x"); + for(QValueList::ConstIterator rit = d->rosterItemList.begin(); rit != d->rosterItemList.end(); ++rit) { + QDomElement item = s.createElement("jabber:x:roster", "item"); + + /* Set jid */ + if (!(*rit).jid().isEmpty()) { + item.setAttribute("jid",(*rit).jid().full()); + } + + /* Set name */ + if (!(*rit).name().isEmpty()) { + item.setAttribute("name",(*rit).name()); + } + + /* Add groups */ + if (!(*rit).groups().isEmpty()) { + for (QStringList::ConstIterator git = (*rit).groups().begin() ; git != (*rit).groups().end(); ++git) { + item.appendChild(s.createTextElement("jabber:x:roster", "group", *git)); + } + } + x.appendChild(item); + } + s.appendChild(x); + } + // xencrypted if(!d->xencrypted.isEmpty()) s.appendChild(s.createTextElement("jabber:x:encrypted", "x", d->xencrypted)); @@ -683,6 +739,26 @@ d->eventList += CancelEvent; } + // roster items + d->rosterItemList.clear(); + nl = root.elementsByTagNameNS("jabber:x:roster", "x"); + if (nl.count()) { + nl = nl.item(0).toElement().elementsByTagNameNS("jabber:x:roster", "item"); + for(n = 0; n < nl.count(); ++n) { + QDomElement item = nl.item(n).toElement(); + RosterItem it; + it.setJid(Jid(item.attribute("jid",""))); + it.setName(item.attribute("name","")); + + QDomNodeList groups = nl.item(n).toElement().elementsByTagNameNS("jabber:x:roster", "group"); + for (unsigned int gn = 0; gn < groups.count(); ++gn) { + it.addGroup(groups.item(gn).toElement().text()); + } + + d->rosterItemList += it; + } + } + // xencrypted t = root.elementsByTagNameNS("jabber:x:encrypted", "x").item(0).toElement(); if(!t.isNull())