Skip to content

Commit

Permalink
refactor: remove deprecated and unused api
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Nov 7, 2024
1 parent 951b441 commit 89504bb
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 97 deletions.
12 changes: 0 additions & 12 deletions app/src/main/java/com/osfans/trime/core/Rime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,6 @@ class Rime :
@JvmStatic
external fun selectRimeSchema(schemaId: String): Boolean

@JvmStatic
external fun getRimeConfigMap(
configId: String,
key: String,
): Map<String, Any>?

@JvmStatic
external fun setRimeCustomConfigInt(
configId: String,
keyValuePairs: Array<Pair<String?, Int?>?>,
)

// testing
@JvmStatic
external fun simulateRimeKeySequence(keySequence: String): Boolean
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/jni/librime_jni/levers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,3 @@ Java_com_osfans_trime_core_Rime_selectRimeSchemas(JNIEnv *env,
}
return true;
}

extern "C" JNIEXPORT void JNICALL
Java_com_osfans_trime_core_Rime_setRimeCustomConfigInt(
JNIEnv *env, jclass clazz, jstring config_id,
jobjectArray key_value_pairs) {
auto levers = get_levers();
auto custom =
levers->custom_settings_init(CString(env, config_id), "rime.trime");
levers->load_settings(custom);
int arrayLength = env->GetArrayLength(key_value_pairs);
for (int i = 0; i < arrayLength; i++) {
auto pair = JRef<>(env, env->GetObjectArrayElement(key_value_pairs, i));
auto key = CString(
env, (jstring)env->CallObjectMethod(pair, GlobalRef->PairFirst));
auto value =
extract_int(env, env->CallObjectMethod(pair, GlobalRef->PairSecond));
levers->customize_int(custom, key, value);
levers->save_settings(custom);
}
levers->custom_settings_destroy(custom);
}
50 changes: 0 additions & 50 deletions app/src/main/jni/librime_jni/objconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,56 +84,6 @@ inline jobject rimeStatusToJObject(JNIEnv *env, const RimeStatus &status) {
status.is_traditional, status.is_ascii_punct);
}

inline jobject rimeConfigValueToJObject(JNIEnv *env, RimeConfig *config,
const std::string &key);

inline jobject rimeConfigListToJObject(JNIEnv *env, RimeConfig *config,
const std::string &key) {
auto rime = rime_get_api();
RimeConfigIterator iter = {nullptr};
if (!rime->config_begin_list(&iter, config, key.c_str())) return nullptr;
auto size = rime->config_list_size(config, key.c_str());
auto obj =
env->NewObject(GlobalRef->ArrayList, GlobalRef->ArrayListInit, size);
int i = 0;
while (rime->config_next(&iter)) {
auto e = JRef<>(env, rimeConfigValueToJObject(env, config, iter.path));
env->CallVoidMethod(obj, GlobalRef->ArrayListAdd, i++, *e);
}
rime->config_end(&iter);
return obj;
}

inline jobject rimeConfigMapToJObject(JNIEnv *env, RimeConfig *config,
const std::string &key) {
auto rime = rime_get_api();
RimeConfigIterator iter = {nullptr};
if (!rime->config_begin_map(&iter, config, key.c_str())) return nullptr;
auto obj = env->NewObject(GlobalRef->HashMap, GlobalRef->HashMapInit);
while (rime->config_next(&iter)) {
auto v = JRef<>(env, rimeConfigValueToJObject(env, config, iter.path));
env->CallObjectMethod(obj, GlobalRef->HashMapPut, *JString(env, iter.key),
*v);
}
rime->config_end(&iter);
return obj;
}

inline jobject rimeConfigValueToJObject(JNIEnv *env, RimeConfig *config,
const std::string &key) {
auto rime = rime_get_api();

const char *value;
if ((value = rime->config_get_cstring(config, key.c_str()))) {
return env->NewStringUTF(value);
}
jobject list;
if ((list = rimeConfigListToJObject(env, config, key))) {
return list;
}
return rimeConfigMapToJObject(env, config, key);
}

inline jobjectArray rimeSchemaListToJObjectArray(JNIEnv *env,
RimeSchemaList &list) {
jobjectArray array = env->NewObjectArray(static_cast<int>(list.size),
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/jni/librime_jni/rime_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,20 +480,6 @@ Java_com_osfans_trime_core_Rime_getLibrimeVersion(JNIEnv *env,
return env->NewStringUTF(LIBRIME_VERSION);
}

extern "C" JNIEXPORT jobject JNICALL
Java_com_osfans_trime_core_Rime_getRimeConfigMap(JNIEnv *env, jclass clazz,
jstring config_id,
jstring key) {
auto rime = rime_get_api();
RimeConfig config = {nullptr};
jobject value = nullptr;
if (rime->config_open(CString(env, config_id), &config)) {
value = rimeConfigMapToJObject(env, &config, CString(env, key));
rime->config_close(&config);
}
return value;
}

extern "C" JNIEXPORT jboolean JNICALL
Java_com_osfans_trime_core_Rime_runRimeTask(JNIEnv *env, jclass /* thiz */,
jstring task_name) {
Expand Down

0 comments on commit 89504bb

Please sign in to comment.