1// 2// Copyright (C) 2015 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17#ifndef SHILL_DBUS_CHROMEOS_MODEM_MANAGER_PROXY_H_ 18#define SHILL_DBUS_CHROMEOS_MODEM_MANAGER_PROXY_H_ 19 20#include <string> 21#include <vector> 22 23#include <base/macros.h> 24 25#include "cellular/dbus-proxies.h" 26#include "shill/cellular/modem_manager_proxy_interface.h" 27 28namespace shill { 29 30class EventDispatcher; 31class ModemManagerClassic; 32 33// There's a single proxy per (old) ModemManager service identified by 34// its DBus |path| and owner name |service|. 35class ChromeosModemManagerProxy : public ModemManagerProxyInterface { 36 public: 37 ChromeosModemManagerProxy( 38 EventDispatcher* dispatcher, 39 const scoped_refptr<dbus::Bus>& bus, 40 ModemManagerClassic* manager, 41 const std::string& path, 42 const std::string& service, 43 const base::Closure& service_appeared_callback, 44 const base::Closure& service_vanished_callback); 45 ~ChromeosModemManagerProxy() override; 46 47 // Inherited from ModemManagerProxyInterface. 48 std::vector<std::string> EnumerateDevices() override; 49 50 private: 51 // Signal handlers. 52 void DeviceAdded(const dbus::ObjectPath& device); 53 void DeviceRemoved(const dbus::ObjectPath& device); 54 55 // Called when service appeared or vanished. 56 void OnServiceAvailable(bool available); 57 58 // Service name owner changed handler. 59 void OnServiceOwnerChanged(const std::string& old_owner, 60 const std::string& new_owner); 61 62 // Called when signal is connected to the ObjectProxy. 63 void OnSignalConnected(const std::string& interface_name, 64 const std::string& signal_name, 65 bool success); 66 67 std::unique_ptr<org::freedesktop::ModemManagerProxy> proxy_; 68 EventDispatcher* dispatcher_; 69 ModemManagerClassic* manager_; // The owner of this proxy. 70 base::Closure service_appeared_callback_; 71 base::Closure service_vanished_callback_; 72 bool service_available_; 73 74 base::WeakPtrFactory<ChromeosModemManagerProxy> weak_factory_{this}; 75 DISALLOW_COPY_AND_ASSIGN(ChromeosModemManagerProxy); 76}; 77 78} // namespace shill 79 80#endif // SHILL_DBUS_CHROMEOS_MODEM_MANAGER_PROXY_H_ 81