diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-02-22 02:21:05 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-02-22 02:21:05 +0000 |
commit | efe66a0e796306f46f1f863aec10fcfae07ff467 (patch) | |
tree | 72283c21b2a7edbf38ead11b536895250cda3cc0 /native/jni/gconf-peer/GConfNativePeer.c | |
parent | 85cbf78900ceb1a2c1d54523da5da2e3088ec860 (diff) | |
download | classpath-efe66a0e796306f46f1f863aec10fcfae07ff467.tar.gz |
2008-02-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/util/prefs/EventDispatcher.java:
Re-added.
* gnu/java/util/prefs/GConfBasedPreferences.java,
* gnu/java/util/prefs/gconf/GConfNativePeer.java,
* java/util/prefs/AbstractPreferences.java,
* native/jni/gconf-peer/GConfNativePeer.c:
Regress to 0.96 versions.
Diffstat (limited to 'native/jni/gconf-peer/GConfNativePeer.c')
-rw-r--r-- | native/jni/gconf-peer/GConfNativePeer.c | 112 |
1 files changed, 90 insertions, 22 deletions
diff --git a/native/jni/gconf-peer/GConfNativePeer.c b/native/jni/gconf-peer/GConfNativePeer.c index a53bbad75..42986c33a 100644 --- a/native/jni/gconf-peer/GConfNativePeer.c +++ b/native/jni/gconf-peer/GConfNativePeer.c @@ -70,10 +70,12 @@ static jmethodID jlist_add_id = NULL; /* ***** PRIVATE FUNCTIONS DELCARATION ***** */ /** - * Gets the reference of the default GConfClient.. + * Gets the reference of the default GConfClient and initialize the + * the type system. * The client reference should be released with g_object_unref after use. + * This functions must be called with gdk lock held. */ -static void init_gconf (void); +static void init_gconf_client (void); /** * Throws a new runtime exception after a failure, with the given message. @@ -131,7 +133,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache { reference_count++; - init_gconf (); + gdk_threads_enter (); + init_gconf_client (); + gdk_threads_leave (); /* if client is null, there is probably an out of memory */ if (client == NULL) @@ -153,11 +157,11 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_all_keys + * Method: gconf_client_all_keys * Signature: (Ljava/lang/String;)Ljava/util/List; */ JNIEXPORT jobject JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1keys +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) { /* TODO: check all the calls to gdk_threads_enter/leave */ @@ -179,7 +183,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1keys return NULL; } + gdk_threads_enter (); entries = gconf_client_all_entries (client, dir, &err); + gdk_threads_leave (); if (err != NULL) { throw_exception_by_name (env, "java/util/prefs/BackingStoreException", @@ -229,11 +235,11 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1keys /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_all_nodes + * Method: gconf_client_all_nodes * Signature: (Ljava/lang/String;)Ljava/util/List; */ JNIEXPORT jobject JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1nodes +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) { const char *dir = NULL; @@ -253,7 +259,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1nodes return NULL; } + gdk_threads_enter (); entries = gconf_client_all_dirs (client, dir, &err); + gdk_threads_leave (); if (err != NULL) { throw_exception_by_name (env, "java/util/prefs/BackingStoreException", @@ -303,16 +311,18 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1nodes /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_suggest_sync + * Method: gconf_client_suggest_sync * Signature: ()V */ JNIEXPORT void JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1suggest_1sync +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync (JNIEnv *env, jclass clazz __attribute__ ((unused))) { GError *err = NULL; + gdk_threads_enter (); gconf_client_suggest_sync (client, &err); + gdk_threads_leave (); if (err != NULL) { throw_exception_by_name (env, "java/util/prefs/BackingStoreException", @@ -324,11 +334,11 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1suggest_1sync /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_unset + * Method: gconf_client_unset * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unset +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key) { const char *_key = NULL; @@ -341,7 +351,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unset return JNI_FALSE; } + gdk_threads_enter (); result = gconf_client_unset (client, _key, &err); + gdk_threads_leave (); if (err != NULL) { result = JNI_FALSE; @@ -356,11 +368,11 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unset /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_get_string + * Method: gconf_client_get_string * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1get_1string +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key) { const char *_key = NULL; @@ -374,7 +386,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1get_1string return NULL; } + gdk_threads_enter (); _value = gconf_client_get_string (client, _key, &err); + gdk_threads_leave (); JCL_free_cstring (env, key, _key); if (err != NULL) { @@ -393,19 +407,17 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1get_1string result = (*env)->NewStringUTF (env, _value); g_free ((gpointer) _value); } - - gconf_client_suggest_sync (client, NULL); - + return result; } /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_set_string + * Method: gconf_client_set_string * Signature: (Ljava/lang/String;Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1set_1string +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key, jstring value) { @@ -423,7 +435,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1set_1string return JNI_FALSE; } + gdk_threads_enter (); result = gconf_client_set_string (client, _key, _value, &err); + gdk_threads_leave (); if (err != NULL) { g_error_free (err); @@ -439,11 +453,56 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1set_1string /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_dir_exists + * Method: gconf_client_remove_dir + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir + (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) +{ + const char *dir = NULL; + + dir = JCL_jstring_to_cstring (env, node); + if (dir == NULL) + return; + + gdk_threads_enter (); + gconf_client_remove_dir (client, dir, NULL); + gdk_threads_leave (); + + JCL_free_cstring (env, node, dir); +} + +/* + * Class: gnu_java_util_prefs_gconf_GConfNativePeer + * Method: gconf_client_add_dir + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir + (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) +{ + const char *dir = NULL; + + dir = JCL_jstring_to_cstring (env, node); + if (dir == NULL) + return; + + /* ignore errors */ + gdk_threads_enter (); + gconf_client_add_dir (client, dir, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gdk_threads_leave (); + + JCL_free_cstring (env, node, dir); +} + +/* + * Class: gnu_java_util_prefs_gconf_GConfNativePeer + * Method: gconf_client_dir_exists * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1dir_1exists +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) { const char *dir = NULL; @@ -455,7 +514,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1dir_1exists return value; /* on error return false */ + gdk_threads_enter (); value = gconf_client_dir_exists (client, dir, &err); + gdk_threads_leave (); if (err != NULL) value = JNI_FALSE; @@ -476,8 +537,10 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class if (reference_count == 0) { /* last reference, free all resources and return */ + gdk_threads_enter (); g_object_unref (G_OBJECT (client)); - + gdk_threads_leave (); + (*env)->DeleteGlobalRef (env, jlist_class); jlist_class = NULL; @@ -509,7 +572,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key return NULL; } + gdk_threads_enter (); escaped = gconf_escape_key (_plain, strlen (_plain)); + gdk_threads_leave (); JCL_free_cstring (env, plain, _plain); /* check for NULL, if so prevent string creation */ @@ -541,7 +606,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key return NULL; } + gdk_threads_enter (); plain = gconf_unescape_key (_escaped, strlen (_escaped)); + gdk_threads_leave (); JCL_free_cstring (env, escaped, _escaped); /* check for NULL, if so prevent string creation */ @@ -569,8 +636,9 @@ throw_exception_by_name (JNIEnv *env, const char *name, const char *msg) JCL_ThrowException (env, name, msg); } -static void init_gconf (void) +static void init_gconf_client (void) { + g_type_init (); client = gconf_client_get_default (); } |