blob: 85eb9c032bf0939a52365590afdca28eb6c38e7c [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
5#ifndef SHILL_MANAGER_
6#define SHILL_MANAGER_
7
Chris Masone9be4a9d2011-05-16 15:44:09 -07008#include <string>
Paul Stewart75897df2011-04-27 09:05:53 -07009#include <vector>
Chris Masone487b8bf2011-05-13 16:27:57 -070010
Chris Masone9be4a9d2011-05-16 15:44:09 -070011#include <base/memory/ref_counted.h>
Chris Masone487b8bf2011-05-13 16:27:57 -070012#include <base/memory/scoped_ptr.h>
Chris Masone88cbd5f2011-07-03 14:30:04 -070013#include <chromeos/dbus/service_constants.h>
Paul Stewart75897df2011-04-27 09:05:53 -070014
Paul Stewart75897df2011-04-27 09:05:53 -070015#include "shill/device.h"
Paul Stewart0af98bf2011-05-10 17:38:08 -070016#include "shill/device_info.h"
Darin Petkov887f2982011-07-14 16:10:17 -070017#include "shill/modem_info.h"
Chris Masoneb925cc82011-06-22 15:39:57 -070018#include "shill/property_store.h"
Chris Masone9be4a9d2011-05-16 15:44:09 -070019#include "shill/service.h"
20#include "shill/shill_event.h"
Paul Stewart75897df2011-04-27 09:05:53 -070021
22namespace shill {
23
Chris Masoned0ceb8c2011-06-02 10:05:39 -070024class ControlInterface;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070025class Error;
Chris Masoned0ceb8c2011-06-02 10:05:39 -070026class EventDispatcher;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070027class ManagerAdaptorInterface;
Darin Petkov887f2982011-07-14 16:10:17 -070028class GLib;
Chris Masoned0ceb8c2011-06-02 10:05:39 -070029
Chris Masone27c4aa52011-07-02 13:10:14 -070030class Manager {
Paul Stewart75897df2011-04-27 09:05:53 -070031 public:
Chris Masone88cbd5f2011-07-03 14:30:04 -070032 struct Properties {
33 public:
34 Properties() : offline_mode(false) {}
35 bool offline_mode;
36 std::string check_portal_list;
37 std::string country;
38 std::string portal_url;
39 };
40
Paul Stewart75897df2011-04-27 09:05:53 -070041 // A constructor for the Manager object
Chris Masone9be4a9d2011-05-16 15:44:09 -070042 Manager(ControlInterface *control_interface,
Darin Petkov887f2982011-07-14 16:10:17 -070043 EventDispatcher *dispatcher,
44 GLib *glib);
Chris Masone3bd3c8c2011-06-13 08:20:26 -070045 virtual ~Manager();
Paul Stewart75897df2011-04-27 09:05:53 -070046 void Start();
47 void Stop();
48
Chris Masone7aa5f902011-07-11 11:13:35 -070049 const ProfileRefPtr &ActiveProfile();
50
Chris Masone2b105542011-06-22 10:58:09 -070051 void RegisterDevice(const DeviceRefPtr &to_manage);
52 void DeregisterDevice(const DeviceConstRefPtr &to_forget);
Chris Masone9be4a9d2011-05-16 15:44:09 -070053
Chris Masone2b105542011-06-22 10:58:09 -070054 void RegisterService(const ServiceRefPtr &to_manage);
55 void DeregisterService(const ServiceConstRefPtr &to_forget);
Chris Masone9be4a9d2011-05-16 15:44:09 -070056
57 void FilterByTechnology(Device::Technology tech,
Chris Masonec1e50412011-06-07 13:04:53 -070058 std::vector<DeviceRefPtr> *found);
Chris Masone9be4a9d2011-05-16 15:44:09 -070059
Chris Masonee0dea762011-06-09 09:06:03 -070060 ServiceRefPtr FindService(const std::string& name);
Chris Masone9be4a9d2011-05-16 15:44:09 -070061
Chris Masone27c4aa52011-07-02 13:10:14 -070062 PropertyStore *store() { return &store_; }
Chris Masoneb925cc82011-06-22 15:39:57 -070063
Paul Stewart75897df2011-04-27 09:05:53 -070064 private:
Chris Masoneb925cc82011-06-22 15:39:57 -070065 std::string CalculateState();
66 std::vector<std::string> AvailableTechnologies();
67 std::vector<std::string> ConnectedTechnologies();
68 std::string DefaultTechnology();
69 std::vector<std::string> EnabledTechnologies();
Chris Masone3c3f6a12011-07-01 10:01:41 -070070 std::vector<std::string> EnumerateDevices();
71 // TODO(cmasone): these two should be implemented by asking the currently
72 // active profile, once we have such a thing.
73 std::vector<std::string> EnumerateAvailableServices();
74 std::vector<std::string> EnumerateWatchedServices();
Chris Masone7aa5f902011-07-11 11:13:35 -070075 std::string GetActiveProfileName();
Chris Masoneb925cc82011-06-22 15:39:57 -070076
Chris Masone27c4aa52011-07-02 13:10:14 -070077 void HelpRegisterDerivedString(const std::string &name,
Chris Masone7aa5f902011-07-11 11:13:35 -070078 std::string(Manager::*get)(void),
79 bool(Manager::*set)(const std::string&));
Chris Masone27c4aa52011-07-02 13:10:14 -070080 void HelpRegisterDerivedStrings(const std::string &name,
Chris Masone7aa5f902011-07-11 11:13:35 -070081 Strings(Manager::*get)(void),
82 bool(Manager::*set)(const Strings&));
Chris Masone27c4aa52011-07-02 13:10:14 -070083
Paul Stewart0af98bf2011-05-10 17:38:08 -070084 scoped_ptr<ManagerAdaptorInterface> adaptor_;
85 DeviceInfo device_info_;
Darin Petkov887f2982011-07-14 16:10:17 -070086 ModemInfo modem_info_;
Paul Stewart75897df2011-04-27 09:05:53 -070087 bool running_;
Chris Masonec1e50412011-06-07 13:04:53 -070088 std::vector<DeviceRefPtr> devices_;
89 std::vector<ServiceRefPtr> services_;
Chris Masone7aa5f902011-07-11 11:13:35 -070090 std::vector<ProfileRefPtr> profiles_;
91 ProfileRefPtr ephemeral_profile_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070092
Chris Masoneb925cc82011-06-22 15:39:57 -070093 // Properties to be get/set via PropertyStore calls.
Chris Masone88cbd5f2011-07-03 14:30:04 -070094 Properties props_;
Chris Masone27c4aa52011-07-02 13:10:14 -070095 PropertyStore store_;
96
Chris Masone413a3192011-05-09 17:10:05 -070097 friend class ManagerAdaptorInterface;
Paul Stewart75897df2011-04-27 09:05:53 -070098};
99
100} // namespace shill
101
102#endif // SHILL_MANAGER_