Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Side by Side Diff: jingle/notifier/listener/listen_task.cc

Issue 6392014: [Sync] Relax checks for received XMPP messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "jingle/notifier/listener/listen_task.h" 5 #include "jingle/notifier/listener/listen_task.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "jingle/notifier/listener/notification_constants.h" 8 #include "jingle/notifier/listener/notification_constants.h"
9 #include "jingle/notifier/listener/xml_element_util.h" 9 #include "jingle/notifier/listener/xml_element_util.h"
10 #include "talk/base/task.h" 10 #include "talk/base/task.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // <Type int="#"/> 58 // <Type int="#"/>
59 // <Read bool="{true/false}"/> 59 // <Read bool="{true/false}"/>
60 // </State> 60 // </State>
61 // <ClientActive bool="{true/false}"/> 61 // <ClientActive bool="{true/false}"/>
62 // </Result> 62 // </Result>
63 // </not:getAll> 63 // </not:getAll>
64 // </iq> " 64 // </iq> "
65 // Note that there can be multiple "Result" elements, so we need to loop 65 // Note that there can be multiple "Result" elements, so we need to loop
66 // through all of them. 66 // through all of them.
67 bool update_signaled = false; 67 bool update_signaled = false;
68 const buzz::QName kQnNotifierGetAll(kNotifierNamespace, "getAll");
68 const buzz::XmlElement* get_all_element = 69 const buzz::XmlElement* get_all_element =
69 stanza->FirstNamed(buzz::QName("google:notifier", "getAll")); 70 stanza->FirstNamed(kQnNotifierGetAll);
70 if (get_all_element) { 71 if (get_all_element) {
71 const buzz::XmlElement* result_element = 72 const buzz::XmlElement* result_element =
72 get_all_element->FirstNamed( 73 get_all_element->FirstNamed(
73 buzz::QName(buzz::STR_EMPTY, "Result")); 74 buzz::QName(buzz::STR_EMPTY, "Result"));
74 while (result_element) { 75 while (result_element) {
75 IncomingNotificationData notification_data; 76 IncomingNotificationData notification_data;
76 const buzz::XmlElement* id_element = 77 const buzz::XmlElement* id_element =
77 result_element->FirstNamed(buzz::QName(buzz::STR_EMPTY, "Id")); 78 result_element->FirstNamed(buzz::QName(buzz::STR_EMPTY, "Id"));
78 if (id_element) { 79 if (id_element) {
79 const buzz::XmlElement* service_url_element = 80 const buzz::XmlElement* service_url_element =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // TODO(akalin): Do more verification on stanza depending on 119 // TODO(akalin): Do more verification on stanza depending on
119 // the sync notification method 120 // the sync notification method
120 if (IsValidNotification(stanza)) { 121 if (IsValidNotification(stanza)) {
121 QueueStanza(stanza); 122 QueueStanza(stanza);
122 return true; 123 return true;
123 } 124 }
124 return false; 125 return false;
125 } 126 }
126 127
127 bool ListenTask::IsValidNotification(const buzz::XmlElement* stanza) { 128 bool ListenTask::IsValidNotification(const buzz::XmlElement* stanza) {
128 static const buzz::QName kQnNotifierGetAll( 129 const buzz::QName kQnNotifierGetAll(kNotifierNamespace, "getAll");
129 kNotifierNamespace, "getAll"); 130 return MatchRequestIq(stanza, buzz::STR_SET, kQnNotifierGetAll);
sanjeevr 2011/01/30 22:55:07 Nit: Leave the original comment about the format o
akalin 2011/01/31 09:54:17 Done.
130 // An update notificaiton has the following form.
131 // <cli:iq from="{bare_jid}" to="{full_jid}"
132 // id="#" type="set" xmlns:cli="jabber:client">
133 // <not:getAll xmlns:not="google:notifier">
134 // <Timestamp long="#" xmlns=""/>
135 // </not:getAll>
136 // </cli:iq>
137 return
138 (MatchRequestIq(stanza, buzz::STR_SET, kQnNotifierGetAll) &&
139 (stanza->Attr(buzz::QN_TO) == GetClient()->jid().Str()) &&
140 (stanza->Attr(buzz::QN_FROM) == GetClient()->jid().BareJid().Str()));
141 } 131 }
142 132
143 } // namespace notifier 133 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698