From 239b2b15c3cfd9e4d7cc085ed31645d6ae6942ee Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Mon, 26 Oct 2009 17:01:09 +0000 Subject: Fix for Issue 23: QXmppBind compilation error on macosx starting from r23 Issue 26: examples fail to link on macosx and linux Issue 24: all text files should have the svn property eol-style set Contributed by: Marco Molteni --- source/QXmppRoster.cpp | 406 ++++++++++++++++++++++++------------------------- 1 file changed, 203 insertions(+), 203 deletions(-) (limited to 'source/QXmppRoster.cpp') diff --git a/source/QXmppRoster.cpp b/source/QXmppRoster.cpp index eb5fc737..13f5c8cd 100644 --- a/source/QXmppRoster.cpp +++ b/source/QXmppRoster.cpp @@ -1,203 +1,203 @@ -/* - * Copyright (C) 2008-2009 Manjeet Dahiya - * - * Author: - * Manjeet Dahiya - * - * Source: - * http://code.google.com/p/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "QXmppRoster.h" -#include "QXmppUtils.h" -#include "QXmppRosterIq.h" -#include "QXmppPresence.h" -#include "QXmppStream.h" - -QXmppRoster::QXmppRoster(QXmppStream* stream) : m_stream(stream) -{ -} - -QXmppRoster::~QXmppRoster() -{ - -} - -void QXmppRoster::presenceReceived(const QXmppPresence& presence) -{ - QString jid = presence.getFrom(); - QString bareJid = jidToBareJid(jid); - QString resource = jidToResource(jid); - - m_presences[bareJid][resource] = presence; - - emit presenceChanged(bareJid, resource); -} - -void QXmppRoster::rosterIqReceived(const QXmppRosterIq& rosterIq) -{ - switch(rosterIq.getType()) - { - case QXmppIq::Set: - case QXmppIq::Result: - { - QList items = rosterIq.getItems(); - for(int i = 0; i < items.count(); ++i) - { - QString bareJid = items.at(i).getBareJid(); - m_entries[bareJid].setBareJid(bareJid); - m_entries[bareJid].setName(items.at(i).getName()); - m_entries[bareJid].setSubscriptionType( - static_cast( - items.at(i).getSubscriptionType())); - m_entries[bareJid].setSubscriptionStatus( - items.at(i).getSubscriptionStatus()); - m_entries[bareJid].setGroups(items.at(i).getGroups()); - emit rosterChanged(bareJid); - } - if(rosterIq.getType() == QXmppIq::Set) // send result iq - { - QXmppIq returnIq(QXmppIq::Result); - returnIq.setId(rosterIq.getId()); - m_stream->sendPacket(returnIq); - } - break; - } - default: - break; - } -} - -QString QXmppRoster::QXmppRosterEntry::getBareJid() const -{ - return m_bareJid; -} - -QString QXmppRoster::QXmppRosterEntry::getName() const -{ - return m_name; -} - -QXmppRoster::QXmppRosterEntry::SubscriptionType - QXmppRoster::QXmppRosterEntry::getSubscriptionType() const -{ - return m_type; -} - -QString QXmppRoster::QXmppRosterEntry::getSubscriptionStatus() const -{ - return m_subscriptionStatus; -} - -QSet QXmppRoster::QXmppRosterEntry::getGroups() const -{ - return m_groups; -} - -void QXmppRoster::QXmppRosterEntry::setBareJid(const QString& str) -{ - m_bareJid = str; -} - -void QXmppRoster::QXmppRosterEntry::setName(const QString& str) -{ - m_name = str; -} - -void QXmppRoster::QXmppRosterEntry::setSubscriptionType( - QXmppRosterEntry::SubscriptionType type) -{ - m_type = type; -} - -void QXmppRoster::QXmppRosterEntry::setSubscriptionStatus(const QString& str) -{ - m_subscriptionStatus = str; -} - -void QXmppRoster::QXmppRosterEntry::addGroupEntry(const QString& str) -{ - m_groups << str; -} - -void QXmppRoster::QXmppRosterEntry::setGroups(const QSet& groups) -{ - m_groups = groups; -} - -QStringList QXmppRoster::getRosterBareJids() const -{ - return m_entries.keys(); -} - -QXmppRoster::QXmppRosterEntry QXmppRoster::getRosterEntry( - const QString& bareJid) const -{ - // will return blank entry if bareJid does'nt exist - if(m_entries.contains(bareJid)) - return m_entries.value(bareJid); - else - { - qWarning("QXmppRoster::getRosterEntry(): bareJid doesn't exist in roster db"); - return QXmppRoster::QXmppRosterEntry(); - } -} - -QMap - QXmppRoster::getRosterEntries() const -{ - return m_entries; -} - -QStringList QXmppRoster::getResources(const QString& bareJid) const -{ - if(m_presences.contains(bareJid)) - { - return m_presences[bareJid].keys(); - } - else - return QStringList(); -} - -QMap QXmppRoster::getAllPresencesForBareJid( - const QString& bareJid) const -{ - if(m_presences.contains(bareJid)) - return m_presences[bareJid]; - else - { - qWarning("QXmppRoster::getAllPresences(): invalid bareJid"); - return QMap(); - } -} - -QXmppPresence QXmppRoster::getPresence(const QString& bareJid, - const QString& resource) const -{ - if(m_presences.contains(bareJid) && m_presences[bareJid].contains(resource)) - return m_presences[bareJid][resource]; - else - { - qWarning("QXmppRoster::getPresence(): invalid bareJid"); - return QXmppPresence(); - } -} - -QMap > QXmppRoster::getAllPresences() const -{ - return m_presences; -} +/* + * Copyright (C) 2008-2009 Manjeet Dahiya + * + * Author: + * Manjeet Dahiya + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + + +#include "QXmppRoster.h" +#include "QXmppUtils.h" +#include "QXmppRosterIq.h" +#include "QXmppPresence.h" +#include "QXmppStream.h" + +QXmppRoster::QXmppRoster(QXmppStream* stream) : m_stream(stream) +{ +} + +QXmppRoster::~QXmppRoster() +{ + +} + +void QXmppRoster::presenceReceived(const QXmppPresence& presence) +{ + QString jid = presence.getFrom(); + QString bareJid = jidToBareJid(jid); + QString resource = jidToResource(jid); + + m_presences[bareJid][resource] = presence; + + emit presenceChanged(bareJid, resource); +} + +void QXmppRoster::rosterIqReceived(const QXmppRosterIq& rosterIq) +{ + switch(rosterIq.getType()) + { + case QXmppIq::Set: + case QXmppIq::Result: + { + QList items = rosterIq.getItems(); + for(int i = 0; i < items.count(); ++i) + { + QString bareJid = items.at(i).getBareJid(); + m_entries[bareJid].setBareJid(bareJid); + m_entries[bareJid].setName(items.at(i).getName()); + m_entries[bareJid].setSubscriptionType( + static_cast( + items.at(i).getSubscriptionType())); + m_entries[bareJid].setSubscriptionStatus( + items.at(i).getSubscriptionStatus()); + m_entries[bareJid].setGroups(items.at(i).getGroups()); + emit rosterChanged(bareJid); + } + if(rosterIq.getType() == QXmppIq::Set) // send result iq + { + QXmppIq returnIq(QXmppIq::Result); + returnIq.setId(rosterIq.getId()); + m_stream->sendPacket(returnIq); + } + break; + } + default: + break; + } +} + +QString QXmppRoster::QXmppRosterEntry::getBareJid() const +{ + return m_bareJid; +} + +QString QXmppRoster::QXmppRosterEntry::getName() const +{ + return m_name; +} + +QXmppRoster::QXmppRosterEntry::SubscriptionType + QXmppRoster::QXmppRosterEntry::getSubscriptionType() const +{ + return m_type; +} + +QString QXmppRoster::QXmppRosterEntry::getSubscriptionStatus() const +{ + return m_subscriptionStatus; +} + +QSet QXmppRoster::QXmppRosterEntry::getGroups() const +{ + return m_groups; +} + +void QXmppRoster::QXmppRosterEntry::setBareJid(const QString& str) +{ + m_bareJid = str; +} + +void QXmppRoster::QXmppRosterEntry::setName(const QString& str) +{ + m_name = str; +} + +void QXmppRoster::QXmppRosterEntry::setSubscriptionType( + QXmppRosterEntry::SubscriptionType type) +{ + m_type = type; +} + +void QXmppRoster::QXmppRosterEntry::setSubscriptionStatus(const QString& str) +{ + m_subscriptionStatus = str; +} + +void QXmppRoster::QXmppRosterEntry::addGroupEntry(const QString& str) +{ + m_groups << str; +} + +void QXmppRoster::QXmppRosterEntry::setGroups(const QSet& groups) +{ + m_groups = groups; +} + +QStringList QXmppRoster::getRosterBareJids() const +{ + return m_entries.keys(); +} + +QXmppRoster::QXmppRosterEntry QXmppRoster::getRosterEntry( + const QString& bareJid) const +{ + // will return blank entry if bareJid does'nt exist + if(m_entries.contains(bareJid)) + return m_entries.value(bareJid); + else + { + qWarning("QXmppRoster::getRosterEntry(): bareJid doesn't exist in roster db"); + return QXmppRoster::QXmppRosterEntry(); + } +} + +QMap + QXmppRoster::getRosterEntries() const +{ + return m_entries; +} + +QStringList QXmppRoster::getResources(const QString& bareJid) const +{ + if(m_presences.contains(bareJid)) + { + return m_presences[bareJid].keys(); + } + else + return QStringList(); +} + +QMap QXmppRoster::getAllPresencesForBareJid( + const QString& bareJid) const +{ + if(m_presences.contains(bareJid)) + return m_presences[bareJid]; + else + { + qWarning("QXmppRoster::getAllPresences(): invalid bareJid"); + return QMap(); + } +} + +QXmppPresence QXmppRoster::getPresence(const QString& bareJid, + const QString& resource) const +{ + if(m_presences.contains(bareJid) && m_presences[bareJid].contains(resource)) + return m_presences[bareJid][resource]; + else + { + qWarning("QXmppRoster::getPresence(): invalid bareJid"); + return QXmppPresence(); + } +} + +QMap > QXmppRoster::getAllPresences() const +{ + return m_presences; +} -- cgit v1.2.3