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

Unified Diff: third_party/xmpp/mucroomdiscoverytask.cc

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Restored includes in jingle/ as well Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/xmpp/mucroomdiscoverytask.cc
diff --git a/third_party/xmpp/mucroomdiscoverytask.cc b/third_party/xmpp/mucroomdiscoverytask.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b7507aa4452f47525e7600c4bb0038dc356968ce
--- /dev/null
+++ b/third_party/xmpp/mucroomdiscoverytask.cc
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2012 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "third_party/xmpp/mucroomdiscoverytask.h"
+
+#include "third_party/xmpp/constants.h"
+
+namespace buzz {
+
+MucRoomDiscoveryTask::MucRoomDiscoveryTask(
+ XmppTaskParentInterface* parent,
+ const Jid& room_jid)
+ : IqTask(parent, STR_GET, room_jid,
+ new buzz::XmlElement(buzz::QN_DISCO_INFO_QUERY)) {
+}
+
+void MucRoomDiscoveryTask::HandleResult(const XmlElement* stanza) {
+ const XmlElement* query = stanza->FirstNamed(QN_DISCO_INFO_QUERY);
+ if (query == NULL) {
+ SignalError(this, NULL);
+ return;
+ }
+
+ std::set<std::string> features;
+ std::map<std::string, std::string> extended_info;
+ const XmlElement* identity = query->FirstNamed(QN_DISCO_IDENTITY);
+ if (identity == NULL || !identity->HasAttr(QN_NAME)) {
+ SignalResult(this, false, "", "", features, extended_info);
+ return;
+ }
+
+ const std::string name(identity->Attr(QN_NAME));
+
+ // Get the conversation id
+ const XmlElement* conversation =
+ identity->FirstNamed(QN_GOOGLE_MUC_HANGOUT_CONVERSATION_ID);
+ std::string conversation_id;
+ if (conversation != NULL) {
+ conversation_id = conversation->BodyText();
+ }
+
+ for (const XmlElement* feature = query->FirstNamed(QN_DISCO_FEATURE);
+ feature != NULL; feature = feature->NextNamed(QN_DISCO_FEATURE)) {
+ features.insert(feature->Attr(QN_VAR));
+ }
+
+ const XmlElement* data_x = query->FirstNamed(QN_XDATA_X);
+ if (data_x != NULL) {
+ for (const XmlElement* field = data_x->FirstNamed(QN_XDATA_FIELD);
+ field != NULL; field = field->NextNamed(QN_XDATA_FIELD)) {
+ const std::string key(field->Attr(QN_VAR));
+ extended_info[key] = field->Attr(QN_XDATA_VALUE);
+ }
+ }
+
+ SignalResult(this, true, name, conversation_id, features, extended_info);
+}
+
+} // namespace buzz

Powered by Google App Engine
This is Rietveld 408576698