diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 07:06:34 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 07:06:34 +0000 |
commit | c80c5d256810c450e6b5f12ec4b3dd7a658f4497 (patch) | |
tree | 9b2432a365d5f5066e0f53938b10dfcd1b1f63af /remoting | |
parent | 44a8aacef75d0de3db8278d72386f110b4eb9bcc (diff) | |
download | chromium_src-c80c5d256810c450e6b5f12ec4b3dd7a658f4497.zip chromium_src-c80c5d256810c450e6b5f12ec4b3dd7a658f4497.tar.gz chromium_src-c80c5d256810c450e6b5f12ec4b3dd7a658f4497.tar.bz2 |
Implement DaemonController::GetVersion() method on Linux
BUG=120950
Review URL: https://chromiumcodereview.appspot.com/10909090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/plugin/daemon_controller_linux.cc | 38 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 9 | ||||
-rw-r--r-- | remoting/remoting.gyp | 3 | ||||
-rwxr-xr-x | remoting/tools/me2me_virtual_host.py | 9 | ||||
-rw-r--r-- | remoting/webapp/host_controller.js | 2 |
5 files changed, 56 insertions, 5 deletions
diff --git a/remoting/host/plugin/daemon_controller_linux.cc b/remoting/host/plugin/daemon_controller_linux.cc index 71857cd..ab2e087 100644 --- a/remoting/host/plugin/daemon_controller_linux.cc +++ b/remoting/host/plugin/daemon_controller_linux.cc @@ -76,6 +76,7 @@ class DaemonControllerLinux : public remoting::DaemonController { void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, const CompletionCallback& done_callback); void DoStop(const CompletionCallback& done_callback); + void DoGetVersion(const GetVersionCallback& done_callback); base::Thread file_io_thread_; @@ -194,9 +195,9 @@ void DaemonControllerLinux::SetWindow(void* window_handle) { void DaemonControllerLinux::GetVersion( const GetVersionCallback& done_callback) { - // TODO(sergeyu): Implement this method. - NOTIMPLEMENTED(); - done_callback.Run(""); + file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + &DaemonControllerLinux::DoGetVersion, base::Unretained(this), + done_callback)); } FilePath DaemonControllerLinux::GetConfigPath() { @@ -302,6 +303,37 @@ void DaemonControllerLinux::DoStop(const CompletionCallback& done_callback) { done_callback.Run(result); } +void DaemonControllerLinux::DoGetVersion( + const GetVersionCallback& done_callback) { + FilePath script_path; + if (!GetScriptPath(&script_path)) { + done_callback.Run(""); + return; + } + CommandLine command_line(script_path); + command_line.AppendArg("--host-version"); + + std::string version; + int exit_code = 0; + int result = + base::GetAppOutputWithExitCode(command_line, &version, &exit_code); + if (!result || exit_code != 0) { + LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString() + << "\". Exit code: " << exit_code; + done_callback.Run(""); + return; + } + + TrimWhitespaceASCII(version, TRIM_ALL, &version); + if (!ContainsOnlyChars(version, "0123456789.")) { + LOG(ERROR) << "Received invalid host version number: " << version; + done_callback.Run(""); + return; + } + + done_callback.Run(version); +} + } // namespace scoped_ptr<DaemonController> remoting::DaemonController::Create() { diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 045727c..bc18501 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -17,6 +17,7 @@ #include "base/message_loop.h" #include "base/scoped_native_library.h" #include "base/string_util.h" +#include "base/stringize_macros.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "base/utf_string_conversions.h" @@ -88,6 +89,9 @@ const char kApplicationName[] = "chromoting"; // The command line switch specifying the name of the daemon IPC endpoint. const char kDaemonIpcSwitchName[] = "daemon-pipe"; +// The command line switch used to get version of the daemon. +const char kVersionSwitchName[] = "version"; + const char kUnofficialOAuth2ClientId[] = "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com"; const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_"; @@ -715,6 +719,11 @@ int main(int argc, char** argv) { // LazyInstance, MessageLoop). base::AtExitManager exit_manager; + if (CommandLine::ForCurrentProcess()->HasSwitch(kVersionSwitchName)) { + printf("%s\n", STRINGIZE(VERSION)); + return 0; + } + // Initialize logging with an appropriate log-file location, and default to // log to that on Windows, or to standard error output otherwise. FilePath debug_log = remoting::GetConfigDir(). diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index c0426f0..b41fd56 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -1445,6 +1445,9 @@ '../media/media.gyp:media', '../net/net.gyp:net', ], + 'defines': [ + 'VERSION=<(version_full)', + ], 'sources': [ 'host/branding.cc', 'host/branding.h', diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py index 0c99ac9..9d23268 100755 --- a/remoting/tools/me2me_virtual_host.py +++ b/remoting/tools/me2me_virtual_host.py @@ -573,6 +573,9 @@ Web Store: https://chrome.google.com/remotedesktop""" parser.add_option("", "--add-user", dest="add_user", default=False, action="store_true", help="Add current user to the chrome-remote-desktop group.") + parser.add_option("", "--host-version", dest="host_version", default=False, + action="store_true", + help="Prints version of the host.") (options, args) = parser.parse_args() host_hash = hashlib.md5(socket.gethostname()).hexdigest() @@ -606,7 +609,11 @@ Web Store: https://chrome.google.com/remotedesktop""" "\"groupadd -f %(group)s && gpasswd --add %(user)s %(group)s\"" % { 'group': CHROME_REMOTING_GROUP_NAME, 'user': getpass.getuser() }) - return os.system(command) + return os.system(command) >> 8 + + if options.host_version: + # TODO(sergeyu): Also check RPM package version once we add RPM package. + return os.system(locate_executable(HOST_BINARY_NAME) + " --version") >> 8 if not options.start: # If no modal command-line options specified, print an error and exit. diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js index 5771c92..b5d6876 100644 --- a/remoting/webapp/host_controller.js +++ b/remoting/webapp/host_controller.js @@ -21,7 +21,7 @@ remoting.HostController = function() { if (version == '') { console.log('Host not installed.'); } else { - console.log('Host version:', version); + console.log('Host version: ' + version); } }; try { |