json_object* resp_config = NULL;
json_object* config = NULL;
+typedef struct {
+ int available_images;
+ int downloaded_images;
+ int complete_scanned;
+} scan_status;
+
+scan_status current_scan_status;
+
void _write_string_value(json_object* value_object, void* value)
{
const char* string_value = json_object_get_string(value_object);
resp = kds_s2000w_client_response_init();
kds_s2000w_client_start_scan(state->sessionid, resp);
kds_s2000w_client_response_free(resp);
+ current_scan_status.available_images = 0;
+ current_scan_status.downloaded_images = 0;
+ current_scan_status.complete_scanned = 0;
resp = NULL;
}
json_object* metadata = NULL;
json_object* mdata_value = NULL;
int channels = 1;
- int status_image_number = 0;
- resp = kds_s2000w_client_response_init();
- kds_s2000w_client_status_session(state->sessionid, resp);
- metadataResp = json_tokener_parse(resp->data);
- metadata = json_object_object_get(metadataResp, "Status");
- mdata_value = json_object_object_get(metadata, "NumImagesScanned");
- status_image_number = json_object_get_int(mdata_value);
- kds_s2000w_client_response_free(resp);
- resp = NULL;
+ if (!current_scan_status.complete_scanned) {
+ resp = kds_s2000w_client_response_init();
+ kds_s2000w_client_status_session(state->sessionid, resp);
+ metadataResp = json_tokener_parse(resp->data);
+ metadata = json_object_object_get(metadataResp, "Status");
+ mdata_value = json_object_object_get(metadata, "NumImagesScanned");
+ current_scan_status.available_images = json_object_get_int(mdata_value);
+ mdata_value = NULL;
+ mdata_value = json_object_object_get(metadata, "State");
+ const char* scanner_state = json_object_get_string(mdata_value);
+ if (strcmp(scanner_state, "Scanning") != 0)
+ current_scan_status.complete_scanned = 1;
+
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
+ }
- if (status_image_number < image_number) {
+ printf("current available images: %i\n", current_scan_status.available_images);
+ printf("current downloaded images: %i\n", current_scan_status.downloaded_images);
+ printf("complete_scanned: %i\n", current_scan_status.complete_scanned);
+ if (current_scan_status.available_images < image_number) {
mdata_value = NULL;
metadata = NULL;
json_object_put(metadataResp);