71 return _(
"send as email");
75 const size_t old_params_size,
const int old_version,
const int new_version,
78 if(old_version == 1 && new_version == 2)
80 typedef struct dt_imageio_email_v1_t
84 } dt_imageio_email_v1_t;
87 dt_imageio_email_v1_t *o = (dt_imageio_email_v1_t *)old_params;
89 g_strlcpy(
n->filename, o->filename,
sizeof(
n->filename));
91 *new_size = self->params_size(self);
120 const gboolean high_quality,
const gboolean upscale,
const gboolean export_masks,
127 attachment->
imgid = imgid;
134 gboolean from_cache =
FALSE;
136 gchar *filename = g_path_get_basename(dirname);
138 g_strlcpy(dirname, filename,
sizeof(dirname));
142 gchar *end = g_strrstr(dirname,
".") + 1;
146 g_strlcat(dirname, format->extension(fdata),
sizeof(dirname));
150 attachment->
file = g_build_filename(tmpdir, dirname, (
char *)NULL);
153 icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
155 fprintf(stderr,
"[imageio_storage_email] could not export to file: `%s'!\n", attachment->
file);
163 dt_control_log(ngettext(
"%d/%d exported to `%s'",
"%d/%d exported to `%s'", num),
164 num, total, attachment->
file);
169 d->images = g_list_append(
d->images, attachment);
193 if(
size != self->params_size(self))
return 1;
207 const gchar *imageBodyFormat =
" - %s (%s)\\n";
208 const gint nb_images = g_list_length(
d->images);
209 const gint argc = 5 + (2 * nb_images);
211 char **argv = g_malloc0(
sizeof(
char *) * (argc + 1));
215 argv[0] =
"xdg-email";
216 argv[1] =
"--subject";
217 argv[2] = _(
"images exported from Ansel");
221 for(GList *iter =
d->images; iter; iter = g_list_next(iter))
223 gchar exif[256] = { 0 };
225 gchar *filename = g_path_get_basename(attachment->
file);
230 gchar *imgbody = g_strdup_printf(imageBodyFormat, filename, exif);
232 gchar *body_bak = body;
233 body = g_strconcat(body_bak, imgbody, NULL);
238 body = g_strdup(imgbody);
243 argv[
n] = g_strdup(
"--attach");
246 argv[
n+1] = attachment->
file;
256 fprintf(stderr,
"[email] launching '");
257 for (
int k=0;
k<argc;
k++) fprintf(stderr,
" %s", argv[
k]);
258 fprintf(stderr,
"'\n");
260 gint exit_status = 0;
262 g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
263 NULL, NULL, NULL, NULL, &exit_status, NULL);
276 const char *
mime = format->mime(NULL);
const char * mime(dt_imageio_module_data_t *data)
dt_colorspaces_color_profile_type_t
void dt_image_path_append_version(const int32_t imgid, char *pathname, size_t pathname_len)
void dt_image_print_exif(const dt_image_t *img, char *line, size_t line_len)
void dt_image_full_path(const int32_t imgid, char *pathname, size_t pathname_len, gboolean *from_cache, const char *calling_func)
Get the full path of an image out of the database.
void dt_control_log(const char *msg,...)
#define DT_MODULE(MODVER)
static void dt_free_gpointer(gpointer ptr)
#define DT_MAX_PATH_FOR_PARAMS
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
void * get_params(dt_imageio_module_storage_t *self)
void finalize_store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *params)
int recommended_dimension(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data, uint32_t *width, uint32_t *height)
void gui_cleanup(dt_imageio_module_storage_t *self)
void free_params(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *params)
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int32_t imgid, dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total, const gboolean high_quality, const gboolean upscale, const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent, dt_export_metadata_t *metadata)
size_t params_size(dt_imageio_module_storage_t *self)
void gui_init(dt_imageio_module_storage_t *self)
int supported(struct dt_imageio_module_storage_t *storage, struct dt_imageio_module_format_t *format)
void init(dt_imageio_module_storage_t *self)
void gui_reset(dt_imageio_module_storage_t *self)
void * legacy_params(dt_imageio_module_storage_t *self, const void *const old_params, const size_t old_params_size, const int old_version, const int new_version, size_t *new_size)
int set_params(dt_imageio_module_storage_t *self, const void *params, const int size)
void dt_loc_get_tmp_dir(char *tmpdir, size_t bufsize)
void dt_image_cache_read_release(dt_image_cache_t *cache, const dt_image_t *img)
dt_image_t * dt_image_cache_get(dt_image_cache_t *cache, const int32_t imgid, char mode)
int dt_imageio_export(const int32_t imgid, const char *filename, dt_imageio_module_format_t *format, dt_imageio_module_data_t *format_params, const gboolean high_quality, const gboolean copy_metadata, const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent, dt_imageio_module_storage_t *storage, dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata)
float *const restrict const size_t k
struct dt_image_cache_t * image_cache
char filename[DT_MAX_PATH_FOR_PARAMS]