blob: f6fc027b326b5a332100de777500ab631a6bf551 [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"
Chris Masoneb925cc82011-06-22 15:39:57 -070017#include "shill/property_store.h"
Chris Masone9be4a9d2011-05-16 15:44:09 -070018#include "shill/service.h"
19#include "shill/shill_event.h"
Paul Stewart75897df2011-04-27 09:05:53 -070020
21namespace shill {
22
Chris Masoned0ceb8c2011-06-02 10:05:39 -070023class ControlInterface;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070024class Error;
Chris Masoned0ceb8c2011-06-02 10:05:39 -070025class EventDispatcher;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070026class ManagerAdaptorInterface;
Chris Masoned0ceb8c2011-06-02 10:05:39 -070027
Chris Masone27c4aa52011-07-02 13:10:14 -070028class Manager {
Paul Stewart75897df2011-04-27 09:05:53 -070029 public:
Chris Masone88cbd5f2011-07-03 14:30:04 -070030 struct Properties {
31 public:
32 Properties() : offline_mode(false) {}
33 bool offline_mode;
34 std::string check_portal_list;
35 std::string country;
36 std::string portal_url;
37 };
38
Paul Stewart75897df2011-04-27 09:05:53 -070039 // A constructor for the Manager object
Chris Masone9be4a9d2011-05-16 15:44:09 -070040 Manager(ControlInterface *control_interface,
41 EventDispatcher *dispatcher);
Chris Masone3bd3c8c2011-06-13 08:20:26 -070042 virtual ~Manager();
Paul Stewart75897df2011-04-27 09:05:53 -070043 void Start();
44 void Stop();
45
Chris Masone2b105542011-06-22 10:58:09 -070046 void RegisterDevice(const DeviceRefPtr &to_manage);
47 void DeregisterDevice(const DeviceConstRefPtr &to_forget);
Chris Masone9be4a9d2011-05-16 15:44:09 -070048
Chris Masone2b105542011-06-22 10:58:09 -070049 void RegisterService(const ServiceRefPtr &to_manage);
50 void DeregisterService(const ServiceConstRefPtr &to_forget);
Chris Masone9be4a9d2011-05-16 15:44:09 -070051
52 void FilterByTechnology(Device::Technology tech,
Chris Masonec1e50412011-06-07 13:04:53 -070053 std::vector<DeviceRefPtr> *found);
Chris Masone9be4a9d2011-05-16 15:44:09 -070054
Chris Masonee0dea762011-06-09 09:06:03 -070055 ServiceRefPtr FindService(const std::string& name);
Chris Masone9be4a9d2011-05-16 15:44:09 -070056
Chris Masone27c4aa52011-07-02 13:10:14 -070057 PropertyStore *store() { return &store_; }
Chris Masoneb925cc82011-06-22 15:39:57 -070058
Paul Stewart75897df2011-04-27 09:05:53 -070059 private:
Chris Masoneb925cc82011-06-22 15:39:57 -070060 std::string CalculateState();
61 std::vector<std::string> AvailableTechnologies();
62 std::vector<std::string> ConnectedTechnologies();
63 std::string DefaultTechnology();
64 std::vector<std::string> EnabledTechnologies();
Chris Masone3c3f6a12011-07-01 10:01:41 -070065 std::vector<std::string> EnumerateDevices();
66 // TODO(cmasone): these two should be implemented by asking the currently
67 // active profile, once we have such a thing.
68 std::vector<std::string> EnumerateAvailableServices();
69 std::vector<std::string> EnumerateWatchedServices();
Chris Masoneb925cc82011-06-22 15:39:57 -070070
Chris Masone27c4aa52011-07-02 13:10:14 -070071 void HelpRegisterDerivedString(const std::string &name,
72 std::string(Manager::*get)(void),
73 bool(Manager::*set)(const std::string&));
74 void HelpRegisterDerivedStrings(const std::string &name,
75 Strings(Manager::*get)(void),
76 bool(Manager::*set)(const Strings&));
77
Paul Stewart0af98bf2011-05-10 17:38:08 -070078 scoped_ptr<ManagerAdaptorInterface> adaptor_;
79 DeviceInfo device_info_;
Paul Stewart75897df2011-04-27 09:05:53 -070080 bool running_;
Chris Masonec1e50412011-06-07 13:04:53 -070081 std::vector<DeviceRefPtr> devices_;
82 std::vector<ServiceRefPtr> services_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070083
Chris Masoneb925cc82011-06-22 15:39:57 -070084 // Properties to be get/set via PropertyStore calls.
Chris Masone88cbd5f2011-07-03 14:30:04 -070085 Properties props_;
Chris Masone27c4aa52011-07-02 13:10:14 -070086 PropertyStore store_;
87
Chris Masone3bd3c8c2011-06-13 08:20:26 -070088 std::string active_profile_; // This is supposed to be, essentially,
89 // an RPC-visible object handle
90
Chris Masone413a3192011-05-09 17:10:05 -070091 friend class ManagerAdaptorInterface;
Paul Stewart75897df2011-04-27 09:05:53 -070092};
93
94} // namespace shill
95
96#endif // SHILL_MANAGER_