DBusManager: style fixes

This commit is contained in:
iamanaws 2025-01-04 08:05:52 -08:00
parent 0817a59807
commit 00b02c005f
2 changed files with 17 additions and 17 deletions

View file

@ -16,14 +16,14 @@ DBusManager::~DBusManager() {
void DBusManager::initializeConnection() { void DBusManager::initializeConnection() {
try { try {
m_connection = sdbus::createSystemBusConnection(); m_pConnection = sdbus::createSystemBusConnection();
const sdbus::ServiceName destination{"org.freedesktop.login1"}; const sdbus::ServiceName destination{"org.freedesktop.login1"};
const sdbus::ObjectPath loginPath{"/org/freedesktop/login1"}; const sdbus::ObjectPath loginPath{"/org/freedesktop/login1"};
const sdbus::ObjectPath sessionPath{"/org/freedesktop/login1/session/auto"}; const sdbus::ObjectPath sessionPath{"/org/freedesktop/login1/session/auto"};
m_loginProxy = sdbus::createProxy(*m_connection, destination, loginPath); m_pLoginProxy = sdbus::createProxy(*m_pConnection, destination, loginPath);
m_sessionProxy = sdbus::createProxy(*m_connection, destination, sessionPath); m_pSessionProxy = sdbus::createProxy(*m_pConnection, destination, sessionPath);
Debug::log(LOG, "[DBusManager] Initialized D-Bus connection. Service: {}. Login path: {}, Session path: {}", Debug::log(LOG, "[DBusManager] Initialized D-Bus connection. Service: {}. Login path: {}, Session path: {}",
std::string(destination), std::string(loginPath), std::string(sessionPath)); std::string(destination), std::string(loginPath), std::string(sessionPath));
@ -34,35 +34,35 @@ void DBusManager::initializeConnection() {
std::shared_ptr<sdbus::IConnection> DBusManager::getConnection() { std::shared_ptr<sdbus::IConnection> DBusManager::getConnection() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
return m_connection; return m_pConnection;
} }
std::shared_ptr<sdbus::IProxy> DBusManager::getLoginProxy() { std::shared_ptr<sdbus::IProxy> DBusManager::getLoginProxy() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
if (!m_loginProxy) { if (!m_pLoginProxy)
initializeConnection(); initializeConnection();
}
return m_loginProxy; return m_pLoginProxy;
} }
std::shared_ptr<sdbus::IProxy> DBusManager::getSessionProxy() { std::shared_ptr<sdbus::IProxy> DBusManager::getSessionProxy() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
if (!m_sessionProxy) { if (!m_pSessionProxy)
initializeConnection(); initializeConnection();
}
return m_sessionProxy; return m_pSessionProxy;
} }
void DBusManager::setLockedHint(bool locked) { void DBusManager::setLockedHint(bool locked) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
if (!m_sessionProxy) { if (!m_pSessionProxy) {
Debug::log(WARN, "[DBusManager] Cannot set locked hint: Proxy is not initialized."); Debug::log(WARN, "[DBusManager] Cannot set locked hint: Proxy is not initialized.");
return; return;
} }
try { try {
const sdbus::ServiceName interface{"org.freedesktop.login1.Session"}; const sdbus::ServiceName interface{"org.freedesktop.login1.Session"};
m_sessionProxy->callMethod("SetLockedHint").onInterface(interface).withArguments(locked); m_pSessionProxy->callMethod("SetLockedHint").onInterface(interface).withArguments(locked);
Debug::log(LOG, "[DBusManager] Sent 'SetLockedHint({})' on {}", locked, std::string(interface)); Debug::log(LOG, "[DBusManager] Sent 'SetLockedHint({})' on {}", locked, std::string(interface));
} catch (const sdbus::Error& e) { } catch (const sdbus::Error& e) {
@ -72,14 +72,14 @@ void DBusManager::setLockedHint(bool locked) {
void DBusManager::sendUnlockSignal() { void DBusManager::sendUnlockSignal() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
if (!m_sessionProxy) { if (!m_pSessionProxy) {
Debug::log(WARN, "[DBusManager] Unlock signal skipped: Proxy is not initialized."); Debug::log(WARN, "[DBusManager] Unlock signal skipped: Proxy is not initialized.");
return; return;
} }
try { try {
const sdbus::ServiceName interface{"org.freedesktop.login1.Session"}; const sdbus::ServiceName interface{"org.freedesktop.login1.Session"};
m_sessionProxy->callMethod("Unlock").onInterface(interface); m_pSessionProxy->callMethod("Unlock").onInterface(interface);
Debug::log(LOG, "[DBusManager] Sent 'Unlock' on {}", std::string(interface)); Debug::log(LOG, "[DBusManager] Sent 'Unlock' on {}", std::string(interface));
} catch (const sdbus::Error& e) { } catch (const sdbus::Error& e) {

View file

@ -22,9 +22,9 @@ private:
void initializeConnection(); void initializeConnection();
std::shared_ptr<sdbus::IConnection> m_connection; std::shared_ptr<sdbus::IConnection> m_pConnection;
std::shared_ptr<sdbus::IProxy> m_loginProxy; std::shared_ptr<sdbus::IProxy> m_pLoginProxy;
std::shared_ptr<sdbus::IProxy> m_sessionProxy; std::shared_ptr<sdbus::IProxy> m_pSessionProxy;
std::mutex m_mutex; std::mutex m_mutex;
}; };