Пример #1
0
static void FcitxRimeStart(FcitxRime* rime, boolean fullcheck) {

    char* user_path = NULL;
    FILE* fp = FcitxXDGGetFileUserWithPrefix("rime", ".place_holder", "w", NULL);
    if (fp)
        fclose(fp);
    FcitxXDGGetFileUserWithPrefix("rime", "", NULL, &user_path);
    //char* shared_data_dir = fcitx_utils_get_fcitx_path_with_filename("pkgdatadir", "rime");
    const char* shared_data_dir = RIME_DATA_DIR;

    RIME_STRUCT(RimeTraits, fcitx_rime_traits);
    fcitx_rime_traits.shared_data_dir = shared_data_dir;
    fcitx_rime_traits.app_name = "rime.fcitx-rime";
    fcitx_rime_traits.user_data_dir = user_path;
    fcitx_rime_traits.distribution_name = "Rime";
    fcitx_rime_traits.distribution_code_name = "fcitx-rime";
    fcitx_rime_traits.distribution_version = "0.2.3";
    if (rime->firstRun) {
        rime->api->setup(&fcitx_rime_traits);
        rime->firstRun = false;
    }
    rime->api->initialize(&fcitx_rime_traits);
    rime->api->set_notification_handler(FcitxRimeNotificationHandler, rime);
    rime->api->start_maintenance(fullcheck);

    rime->session_id = rime->api->create_session();
    free(user_path);
}
Пример #2
0
/**
 * @brief initialize the extra input method
 *
 * @param arg
 * @return successful or not
 **/
