Index: jingle/notifier/listener/send_ping_task.cc |
diff --git a/jingle/notifier/listener/send_ping_task.cc b/jingle/notifier/listener/send_ping_task.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..44ca252648a07006bead716a97ca950e1e8952f9 |
--- /dev/null |
+++ b/jingle/notifier/listener/send_ping_task.cc |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "jingle/notifier/listener/send_ping_task.h" |
+ |
+#include <string> |
+ |
+#include "base/base64.h" |
akalin
2012/10/24 21:45:35
no need for base64
gene
2012/10/24 22:30:09
Done.
|
+#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "jingle/notifier/listener/notification_constants.h" |
akalin
2012/10/24 21:45:35
no need for notification_constants?
gene
2012/10/24 22:30:09
Done.
|
+#include "jingle/notifier/listener/xml_element_util.h" |
+#include "talk/xmllite/qname.h" |
+#include "talk/xmllite/xmlelement.h" |
+#include "talk/xmpp/constants.h" |
+#include "talk/xmpp/jid.h" |
+#include "talk/xmpp/xmppclient.h" |
+ |
+namespace notifier { |
+ |
+SendPingTask::SendPingTask(buzz::XmppTaskParentInterface* parent) |
+ : XmppTask(parent) { |
+} |
+ |
+SendPingTask::~SendPingTask() { |
+} |
+ |
+int SendPingTask::ProcessStart() { |
+ scoped_ptr<buzz::XmlElement> stanza; |
akalin
2012/10/24 21:45:35
just initialize stanza directly from MakePingStanz
gene
2012/10/24 22:30:09
Done.
|
+ stanza.reset(MakePingStanza(task_id())); |
+ |
+ DVLOG(1) << "Sending ping stanza " << XmlElementToString(*stanza); |
+ if (SendStanza(stanza.get()) != buzz::XMPP_RETURN_OK) { |
+ LOG(WARNING) << "Could not send stanza " << XmlElementToString(*stanza); |
+ } |
+ return STATE_DONE; |
+} |
+ |
+buzz::XmlElement* SendPingTask::MakePingStanza(const std::string& task_id) { |
+ buzz::XmlElement* stanza = MakeIq(buzz::STR_GET, |
+ buzz::Jid(buzz::STR_EMPTY), |
+ task_id); |
+ stanza->AddElement(new buzz::XmlElement(buzz::QN_PING)); |
+ return stanza; |
+} |
+ |
+} // namespace notifier |