summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-01-20 16:00:37 +0100
committerraveit65 <[email protected]>2020-01-31 18:52:19 +0100
commita70e19a51423b855b9da8d7f9ed40d396a534c67 (patch)
tree1fe5414f810a3fadd3fbd88673987cad60d62aac
parente388b7032dda81917b05583c306a4b9690dcaa46 (diff)
downloadatril-a70e19a51423b855b9da8d7f9ed40d396a534c67.tar.bz2
atril-a70e19a51423b855b9da8d7f9ed40d396a534c67.tar.xz
Fix year 2038 issue with signed 32-bit integers
GTime is defined to always be a signed 32-bit integer, it will overflow in the year 2038.
-rw-r--r--backend/pdf/ev-poppler.cc5
-rw-r--r--configure.ac4
-rw-r--r--libdocument/ev-annotation.c6
-rw-r--r--libdocument/ev-annotation.h2
-rw-r--r--libdocument/ev-attachment.c12
-rw-r--r--libdocument/ev-attachment.h8
-rw-r--r--libdocument/ev-document-info.h4
-rw-r--r--libdocument/ev-document-misc.c29
-rw-r--r--libdocument/ev-document-misc.h2
-rw-r--r--properties/ev-properties-view.c4
-rw-r--r--shell/ev-window.c38
11 files changed, 54 insertions, 60 deletions
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index e21bd768..be16e88f 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -667,12 +667,13 @@ pdf_document_get_info (EvDocument *document)
"permissions", &permissions,
"creator", &(info->creator),
"producer", &(info->producer),
- "creation-date", &(info->creation_date),
- "mod-date", &(info->modified_date),
"linearized", &linearized,
"metadata", &metadata,
NULL);
+ info->creation_date = (gint64) poppler_document_get_creation_date (PDF_DOCUMENT (document)->document);
+ info->modified_date = (gint64) poppler_document_get_modification_date (PDF_DOCUMENT (document)->document);
+
if (metadata != NULL) {
pdf_document_parse_metadata (metadata, info);
g_free (metadata);
diff --git a/configure.ac b/configure.ac
index 498aeb32..529ef2a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,7 +84,7 @@ GLIB_GSETTINGS
dnl Specify required versions of dependencies
CAIRO_REQUIRED=1.14.0
-GLIB_REQUIRED=2.54.0
+GLIB_REQUIRED=2.62.0
GTK_REQUIRED=3.22.0
WEBKIT_REQUIRED=2.6.0
LIBSECRET_REQUIRED=0.5
@@ -644,8 +644,6 @@ fi
AC_SUBST(ATRIL_MIME_TYPES)
-AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system]))
-
# *****************
# Help files
# *****************
diff --git a/libdocument/ev-annotation.c b/libdocument/ev-annotation.c
index 41bd4249..03fe925c 100644
--- a/libdocument/ev-annotation.c
+++ b/libdocument/ev-annotation.c
@@ -454,7 +454,7 @@ ev_annotation_get_modified (EvAnnotation *annot)
* @modified: string with the last modification date.
*
* Set the last modification date of @annot to @modified. To
- * set the last modification date using a #GTime, use
+ * set the last modification date using a #gint64, use
* ev_annotation_set_modified_from_time() instead. You can monitor
* changes to the last modification date by connecting to the
* notify::modified signal on @annot.
@@ -482,7 +482,7 @@ ev_annotation_set_modified (EvAnnotation *annot,
/**
* ev_annotation_set_modified_from_time:
* @annot: an #EvAnnotation
- * @utime: a #GTime
+ * @utime: a #gint64
*
* Set the last modification date of @annot to @utime. You can
* monitor changes to the last modification date by connectin to the
@@ -493,7 +493,7 @@ ev_annotation_set_modified (EvAnnotation *annot,
*/
gboolean
ev_annotation_set_modified_from_time (EvAnnotation *annot,
- GTime utime)
+ gint64 utime)
{
gchar *modified;
diff --git a/libdocument/ev-annotation.h b/libdocument/ev-annotation.h
index 408c4577..ce87e952 100644
--- a/libdocument/ev-annotation.h
+++ b/libdocument/ev-annotation.h
@@ -115,7 +115,7 @@ const gchar *ev_annotation_get_modified (EvAnnotation
gboolean ev_annotation_set_modified (EvAnnotation *annot,
const gchar *modified);
gboolean ev_annotation_set_modified_from_time (EvAnnotation *annot,
- GTime utime);
+ gint64 utime);
EV_DEPRECATED_FOR(ev_annotaion_get_rgba)
void ev_annotation_get_color (EvAnnotation *annot,
GdkColor *color);
diff --git a/libdocument/ev-attachment.c b/libdocument/ev-attachment.c
index c0fb46f7..f87cfc13 100644
--- a/libdocument/ev-attachment.c
+++ b/libdocument/ev-attachment.c
@@ -38,8 +38,8 @@ enum
struct _EvAttachmentPrivate {
gchar *name;
gchar *description;
- GTime mtime;
- GTime ctime;
+ gint64 mtime;
+ gint64 ctime;
gsize size;
gchar *data;
gchar *mime_type;
@@ -217,8 +217,8 @@ ev_attachment_init (EvAttachment *attachment)
EvAttachment *
ev_attachment_new (const gchar *name,
const gchar *description,
- GTime mtime,
- GTime ctime,
+ gint64 mtime,
+ gint64 ctime,
gsize size,
gpointer data)
{
@@ -252,7 +252,7 @@ ev_attachment_get_description (EvAttachment *attachment)
return attachment->priv->description;
}
-GTime
+gint64
ev_attachment_get_modification_date (EvAttachment *attachment)
{
g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0);
@@ -260,7 +260,7 @@ ev_attachment_get_modification_date (EvAttachment *attachment)
return attachment->priv->mtime;
}
-GTime
+gint64
ev_attachment_get_creation_date (EvAttachment *attachment)
{
g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0);
diff --git a/libdocument/ev-attachment.h b/libdocument/ev-attachment.h
index 17999437..33e16e1b 100644
--- a/libdocument/ev-attachment.h
+++ b/libdocument/ev-attachment.h
@@ -56,15 +56,15 @@ GType ev_attachment_get_type (void) G_GNUC_CONST;
GQuark ev_attachment_error_quark (void) G_GNUC_CONST;
EvAttachment *ev_attachment_new (const gchar *name,
const gchar *description,
- GTime mtime,
- GTime ctime,
+ gint64 mtime,
+ gint64 ctime,
gsize size,
gpointer data);
const gchar *ev_attachment_get_name (EvAttachment *attachment);
const gchar *ev_attachment_get_description (EvAttachment *attachment);
-GTime ev_attachment_get_modification_date (EvAttachment *attachment);
-GTime ev_attachment_get_creation_date (EvAttachment *attachment);
+gint64 ev_attachment_get_modification_date (EvAttachment *attachment);
+gint64 ev_attachment_get_creation_date (EvAttachment *attachment);
const gchar *ev_attachment_get_mime_type (EvAttachment *attachment);
gboolean ev_attachment_save (EvAttachment *attachment,
GFile *file,
diff --git a/libdocument/ev-document-info.h b/libdocument/ev-document-info.h
index 54a4e94e..49698bfc 100644
--- a/libdocument/ev-document-info.h
+++ b/libdocument/ev-document-info.h
@@ -115,8 +115,8 @@ struct _EvDocumentInfo
char *producer;
char *linearized;
char *security;
- GTime creation_date;
- GTime modified_date;
+ gint64 creation_date;
+ gint64 modified_date;
EvDocumentLayout layout;
EvDocumentMode mode;
guint ui_hints;
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index e25b9ca6..80948936 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <math.h>
+#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
@@ -359,25 +360,17 @@ ev_document_misc_get_monitor_dpi (GdkMonitor *monitor)
/* Returns a locale specific date and time representation */
gchar *
-ev_document_misc_format_date (GTime utime)
+ev_document_misc_format_date (gint64 utime)
{
- time_t time = (time_t) utime;
- char s[256];
- const char fmt_hack[] = "%c";
- size_t len;
-#ifdef HAVE_LOCALTIME_R
- struct tm t;
- if (time == 0 || !localtime_r (&time, &t)) return NULL;
- len = strftime (s, sizeof (s), fmt_hack, &t);
-#else
- struct tm *t;
- if (time == 0 || !(t = localtime (&time)) ) return NULL;
- len = strftime (s, sizeof (s), fmt_hack, t);
-#endif
-
- if (len == 0 || s[0] == '\0') return NULL;
-
- return g_locale_to_utf8 (s, -1, NULL, NULL, NULL);
+ GDateTime *date_time;
+ gchar *result = NULL;
+
+ date_time = g_date_time_new_from_unix_local (utime);
+ if (date_time != NULL) {
+ result = g_date_time_format (date_time, "%c");
+ g_date_time_unref (date_time);
+ }
+ return result;
}
void
diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h
index 3b97e3f8..bd789971 100644
--- a/libdocument/ev-document-misc.h
+++ b/libdocument/ev-document-misc.h
@@ -63,7 +63,7 @@ void ev_document_misc_invert_pixbuf (GdkPixbuf *pixbuf);
gdouble ev_document_misc_get_monitor_dpi (GdkMonitor *monitor);
-gchar *ev_document_misc_format_date (GTime utime);
+gchar *ev_document_misc_format_date (gint64 utime);
void ev_document_misc_get_pointer_position (GtkWidget *widget,
gint *x,
diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c
index 709b7c27..e6d703c7 100644
--- a/properties/ev-properties-view.c
+++ b/properties/ev-properties-view.c
@@ -342,12 +342,12 @@ ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo
if (info->fields_mask & EV_DOCUMENT_INFO_CREATOR) {
set_property (properties, GTK_GRID (grid), CREATOR_PROPERTY, info->creator, &row);
}
- if (info->fields_mask & EV_DOCUMENT_INFO_CREATION_DATE) {
+ if ((info->fields_mask & EV_DOCUMENT_INFO_CREATION_DATE) && (info->creation_date > 0)) {
text = ev_document_misc_format_date (info->creation_date);
set_property (properties, GTK_GRID (grid), CREATION_DATE_PROPERTY, text, &row);
g_free (text);
}
- if (info->fields_mask & EV_DOCUMENT_INFO_MOD_DATE) {
+ if ((info->fields_mask & EV_DOCUMENT_INFO_MOD_DATE) && (info->modified_date > 0)) {
text = ev_document_misc_format_date (info->modified_date);
set_property (properties, GTK_GRID (grid), MOD_DATE_PROPERTY, text, &row);
g_free (text);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 1da50613..e4cbce93 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -199,7 +199,7 @@ struct _EvWindowPrivate {
/* Document */
EvDocumentModel *model;
char *uri;
- glong uri_mtime;
+ gint64 uri_mtime;
char *local_uri;
gboolean in_reload;
EvFileMonitor *monitor;
@@ -2190,21 +2190,19 @@ set_uri_mtime (GFile *source,
EvWindow *ev_window)
{
GFileInfo *info;
- GError *error = NULL;
-
- info = g_file_query_info_finish (source, async_result, &error);
-
- if (error) {
- ev_window->priv->uri_mtime = 0;
- g_error_free (error);
- } else {
- GTimeVal mtime;
-
- g_file_info_get_modification_time (info, &mtime);
- ev_window->priv->uri_mtime = mtime.tv_sec;
+ gint utime = -1;
+
+ info = g_file_query_info_finish (source, async_result, NULL);
+ if (info) {
+ GDateTime *mtime;
+ mtime = g_file_info_get_modification_date_time (info);
+ if (mtime) {
+ utime = g_date_time_to_unix (mtime);
+ g_date_time_unref (mtime);
+ }
g_object_unref (info);
}
-
+ ev_window->priv->uri_mtime = utime;
g_object_unref (source);
}
@@ -2599,8 +2597,9 @@ query_remote_uri_mtime_cb (GFile *remote,
EvWindow *ev_window)
{
GFileInfo *info;
- GTimeVal mtime;
+ GDateTime *mtime;
GError *error = NULL;
+ gint64 utime;
info = g_file_query_info_finish (remote, async_result, &error);
if (error) {
@@ -2611,12 +2610,15 @@ query_remote_uri_mtime_cb (GFile *remote,
return;
}
- g_file_info_get_modification_time (info, &mtime);
- if (ev_window->priv->uri_mtime != mtime.tv_sec) {
+ mtime = g_file_info_get_modification_date_time (info);
+ utime = g_date_time_to_unix (mtime);
+ g_date_time_unref (mtime);
+
+ if (ev_window->priv->uri_mtime != utime) {
GFile *target_file;
/* Remote file has changed */
- ev_window->priv->uri_mtime = mtime.tv_sec;
+ ev_window->priv->uri_mtime = utime;
ev_window_reset_progress_cancellable (ev_window);