blob: fd59e828e561e468715175664b912bc4b2b5ecce [file] [log] [blame]
diff -ur ibus-1.4.99.20120314.orig/conf/memconf/config.c ibus-1.4.99.20120314/conf/memconf/config.c
--- ibus-1.4.99.20120314.orig/conf/memconf/config.c 2012-02-27 06:37:21.000000000 +0900
+++ ibus-1.4.99.20120314/conf/memconf/config.c 2012-04-02 15:05:20.300663070 +0900
@@ -29,6 +29,8 @@
struct _IBusConfigMemconf {
IBusConfigService parent;
GHashTable *values;
+ GHashTable *unread;
+ GHashTable *unwritten;
};
struct _IBusConfigMemconfClass {
@@ -55,6 +57,10 @@
const gchar *section,
const gchar *name,
GError **error);
+static gboolean ibus_config_memconf_get_unused (IBusConfigService *config,
+ GVariant **unread,
+ GVariant **unwritten,
+ GError **error);
G_DEFINE_TYPE (IBusConfigMemconf, ibus_config_memconf, IBUS_TYPE_CONFIG_SERVICE)
@@ -68,6 +74,7 @@
IBUS_CONFIG_SERVICE_CLASS (object_class)->get_value = ibus_config_memconf_get_value;
IBUS_CONFIG_SERVICE_CLASS (object_class)->get_values = ibus_config_memconf_get_values;
IBUS_CONFIG_SERVICE_CLASS (object_class)->unset_value = ibus_config_memconf_unset_value;
+ IBUS_CONFIG_SERVICE_CLASS (object_class)->get_unused = ibus_config_memconf_get_unused;
}
static void
@@ -75,14 +82,25 @@
{
config->values = g_hash_table_new_full (g_str_hash,
g_str_equal,
- (GDestroyNotify)g_free,
- (GDestroyNotify)g_variant_unref);
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_variant_unref);
+ config->unread = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
+ config->unwritten
+ = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
}
static void
ibus_config_memconf_destroy (IBusConfigMemconf *config)
{
g_hash_table_destroy (config->values);
+ g_hash_table_destroy (config->unread);
+ g_hash_table_destroy (config->unwritten);
IBUS_OBJECT_CLASS (ibus_config_memconf_parent_class)->destroy ((IBusObject *)config);
}
@@ -101,6 +119,12 @@
gchar *key = g_strdup_printf ("%s:%s", section, name);
+ if (g_hash_table_lookup (
+ IBUS_CONFIG_MEMCONF (config)->values, key) == NULL) {
+ g_hash_table_insert (IBUS_CONFIG_MEMCONF (config)->unread,
+ g_strdup (key), NULL);
+ }
+
g_hash_table_insert (IBUS_CONFIG_MEMCONF (config)->values,
key, g_variant_ref_sink (value));
@@ -121,16 +145,21 @@
g_assert (error == NULL || *error == NULL);
gchar *key = g_strdup_printf ("%s:%s", section, name);
+
GVariant *value = (GVariant *)g_hash_table_lookup (IBUS_CONFIG_MEMCONF (config)->values, key);
- g_free (key);
- if (value != NULL) {
+ if (value == NULL) {
+ g_hash_table_insert (IBUS_CONFIG_MEMCONF (config)->unwritten,
+ g_strdup (key), NULL);
+ if (error != NULL) {
+ *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+ "Config value [%s:%s] does not exist.", section, name);
+ }
+ } else {
+ g_hash_table_remove (IBUS_CONFIG_MEMCONF (config)->unread, key);
g_variant_ref (value);
}
- else if (error != NULL) {
- *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "Config value [%s:%s] does not exist.", section, name);
- }
+ g_free (key);
return value;
}
@@ -173,13 +202,13 @@
gchar *key = g_strdup_printf ("%s:%s", section, name);
gboolean retval = g_hash_table_remove (IBUS_CONFIG_MEMCONF (config)->values, key);
- g_free (key);
if (retval) {
ibus_config_service_value_changed (config,
section,
name,
g_variant_new_tuple (NULL, 0));
+ g_hash_table_remove (IBUS_CONFIG_MEMCONF (config)->unread, key);
}
else {
if (error && *error) {
@@ -187,9 +216,39 @@
"Config value [%s:%s] does not exist.", section, name);
}
}
+ g_free (key);
return retval;
}
+static gboolean
+ibus_config_memconf_get_unused (IBusConfigService *config,
+ GVariant **unread,
+ GVariant **unwritten,
+ GError **error)
+{
+ GVariantBuilder builder;
+ GList *keys, *p;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+ keys = g_hash_table_get_keys (IBUS_CONFIG_MEMCONF (config)->unread);
+ for (p = keys; p != NULL; p = p->next) {
+ g_variant_builder_add (&builder, "s", (const gchar *)p->data);
+ }
+ g_list_free (keys);
+ *unread = g_variant_builder_end (&builder);
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+ keys = g_hash_table_get_keys (IBUS_CONFIG_MEMCONF (config)->unwritten);
+ for (p = keys; p != NULL; p = p->next) {
+ g_variant_builder_add (&builder, "s", (const gchar *)p->data);
+ }
+ g_list_free (keys);
+
+ *unwritten = g_variant_builder_end (&builder);
+
+ return TRUE;
+}
+
IBusConfigMemconf *
ibus_config_memconf_new (GDBusConnection *connection)
{
diff -ur ibus-1.4.99.20120314.orig/src/ibusconfig.c ibus-1.4.99.20120314/src/ibusconfig.c
--- ibus-1.4.99.20120314.orig/src/ibusconfig.c 2012-03-07 14:39:58.000000000 +0900
+++ ibus-1.4.99.20120314/src/ibusconfig.c 2012-04-02 15:03:18.361126672 +0900
@@ -720,3 +720,37 @@
async_initable_iface->init_async = async_initable_init_async;
async_initable_iface->init_finish = async_initable_init_finish;
}
+
+gboolean
+ibus_config_get_unused (IBusConfig *config,
+ GVariant **unread,
+ GVariant **unwritten)
+{
+ g_assert (IBUS_IS_CONFIG (config));
+ g_assert (unread != NULL && *unread == NULL);
+ g_assert (unwritten != NULL && *unwritten == NULL);
+
+ GError *error = NULL;
+ GVariant *result;
+
+ result = g_dbus_proxy_call_sync ((GDBusProxy *) config,
+ "GetUnused", /* method_name */
+ NULL, /* parameters */
+ G_DBUS_CALL_FLAGS_NONE, /* flags */
+ -1, /* timeout */
+ NULL, /* cancellable */
+ &error /* error */
+ );
+ if (result == NULL) {
+ g_warning ("%s.GetUnused: %s", IBUS_INTERFACE_CONFIG, error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ *unread = g_variant_get_child_value (result, 0);
+ *unwritten = g_variant_get_child_value (result, 1);
+
+ g_variant_unref (result);
+
+ return TRUE;
+}
Only in ibus-1.4.99.20120314/src: ibusconfig.c.orig
diff -ur ibus-1.4.99.20120314.orig/src/ibusconfig.h ibus-1.4.99.20120314/src/ibusconfig.h
--- ibus-1.4.99.20120314.orig/src/ibusconfig.h 2012-03-07 14:39:58.000000000 +0900
+++ ibus-1.4.99.20120314/src/ibusconfig.h 2012-04-02 15:03:18.361126672 +0900
@@ -347,6 +347,19 @@
/* FIXME add an asynchronous version of unwatch */
+/**
+ * ibus_config_get_unused:
+ * @config: An IBusConfig
+ * @unread: GVariant that holds a list of values that have been written but not
+ * read.
+ * @unwritten: GVariant that holds a list of values that have been read but not
+ * written.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Get the list of values that haven't been used properly.
+ */
+gboolean ibus_config_get_unused (IBusConfig *config,
+ GVariant **unread,
+ GVariant **unwritten);
G_END_DECLS
#endif
-
Only in ibus-1.4.99.20120314/src: ibusconfig.h.orig
diff -ur ibus-1.4.99.20120314.orig/src/ibusconfigservice.c ibus-1.4.99.20120314/src/ibusconfigservice.c
--- ibus-1.4.99.20120314.orig/src/ibusconfigservice.c 2012-03-07 14:41:10.000000000 +0900
+++ ibus-1.4.99.20120314/src/ibusconfigservice.c 2012-04-02 15:03:18.361126672 +0900
@@ -76,6 +76,10 @@
const gchar *section,
const gchar *name,
GError **error);
+static gboolean ibus_config_service_get_unused (IBusConfigService *config,
+ GVariant **unread,
+ GVariant **unwritten,
+ GError **error);
G_DEFINE_TYPE (IBusConfigService, ibus_config_service, IBUS_TYPE_SERVICE)
@@ -105,6 +109,10 @@
" <arg type='s' name='name' />"
" <arg type='v' name='value' />"
" </signal>"
+ " <method name='GetUnused'>"
+ " <arg direction='out' type='as' name='unread' />"
+ " <arg direction='out' type='as' name='unwritten' />"
+ " </method>"
" </interface>"
"</node>";
@@ -125,6 +133,7 @@
class->get_value = ibus_config_service_get_value;
class->get_values = ibus_config_service_get_values;
class->unset_value = ibus_config_service_unset_value;
+ class->get_unused = ibus_config_service_get_unused;
}
static void
@@ -242,6 +251,25 @@
return;
}
+ if (g_strcmp0 (method_name, "GetUnused") == 0) {
+ GVariant *unread = NULL;
+ GVariant *unwritten = NULL;
+ gboolean retval;
+ GError *error = NULL;
+
+ retval = IBUS_CONFIG_SERVICE_GET_CLASS (config)->get_unused (
+ config, &unread, &unwritten, &error);
+ if (retval) {
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(@as@as)", unread, unwritten));
+ }
+ else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+ return;
+ }
+
/* should not be reached */
g_return_if_reached ();
}
@@ -352,6 +380,19 @@
return IBUS_CONFIG_SERVICE (object);
}
+static gboolean
+ibus_config_service_get_unused (IBusConfigService *config,
+ GVariant **unread,
+ GVariant **unwritten,
+ GError **error)
+{
+ if (error) {
+ *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+ "Not implemented");
+ }
+ return FALSE;
+}
+
void
ibus_config_service_value_changed (IBusConfigService *config,
const gchar *section,
Only in ibus-1.4.99.20120314/src: ibusconfigservice.c.orig
diff -ur ibus-1.4.99.20120314.orig/src/ibusconfigservice.h ibus-1.4.99.20120314/src/ibusconfigservice.h
--- ibus-1.4.99.20120314.orig/src/ibusconfigservice.h 2011-08-11 09:49:43.000000000 +0900
+++ ibus-1.4.99.20120314/src/ibusconfigservice.h 2012-04-02 15:03:18.361126672 +0900
@@ -203,10 +203,14 @@
GVariant * (* get_values) (IBusConfigService *config,
const gchar *section,
GError **error);
+ gboolean (* get_unused) (IBusConfigService *config,
+ GVariant **unread,
+ GVariant **unwritten,
+ GError **error);
/*< private >*/
/* padding */
- gpointer pdummy[12];
+ gpointer pdummy[11];
};
GType ibus_config_service_get_type (void);
@@ -238,4 +242,3 @@
G_END_DECLS
#endif
-