sanei_usb: Allow backends to modify when USB recording is cleared

merge-requests/392/head
Povilas Kanapickas 2020-04-09 00:47:41 +03:00
rodzic ee7f913974
commit e9d2cdf67b
2 zmienionych plików z 30 dodań i 0 usunięć

Wyświetl plik

@ -224,6 +224,19 @@ extern SANE_String sanei_usb_testing_get_backend();
*/
extern SANE_Bool sanei_usb_is_replay_mode_enabled();
/** Clears currently recorded data.
This is useful on certain backends to clear the currently recorded data if it relates to
other devices than the one that the scan will be performed on. On these backends all
devices that the backend supports are opened multiple times. Recording this interaction
to XML file makes it impossible to replay it, as the existence of these devices is not mocked
currently.
This function may only be called when no USB devices are open, otherwise the behavior is
unpredictable.
*/
extern void sanei_usb_testing_record_clear();
/** Records a debug message in the captured USB data if testing mode is enabled. If testing mode
* is not enabled, this function does nothing.
*

Wyświetl plik

@ -1124,6 +1124,19 @@ static void sanei_usb_replay_debug_msg(SANE_String_Const message)
}
}
extern void sanei_usb_testing_record_clear()
{
if (testing_mode != sanei_usb_testing_mode_record)
return;
// we only need to indicate that we never opened a device and sanei_usb_record_open() will
// reinitialize everything for us.
testing_already_opened = 0;
testing_known_commands_input_failed = 0;
testing_last_known_seq = 0;
testing_append_commands_node = NULL;
}
extern void sanei_usb_testing_record_message(SANE_String_Const message)
{
if (testing_mode == sanei_usb_testing_mode_record)
@ -1356,6 +1369,10 @@ SANE_Bool sanei_usb_is_replay_mode_enabled()
return SANE_FALSE;
}
void sanei_usb_testing_record_clear()
{
}
void sanei_usb_testing_record_message(SANE_String_Const message)
{
(void) message;