Beispiel #1
0
HalDevice *
hal_device_store_match_key_value_int (HalDeviceStore *store,
				      const char *key,
				      int value)
{
	GSList *iter;

	g_return_val_if_fail (store != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);

	for (iter = store->devices; iter != NULL; iter = iter->next) {
		HalDevice *d = HAL_DEVICE (iter->data);
		int type;

		if (!hal_device_has_property (d, key))
			continue;

		type = hal_device_property_get_type (d, key);
		if (type != HAL_PROPERTY_TYPE_INT32)
			continue;

		if (hal_device_property_get_int (d, key) == value)
			return d;
	}

	return NULL;
}
Beispiel #2
0
GSList *
hal_device_store_match_multiple_key_value_string (HalDeviceStore *store,
						  const char *key,
						  const char *value)
{
	GSList *iter;
	GSList *matches = NULL;

	g_return_val_if_fail (store != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	g_return_val_if_fail (value != NULL, NULL);

	for (iter = store->devices; iter != NULL; iter = iter->next) {
		HalDevice *d = HAL_DEVICE (iter->data);
		int type;

		if (!hal_device_has_property (d, key))
			continue;

		type = hal_device_property_get_type (d, key);
		if (type != HAL_PROPERTY_TYPE_STRING)
			continue;

		if (strcmp (hal_device_property_get_string (d, key),
			    value) == 0)
			matches = g_slist_prepend (matches, d);
	}

	return matches;
}
Beispiel #3
0
static void
device_pre_property_changed (HalDevice *device,
			      const char *key,
			      gboolean removed,
			      gpointer data)
{
	HalDeviceStore *store = HAL_DEVICE_STORE (data);

	if (hal_device_property_get_type (device, key) == HAL_PROPERTY_TYPE_STRING) {
		property_index_modify_string(store, device, key, FALSE);
	}
}
Beispiel #4
0
static void
property_index_check_all (HalDeviceStore *store, HalDevice *device, gboolean added)
{
	GList *indexed_properties, *lp;

	indexed_properties = g_hash_table_get_keys (store->property_index);
	for (lp = indexed_properties; lp; lp = g_list_next (lp)) {
		if (hal_device_property_get_type (device, lp->data) == HAL_PROPERTY_TYPE_STRING) {
			property_index_modify_string (store, device, lp->data, added);
		}
	}
	g_list_free (indexed_properties);
}
Beispiel #5
0
static void
emit_device_property_changed (HalDevice *device,
			      const char *key,
			      gboolean added,
			      gboolean removed,
			      gpointer data)
{
	HalDeviceStore *store = HAL_DEVICE_STORE (data);

	if (hal_device_property_get_type (device, key) == HAL_PROPERTY_TYPE_STRING) {
		property_index_modify_string(store, device, key, TRUE);
	}

	g_signal_emit (store, signals[DEVICE_PROPERTY_CHANGED], 0,
		       device, key, added, removed);
}
Beispiel #6
0
HalDevice *
hal_device_store_match_key_value_string (HalDeviceStore *store,
					 const char *key,
					 const char *value)
{
	GSList *iter;
	GSList *devices;
	GHashTable *index;

	g_return_val_if_fail (store != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	g_return_val_if_fail (value != NULL, NULL);

	index = g_hash_table_lookup (store->property_index, key);

	if (index) {
		devices = g_hash_table_lookup (index, value);
		if (devices)
			return (HalDevice*) devices->data;
		else
			return NULL;
	} else {
		for (iter = store->devices; iter != NULL; iter = iter->next) {
			HalDevice *d = HAL_DEVICE (iter->data);
			int type;

			if (!hal_device_has_property (d, key))
				continue;

			type = hal_device_property_get_type (d, key);
			if (type != HAL_PROPERTY_TYPE_STRING)
				continue;

			if (strcmp (hal_device_property_get_string (d, key),
				    value) == 0)
				return d;
		}
	}

	return NULL;
}