[Evolution-hackers] [PATCH 6/6] EBookSqlite: Enable x509Cert summary field by default

2014-08-26 Thread David Woodhouse
---
 addressbook/libedata-book/e-book-sqlite.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/addressbook/libedata-book/e-book-sqlite.c 
b/addressbook/libedata-book/e-book-sqlite.c
index 09eceff..370c492 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -244,7 +244,7 @@ ebsql_init_debug (void)
} \
} G_STMT_END
 
-#define FOLDER_VERSION8
+#define FOLDER_VERSION9
 #define INSERT_MULTI_STMT_BYTES   128
 #define COLUMN_DEFINITION_BYTES   32
 #define GENERATED_QUERY_BYTES 1024
@@ -404,7 +404,8 @@ static EContactField default_summary_fields[] = {
E_CONTACT_TEL,
E_CONTACT_IS_LIST,
E_CONTACT_LIST_SHOW_ADDRESSES,
-   E_CONTACT_WANTS_HTML
+   E_CONTACT_WANTS_HTML,
+   E_CONTACT_X509_CERT,
 };
 
 /* Create indexes on full_name and email fields as autocompletion 
@@ -2293,6 +2294,13 @@ ebsql_introspect_summary (EBookSqlite *ebsql,
summary_field->index |= INDEX_FLAG (SORT_KEY);
}
}
+
+   if (previous_schema < 9) {
+   if (summary_field_array_index (summary_fields, 
E_CONTACT_X509_CERT) < 0) {
+   summary_field_append (summary_fields, 
ebsql->priv->folderid,
+ E_CONTACT_X509_CERT, 
NULL);
+   }
+   }
}
 
  introspect_summary_finish:
-- 
1.9.3


-- 
David WoodhouseOpen Source Technology Centre
david.woodho...@intel.com  Intel Corporation


smime.p7s
Description: S/MIME cryptographic signature
___
evolution-hackers mailing list
evolution-hackers@gnome.org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers


[Evolution-hackers] [PATCH 4/6] EBookSqlite: Support 'exists' queries from summary

2014-08-26 Thread David Woodhouse
---
 addressbook/libedata-book/e-book-sqlite.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/addressbook/libedata-book/e-book-sqlite.c 
b/addressbook/libedata-book/e-book-sqlite.c
index 9131c09..13a4843 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -4233,7 +4233,12 @@ func_check (struct _ESExp *f,
 
query_type = GPOINTER_TO_UINT (data);
 
-   if (argc == 2 &&
+   if (argc == 1 &&
+   argv[0]->type == ESEXP_RES_STRING) {
+   query_name = argv[0]->value.string;
+
+   field_id = e_contact_field_id (query_name);
+   } else if (argc == 2 &&
argv[0]->type == ESEXP_RES_STRING &&
argv[1]->type == ESEXP_RES_STRING) {
query_name = argv[0]->value.string;
-- 
1.9.3


-- 
David WoodhouseOpen Source Technology Centre
david.woodho...@intel.com  Intel Corporation


smime.p7s
Description: S/MIME cryptographic signature
___
evolution-hackers mailing list
evolution-hackers@gnome.org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers


[Evolution-hackers] [PATCH 5/6] EBookSqlite: Add support for storing x509Cert in a boolean summary field

2014-08-26 Thread David Woodhouse
We don't actually care about summarising the *data*; merely indicating
the *presence* of the field is sufficient. With the new evolution-pkcs11
module, the 'exists(x509Cert)' query is going to get very hot...

This halves the time it takes to query the Intel global addressbook,
with almost quarter of a million entries of whom about 5% have
certificates listed. Adding an index on the field would probably make it
even faster, if it can be used appropriately. And if I knew how to do it.
---
 addressbook/libedata-book/e-book-sqlite.c | 49 ++-
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/addressbook/libedata-book/e-book-sqlite.c 
b/addressbook/libedata-book/e-book-sqlite.c
index 13a4843..09eceff 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -449,7 +449,7 @@ column_info_new (SummaryField *field,
if (!info->type) {
if (field->type == G_TYPE_STRING)
info->type = "TEXT";
-   else if (field->type == G_TYPE_BOOLEAN)
+   else if (field->type == G_TYPE_BOOLEAN || field->type == 
E_TYPE_CONTACT_CERT)
info->type = "INTEGER";
else if (field->type == E_TYPE_CONTACT_ATTR_LIST)
info->type = "TEXT";
@@ -551,6 +551,7 @@ summary_field_append (GArray *array,
 
if (type != G_TYPE_STRING &&
type != G_TYPE_BOOLEAN &&
+   type != E_TYPE_CONTACT_CERT &&
type != E_TYPE_CONTACT_ATTR_LIST) {
EBSQL_SET_ERROR (
error, E_BOOK_SQLITE_ERROR_UNSUPPORTED_FIELD,
@@ -645,6 +646,7 @@ summary_field_list_columns (SummaryField *field,
g_return_val_if_fail (
field->type == G_TYPE_STRING ||
field->type == G_TYPE_BOOLEAN ||
+   field->type == E_TYPE_CONTACT_CERT ||
field->type == E_TYPE_CONTACT_ATTR_LIST,
NULL);
 
@@ -662,13 +664,15 @@ summary_field_list_columns (SummaryField *field,
}
 
/* Suffix match column */
-   if (field->type != G_TYPE_BOOLEAN && (field->index & INDEX_FLAG 
(SUFFIX)) != 0) {
+   if (field->type != G_TYPE_BOOLEAN && field->type != E_TYPE_CONTACT_CERT 
&&
+   (field->index & INDEX_FLAG (SUFFIX)) != 0) {
info = column_info_new (field, folderid, EBSQL_SUFFIX_REVERSE, 
"TEXT", NULL, "RINDEX");
columns = g_slist_prepend (columns, info);
}
 
/* Phone match columns */
-   if (field->type != G_TYPE_BOOLEAN && (field->index & INDEX_FLAG 
(PHONE)) != 0) {
+   if (field->type != G_TYPE_BOOLEAN && field->type != E_TYPE_CONTACT_CERT 
&&
+   (field->index & INDEX_FLAG (PHONE)) != 0) {
 
/* One indexed column for storing the national number */
info = column_info_new (field, folderid, EBSQL_SUFFIX_PHONE, 
"TEXT", NULL, "PINDEX");
@@ -3450,7 +3454,8 @@ ebsql_prepare_insert (EBookSqlite *ebsql,
g_string_append (string, ", ");
}
 
-   if (field->type == G_TYPE_STRING || field->type == 
G_TYPE_BOOLEAN) {
+   if (field->type == G_TYPE_STRING || field->type == 
G_TYPE_BOOLEAN ||
+   field->type == E_TYPE_CONTACT_CERT) {
 
g_string_append_c (string, ':');
g_string_append (string, field->dbname);
@@ -3626,6 +3631,15 @@ ebsql_run_insert (EBookSqlite *ebsql,
val = e_contact_get (contact, field->field_id) ? TRUE : 
FALSE;
 
ret = sqlite3_bind_int (stmt, param_idx++, val ? 1 : 0);
+   } else if (field->type == E_TYPE_CONTACT_CERT) {
+   EContactCert *cert = NULL;
+
+   cert = e_contact_get (contact, field->field_id);
+
+   /* We don't actually store the cert; only a boolean to 
indicate
+* that is *has* a cert. */
+   ret = sqlite3_bind_int (stmt, param_idx++, cert ? 1 : 
0);
+   e_contact_cert_free (cert);
} else if (field->type != E_TYPE_CONTACT_ATTR_LIST)
g_warn_if_reached ();
}
@@ -4536,6 +4550,17 @@ query_preflight_check (PreflightContext *context,
 
switch (field_test) {
case E_BOOK_QUERY_IS:
+   if (test->field && test->field->type == 
E_TYPE_CONTACT_CERT) {
+   no_cert_content:
+   context->status = MAX (context->status, 
PREFLIGHT_NOT_SUMMARIZED);
+   EBSQL_NOTE (
+   PREFLIGHT,
+   g_printerr (
+   "PREFLIGHT CHECK: "
+   "Refusing content check on 
X.509 cert field '%s', new sta

[Evolution-hackers] [PATCH 3/6] test-book-client-custom-summary: Add 'exists' tests for email and X509 certificates

2014-08-26 Thread David Woodhouse
---
 .../client/test-book-client-custom-summary.c   | 25 ++
 tests/libebook/data/vcards/custom-7.vcf|  1 +
 2 files changed, 26 insertions(+)

diff --git a/tests/libebook/client/test-book-client-custom-summary.c 
b/tests/libebook/client/test-book-client-custom-summary.c
index ec3f59c..f17f56d 100644
--- a/tests/libebook/client/test-book-client-custom-summary.c
+++ b/tests/libebook/client/test-book-client-custom-summary.c
@@ -762,6 +762,30 @@ main (gint argc,
suites[i].custom,
FALSE);
 
+   add_client_test (
+   suites[i].prefix,
+   "/Exists/Email",
+   suites[i].func,
+   e_book_query_field_exists (
+   E_CONTACT_EMAIL),
+   /* There are 13 contacts with email addresses */
+   13,
+   suites[i].direct,
+   suites[i].custom,
+   FALSE);
+
+   add_client_test (
+   suites[i].prefix,
+   "/Exists/X509",
+   suites[i].func,
+   e_book_query_field_exists (
+   E_CONTACT_X509_CERT),
+   /* There is 1 contact with a cert listed */
+   1,
+   suites[i].direct,
+   suites[i].custom,
+   FALSE);
+
/*
 *PHONE NUMBERS  *
 */
diff --git a/tests/libebook/data/vcards/custom-7.vcf 
b/tests/libebook/data/vcards/custom-7.vcf
index 2141e36..dae210a 100644
--- a/tests/libebook/data/vcards/custom-7.vcf
+++ b/tests/libebook/data/vcards/custom-7.vcf
@@ -2,4 +2,5 @@ BEGIN:VCARD
 UID:custom-7
 FN:Purple Goose
 TEL;HOME:+49-89-7888 99
+KEY;ENCODING=b;TYPE=X509:AA==
 END:VCARD
-- 
1.9.3


-- 
David WoodhouseOpen Source Technology Centre
david.woodho...@intel.com  Intel Corporation


smime.p7s
Description: S/MIME cryptographic signature
___
evolution-hackers mailing list
evolution-hackers@gnome.org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers


[Evolution-hackers] [PATCH 2/6] Migrate sync_data from EBookBackendSqliteDB to EBookSqlite

2014-08-26 Thread David Woodhouse
We migrated the is_populated field, but not sync_data. EWS will need that.
---
 addressbook/libedata-book/e-book-sqlite.c | 24 
 addressbook/libedata-book/e-book-sqlite.h | 13 +
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/addressbook/libedata-book/e-book-sqlite.c 
b/addressbook/libedata-book/e-book-sqlite.c
index 9e5cb78..9131c09 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -2655,15 +2655,16 @@ ebsql_set_locale_internal (EBookSqlite *ebsql,
 
 /* Called with the lock held and inside a transaction */
 static gboolean
-ebsql_init_is_populated (EBookSqlite *ebsql,
- gint previous_schema,
- GError **error)
+ebsql_init_legacy_keys (EBookSqlite *ebsql,
+gint previous_schema,
+GError **error)
 {
gboolean success = TRUE;
 
/* Schema 8 is when we moved from EBookSqlite */
if (previous_schema >= 1 && previous_schema < 8) {
gint is_populated = 0;
+   gchar *sync_data = NULL;
 
/* We need to hold on to the value of any previously set 
'is_populated' flag */
success = ebsql_exec_printf (
@@ -2681,6 +2682,21 @@ ebsql_init_is_populated (EBookSqlite *ebsql,
is_populated ? "1" : "0",
ebsql->priv->folderid);
}
+
+   /* Repeat for 'sync_data' */
+   success = ebsql_exec_printf (
+   ebsql, "SELECT sync_data FROM folders WHERE folder_id = 
%Q",
+   get_string_cb, &sync_data, NULL, error, 
ebsql->priv->folderid);
+
+   if (success) {
+   success = ebsql_exec_printf (
+   ebsql, "INSERT or REPLACE INTO keys (key, 
value, folder_id) values (%Q, %Q, %Q)",
+   NULL, NULL, NULL, error,
+   E_BOOK_SQL_SYNC_DATA_KEY,
+   sync_data, ebsql->priv->folderid);
+
+   g_free (sync_data);
+   }
}
 
return success;
@@ -2902,7 +2918,7 @@ ebsql_new_internal (const gchar *path,
 
/* When porting from older schemas, we need to port the old 
'is-populated' flag */
if (success)
-   success = ebsql_init_is_populated (ebsql, previous_schema, 
error);
+   success = ebsql_init_legacy_keys (ebsql, previous_schema, 
error);
 
/* Load / resolve the current locale setting
 *
diff --git a/addressbook/libedata-book/e-book-sqlite.h 
b/addressbook/libedata-book/e-book-sqlite.h
index 67ba6ff..9aa1b3a 100644
--- a/addressbook/libedata-book/e-book-sqlite.h
+++ b/addressbook/libedata-book/e-book-sqlite.h
@@ -69,6 +69,19 @@
  **/
 #define E_BOOK_SQL_IS_POPULATED_KEY "eds-reserved-namespace-is-populated"
 
+/**
+ * E_BOOK_SQL_SYNC_DATA_KEY:
+ *
+ * This key can be used with e_book_sqlite_get_key_value().
+ *
+ * In the case of a migration from an older SQLite, any value which
+ * was previously stored with e_book_sqlitedb_set_sync_data()
+ * can be retrieved with this key.
+ *
+ * Since: 3.12
+ **/
+#define E_BOOK_SQL_SYNC_DATA_KEY "eds-reserved-namespace-sync-data"
+
 G_BEGIN_DECLS
 
 typedef struct _EBookSqlite EBookSqlite;
-- 
1.9.3


-- 
David WoodhouseOpen Source Technology Centre
david.woodho...@intel.com  Intel Corporation


smime.p7s
Description: S/MIME cryptographic signature
___
evolution-hackers mailing list
evolution-hackers@gnome.org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers


[Evolution-hackers] [PATCH 1/6] Allow EBookSqlite to be used without transactions

2014-08-26 Thread David Woodhouse
If we use it without grouping changes into transactions by using
e_book_sqlite_lock(), and if we have a cancellation in the calls to
actually make the changes, then this warning triggers because the
new cancellation doesn't match the NULL that we have stored for the
non-existent overall transaction.

Yes, we probably ought to be using locking in EWS but we're not. It's
perfectly valid to make changes without a transaction lock. Shut up
about it.
---
 addressbook/libedata-book/e-book-sqlite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addressbook/libedata-book/e-book-sqlite.c 
b/addressbook/libedata-book/e-book-sqlite.c
index 0ae89cd..9e5cb78 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -209,7 +209,7 @@ ebsql_init_debug (void)
 #define EBSQL_LOCK_OR_RETURN(ebsql, cancellable, val) \
G_STMT_START { \
EBSQL_LOCK_MUTEX (&(ebsql)->priv->lock); \
-   if (cancellable != NULL && \
+   if (cancellable != NULL && (ebsql)->priv->cancel && \
(ebsql)->priv->cancel != cancellable) { \
g_warning ("The GCancellable passed to `%s' " \
   "is not the same as the cancel object " \
-- 
1.9.3


-- 
David WoodhouseOpen Source Technology Centre
david.woodho...@intel.com  Intel Corporation


smime.p7s
Description: S/MIME cryptographic signature
___
evolution-hackers mailing list
evolution-hackers@gnome.org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers