~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to iris/src/xmpp/xmpp-im/xmpp_tasks.cpp

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 * You should have received a copy of the GNU Lesser General Public
16
16
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 *
19
19
 */
20
20
 
26
26
//#include "xmpp_stream.h"
27
27
//#include "xmpp_types.h"
28
28
#include "xmpp_vcard.h"
 
29
#include "xmpp_bitsofbinary.h"
29
30
 
30
31
#include <qregexp.h>
31
32
#include <QList>
 
33
#include <QTimer>
32
34
 
33
35
using namespace XMPP;
34
36
 
275
277
                                        d->xdata.fromXml(i);
276
278
                                        d->hasXData = true;
277
279
                                }
 
280
                                else if(i.tagName() == "data" && i.attribute("xmlns") == "urn:xmpp:bob") {
 
281
                                        client()->bobManager()->append(BoBData(i)); // xep-0231
 
282
                                }
278
283
                                else {
279
284
                                        FormField f;
280
285
                                        if(f.setType(i.tagName())) {
612
617
                        m.appendChild(textTag(doc(), "photo", s.photoHash()));
613
618
                        tag.appendChild(m);
614
619
                }
 
620
 
 
621
                // bits of binary
 
622
                foreach(const BoBData &bd, s.bobDataList()) {
 
623
                        tag.appendChild(bd.toXml(doc()));
 
624
                }
615
625
        }
616
626
}
617
627
 
773
783
                                        p.setMUCDestroy(MUCDestroy(muc_e));
774
784
                        }
775
785
                }
 
786
                else if (i.tagName() == "data" && i.attribute("xmlns") == "urn:xmpp:bob") {
 
787
                        BoBData bd(i);
 
788
                        client()->bobManager()->append(bd);
 
789
                        p.addBoBData(bd);
 
790
                }
776
791
        }
777
792
 
778
793
 
882
897
                return false;
883
898
        }
884
899
 
885
 
        message(m);
 
900
        emit message(m);
886
901
        return true;
887
902
}
888
903
 
1006
1021
        d->iq = createIQ(doc(), "get", type == 1 ? Jid().full() : d->jid.full(), id());
1007
1022
        QDomElement v = doc()->createElement("vCard");
1008
1023
        v.setAttribute("xmlns", "vcard-temp");
1009
 
        v.setAttribute("version", "2.0");
1010
 
        v.setAttribute("prodid", "-//HandGen//NONSGML vGen v1.0//EN");
1011
1024
        d->iq.appendChild(v);
1012
1025
}
1013
1026
 
1466
1479
                        query.appendChild(feature);
1467
1480
 
1468
1481
                        feature = doc()->createElement("feature");
 
1482
                        feature.setAttribute("var", "http://jabber.org/protocol/ibb");
 
1483
                        query.appendChild(feature);
 
1484
 
 
1485
                        feature = doc()->createElement("feature");
1469
1486
                        feature.setAttribute("var", "http://jabber.org/protocol/si");
1470
1487
                        query.appendChild(feature);
1471
1488
 
1477
1494
                        feature.setAttribute("var", "http://jabber.org/protocol/disco#info");
1478
1495
                        query.appendChild(feature);
1479
1496
 
 
1497
                        feature = doc()->createElement("feature");
 
1498
                        feature.setAttribute("var", "urn:xmpp:bob");
 
1499
                        query.appendChild(feature);
 
1500
 
1480
1501
                        // Client-specific features
1481
1502
                        QStringList clientFeatures = client()->features().list();
1482
1503
                        for (QStringList::ConstIterator i = clientFeatures.begin(); i != clientFeatures.end(); ++i) {
1930
1951
        return true;
1931
1952
}
1932
1953
 
 
1954
 
 
1955
// ---------------------------------------------------------
 
1956
// JT_BoBServer
 
1957
// ---------------------------------------------------------
 
1958
JT_BoBServer::JT_BoBServer(Task *parent)
 
1959
        : Task(parent)
 
1960
{
 
1961
 
 
1962
}
 
