| 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> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // returns NULL if service is not found | 37 // returns NULL if service is not found |
| 38 virtual const Service* GetService(const std::string& service_path) const; | 38 virtual const Service* GetService(const std::string& service_path) const; |
| 39 | 39 |
| 40 // set Cashew server | 40 // set Cashew server |
| 41 // we'll talk to it when we want to emit updates to the world on behalf of | 41 // we'll talk to it when we want to emit updates to the world on behalf of |
| 42 // our child Services. | 42 // our child Services. |
| 43 // it's ok to clear this by setting it to NULL, in which case our updates | 43 // it's ok to clear this by setting it to NULL, in which case our updates |
| 44 // will go into a black hole. | 44 // will go into a black hole. |
| 45 virtual void SetCashewServer(CashewServer *cashew_server); | 45 virtual void SetCashewServer(CashewServer *cashew_server); |
| 46 | 46 |
| 47 // return our latest info on the current default technology |
| 48 virtual Service::Type GetDefaultTechnology() const; |
| 49 |
| 50 // valid Flimflam global connectivity state values |
| 51 typedef enum { |
| 52 kConnectivityStateUnknown = 0, |
| 53 kConnectivityStateOffline, |
| 54 kConnectivityStateConnected, |
| 55 kConnectivityStateOnline, |
| 56 } ConnectivityState; |
| 57 |
| 58 // return our latest info on Flimflam's global connectivity state |
| 59 virtual ConnectivityState GetConnectivityState() const; |
| 60 |
| 61 // does |state| represent an offline state |
| 62 static bool IsOfflineConnectivityState(ConnectivityState state); |
| 63 |
| 64 // does |state| represent an online state |
| 65 static bool IsOnlineConnectivityState(ConnectivityState state); |
| 66 |
| 47 // Flimflam Manager D-Bus Proxy methods | 67 // Flimflam Manager D-Bus Proxy methods |
| 48 | 68 |
| 49 // receive incoming PropertyChanged D-Bus signal from Flimflam | 69 // receive incoming PropertyChanged D-Bus signal from Flimflam |
| 50 virtual void PropertyChanged(const std::string& property_name, | 70 virtual void PropertyChanged(const std::string& property_name, |
| 51 const DBus::Variant& new_value); | 71 const DBus::Variant& new_value); |
| 52 | 72 |
| 53 // receive incoming StateChanged D-Bus signal from Flimflam | 73 // receive incoming StateChanged D-Bus signal from Flimflam |
| 54 virtual void StateChanged(const std::string& new_state); | 74 virtual void StateChanged(const std::string& new_state_string); |
| 55 | 75 |
| 56 // Service methods | 76 // Service methods |
| 57 | 77 |
| 58 // a child Service wants us to emit an update about its data plans | 78 // a child Service wants us to emit an update about its data plans |
| 59 virtual void EmitDataPlansUpdate(const Service& service); | 79 virtual void EmitDataPlansUpdate(const Service& service); |
| 60 | 80 |
| 61 private: | 81 private: |
| 62 // D-Bus connection owned by our creator | 82 // D-Bus connection owned by our creator |
| 63 // shared with Service objs that we create | 83 // shared with Service objs that we create |
| 64 DBus::Connection& connection_; | 84 DBus::Connection& connection_; |
| 65 | 85 |
| 66 // collection of Service objs representing cellular services | 86 // collection of Service objs representing cellular services |
| 67 ServiceMap services_; | 87 ServiceMap services_; |
| 68 | 88 |
| 69 // Cashew server implementing our front-end interface | 89 // Cashew server implementing our front-end interface |
| 70 CashewServer *cashew_server_; | 90 CashewServer *cashew_server_; |
| 71 | 91 |
| 92 // default technology most recently reported by Flimflam |
| 93 Service::Type default_technology_; |
| 94 |
| 95 // the cellular service, if any, that we think is the default service |
| 96 // can be NULL if we don't know the default service or a non-cellular |
| 97 // service is the default |
| 98 Service *default_cellular_service_; |
| 99 |
| 100 // global connectivity state most recently reported by Flimflam |
| 101 ConnectivityState connectivity_state_; |
| 102 |
| 72 // delete a collection of services | 103 // delete a collection of services |
| 73 void DeleteServices(ServiceMap *service_map); | 104 void DeleteServices(ServiceMap *service_map); |
| 74 | 105 |
| 75 // get Services info from Flimflam | 106 // get interesting properties from Flimflam such as Services and |
| 76 void GetFlimflamServices(); | 107 // DefaultTechnology |
| 108 void GetFlimflamProperties(); |
| 109 |
| 110 // we've received updated DefaultTechnology info from Flimflam |
| 111 void OnDefaultTechnologyUpdate(const std::string& default_technology); |
| 77 | 112 |
| 78 // we've received updated Services info from Flimflam | 113 // we've received updated Services info from Flimflam |
| 79 void OnServicesUpdate(const ServicePathList& paths); | 114 void OnServicesUpdate(const ServicePathList& paths); |
| 80 | 115 |
| 81 // Flimflam has started advertising a new service | 116 // Flimflam has started advertising a new service |
| 82 void OnNewService(const DBus::Path& path); | 117 void OnNewService(const DBus::Path& path); |
| 83 | 118 |
| 119 // we've received updated default service info from Flimflam |
| 120 // NULL |path| means that there is no default service |
| 121 void OnDefaultServiceUpdate(const DBus::Path *path); |
| 122 |
| 123 // if |default_cellular_service_| points to a service, tell it |
| 124 // that it is no longer the default service and clear our ptr |
| 125 void ClearDefaultCellularService(); |
| 126 |
| 127 // tell |service| that it is now the default service and set our |
| 128 // |default_cellular_service_| ptr to point to it. |
| 129 // if there is already a default service, first clear it. |
| 130 // NULL |service| is ok and is equivalent to ClearDefaultCellularService |
| 131 // no-op if |service| == |default_cellular_service_| |
| 132 void SetDefaultCellularService(Service *service); |
| 133 |
| 134 // convert connectivity state string to ConnectivityState enum value |
| 135 static ConnectivityState ConnectivityStateFromString( |
| 136 const std::string& state); |
| 137 |
| 138 // Flimflam has told us that it has come online |
| 139 void OnFlimflamOnline(); |
| 140 |
| 141 // Flimflam has told us that it has gone offline |
| 142 void OnFlimflamOffline(); |
| 143 |
| 84 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 144 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
| 85 }; | 145 }; |
| 86 | 146 |
| 87 } // namespace cashew | 147 } // namespace cashew |
| 88 | 148 |
| 89 #endif // SRC_SERVICE_MANAGER_H_ | 149 #endif // SRC_SERVICE_MANAGER_H_ |
| OLD | NEW |