1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef REMOTING_HOST_WIN_WTS_TERMINAL_MONITOR_H_
6 #define REMOTING_HOST_WIN_WTS_TERMINAL_MONITOR_H_
7 
8 #include <stdint.h>
9 
10 #include <string>
11 
12 #include "base/macros.h"
13 #include "base/strings/utf_string_conversions.h"
14 
15 namespace remoting {
16 
17 class WtsTerminalObserver;
18 
19 // Session id that does not represent any session.
20 extern const uint32_t kInvalidSessionId;
21 
22 class WtsTerminalMonitor {
23  public:
24   // The console terminal ID.
25   static const char kConsole[];
26 
27   virtual ~WtsTerminalMonitor();
28 
29   // Registers an observer to receive notifications about a particular WTS
30   // terminal. |terminal_id| is used to specify an RdpClient instance for which
31   // the connected session should be monitored, or |kConsole| may be passed to
32   // monitor the console session.
33   //
34   // Each observer instance can monitor a single WTS console. Returns
35   // |true| of success. Returns |false| if |observer| is already registered.
36   virtual bool AddWtsTerminalObserver(const std::string& terminal_id,
37                                       WtsTerminalObserver* observer) = 0;
38 
39   // Unregisters a previously registered observer.
40   virtual void RemoveWtsTerminalObserver(WtsTerminalObserver* observer) = 0;
41 
42   // Returns ID of the terminal connected to |session_id| in |*terminal_id|.
43   // Returns false if |session_id| is not attached to the physical console or
44   // does not have an assigned terminal ID.
45   static bool LookupTerminalId(uint32_t session_id, std::string* terminal_id);
46 
47   // Returns ID of the session that |terminal_id| is attached.
48   // |kInvalidSessionId| is returned if none of the sessions is currently
49   // attahced to |client_endpoint|.
50   static uint32_t LookupSessionId(const std::string& terminal_id);
51 
52  protected:
53   WtsTerminalMonitor();
54 
55  private:
56   DISALLOW_COPY_AND_ASSIGN(WtsTerminalMonitor);
57 };
58 
59 }  // namespace remoting
60 
61 #endif  // REMOTING_HOST_WIN_WTS_TERMINAL_MONITOR_H_
62