Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | |
| 5 | #ifndef SHILL_VPN_SERVICE_ |
| 6 | #define SHILL_VPN_SERVICE_ |
| 7 | |
| 8 | #include <base/memory/scoped_ptr.h> |
| 9 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 10 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 11 | #include "shill/connection.h" |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 12 | #include "shill/service.h" |
| 13 | |
| 14 | namespace shill { |
| 15 | |
Darin Petkov | 0286771 | 2012-03-12 14:25:05 +0100 | [diff] [blame] | 16 | class KeyValueStore; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 17 | class VPNDriver; |
| 18 | |
| 19 | class VPNService : public Service { |
| 20 | public: |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 21 | VPNService(ControlInterface *control, |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 22 | EventDispatcher *dispatcher, |
| 23 | Metrics *metrics, |
| 24 | Manager *manager, |
| 25 | VPNDriver *driver); // Takes ownership of |driver|. |
| 26 | virtual ~VPNService(); |
| 27 | |
| 28 | // Inherited from Service. |
mukesh agrawal | dc7b844 | 2012-09-27 13:48:14 -0700 | [diff] [blame] | 29 | virtual void Connect(Error *error, const char *reason); |
Darin Petkov | 6aa2187 | 2012-03-09 16:10:19 +0100 | [diff] [blame] | 30 | virtual void Disconnect(Error *error); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 31 | virtual std::string GetStorageIdentifier() const; |
Darin Petkov | f3c71d7 | 2012-03-21 12:32:15 +0100 | [diff] [blame] | 32 | virtual bool Load(StoreInterface *storage); |
| 33 | virtual bool Save(StoreInterface *storage); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 34 | virtual bool Unload(); |
Darin Petkov | 1d0080a | 2012-04-30 17:10:36 +0200 | [diff] [blame] | 35 | virtual void MakeFavorite(); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 36 | virtual void SetConnection(const ConnectionRefPtr &connection); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 37 | virtual bool SetNameProperty(const std::string &name, Error *error); |
Darin Petkov | 6aa2187 | 2012-03-09 16:10:19 +0100 | [diff] [blame] | 38 | |
Paul Stewart | ebd3856 | 2012-03-23 13:06:40 -0700 | [diff] [blame] | 39 | virtual void InitDriverPropertyStore(); |
| 40 | |
Darin Petkov | 6aa2187 | 2012-03-09 16:10:19 +0100 | [diff] [blame] | 41 | VPNDriver *driver() const { return driver_.get(); } |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 42 | |
Darin Petkov | 0286771 | 2012-03-12 14:25:05 +0100 | [diff] [blame] | 43 | static std::string CreateStorageIdentifier(const KeyValueStore &args, |
| 44 | Error *error); |
| 45 | void set_storage_id(const std::string &id) { storage_id_ = id; } |
| 46 | |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 47 | protected: |
| 48 | // Inherited from Service. |
| 49 | virtual bool IsAutoConnectable(const char **reason) const; |
| 50 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 51 | private: |
Darin Petkov | 4cbff5b | 2013-01-29 16:29:05 +0100 | [diff] [blame] | 52 | friend class VPNServiceTest; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 53 | FRIEND_TEST(VPNServiceTest, GetDeviceRpcId); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 54 | FRIEND_TEST(VPNServiceTest, SetConnection); |
Alex Deymo | fddc09a | 2013-07-03 18:41:31 -0700 | [diff] [blame] | 55 | FRIEND_TEST(VPNServiceTest, GetPhysicalTechologyPropertyFailsIfNoCarrier); |
| 56 | FRIEND_TEST(VPNServiceTest, GetPhysicalTechologyPropertyOverWifi); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 57 | |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 58 | static const char kAutoConnNeverConnected[]; |
Darin Petkov | 4cbff5b | 2013-01-29 16:29:05 +0100 | [diff] [blame] | 59 | static const char kAutoConnVPNAlreadyActive[]; |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 60 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 61 | virtual std::string GetDeviceRpcId(Error *error); |
| 62 | |
Alex Deymo | fddc09a | 2013-07-03 18:41:31 -0700 | [diff] [blame] | 63 | // Returns the Type name of the lowest connection (presumably the "physical" |
| 64 | // connection) that this service depends on. |
| 65 | std::string GetPhysicalTechologyProperty(Error *error); |
| 66 | |
Darin Petkov | 0286771 | 2012-03-12 14:25:05 +0100 | [diff] [blame] | 67 | std::string storage_id_; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 68 | scoped_ptr<VPNDriver> driver_; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 69 | scoped_ptr<Connection::Binder> connection_binder_; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 70 | |
Paul Stewart | 2280799 | 2012-04-11 08:48:31 -0700 | [diff] [blame] | 71 | // Provided only for compatibility. crosbug.com/29286 |
| 72 | std::string vpn_domain_; |
| 73 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 74 | DISALLOW_COPY_AND_ASSIGN(VPNService); |
| 75 | }; |
| 76 | |
| 77 | } // namespace shill |
| 78 | |
| 79 | #endif // SHILL_VPN_SERVICE_ |