Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS 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 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 5 | #ifndef SHILL_SERVICE_ |
| 6 | #define SHILL_SERVICE_ |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
| 10 | #include <base/memory/ref_counted.h> |
Paul Stewart | ba41b99 | 2011-05-26 07:02:46 -0700 | [diff] [blame] | 11 | #include <base/memory/scoped_ptr.h> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 12 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 13 | #include "shill/device_config_interface.h" |
| 14 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 15 | namespace shill { |
| 16 | |
| 17 | class Connection; |
| 18 | class Configuration; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 19 | class ControlInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 20 | class Endpoint; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 21 | class EventDispatcher; |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 22 | class Service; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 23 | class ServiceAdaptorInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 24 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 25 | typedef scoped_refptr<const Service> ServiceConstRefPtr; |
| 26 | typedef scoped_refptr<Service> ServiceRefPtr; |
| 27 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 28 | class Service : public base::RefCounted<Service> { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 29 | public: |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 30 | enum ConnectFailure { |
| 31 | kServiceFailureUnknown, |
| 32 | kServiceFailureActivationFailure, |
| 33 | kServiceFailureOutOfRange, |
| 34 | kServiceFailurePinMissing, |
| 35 | kServiceFailureConfigurationFailed, |
| 36 | kServiceFailureBadCredentials, |
| 37 | kServiceFailureNeedEVDO, |
| 38 | kServiceFailureNeedHomeNetwork, |
| 39 | kServiceFailureOTASPFailure, |
| 40 | kServiceFailureAAAFailure |
| 41 | }; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 42 | enum ConnectState { |
| 43 | kServiceStateUnknown, |
| 44 | kServiceStateIdle, |
| 45 | kServiceStateAssociating, |
| 46 | kServiceStateConfiguring, |
| 47 | kServiceStateConnected, |
| 48 | kServiceStateDisconnected, |
| 49 | kServiceStateFailure |
| 50 | }; |
| 51 | |
| 52 | // A constructor for the Service object |
| 53 | Service(ControlInterface *control_interface, |
| 54 | EventDispatcher *dispatcher, |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 55 | DeviceConfigInterfaceRefPtr config_interface, |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 56 | const std::string& name); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 57 | virtual ~Service(); |
| 58 | virtual void Connect() = 0; |
| 59 | virtual void Disconnect() = 0; |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 60 | |
| 61 | // Returns a string that is guaranteed to uniquely identify this |
| 62 | // Service instance. |
| 63 | virtual const std::string& UniqueName() { return name_; } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 64 | |
| 65 | private: |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 66 | const std::string name_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 67 | bool available_; |
| 68 | bool configured_; |
| 69 | bool auto_connect_; |
| 70 | Configuration *configuration_; |
| 71 | Connection *connection_; |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 72 | DeviceConfigInterfaceRefPtr config_interface_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 73 | Endpoint *endpoint_; |
Paul Stewart | ba41b99 | 2011-05-26 07:02:46 -0700 | [diff] [blame] | 74 | scoped_ptr<ServiceAdaptorInterface> adaptor_; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 75 | friend class ServiceAdaptorInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace shill |
| 79 | |
| 80 | #endif // SHILL_SERVICE_ |