Exemplo n.º 1
0
int engine_register(struct engine *engine, const char *name, const char *precedence, const char* ref)
{
	if (engine == NULL || name == NULL) {
		return kr_error(EINVAL);
	}
	/* Make sure module is unloaded */
	(void) engine_unregister(engine, name);
	/* Find the index of referenced module. */
	module_array_t *mod_list = &engine->modules;
	size_t ref_pos = mod_list->len;
	if (precedence && ref) {
		ref_pos = module_find(mod_list, ref);
		if (ref_pos >= mod_list->len) {
			return kr_error(EIDRM);
		}
	}
	/* Attempt to load binary module */
	struct kr_module *module = malloc(sizeof(*module));
	if (!module) {
		return kr_error(ENOMEM);
	}
	module->data = engine;
	int ret = kr_module_load(module, name, NULL);
	/* Load Lua module if not a binary */
	if (ret == kr_error(ENOENT)) {
		ret = ffimodule_register_lua(engine, module, name);
	}
	if (ret != 0) {
		free(module);
		return ret;
	}
	if (array_push(engine->modules, module) < 0) {
		engine_unload(engine, module);
		return kr_error(ENOMEM);
	}
	/* Evaluate precedence operator */
	if (precedence) {
		struct kr_module **arr = mod_list->at;
		size_t emplacement = mod_list->len;
		if (strcasecmp(precedence, ">") == 0) {
			if (ref_pos + 1 < mod_list->len)
				emplacement = ref_pos + 1; /* Insert after target */
		}
		if (strcasecmp(precedence, "<") == 0) {
			emplacement = ref_pos; /* Insert at target */
		}
		/* Move the tail if it has some elements. */
		if (emplacement + 1 < mod_list->len) {
			memmove(&arr[emplacement + 1], &arr[emplacement], sizeof(*arr) * (mod_list->len - (emplacement + 1)));
			arr[emplacement] = module;
		}
	}

	/* Register properties */
	if (module->props || module->config) {
		return register_properties(engine, module);
	}

	return kr_ok();
}
void WaitZarInstance::loadProperties()
{
    //Add our properties to a proplist
    PropertyList proplist;
    proplist.push_back (_waitzar_encoding_prop);
    proplist.push_back (_waitzar_encoding_unicode_prop);
    proplist.push_back (_waitzar_encoding_zawgyi_prop);
    proplist.push_back (_waitzar_encoding_wininnwa_prop);

    //Now, register these properties
    register_properties(proplist);

    //Set tooltips
    _waitzar_encoding_prop.set_tip (_("The encoding of the text WaitZar outputs. Change this only if you know what you're doing."));
    _waitzar_encoding_unicode_prop.set_tip (_("The encoding as defined in Unicode 5.1 and later. The default & recommended option."));
    update_property (_waitzar_encoding_unicode_prop);
    _waitzar_encoding_zawgyi_prop.set_tip (_("The encoding used by the Zawgyi-One font, a popular font on the web which conflicts with Unicode."));
    update_property (_waitzar_encoding_zawgyi_prop);
    _waitzar_encoding_wininnwa_prop.set_tip (_("The encoding used by the Win Innwa font family (inc. Win Kalaw), a popular legacy font which conflicts with ASCII."));
    update_property (_waitzar_encoding_wininnwa_prop);

    //Finally, double-check the label... although this really shouldn't change.
    String newLbl = "";
    int encoding = model->getOutputEncoding();
    if (encoding == ENCODING_UNICODE)
	    newLbl = "UNI";
    else if (encoding == ENCODING_ZAWGYI)
	newLbl = "ZG";
    else if (encoding == ENCODING_WININNWA)
	newLbl = "WI";
    else
	newLbl = "??";
    _waitzar_encoding_prop.set_label (newLbl);
    update_property (_waitzar_encoding_prop);
}
Exemplo n.º 3
0
static void
constructed (GObject *object)
{
	NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_ip6_config_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP6_CONFIG);
	register_properties (NM_IP6_CONFIG (object));
}
Exemplo n.º 4
0
static void
constructed (GObject *object)
{
    NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);

    G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object);

    priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_GENERIC);
    register_properties (NM_DEVICE_GENERIC (object));
}
static void
constructed (GObject *object)
{
	NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH);
	register_properties (NM_DEVICE_OLPC_MESH (object));
}
Exemplo n.º 6
0
static void
constructed (GObject *object)
{
	NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_WIMAX_NSP);
	register_properties (NM_WIMAX_NSP (object));
}
static void
constructed (GObject *object)
{
	NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_INFINIBAND);
	register_properties (NM_DEVICE_INFINIBAND (object));
}
Exemplo n.º 8
0
static void
constructed (GObject *object)
{
	NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRED);
	register_properties (NM_DEVICE_ETHERNET (object));
}
Exemplo n.º 9
0
static void
constructed (GObject *object)
{
	NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_device_vlan_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_VLAN);
	register_properties (NM_DEVICE_VLAN (object));
}
Exemplo n.º 10
0
static void
constructed (GObject *object)
{
	NMAccessPointPrivate *priv;

	G_OBJECT_CLASS (nm_access_point_parent_class)->constructed (object);

	priv = NM_ACCESS_POINT_GET_PRIVATE (object);
	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACCESS_POINT);
	register_properties (NM_ACCESS_POINT (object));
}
Exemplo n.º 11
0
static void
constructed (GObject *object)
{
	NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->constructed (object);

	priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP4_CONFIG);
	register_properties (NM_DHCP4_CONFIG (object));
}
void
CannaInstance::focus_in ()
{
    SCIM_DEBUG_IMENGINE(2) << "focus_in.\n";

    register_properties (m_canna_jrkanji.get_properties ());

    if (m_canna_jrkanji.preedit_string_visible ())
        m_canna_jrkanji.show_preedit_string ();
    if (m_canna_jrkanji.aux_string_visible ())
        m_canna_jrkanji.show_aux_string ();
}
Exemplo n.º 13
0
static void
constructed (GObject *object)
{
	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_device_bt_parent_class)->constructed (object);

	priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
	                                         NM_DBUS_SERVICE,
	                                         nm_object_get_path (NM_OBJECT (object)),
	                                         NM_DBUS_INTERFACE_DEVICE_BLUETOOTH);

	register_properties (NM_DEVICE_BT (object));
}
Exemplo n.º 14
0
static void
constructed (GObject *object)
{
	NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_device_wimax_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIMAX);
	register_properties (NM_DEVICE_WIMAX (object));

	g_signal_connect (object,
	                  "notify::" NM_DEVICE_STATE,
	                  G_CALLBACK (state_changed_cb),
	                  NULL);
}
Exemplo n.º 15
0
void
HangulInstance::register_all_properties()
{
    PropertyList proplist;

    const char* layout_label;
    if (m_factory->m_keyboard_layout == "2") {
	layout_label = _("2bul");
    } else if (m_factory->m_keyboard_layout == "32") {
	layout_label = _("3bul 2bul-shifted");
    } else if (m_factory->m_keyboard_layout == "3f") {
	layout_label = _("3bul Final");
    } else if (m_factory->m_keyboard_layout == "39") {
	layout_label = _("3bul 390");
    } else if (m_factory->m_keyboard_layout == "3s") {
	layout_label = _("3bul No-Shift");
    } else if (m_factory->m_keyboard_layout == "3y") {
	layout_label = _("3bul Yetgeul");
    }
    keyboard_layout.set_label(layout_label);
    proplist.push_back(keyboard_layout);
    proplist.push_back(keyboard_layout_2);
    proplist.push_back(keyboard_layout_32);
    proplist.push_back(keyboard_layout_3f);
    proplist.push_back(keyboard_layout_39);
    proplist.push_back(keyboard_layout_3s);
    proplist.push_back(keyboard_layout_3y);

    if (use_ascii_mode()) {
	if (m_hangul_mode) {
	    hangul_mode.set_label("한");
	} else {
	    hangul_mode.set_label("A");
	}
	proplist.push_back(hangul_mode);
    }

    if (is_hanja_mode()) {
	hanja_mode.set_label("漢");
    } else {
	hanja_mode.set_label("韓");
    }
    proplist.push_back(hanja_mode);

    register_properties(proplist);
}
Exemplo n.º 16
0
static void
constructed (GObject *object)
{
	DBusGConnection *connection;
	NMIP4ConfigPrivate *priv;

	G_OBJECT_CLASS (nm_ip4_config_parent_class)->constructed (object);

	priv = NM_IP4_CONFIG_GET_PRIVATE (object);
	connection = nm_object_get_connection (NM_OBJECT (object));

	priv->proxy = dbus_g_proxy_new_for_name (connection,
										   NM_DBUS_SERVICE,
										   nm_object_get_path (NM_OBJECT (object)),
										   NM_DBUS_INTERFACE_IP4_CONFIG);

	register_properties (NM_IP4_CONFIG (object));
}
Exemplo n.º 17
0
static void
constructed (GObject *object)
{
	DBusGConnection *connection;
	NMDHCP6ConfigPrivate *priv;

	G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructed (object);

	priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
	priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

	connection = nm_object_get_connection (NM_OBJECT (object));

	priv->proxy = dbus_g_proxy_new_for_name (connection,
										   NM_DBUS_SERVICE,
										   nm_object_get_path (NM_OBJECT (object)),
										   NM_DBUS_INTERFACE_DHCP6_CONFIG);

	register_properties (NM_DHCP6_CONFIG (object));
}
static void
constructed (GObject *object)
{
	NMDeviceWifiPrivate *priv;

	G_OBJECT_CLASS (nm_device_wifi_parent_class)->constructed (object);

	priv = NM_DEVICE_WIFI_GET_PRIVATE (object);

	priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
											NM_DBUS_SERVICE,
											nm_object_get_path (NM_OBJECT (object)),
											NM_DBUS_INTERFACE_DEVICE_WIRELESS);

	register_properties (NM_DEVICE_WIFI (object));

	g_signal_connect (NM_DEVICE (object),
	                  "notify::" NM_DEVICE_STATE,
	                  G_CALLBACK (state_changed_cb),
	                  NULL);
}
Exemplo n.º 19
0
static void
constructed (GObject *object)
{
	NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);

	G_OBJECT_CLASS (nm_vpn_connection_parent_class)->constructed (object);

	priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_VPN_CONNECTION);

	dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
	                                   G_TYPE_NONE,
	                                   G_TYPE_UINT, G_TYPE_UINT,
	                                   G_TYPE_INVALID);
	dbus_g_proxy_add_signal (priv->proxy, "VpnStateChanged", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->proxy,
						    "VpnStateChanged",
						    G_CALLBACK (vpn_state_changed_proxy),
						    object,
						    NULL);

	register_properties (NM_VPN_CONNECTION (object));
}
Exemplo n.º 20
0
static void
constructed (GObject *object)
{
	NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
	NMDeviceType type;
	DBusGConnection *connection;
	const char *path, *interface;

	G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object);

	g_object_get (object,
	              NM_OBJECT_DBUS_CONNECTION, &connection,
	              NM_OBJECT_DBUS_PATH, &path,
	              NULL);

	type = _nm_device_type_for_path (connection, path);
	interface = _device_type_to_interface (type);

	if (interface) {
		priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, interface);
		register_properties (NM_DEVICE_GENERIC (object));
	}
}
Exemplo n.º 21
0
void
HangulInstance::register_all_properties()
{
    PropertyList proplist;

    if (use_ascii_mode()) {
	if (m_hangul_mode) {
	    hangul_mode.set_label("한");
	} else {
	    hangul_mode.set_label("A");
	}
	proplist.push_back(hangul_mode);
    }

    if (m_factory->m_hanja_mode) {
	hanja_mode.set_icon(SCIM_HANGUL_ICON_ON);
    } else {
	hanja_mode.set_icon(SCIM_HANGUL_ICON_OFF);
    }
    hanja_mode.set_label(_("Hanja Lock"));
    proplist.push_back(hanja_mode);

    register_properties(proplist);
}
Exemplo n.º 22
0
bool
SocketInstance::do_transaction (Transaction &trans, bool &ret)
{
    int cmd = -1;
    bool cont = false;

    ret = false;

    SCIM_DEBUG_IMENGINE(2) << " Do transaction:\n";

    if (trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY) {
        while (trans.get_command (cmd)) {
            switch (cmd) {
                case SCIM_TRANS_CMD_SHOW_PREEDIT_STRING:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  show_preedit_string ()\n";
                    show_preedit_string ();
                    break;
                }
                case SCIM_TRANS_CMD_SHOW_AUX_STRING:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  show_aux_string ()\n";
                    show_aux_string ();
                    break;
                }
                case SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  show_lookup_table ()\n";
                    show_lookup_table ();
                    break;
                }
                case SCIM_TRANS_CMD_HIDE_PREEDIT_STRING:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  hide_preedit_string ()\n";
                    hide_preedit_string ();
                    break;
                }
                case SCIM_TRANS_CMD_HIDE_AUX_STRING:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  hide_aux_string ()\n";
                    hide_aux_string ();
                    break;
                }
                case SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  hide_lookup_table ()\n";
                    hide_lookup_table ();
                    break;
                }
                case SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET:
                {
                    uint32 caret;
                    if (trans.get_data (caret)) {
                        SCIM_DEBUG_IMENGINE(3) << "  update_preedit_caret (" << caret << ")\n";
                        update_preedit_caret (caret);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING:
                {
                    WideString str;
                    AttributeList attrs;
                    if (trans.get_data (str) && trans.get_data (attrs)) {
                        SCIM_DEBUG_IMENGINE(3) << "  update_preedit_string ()\n";
                        update_preedit_string (str, attrs);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_UPDATE_AUX_STRING:
                {
                    WideString str;
                    AttributeList attrs;
                    if (trans.get_data (str) && trans.get_data (attrs)) {
                        SCIM_DEBUG_IMENGINE(3) << "  update_aux_string ()\n";
                        update_aux_string (str, attrs);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE:
                {
                    CommonLookupTable table;
                    if (trans.get_data (table)) {
                        SCIM_DEBUG_IMENGINE(3) << "  update_lookup_table ()\n";
                        update_lookup_table (table);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_COMMIT_STRING:
                {
                    WideString str;
                    if (trans.get_data (str)) {
                        SCIM_DEBUG_IMENGINE(3) << "  commit_string ()\n";
                        commit_string (str);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_FORWARD_KEY_EVENT:
                {
                    KeyEvent key;
                    if (trans.get_data (key)) {
                        SCIM_DEBUG_IMENGINE(3) << "  forward_key_event ()\n";
                        forward_key_event (key);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_REGISTER_PROPERTIES:
                {
                    PropertyList proplist;
                    if (trans.get_data (proplist)) {
                        SCIM_DEBUG_IMENGINE(3) << "  register_properties ()\n";

                        // Load icon files of these properties from remote SocketFrontEnd.
                        for (PropertyList::iterator it = proplist.begin (); it != proplist.end (); ++it)
                            it->set_icon (global->load_icon (it->get_icon ()));

                        register_properties (proplist);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_UPDATE_PROPERTY:
                {
                    Property prop;
                    if (trans.get_data (prop)) {
                        SCIM_DEBUG_IMENGINE(3) << "  update_property ()\n";

                        // Load the icon file of this property from remote SocketFrontEnd.
                        prop.set_icon (global->load_icon (prop.get_icon ()));

                        update_property (prop);
                    }
                    break;
                }
                case SCIM_TRANS_CMD_BEEP:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  beep ()\n";
                    beep ();
                    break;
                }
                case SCIM_TRANS_CMD_START_HELPER:
                {
                    String helper_uuid;
                    if (trans.get_data (helper_uuid)) {
                        SCIM_DEBUG_IMENGINE(3) << "  start_helper (" << helper_uuid << ")\n";
                        start_helper (helper_uuid);
                    }
                    break; 
                }
                case SCIM_TRANS_CMD_STOP_HELPER:
                {
                    String helper_uuid;
                    if (trans.get_data (helper_uuid)) {
                        SCIM_DEBUG_IMENGINE(3) << "  stop_helper (" << helper_uuid << ")\n";
                        stop_helper (helper_uuid);
                    }
                    break; 
                }
                case SCIM_TRANS_CMD_SEND_HELPER_EVENT:
                {
                    String helper_uuid;
                    Transaction temp_trans;
                    if (trans.get_data (helper_uuid) && trans.get_data (temp_trans)) {
                        SCIM_DEBUG_IMENGINE(3) << "  send_helper_event (" << helper_uuid << ")\n";
                        send_helper_event (helper_uuid, temp_trans);
                    }
                    break; 
                }
                case SCIM_TRANS_CMD_OK:
                {
                    SCIM_DEBUG_IMENGINE(3) << "  ret = true\n";
                    ret = true;
                    break;
                }
                case SCIM_TRANS_CMD_GET_SURROUNDING_TEXT:
                {
                    WideString text;
                    int cursor;
                    uint32 maxlen_before;
                    uint32 maxlen_after;
                    Transaction temp_trans;
                    if (trans.get_data (maxlen_before) && trans.get_data (maxlen_after)) {
                        global->init_transaction (temp_trans);
                        if (get_surrounding_text (text, cursor, (int) maxlen_before, (int) maxlen_after)) {
                            temp_trans.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
                            temp_trans.put_data (text);
                            temp_trans.put_data ((uint32) cursor);
                        } else {
                            temp_trans.put_command (SCIM_TRANS_CMD_FAIL);
                        }
                        global->send_transaction (temp_trans);
                    }
                    cont = true;
                    break;
                }
                case SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT:
                {
                    uint32 offset;
                    uint32 len;
                    Transaction temp_trans;
                    if (trans.get_data (offset) && trans.get_data (len)) {
                        global->init_transaction (temp_trans);
                        if (delete_surrounding_text ((int) offset, (int) len)) {
                            temp_trans.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
                            temp_trans.put_command (SCIM_TRANS_CMD_OK);
                        } else {
                            temp_trans.put_command (SCIM_TRANS_CMD_FAIL);
                        }
                        global->send_transaction (temp_trans);
                    }
                    cont = true;
                    break;
                }
                default:
                    SCIM_DEBUG_IMENGINE(3) << "  Strange cmd: " << cmd << "\n";;
            }
        }
    } else {
        SCIM_DEBUG_IMENGINE(3) << "  Failed to get cmd: " << cmd << "\n";
    }

    SCIM_DEBUG_IMENGINE(2) << " End of Do transaction\n";

    return cont;
}
Exemplo n.º 23
0
void
FilterInstanceBase::filter_register_properties (const PropertyList &properties)
{
    register_properties (properties);
}
Exemplo n.º 24
0
void
ComposeKeyInstance::focus_in ()
{
    register_properties (PropertyList ());
    reset ();
}