const gchar * ev_attachment_get_mime_type (EvAttachment *attachment) { g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL); return attachment->priv->mime_type; }
const gchar * ev_attachment_get_description (EvAttachment *attachment) { g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL); return attachment->priv->description; }
GTime ev_attachment_get_creation_date (EvAttachment *attachment) { g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0); return attachment->priv->ctime; }
gboolean ev_attachment_open (EvAttachment *attachment, GdkScreen *screen, guint32 timestamp, GError **error) { GAppInfo *app_info; gboolean retval = FALSE; g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE); if (!attachment->priv->app) { app_info = g_app_info_get_default_for_type (attachment->priv->mime_type, FALSE); attachment->priv->app = app_info; } if (!attachment->priv->app) { g_set_error (error, EV_ATTACHMENT_ERROR, 0, _("Couldn't open attachment “%s”"), attachment->priv->name); return FALSE; } if (attachment->priv->tmp_file) { retval = ev_attachment_launch_app (attachment, screen, timestamp, error); } else { char *template; GFile *file;
gboolean ev_attachment_save (EvAttachment *attachment, GFile *file, GError **error) { GFileOutputStream *output_stream; GError *ioerror = NULL; gssize written_bytes; g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); output_stream = g_file_replace (file, NULL, FALSE, 0, NULL, &ioerror); if (output_stream == NULL) { char *uri; uri = g_file_get_uri (file); g_set_error (error, EV_ATTACHMENT_ERROR, ioerror->code, _("Couldn't save attachment “%s”: %s"), uri, ioerror->message); g_error_free (ioerror); g_free (uri); return FALSE; } written_bytes = g_output_stream_write (G_OUTPUT_STREAM (output_stream), attachment->priv->data, attachment->priv->size, NULL, &ioerror); if (written_bytes == -1) { char *uri; uri = g_file_get_uri (file); g_set_error (error, EV_ATTACHMENT_ERROR, ioerror->code, _("Couldn't save attachment “%s”: %s"), uri, ioerror->message); g_output_stream_close (G_OUTPUT_STREAM (output_stream), NULL, NULL); g_error_free (ioerror); g_free (uri); return FALSE; } g_output_stream_close (G_OUTPUT_STREAM (output_stream), NULL, NULL); return TRUE; }