mirror of
				https://git.kernel.org/pub/scm/network/wireless/iwd.git
				synced 2025-10-31 04:57:25 +01:00 
			
		
		
		
	client: Add proxy property handlers
This commit is contained in:
		
							parent
							
								
									dc3b17f496
								
							
						
					
					
						commit
						5e3a8bcd9d
					
				| @ -43,10 +43,53 @@ static struct l_dbus *dbus; | ||||
| static struct l_queue *proxy_interfaces; | ||||
| static struct l_queue *proxy_interface_types; | ||||
| 
 | ||||
| static void proxy_interface_property_set(struct proxy_interface *proxy, | ||||
| 					const char *name, | ||||
| 					struct l_dbus_message_iter *variant) | ||||
| { | ||||
| 	size_t i; | ||||
| 	const void *value; | ||||
| 	const struct proxy_interface_property *property_table = | ||||
| 							proxy->type->properties; | ||||
| 
 | ||||
| 	for (i = 0; property_table[i].name; i++) { | ||||
| 		if (strcmp(property_table[i].name, name)) | ||||
| 			continue; | ||||
| 
 | ||||
| 		if (!property_table[i].set) | ||||
| 			return; | ||||
| 
 | ||||
| 		if (variant) | ||||
| 			l_dbus_message_iter_get_variant(variant, | ||||
| 						property_table[i].type, | ||||
| 						&value); | ||||
| 		else | ||||
| 			value = NULL; | ||||
| 
 | ||||
| 		property_table[i].set(proxy->data, value); | ||||
| 
 | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	l_debug("Unknown property name: %s for interface %s", name, | ||||
| 							proxy->type->interface); | ||||
| } | ||||
| 
 | ||||
| static void interface_update_properties(struct proxy_interface *proxy, | ||||
| 					struct l_dbus_message_iter *changed, | ||||
| 					struct l_dbus_message_iter *invalidated) | ||||
| { | ||||
| 	const char *name; | ||||
| 	struct l_dbus_message_iter variant; | ||||
| 
 | ||||
| 	while (l_dbus_message_iter_next_entry(changed, &name, &variant)) | ||||
| 		proxy_interface_property_set(proxy, name, &variant); | ||||
| 
 | ||||
| 	if (!invalidated) | ||||
| 		return; | ||||
| 
 | ||||
| 	while (l_dbus_message_iter_next_entry(invalidated, &name)) | ||||
| 		proxy_interface_property_set(proxy, name, NULL); | ||||
| } | ||||
| 
 | ||||
| static bool dbus_message_has_error(struct l_dbus_message *message) | ||||
|  | ||||
| @ -22,6 +22,12 @@ | ||||
| 
 | ||||
| struct proxy_interface; | ||||
| 
 | ||||
| struct proxy_interface_property { | ||||
| 	const char *name; | ||||
| 	const char *type; | ||||
| 	void (*set)(void *data, const void *value); | ||||
| }; | ||||
| 
 | ||||
| struct proxy_interface_type_ops { | ||||
| 	void *(*create)(void); | ||||
| 	void (*destroy)(void *data); | ||||
| @ -29,6 +35,7 @@ struct proxy_interface_type_ops { | ||||
| 
 | ||||
| struct proxy_interface_type { | ||||
| 	const char *interface; | ||||
| 	const struct proxy_interface_property *properties; | ||||
| 	const struct proxy_interface_type_ops *ops; | ||||
| }; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tim Kourt
						Tim Kourt