}
}
- void ReadAndListenProperty()
+ void ReadIsEnabledProperty()
{
- // read property
- auto enabled = mAccessibilityStatusClient.property<bool>("ScreenReaderEnabled").get();
- if(enabled)
- {
- mIsScreenReaderEnabled = std::get<0>(enabled);
- }
-
- enabled = mAccessibilityStatusClient.property<bool>("IsEnabled").get();
- if(enabled)
- {
- mIsEnabled = std::get<0>(enabled);
- }
-
- if(mIsScreenReaderEnabled || mIsEnabled)
- {
- ForceUp();
- }
+ mAccessibilityStatusClient.property<bool>("IsEnabled").asyncGet([this](DBus::ValueOrError<bool> msg) {
+ if(!msg)
+ {
+ DALI_LOG_ERROR("Get IsEnabled property error: %s\n", msg.getError().message.c_str());
+ if(msg.getError().errorType == DBus::ErrorType::INVALID_REPLY)
+ {
+ ReadIsEnabledProperty();
+ }
+ return;
+ }
+ mIsEnabled = std::get<0>(msg);
+ if(mIsEnabled)
+ {
+ ForceUp();
+ }
+ });
+ }
- // listen property change
- mAccessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
- mIsScreenReaderEnabled = res;
+ void ListenIsEnabledProperty()
+ {
+ mAccessibilityStatusClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) {
+ mIsEnabled = res;
if(mIsScreenReaderEnabled || mIsEnabled)
{
ForceUp();
ForceDown();
}
});
+ }
- mAccessibilityStatusClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) {
- mIsEnabled = res;
+ void ReadScreenReaderEnabledProperty()
+ {
+ mAccessibilityStatusClient.property<bool>("ScreenReaderEnabled").asyncGet([this](DBus::ValueOrError<bool> msg) {
+ if(!msg)
+ {
+ DALI_LOG_ERROR("Get ScreenReaderEnabled property error: %s\n", msg.getError().message.c_str());
+ if(msg.getError().errorType == DBus::ErrorType::INVALID_REPLY)
+ {
+ ReadScreenReaderEnabledProperty();
+ }
+ return;
+ }
+ mIsScreenReaderEnabled = std::get<0>(msg);
+ if(mIsScreenReaderEnabled)
+ {
+ ForceUp();
+ }
+ });
+ }
+
+ void ListenScreenReaderEnabledProperty()
+ {
+ mAccessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
+ mIsScreenReaderEnabled = res;
if(mIsScreenReaderEnabled || mIsEnabled)
{
ForceUp();
});
}
+ void ReadAndListenProperties()
+ {
+ ReadIsEnabledProperty();
+ ListenIsEnabledProperty();
+
+ ReadScreenReaderEnabledProperty();
+ ListenScreenReaderEnabledProperty();
+ }
+
bool InitializeAccessibilityStatusClient()
{
mAccessibilityStatusClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION};
{
if ( InitializeAccessibilityStatusClient() )
{
- ReadAndListenProperty();
+ ReadAndListenProperties();
mIdleCallback = NULL;
return false;
}
{
if ( InitializeAccessibilityStatusClient() )
{
- ReadAndListenProperty();
+ ReadAndListenProperties();
return;
}
*/
void setDebugPrinter(std::function<void(const char*, size_t)>);
+/**
+ * @brief Enumeration indicatng DBus error type
+ */
+enum class ErrorType
+{
+ DEFAULT, ///< default
+ INVALID_REPLY ///< reply message has error
+};
+
struct Error
{
std::string message;
+ ErrorType errorType;
Error() = default;
- Error(std::string msg)
- : message(std::move(msg))
+ Error(std::string msg, ErrorType errorType = ErrorType::DEFAULT)
+ : message(std::move(msg)),
+ errorType(errorType)
{
assert(!message.empty());
}
if(DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg))
{
DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str());
- callback(Error{errname + ": " + errmsg});
+ callback(Error{errname + ": " + errmsg, ErrorType::INVALID_REPLY});
}
else
{