• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "webservd/firewalld_firewall.h"
16 
17 #include <string>
18 
19 #include <base/bind.h>
20 
21 namespace webservd {
22 
WaitForServiceAsync(dbus::Bus * bus,const base::Closure & callback)23 void FirewalldFirewall::WaitForServiceAsync(dbus::Bus* bus,
24                                             const base::Closure& callback) {
25   service_online_cb_ = callback;
26   object_manager_.reset(new org::chromium::Firewalld::ObjectManagerProxy{bus});
27   object_manager_->SetFirewalldAddedCallback(
28       base::Bind(&FirewalldFirewall::OnFirewalldOnline,
29                  weak_ptr_factory_.GetWeakPtr()));
30 }
31 
PunchTcpHoleAsync(uint16_t port,const std::string & interface_name,const base::Callback<void (bool)> & success_cb,const base::Callback<void (brillo::Error *)> & failure_cb)32 void FirewalldFirewall::PunchTcpHoleAsync(
33     uint16_t port,
34     const std::string& interface_name,
35     const base::Callback<void(bool)>& success_cb,
36     const base::Callback<void(brillo::Error*)>& failure_cb) {
37   proxy_->PunchTcpHoleAsync(port, interface_name, success_cb, failure_cb);
38 }
39 
OnFirewalldOnline(org::chromium::FirewalldProxyInterface * proxy)40 void FirewalldFirewall::OnFirewalldOnline(
41     org::chromium::FirewalldProxyInterface* proxy) {
42   proxy_ = proxy;
43   service_online_cb_.Run();
44 }
45 
46 }  // namespace webservd
47