__EXPORT_API
void* FcitxChewingCreate(FcitxInstance* instance)
{
    if (GetFcitxChewingConfigDesc() == NULL)
        return NULL;
    
    char* user_path = NULL;
    FILE* fp = FcitxXDGGetFileUserWithPrefix("chewing", ".place_holder", "w", NULL);
    if (fp)
        fclose(fp);
    FcitxXDGGetFileUserWithPrefix("chewing", "", NULL, &user_path);
    FcitxLog(INFO, "Chewing storage path %s", user_path);
    if (0 == chewing_Init(CHEWING_DATADIR, user_path)) {
        FcitxLog(DEBUG, "chewing init ok");
    } else {
        FcitxLog(DEBUG, "chewing init failed");
        return NULL;
    }
    
    FcitxChewing* chewing = (FcitxChewing*) fcitx_utils_malloc0(sizeof(FcitxChewing));
    FcitxGlobalConfig* config = FcitxInstanceGetGlobalConfig(instance);
    FcitxInputState *input = FcitxInstanceGetInputState(instance);
    FcitxCandidateWordSetChoose(FcitxInputStateGetCandidateList(input), DIGIT_STR_CHOOSE);
    
    bindtextdomain("fcitx-chewing", LOCALEDIR);

    chewing->context = chewing_new();
    ChewingContext * c = chewing->context;
    chewing->owner = instance;
    chewing_set_ChiEngMode(c, CHINESE_MODE);
    chewing_set_maxChiSymbolLen(c, 16);
    // chewing will crash without set page
    chewing_set_candPerPage(c, config->iMaxCandWord);
    FcitxCandidateWordSetPageSize(FcitxInputStateGetCandidateList(input), config->iMaxCandWord);
    chewing_set_selKey(c, selKey, 10);
    LoadChewingConfig(&chewing->config);
    ConfigChewing(chewing);

    FcitxInstanceRegisterIM(
        instance,
        chewing,
        "chewing",
        _("Chewing"),
        "chewing",
        FcitxChewingInit,
        FcitxChewingReset,
        FcitxChewingDoInput,
        FcitxChewingGetCandWords,
        NULL,
        NULL,
        FcitxChewingReloadConfig,
        NULL,
        1,
        "zh_TW"
    );
    return chewing;
}
Пример #3
0
void ScelConverter::finished(int exitCode, QProcess::ExitStatus status)
{
    if (status == QProcess::CrashExit) {
        emit message(QMessageBox::Critical, _("Converter crashed."));
        emit finished(false);
        return;
    }

    if (exitCode != 0) {
        emit message(QMessageBox::Warning, _("Convert failed."));
        emit finished(false);
    }

    char* fullName;
    FcitxXDGMakeDirUser("libpinyin/importdict");
    FcitxXDGGetFileUserWithPrefix("libpinyin/importdict", m_name.toLocal8Bit().constData(), NULL, &fullName);

    if (QFile::rename(m_file.fileName(), QString::fromLocal8Bit(fullName))) {
        emit finished(true);
    } else {
        QFile::remove(m_file.fileName());
        emit message(QMessageBox::Warning, _("Rename failed."));
        emit finished(false);
    }

    free(fullName);
}
Пример #4
0
bool DictModel::save()
{
    char* name = NULL;
    FcitxXDGMakeDirUser("kkc");
    FcitxXDGGetFileUserWithPrefix("kkc", "dictionary_list", NULL, &name);
    QString fileName = QString::fromLocal8Bit(name);
    QTemporaryFile tempFile(fileName);
    free(name);
    if (!tempFile.open()) {
        return false;
    }

    typedef QMap<QString, QString> DictType;

    Q_FOREACH(const DictType& dict, m_dicts) {
        boolean first = true;
        Q_FOREACH(const QString& key, dict.keys()) {
            if (first) {
                first = false;
            } else {
                tempFile.write(",");
            }
            tempFile.write(key.toUtf8());
            tempFile.write("=");
            tempFile.write(dict[key].toUtf8());
        }
        tempFile.write("\n");
    }
Пример #5
0
boolean LoadQuickPhraseConfig(QuickPhraseState* qpstate)
{
    FcitxConfigFileDesc* configDesc = GetQuickPhraseConfigDesc();
    if (configDesc == NULL)
        return false;

    FILE *fp;
    char *file;
    fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-quickphrase.config", "r", &file);
    FcitxLog(DEBUG, "Load Config File %s", file);
    free(file);
    if (!fp) {
        if (errno == ENOENT)
            SaveQuickPhraseConfig(qpstate);
    }

    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);

    QuickPhraseStateConfigBind(qpstate, cfile, configDesc);
    FcitxConfigBindSync((FcitxGenericConfig*)qpstate);

    if (fp)
        fclose(fp);

    return true;
}
Пример #6
0
boolean LoadIMSelectorConfig(IMSelector* imselector)
{
    FcitxConfigFileDesc* configDesc = GetIMSelectorConfig();
    if (configDesc == NULL)
        return false;

    FILE *fp;
    char *file;
    fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-imselector.config", "r", &file);
    FcitxLog(DEBUG, "Load Config File %s", file);
    free(file);
    if (!fp) {
        if (errno == ENOENT)
            SaveIMSelectorConfig(imselector);
    }

    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);

    IMSelectorConfigBind(imselector, cfile, configDesc);
    FcitxConfigBindSync((FcitxGenericConfig*)imselector);

    if (fp)
        fclose(fp);

    return true;
}
Пример #7
0
boolean LoadChttransConfig(FcitxChttrans* transState)
{
    FcitxConfigFileDesc* configDesc = GetChttransConfigDesc();
    if (configDesc == NULL)
        return false;

    FILE *fp;
    char *file;
    fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-chttrans.config",
                                       "r", &file);
    FcitxLog(DEBUG, "Load Config File %s", file);
    free(file);
    if (!fp) {
        if (errno == ENOENT)
            SaveChttransConfig(transState);
    }

    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);

    FcitxChttransConfigBind(transState, cfile, configDesc);
    FcitxConfigBindSync((FcitxGenericConfig*)transState);

    if (fp)
        fclose(fp);

    return true;
}
Пример #8
0
static void
_fcitx_main_window_toggled_cb(GtkCellRenderer *renderer,
                              gchar* str_path,
                              gpointer         user_data)
{
    GtkTreeModel *model = (GtkTreeModel *)user_data;
    GtkTreePath *path = gtk_tree_path_new_from_string(str_path);
    GtkTreeIter iter;
    gtk_tree_model_get_iter(model, &iter, path);
    FcitxAddon* addon = NULL;
    gtk_tree_path_free(path);
    gtk_tree_model_get(model,
                       &iter,
                       LIST_ADDON, &addon,
                       -1);

    if (!addon)
        return;

    addon->bEnabled = !addon->bEnabled;
    char *buf;
    asprintf(&buf, "%s.conf", addon->name);
    FILE* fp = FcitxXDGGetFileUserWithPrefix("addon", buf, "w", NULL);
    free(buf);
    if (fp) {
        fprintf(fp, "[Addon]\nEnabled=%s\n", addon->bEnabled ? "True" : "False");
        fclose(fp);
    }
    g_object_set(renderer,
                 "active", (gboolean) addon->bEnabled,
                 NULL);
}
Пример #9
0
int FcitxXErrorHandler(Display * dpy, XErrorEvent * event)
{
    if (!x11handle)
        return 0;

    if (FcitxInstanceGetIsDestroying(x11handle->owner))
        return 0;

    char    str[256];
    FILE* fp = NULL;

    fp = FcitxXDGGetFileUserWithPrefix("log", "crash.log", "w" , NULL);
    if (fp) {
        XGetErrorText(dpy, event->error_code, str, 255);
        fprintf(fp, "fcitx: %s\n", str);
    }

    FcitxInstanceSaveAllIM(x11handle->owner);

    if (fp)
        fclose(fp);
    if (event->error_code != 3 && event->error_code != BadMatch) {
        // xterm will generate 3
        FcitxInstanceEnd(x11handle->owner);
    }

    return 0;
}
Пример #10
0
static boolean
LoadAutoEngConfig(FcitxAutoEngConfig *config)
{
    FcitxConfigFileDesc *configDesc = GetAutoEngConfigDesc();
    if (configDesc == NULL)
        return false;

    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-autoeng.config",
                                             "r", NULL);

    if (!fp) {
        if (errno == ENOENT)
            SaveAutoEngConfig(config);
    }
    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);
    FcitxAutoEngConfigConfigBind(config, cfile, configDesc);
    FcitxConfigBindSync(&config->gconfig);
    if (config->chooseModifier > AECM_CTRL)
        config->chooseModifier = AECM_CTRL;

    if (fp)
        fclose(fp);

    return true;
}
Пример #11
0
static void
ClipboardWriteHistory(FcitxClipboard *clipboard)
{
    FILE *fp;
    fp = FcitxXDGGetFileUserWithPrefix("clipboard", "history.dat", "w", NULL);
    if (!fp)
        return;
    if (!clipboard->config.save_history)
        goto out;
    fcitx_utils_write_uint32(fp, clipboard->clp_hist_len);
    fcitx_utils_write_uint32(fp, clipboard->primary.len);
    unsigned int i;
    for (i = 0;i < clipboard->clp_hist_len;i++) {
        fcitx_utils_write_uint32(fp, clipboard->clp_hist_lst[i].len);
    }
    if (clipboard->primary.len)
        fwrite(clipboard->primary.str, 1, clipboard->primary.len, fp);
    for (i = 0;i < clipboard->clp_hist_len;i++) {
        if (clipboard->clp_hist_lst[i].len)
            fwrite(clipboard->clp_hist_lst[i].str, 1,
                   clipboard->clp_hist_lst[i].len, fp);
    }
out:
    fclose(fp);
}
Пример #12
0
void SaveChewingConfig(FcitxChewingConfig* fc)
{
    FcitxConfigFileDesc *configDesc = GetFcitxChewingConfigDesc();
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-chewing.config", "wt", NULL);
    FcitxConfigSaveConfigFileFp(fp, &fc->config, configDesc);
    if (fp)
        fclose(fp);
}
Пример #13
0
/**
 * @brief Save the config
 *
 * @return void
 **/
