Beispiel #1
0
uim_agent_context *
create_uim_agent_context(const char *encoding)
{

  uim_agent_context *ret;
  const char *im;

  debug_printf(DEBUG_NOTE, "create_uim_agent_context\n");

  ret = uim_malloc(sizeof(uim_agent_context));

  if (encoding) {
	ret->encoding = uim_strdup(encoding);
  } else {
	if (debug_level > 0)
	  ret->encoding = uim_strdup("EUC-JP");
	else
	  ret->encoding = uim_strdup("UTF-8");
  }

  ret->context = create_context(ret->encoding, ret);

  if ((im = uim_get_default_im_name(setlocale(LC_CTYPE, NULL))))
	ret->im = uim_strdup(im);
  else
	ret->im = NULL;

  ret->pe = create_preedit();
  ret->cand = create_candidate();
  ret->prop = create_prop();

  ret->comstr = (char *)NULL;

  return ret;
}
Beispiel #2
0
QPlatformInputContext *UimInputContextPlugin::create( const QString & key, const QStringList & paramList )
#endif
{
#if QT_VERSION >= 0x050000
    Q_UNUSED(paramList);
#endif
    QString imname;

#if UIM_QT_LIST_SUBIM_AS_QTIM
    if ( key.startsWith( QLatin1String( "uim-" ) ) )
        imname = key.mid( 4 );
    else
#endif
    if ( key == "uim" )
        imname = uim_get_default_im_name( setlocale( LC_CTYPE, 0 ) );

#if QT_VERSION < 0x050000
    QUimInputContext *uic = new QUimInputContext( imname.toUtf8().data() );
#else
    QUimPlatformInputContext *uic
        = new QUimPlatformInputContext( imname.toUtf8().data() );
#endif

    return uic;
}
Beispiel #3
0
const char *
get_imlist(const char *args)
{
    int i, nr;
    uim_context uc;

    if (!vp_iobuf_get_args(iobuf, args, ""))
        return vp_iobuf_return(iobuf);

    uc = uim_create_context(NULL, "UTF-8", NULL, NULL, NULL, NULL);
    if (uc == NULL)
        return "uim_create_context error";

    /* [method, langs, desc, is_default] */
    nr = uim_get_nr_im(uc);
    for (i = 0; i < nr; ++i) {
        vp_iobuf_put_str(iobuf, uim_get_im_name(uc, i));
        vp_iobuf_put_str(iobuf, uim_get_im_language(uc, i));
        vp_iobuf_put_str(iobuf, uim_get_im_short_desc(uc, i));
        vp_iobuf_put_num(iobuf, (strcmp(uim_get_im_name(uc, i),
                                        uim_get_default_im_name("")) == 0));
    }

    uim_release_context(uc);

    return vp_iobuf_return(iobuf);
}
Beispiel #4
0
static void check_default_engine(const char *locale)
{
    bool found = false;
    if (default_engine) {
	std::list<UIMInfo>::iterator it;
	for (it = uim_info.begin(); it != uim_info.end(); ++it) {
	    if (!strcmp(it->name, default_engine)) {
		found = true;
		break;
	    }
	}
    }

    if (found == false)
	default_engine = uim_get_default_im_name(locale);
}
Beispiel #5
0
void
InputContext::createUimContext(const char *engine)
{
    char *locale;
    const char *client_locale, *engine_locales;
    const char *encoding;
    const char *real_im;

    encoding = mXic->get_encoding();
    client_locale = mXic->get_lang_region();
    engine_locales = compose_localenames_from_im_lang(get_im_lang_from_engine(engine));

    if (!strcmp(encoding, "UTF-8")) {
	real_im = engine;
	if (is_locale_included(engine_locales, client_locale))
	    locale = strdup(client_locale);
	else {
	    locale = get_prefered_locale(engine_locales);
	}
    } else {
	// Use default engine for corresponding encoding of the client
	// unless encoding matches with selected engine.
	if (!is_locale_included(engine_locales, client_locale)) {
	    const char *test_im = uim_get_default_im_name(client_locale);
	    const char *test_im_lang = get_im_lang_from_engine(test_im);
	    const char *test_im_locales = compose_localenames_from_im_lang(test_im_lang);
	    if (is_locale_included(test_im_locales, client_locale))
		real_im = test_im;
	    else
		real_im = uim_get_im_name_for_locale(client_locale);

	} else
	    real_im = engine;

	locale = strdup(client_locale);
    }

    locale = (char *)realloc(locale, strlen(locale) + strlen(encoding) + 2);
    strcat(locale, ".");
    strcat(locale, encoding);

    setlocale(LC_CTYPE, locale);

    free(mLocaleName);
    mLocaleName = locale;

    if (mEngineName != real_im) {
      free(mEngineName);
      mEngineName = strdup(real_im);
    }

    uim_context uc = uim_create_context((void *) this, "UTF-8",
					NULL, real_im, NULL,
					InputContext::commit_cb);

    if (uc) {
	uim_set_preedit_cb(uc,
			InputContext::clear_cb,
			InputContext::pushback_cb,
			InputContext::update_cb);
	uim_set_candidate_selector_cb(uc,
			InputContext::candidate_activate_cb,
			InputContext::candidate_select_cb,
			InputContext::candidate_shift_page_cb,
			InputContext::candidate_deactivate_cb);
	uim_set_prop_list_update_cb(uc,
			InputContext::update_prop_list_cb);
#if 0
	uim_set_prop_label_update_cb(uc,
			InputContext::update_prop_label_cb);
#endif
	uim_set_configuration_changed_cb(uc,
			InputContext::configuration_changed_cb);
	uim_set_im_switch_request_cb(uc,
			InputContext::switch_app_global_im_cb,
			InputContext::switch_system_global_im_cb);
#if UIM_XIM_USE_DELAY
	uim_set_delay_candidate_selector_cb(uc,
			InputContext::candidate_activate_with_delay_cb);
#endif

	if (mFocusedContext == this)
	    uim_prop_list_update(uc);
    }
    mUc = uc;
}