* After enable you can call eldbus_proxy_property_local_get() or
* eldbus_proxy_property_local_get_all() to get cached properties.
*
- * @note After enable, it will asynchrony get the properties values.
+ * @param proxy bus+path+interface that the properties belong
+ * @param enable enable or disable properties monitor
+ * @return EINA_TRUE if already have cached properties
+ * EINA_FALSE if it will asynchrony get the properties.
+ * You should listen for a ELDBUS_PROXY_EVENT_PROPERTY_LOADED
+ * to know when properties finish to load.
*/
-EAPI void eldbus_proxy_properties_monitor(Eldbus_Proxy *proxy, Eina_Bool enable) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eldbus_proxy_properties_monitor(Eldbus_Proxy *proxy, Eina_Bool enable) EINA_ARG_NONNULL(1);
EAPI Eldbus_Pending *eldbus_proxy_property_get(Eldbus_Proxy *proxy, const char *name, Eldbus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3);
EAPI Eldbus_Pending *eldbus_proxy_property_set(Eldbus_Proxy *proxy, const char *name, const char *sig, const void *value, Eldbus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3, 4);
&event);
}
-EAPI void
+EAPI Eina_Bool
eldbus_proxy_properties_monitor(Eldbus_Proxy *proxy, Eina_Bool enable)
{
- ELDBUS_PROXY_CHECK(proxy);
+ ELDBUS_PROXY_CHECK_RETVAL(proxy, EINA_FALSE);
if (proxy->monitor_enabled == enable)
- return;
+ return proxy->props ? !!eina_hash_population(proxy->props) : EINA_FALSE;
proxy->monitor_enabled = enable;
- if (enable)
- {
- if (!proxy->props)
- proxy->props = eina_hash_string_superfast_new(_props_cache_free);
- eldbus_proxy_property_get_all(proxy, _props_get_all, proxy);
-
- if (proxy->properties_changed)
- return;
- proxy->properties_changed =
- eldbus_proxy_properties_changed_callback_add(proxy,
- _properties_changed,
- proxy);
- }
- else
+ if (!enable)
{
Eldbus_Proxy_Context_Event *ce_prop_changed, *ce_prop_removed;
ce_prop_changed = proxy->event_handlers + ELDBUS_PROXY_EVENT_PROPERTY_CHANGED;
eldbus_signal_handler_unref(proxy->properties_changed);
proxy->properties_changed = NULL;
}
+ return EINA_TRUE;
}
+
+ if (!proxy->props)
+ proxy->props = eina_hash_string_superfast_new(_props_cache_free);
+
+ eldbus_proxy_property_get_all(proxy, _props_get_all, proxy);
+
+ if (proxy->properties_changed)
+ return !!eina_hash_population(proxy->props);
+ proxy->properties_changed =
+ eldbus_proxy_properties_changed_callback_add(proxy,
+ _properties_changed,
+ proxy);
+ return !!eina_hash_population(proxy->props);
}
EAPI Eina_Value *