20#include <glib/gstdio.h>
34#define DT_FOLDER_SURVEY_STATE_FILE "folder-survey-state.ini"
105 const char *path = (
const char *)
key;
131 return success ? 0 : 1;
218 fprintf(
stderr,
"[folder survey] failed to enumerate folder: %s\n",
437 "Folder survey found %d new images to import.", elements),
454 .folder_survey =
TRUE,
460 .target_subfolder_pattern =
dt_conf_get_string(
"studio_capture/sub_directory_pattern"),
463 .elements = elements,
467 .callback_data_free =
NULL };
616 && file_pattern[0] !=
'\0';
637 .folder_survey =
TRUE,
639 .base_folder =
g_strdup(base_folder),
641 .target_file_pattern =
g_strdup(file_pattern),
699 *message =
_(
"The folder to survey does not exist.");
704 *message =
_(
"The folder to survey is not readable.");
712 *message =
_(
"The project date is invalid.");
721 *message =
_(
"The base directory does not exist.");
726 *message =
_(
"The base directory is not writable.");
733 *message =
_(
"The project directory naming pattern is empty.");
737 if(
IS_NULL_PTR(file_pattern) || file_pattern[0] ==
'\0')
739 *message =
_(
"The file naming pattern is empty.");
755 *message =
_(
"The base directory destination cannot be inside the surveyed folder.");
762 *message =
_(
"The configured destination path is invalid.");
832 "[folder_survey] %d new file(s) pending, but no handler to ask about importing them\n",
860 const char *message =
NULL;
964 gpointer path =
NULL;
1005 gpointer path =
NULL;
static void error(char *msg)
int dt_conf_get_bool(const char *name)
gchar * dt_conf_get_string(const char *name)
Read the stored string for name as a private copy.
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
void dt_conf_set_string(const char *name, const char *val)
const char * dt_conf_get_string_const(const char *name)
Borrow the stored string for name without copying it.
void dt_image_init(dt_image_t *img)
void dt_control_log(const char *msg,...)
struct dt_control_t * dt_control_get_global(void)
struct dt_view_manager_t * dt_view_manager_get_global(void)
void * dt_alloc_align(size_t size)
Allocate cacheline-aligned memory.
GDateTime * dt_string_to_datetime(const char *string)
gboolean dt_datetime_entry_to_exif(char *exif, const size_t exif_size, const char *entry)
#define DT_DATETIME_LENGTH
GHashTable * names
GtkWidget* -> the name the application knows it by.
GtkWidget * preview
what the selected row actually captures
GtkWidget * folder
destination folder chooser
GtkWidget * view
the tree view
static int dt_pthread_mutex_unlock(dt_pthread_mutex_t *mutex) RELEASE(mutex) NO_THREAD_SAFETY_ANALYSIS
static int dt_pthread_mutex_init(dt_pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr)
Initialise a mutex. With mutexattr NULL – which is how 54 of the 56 call sites in this tree spell it ...
static int dt_pthread_mutex_destroy(dt_pthread_mutex_t *mutex)
static int dt_pthread_mutex_lock(dt_pthread_mutex_t *mutex) ACQUIRE(mutex) NO_THREAD_SAFETY_ANALYSIS
void dt_loc_get_user_config_dir(char *configdir, size_t bufsize)
static void _folder_survey_job_cleanup(void *data)
Release one scan job and allow the next periodic scan to start.
static gboolean _folder_survey_scan(gpointer user_data)
Queue one background scan without overlapping the previous scan.
static void _folder_survey_imported(const char *source, const gboolean success, gpointer user_data)
Update one persisted entry when its asynchronous import completes.
static int32_t _folder_survey_job_run(dt_job_t *job)
Compare the current directory contents with the prior survey loop.
static void _folder_survey_reschedule()
Recreate the periodic source after a frequency or state change.
dt_folder_survey_file_state_t
@ DT_FOLDER_SURVEY_FILE_QUEUED
@ DT_FOLDER_SURVEY_FILE_PENDING
@ DT_FOLDER_SURVEY_FILE_DONE
int dt_folder_survey_start()
Validate the persisted configuration and start monitoring.
void dt_folder_survey_cleanup()
Release folder survey state after control workers have stopped.
gboolean dt_folder_survey_session_was_active()
TRUE when the previous application session quit while monitoring.
char * dt_folder_survey_destination_preview()
Build the expanded destination path of a sample file from the current configuration,...
static dt_folder_survey_t _folder_survey
gboolean dt_folder_survey_is_active()
TRUE while the periodic folder scan is running.
static gboolean _folder_survey_scan_once(gpointer user_data)
Run the immediate post-configuration scan only once.
static dt_folder_survey_confirm_import_handler_t _confirm_import_handler
#define DT_FOLDER_SURVEY_STATE_FILE
void dt_folder_survey_stop()
Stop new scans before control workers begin shutting down.
static void _folder_survey_offer_pending_import()
void dt_folder_survey_forget_session()
Persist the cleared session marker, so resume is not proposed again.
void dt_folder_survey_absorb_new_files()
Record every file currently in the surveyed folder as already handled, so restarting the survey will ...
static int _folder_survey_collect(const char *folder, GHashTable *observed)
Recursively collect supported images and their stability metadata.
gboolean dt_folder_survey_can_start(const char **message)
Check, without any side effect, whether the persisted configuration has everything dt_folder_survey_s...
static int _folder_survey_save_locked()
Persist the complete survey baseline while the survey lock is held.
gboolean dt_folder_survey_take_session_marker()
Consume the "a session was monitoring when we last closed" marker.
void dt_folder_survey_init()
Initialize the folder survey state from the persisted configuration.
static GList * _folder_survey_styles_for_import()
Read the ordered auto-apply style list from conf.
void dt_folder_survey_halt()
User-requested stop: end monitoring and clear the persisted session marker so the next application st...
void dt_folder_survey_set_confirm_import_handler(dt_folder_survey_confirm_import_handler_t handler)
static void _folder_survey_deactivate()
Stop periodic scans without discarding the persisted comparison state.
static int _folder_survey_load_locked()
Load the previous file list and convert interrupted imports to retries.
int dt_folder_survey_count_new_files()
Count files in the surveyed folder that are unknown to the persisted baseline, i.e....
#define DT_FOLDER_SURVEY_STYLES_SEPARATOR
gboolean(* dt_folder_survey_confirm_import_handler_t)(int new_files)
#define DT_FOLDER_SURVEY_STYLES_CONF_KEY
gboolean dt_supported_image(const gchar *filename)
gchar * dt_build_filename_from_pattern(const char *const filename, const int index, dt_image_t *img, dt_control_import_t *data)
Build a full path for a given image file, given a pattern.
int dt_control_import(dt_control_import_t data)
Process a list of images to import with or without copying the files on an arbitrary hard-drive.
void dt_control_import_data_free(dt_control_import_t *data)
@ DT_IMPORT_ONCONFLICT_UNIQUE
@ DT_IMPORT_ONCONFLICT_SKIP
dt_job_t * dt_control_job_create(dt_job_execute_callback execute, const char *msg,...)
int dt_control_add_job(dt_control_t *control, dt_job_queue_t queue_id, _dt_job_t *job)
void * dt_control_job_get_params(const _dt_job_t *job)
void dt_control_job_set_params(_dt_job_t *job, void *params, dt_job_destroy_callback callback)
static const dt_iop_drawlayer_params_t * params
_lib_location_type_t type
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
static void dt_free_gpointer(gpointer ptr)
g_free() one pointer, with the signature GDestroyNotify wants.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
struct dt_control_signal_t * dt_control_signal_get_global(void)
@ DT_SIGNAL_FOLDER_SURVEY_CHANGED
Raised when the folder survey starts or stops monitoring. no param, no returned value.
static const dt_aligned_pixel_simd_t value
const float uint32_t state[4]
dt_folder_survey_file_state_t state
gboolean baseline_initialized
gboolean was_active_last_session
gboolean dt_util_test_writable_dir(const char *path)
const dt_view_t * dt_view_manager_get_current_view(dt_view_manager_t *vm)