summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2016-08-15 16:17:51 (GMT)
committerPali Rohár <pali.rohar@gmail.com>2016-08-15 16:17:51 (GMT)
commit76eb903dd96532e96ce3b7113a7489f2f5a88cd0 (patch)
treeff80321bccdbe8576d2eb17ba999a108face8087
parenta95cdf6ca49e7fc7e5b7160054b38612dc8b1e78 (diff)
Update libiris from https://github.com/psi-im/iris.git commit 1db95f9af245e0dd8d33fd7e686e960b59d0cb9d
Remove also applied patch 01_qtxml_unicode.patch
-rw-r--r--protocols/jabber/libiris/patches/01_qtxml_unicode.patch19
-rw-r--r--protocols/jabber/libiris/src/xmpp/xmpp-im/types.cpp43
-rw-r--r--protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.cpp11
-rw-r--r--protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.h2
-rw-r--r--protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_message.h16
-rw-r--r--protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.cpp80
-rw-r--r--protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.h16
7 files changed, 167 insertions, 20 deletions
diff --git a/protocols/jabber/libiris/patches/01_qtxml_unicode.patch b/protocols/jabber/libiris/patches/01_qtxml_unicode.patch
deleted file mode 100644
index ad0ed69..0000000
--- a/protocols/jabber/libiris/patches/01_qtxml_unicode.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff --git a/src/xmpp/xmpp-core/xmlprotocol.cpp b/src/xmpp/xmpp-core/xmlprotocol.cpp
-index 51d2876..6cc0142 100644
---- a/src/xmpp/xmpp-core/xmlprotocol.cpp
-+++ b/src/xmpp/xmpp-core/xmlprotocol.cpp
-@@ -97,6 +97,14 @@ static QString xmlToString(const QDomElement &e, const QString &fakeNS, const QS
- QString out;
- {
- QTextStream ts(&out, QIODevice::WriteOnly);
-+ // NOTE: Workaround for bug in QtXML https://bugreports.qt.io/browse/QTBUG-25291 (Qt4 only):
-+ // Qt by default convert low surrogate to XML notation &#x....; and let high in binary!
-+ //
-+ // Qt is calling encode function per UTF-16 codepoint, which means that high and low
-+ // surrogate pairs are encoded separately. So all encoding except UTF-16 will leads
-+ // to damaged Unicode characters above 0xFFFF. Internal QString encoding is UTF-16
-+ // so this should be safe as QString still contains valid Unicode characters.
-+ ts.setCodec("UTF-16");
- fake.firstChild().save(ts, 0);
- }
- // 'clip' means to remove any unwanted (and unneeded) characters, such as a trailing newline
diff --git a/protocols/jabber/libiris/src/xmpp/xmpp-im/types.cpp b/protocols/jabber/libiris/src/xmpp/xmpp-im/types.cpp
index 4cbd0cc..e5c8b6a 100644
--- a/protocols/jabber/libiris/src/xmpp/xmpp-im/types.cpp
+++ b/protocols/jabber/libiris/src/xmpp/xmpp-im/types.cpp
@@ -957,6 +957,7 @@ public:
QMap<QString,HTMLElement> htmlElements;
QDomElement sxe;
QList<BoBData> bobDataList;
+ Jid forwardedFrom;
QList<int> mucStatuses;
QList<MUCInvite> mucInvites;
@@ -964,6 +965,10 @@ public:
QString mucPassword;
bool spooled, wasEncrypted;
+
+ //XEP-0280 Message Carbons
+ Message::CarbonDir carbonDir; // it's a forwarded message
+ bool isDisabledCarbons;
};
//! \brief Constructs Message with given Jid information.
@@ -984,6 +989,8 @@ Message::Message(const Jid &to)
d->errorCode = -1;*/
d->chatState = StateNone;
d->messageReceipt = ReceiptNone;
+ d->carbonDir = Message::NoCarbon;
+ d->isDisabledCarbons = false;
}
//! \brief Constructs a copy of Message object
@@ -1458,6 +1465,36 @@ const IBBData& Message::ibbData() const
return d->ibbData;
}
+void Message::setDisabledCarbons(bool disabled)
+{
+ d->isDisabledCarbons = disabled;
+}
+
+bool Message::isDisabledCarbons() const
+{
+ return d->isDisabledCarbons;
+}
+
+void Message::setCarbonDirection(Message::CarbonDir cd)
+{
+ d->carbonDir = cd;
+}
+
+Message::CarbonDir Message::carbonDirection() const
+{
+ return d->carbonDir;
+}
+
+void Message::setForwardedFrom(const Jid &jid)
+{
+ d->forwardedFrom = jid;
+}
+
+const Jid &Message::forwardedFrom() const
+{
+ return d->forwardedFrom;
+}
+
bool Message::spooled() const
{
return d->spooled;
@@ -1703,6 +1740,12 @@ Stanza Message::toStanza(Stream *stream) const
s.appendChild(bd.toXml(&s.doc()));
}
+ // Avoiding Carbons
+ if (isDisabledCarbons() || wasEncrypted()) {
+ QDomElement e = s.createElement("urn:xmpp:carbons:2","private");
+ s.appendChild(e);
+ }
+
return s;
}
diff --git a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.cpp b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.cpp
index 5477a11..34678ff 100644
--- a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.cpp
+++ b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.cpp
@@ -184,6 +184,15 @@ bool Features::haveVCard() const
return test(ns);
}
+#define FID_MESSAGECARBONS "urn:xmpp:carbons:2"
+bool Features::canMessageCarbons() const
+{
+ QStringList ns;
+ ns << FID_MESSAGECARBONS;
+
+ return test(ns);
+}
+
// custom Psi acitons
#define FID_ADD "psi:add"
@@ -205,6 +214,7 @@ public:
id2s[FID_VCard] = tr("VCard");
id2s[FID_AHCommand] = tr("Execute command");
id2s[FID_QueryVersion] = tr("Query version");
+ id2s[FID_MessageCarbons]= tr("Message Carbons");
// custom Psi actions
id2s[FID_Add] = tr("Add to roster");
@@ -222,6 +232,7 @@ public:
id2f[FID_VCard] = FID_VCARD;
id2f[FID_AHCommand] = FID_AHCOMMAND;
id2f[FID_QueryVersion] = FID_QUERYVERSION;
+ id2f[FID_MessageCarbons]= FID_MESSAGECARBONS;
// custom Psi actions
id2f[FID_Add] = FID_ADD;
diff --git a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.h b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.h
index 37d3575..8620391 100644
--- a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.h
+++ b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_features.h
@@ -55,6 +55,7 @@ namespace XMPP
bool isGateway() const;
bool hasVersion() const;
bool haveVCard() const;
+ bool canMessageCarbons() const;
enum FeatureID {
FID_Invalid = -1,
@@ -67,6 +68,7 @@ namespace XMPP
FID_VCard,
FID_AHCommand,
FID_QueryVersion,
+ FID_MessageCarbons,
// private Psi actions
FID_Add
diff --git a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_message.h b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_message.h
index fe7448c..45184cb 100644
--- a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_message.h
+++ b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_message.h
@@ -47,6 +47,12 @@ namespace XMPP {
class Message
{
public:
+ enum CarbonDir : quint8 {
+ NoCarbon,
+ Received,
+ Sent
+ };
+
Message(const Jid &to="");
Message(const Message &from);
Message & operator=(const Message &from);
@@ -149,6 +155,16 @@ namespace XMPP {
// XEP-0047 ibb
const IBBData& ibbData() const;
+ // XEP-0280 Message Carbons
+ void setDisabledCarbons(bool disabled);
+ bool isDisabledCarbons() const;
+ void setCarbonDirection(CarbonDir);
+ CarbonDir carbonDirection() const;
+
+ // XEP-0297
+ void setForwardedFrom(const Jid &jid);
+ const Jid &forwardedFrom() const;
+
// MUC
void addMUCStatus(int);
const QList<int>& getMUCStatuses() const;
diff --git a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.cpp b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.cpp
index f32ec41..0e74b71 100644
--- a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.cpp
+++ b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.cpp
@@ -884,7 +884,37 @@ bool JT_PushMessage::take(const QDomElement &e)
if(e.tagName() != "message")
return false;
- Stanza s = client()->stream().createStanza(addCorrectNS(e));
+ QDomElement e1 = e;
+ QDomElement forward;
+ Message::CarbonDir cd = Message::NoCarbon;
+
+ // Check for Carbon
+ QDomNodeList list = e1.childNodes();
+ for (int i = 0; i < list.size(); ++i) {
+ QDomElement el = list.at(i).toElement();
+
+ if (el.attribute("xmlns") == QLatin1String("urn:xmpp:carbons:2") && (el.tagName() == QLatin1String("received") || el.tagName() == QLatin1String("sent"))) {
+ QDomElement el1 = el.firstChildElement();
+ if (el1.tagName() == QLatin1String("forwarded") && el1.attribute(QLatin1String("xmlns")) == QLatin1String("urn:xmpp:forward:0")) {
+ QDomElement el2 = el1.firstChildElement(QLatin1String("message"));
+ if (!el2.isNull()) {
+ forward = el2;
+ cd = el.tagName() == QLatin1String("received")? Message::Received : Message::Sent;
+ break;
+ }
+ }
+ }
+ else if (el.tagName() == QLatin1String("forwarded") && el.attribute(QLatin1String("xmlns")) == QLatin1String("urn:xmpp:forward:0")) {
+ forward = el.firstChildElement(QLatin1String("message")); // currently only messages are supportted
+ // TODO <delay> element support
+ if (!forward.isNull()) {
+ break;
+ }
+ }
+ }
+
+ QString from = e1.attribute(QLatin1String("from"));
+ Stanza s = client()->stream().createStanza(addCorrectNS(forward.isNull()? e1 : forward));
if(s.isNull()) {
//printf("take: bad stanza??\n");
return false;
@@ -895,6 +925,10 @@ bool JT_PushMessage::take(const QDomElement &e)
//printf("bad message\n");
return false;
}
+ if (!forward.isNull()) {
+ m.setForwardedFrom(Jid(from));
+ m.setCarbonDirection(cd);
+ }
emit message(m);
return true;
@@ -2180,3 +2214,47 @@ bool JT_CaptchaSender::take(const QDomElement &x)
return true;
}
+
+//----------------------------------------------------------------------------
+// JT_MessageCarbons
+//----------------------------------------------------------------------------
+JT_MessageCarbons::JT_MessageCarbons(Task *parent)
+ : Task(parent)
+{
+
+}
+
+void JT_MessageCarbons::enable()
+{
+ _iq = createIQ(doc(), "set", "", id());
+
+ QDomElement enable = doc()->createElement("enable");
+ enable.setAttribute("xmlns", "urn:xmpp:carbons:2");
+
+ _iq.appendChild(enable);
+}
+
+void JT_MessageCarbons::disable()
+{
+ _iq = createIQ(doc(), "set", "", id());
+
+ QDomElement disable = doc()->createElement("disable");
+ disable.setAttribute("xmlns", "urn:xmpp:carbons:2");
+
+ _iq.appendChild(disable);
+}
+
+void JT_MessageCarbons::onGo()
+{
+ send(_iq);
+ setSuccess();
+}
+
+bool JT_MessageCarbons::take(const QDomElement &e)
+{
+ if (e.tagName() != "iq" || e.attribute("type") != "result")
+ return false;
+
+ bool res = iqVerify(e, Jid(), id());
+ return res;
+}
diff --git a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.h b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.h
index 54942a0..7f32991 100644
--- a/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.h
+++ b/protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_tasks.h
@@ -459,6 +459,22 @@ namespace XMPP
bool take(const QDomElement &);
};
+ class JT_MessageCarbons : public Task
+ {
+ Q_OBJECT
+
+ public:
+ JT_MessageCarbons(Task *parent);
+ void enable();
+ void disable();
+
+ void onGo();
+ bool take(const QDomElement &e);
+
+ private:
+ QDomElement _iq;
+ };
+
class JT_CaptchaChallenger : public Task
{
Q_OBJECT