Esempio n. 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;
}
Esempio n. 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;
}
Esempio n. 3
0
static void
store_changed (HalDeviceStore *store, HalDevice *device,
	       gboolean added, gpointer user_data)
{
	AsyncMatchInfo *info = (AsyncMatchInfo *) user_data;

	if (!added)
		return;

	if (!hal_device_has_property (device, info->key))
		return;

	if (strcmp (hal_device_property_get_string (device, info->key),
		    info->value) != 0)
		return;

	info->callback (store, device, info->user_data);

	destroy_async_match_info (info);
}
Esempio n. 4
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;
}