diff options
Diffstat (limited to 'remoting/host/chromoting_host.cc')
-rw-r--r-- | remoting/host/chromoting_host.cc | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index ace4f71..81f1f86 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -186,8 +186,8 @@ void ChromotingHost::AddStatusObserver( void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) { DCHECK_EQ(context_->network_message_loop(), MessageLoop::current()); VLOG(1) << "Connection to client established."; - // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. if (is_me2mom_) { + // TODO(wez): Improve our authentication framework. context_->main_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &ChromotingHost::ProcessPreAuthentication, @@ -283,13 +283,6 @@ void ChromotingHost::OnNewClientSession( return; } - // If we are running Me2Mom and already have an authenticated client then - // reject the connection immediately. - if (is_me2mom_ && HasAuthenticatedClients()) { - *response = protocol::SessionManager::DECLINE; - return; - } - // Check that the client has access to the host. if (!access_verifier_->VerifyPermissions(session->jid(), session->initiator_token())) { @@ -392,9 +385,20 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) { connection->Disconnect(); // Also remove reference to ConnectionToClient from this object. + int old_authenticated_clients = AuthenticatedClientsCount(); clients_.erase(client); - if (!HasAuthenticatedClients()) { + // Notify the observers of the change, if any. + int authenticated_clients = AuthenticatedClientsCount(); + if (old_authenticated_clients != authenticated_clients) { + for (StatusObserverList::iterator it = status_observers_.begin(); + it != status_observers_.end(); ++it) { + (*it)->OnAuthenticatedClientsChanged(authenticated_clients); + } + } + + // Enable the "curtain", if at least one client is actually authenticated. + if (AuthenticatedClientsCount() > 0) { EnableCurtainMode(false); if (is_me2mom_) { MonitorLocalInputs(false); @@ -428,19 +432,19 @@ std::string ChromotingHost::GenerateHostAuthToken( return encoded_client_token; } -bool ChromotingHost::HasAuthenticatedClients() const { +int ChromotingHost::AuthenticatedClientsCount() const { + int authenticated_clients = 0; for (ClientList::const_iterator it = clients_.begin(); it != clients_.end(); ++it) { if (it->get()->authenticated()) - return true; + ++authenticated_clients; } - return false; + return authenticated_clients; } void ChromotingHost::EnableCurtainMode(bool enable) { // TODO(jamiewalch): This will need to be more sophisticated when we think // about proper crash recovery and daemon mode. - // TODO(wez): CurtainMode shouldn't be driven directly by ChromotingHost. if (is_me2mom_ || enable == is_curtained_) return; desktop_environment_->curtain()->EnableCurtainMode(enable); @@ -515,6 +519,12 @@ void ChromotingHost::LocalLoginSucceeded( username.replace(pos, std::string::npos, ""); ShowDisconnectWindow(true, username); } + + // Notify observers that there is at least one authenticated client. + for (StatusObserverList::iterator it = status_observers_.begin(); + it != status_observers_.end(); ++it) { + (*it)->OnAuthenticatedClientsChanged(AuthenticatedClientsCount()); + } } void ChromotingHost::LocalLoginFailed( |