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 | #include "shill/vpn_provider.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | #include <chromeos/dbus/service_constants.h> |
| 9 | |
| 10 | #include "shill/error.h" |
| 11 | #include "shill/openvpn_driver.h" |
| 12 | #include "shill/vpn_service.h" |
| 13 | |
| 14 | using std::string; |
| 15 | |
| 16 | namespace shill { |
| 17 | |
| 18 | VPNProvider::VPNProvider(ControlInterface *control_interface, |
| 19 | EventDispatcher *dispatcher, |
| 20 | Metrics *metrics, |
| 21 | Manager *manager) |
| 22 | : control_interface_(control_interface), |
| 23 | dispatcher_(dispatcher), |
| 24 | metrics_(metrics), |
| 25 | manager_(manager) {} |
| 26 | |
| 27 | VPNProvider::~VPNProvider() {} |
| 28 | |
| 29 | void VPNProvider::Start() {} |
| 30 | |
| 31 | void VPNProvider::Stop() {} |
| 32 | |
| 33 | VPNServiceRefPtr VPNProvider::GetService(const KeyValueStore &args, |
| 34 | Error *error) { |
| 35 | VLOG(2) << __func__; |
| 36 | if (!args.ContainsString(flimflam::kProviderTypeProperty)) { |
| 37 | Error::PopulateAndLog( |
| 38 | error, Error::kNotSupported, "Missing VPN type property."); |
| 39 | return NULL; |
| 40 | } |
| 41 | const string &type = args.GetString(flimflam::kProviderTypeProperty); |
| 42 | scoped_ptr<VPNDriver> driver; |
| 43 | if (type == flimflam::kProviderOpenVpn) { |
| 44 | driver.reset(new OpenVPNDriver()); |
| 45 | } else { |
| 46 | Error::PopulateAndLog( |
| 47 | error, Error::kNotSupported, "Unsupported VPN type: " + type); |
| 48 | return NULL; |
| 49 | } |
| 50 | return new VPNService( |
| 51 | control_interface_, dispatcher_, metrics_, manager_, driver.release()); |
| 52 | } |
| 53 | |
| 54 | } // namespace shill |