summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/host_event_logger.cc50
-rw-r--r--remoting/host/host_event_logger.h30
-rw-r--r--remoting/host/remoting_me2me_host.cc5
3 files changed, 85 insertions, 0 deletions
diff --git a/remoting/host/host_event_logger.cc b/remoting/host/host_event_logger.cc
new file mode 100644
index 0000000..9284cff
--- /dev/null
+++ b/remoting/host/host_event_logger.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/host_event_logger.h"
+
+#if defined(OS_LINUX)
+#include <syslog.h>
+#endif
+
+namespace {
+
+void Log(const std::string& message) {
+ // TODO(lambroslambrou): Refactor this part into platform-specific classes.
+#if defined(OS_LINUX)
+ syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str());
+#endif
+}
+
+} // namespace
+
+namespace remoting {
+
+HostEventLogger::HostEventLogger() {
+#if defined(OS_LINUX)
+ openlog("chromoting_host", 0, LOG_USER);
+#endif
+}
+
+HostEventLogger::~HostEventLogger() {
+}
+
+void HostEventLogger::OnClientAuthenticated(const std::string& jid) {
+ std::string username = jid.substr(0, jid.find('/'));
+ Log("Client connected: " + username);
+}
+
+void HostEventLogger::OnClientDisconnected(const std::string& jid) {
+ std::string username = jid.substr(0, jid.find('/'));
+ Log("Client disconnected: " + username);
+}
+
+void HostEventLogger::OnAccessDenied() {
+ Log("Access denied");
+}
+
+void HostEventLogger::OnShutdown() {
+}
+
+} // namespace remoting
diff --git a/remoting/host/host_event_logger.h b/remoting/host/host_event_logger.h
new file mode 100644
index 0000000..27d43ff
--- /dev/null
+++ b/remoting/host/host_event_logger.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_HOST_EVENT_LOGGER_H_
+#define REMOTING_HOST_HOST_EVENT_LOGGER_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "remoting/host/host_status_observer.h"
+
+namespace remoting {
+
+class HostEventLogger : public HostStatusObserver {
+ public:
+ HostEventLogger();
+ virtual ~HostEventLogger();
+
+ // HostStatusObserver implementation. These methods will be called from the
+ // network thread.
+ virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
+ virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
+ virtual void OnAccessDenied() OVERRIDE;
+ virtual void OnShutdown() OVERRIDE;
+};
+
+}
+
+#endif // REMOTING_HOST_HOST_EVENT_LOGGER_H_
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 33c5728..bd397a7 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -27,6 +27,7 @@
#include "remoting/host/event_executor.h"
#include "remoting/host/heartbeat_sender.h"
#include "remoting/host/host_config.h"
+#include "remoting/host/host_event_logger.h"
#include "remoting/host/json_host_config.h"
#include "remoting/host/log_to_server.h"
#include "remoting/host/signaling_connector.h"
@@ -175,6 +176,9 @@ class HostProcess {
log_to_server_.reset(new LogToServer(signal_strategy_.get()));
host_->AddStatusObserver(log_to_server_.get());
+ host_event_logger_.reset(new HostEventLogger());
+ host_->AddStatusObserver(host_event_logger_.get());
+
host_->Start();
// Create authenticator factory.
@@ -207,6 +211,7 @@ class HostProcess {
scoped_ptr<DesktopEnvironment> desktop_environment_;
scoped_ptr<remoting::HeartbeatSender> heartbeat_sender_;
scoped_ptr<LogToServer> log_to_server_;
+ scoped_ptr<HostEventLogger> host_event_logger_;
scoped_refptr<ChromotingHost> host_;
};