summaryrefslogtreecommitdiff
path: root/src/addressbook/libedata-book
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2018-07-04 11:46:52 +0200
committerMilan Crha <mcrha@redhat.com>2018-07-04 11:46:52 +0200
commitea9ed9224edab871cb539e0b7cc0821480012836 (patch)
tree5d921d01f3a5dc160af0988565e39eca81ea2d27 /src/addressbook/libedata-book
parent20a03b5d1695a05915c5ae1c7112707fac8ad464 (diff)
downloadevolution-data-server-ea9ed9224edab871cb539e0b7cc0821480012836.tar.gz
Bug 704246 - Cannot send encrypted mail to contact with certificate
Diffstat (limited to 'src/addressbook/libedata-book')
-rw-r--r--src/addressbook/libedata-book/e-book-cache.c48
-rw-r--r--src/addressbook/libedata-book/e-book-sqlite.c17
2 files changed, 60 insertions, 5 deletions
diff --git a/src/addressbook/libedata-book/e-book-cache.c b/src/addressbook/libedata-book/e-book-cache.c
index fbf931a7c..1401d8f40 100644
--- a/src/addressbook/libedata-book/e-book-cache.c
+++ b/src/addressbook/libedata-book/e-book-cache.c
@@ -49,7 +49,7 @@
#include "e-book-cache.h"
-#define E_BOOK_CACHE_VERSION 1
+#define E_BOOK_CACHE_VERSION 2
#define INSERT_MULTI_STMT_BYTES 128
#define COLUMN_DEFINITION_BYTES 32
#define GENERATED_QUERY_BYTES 1024
@@ -228,7 +228,8 @@ static EContactField default_summary_fields[] = {
E_CONTACT_IS_LIST,
E_CONTACT_LIST_SHOW_ADDRESSES,
E_CONTACT_WANTS_HTML,
- E_CONTACT_X509_CERT
+ E_CONTACT_X509_CERT,
+ E_CONTACT_PGP_CERT
};
/* Create indexes on full_name and email fields as autocompletion
@@ -4229,6 +4230,41 @@ e_book_cache_gather_table_names_cb (ECache *cache,
}
static gboolean
+e_book_cache_fill_pgp_cert_column (ECache *cache,
+ const gchar *uid,
+ const gchar *revision,
+ const gchar *object,
+ EOfflineState offline_state,
+ gint ncols,
+ const gchar *column_names[],
+ const gchar *column_values[],
+ gchar **out_revision,
+ gchar **out_object,
+ EOfflineState *out_offline_state,
+ ECacheColumnValues **out_other_columns,
+ gpointer user_data)
+{
+ EContact *contact;
+ EContactCert *cert;
+
+ g_return_val_if_fail (object != NULL, FALSE);
+ g_return_val_if_fail (out_other_columns != NULL, FALSE);
+
+ contact = e_contact_new_from_vcard (object);
+ if (!contact)
+ return TRUE;
+
+ *out_other_columns = e_cache_column_values_new ();
+ cert = e_contact_get (contact, E_CONTACT_PGP_CERT);
+
+ e_cache_column_values_take_value (*out_other_columns, e_contact_field_name (E_CONTACT_PGP_CERT), g_strdup_printf ("%d", cert ? 1 : 0));
+
+ e_contact_cert_free (cert);
+
+ return TRUE;
+}
+
+static gboolean
e_book_cache_migrate (ECache *cache,
gint from_version,
GCancellable *cancellable,
@@ -4297,8 +4333,12 @@ e_book_cache_migrate (ECache *cache,
}
/* Add any version-related changes here */
- /*if (from_version < E_BOOK_CACHE_VERSION) {
- }*/
+ if (success && from_version > 0 && from_version < E_BOOK_CACHE_VERSION) {
+ if (from_version == 1) {
+ /* Version 2 added E_CONTACT_PGP_CERT existence into the summary */
+ success = e_cache_foreach_update (cache, E_CACHE_INCLUDE_DELETED, NULL, e_book_cache_fill_pgp_cert_column, NULL, cancellable, error);
+ }
+ }
return success;
}
diff --git a/src/addressbook/libedata-book/e-book-sqlite.c b/src/addressbook/libedata-book/e-book-sqlite.c
index 169b00214..e43da968e 100644
--- a/src/addressbook/libedata-book/e-book-sqlite.c
+++ b/src/addressbook/libedata-book/e-book-sqlite.c
@@ -270,7 +270,7 @@ ebsql_origin_str (EbSqlCursorOrigin origin)
} \
} G_STMT_END
-#define FOLDER_VERSION 11
+#define FOLDER_VERSION 12
#define INSERT_MULTI_STMT_BYTES 128
#define COLUMN_DEFINITION_BYTES 32
#define GENERATED_QUERY_BYTES 1024
@@ -443,6 +443,7 @@ static EContactField default_summary_fields[] = {
E_CONTACT_LIST_SHOW_ADDRESSES,
E_CONTACT_WANTS_HTML,
E_CONTACT_X509_CERT,
+ E_CONTACT_PGP_CERT
};
/* Create indexes on full_name and email fields as autocompletion
@@ -2423,6 +2424,13 @@ ebsql_introspect_summary (EBookSqlite *ebsql,
}
}
+
+ if (previous_schema < 12) {
+ if (summary_field_array_index (summary_fields, E_CONTACT_PGP_CERT) < 0) {
+ summary_field_append (summary_fields, ebsql->priv->folderid,
+ E_CONTACT_PGP_CERT, NULL);
+ }
+ }
}
introspect_summary_finish:
@@ -3085,6 +3093,13 @@ ebsql_new_internal (const gchar *path,
ebsql, previous_schema,
already_exists, error);
+
+ /* Schema 12 added E_CONTACT_PGP_CERT column into the summary;
+ the ebsql_init_locale() also calls ebsql_upgrade() for schema 10-,
+ thus call it here only for schema 11, to populate the PGP column */
+ if (success && previous_schema == 11)
+ success = ebsql_upgrade (ebsql, EBSQL_CHANGE_LAST, error);
+
if (success)
success = ebsql_commit_transaction (ebsql, error);
else