summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Lima (Etrunko) <eduardo.lima@intel.com>2013-10-10 16:56:07 -0300
committerEduardo Lima (Etrunko) <eduardo.lima@intel.com>2013-10-10 16:58:58 -0300
commit9a3cae9cb8eb290a077eee61dd5f985838729d33 (patch)
tree169c19212af73ca4a2fb8d0a88d391c104174744
parentabb645fc09405557eadb28d09912dc96510095a1 (diff)
downloadweekeyboard-9a3cae9cb8eb290a077eee61dd5f985838729d33.tar.gz
weekeyboard-9a3cae9cb8eb290a077eee61dd5f985838729d33.tar.bz2
weekeyboard-9a3cae9cb8eb290a077eee61dd5f985838729d33.zip
New dedicated file for various IBus helper functions
Change-Id: I229d63553c2e8917af196946f5d4864ff78881dc Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
-rw-r--r--src/Makefile.am2
-rw-r--r--src/wkb-ibus-helper.c380
-rw-r--r--src/wkb-ibus-helper.h84
-rw-r--r--src/wkb-ibus-panel.c411
4 files changed, 482 insertions, 395 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7fa860a..ee0b7cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,6 +41,8 @@ noinst_PROGRAMS += \
weekeyboard_ibus_test_SOURCES = \
wkb-ibus.h \
wkb-ibus.c \
+ wkb-ibus-helper.h \
+ wkb-ibus-helper.c \
wkb-log.c \
wkb-log.h \
wkb-ibus-defs.h \
diff --git a/src/wkb-ibus-helper.c b/src/wkb-ibus-helper.c
new file mode 100644
index 0000000..da1e54a
--- /dev/null
+++ b/src/wkb-ibus-helper.c
@@ -0,0 +1,380 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wkb-ibus-helper.h"
+#include "wkb-log.h"
+
+struct wkb_ibus_serializable
+{
+ /*
+ * All messages sent by IBus will start with the sa{sv} signature, but
+ * those fields don't seem useful for us, this struct is used to help
+ * on deserializing those fields
+ */
+ char *text;
+ Eldbus_Message_Iter *variant;
+};
+
+typedef void (*_free_func) (void*);
+
+static void
+_free_eina_array(Eina_Array *array, _free_func free_cb)
+{
+ if (!array)
+ return;
+
+ while (eina_array_count(array))
+ free_cb(eina_array_pop(array));
+
+ eina_array_free(array);
+}
+
+struct wkb_ibus_attr *
+wkb_ibus_attr_from_message_iter(Eldbus_Message_Iter *iter)
+{
+ struct wkb_ibus_attr *attr = calloc(1, sizeof(*attr));
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(attr, NULL);
+
+ DBG("Attribute iter signature '%s'", eldbus_message_iter_signature_get(iter));
+
+ if (!eldbus_message_iter_arguments_get(iter, "uuuu", &attr->type,
+ &attr->value, &attr->start_idx,
+ &attr->end_idx))
+ {
+ ERR("Error deserializing IBusAttribute");
+ wkb_ibus_attr_free(attr);
+ attr = NULL;
+ }
+
+ return attr;
+}
+
+void
+wkb_ibus_attr_free(struct wkb_ibus_attr *attr)
+{
+ free(attr);
+}
+
+void
+wkb_ibus_text_free(struct wkb_ibus_text *text)
+{
+ if (!text)
+ return;
+
+ _free_eina_array(text->attrs, (_free_func) free);
+ free(text->text);
+ free(text);
+}
+
+struct wkb_ibus_text *
+wkb_ibus_text_from_message_iter(Eldbus_Message_Iter *iter)
+{
+ struct wkb_ibus_serializable ignore = { 0 };
+ struct wkb_ibus_text *text = calloc(1, sizeof(*text));
+ struct wkb_ibus_attr *attr = NULL;
+ Eldbus_Message_Iter *attrs = NULL, *a = NULL;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(text, NULL);
+
+ DBG("Text iter signature '%s'", eldbus_message_iter_signature_get(iter));
+
+ if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}sv)", &ignore.text,
+ &ignore.variant, &text->text, &attrs))
+ {
+ ERR("Error deserializing IBusText");
+ free(text);
+ text = NULL;
+ goto end;
+ }
+
+ /* Check for attributes */
+ if (attrs == NULL)
+ {
+ INF("Text has no attributes");
+ goto end;
+ }
+
+ while (eldbus_message_iter_get_and_next(attrs, 'v', &a))
+ {
+ if (!text->attrs)
+ text->attrs = eina_array_new(10);
+
+ if (!(attr = wkb_ibus_attr_from_message_iter(a)))
+ {
+ wkb_ibus_text_free(text);
+ text = NULL;
+ goto end;
+ }
+
+ eina_array_push(text->attrs, attr);
+ }
+
+end:
+ return text;
+}
+
+void
+wkb_ibus_lookup_table_free(struct wkb_ibus_lookup_table *table)
+{
+ if (!table)
+ return;
+
+ _free_eina_array(table->candidates, (_free_func) wkb_ibus_text_free);
+ _free_eina_array(table->labels, (_free_func) wkb_ibus_text_free);
+ free(table);
+}
+
+struct wkb_ibus_lookup_table *
+wkb_ibus_lookup_table_from_message_iter(Eldbus_Message_Iter *iter)
+{
+ struct wkb_ibus_serializable ignore = { 0 };
+ struct wkb_ibus_lookup_table *table = calloc(1, sizeof(*table));
+ struct wkb_ibus_text *text = NULL;
+ Eldbus_Message_Iter *candidates = NULL, *labels = NULL, *t = NULL;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(table, NULL);
+
+ DBG("LookupTable iter signature '%s'", eldbus_message_iter_signature_get(iter));
+
+ if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}uubbiavav)",
+ &ignore.text, &ignore.variant,
+ &table->page_size, &table->cursor_pos,
+ &table->cursor_visible, &table->round,
+ &table->orientation, &candidates,
+ &labels))
+ {
+ ERR("Error deserializing IBusLookupTable");
+ free(table);
+ table = NULL;
+ goto end;
+ }
+
+ DBG("Lookup table:");
+ DBG("\tPage size.......: '%d'", table->page_size);
+ DBG("\tCursor position.: '%d'", table->cursor_pos);
+ DBG("\tCursor visible..: '%d'", table->cursor_visible);
+ DBG("\tRound...........: '%d'", table->round);
+ DBG("\tOrientation.....: '%d'", table->orientation);
+ DBG("\tCandidates......: '%p'", candidates);
+ DBG("\tLabels..........: '%p'", labels);
+
+ if (!candidates)
+ {
+ INF("Lookup table has no candidates");
+ goto labels;
+ }
+
+ while (eldbus_message_iter_get_and_next(candidates, 'v', &t))
+ {
+ if (!table->candidates)
+ table->candidates = eina_array_new(10);
+
+ if (!(text = wkb_ibus_text_from_message_iter(t)))
+ {
+ wkb_ibus_lookup_table_free(table);
+ table = NULL;
+ goto end;
+ }
+
+ DBG("Appending new candidate %s", text->text);
+ eina_array_push(table->candidates, text);
+ }
+
+labels:
+ if (!labels)
+ {
+ INF("Lookup table has no labels");
+ goto end;
+ }
+
+ while (eldbus_message_iter_get_and_next(labels, 'v', &t))
+ {
+ if (!table->labels)
+ table->labels = eina_array_new(10);
+
+ if (!(text = wkb_ibus_text_from_message_iter(t)))
+ {
+ wkb_ibus_lookup_table_free(table);
+ table = NULL;
+ goto end;
+ }
+
+ DBG("Appending new label %s", text->text);
+ eina_array_push(table->labels, text);
+ }
+
+end:
+ return table;
+}
+
+void
+wkb_ibus_property_free(struct wkb_ibus_property *property)
+{
+ if (!property)
+ return;
+
+ free(property->key);
+ free(property->icon);
+ wkb_ibus_text_free(property->label);
+ wkb_ibus_text_free(property->symbol);
+ wkb_ibus_text_free(property->tooltip);
+ _free_eina_array(property->sub_properties, (_free_func) wkb_ibus_property_free);
+ free(property);
+}
+
+struct wkb_ibus_property *
+wkb_ibus_property_from_message_iter(Eldbus_Message_Iter *iter)
+{
+ struct wkb_ibus_serializable ignore = { 0 };
+ struct wkb_ibus_property *prop = calloc(1, sizeof(*prop));
+ Eldbus_Message_Iter *label = NULL, *symbol = NULL, *tooltip = NULL, *sub_props = NULL;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(prop, NULL);
+
+ DBG("Property iter signature '%s'", eldbus_message_iter_signature_get(iter));
+
+ if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}suvsvbbuvv)",
+ &ignore.text, &ignore.variant,
+ &prop->key, &prop->type,
+ &label, &prop->icon, &tooltip,
+ &prop->sensitive, &prop->visible,
+ &prop->state, &sub_props, &symbol))
+ {
+ ERR("Error deserializing IBusProperty");
+ free(prop);
+ prop = NULL;
+ goto end;
+ }
+
+ DBG("Property :");
+ DBG("\tKey.............: '%s'", prop->key);
+ DBG("\tType............: '%d'", prop->type);
+ DBG("\tLabel...........: '%p'", label);
+ DBG("\tIcon............: '%s'", prop->icon);
+ DBG("\tTooltip.........: '%p'", tooltip);
+ DBG("\tSensitive.......: '%d'", prop->sensitive);
+ DBG("\tVisible.........: '%d'", prop->visible);
+ DBG("\tState...........: '%d'", prop->state);
+ DBG("\tSub Properties..: '%p'", sub_props);
+ DBG("\tSymbol..........: '%p'", symbol);
+
+ if (!label)
+ {
+ INF("Property has no label");
+ goto symbol;
+ }
+
+ if (!(prop->label = wkb_ibus_text_from_message_iter(label)))
+ {
+ wkb_ibus_property_free(prop);
+ prop = NULL;
+ goto end;
+ }
+
+symbol:
+ if (!symbol)
+ {
+ INF("Property has no symbol");
+ goto tooltip;
+ }
+
+ if (!(prop->symbol = wkb_ibus_text_from_message_iter(symbol)))
+ {
+ wkb_ibus_property_free(prop);
+ prop = NULL;
+ goto end;
+ }
+
+tooltip:
+ if (!tooltip)
+ {
+ INF("Property has no tooltip");
+ goto sub_props;
+ }
+
+ if (!(prop->tooltip = wkb_ibus_text_from_message_iter(tooltip)))
+ {
+ wkb_ibus_property_free(prop);
+ prop = NULL;
+ goto end;
+ }
+
+sub_props:
+ if (!sub_props)
+ {
+ INF("Property has no sub properties");
+ goto end;
+ }
+
+ prop->sub_properties = wkb_ibus_properties_from_message_iter(sub_props);
+
+end:
+ return prop;
+}
+
+void
+wkb_ibus_properties_free(Eina_Array *properties)
+{
+ _free_eina_array(properties, (_free_func) wkb_ibus_property_free);
+}
+
+Eina_Array *
+wkb_ibus_properties_from_message_iter(Eldbus_Message_Iter *iter)
+{
+ Eina_Array *properties = NULL;
+ Eldbus_Message_Iter *props = NULL, *prop = NULL;
+ struct wkb_ibus_serializable ignore = { 0 };
+ struct wkb_ibus_property *property = NULL;
+
+ DBG("PropList iter signature '%s'", eldbus_message_iter_signature_get(iter));
+
+ if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}av)", &ignore.text, &ignore.variant, &props))
+ {
+ ERR("Error deserializing IBusPropList");
+ goto end;
+ }
+
+ if (!props)
+ {
+ INF("PropList has no property");
+ goto end;
+ }
+
+ while (eldbus_message_iter_get_and_next(props, 'v', &prop))
+ {
+ if (!properties)
+ properties = eina_array_new(10);
+
+ if (!(property = wkb_ibus_property_from_message_iter(prop)))
+ {
+ wkb_ibus_properties_free(properties);
+ properties = NULL;
+ goto end;
+ }
+
+ DBG("Appending new property %p", property);
+ eina_array_push(properties, property);
+ }
+
+end:
+ return properties;
+}
+
diff --git a/src/wkb-ibus-helper.h b/src/wkb-ibus-helper.h
new file mode 100644
index 0000000..98498fe
--- /dev/null
+++ b/src/wkb-ibus-helper.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _WKB_IBUS_HELPER_H_
+#define _WKB_IBUS_HELPER_H_
+
+#include <Eina.h>
+#include <Eldbus.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct wkb_ibus_attr
+{
+ unsigned int type;
+ unsigned int value;
+ unsigned int start_idx;
+ unsigned int end_idx;
+};
+
+struct wkb_ibus_text
+{
+ char *text;
+ Eina_Array *attrs;
+};
+
+struct wkb_ibus_lookup_table
+{
+ unsigned int page_size;
+ unsigned int cursor_pos;
+ Eina_Bool cursor_visible;
+ Eina_Bool round;
+ int orientation;
+ Eina_Array *candidates;
+ Eina_Array *labels;
+};
+
+struct wkb_ibus_property
+{
+ char *key;
+ char *icon;
+ struct wkb_ibus_text *label;
+ struct wkb_ibus_text *symbol;
+ struct wkb_ibus_text *tooltip;
+ Eina_Bool sensitive;
+ Eina_Bool visible;
+ unsigned int type;
+ unsigned int state;
+ Eina_Array *sub_properties;
+};
+
+struct wkb_ibus_attr *wkb_ibus_attr_from_message_iter(Eldbus_Message_Iter *iter);
+void wkb_ibus_attr_free(struct wkb_ibus_attr *attr);
+
+struct wkb_ibus_text *wkb_ibus_text_from_message_iter(Eldbus_Message_Iter *iter);
+void wkb_ibus_text_free(struct wkb_ibus_text *text);
+
+struct wkb_ibus_lookup_table *wkb_ibus_lookup_table_from_message_iter(Eldbus_Message_Iter *iter);
+void wkb_ibus_lookup_table_free(struct wkb_ibus_lookup_table *table);
+
+struct wkb_ibus_property *wkb_ibus_property_from_message_iter(Eldbus_Message_Iter *iter);
+void wkb_ibus_property_free(struct wkb_ibus_property *property);
+
+Eina_Array *wkb_ibus_properties_from_message_iter(Eldbus_Message_Iter *iter);
+void wkb_ibus_properties_free(Eina_Array *properties);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WKB_IBUS_HELPER_H_ */
diff --git a/src/wkb-ibus-panel.c b/src/wkb-ibus-panel.c
index abe5823..d4398e2 100644
--- a/src/wkb-ibus-panel.c
+++ b/src/wkb-ibus-panel.c
@@ -23,6 +23,7 @@
#include "wkb-ibus.h"
#include "wkb-ibus-defs.h"
+#include "wkb-ibus-helper.h"
#include "wkb-log.h"
#define _panel_check_message_errors(_msg) \
@@ -37,397 +38,13 @@
DBG("Message '%s' with signature '%s'", eldbus_message_member_get(_msg), eldbus_message_signature_get(_msg)); \
} while (0)
-static Eina_Array *_get_properties_from_message_iter(Eldbus_Message_Iter *iter);
-
-struct _ibus_serializable
-{
- /*
- * All messages sent by IBus will start with the sa{sv} signature, but
- * those fields don't seem useful for us, this struct is used to help
- * on deserializing those fields
- */
- char *text;
- Eldbus_Message_Iter *variant;
-};
-
-struct _ibus_attr
-{
- unsigned int type;
- unsigned int value;
- unsigned int start_idx;
- unsigned int end_idx;
-};
-
-struct _ibus_text
-{
- char *text;
- Eina_Array *attrs;
-};
-
-struct _ibus_lookup_table
-{
- unsigned int page_size;
- unsigned int cursor_pos;
- Eina_Bool cursor_visible;
- Eina_Bool round;
- int orientation;
- Eina_Array *candidates;
- Eina_Array *labels;
-};
-
-struct _ibus_property
-{
- char *key;
- char *icon;
- struct _ibus_text *label;
- struct _ibus_text *symbol;
- struct _ibus_text *tooltip;
- Eina_Bool sensitive;
- Eina_Bool visible;
- unsigned int type;
- unsigned int state;
- Eina_Array *sub_properties;
-};
-
-static struct _ibus_attr *
-_get_attr_from_message_iter(Eldbus_Message_Iter *iter)
-{
- struct _ibus_attr *attr = calloc(1, sizeof(*attr));
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(attr, NULL);
-
- DBG("Attribute iter signature '%s'", eldbus_message_iter_signature_get(iter));
-
- if (!eldbus_message_iter_arguments_get(iter, "uuuu", &attr->type,
- &attr->value, &attr->start_idx,
- &attr->end_idx))
- {
- ERR("Error deserializing IBusAttribute");
- free(attr);
- attr = NULL;
- }
-
- return attr;
-}
-
-static void
-_free_eina_array(Eina_Array *array, void (* free_func)(void *))
-{
- if (!array)
- return;
-
- while (eina_array_count(array))
- free_func(eina_array_pop(array));
-
- eina_array_free(array);
-}
-
-static void
-_free_text(struct _ibus_text *text)
-{
- if (!text)
- return;
-
- _free_eina_array(text->attrs, free);
- free(text->text);
- free(text);
-}
-
-static struct _ibus_text *
-_get_text_from_message_iter(Eldbus_Message_Iter *iter)
-{
- struct _ibus_serializable ignore = { 0 };
- struct _ibus_text *text = calloc(1, sizeof(*text));
- struct _ibus_attr *attr = NULL;
- Eldbus_Message_Iter *attrs = NULL, *a = NULL;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(text, NULL);
-
- DBG("Text iter signature '%s'", eldbus_message_iter_signature_get(iter));
-
- if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}sv)", &ignore.text,
- &ignore.variant, &text->text, &attrs))
- {
- ERR("Error deserializing IBusText");
- free(text);
- text = NULL;
- goto end;
- }
-
- /* Check for attributes */
- if (attrs == NULL)
- {
- INF("Text has no attributes");
- goto end;
- }
-
- while (eldbus_message_iter_get_and_next(attrs, 'v', &a))
- {
- if (!text->attrs)
- text->attrs = eina_array_new(10);
-
- if (!(attr = _get_attr_from_message_iter(a)))
- {
- _free_text(text);
- text = NULL;
- goto end;
- }
-
- eina_array_push(text->attrs, attr);
- }
-
-end:
- return text;
-}
-
-static void
-_free_lookup_table(struct _ibus_lookup_table *table)
-{
- if (!table)
- return;
-
- _free_eina_array(table->candidates, _free_text);
- _free_eina_array(table->labels, _free_text);
- free(table);
-}
-
-static struct _ibus_lookup_table *
-_get_lookup_table_from_message_iter(Eldbus_Message_Iter *iter)
-{
- struct _ibus_serializable ignore = { 0 };
- struct _ibus_lookup_table *table = calloc(1, sizeof(*table));
- struct _ibus_text *text = NULL;
- Eldbus_Message_Iter *candidates = NULL, *labels = NULL, *t = NULL;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(table, NULL);
-
- DBG("LookupTable iter signature '%s'", eldbus_message_iter_signature_get(iter));
-
- if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}uubbiavav)",
- &ignore.text, &ignore.variant,
- &table->page_size, &table->cursor_pos,
- &table->cursor_visible, &table->round,
- &table->orientation, &candidates,
- &labels))
- {
- ERR("Error deserializing IBusLookupTable");
- free(table);
- table = NULL;
- goto end;
- }
-
- DBG("Lookup table:");
- DBG("\tPage size.......: '%d'", table->page_size);
- DBG("\tCursor position.: '%d'", table->cursor_pos);
- DBG("\tCursor visible..: '%d'", table->cursor_visible);
- DBG("\tRound...........: '%d'", table->round);
- DBG("\tOrientation.....: '%d'", table->orientation);
- DBG("\tCandidates......: '%p'", candidates);
- DBG("\tLabels..........: '%p'", labels);
-
- if (!candidates)
- {
- INF("Lookup table has no candidates");
- goto labels;
- }
-
- while (eldbus_message_iter_get_and_next(candidates, 'v', &t))
- {
- if (!table->candidates)
- table->candidates = eina_array_new(10);
-
- if (!(text = _get_text_from_message_iter(t)))
- {
- _free_lookup_table(table);
- table = NULL;
- goto end;
- }
-
- DBG("Appending new candidate %s", text->text);
- eina_array_push(table->candidates, text);
- }
-
-labels:
- if (!labels)
- {
- INF("Lookup table has no labels");
- goto end;
- }
-
- while (eldbus_message_iter_get_and_next(labels, 'v', &t))
- {
- if (!table->labels)
- table->labels = eina_array_new(10);
-
- if (!(text = _get_text_from_message_iter(t)))
- {
- _free_lookup_table(table);
- table = NULL;
- goto end;
- }
-
- DBG("Appending new label %s", text->text);
- eina_array_push(table->labels, text);
- }
-
-end:
- return table;
-}
-
-static void
-_free_property(struct _ibus_property *property)
-{
- if (!property)
- return;
-
- free(property->key);
- free(property->icon);
- _free_text(property->label);
- _free_text(property->symbol);
- _free_text(property->tooltip);
- _free_eina_array(property->sub_properties, _free_property);
- free(property);
-}
-
-static struct _ibus_property *
-_get_property_from_message_iter(Eldbus_Message_Iter *iter)
-{
- struct _ibus_serializable ignore = { 0 };
- struct _ibus_property *prop = calloc(1, sizeof(*prop));
- Eldbus_Message_Iter *label = NULL, *symbol = NULL, *tooltip = NULL, *sub_props = NULL;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(prop, NULL);
-
- DBG("Property iter signature '%s'", eldbus_message_iter_signature_get(iter));
-
- if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}suvsvbbuvv)",
- &ignore.text, &ignore.variant,
- &prop->key, &prop->type,
- &label, &prop->icon, &tooltip,
- &prop->sensitive, &prop->visible,
- &prop->state, &sub_props, &symbol))
- {
- ERR("Error deserializing IBusProperty");
- free(prop);
- prop = NULL;
- goto end;
- }
-
- DBG("Property :");
- DBG("\tKey.............: '%s'", prop->key);
- DBG("\tType............: '%d'", prop->type);
- DBG("\tLabel...........: '%p'", label);
- DBG("\tIcon............: '%s'", prop->icon);
- DBG("\tTooltip.........: '%p'", tooltip);
- DBG("\tSensitive.......: '%d'", prop->sensitive);
- DBG("\tVisible.........: '%d'", prop->visible);
- DBG("\tState...........: '%d'", prop->state);
- DBG("\tSub Properties..: '%p'", sub_props);
- DBG("\tSymbol..........: '%p'", symbol);
-
- if (!label)
- {
- INF("Property has no label");
- goto symbol;
- }
-
- if (!(prop->label = _get_text_from_message_iter(label)))
- {
- _free_property(prop);
- prop = NULL;
- goto end;
- }
-
-symbol:
- if (!symbol)
- {
- INF("Property has no symbol");
- goto tooltip;
- }
-
- if (!(prop->symbol = _get_text_from_message_iter(symbol)))
- {
- _free_property(prop);
- prop = NULL;
- goto end;
- }
-
-tooltip:
- if (!tooltip)
- {
- INF("Property has no tooltip");
- goto sub_props;
- }
-
- if (!(prop->tooltip = _get_text_from_message_iter(tooltip)))
- {
- _free_property(prop);
- prop = NULL;
- goto end;
- }
-
-sub_props:
- if (!sub_props)
- {
- INF("Property has no sub properties");
- goto end;
- }
-
- prop->sub_properties = _get_properties_from_message_iter(sub_props);
-
-end:
- return prop;
-}
-
-static Eina_Array *
-_get_properties_from_message_iter(Eldbus_Message_Iter *iter)
-{
- Eina_Array *properties = NULL;
- Eldbus_Message_Iter *props = NULL, *prop = NULL;
- struct _ibus_serializable ignore = { 0 };
- struct _ibus_property *property = NULL;
-
- DBG("PropList iter signature '%s'", eldbus_message_iter_signature_get(iter));
-
- if (!eldbus_message_iter_arguments_get(iter, "(sa{sv}av)", &ignore.text, &ignore.variant, &props))
- {
- ERR("Error deserializing IBusPropList");
- goto end;
- }
-
- if (!props)
- {
- INF("PropList has no property");
- goto end;
- }
-
- while (eldbus_message_iter_get_and_next(props, 'v', &prop))
- {
- if (!properties)
- properties = eina_array_new(10);
-
- if (!(property = _get_property_from_message_iter(prop)))
- {
- _free_eina_array(properties, _free_property);
- properties = NULL;
- goto end;
- }
-
- DBG("Appending new property %p", property);
- eina_array_push(properties, property);
- }
-
-end:
- return properties;
-}
-
static Eldbus_Message *
_panel_update_preedit_text(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
{
Eldbus_Message_Iter *text = NULL;
unsigned int cursor_pos = 0;
Eina_Bool visible = 0;
- struct _ibus_text *ibus_text;
+ struct wkb_ibus_text *ibus_text;
_panel_check_message_errors(msg);
@@ -439,9 +56,9 @@ _panel_update_preedit_text(const Eldbus_Service_Interface *iface, const Eldbus_M
DBG("text: '%p', cursor_pos: '%d', visible: '%d')", text, cursor_pos, visible);
- ibus_text = _get_text_from_message_iter(text);
+ ibus_text = wkb_ibus_text_from_message_iter(text);
DBG("Preedit text = '%s'", ibus_text->text);
- _free_text(ibus_text);
+ wkb_ibus_text_free(ibus_text);
return NULL;
}
@@ -467,7 +84,7 @@ _panel_update_auxiliary_text(const Eldbus_Service_Interface *iface, const Eldbus
{
Eldbus_Message_Iter *text = NULL;
Eina_Bool visible = 0;
- struct _ibus_text *ibus_text;
+ struct wkb_ibus_text *ibus_text;
_panel_check_message_errors(msg);
@@ -479,9 +96,9 @@ _panel_update_auxiliary_text(const Eldbus_Service_Interface *iface, const Eldbus
DBG("text: '%p', visible: '%d'", text, visible);
- ibus_text = _get_text_from_message_iter(text);
+ ibus_text = wkb_ibus_text_from_message_iter(text);
DBG("Auxiliary text = '%s'", ibus_text->text);
- _free_text(ibus_text);
+ wkb_ibus_text_free(ibus_text);
return NULL;
}
@@ -507,7 +124,7 @@ _panel_update_lookup_table(const Eldbus_Service_Interface *iface, const Eldbus_M
{
Eldbus_Message_Iter *table = NULL;
Eina_Bool visible = 0;
- struct _ibus_lookup_table *ibus_lookup_table;
+ struct wkb_ibus_lookup_table *ibus_lookup_table;
_panel_check_message_errors(msg);
@@ -519,8 +136,8 @@ _panel_update_lookup_table(const Eldbus_Service_Interface *iface, const Eldbus_M
DBG("table: '%p', visible: '%d'", table, visible);
- ibus_lookup_table = _get_lookup_table_from_message_iter(table);
- _free_lookup_table(ibus_lookup_table);
+ ibus_lookup_table = wkb_ibus_lookup_table_from_message_iter(table);
+ wkb_ibus_lookup_table_free(ibus_lookup_table);
return NULL;
}
@@ -589,8 +206,8 @@ _panel_register_properties(const Eldbus_Service_Interface *iface, const Eldbus_M
DBG("properties: '%p'", props);
- properties = _get_properties_from_message_iter(props);
- _free_eina_array(properties, _free_property);
+ properties = wkb_ibus_properties_from_message_iter(props);
+ wkb_ibus_properties_free(properties);
return NULL;
}
@@ -619,6 +236,8 @@ _panel_focus_in(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg
{
_panel_check_message_errors(msg);
+ INF("FOCUS IN!!!");
+
return NULL;
}
@@ -627,6 +246,8 @@ _panel_focus_out(const Eldbus_Service_Interface *iface, const Eldbus_Message *ms
{
_panel_check_message_errors(msg);
+ INF("FOCUS OUT!!!");
+
return NULL;
}