@@ -3,7 +3,7 @@ use super::{utils::generate_certificate, ConnectorOptions, IntifaceCLIErrorEnum,
33use super :: frontend:: { self , FrontendPBufChannel } ;
44use argh:: FromArgs ;
55use buttplug:: device:: configuration_manager:: {
6- set_external_device_config , set_user_device_config , DeviceConfigurationManager ,
6+ DeviceConfigurationManager ,
77} ;
88use std:: fs;
99
@@ -85,6 +85,10 @@ struct IntifaceCLIArguments {
8585 #[ allow( dead_code) ]
8686 #[ argh( option) ]
8787 log : Option < String > ,
88+
89+ /// allow raw messages (dangerous, only use for development)
90+ #[ argh( switch) ]
91+ allowraw : bool ,
8892}
8993
9094pub fn check_options_and_pipe ( ) -> Option < FrontendPBufChannel > {
@@ -186,8 +190,9 @@ pub fn parse_options() -> Result<Option<ConnectorOptions>, IntifaceCLIErrorEnum>
186190 ) ;
187191 }
188192
189- connector_info. server_name = args. servername ;
190- connector_info. max_ping_time = args. pingtime ;
193+ connector_info. server_options . name = args. servername ;
194+ connector_info. server_options . max_ping_time = args. pingtime ;
195+ connector_info. server_options . allow_raw_messages = args. allowraw ;
191196
192197 if args. frontendpipe {
193198 info ! ( "Intiface CLI Options: Using frontend pipe" ) ;
@@ -206,20 +211,31 @@ pub fn parse_options() -> Result<Option<ConnectorOptions>, IntifaceCLIErrorEnum>
206211 "Intiface CLI Options: External Device Config {}" ,
207212 deviceconfig
208213 ) ;
209- let cfg = fs:: read_to_string ( deviceconfig) . unwrap ( ) ;
210- set_external_device_config ( Some ( cfg) ) ;
211- // Make an unused DeviceConfigurationManager here, as it'll panic if it's invalid.
212- let _manager = DeviceConfigurationManager :: default ( ) ;
214+ match fs:: read_to_string ( deviceconfig) {
215+ Ok ( cfg ) => connector_info . server_options . device_configuration_json = Some ( cfg) ,
216+ Err ( err ) => panic ! ( "Error opening external device configuration: {:?}" , err )
217+ } ;
213218 }
214219
215220 if let Some ( userdeviceconfig) = & args. userdeviceconfig {
216221 info ! (
217222 "Intiface CLI Options: User Device Config {}" ,
218223 userdeviceconfig
219224 ) ;
220- let cfg = fs:: read_to_string ( userdeviceconfig) . unwrap ( ) ;
221- set_user_device_config ( Some ( cfg) ) ;
222- let _manager = DeviceConfigurationManager :: default ( ) ;
225+ match fs:: read_to_string ( userdeviceconfig) {
226+ Ok ( cfg) => connector_info. server_options . user_device_configuration_json = Some ( cfg) ,
227+ Err ( err) => panic ! ( "Error opening user device configuration: {:?}" , err)
228+ } ;
229+ }
230+
231+ // Make sure we can bring up a DeviceConfigurationManager before handing back
232+ // to the server to start the listener.
233+
234+ if let Err ( err) = DeviceConfigurationManager :: new_with_options (
235+ connector_info. server_options . allow_raw_messages ,
236+ & connector_info. server_options . device_configuration_json ,
237+ & connector_info. server_options . user_device_configuration_json ) {
238+ panic ! ( "Error in creation of Device Configuration Manager: {:?}" , err) ;
223239 }
224240
225241 Ok ( Some ( connector_info) )
0 commit comments