mirror of
				https://git.kernel.org/pub/scm/network/wireless/iwd.git
				synced 2025-10-29 19:17:31 +01:00 
			
		
		
		
	manager: Add manager skeleton
This commit is contained in:
		
							parent
							
								
									5bea86e47b
								
							
						
					
					
						commit
						09c29ba3e2
					
				| @ -45,7 +45,8 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h linux/kdbus.h \ | ||||
| 					src/wiphy.h src/wiphy.c \
 | ||||
| 					src/sha1.h src/sha1.c \
 | ||||
| 					src/ie.h src/ie.c \
 | ||||
| 					src/dbus.h src/dbus.c | ||||
| 					src/dbus.h src/dbus.c \
 | ||||
| 					src/manager.h src/manager.c | ||||
| src_iwd_LDADD = ell/libell-internal.la | ||||
| 
 | ||||
| client_iwctl_SOURCES = client/main.c linux/kdbus.h \
 | ||||
|  | ||||
| @ -26,6 +26,7 @@ | ||||
| 
 | ||||
| #include <ell/ell.h> | ||||
| #include "src/dbus.h" | ||||
| #include "src/manager.h" | ||||
| 
 | ||||
| struct l_dbus *g_dbus = 0; | ||||
| 
 | ||||
| @ -64,6 +65,7 @@ static void request_name_setup(struct l_dbus_message *message, void *user_data) | ||||
| static void ready_callback(void *user_data) | ||||
| { | ||||
| 	l_info("ready"); | ||||
| 	manager_init(g_dbus); | ||||
| } | ||||
| 
 | ||||
| static void disconnect_callback(void *user_data) | ||||
| @ -95,6 +97,7 @@ bool dbus_init(void) | ||||
| 
 | ||||
| bool dbus_exit(void) | ||||
| { | ||||
| 	manager_exit(g_dbus); | ||||
| 	l_dbus_destroy(g_dbus); | ||||
| 	g_dbus = NULL; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										90
									
								
								src/manager.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								src/manager.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,90 @@ | ||||
| /*
 | ||||
|  * | ||||
|  *  Wireless daemon for Linux | ||||
|  * | ||||
|  *  Copyright (C) 2013-2014  Intel Corporation. All rights reserved. | ||||
|  * | ||||
|  *  This library is free software; you can redistribute it and/or | ||||
|  *  modify it under the terms of the GNU Lesser General Public | ||||
|  *  License as published by the Free Software Foundation; either | ||||
|  *  version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  *  This library is distributed in the hope that it will be useful, | ||||
|  *  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  *  Lesser General Public License for more details. | ||||
|  * | ||||
|  *  You should have received a copy of the GNU Lesser General Public | ||||
|  *  License along with this library; if not, write to the Free Software | ||||
|  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| #ifdef HAVE_CONFIG_H | ||||
| #include <config.h> | ||||
| #endif | ||||
| 
 | ||||
| #include <ell/ell.h> | ||||
| #include "src/manager.h" | ||||
| 
 | ||||
| #define IWD_MANAGER_INTERFACE "net.connman.iwd.Manager" | ||||
| 
 | ||||
| static struct l_dbus_message *manager_set_property(struct l_dbus *dbus, | ||||
| 						struct l_dbus_message *message, | ||||
| 						void *user_data) | ||||
| { | ||||
| 	const char *property; | ||||
| 	struct l_dbus_message_iter variant; | ||||
| 
 | ||||
| 	if (!l_dbus_message_get_arguments(message, "sv", &property, &variant)) | ||||
| 		return l_dbus_message_new_error(message, | ||||
| 						"org.test.InvalidArguments", | ||||
| 						"Invalid arguments"); | ||||
| 
 | ||||
| 	return l_dbus_message_new_error(message, "org.test.InvalidArguments", | ||||
| 					"Unknown Property %s", property); | ||||
| } | ||||
| 
 | ||||
| static struct l_dbus_message *manager_get_properties(struct l_dbus *dbus, | ||||
| 						struct l_dbus_message *message, | ||||
| 						void *user_data) | ||||
| { | ||||
| 	struct l_dbus_message *reply; | ||||
| 
 | ||||
| 	reply = l_dbus_message_new_method_return(message); | ||||
| 	l_dbus_message_set_arguments(reply, "a{sv}", 0); | ||||
| 
 | ||||
| 	return reply; | ||||
| } | ||||
| 
 | ||||
| static void setup_manager_interface(struct l_dbus_interface *interface) | ||||
| { | ||||
| 	l_dbus_interface_method(interface, "GetProperties", 0, | ||||
| 				manager_get_properties, | ||||
| 				"a{sv}", "", "properties"); | ||||
| 	l_dbus_interface_method(interface, "SetProperty", 0, | ||||
| 				manager_set_property, | ||||
| 				"", "sv", "name", "value"); | ||||
| 
 | ||||
| 	l_dbus_interface_signal(interface, "PropertyChanged", 0, | ||||
| 				"sv", "name", "value"); | ||||
| } | ||||
| 
 | ||||
| bool manager_init(struct l_dbus *dbus) | ||||
| { | ||||
| 	if (!l_dbus_register_interface(dbus, "/", IWD_MANAGER_INTERFACE, | ||||
| 					setup_manager_interface, NULL, NULL)) { | ||||
| 		l_info("Unable to register %s interface", | ||||
| 				IWD_MANAGER_INTERFACE); | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| bool manager_exit(struct l_dbus *dbus) | ||||
| { | ||||
| 	l_dbus_unregister_interface(dbus, "/", IWD_MANAGER_INTERFACE); | ||||
| 
 | ||||
| 	return true; | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/manager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/manager.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| /*
 | ||||
|  * | ||||
|  *  Wireless daemon for Linux | ||||
|  * | ||||
|  *  Copyright (C) 2013-2014  Intel Corporation. All rights reserved. | ||||
|  * | ||||
|  *  This library is free software; you can redistribute it and/or | ||||
|  *  modify it under the terms of the GNU Lesser General Public | ||||
|  *  License as published by the Free Software Foundation; either | ||||
|  *  version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  *  This library is distributed in the hope that it will be useful, | ||||
|  *  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  *  Lesser General Public License for more details. | ||||
|  * | ||||
|  *  You should have received a copy of the GNU Lesser General Public | ||||
|  *  License along with this library; if not, write to the Free Software | ||||
|  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| #include <stdbool.h> | ||||
| 
 | ||||
| bool manager_init(struct l_dbus *dbus); | ||||
| bool manager_exit(struct l_dbus *dbus); | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Denis Kenzior
						Denis Kenzior