Logo Search packages:      
Sourcecode: gabber version File versions  Download package

void Roster::update ( const Element t  ) 

Add a Roster Item to the Roster given a judo::Element. This is how you push Items as they're received.

Parameters:
t The judo::Element

Definition at line 63 of file jabberoo-roster.cc.

References judo::Element::begin(), judo::Element::cmpAttrib(), judo::Element::end(), evtRefresh, and judo::Element::getAttrib().

Referenced by operator<<().

{
     bool updateFlag = false;

     // Process each <item> tag and add/update
     // the roster
     Element::const_iterator it = t.begin();
     for (; it != t.end(); ++it )
     {
        if ((*it)->getType() != Node::ntElement)
             continue;
        // Cast item into a tag..
        Element& item = *static_cast<Element*>(*it);

        // Extract JID & resource
        string jid = filterJID(item.getAttrib("jid"));

        // Lookup this jid in the item map
        ItemMap::iterator rit = _items.find(jid);

        // If this jid is already in the Item map, update it...
        if (rit != _items.end())
        {
             // If the subscription type = "remove" then, we need
             // to delete this roster item...
             updateFlag = true;
             if (item.cmpAttrib("subscription", "remove"))
             {
                removeItemFromAllGroups(rit->second);
                _items.erase(rit);
             }
             // Otherwise, update the roster item
             else
                rit->second.update(*this, item);

        }
        // Otherwise, create a new item on the map
        else if (!item.cmpAttrib("subscription", "remove"))
        {
             _items.insert(make_pair(jid, Item(*this, item)));
             updateFlag = true;
        }
     }
     // Notify whoever we need to that the overall roster has been updated
     if (updateFlag)
        evtRefresh();

}


Generated by  Doxygen 1.6.0   Back to index