make bluetooth service singleton
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "sigc++/signal.h"
|
||||
|
||||
class BluetoothService {
|
||||
static BluetoothService *instance;
|
||||
|
||||
public:
|
||||
BluetoothService();
|
||||
|
||||
sigc::signal<void(bool)> powerStateChangedSignal;
|
||||
|
||||
sigc::signal<void(bool)> isDiscoveringChangedSignal;
|
||||
|
||||
bool getPowerState();
|
||||
@@ -19,10 +22,22 @@ class BluetoothService {
|
||||
void togglePowerState();
|
||||
void toggleIsDiscovering();
|
||||
|
||||
private:
|
||||
static BluetoothService *getInstance() {
|
||||
if (BluetoothService::instance == nullptr) {
|
||||
|
||||
BluetoothService::instance = new BluetoothService();
|
||||
}
|
||||
return BluetoothService::instance;
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothService();
|
||||
|
||||
GDBusProxy *adapter_proxy = nullptr;
|
||||
bool powerState = false;
|
||||
bool isDiscovering = false;
|
||||
|
||||
std::vector<std::string> getDeviceObjectPaths();
|
||||
bool powerState = false;
|
||||
bool isDiscovering = false;
|
||||
|
||||
void onPropertyChanged(GDBusProxy *proxy,
|
||||
GVariant *changed_properties,
|
||||
|
||||
Reference in New Issue
Block a user