return DBUS_W->eldbus_connection_get_impl(connectionType);
}
+static void PropertyChangedCb(void* data,
+ Eldbus_Proxy* proxy EINA_UNUSED,
+ void* event)
+{
+ DBus::DBusClient2* obj = static_cast<DBus::DBusClient2*>(data);
+ if (!obj) {
+ DALI_LOG_ERROR("obj is null\n");
+ return;
+ }
+
+ Eldbus_Proxy_Event_Property_Changed* ev =
+ static_cast<Eldbus_Proxy_Event_Property_Changed*>(event);
+ Eina_Bool val;
+ const char* ifc = eldbus_proxy_interface_get(ev->proxy);
+
+ if (ev->name &&
+ !strncmp(ev->name, "ScreenReaderEnabled",
+ strlen("ScreenReaderEnabled")) &&
+ ifc &&
+ !strncmp("org.a11y.Status", ifc,
+ strlen("org.a11y.Status"))) {
+ if (!eina_value_get(ev->value, &val)) {
+ DALI_LOG_ERROR("Unable to get ScreenReaderEnabled property\n");
+ return;
+ }
+
+ DALI_LOG_ERROR("property is: %d\n", val);
+ }
+}
+
+static void ScreenReaderEnabledGet(void* data,
+ const Eldbus_Message* msg,
+ Eldbus_Pending* pending)
+{
+ DBus::DBusClient2* obj = static_cast<DBus::DBusClient2*>(data);
+ if (!obj) {
+ DALI_LOG_ERROR("obj is null\n");
+ return;
+ }
+
+ const char* errname;
+ const char* errmsg;
+ Eina_Bool is_enabled;
+ Eldbus_Message_Iter* variant;
+
+ if (eldbus_message_error_get(msg, &errname, &errmsg)) {
+ DALI_LOG_ERROR("message error - name(%s) msg(%s)\n", errname, errmsg);
+ return;
+ }
+
+ if (!eldbus_message_arguments_get(msg, "v", &variant)) {
+ DALI_LOG_ERROR("ScreenReaderEnabled not packed into variant\n");
+ return;
+ }
+
+ if (!eldbus_message_iter_arguments_get(variant, "b", &is_enabled)) {
+ DALI_LOG_ERROR("could not get ScreenReaderEnabled bool property\n");
+ return;
+ }
+
+ DALI_LOG_ERROR("is enabled: %d\n", is_enabled);
+
+}
+
+DBus::DBusClient2::DBusClient2(std::string busName, std::string pathName, std::string interfaceName, ConnectionType tp)
+{
+ Eldbus_Connection_Type eldbusType = ELDBUS_CONNECTION_TYPE_SYSTEM;
+
+ switch( tp )
+ {
+ case ConnectionType::SYSTEM:
+ {
+ eldbusType = ELDBUS_CONNECTION_TYPE_SYSTEM;
+ break;
+ }
+ case ConnectionType::SESSION:
+ {
+ eldbusType = ELDBUS_CONNECTION_TYPE_SESSION;
+ break;
+ }
+ }
+
+ Eldbus_Connection *bus_con = nullptr;
+ if( !(bus_con = eldbus_connection_get(eldbusType)) )
+ {
+ DALI_LOG_ERROR("unable connect session bus\n");
+ }
+
+ Eldbus_Object *bus_obj = nullptr;
+ if( !(bus_obj = eldbus_object_get(bus_con, busName.c_str(), pathName.c_str())) )
+ {
+ eldbus_connection_unref(bus_con);
+ DALI_LOG_ERROR("unable to get object\n");
+ }
+
+ Eldbus_Proxy *bus_proxy = nullptr;
+ if( !(bus_proxy = eldbus_proxy_get(bus_obj, interfaceName.c_str())) )
+ {
+ DALI_LOG_ERROR("unable to get proxy\n");
+ eldbus_object_unref(bus_obj);
+ eldbus_connection_unref(bus_con);
+ return;
+ }
+
+ Eldbus_Pending *req = nullptr;
+ if (!(req = eldbus_proxy_property_get(bus_proxy, "ScreenReaderEnabled",
+ ScreenReaderEnabledGet, this))) {
+ DALI_LOG_ERROR("could not set PropertyGet reqeust\n");
+ eldbus_object_unref(bus_obj);
+ eldbus_connection_unref(bus_con);
+ return;
+ }
+
+ eldbus_proxy_properties_monitor(bus_proxy, EINA_TRUE);
+ eldbus_proxy_event_callback_add(bus_proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
+ PropertyChangedCb, this);
+
+}
+
DBus::DBusClient::DBusClient(std::string busName, std::string pathName, std::string interfaceName, ConnectionType tp)
: DBusClient(std::move(busName), std::move(pathName), std::move(interfaceName), getDBusConnectionByType(tp))
{