summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.cc21
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.h12
2 files changed, 32 insertions, 1 deletions
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc
index fe7e2fe..2df898e 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.cc
+++ b/remoting/jingle_glue/xmpp_signal_strategy.cc
@@ -12,6 +12,10 @@
#include "third_party/libjingle/source/talk/xmpp/prexmppauth.h"
#include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h"
+namespace {
+const char kDefaultResourceName[] = "chromoting";
+} // namespace
+
namespace remoting {
XmppSignalStrategy::XmppSignalStrategy(JingleThread* jingle_thread,
@@ -22,6 +26,7 @@ XmppSignalStrategy::XmppSignalStrategy(JingleThread* jingle_thread,
username_(username),
auth_token_(auth_token),
auth_token_service_(auth_token_service),
+ resource_name_(kDefaultResourceName),
xmpp_client_(NULL),
state_(DISCONNECTED) {
}
@@ -41,7 +46,7 @@ void XmppSignalStrategy::Connect() {
buzz::Jid login_jid(username_);
settings.set_user(login_jid.node());
settings.set_host(login_jid.domain());
- settings.set_resource("chromoting");
+ settings.set_resource(resource_name_);
settings.set_use_tls(buzz::TLS_ENABLED);
settings.set_token_service(auth_token_service_);
settings.set_auth_cookie(auth_token_);
@@ -127,6 +132,20 @@ bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) {
return false;
}
+void XmppSignalStrategy::SetAuthInfo(const std::string& username,
+ const std::string& auth_token,
+ const std::string& auth_token_service) {
+ DCHECK(CalledOnValidThread());
+ username_ = username;
+ auth_token_ = auth_token;
+ auth_token_service_ = auth_token_service;
+}
+
+void XmppSignalStrategy::SetResourceName(const std::string &resource_name) {
+ DCHECK(CalledOnValidThread());
+ resource_name_ = resource_name;
+}
+
void XmppSignalStrategy::OnConnectionStateChanged(
buzz::XmppEngine::State state) {
DCHECK(CalledOnValidThread());
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h
index 056c900..641d93d 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.h
+++ b/remoting/jingle_glue/xmpp_signal_strategy.h
@@ -48,6 +48,17 @@ class XmppSignalStrategy : public base::NonThreadSafe,
// buzz::XmppStanzaHandler interface.
virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE;
+ // This method is used to update the auth info (for example when the OAuth
+ // access token is renewed). It is OK to call this even when we are in the
+ // CONNECTED state. It will be used on the next Connect() call.
+ void SetAuthInfo(const std::string& username,
+ const std::string& auth_token,
+ const std::string& auth_token_service);
+
+ // Use this method to override the default resource name used (optional).
+ // This will be used on the next Connect() call.
+ void SetResourceName(const std::string& resource_name);
+
private:
static buzz::PreXmppAuth* CreatePreXmppAuth(
const buzz::XmppClientSettings& settings);
@@ -60,6 +71,7 @@ class XmppSignalStrategy : public base::NonThreadSafe,
std::string username_;
std::string auth_token_;
std::string auth_token_service_;
+ std::string resource_name_;
buzz::XmppClient* xmpp_client_;
State state_;