DBG("section: '%s', name: '%s', value: '%p'", section, name, value);
+ wkb_ibus_config_eet_set_value(_conf_eet, section, name, value);
+
return NULL;
}
_config_get_value(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
{
const char *section, *name;
+ Eldbus_Message *reply = NULL;
+ Eldbus_Message_Iter *iter;
_config_check_message_errors(msg);
DBG("section: '%s', name: '%s'", section, name);
- return NULL;
+ reply = eldbus_message_method_return_new(msg);
+ iter = eldbus_message_iter_get(reply);
+ wkb_ibus_config_eet_get_value(_conf_eet, section, name, iter);
+
+ return reply;
}
static Eldbus_Message *
_config_get_values(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
{
const char *section;
+ Eldbus_Message *reply = NULL;
+ Eldbus_Message_Iter *iter;
_config_check_message_errors(msg);
DBG("section: '%s'", section);
- return NULL;
+ reply = eldbus_message_method_return_new(msg);
+ iter = eldbus_message_iter_get(reply);
+ wkb_ibus_config_eet_get_values(_conf_eet, section, iter);
+
+ return reply;
}
static Eldbus_Message *
DBG("section: '%s', name: '%s'", section, name);
+ wkb_ibus_config_eet_set_value(_conf_eet, section, name, NULL);
+
return NULL;
}
goto end;
}
- _conf_eet = wkb_ibus_config_eet_new("");
+ _conf_eet = wkb_ibus_config_eet_new("/home/edebarro/projects/wayland/weekeyboard/ibus-cfg.eet");
+
+ if (!_conf_eet)
+ {
+ eldbus_service_interface_unregister(ret);
+ ret = NULL;
+ }
end:
return ret;
}
-static void
+void
wkb_ibus_config_unregister(void)
{
if (_conf_eet)
DBG("Message '%s' with signature '%s'", eldbus_message_member_get(_msg), eldbus_message_signature_get(_msg)); \
} while (0)
-struct _wkb_ibus_service
+struct _wkb_ibus_context
{
- Eldbus_Service_Interface *interface;
+ char *address;
+ Ecore_Exe *ibus_daemon;
+ Eldbus_Connection *conn;
+ Eldbus_Service_Interface *config;
+ Eldbus_Service_Interface *panel;
Eldbus_Signal_Handler *name_acquired;
Eldbus_Signal_Handler *name_lost;
-};
-struct _wkb_ibus_context
-{
- char *address;
- Eldbus_Connection *conn;
- Ecore_Exe *ibus_daemon;
-#if 0
- struct _wkb_ibus_service config;
-#else
- Eldbus_Proxy *config;
-#endif
- struct _wkb_ibus_service panel;
int refcount;
Eina_Bool address_pending;
};
static void
_wkb_config_value_changed_cb(void *data, const Eldbus_Message *msg)
{
- const char *section, name;
+ const char *section, *name;
Eldbus_Message_Iter *value;
_check_message_errors(msg);
_wkb_name_owner_changed_cb(void *data, const char *bus, const char *old_id, const char *new_id)
{
DBG("NameOwnerChanged Bus=%s | old=%s | new=%s", bus, old_id, new_id);
-
-#if 0
-#else
- if (strcmp(bus, IBUS_SERVICE_CONFIG) == 0)
- {
- if (*new_id)
- {
- Eldbus_Object *obj;
-
- if (ctx->config)
- return;
-
- ecore_main_loop_glib_integrate();
- obj = eldbus_object_get(ctx->conn, IBUS_SERVICE_CONFIG, IBUS_PATH_CONFIG);
- ctx->config = eldbus_proxy_get(obj, IBUS_INTERFACE_CONFIG);
- eldbus_proxy_signal_handler_add(ctx->config, "ValueChanged", _wkb_config_value_changed_cb, ctx);
-
- INF("Got config proxy");
- }
- else
- {
- if (!ctx->config)
- return;
-
- eldbus_proxy_unref(ctx->config);
- ctx->config = NULL;
- }
- }
-#endif
}
static void
{
const char *name;
- DBG("NameAcquired");
-
_check_message_errors(msg);
if (!eldbus_message_arguments_get(msg, "s", &name))
return;
}
- if (strcmp(name, IBUS_INTERFACE_PANEL) == 0)
+ DBG("NameAcquired: '%s'", name);
+
+ if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0)
{
- if (!ctx->panel.interface)
- {
- ctx->panel.interface = wkb_ibus_panel_register(ctx->conn);
- INF("Registering Panel Interface: %s", ctx->panel.interface ? "Success" : "Fail");
- }
- else
- {
- INF("Panel Interface already registered");
- }
+ ctx->panel = wkb_ibus_panel_register(ctx->conn);
+ INF("Registering Panel Interface: %s", ctx->panel ? "Success" : "Fail");
}
-#if 0
- else if (strcmp(name, IBUS_INTERFACE_CONFIG) == 0)
+ else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0)
{
- if (!ctx->config.interface)
- {
- ctx->config.interface = wkb_ibus_config_register(ctx->conn);
- INF("Registering Config Interface: %s", ctx->config.interface ? "Success" : "Fail");
- }
- else
- {
- INF("Config Interface already registered");
- }
+ ctx->config = wkb_ibus_config_register(ctx->conn);
+ INF("Registering Config Interface: %s", ctx->config ? "Success" : "Fail");
}
-#endif
else
{
WRN("Unexpected name %s", name);
if (!ctx->address)
{
- INF("IBus address is not set.", ctx->address_pending);
+ INF("IBus address is not set.");
if (!ctx->address_pending)
_wkb_ibus_query_address();
return EINA_FALSE;
}
- /* Panel */
+ ctx->name_acquired = eldbus_signal_handler_add(ctx->conn,
+ ELDBUS_FDO_BUS,
+ ELDBUS_FDO_PATH,
+ ELDBUS_FDO_INTERFACE,
+ "NameAcquired",
+ _wkb_name_acquired_cb,
+ ctx);
+
+ ctx->name_lost = eldbus_signal_handler_add(ctx->conn,
+ ELDBUS_FDO_BUS,
+ ELDBUS_FDO_PATH,
+ ELDBUS_FDO_INTERFACE,
+ "NameLost",
+ _wkb_name_lost_cb,
+ ctx);
+
+ /* Config */
eldbus_name_owner_changed_callback_add(ctx->conn,
- IBUS_SERVICE_PANEL,
+ IBUS_SERVICE_CONFIG,
_wkb_name_owner_changed_cb,
ctx, EINA_TRUE);
- ctx->panel.name_acquired = eldbus_signal_handler_add(ctx->conn,
- ELDBUS_FDO_BUS,
- ELDBUS_FDO_PATH,
- IBUS_INTERFACE_PANEL,
- "NameAcquired",
- _wkb_name_acquired_cb,
- ctx);
-
- ctx->panel.name_lost = eldbus_signal_handler_add(ctx->conn,
- ELDBUS_FDO_BUS,
- ELDBUS_FDO_PATH,
- IBUS_INTERFACE_PANEL,
- "NameLost",
- _wkb_name_lost_cb,
- ctx);
-
- eldbus_name_request(ctx->conn, IBUS_SERVICE_PANEL,
+ DBG("Requesting ownership of " IBUS_SERVICE_CONFIG);
+ eldbus_name_request(ctx->conn, IBUS_SERVICE_CONFIG,
ELDBUS_NAME_REQUEST_FLAG_REPLACE_EXISTING | ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE,
_wkb_name_request_cb, ctx);
- /* Config */
+ /* Panel */
eldbus_name_owner_changed_callback_add(ctx->conn,
- IBUS_SERVICE_CONFIG,
+ IBUS_SERVICE_PANEL,
_wkb_name_owner_changed_cb,
ctx, EINA_TRUE);
-#if 0
- ctx->config.name_acquired = eldbus_signal_handler_add(ctx->conn,
- ELDBUS_FDO_BUS,
- ELDBUS_FDO_PATH,
- IBUS_INTERFACE_CONFIG,
- "NameAcquired",
- _wkb_name_acquired_cb,
- ctx);
-
- ctx->config.name_lost = eldbus_signal_handler_add(ctx->conn,
- ELDBUS_FDO_BUS,
- ELDBUS_FDO_PATH,
- IBUS_INTERFACE_CONFIG,
- "NameLost",
- _wkb_name_lost_cb,
- ctx);
-
- eldbus_name_request(ctx->conn, IBUS_SERVICE_CONFIG,
+ DBG("Requesting ownership of " IBUS_SERVICE_PANEL);
+ eldbus_name_request(ctx->conn, IBUS_SERVICE_PANEL,
ELDBUS_NAME_REQUEST_FLAG_REPLACE_EXISTING | ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE,
_wkb_name_request_cb, ctx);
-#endif
+
return EINA_TRUE;
}
DBG("Disconnect");
- if (ctx->panel.interface)
+ eldbus_signal_handler_del(ctx->name_acquired);
+ eldbus_signal_handler_del(ctx->name_lost);
+
+ if (ctx->panel)
{
eldbus_name_release(ctx->conn, IBUS_SERVICE_PANEL, _wkb_name_release_cb, ctx);
- eldbus_signal_handler_del(ctx->panel.name_acquired);
- eldbus_signal_handler_del(ctx->panel.name_lost);
- eldbus_service_interface_unregister(ctx->panel.interface);
- ctx->panel.interface = NULL;
+ eldbus_service_interface_unregister(ctx->panel);
+ ctx->panel = NULL;
}
if (ctx->config)
- {
- eldbus_proxy_unref(ctx->config);
- ctx->config = NULL;
- }
-#if 0
- if (ctx->config.interface)
{
wkb_ibus_config_unregister();
eldbus_name_release(ctx->conn, IBUS_SERVICE_CONFIG, _wkb_name_release_cb, ctx);
- eldbus_signal_handler_del(ctx->config.name_acquired);
- eldbus_signal_handler_del(ctx->config.name_lost);
- eldbus_service_interface_unregister(ctx->config.interface);
- ctx->config.interface = NULL;
+ eldbus_service_interface_unregister(ctx->config);
+ ctx->config = NULL;
}
-#endif
eldbus_connection_unref(ctx->conn);
}