Waybar/include/modules/sni/watcher.hpp

48 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include <gtkmm.h>
#include <dbus-status-notifier-watcher.h>
namespace waybar::modules::SNI {
class Watcher {
public:
Watcher();
2018-11-23 09:46:58 +00:00
~Watcher() = default;
private:
typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType;
typedef struct {
GfWatchType type;
Watcher *watcher;
gchar *service;
gchar *bus_name;
gchar *object_path;
guint watch_id;
} GfWatch;
2018-11-23 09:46:58 +00:00
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
static gboolean handleRegisterHost(Watcher *, GDBusMethodInvocation *,
const gchar *);
static gboolean handleRegisterItem(Watcher *, GDBusMethodInvocation *,
const gchar *);
static GfWatch *gfWatchFind(GSList *list, const gchar *bus_name,
const gchar *object_path);
static GfWatch *gfWatchNew(GfWatchType, const gchar *, const gchar *,
const gchar *, Watcher *);
static void nameVanished(GDBusConnection *connection, const char *name,
gpointer data);
2018-10-26 08:05:54 +00:00
void updateRegisteredItems(SnWatcher *obj);
uint32_t bus_name_id_;
uint32_t watcher_id_;
GSList *hosts_ = nullptr;
GSList *items_ = nullptr;
2018-10-26 08:05:54 +00:00
SnWatcher *watcher_ = nullptr;
};
} // namespace waybar::modules::SNI