diff options
| author | Manjeet Dahiya <manjeetdahiya@gmail.com> | 2010-09-12 14:28:58 +0000 |
|---|---|---|
| committer | Manjeet Dahiya <manjeetdahiya@gmail.com> | 2010-09-12 14:28:58 +0000 |
| commit | 8780445c9fac2840a34042ae3faa217d3fde7f8a (patch) | |
| tree | ae3c7e3d12fec6c59ed78a23d7b3f80b94de879f /src/QXmppEntityTimeManager.cpp | |
| parent | db7fd4aa7f991ba4b74330e905b010cb7ed19e24 (diff) | |
| download | qxmpp-8780445c9fac2840a34042ae3faa217d3fde7f8a.tar.gz | |
populate the result Iq
Diffstat (limited to 'src/QXmppEntityTimeManager.cpp')
| -rw-r--r-- | src/QXmppEntityTimeManager.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/QXmppEntityTimeManager.cpp b/src/QXmppEntityTimeManager.cpp index 1d9e0013..c6d8a67f 100644 --- a/src/QXmppEntityTimeManager.cpp +++ b/src/QXmppEntityTimeManager.cpp @@ -25,10 +25,12 @@ #include "QXmppEntityTimeManager.h"
#include <QDomElement>
+#include <QDateTime>
#include "QXmppConstants.h"
#include "QXmppOutgoingClient.h"
#include "QXmppEntityTimeIq.h"
+#include "QXmppUtils.h"
void QXmppEntityTimeManager::requestTime(const QString& jid)
{
@@ -60,8 +62,24 @@ bool QXmppEntityTimeManager::handleStanza(QXmppStream *stream, const QDomElement responseIq.setTo(entityTime.from());
// TODO: set valid values
- responseIq.setTzo("");
- responseIq.setUtc("");
+ QDateTime currentTime = QDateTime::currentDateTime();
+ QDateTime utc = currentTime.toUTC();
+ responseIq.setUtc(datetimeToString(utc));
+
+ currentTime.setTimeSpec(Qt::UTC);
+ int tzo_sec = currentTime.secsTo(utc);
+ QTime tzo_time;
+ if(tzo_sec < 0)
+ tzo_time.addSecs(-tzo_sec);
+ else
+ tzo_time.addSecs(tzo_sec);
+ QString tzo;
+ if(tzo_sec < 0)
+ tzo = "-" + tzo_time.toString("hh:mm");
+ else
+ tzo = "+" + tzo_time.toString("hh:mm");
+
+ responseIq.setTzo(tzo);
stream->sendPacket(responseIq);
}
|
