56 gchar *presetname = g_strdup(preset_name);
57 gchar *filename = g_strdup_printf(
"%s/%s.dtpreset", filedir, g_strdelimit(presetname,
"/<>:\"\\|*?[]",
'_'));
63 "SELECT op_params, blendop_params, name, description, operation,"
64 " autoapply, model, maker, lens, iso_min, iso_max, exposure_min,"
65 " exposure_max, aperture_min, aperture_max, focal_length_min,"
66 " focal_length_max, op_version, blendop_version, enabled,"
67 " multi_priority, multi_name, filter, def, format "
74 if(sqlite3_step(stmt) == SQLITE_ROW)
76 const gchar *
name = (gchar *)sqlite3_column_text(stmt, 2);
77 const gchar *
description = (gchar *)sqlite3_column_text(stmt, 3);
78 const gchar *operation = (gchar *)sqlite3_column_text(stmt, 4);
79 const int autoapply = sqlite3_column_int(stmt, 5);
80 const gchar *
model = (gchar *)sqlite3_column_text(stmt, 6);
81 const gchar *
maker = (gchar *)sqlite3_column_text(stmt, 7);
82 const gchar *lens = (gchar *)sqlite3_column_text(stmt, 8);
83 const float iso_min = sqlite3_column_double(stmt, 9);
84 const float iso_max = sqlite3_column_double(stmt, 10);
85 const float exposure_min = sqlite3_column_double(stmt, 11);
86 const float exposure_max = sqlite3_column_double(stmt, 12);
87 const float aperture_min = sqlite3_column_double(stmt, 13);
88 const float aperture_max = sqlite3_column_double(stmt, 14);
89 const int focal_length_min = sqlite3_column_double(stmt, 15);
90 const int focal_length_max = sqlite3_column_double(stmt, 16);
91 const int op_version = sqlite3_column_int(stmt, 17);
92 const int blendop_version = sqlite3_column_int(stmt, 18);
93 const int enabled = sqlite3_column_int(stmt, 19);
94 const int multi_priority = sqlite3_column_int(stmt, 20);
95 const gchar *multi_name = (gchar *)sqlite3_column_text(stmt, 21);
96 const int filter = sqlite3_column_double(stmt, 22);
97 const int def = sqlite3_column_double(stmt, 23);
98 const int format = sqlite3_column_double(stmt, 24);
102 xmlTextWriterPtr writer = xmlNewTextWriterFilename(filename, 0);
106 fprintf(stderr,
"[dt_presets_save_to_file] Error creating the xml writer\n, path: %s", filename);
111 rc = xmlTextWriterStartDocument(writer, NULL,
"UTF-8", NULL);
114 fprintf(stderr,
"[dt_presets_save_to_file]: Error on encoding setting");
119 xmlTextWriterStartElement(writer, BAD_CAST
"darktable_preset");
120 xmlTextWriterWriteAttribute(writer, BAD_CAST
"version", BAD_CAST
"1.0");
122 xmlTextWriterStartElement(writer, BAD_CAST
"preset");
123 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"name",
"%s",
name);
124 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"description",
"%s",
description);
125 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"operation",
"%s", operation);
126 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"op_params",
"%s",
dt_preset_encode(stmt, 0));
127 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"op_version",
"%d", op_version);
128 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"enabled",
"%d", enabled);
129 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"autoapply",
"%d", autoapply);
130 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"model",
"%s",
model);
131 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"maker",
"%s",
maker);
132 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"lens",
"%s", lens);
133 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"iso_min",
"%f",
iso_min);
134 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"iso_max",
"%f",
iso_max);
135 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"exposure_min",
"%f", exposure_min);
136 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"exposure_max",
"%f", exposure_max);
137 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"aperture_min",
"%f", aperture_min);
138 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"aperture_max",
"%f", aperture_max);
139 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"focal_length_min",
"%d", focal_length_min);
140 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"focal_length_max",
"%d", focal_length_max);
141 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"blendop_params",
"%s",
dt_preset_encode(stmt, 1));
142 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"blendop_version",
"%d", blendop_version);
143 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"multi_priority",
"%d", multi_priority);
144 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"multi_name",
"%s", multi_name);
145 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"filter",
"%d", filter);
146 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"def",
"%d", def);
147 xmlTextWriterWriteFormatElement(writer, BAD_CAST
"format",
"%d", format);
148 xmlTextWriterEndElement(writer);
150 sqlite3_finalize(stmt);
151 xmlTextWriterEndDocument(writer);
152 xmlFreeTextWriter(writer);
207 xmlDocPtr doc = xmlParseFile(preset_path);
211 xmlNodePtr root = xmlDocGetRootElement(doc);
212 if(
IS_NULL_PTR(root) || xmlStrcmp(root->name, BAD_CAST
"darktable_preset") != 0)
245 int blendop_params_len = 0;
247 (blendop_params, strlen(blendop_params), &blendop_params_len);
249 int op_params_len = 0;
251 (op_params, strlen(op_params), &op_params_len);
260 " (name, description, operation, autoapply,"
261 " model, maker, lens, iso_min, iso_max, exposure_min, exposure_max,"
262 " aperture_min, aperture_max, focal_length_min, focal_length_max,"
263 " op_params, op_version, blendop_params, blendop_version, enabled,"
264 " multi_priority, multi_name, filter, def, format, writeprotect)"
265 " VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, "
266 " ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, 0)",
296 result = (sqlite3_step(stmt) == SQLITE_DONE);
298 sqlite3_finalize(stmt);