| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SRC_SERVICE_MANAGER_H_ | 5 #ifndef SRC_SERVICE_MANAGER_H_ |
| 6 #define SRC_SERVICE_MANAGER_H_ | 6 #define SRC_SERVICE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include <base/basictypes.h> // NOLINT | 12 #include <base/basictypes.h> // NOLINT |
| 13 #include <dbus-c++/dbus.h> // NOLINT | 13 #include <dbus-c++/dbus.h> // NOLINT |
| 14 | 14 |
| 15 #include "src/flimflam_manager_client_glue.h" | 15 #include "src/flimflam_manager_client_glue.h" |
| 16 #include "src/service.h" |
| 16 | 17 |
| 17 namespace cashew { | 18 namespace cashew { |
| 18 | 19 |
| 19 class Service; | 20 class CashewServer; |
| 20 | 21 |
| 21 // map of service path names to Service objects | 22 // map of service path names to Service objects |
| 22 typedef std::map<std::string, Service*> ServiceMap; | 23 typedef std::map<std::string, Service*> ServiceMap; |
| 23 | 24 |
| 24 // vector of DBus::Path objects (strings) representing service path names | 25 // vector of DBus::Path objects (strings) representing service path names |
| 25 typedef std::vector<DBus::Path> ServicePathList; | 26 typedef std::vector<DBus::Path> ServicePathList; |
| 26 | 27 |
| 27 // monitors Flimflam and maintains a collection of cellular service objects | 28 // monitors Flimflam and maintains a collection of cellular service objects |
| 28 class ServiceManager : public org::chromium::flimflam::Manager_proxy, | 29 class ServiceManager : public org::chromium::flimflam::Manager_proxy, |
| 29 public DBus::IntrospectableProxy, | 30 public DBus::IntrospectableProxy, |
| 30 public DBus::ObjectProxy { | 31 public DBus::ObjectProxy { |
| 31 public: | 32 public: |
| 32 explicit ServiceManager(DBus::Connection& connection); // NOLINT | 33 explicit ServiceManager(DBus::Connection& connection); // NOLINT |
| 33 virtual ~ServiceManager(); | 34 virtual ~ServiceManager(); |
| 34 | 35 |
| 35 // look up a service by its path name | 36 // look up a service by its path name |
| 36 // returns NULL if service is not found | 37 // returns NULL if service is not found |
| 37 virtual const Service* GetService(const std::string& service_path) const; | 38 virtual const Service* GetService(const std::string& service_path) const; |
| 38 | 39 |
| 40 // set Cashew server |
| 41 // we'll talk to it when we want to emit updates to the world on behalf of |
| 42 // our child Services. |
| 43 // it's ok to clear this by setting it to NULL, in which case our updates |
| 44 // will go into a black hole. |
| 45 virtual void SetCashewServer(CashewServer *cashew_server); |
| 46 |
| 39 // Flimflam Manager D-Bus Proxy methods | 47 // Flimflam Manager D-Bus Proxy methods |
| 40 | 48 |
| 41 // receive incoming PropertyChanged D-Bus signal from Flimflam | 49 // receive incoming PropertyChanged D-Bus signal from Flimflam |
| 42 virtual void PropertyChanged(const std::string& property_name, | 50 virtual void PropertyChanged(const std::string& property_name, |
| 43 const DBus::Variant& new_value); | 51 const DBus::Variant& new_value); |
| 44 | 52 |
| 45 // receive incoming StateChanged D-Bus signal from Flimflam | 53 // receive incoming StateChanged D-Bus signal from Flimflam |
| 46 virtual void StateChanged(const std::string& new_state); | 54 virtual void StateChanged(const std::string& new_state); |
| 47 | 55 |
| 56 // Service methods |
| 57 |
| 58 // a child Service wants us to emit an update about its data plans |
| 59 virtual void EmitDataPlansUpdate(const Service& service); |
| 60 |
| 48 private: | 61 private: |
| 49 // D-Bus connection owned by our creator | 62 // D-Bus connection owned by our creator |
| 50 // shared with Service objs that we create | 63 // shared with Service objs that we create |
| 51 DBus::Connection& connection_; | 64 DBus::Connection& connection_; |
| 52 | 65 |
| 53 // collection of Service objs representing cellular services | 66 // collection of Service objs representing cellular services |
| 54 ServiceMap services_; | 67 ServiceMap services_; |
| 55 | 68 |
| 69 // Cashew server implementing our front-end interface |
| 70 CashewServer *cashew_server_; |
| 71 |
| 56 // delete a collection of services | 72 // delete a collection of services |
| 57 void DeleteServices(ServiceMap *service_map); | 73 void DeleteServices(ServiceMap *service_map); |
| 58 | 74 |
| 59 // get Services info from Flimflam | 75 // get Services info from Flimflam |
| 60 void GetFlimflamServices(); | 76 void GetFlimflamServices(); |
| 61 | 77 |
| 62 // we've received updated Services info from Flimflam | 78 // we've received updated Services info from Flimflam |
| 63 void OnServicesUpdate(const ServicePathList& paths); | 79 void OnServicesUpdate(const ServicePathList& paths); |
| 64 | 80 |
| 65 // Flimflam has started advertising a new service | 81 // Flimflam has started advertising a new service |
| 66 void OnNewService(const DBus::Path& path); | 82 void OnNewService(const DBus::Path& path); |
| 67 | 83 |
| 68 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 84 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
| 69 }; | 85 }; |
| 70 | 86 |
| 71 } // namespace cashew | 87 } // namespace cashew |
| 72 | 88 |
| 73 #endif // SRC_SERVICE_MANAGER_H_ | 89 #endif // SRC_SERVICE_MANAGER_H_ |
| OLD | NEW |