2018-11-22 14:47:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-17 12:19:04 +00:00
|
|
|
#include <dbus-status-notifier-watcher.h>
|
2019-01-08 20:05:44 +00:00
|
|
|
#include <giomm.h>
|
2019-04-17 12:19:04 +00:00
|
|
|
#include <glibmm/refptr.h>
|
2018-11-22 14:47:23 +00:00
|
|
|
#include <json/json.h>
|
2022-04-06 06:37:19 +00:00
|
|
|
|
2018-11-22 14:47:23 +00:00
|
|
|
#include <tuple>
|
2022-04-06 06:37:19 +00:00
|
|
|
|
2021-08-17 06:33:29 +00:00
|
|
|
#include "bar.hpp"
|
2018-11-22 14:47:23 +00:00
|
|
|
#include "modules/sni/item.hpp"
|
|
|
|
|
|
|
|
namespace waybar::modules::SNI {
|
|
|
|
|
|
|
|
class Host {
|
2019-04-17 12:19:04 +00:00
|
|
|
public:
|
2021-08-17 06:33:29 +00:00
|
|
|
Host(const std::size_t id, const Json::Value&, const Bar&,
|
|
|
|
const std::function<void(std::unique_ptr<Item>&)>&,
|
2019-04-17 12:19:04 +00:00
|
|
|
const std::function<void(std::unique_ptr<Item>&)>&);
|
|
|
|
~Host();
|
|
|
|
|
|
|
|
private:
|
2022-04-06 06:37:19 +00:00
|
|
|
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
|
|
|
|
void nameAppeared(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring,
|
|
|
|
const Glib::ustring&);
|
|
|
|
void nameVanished(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
|
2019-04-17 12:19:04 +00:00
|
|
|
static void proxyReady(GObject*, GAsyncResult*, gpointer);
|
|
|
|
static void registerHost(GObject*, GAsyncResult*, gpointer);
|
|
|
|
static void itemRegistered(SnWatcher*, const gchar*, gpointer);
|
|
|
|
static void itemUnregistered(SnWatcher*, const gchar*, gpointer);
|
2018-11-22 14:47:23 +00:00
|
|
|
|
2019-04-17 12:19:04 +00:00
|
|
|
std::tuple<std::string, std::string> getBusNameAndObjectPath(const std::string);
|
2022-04-06 06:37:19 +00:00
|
|
|
void addRegisteredItem(std::string service);
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Item>> items_;
|
|
|
|
const std::string bus_name_;
|
|
|
|
const std::string object_path_;
|
|
|
|
std::size_t bus_name_id_;
|
|
|
|
std::size_t watcher_id_;
|
|
|
|
GCancellable* cancellable_ = nullptr;
|
|
|
|
SnWatcher* watcher_ = nullptr;
|
|
|
|
const Json::Value& config_;
|
|
|
|
const Bar& bar_;
|
2019-04-17 12:19:04 +00:00
|
|
|
const std::function<void(std::unique_ptr<Item>&)> on_add_;
|
|
|
|
const std::function<void(std::unique_ptr<Item>&)> on_remove_;
|
2018-11-22 14:47:23 +00:00
|
|
|
};
|
|
|
|
|
2019-04-17 12:19:04 +00:00
|
|
|
} // namespace waybar::modules::SNI
|