51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <gio/gio.h>
|
|
#include <gtk/gtk.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "sigc++/signal.h"
|
|
|
|
class BluetoothService {
|
|
static BluetoothService *instance;
|
|
|
|
public:
|
|
sigc::signal<void(bool)> powerStateChangedSignal;
|
|
|
|
sigc::signal<void(bool)> isDiscoveringChangedSignal;
|
|
|
|
bool getPowerState();
|
|
|
|
bool getIsDiscovering();
|
|
|
|
void togglePowerState();
|
|
void toggleIsDiscovering();
|
|
|
|
static BluetoothService *getInstance() {
|
|
if (BluetoothService::instance == nullptr) {
|
|
|
|
BluetoothService::instance = new BluetoothService();
|
|
}
|
|
return BluetoothService::instance;
|
|
}
|
|
|
|
private:
|
|
BluetoothService();
|
|
|
|
GDBusProxy *adapter_proxy = nullptr;
|
|
|
|
std::vector<std::string> getDeviceObjectPaths();
|
|
bool powerState = false;
|
|
bool isDiscovering = false;
|
|
|
|
void onPropertyChanged(GDBusProxy *proxy,
|
|
GVariant *changed_properties,
|
|
const gchar *const *invalidated_properties,
|
|
gpointer user_data);
|
|
|
|
static void onPropertyChangedStatic(GDBusProxy *proxy,
|
|
GVariant *changed_properties,
|
|
const gchar *const *invalidated_properties,
|
|
gpointer user_data);
|
|
}; |