Files
BPI-M2C/source_sync_rls_25c/source/unisoc/perflink/libudbus/BusTimeout.cpp
T
2026-09-22 09:38:26 +08:00

57 lines
1.8 KiB
C++

/*
* SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0
* Copyright 2016-2023 Unisoc (Shanghai) Technologies Co., Ltd
* Licensed under the Unisoc General Software License, version 1.0 (the License);
* you may not use this file except in compliance with the License. You may obtain a copy of the License at
* https://www.unisoc.com/en_us/license/UNISOC_GENERAL_LICENSE_V1.0-EN_US
* Software distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OF ANY KIND, either express or implied.
* See the Unisoc General Software License, version 1.0 for more details.
*/
#include "Debug.h"
#include <dbus/dbus.h>
#include "BusTimeout.h"
#include "BusDispatcher.h"
using namespace UDBus;
BusTimeout::BusTimeout(Timeout::Internal* internal, EventLoop* eventLoop)
: Timeout(internal), DefaultTimeout(0, true, eventLoop)
{
bool enable = dbus_timeout_get_enabled ((DBusTimeout *)mInternal);
int interval = dbus_timeout_get_interval((DBusTimeout *)mInternal);
DEBUG("BusTimeout:enable[%d],interval[%d]",enable,interval);
DefaultTimeout::SetEnabled(enable);
DefaultTimeout::SetInterval(interval);
DefaultTimeout::UpdateExpiration(interval);
dbus_timeout_set_data((DBusTimeout *)internal, this, nullptr);
}
int BusTimeout::GetBusInterval() const
{
return dbus_timeout_get_interval((DBusTimeout *)mInternal);
}
bool BusTimeout::GetBusEnabled() const
{
return dbus_timeout_get_enabled((DBusTimeout *)mInternal);
}
void BusTimeout::Toggle()
{
bool enable = this->GetEnabled();
DEBUG("timeout %p toggled (%s)", this, enable ? "on" : "off");
DefaultTimeout::SetEnabled(!enable);
}
bool BusTimeout::Handle()
{
DEBUG("timeout %p Handle (%p)", this, mInternal);
return dbus_timeout_handle((DBusTimeout *)mInternal);
}