~ubuntu-branches/ubuntu/trusty/kopete/trusty

« back to all changes in this revision

Viewing changes to protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2013-11-23 17:46:40 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20131123174640-gz1zjv1xqh81bi2h
Tags: 4:4.11.80-0ubuntu1
* New upstream beta release
* Bump build dependency to libotr5-dev
* Update symbols
* Update install files
* Drop new_linphone.diff, not required anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
585
585
                if(!s.capsNode().isEmpty() && !s.capsVersion().isEmpty()) {
586
586
                        QDomElement c = doc()->createElement("c");
587
587
                        c.setAttribute("xmlns","http://jabber.org/protocol/caps");
 
588
                        if (!s.capsHashAlgorithm().isEmpty())
 
589
                                c.setAttribute("hash",s.capsHashAlgorithm());
588
590
                        c.setAttribute("node",s.capsNode());
589
591
                        c.setAttribute("ver",s.capsVersion());
590
592
                        if (!s.capsExt().isEmpty())
591
593
                                c.setAttribute("ext",s.capsExt());
592
 
                        if (!s.capsHash().isEmpty())
593
 
                                c.setAttribute("hash",s.capsHash());
594
594
                        tag.appendChild(c);
595
595
                }
596
596
 
608
608
                                        h.setAttribute("maxstanzas",s.mucHistoryMaxStanzas());
609
609
                                if (s.mucHistorySeconds() >= 0)
610
610
                                        h.setAttribute("seconds",s.mucHistorySeconds());
 
611
                                if (!s.mucHistorySince().isNull())
 
612
                                        h.setAttribute("since", s.mucHistorySince().toUTC().addSecs(1).toString(Qt::ISODate));
611
613
                                m.appendChild(h);
612
614
                        }
613
615
                        tag.appendChild(m);
696
698
                }
697
699
                else if(type == "subscribe" || type == "subscribed" || type == "unsubscribe" || type == "unsubscribed") {
698
700
                        QString nick;
699
 
                        bool found;
700
 
                        QDomElement tag = findSubTag(e, "nick", &found);
701
 
                        if (found && tag.attribute("xmlns") == "http://jabber.org/protocol/nick") {
 
701
                        QDomElement tag = e.firstChildElement("nick");
 
702
                        if (!tag.isNull() && tag.attribute("xmlns") == "http://jabber.org/protocol/nick") {
702
703
                                nick = tagContent(tag);
703
704
                        }
704
705
                        subscription(j, type, nick);
707
708
        }
708
709
 
709
710
        QDomElement tag;
710
 
        bool found;
711
711
 
712
 
        tag = findSubTag(e, "status", &found);
713
 
        if(found)
 
712
        tag = e.firstChildElement("status");
 
713
        if(!tag.isNull())
714
714
                p.setStatus(tagContent(tag));
715
 
        tag = findSubTag(e, "show", &found);
716
 
        if(found)
 
715
        tag = e.firstChildElement("show");
 
716
        if(!tag.isNull())
717
717
                p.setShow(tagContent(tag));
718
 
        tag = findSubTag(e, "priority", &found);
719
 
        if(found)
 
718
        tag = e.firstChildElement("priority");
 
719
        if(!tag.isNull())
720
720
                p.setPriority(tagContent(tag).toInt());
721
721
 
722
722
        QDateTime stamp;
738
738
                }
739
739
                else if(i.tagName() == "x" && i.attribute("xmlns") == "gabber:x:music:info") {
740
740
                        QDomElement t;
741
 
                        bool found;
742
741
                        QString title, state;
743
742
 
744
 
                        t = findSubTag(i, "title", &found);
745
 
                        if(found)
 
743
                        t = i.firstChildElement("title");
 
744
                        if(!t.isNull())
746
745
                                title = tagContent(t);
747
 
                        t = findSubTag(i, "state", &found);
748
 
                        if(found)
 
746
                        t = i.firstChildElement("state");
 
747
                        if(!t.isNull())
749
748
                                state = tagContent(t);
750
749
 
751
750
                        if(!title.isEmpty() && state == "playing")
761
760
                        p.setCapsNode(i.attribute("node"));
762
761
                        p.setCapsVersion(i.attribute("ver"));
763
762
                        p.setCapsExt(i.attribute("ext"));
764
 
                        p.setCapsHash(i.attribute("hash"));
765
763
                }
