Пример #1
0
	void GlooxAccount::SetBookmarkedMUCs (const QVariantList& datas)
	{
		QSet<QString> jids;

		QList<QXmppBookmarkConference> mucs;
		Q_FOREACH (const QVariant& var, datas)
		{
			const QVariantMap& map = var.toMap ();
			QXmppBookmarkConference conf;
			conf.setAutoJoin (map.value ("Autojoin").toBool ());

			const auto& room = map.value ("Room").toString ();
			const auto& server = map.value ("Server").toString ();
			if (room.isEmpty () || server.isEmpty ())
				continue;

			const auto& jid = room + '@' + server;
			if (jids.contains (jid))
				continue;

			jids << jid;

			conf.setJid (jid);
			conf.setNickName (map.value ("Nick").toString ());
			conf.setName (map.value ("StoredName").toString ());
			mucs << conf;
		}

		QXmppBookmarkSet set;
		set.setConferences (mucs);
		set.setUrls (GetBookmarks ().urls ());
		SetBookmarks (set);
	}
Пример #2
0
void QXmppBookmarkSet::parse(const QDomElement &element)
{
    QDomElement childElement = element.firstChildElement();
    while (!childElement.isNull())
    {
        if (childElement.tagName() == "conference")
        {
            QXmppBookmarkConference conference;
            conference.setAutoJoin(childElement.attribute("autojoin") == "true" || childElement.attribute("autojoin") == "1");
            conference.setJid(childElement.attribute("jid"));
            conference.setName(childElement.attribute("name"));
            conference.setNickName(childElement.firstChildElement("nick").text());
            m_conferences << conference;
        }
        else if (childElement.tagName() == "url")
        {
            QXmppBookmarkUrl url;
            url.setName(childElement.attribute("name"));
            url.setUrl(childElement.attribute("url"));
            m_urls << url;
        }
        childElement = childElement.nextSiblingElement();
    }
}