예제 #1
0
void tst_QXmppEntityTimeIq::testEntityTimeResult()
{
    const QByteArray xml(
    "<iq id=\"time_1\" to=\"[email protected]/orchard\" from=\"[email protected]/balcony\" type=\"result\">"
      "<time xmlns=\"urn:xmpp:time\">"
        "<tzo>-06:00</tzo>"
        "<utc>2006-12-19T17:58:35Z</utc>"
      "</time>"
    "</iq>");

    QXmppEntityTimeIq entityTime;
    parsePacket(entityTime, xml);
    QCOMPARE(entityTime.id(), QLatin1String("time_1"));
    QCOMPARE(entityTime.from(), QLatin1String("[email protected]/balcony"));
    QCOMPARE(entityTime.to(), QLatin1String("[email protected]/orchard"));
    QCOMPARE(entityTime.type(), QXmppIq::Result);
    QCOMPARE(entityTime.tzo(), -21600);
    QCOMPARE(entityTime.utc(), QDateTime(QDate(2006, 12, 19), QTime(17, 58, 35), Qt::UTC));
    serializePacket(entityTime, xml);
}
예제 #2
0
	void EntryBase::handleTimeReceived (const QXmppEntityTimeIq& iq)
	{
		const auto& from = iq.from ();
		if (!from.startsWith (GetJID ()))
			return;

		const auto& thatTime = iq.utc ();
		if (!thatTime.isValid ())
			return;

		QString bare;
		QString variant;
		ClientConnection::Split (from, &bare, &variant);

		if (variant.isEmpty () || GetEntryType () == EntryType::PrivateChat)
			variant = "";

		const auto secsDiff = QDateTime::currentDateTimeUtc ().secsTo (thatTime);
		Variant2SecsDiff_ [variant] = { static_cast<int> (secsDiff), iq.tzo () };

		emit entryGenerallyChanged ();

		emit entityTimeUpdated ();
	}