Merge "[AT-SPI] Add Bridge::{Enabled,Disabled}Signal()" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-impl.cpp
index f46f5ea..b5c275e 100644 (file)
@@ -208,6 +208,8 @@ public:
       }
       mData->mCurrentlyHighlightedActor = {};
       mData->mHighlightActor            = {};
+
+      mDisabledSignal.Emit();
     }
     mHighlightedActor     = {};
     mHighlightClearAction = {};
@@ -294,6 +296,9 @@ public:
       auto window    = Dali::DevelWindow::Get(rootLayer);
       EmitActivate(window); // Currently, sends a signal that the default window is activated here.
     }
+
+    mEnabledSignal.Emit();
+
     return ForceUpResult::JUST_STARTED;
   }
 
@@ -403,29 +408,30 @@ public:
     }
   }
 
-  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();
@@ -435,9 +441,32 @@ public:
         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();
@@ -449,6 +478,15 @@ public:
     });
   }
 
+  void ReadAndListenProperties()
+  {
+    ReadIsEnabledProperty();
+    ListenIsEnabledProperty();
+
+    ReadScreenReaderEnabledProperty();
+    ListenScreenReaderEnabledProperty();
+  }
+
   bool InitializeAccessibilityStatusClient()
   {
     mAccessibilityStatusClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION};
@@ -466,7 +504,7 @@ public:
   {
     if ( InitializeAccessibilityStatusClient() )
     {
-      ReadAndListenProperty();
+      ReadAndListenProperties();
       mIdleCallback = NULL;
       return false;
     }
@@ -481,7 +519,7 @@ public:
   {
     if ( InitializeAccessibilityStatusClient() )
     {
-      ReadAndListenProperty();
+      ReadAndListenProperties();
       return;
     }