| Index: jingle/notifier/listener/push_notifications_listen_task.cc
|
| diff --git a/jingle/notifier/listener/push_notifications_listen_task.cc b/jingle/notifier/listener/push_notifications_listen_task.cc
|
| index ad1da9f9debd3ec4e73566760891badffbfa9a13..ba66706f8de67c4a43cb60f65ca91db6e2a45eba 100644
|
| --- a/jingle/notifier/listener/push_notifications_listen_task.cc
|
| +++ b/jingle/notifier/listener/push_notifications_listen_task.cc
|
| @@ -40,6 +40,34 @@ int PushNotificationsListenTask::ProcessResponse() {
|
|
|
| DVLOG(1) << "Received stanza " << XmlElementToString(*stanza);
|
|
|
| + if (stanza->Name() == buzz::QN_MESSAGE) {
|
| + ProcessMessageStanza(stanza);
|
| + } else if (stanza->Name() == buzz::QN_IQ) {
|
| + ProcessPingStanza(stanza);
|
| + } else {
|
| + LOG(WARNING) << "Unknwon stanza " << XmlElementToString(*stanza);
|
| + }
|
| + return STATE_RESPONSE;
|
| +}
|
| +
|
| +bool PushNotificationsListenTask::HandleStanza(const buzz::XmlElement* stanza) {
|
| + if (IsValidNotification(stanza)) {
|
| + QueueStanza(stanza);
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +bool PushNotificationsListenTask::IsValidNotification(
|
| + const buzz::XmlElement* stanza) {
|
| + // We don't do much validation here, just check if the stanza is a message
|
| + // or iq (ping) stanza.
|
| + return (stanza->Name() == buzz::QN_MESSAGE) ||
|
| + (stanza->Name() == buzz::QN_IQ);
|
| +}
|
| +
|
| +void PushNotificationsListenTask::ProcessMessageStanza(
|
| + const buzz::XmlElement* stanza) {
|
| // The push notifications service does not need us to acknowledge receipt of
|
| // the notification to the buzz server.
|
|
|
| @@ -78,22 +106,18 @@ int PushNotificationsListenTask::ProcessResponse() {
|
| LOG(WARNING) << "No push element found in stanza "
|
| << XmlElementToString(*stanza);
|
| }
|
| - return STATE_RESPONSE;
|
| -}
|
| -
|
| -bool PushNotificationsListenTask::HandleStanza(const buzz::XmlElement* stanza) {
|
| - if (IsValidNotification(stanza)) {
|
| - QueueStanza(stanza);
|
| - return true;
|
| - }
|
| - return false;
|
| }
|
|
|
| -bool PushNotificationsListenTask::IsValidNotification(
|
| +void PushNotificationsListenTask::ProcessPingStanza(
|
| const buzz::XmlElement* stanza) {
|
| - // We don't do much validation here, just check if the stanza is a message
|
| - // stanza.
|
| - return (stanza->Name() == buzz::QN_MESSAGE);
|
| + // TODO(gene): Do we need to check if to=<jid> condition?
|
| + std::string type = stanza->Attr(buzz::QN_TYPE);
|
| + if (type == buzz::STR_RESULT) {
|
| + delegate_->OnPingResponseReceived();
|
| + } else {
|
| + LOG(WARNING) << "No type=\"result\" attribute found in stanza "
|
| + << XmlElementToString(*stanza);
|
| + }
|
| }
|
|
|
| } // namespace notifier
|
|
|