aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conversion.c19
-rw-r--r--src/gpgme.h.in16
-rw-r--r--src/keylist.c23
-rw-r--r--src/util.h3
4 files changed, 52 insertions, 9 deletions
diff --git a/src/conversion.c b/src/conversion.c
index 6dfabe7e..92dd2141 100644
--- a/src/conversion.c
+++ b/src/conversion.c
@@ -536,6 +536,25 @@ _gpgme_parse_timestamp (const char *timestamp, char **endp)
}
+/* This function is similar to _gpgme_parse_timestamp but returns an
+ * unsigned long and 0 on error. */
+unsigned long
+_gpgme_parse_timestamp_ul (const char *timestamp)
+{
+ time_t tim;
+ char *tail;
+
+ if (!*timestamp)
+ return 0; /* Shortcut empty strings. */
+
+ tim = _gpgme_parse_timestamp (timestamp, &tail);
+ if (tim == -1 || timestamp == tail || (*tail && *tail != ' '))
+ tim = 0; /* No time given or invalid engine. */
+
+ return (unsigned long)tim;
+}
+
+
/* The GPG backend uses OpenPGP algorithm numbers which we need to map
to our algorithm numbers. This function MUST not change ERRNO. */
int
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index b6c14064..24b21e7d 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -662,7 +662,10 @@ struct _gpgme_user_id
unsigned int invalid : 1;
/* Internal to GPGME, do not use. */
- unsigned int _unused : 30;
+ unsigned int _unused : 25;
+
+ /* Origin of this user ID. */
+ unsigned int origin : 5;
/* The validity of the user ID. */
gpgme_validity_t validity;
@@ -693,6 +696,9 @@ struct _gpgme_user_id
/* The malloced TOFU information or NULL. */
gpgme_tofu_info_t tofu;
+
+ /* Time of the last refresh of thsi user id. 0 if unknown. */
+ unsigned long last_update;
};
typedef struct _gpgme_user_id *gpgme_user_id_t;
@@ -736,7 +742,10 @@ struct _gpgme_key
unsigned int is_qualified : 1;
/* Internal to GPGME, do not use. */
- unsigned int _unused : 22;
+ unsigned int _unused : 17;
+
+ /* Origin of this key. */
+ unsigned int origin : 5;
/* This is the protocol supported by this key. */
gpgme_protocol_t protocol;
@@ -776,6 +785,9 @@ struct _gpgme_key
* this is a copy of the FPR of the first subkey. We need it here
* to allow for an incomplete key object. */
char *fpr;
+
+ /* Time of the last refresh of the entire key. 0 if unknown. */
+ unsigned long last_update;
};
typedef struct _gpgme_key *gpgme_key_t;
diff --git a/src/keylist.c b/src/keylist.c
index c88a7ca5..e16ba4d1 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -552,7 +552,7 @@ keylist_colon_handler (void *priv, char *line)
RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK
}
rectype = RT_NONE;
-#define NR_FIELDS 18
+#define NR_FIELDS 20
char *field[NR_FIELDS];
int fields = 0;
void *hook;
@@ -733,6 +733,12 @@ keylist_colon_handler (void *priv, char *line)
if (fields >= 17 && *field[17])
parse_pub_field18 (subkey, field[17]);
+ if (fields >= 20)
+ {
+ key->last_update = _gpgme_parse_timestamp_ul (field[18]);
+ key->origin = 0; /* Fixme: Not yet defined in gpg. */
+ }
+
break;
case RT_SUB:
@@ -818,12 +824,15 @@ keylist_colon_handler (void *priv, char *line)
{
if (_gpgme_key_append_name (key, field[9], 1))
return gpg_error (GPG_ERR_ENOMEM); /* FIXME */
- else
- {
- if (field[1])
- set_userid_flags (key, field[1]);
- opd->tmp_uid = key->_last_uid;
- }
+
+ if (field[1])
+ set_userid_flags (key, field[1]);
+ opd->tmp_uid = key->_last_uid;
+ if (fields >= 20)
+ {
+ opd->tmp_uid->last_update = _gpgme_parse_timestamp_ul (field[18]);
+ opd->tmp_uid->origin = 0; /* Fixme: Not yet defined in gpg. */
+ }
}
break;
diff --git a/src/util.h b/src/util.h
index b27c5833..7b7924cf 100644
--- a/src/util.h
+++ b/src/util.h
@@ -165,6 +165,9 @@ gpgme_off_t _gpgme_string_to_off (const char *string);
point to the next non-parsed character in TIMESTRING. */
time_t _gpgme_parse_timestamp (const char *timestamp, char **endp);
+/* Variant of _gpgme_parse_timestamp to return an unsigned long or 0
+ * on error or missing timestamp. */
+unsigned long _gpgme_parse_timestamp_ul (const char *timestamp);
gpgme_error_t _gpgme_map_gnupg_error (char *err);