1963
 
 
1964
bool JT_BoBServer::take(const QDomElement &e)
 
1965
{
 
1966
        if (e.tagName() != "iq" || e.attribute("type") != "get")
 
1967
                return false;
 
1968
 
 
1969
        QDomElement data = e.firstChildElement("data");
 
1970
        if (data.attribute("xmlns") == "urn:xmpp:bob") {
 
1971
                QDomElement iq;
 
1972
                BoBData bd = client()->bobManager()->bobData(data.attribute("cid"));
 
1973
                if (bd.isNull()) {
 
1974
                        iq = createIQ(client()->doc(), "error",
 
1975
                                                  e.attribute("from"), e.attribute("id"));
 
1976
                        Stanza::Error error(Stanza::Error::Cancel,
 
1977
                                                                Stanza::Error::ItemNotFound);
 
1978
                        iq.appendChild(error.toXml(*doc(), client()->stream().baseNS()));
 
1979
                }
 
1980
                else {
 
1981
                        iq = createIQ(doc(), "result", e.attribute("from"), e.attribute("id"));
 
1982
                        iq.appendChild(bd.toXml(doc()));
 
1983
                }
 
1984
                send(iq);
 
1985
                return true;
 
1986
        }
 
1987
        return false;
 
1988
}
 
1989
 
 
1990
 
 
1991
//----------------------------------------------------------------------------
 
1992
// JT_BitsOfBinary
 
1993
//----------------------------------------------------------------------------
 
1994
class JT_BitsOfBinary::Private
 
1995
{
 
1996
public:
 
1997
        Private() { }
 
1998
 
 
1999
        QDomElement iq;
 
2000
        Jid jid;
 
2001
        QString cid;
 
2002
        BoBData data;
 
2003
};
 
2004
 
 
2005
JT_BitsOfBinary::JT_BitsOfBinary(Task *parent)
 
2006
: Task(parent)
 
2007
{
 
2008
        d = new Private;
 
2009
}
 
2010
 
 
2011
JT_BitsOfBinary::~JT_BitsOfBinary()
 
2012
{
 
2013
        delete d;
 
2014
}
 
2015
 
 
2016
void JT_BitsOfBinary::get(const Jid &j, const QString &cid)
 
2017
{
 
2018
        d->jid = j;
 
2019
        d->cid = cid;
 
2020
 
 
2021
        d->data = client()->bobManager()->bobData(cid);
 
2022
        if (d->data.isNull()) {
 
2023
                d->iq = createIQ(doc(), "get", d->jid.full(), id());
 
2024
                QDomElement data = doc()->createElement("data");
 
2025
                data.setAttribute("xmlns", "urn:xmpp:bob");
 
2026
                data.setAttribute("cid", cid);
 
2027
                d->iq.appendChild(data);
 
2028
        }
 
2029
}
 
2030
 
 
2031
void JT_BitsOfBinary::onGo()
 
2032
{
 
2033
        if (d->data.isNull()) {
 
2034
                send(d->iq);
 
2035
        }
 
2036
        else {
 
2037
                setSuccess();
 
2038
        }
 
2039
}
 
2040
 
 
2041
bool JT_BitsOfBinary::take(const QDomElement &x)
 
2042
{
 
2043
        if (!iqVerify(x, d->jid, id())) {
 
2044
                return false;
 
2045
        }
 
2046
 
 
2047
        if (x.attribute("type") == "result") {
 
2048
                QDomElement data = x.firstChildElement("data");
 
2049
 
 
2050
                if (!data.isNull() && data.attribute("cid") == d->cid) { // check xmlns?
 
2051
                        d->data.fromXml(data);
 
2052
                        client()->bobManager()->append(d->data);
 
2053
                }
 
2054
 
 
2055
                setSuccess();
 
2056
        }
 
2057
        else {
 
2058
                setError(x);
 
2059
        }
 
2060
 
 
2061
        return true;
 
2062
}
 
2063
 
 
2064
BoBData JT_BitsOfBinary::data()
 
2065
{
 
2066
        return d->data;
 
2067
}