Skip to content

Commit

Permalink
Adding a setting to toggle the option to connect to gtalk or a custom…
Browse files Browse the repository at this point in the history
… xmpp server.
  • Loading branch information
lukeweber committed Apr 15, 2013
1 parent 8324ec9 commit 830b5f5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions talk/xmpp/xmppclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ XmppReturnStatus XmppClient::Connect(
d_->socket_->SignalClosed.connect(d_.get(), &Private::OnSocketClosed);

d_->engine_.reset(XmppEngine::Create());
if (settings.allow_gtalk_username_custom_domain()){
d_->engine_->AllowGtalkLoginWithUserDomain();
}
d_->engine_->SetSessionHandler(d_.get());
d_->engine_->SetOutputHandler(d_.get());
if (!settings.resource().empty()) {
Expand Down
3 changes: 3 additions & 0 deletions talk/xmpp/xmppclientsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class XmppUserSettings {
}
void set_resource(const std::string& resource) { resource_ = resource; }
void set_use_tls(const TlsOptions use_tls) { use_tls_ = use_tls; }
void set_allow_gtalk_username_custom_domain(bool b) { allow_gtalk_username_custom_domain_ = b; }
void set_allow_plain(bool f) { allow_plain_ = f; }
void set_test_server_domain(const std::string& test_server_domain) {
test_server_domain_ = test_server_domain;
Expand All @@ -69,6 +70,7 @@ class XmppUserSettings {
bool allow_plain() const { return allow_plain_; }
const std::string& test_server_domain() const { return test_server_domain_; }
const std::string& token_service() const { return token_service_; }
bool allow_gtalk_username_custom_domain() const { return allow_gtalk_username_custom_domain_; }

private:
std::string user_;
Expand All @@ -78,6 +80,7 @@ class XmppUserSettings {
std::string auth_token_;
std::string resource_;
TlsOptions use_tls_;
bool allow_gtalk_username_custom_domain_;
bool allow_plain_;
std::string test_server_domain_;
std::string token_service_;
Expand Down
3 changes: 3 additions & 0 deletions talk/xmpp/xmppengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ class XmppEngine {
//! Call this when building iq stanzas, to ensure that each iq
//! gets its own unique id.
virtual std::string NextId() = 0;

virtual void AllowGtalkLoginWithUserDomain() = 0;

#ifdef IOS_XMPP_FRAMEWORK
virtual void SignalBound(const Jid& fullJid) = 0;
virtual void RaiseReset() = 0;
Expand Down
4 changes: 4 additions & 0 deletions talk/xmpp/xmppengineimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ XmppReturnStatus XmppEngineImpl::Disconnect() {
return XMPP_RETURN_OK;
}

void XmppEngineImpl::AllowGtalkLoginWithUserDomain(){
login_task_->set_allow_non_google_login(true);
}

void XmppEngineImpl::IncomingStart(const XmlElement* start) {
if (HasError() || raised_reset_)
return;
Expand Down
5 changes: 4 additions & 1 deletion talk/xmpp/xmppengineimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ class XmppEngineImpl : public XmppEngine {
//! Call this when building iq stanzas, to ensure that each iq
//! gets its own unique id.
virtual std::string NextId();

virtual void AllowGtalkLoginWithUserDomain();

#ifdef IOS_XMPP_FRAMEWORK
void SignalBound(const Jid& fullJid);
void SignalBound(const Jid& fullJid);
#endif
private:
friend class XmppLoginTask;
Expand Down
2 changes: 0 additions & 2 deletions talk/xmpp/xmpplogintask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ XmppLoginTask::Advance() {
if (auth == NULL) {
return Failure(XmppEngine::ERROR_AUTH);
}
#ifndef XMPP_COMPATIBILITY
if (allowNonGoogleLogin_) {
// Setting the following two attributes is required to support
// non-google ids.
Expand All @@ -233,7 +232,6 @@ XmppLoginTask::Advance() {
// Allow login with either the non-google id or the friendly email.
auth->SetAttr(QN_GOOGLE_AUTH_CLIENT_USES_FULL_BIND_RESULT, "true");
}
#endif
pctx_->InternalSendStanza(auth);
delete auth;
state_ = LOGINSTATE_SASL_RUNNING;
Expand Down

0 comments on commit 830b5f5

Please sign in to comment.