766
764
                else if(i.tagName() == "x" && i.attribute("xmlns") == "vcard-temp:x:update") {
767
765
                        QDomElement t;
768
 
                        bool found;
769
 
                        t = findSubTag(i, "photo", &found);
770
 
                        if (found)
 
766
                        t = i.firstChildElement("photo");
 
767
                        if (!t.isNull())
771
768
                                p.setPhotoHash(tagContent(t));
772
769
                        else
773
770
                                p.setPhotoHash("");
954
951
                                a.setJid(Jid(i.attribute("jid")));
955
952
 
956
953
                                QDomElement tag;
957
 
                                bool found;
958
954
 
959
 
                                tag = findSubTag(i, "name", &found);
960
 
                                if(found)
 
955
                                tag = i.firstChildElement("name");
 
956
                                if(!tag.isNull())
961
957
                                        a.setName(tagContent(tag));
962
958
 
963
959
                                // determine which namespaces does item support
964
960
                                QStringList ns;
965
961
 
966
 
                                tag = findSubTag(i, "register", &found);
967
 
                                if(found)
 
962
                                tag = i.firstChildElement("register");
 
963
                                if(!tag.isNull())
968
964
                                        ns << "jabber:iq:register";
969
 
                                tag = findSubTag(i, "search", &found);
970
 
                                if(found)
 
965
                                tag = i.firstChildElement("search");
 
966
                                if(!tag.isNull())
971
967
                                        ns << "jabber:iq:search";
972
 
                                tag = findSubTag(i, "groupchat", &found);
973
 
                                if(found)
 
968
                                tag = i.firstChildElement("groupchat");
 
969
                                if(!tag.isNull())
974
970
                                        ns << "jabber:iq:conference";
975
 
                                tag = findSubTag(i, "transport", &found);
976
 
                                if(found)
 
971
                                tag = i.firstChildElement("transport");
 
972
                                if(!tag.isNull())
977
973
                                        ns << "jabber:iq:gateway";
978
974
 
979
975
                                a.setFeatures(ns);
1245
1241
                                        SearchResult r(Jid(i.attribute("jid")));
1246
1242
 
1247
1243
                                        QDomElement tag;
1248
 
                                        bool found;
1249
1244
 
1250
 
                                        tag = findSubTag(i, "nick", &found);
1251
 
                                        if(found)
 
1245
                                        tag = i.firstChildElement("nick");
 
1246
                                        if(!tag.isNull())
1252
1247
                                                r.setNick(tagContent(tag));
1253
 
                                        tag = findSubTag(i, "first", &found);
1254
 
                                        if(found)
 
1248
                                        tag = i.firstChildElement("first");
 
1249
                                        if(!tag.isNull())
1255
1250
                                                r.setFirst(tagContent(tag));
1256
 
                                        tag = findSubTag(i, "last", &found);
1257
 
                                        if(found)
 
1251
                                        tag = i.firstChildElement("last");
 
1252
                                        if(!tag.isNull())
1258
1253
                                                r.setLast(tagContent(tag));
1259
 
                                        tag = findSubTag(i, "email", &found);
1260
 
                                        if(found)
 
1254
                                        tag = i.firstChildElement("email");
 
1255
                                        if(!tag.isNull())
1261
1256
                                                r.setEmail(tagContent(tag));
1262
1257
 
1263
1258
                                        d->resultList += r;
1306
1301
                return false;
1307
1302
 
1308
1303
        if(x.attribute("type") == "result") {
1309
 
                bool found;
1310
1304
                QDomElement q = queryTag(x);
1311
1305
                QDomElement tag;
1312
 
                tag = findSubTag(q, "name", &found);
1313
 
                if(found)
 
1306
                tag = q.firstChildElement("name");
 
1307
                if(!tag.isNull())
1314
1308
                        v_name = tagContent(tag);
1315
 
                tag = findSubTag(q, "version", &found);
1316
 
                if(found)
 
1309
                tag = q.firstChildElement("version");
 
1310
                if(!tag.isNull())
1317
1311
                        v_ver = tagContent(tag);
1318
 
                tag = findSubTag(q, "os", &found);
1319
 
                if(found)
 
1312
                tag = q.firstChildElement("os");
 
1313
                if(!tag.isNull())
1320
1314
                        v_os = tagContent(tag);
1321
1315
 
1322
1316
                setSuccess();
1445
1439
                // Find out the node
1446
1440
                bool invalid_node = false;
1447
1441
                QString node;
1448
 
                bool found;
1449
 
                QDomElement q = findSubTag(e, "query", &found);
1450
 
                if(found) // NOTE: Should always be true, since a NS was found above
 
1442
                QDomElement q = e.firstChildElement("query");
 
1443
                if(!q.isNull()) // NOTE: Should always be true, since a NS was found above
1451
1444
                        node = q.attribute("node");
1452
1445
 
1453
1446
                QDomElement iq = createIQ(doc(), "result", e.attribute("from"), e.attribute("id"));
1476
1469
 
1477
1470
                QDomElement feature;
1478
1471
                if (node.isEmpty() || node == client()->capsNode() + "#" + client()->capsVersion()) {
1479
 
                        // Standard features
1480
 
                        feature = doc()->createElement("feature");
1481
 
                        feature.setAttribute("var", "http://jabber.org/protocol/bytestreams");
1482
 
                        query.appendChild(feature);
1483
 
 
1484
 
                        feature = doc()->createElement("feature");
1485
 
                        feature.setAttribute("var", "http://jabber.org/protocol/ibb");
1486
 
                        query.appendChild(feature);
1487
 
 
1488
 
                        feature = doc()->createElement("feature");
1489
 
                        feature.setAttribute("var", "http://jabber.org/protocol/si");
1490
 
                        query.appendChild(feature);
1491
 
 
1492
 
                        feature = doc()->createElement("feature");
1493
 
                        feature.setAttribute("var", "http://jabber.org/protocol/si/profile/file-transfer");
1494
 
                        query.appendChild(feature);
 
1472
                        if (client()->fileTransferManager()) {
 
1473
                                // Standard features
 
1474
                                feature = doc()->createElement("feature");
 
1475
                                feature.setAttribute("var", "http://jabber.org/protocol/bytestreams");
 
1476
                                query.appendChild(feature);
 
1477
 
 
1478
                                feature = doc()->createElement("feature");
 
1479
                                feature.setAttribute("var", "http://jabber.org/protocol/ibb");
 
1480
                                query.appendChild(feature);
 
1481
 
 
1482
                                feature = doc()->createElement("feature");
 
1483
                                feature.setAttribute("var", "http://jabber.org/protocol/si");
 
1484
                                query.appendChild(feature);
 
1485
 
 
1486
                                feature = doc()->createElement("feature");
 
1487
                                feature.setAttribute("var", "http://jabber.org/protocol/si/profile/file-transfer");
 
1488
                                query.appendChild(feature);
 
1489
                        }
1495
1490
 
1496
1491
                        feature = doc()->createElement("feature");
1497
1492
                        feature.setAttribute("var", "http://jabber.org/protocol/disco#info");
1636
1631
        if(x.attribute("type") == "result") {
1637
1632
                if(type == 0) {
1638
1633
                        QDomElement query = queryTag(x);
1639
 
                        bool found;
1640
1634
                        QDomElement tag;
1641
 
                        tag = findSubTag(query, "desc", &found);
1642
 
                        if (found) {
 
1635
                        tag = query.firstChildElement("desc");
 
1636
                        if (!tag.isNull()) {
1643
1637
                                v_desc = tagContent(tag);
1644
1638
                        }
1645
 
                        tag = findSubTag(query, "prompt", &found);
1646
 
                        if (found) {
 
1639
                        tag = query.firstChildElement("prompt");
 
1640
                        if (!tag.isNull()) {
1647
1641
                                v_prompt = tagContent(tag);
1648
1642
                        }
1649
1643
                }
1650
1644
                else {
1651
1645
                        QDomElement query = queryTag(x);
1652
 
                        bool found;
1653
1646
                        QDomElement tag;
1654
 
                        tag = findSubTag(query, "jid", &found);
1655
 
                        if (found) {
 
1647
                        tag = query.firstChildElement("jid");
 
1648
                        if (!tag.isNull()) {
1656
1649
                                v_translatedJid = tagContent(tag);
1657
1650
                        }
1658
1651
                        // we used to read 'prompt' in the past
1659
1652
                        // and some gateways still send it
1660
 
                        tag = findSubTag(query, "prompt", &found);
1661
 
                        if (found) {
 
1653
                        tag = query.firstChildElement("prompt");
 
1654
                        if (!tag.isNull()) {
1662
1655
                                v_prompt = tagContent(tag);
1663
1656
                        }
1664
1657
                }
2092
2085
        if (e.tagName() != "iq" || e.attribute("type") != "get")
2093
2086
                return false;
2094
2087
 
2095
 
        bool found = false;
2096
 
        QDomElement ping = findSubTag(e, "ping", &found);
2097
 
        if (found && ping.attribute("xmlns") == "urn:xmpp:ping") {
 
2088
        QDomElement ping = e.firstChildElement("ping");
 
2089
        if (!e.isNull() && ping.attribute("xmlns") == "urn:xmpp:ping") {
2098
2090
                QDomElement iq = createIQ(doc(), "result", e.attribute("from"), e.attribute("id"));
2099
2091
                send(iq);
2100
2092
                return true;