2018-08-29 20:36:39 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-17 14:19:04 +02:00
|
|
|
#include <dbus-status-notifier-watcher.h>
|
2019-01-08 21:05:44 +01:00
|
|
|
#include <giomm.h>
|
|
|
|
#include <glibmm/refptr.h>
|
2018-08-29 20:36:39 +02:00
|
|
|
|
|
|
|
namespace waybar::modules::SNI {
|
|
|
|
|
|
|
|
class Watcher {
|
2019-04-17 14:19:04 +02:00
|
|
|
public:
|
2018-10-04 18:47:06 +02:00
|
|
|
Watcher();
|
2019-04-17 14:19:04 +02:00
|
|
|
~Watcher();
|
2018-10-04 18:47:06 +02:00
|
|
|
|
2019-04-17 14:19:04 +02:00
|
|
|
private:
|
2018-10-04 18:47:06 +02:00
|
|
|
typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GfWatchType type;
|
2019-04-18 17:52:00 +02:00
|
|
|
Watcher * watcher;
|
|
|
|
gchar * service;
|
|
|
|
gchar * bus_name;
|
|
|
|
gchar * object_path;
|
|
|
|
guint watch_id;
|
2018-10-04 18:47:06 +02:00
|
|
|
} GfWatch;
|
|
|
|
|
2019-04-18 17:52:00 +02:00
|
|
|
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection> &, Glib::ustring);
|
2019-04-17 14:19:04 +02:00
|
|
|
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 *);
|
2019-04-18 17:52:00 +02:00
|
|
|
static void nameVanished(GDBusConnection *connection, const char *name, gpointer data);
|
|
|
|
static void gfWatchFree(gpointer data);
|
2018-10-04 18:47:06 +02:00
|
|
|
|
2018-10-26 10:05:54 +02:00
|
|
|
void updateRegisteredItems(SnWatcher *obj);
|
2018-10-04 18:47:06 +02:00
|
|
|
|
2019-04-18 17:52:00 +02:00
|
|
|
uint32_t bus_name_id_;
|
|
|
|
uint32_t watcher_id_;
|
|
|
|
GSList * hosts_ = nullptr;
|
|
|
|
GSList * items_ = nullptr;
|
2018-10-26 10:05:54 +02:00
|
|
|
SnWatcher *watcher_ = nullptr;
|
2019-04-18 17:52:00 +02:00
|
|
|
gulong handler_item_id_;
|
|
|
|
gulong handler_host_id_;
|
2018-08-29 20:36:39 +02:00
|
|
|
};
|
|
|
|
|
2019-04-17 14:19:04 +02:00
|
|
|
} // namespace waybar::modules::SNI
|