Home | History | Annotate | Download | only in win
      1 // Copyright 2013 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 CLOUD_PRINT_SERVICE_SERVICE_CONTROLLER_H_
      6 #define CLOUD_PRINT_SERVICE_SERVICE_CONTROLLER_H_
      7 
      8 #include <atlbase.h>
      9 #include <string>
     10 
     11 #include "base/command_line.h"
     12 #include "base/strings/string16.h"
     13 #include "cloud_print/resources.h"
     14 
     15 namespace base {
     16 class FilePath;
     17 }  // base
     18 
     19 class ServiceController {
     20  public:
     21   enum State {
     22     STATE_UNKNOWN = 0,
     23     STATE_NOT_FOUND,
     24     STATE_STOPPED,
     25     STATE_RUNNING,
     26   };
     27 
     28   DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CLOUDPRINTSERVICE,
     29                                     "{8013FB7C-2E3E-4992-B8BD-05C0C4AB0627}")
     30 
     31   ServiceController();
     32   ~ServiceController();
     33 
     34   // Installs temporarily service to check pre-requirements.
     35   HRESULT InstallCheckService(const base::string16& user,
     36                               const base::string16& password,
     37                               const base::FilePath& user_data_dir);
     38 
     39   // Installs real service that will run connector.
     40   HRESULT InstallConnectorService(const base::string16& user,
     41                                   const base::string16& password,
     42                                   const base::FilePath& user_data_dir,
     43                                   bool enable_logging);
     44 
     45   HRESULT UninstallService();
     46 
     47   HRESULT StartService();
     48   HRESULT StopService();
     49 
     50   HRESULT UpdateBinaryPath();
     51 
     52   // Query service status and options. Results accessible with getters below.
     53   void UpdateState();
     54   State state() const { return state_; }
     55   const base::string16& user() const { return user_; }
     56   bool is_logging_enabled() const;
     57 
     58   base::FilePath GetBinary() const;
     59 
     60  private:
     61   HRESULT InstallService(const base::string16& user,
     62                          const base::string16& password,
     63                          bool auto_start,
     64                          const std::string& run_switch,
     65                          const base::FilePath& user_data_dir,
     66                          bool enable_logging);
     67 
     68   const base::string16 name_;
     69   State state_;
     70   base::string16 user_;
     71   bool is_logging_enabled_;
     72   base::CommandLine command_line_;
     73 };
     74 
     75 #endif  // CLOUD_PRINT_SERVICE_SERVICE_CONTROLLER_H_
     76 
     77