blob: ff7a97aa45ebcff0ddf3b66030e2ba4d88c6807a [file] [log] [blame]
Alex Vakulenkof0f55342015-08-18 15:51:40 -07001/*
2 * Copyright 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 BUFFET_MDNS_CLIENT_H_
18#define BUFFET_MDNS_CLIENT_H_
19
20#include <map>
21#include <memory>
22#include <string>
23
24#include <base/guid.h>
Robert Gindacf92c662015-08-20 09:30:11 -070025#include <base/memory/ref_counted.h>
26#include <dbus/bus.h>
Alex Vakulenkoe32375b2015-09-28 08:55:40 -070027#include <weave/provider/dns_service_discovery.h>
Alex Vakulenkof0f55342015-08-18 15:51:40 -070028
29namespace buffet {
30
31// Stub MDNS implementation that does nothing on platform without MDNS support.
Alex Vakulenkoe32375b2015-09-28 08:55:40 -070032class MdnsClient : public weave::provider::DnsServiceDiscovery {
Alex Vakulenkof0f55342015-08-18 15:51:40 -070033 public:
34 MdnsClient() : device_id_{base::GenerateGUID()} {}
35 ~MdnsClient() override = default;
36
Alex Vakulenkoe32375b2015-09-28 08:55:40 -070037 // weave::provider::DnsServiceDiscovery implementation.
Alex Vakulenko35d119a2015-09-10 16:16:27 -070038 void PublishService(const std::string& service_type, uint16_t port,
39 const std::vector<std::string>& txt) override {}
Robert Gindacf92c662015-08-20 09:30:11 -070040 void StopPublishing(const std::string& service_type) override {}
Alex Vakulenkof0f55342015-08-18 15:51:40 -070041 std::string GetId() const override { return device_id_; }
42
Robert Gindacf92c662015-08-20 09:30:11 -070043 static std::unique_ptr<MdnsClient> CreateInstance(
Alex Vakulenko7714f332015-08-21 16:53:55 -070044 const scoped_refptr<dbus::Bus>& bus);
Alex Vakulenkof0f55342015-08-18 15:51:40 -070045
46 protected:
47 // Cached value of the device ID that we got from peerd.
48 std::string device_id_;
49
50 DISALLOW_COPY_AND_ASSIGN(MdnsClient);
51};
52
53} // namespace buffet
54
55#endif // BUFFET_MDNS_CLIENT_H_