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 #include "shill/dbus/chromeos_modem_gobi_proxy.h" 18 19 #include <memory> 20 21 #include <base/bind.h> 22 23 #include "shill/cellular/cellular_error.h" 24 #include "shill/error.h" 25 #include "shill/logging.h" 26 27 using std::string; 28 29 namespace shill { 30 31 namespace Logging { 32 static auto kModuleLogScope = ScopeLogger::kDBus; 33 static string ObjectID(const dbus::ObjectPath* p) { return p->value(); } 34 } // namespace Logging 35 36 ChromeosModemGobiProxy::ChromeosModemGobiProxy( 37 const scoped_refptr<dbus::Bus>& bus, 38 const string& path, 39 const string& service) 40 : proxy_( 41 new org::chromium::ModemManager::Modem::GobiProxy( 42 bus, service, dbus::ObjectPath(path))) {} 43 44 ChromeosModemGobiProxy::~ChromeosModemGobiProxy() {} 45 46 void ChromeosModemGobiProxy::SetCarrier(const string& carrier, 47 Error* error, 48 const ResultCallback& callback, 49 int timeout) { 50 SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << carrier; 51 proxy_->SetCarrierAsync( 52 carrier, 53 base::Bind(&ChromeosModemGobiProxy::OnSetCarrierSuccess, 54 weak_factory_.GetWeakPtr(), 55 callback), 56 base::Bind(&ChromeosModemGobiProxy::OnSetCarrierFailure, 57 weak_factory_.GetWeakPtr(), 58 callback)); 59 } 60 61 void ChromeosModemGobiProxy::OnSetCarrierSuccess( 62 const ResultCallback& callback) { 63 SLOG(&proxy_->GetObjectPath(), 2) << __func__; 64 callback.Run(Error()); 65 } 66 67 void ChromeosModemGobiProxy::OnSetCarrierFailure( 68 const ResultCallback& callback, brillo::Error* dbus_error) { 69 SLOG(&proxy_->GetObjectPath(), 2) << __func__; 70 Error error; 71 CellularError::FromChromeosDBusError(dbus_error, &error); 72 callback.Run(error); 73 } 74 75 } // namespace shill 76