blob: 016ddc7f093c3d62b6e2e5cf5adce69999ada85e [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -07001// 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 Masone9be4a9d2011-05-16 15:44:09 -07005#ifndef SHILL_SERVICE_
6#define SHILL_SERVICE_
Paul Stewart75897df2011-04-27 09:05:53 -07007
Chris Masone9be4a9d2011-05-16 15:44:09 -07008#include <string>
9
10#include <base/memory/ref_counted.h>
Paul Stewartba41b992011-05-26 07:02:46 -070011#include <base/memory/scoped_ptr.h>
Paul Stewart75897df2011-04-27 09:05:53 -070012
Chris Masonec1e50412011-06-07 13:04:53 -070013#include "shill/device_config_interface.h"
14
Paul Stewart75897df2011-04-27 09:05:53 -070015namespace shill {
16
17class Connection;
18class Configuration;
Chris Masone9be4a9d2011-05-16 15:44:09 -070019class ControlInterface;
Paul Stewart75897df2011-04-27 09:05:53 -070020class Endpoint;
Chris Masone9be4a9d2011-05-16 15:44:09 -070021class EventDispatcher;
Chris Masonec1e50412011-06-07 13:04:53 -070022class Service;
Chris Masone9be4a9d2011-05-16 15:44:09 -070023class ServiceAdaptorInterface;
Paul Stewart75897df2011-04-27 09:05:53 -070024
Chris Masonec1e50412011-06-07 13:04:53 -070025typedef scoped_refptr<const Service> ServiceConstRefPtr;
26typedef scoped_refptr<Service> ServiceRefPtr;
27
Chris Masone9be4a9d2011-05-16 15:44:09 -070028class Service : public base::RefCounted<Service> {
Paul Stewart75897df2011-04-27 09:05:53 -070029 public:
Paul Stewart75897df2011-04-27 09:05:53 -070030 enum ConnectFailure {
31 kServiceFailureUnknown,
32 kServiceFailureActivationFailure,
33 kServiceFailureOutOfRange,
34 kServiceFailurePinMissing,
35 kServiceFailureConfigurationFailed,
36 kServiceFailureBadCredentials,
37 kServiceFailureNeedEVDO,
38 kServiceFailureNeedHomeNetwork,
39 kServiceFailureOTASPFailure,
40 kServiceFailureAAAFailure
41 };
Chris Masone9be4a9d2011-05-16 15:44:09 -070042 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 Masonec1e50412011-06-07 13:04:53 -070055 DeviceConfigInterfaceRefPtr config_interface,
Chris Masonea82b7112011-05-25 15:16:29 -070056 const std::string& name);
Chris Masone9be4a9d2011-05-16 15:44:09 -070057 virtual ~Service();
58 virtual void Connect() = 0;
59 virtual void Disconnect() = 0;
Chris Masonea82b7112011-05-25 15:16:29 -070060
61 // Returns a string that is guaranteed to uniquely identify this
62 // Service instance.
63 virtual const std::string& UniqueName() { return name_; }
Paul Stewart75897df2011-04-27 09:05:53 -070064
65 private:
Chris Masonea82b7112011-05-25 15:16:29 -070066 const std::string name_;
Paul Stewart75897df2011-04-27 09:05:53 -070067 bool available_;
68 bool configured_;
69 bool auto_connect_;
70 Configuration *configuration_;
71 Connection *connection_;
Chris Masonec1e50412011-06-07 13:04:53 -070072 DeviceConfigInterfaceRefPtr config_interface_;
Paul Stewart75897df2011-04-27 09:05:53 -070073 Endpoint *endpoint_;
Paul Stewartba41b992011-05-26 07:02:46 -070074 scoped_ptr<ServiceAdaptorInterface> adaptor_;
Chris Masone413a3192011-05-09 17:10:05 -070075 friend class ServiceAdaptorInterface;
Paul Stewart75897df2011-04-27 09:05:53 -070076};
77
78} // namespace shill
79
80#endif // SHILL_SERVICE_