void SaveCloudPinyinConfig(FcitxCloudPinyinConfig* fs)
{
    FcitxConfigFileDesc *configDesc = GetCloudPinyinConfigDesc();
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-cloudpinyin.config", "wt", NULL);
    FcitxConfigSaveConfigFileFp(fp, &fs->config, configDesc);
    if (fp)
        fclose(fp);
}
Пример #14
0
void FcitxTabletSaveConfig(FcitxTabletConfig* cfg) {
	FcitxConfigFileDesc *configDesc = GetFcitxTabletConfigDesc();
	FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-tablet.config", "w", NULL);
	if(fp) {
		FcitxConfigSaveConfigFileFp(fp, &cfg->config, configDesc);
		fclose(fp);
	}
}
Пример #15
0
/**
 * @brief Save the config
 *
 * @return void
 **/
void SaveLibpinyinConfig(FcitxLibpinyinConfig* fs)
{
    FcitxConfigFileDesc *configDesc = GetLibpinyinConfigDesc();
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-libpinyin.config", "w", NULL);
    FcitxConfigSaveConfigFileFp(fp, &fs->gconfig, configDesc);
    if (fp)
        fclose(fp);
}
Пример #16
0
char* FcitxLibpinyinGetUserPath(LIBPINYIN_LANGUAGE_TYPE type)
{
    char* user_path = NULL;
    if (type == LPLT_Simplified) {
        FILE* fp = FcitxXDGGetFileUserWithPrefix("libpinyin", "data/.place_holder", "w", NULL);
        if (fp)
            fclose(fp);
        FcitxXDGGetFileUserWithPrefix("libpinyin", "data", NULL, &user_path);
        FcitxLog(INFO, "Libpinyin storage path %s", user_path);
    }
    else {
        FILE* fp = FcitxXDGGetFileUserWithPrefix("libpinyin", "zhuyin_data/.place_holder", "w", NULL);
        if (fp)
            fclose(fp);
        FcitxXDGGetFileUserWithPrefix("libpinyin", "zhuyin_data", NULL, &user_path);
    }
    return user_path;
}
Пример #17
0
void open_native_file(GtkButton *button,
                      gpointer   user_data)
{
    FcitxSubConfigWidget* widget = (FcitxSubConfigWidget*) user_data;
    char *newpath = NULL;
    char* qtguiwrapper = fcitx_utils_get_fcitx_path_with_filename ("libdir", "fcitx/libexec/fcitx-qt-gui-wrapper");
    if (qtguiwrapper) {
        gchar* argv[4];
        argv[0] = qtguiwrapper;
        argv[1] = "--test";
        argv[2] = widget->subconfig->nativepath;
        argv[3] = 0;
        int exit_status = 1;
        g_spawn_sync(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &exit_status, NULL);

        if (exit_status == 0) {
            gchar* argv2[3];
            argv2[0] = qtguiwrapper;
            argv2[1] = widget->subconfig->nativepath;
            argv2[2] = 0;
            g_spawn_async(NULL, argv2, NULL, 0, NULL, NULL, NULL, NULL);
            free(newpath);
        }
        g_free(qtguiwrapper);

        if (exit_status == 0) {
            return;
        }
    }

    if (g_hash_table_size(widget->subconfig->filelist) > 0) {
        GHashTableIter iter;
        g_hash_table_iter_init(&iter, widget->subconfig->filelist);
        gpointer key;
        if (g_hash_table_iter_next(&iter, &key, NULL)) {
            FILE* fp = FcitxXDGGetFileWithPrefix("",  key, "r", &newpath);
            if (fp)
                fclose(fp);
        }
    } else {
        FILE* fp = FcitxXDGGetFileUserWithPrefix("", widget->subconfig->nativepath, "w", &newpath);
        if (fp) {
            g_hash_table_insert(widget->subconfig->filelist, widget->subconfig->nativepath, NULL);
            fclose(fp);
        }
    }

    if (newpath) {
        gchar* filename = newpath;
        gchar* argv[3];
        argv[0] = "xdg-open";
        argv[1] = filename;
        argv[2] = 0;
        g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
        free(newpath);
    }
}
Пример #18
0
static void
SaveAutoEngConfig(FcitxAutoEngConfig* fs)
{
    FcitxConfigFileDesc *configDesc = GetAutoEngConfigDesc();
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-autoeng.config",
                                             "w", NULL);
    FcitxConfigSaveConfigFileFp(fp, &fs->gconfig, configDesc);
    if (fp)
        fclose(fp);
}
Пример #19
0
void SaveLightUIConfig(FcitxLightUI *lightui)
{
    FcitxConfigFileDesc* configDesc = GetLightUIDesc();
    char *file;
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-light-ui.config", "w", &file);
    FcitxLog(INFO, "Save Config to %s", file);
    FcitxConfigSaveConfigFileFp(fp, &lightui->gconfig, configDesc);
    free(file);
    if (fp)
        fclose(fp);
}
Пример #20
0
void SaveChttransConfig(FcitxChttrans* transState)
{
    FcitxConfigFileDesc* configDesc = GetChttransConfigDesc();
    char *file;
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-chttrans.config", "w", &file);
    FcitxLog(DEBUG, "Save Config to %s", file);
    FcitxConfigSaveConfigFileFp(fp, &transState->gconfig, configDesc);
    free(file);
    if (fp)
        fclose(fp);
}
Пример #21
0
void SaveClassicUIConfig(FcitxClassicUI *classicui)
{
    FcitxConfigFileDesc* configDesc = GetClassicUIDesc();
    char *file;
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-classic-ui.config", "wt", &file);
    FcitxLog(DEBUG, "Save Config to %s", file);
    FcitxConfigSaveConfigFileFp(fp, &classicui->gconfig, configDesc);
    free(file);
    if (fp)
        fclose(fp);
}
Пример #22
0
void SaveIMSelectorConfig(IMSelector* imselector)
{
    FcitxConfigFileDesc* configDesc = GetIMSelectorConfig();
    char *file;
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-imselector.config", "w", &file);
    FcitxLog(DEBUG, "Save Config to %s", file);
    FcitxConfigSaveConfigFileFp(fp, &imselector->gconfig, configDesc);
    free(file);
    if (fp)
        fclose(fp);
}
Пример #23
0
void SaveQuickPhraseConfig(QuickPhraseState* qpstate)
{
    FcitxConfigFileDesc* configDesc = GetQuickPhraseConfigDesc();
    char *file;
    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-quickphrase.config", "w", &file);
    FcitxLog(DEBUG, "Save Config to %s", file);
    FcitxConfigSaveConfigFileFp(fp, &qpstate->gconfig, configDesc);
    free(file);
    if (fp)
        fclose(fp);
}
Пример #24
0
char* FcitxLibPinyinGetUserPath(LIBPINYIN_LANGUAGE_TYPE type)
{
    char* user_path = NULL;
#ifdef LIBPINYIN_TOOLS_FOUND
    if (type == LPLT_Simplified) {
#endif
        FILE* fp = FcitxXDGGetFileUserWithPrefix("libpinyin", "data/.place_holder", "w", NULL);
        if (fp)
            fclose(fp);
        FcitxXDGGetFileUserWithPrefix("libpinyin", "data", NULL, &user_path);
#ifdef LIBPINYIN_TOOLS_FOUND
    }
    else {
        FILE* fp = FcitxXDGGetFileUserWithPrefix("libpinyin", "zhuyin_data/.place_holder", "w", NULL);
        if (fp)
            fclose(fp);
        FcitxXDGGetFileUserWithPrefix("libpinyin", "zhuyin_data", NULL, &user_path);
    }
#endif
    return user_path;
}
Пример #25
0
void ShortcutModel::load(const QString& name)
{
    setNeedSave(false);
    beginResetModel();

    do {
        if (m_userRule) {
            g_object_unref(m_userRule);
            m_userRule = 0;
        }

        m_entries.clear();

        KkcRuleMetadata* ruleMeta = kkc_rule_metadata_find(name.toUtf8().constData());
        if (!ruleMeta) {
            return;
        }

        char* fcitxBasePath = NULL;
        FcitxXDGGetFileUserWithPrefix("kkc", "rules", NULL, &fcitxBasePath);

        KkcUserRule* userRule = kkc_user_rule_new(ruleMeta, fcitxBasePath, "fcitx-kkc", NULL);
        free(fcitxBasePath);
        if (!userRule) {
            break;
        }

        for (int mode = 0; mode < KKC_INPUT_MODE_DIRECT; mode ++) {
            KkcKeymap* keymap = kkc_rule_get_keymap(KKC_RULE(userRule), (KkcInputMode) mode);
            int length;
            KkcKeymapEntry* entries = kkc_keymap_entries(keymap, &length);

            for (int i = 0; i < length; i ++) {
                if (entries[i].command) {
                    gchar* label = kkc_keymap_get_command_label(entries[i].command);
                    m_entries << ShortcutEntry(QString::fromUtf8(entries[i].command), entries[i].key, QString::fromUtf8(label), (KkcInputMode) mode);
                    g_free(label);
                }
            }

            for (int i = 0; i < length; i ++) {
                kkc_keymap_entry_destroy(&entries[i]);
            }
            g_free(entries);
            g_object_unref(keymap);
        }

        m_userRule = userRule;
    } while(0);

    endResetModel();
}
Пример #26
0
char*
_fcitx_get_socket_path()
{
    char* addressFile = NULL;
    char* machineId = dbus_get_local_machine_id();
    asprintf(&addressFile, "%s-%d", machineId, fcitx_utils_get_display_number());
    dbus_free(machineId);

    char* file = NULL;

    FcitxXDGGetFileUserWithPrefix("dbus", addressFile, NULL, &file);

    return file;

}
Пример #27
0
static void
FcitxNotifySaveDConfig(FcitxNotify *notify)
{
    FILE *fp;
    fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-notify.config",
                                       "w", NULL);
    if (fp) {
        FcitxDesktopGroup *grp;
        grp = fcitx_desktop_file_ensure_group(&notify->dconfig,
                                              "Notify/Notify");
        FcitxDesktopEntry *ety;
        ety = fcitx_desktop_group_ensure_entry(grp, "HiddenNotify");
        char *val = fcitx_string_map_to_string(notify->hide_notify, ';');
        fcitx_desktop_entry_set_value(ety, val);
        free(val);
        fcitx_desktop_file_write_fp(&notify->dconfig, fp);
        fclose(fp);
    }
}
Пример #28
0
const QString& FcitxQtConnectionPrivate::socketFile()
{
    if (!m_socketFile.isEmpty())
        return m_socketFile;

    char* addressFile = NULL;

    asprintf(&addressFile, "%s-%d", localMachineId().data(), displayNumber());

    char* file = NULL;

    FcitxXDGGetFileUserWithPrefix("dbus", addressFile, NULL, &file);

    QString path = QString::fromUtf8(file);
    free(file);
    free(addressFile);

    m_socketFile = path;

    return m_socketFile;
}
Пример #29
0
boolean FcitxTabletLoadConfig(FcitxTabletConfig* cfg) {
	FcitxConfigFileDesc *configDesc = GetFcitxTabletConfigDesc();
	if(configDesc == NULL)
		return false;

	FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-tablet.config", "r", NULL);

	if (!fp && errno == ENOENT) {
		// Create the file if it doesn't exist
		FcitxTabletSaveConfig(cfg);
	}

	FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);
	FcitxTabletConfigConfigBind(cfg, cfile, configDesc);
	FcitxConfigBindSync(&cfg->config);

	if(fp)
		fclose(fp);

	return true;
}
Пример #30
0
boolean LoadChewingConfig(FcitxChewingConfig* fs)
{
    FcitxConfigFileDesc *configDesc = GetFcitxChewingConfigDesc();
    if (!configDesc)
        return false;

    FILE *fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-chewing.config", "rt", NULL);

    if (!fp) {
        if (errno == ENOENT)
            SaveChewingConfig(fs);
    }
    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);

    FcitxChewingConfigConfigBind(fs, cfile, configDesc);
    FcitxConfigBindSync(&fs->config);

    if (fp)
        fclose(fp);
    return true;
}