p≡p engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

622 lines
28 KiB

ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
  1. #pragma once
  2. #include "pEp_internal.h"
  3. // increment this when patching DDL
  4. #define _DDL_USER_VERSION "19"
  5. PEP_STATUS init_databases(PEP_SESSION session);
  6. PEP_STATUS pEp_sql_init(PEP_SESSION session);
  7. PEP_STATUS pEp_prepare_sql_stmts(PEP_SESSION session);
  8. PEP_STATUS pEp_finalize_sql_stmts(PEP_SESSION session);
  9. /* The strings below are not always all used in a C file, so it is normal that
  10. a lot of these variables are unused: we do not want warnings, nor complicated
  11. attribute declrations for every variable. */
  12. #define MAYBE_UNUSED __attribute__((__unused__))
  13. /**
  14. * Strings to feed into prepared statements
  15. */
  16. static const char *sql_log MAYBE_UNUSED =
  17. "insert into log (title, entity, description, comment)"
  18. "values (?1, ?2, ?3, ?4);";
  19. static const char *sql_trustword MAYBE_UNUSED =
  20. "select id, word from wordlist where lang = lower(?1) "
  21. "and id = ?2 ;";
  22. // FIXME?: problems if we don't have a key for the user - we get nothing
  23. // Also: we've never used pgp_keypair.flags before now, but it seems to me that
  24. // having combination of those flags is a road to ruin. Changing this for now.
  25. static const char *sql_get_identity MAYBE_UNUSED =
  26. "select identity.main_key_id,"
  27. " (case when (identity.flags & 1024 = 0) then ifnull(identity.username, person.username) "
  28. " else identity.username end),"
  29. " comm_type, lang, identity.flags,"
  30. // " identity.flags | pgp_keypair.flags,"
  31. " is_own, pEp_version_major, pEp_version_minor, enc_format"
  32. " from identity"
  33. " join person on id = identity.user_id"
  34. " left join pgp_keypair on fpr = identity.main_key_id"
  35. " left join trust on id = trust.user_id"
  36. " and pgp_keypair_fpr = identity.main_key_id"
  37. " where (case when (address = ?1) then (1)"
  38. " when (lower(address) = lower(?1)) then (1)"
  39. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1)"
  40. " else 0"
  41. " end) = 1"
  42. " and identity.user_id = ?2"
  43. " order by is_own desc, "
  44. " timestamp desc; ";
  45. static const char *sql_get_identities_by_main_key_id MAYBE_UNUSED =
  46. "select address, identity.user_id,"
  47. " (case when (identity.flags & 1024 = 0) then ifnull(identity.username, person.username) "
  48. " else identity.username end),"
  49. " comm_type, lang, identity.flags,"
  50. // " identity.flags | pgp_keypair.flags,"
  51. " is_own, pEp_version_major, pEp_version_minor, enc_format"
  52. " from identity"
  53. " join person on id = identity.user_id"
  54. " left join pgp_keypair on fpr = identity.main_key_id"
  55. " left join trust on id = trust.user_id"
  56. " and pgp_keypair_fpr = identity.main_key_id"
  57. " where identity.main_key_id = ?1"
  58. " order by is_own desc, "
  59. " timestamp desc; ";
  60. static const char *sql_get_identity_without_trust_check MAYBE_UNUSED =
  61. "select identity.main_key_id,"
  62. " (case when (identity.flags & 1024 = 0) then ifnull(identity.username, person.username) "
  63. " else identity.username end),"
  64. " lang, identity.flags, is_own, pEp_version_major, pEp_version_minor, enc_format"
  65. " from identity"
  66. " join person on id = identity.user_id"
  67. " where (case when (address = ?1) then (1)"
  68. " when (lower(address) = lower(?1)) then (1)"
  69. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1)"
  70. " else 0"
  71. " end) = 1"
  72. " and identity.user_id = ?2 "
  73. " order by is_own desc, "
  74. " timestamp desc; ";
  75. static const char *sql_get_identities_by_address MAYBE_UNUSED =
  76. "select user_id, identity.main_key_id,"
  77. " (case when (identity.flags & 1024 = 0) then ifnull(identity.username, person.username) "
  78. " else identity.username end),"
  79. " lang, identity.flags, is_own, pEp_version_major, pEp_version_minor, enc_format"
  80. " from identity"
  81. " join person on id = identity.user_id"
  82. " where (case when (address = ?1) then (1)"
  83. " when (lower(address) = lower(?1)) then (1)"
  84. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1)"
  85. " else 0"
  86. " end) = 1 "
  87. " order by is_own desc, "
  88. " timestamp desc; ";
  89. static const char *sql_get_identities_by_userid MAYBE_UNUSED =
  90. "select address, identity.main_key_id,"
  91. " (case when (identity.flags & 1024 = 0) then ifnull(identity.username, person.username) "
  92. " else identity.username end),"
  93. " comm_type, lang, identity.flags,"
  94. // " identity.flags | pgp_keypair.flags,"
  95. " is_own, pEp_version_major, pEp_version_minor, enc_format"
  96. " from identity"
  97. " join person on id = identity.user_id"
  98. " left join pgp_keypair on fpr = identity.main_key_id"
  99. " left join trust on id = trust.user_id"
  100. " and pgp_keypair_fpr = identity.main_key_id"
  101. " where identity.user_id = ?1"
  102. " order by is_own desc, "
  103. " timestamp desc; ";
  104. static const char *sql_replace_identities_fpr MAYBE_UNUSED =
  105. "update identity"
  106. " set main_key_id = ?1 "
  107. " where main_key_id = ?2 ;";
  108. static const char* sql_set_default_identity_fpr MAYBE_UNUSED =
  109. "update identity set main_key_id = ?3 "
  110. " where user_id = ?1 and address = ?2; ";
  111. static const char *sql_get_default_identity_fpr MAYBE_UNUSED =
  112. "select main_key_id from identity"
  113. " where (case when (address = ?1) then (1)"
  114. " when (lower(address) = lower(?1)) then (1)"
  115. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1) "
  116. " else 0 "
  117. " end) = 1 "
  118. " and user_id = ?2 ;";
  119. static const char *sql_remove_fpr_as_identity_default MAYBE_UNUSED =
  120. "update identity set main_key_id = NULL where main_key_id = ?1 ;";
  121. static const char *sql_remove_fpr_as_user_default MAYBE_UNUSED =
  122. "update person set main_key_id = NULL where main_key_id = ?1 ;";
  123. // Set person, but if already exist, only update.
  124. // if main_key_id already set, don't touch.
  125. static const char *sql_set_person MAYBE_UNUSED =
  126. "insert into person (id, username, lang, main_key_id)"
  127. " values (?1, ?2, ?3, ?4) ;";
  128. static const char *sql_update_person MAYBE_UNUSED =
  129. "update person "
  130. " set username = ?2, "
  131. " lang = ?3, "
  132. " main_key_id = "
  133. " (select coalesce( "
  134. " (select main_key_id from person where id = ?1), "
  135. " upper(replace(?4,' ',''))))"
  136. " where id = ?1 ;";
  137. // Will cascade.
  138. static const char *sql_delete_person MAYBE_UNUSED =
  139. "delete from person where id = ?1 ;";
  140. static const char *sql_set_as_pEp_user MAYBE_UNUSED =
  141. "update person set is_pEp_user = 1 "
  142. " where id = ?1 ; ";
  143. static const char *sql_is_pEp_user MAYBE_UNUSED =
  144. "select is_pEp_user from person "
  145. " where id = ?1 ; ";
  146. static const char* sql_exists_person MAYBE_UNUSED =
  147. "select count(*) from person "
  148. " where id = ?1 ;";
  149. // This will cascade to identity and trust
  150. static const char* sql_replace_userid MAYBE_UNUSED =
  151. "update person set id = ?1 "
  152. " where id = ?2;";
  153. // Hopefully this cascades and removes trust entries...
  154. static const char *sql_delete_key MAYBE_UNUSED =
  155. "delete from pgp_keypair "
  156. " where fpr = ?1 ; ";
  157. static const char *sql_replace_main_user_fpr MAYBE_UNUSED =
  158. "update person "
  159. " set main_key_id = ?1 "
  160. " where id = ?2 ;";
  161. static const char *sql_get_main_user_fpr MAYBE_UNUSED =
  162. "select main_key_id from person"
  163. " where id = ?1 ;";
  164. static const char *sql_replace_main_user_fpr_if_equal MAYBE_UNUSED =
  165. "update person "
  166. " set main_key_id = ?1 "
  167. " where id = ?2 and main_key_id = ?3;";
  168. static const char *sql_refresh_userid_default_key MAYBE_UNUSED =
  169. "update person "
  170. " set main_key_id = "
  171. " (select identity.main_key_id from identity "
  172. " join trust on trust.user_id = identity.user_id "
  173. " and trust.pgp_keypair_fpr = identity.main_key_id "
  174. " join person on person.id = identity.user_id "
  175. " where identity.user_id = ?1 "
  176. " order by trust.comm_type desc "
  177. " limit 1) "
  178. "where id = ?1 ; ";
  179. static const char *sql_set_pgp_keypair MAYBE_UNUSED =
  180. "insert or ignore into pgp_keypair (fpr) "
  181. "values (upper(replace(?1,' ',''))) ;";
  182. static const char *sql_set_pgp_keypair_flags MAYBE_UNUSED =
  183. "update pgp_keypair set flags = "
  184. " ((?1 & 65535) | (select flags from pgp_keypair "
  185. " where fpr = (upper(replace(?2,' ',''))))) "
  186. " where fpr = (upper(replace(?2,' ',''))) ;";
  187. static const char *sql_unset_pgp_keypair_flags MAYBE_UNUSED =
  188. "update pgp_keypair set flags = "
  189. " ( ~(?1 & 65535) & (select flags from pgp_keypair"
  190. " where fpr = (upper(replace(?2,' ',''))))) "
  191. " where fpr = (upper(replace(?2,' ',''))) ;";
  192. static const char* sql_exists_identity_entry MAYBE_UNUSED =
  193. "select count(*) from identity "
  194. " where (case when (address = ?1) then (1)"
  195. " when (lower(address) = lower(?1)) then (1)"
  196. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1)"
  197. " else 0"
  198. " end) = 1"
  199. " and user_id = ?2;";
  200. static const char *sql_set_identity_entry MAYBE_UNUSED =
  201. "insert into identity ("
  202. " address, main_key_id, "
  203. " user_id, "
  204. " username, "
  205. " flags, is_own,"
  206. " pEp_version_major, pEp_version_minor"
  207. " ) values ("
  208. " ?1,"
  209. " upper(replace(?2,' ','')),"
  210. " ?3,"
  211. " ?4,"
  212. " ?5,"
  213. " ?6,"
  214. " ?7,"
  215. " ?8 "
  216. " );";
  217. static const char* sql_update_identity_entry MAYBE_UNUSED =
  218. "update identity "
  219. " set main_key_id = upper(replace(?2,' ','')), "
  220. " username = coalesce(username, ?4), "
  221. " flags = ?5, "
  222. " is_own = ?6, "
  223. " pEp_version_major = ?7, "
  224. " pEp_version_minor = ?8 "
  225. " where (case when (address = ?1) then (1)"
  226. " when (lower(address) = lower(?1)) then (1)"
  227. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1) "
  228. " else 0 "
  229. " end) = 1 "
  230. " and user_id = ?3 ;";
  231. static const char* sql_force_set_identity_username MAYBE_UNUSED =
  232. "update identity "
  233. " set username = coalesce(username, ?3) "
  234. " where (case when (address = ?1) then (1)"
  235. " when (lower(address) = lower(?1)) then (1)"
  236. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1) "
  237. " else 0 "
  238. " end) = 1 "
  239. " and user_id = ?2 ;";
  240. // " (select"
  241. // " coalesce("
  242. // " (select flags from identity"
  243. // " where address = ?1 and"
  244. // " user_id = ?3),"
  245. // " 0)"
  246. // " ) | (?4 & 255)"
  247. /* set_identity ignores previous flags, and doesn't filter machine flags */
  248. static const char *sql_set_identity_flags MAYBE_UNUSED =
  249. "update identity set flags = "
  250. " ((?1 & 65535) | (select flags from identity"
  251. " where (case when (address = ?2) then (1)"
  252. " when (lower(address) = lower(?2)) then (1)"
  253. " when (replace(lower(address),'.','') = replace(lower(?2),'.','')) then (1)"
  254. " else 0 "
  255. " end) = 1 "
  256. " and user_id = ?3)) "
  257. " where (case when (address = ?2) then (1)"
  258. " when (lower(address) = lower(?2)) then (1)"
  259. " when (replace(lower(address),'.','') = replace(lower(?2),'.','')) then (1)"
  260. " else 0"
  261. " end) = 1"
  262. " and user_id = ?3 ;";
  263. static const char *sql_unset_identity_flags MAYBE_UNUSED =
  264. "update identity set flags = "
  265. " ( ~(?1 & 65535) & (select flags from identity"
  266. " where (case when (address = ?2) then (1)"
  267. " when (lower(address) = lower(?2)) then (1)"
  268. " when (replace(lower(address),'.','') = replace(lower(?2),'.','')) then (1)"
  269. " else 0 "
  270. " end) = 1 "
  271. " and user_id = ?3)) "
  272. " where (case when (address = ?2) then (1)"
  273. " when (lower(address) = lower(?2)) then (1)"
  274. " when (replace(lower(address),'.','') = replace(lower(?2),'.','')) then (1)"
  275. " else 0"
  276. " end) = 1"
  277. " and user_id = ?3 ;";
  278. static const char *sql_set_ident_enc_format MAYBE_UNUSED =
  279. "update identity "
  280. " set enc_format = ?1 "
  281. " where (case when (address = ?2) then (1)"
  282. " when (lower(address) = lower(?2)) then (1)"
  283. " when (replace(lower(address),'.','') = replace(lower(?2),'.','')) then (1) "
  284. " else 0 "
  285. " end) = 1 "
  286. " and user_id = ?3 ;";
  287. static const char *sql_set_pEp_version MAYBE_UNUSED =
  288. "update identity "
  289. " set pEp_version_major = ?1, "
  290. " pEp_version_minor = ?2 "
  291. " where (case when (address = ?3) then (1)"
  292. " when (lower(address) = lower(?3)) then (1)"
  293. " when (replace(lower(address),'.','') = replace(lower(?3),'.','')) then (1) "
  294. " else 0 "
  295. " end) = 1 "
  296. " and user_id = ?4 ;";
  297. static const char *sql_upgrade_pEp_version_by_user_id MAYBE_UNUSED =
  298. "update identity "
  299. " set pEp_version_major = ?1, "
  300. " pEp_version_minor = ?2 "
  301. " where user_id = ?3 "
  302. " and (case when (pEp_version_major < ?1) then (1)"
  303. " when (pEp_version_major > ?1) then (0)"
  304. " when (pEp_version_minor < ?2) then (1)"
  305. " else 0 "
  306. " end) = 1 ;";
  307. static const char *sql_set_trust MAYBE_UNUSED =
  308. "insert into trust (user_id, pgp_keypair_fpr, comm_type) "
  309. "values (?1, upper(replace(?2,' ','')), ?3) ;";
  310. static const char *sql_update_trust MAYBE_UNUSED =
  311. "update trust set comm_type = ?3 "
  312. " where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ',''));";
  313. static const char *sql_clear_trust_info MAYBE_UNUSED =
  314. "delete from trust "
  315. " where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ',''));";
  316. static const char *sql_update_trust_to_pEp MAYBE_UNUSED =
  317. "update trust set comm_type = comm_type + 71 "
  318. " where (user_id = ?1 "
  319. " and (case when (comm_type = 56) then (1) "
  320. " when (comm_type = 184) then (1) "
  321. " else 0"
  322. " end) = 1); ";
  323. static const char* sql_exists_trust_entry MAYBE_UNUSED =
  324. "select count(*) from trust "
  325. " where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ',''));";
  326. static const char *sql_update_trust_for_fpr MAYBE_UNUSED =
  327. "update trust "
  328. "set comm_type = ?1 "
  329. "where pgp_keypair_fpr = upper(replace(?2,' ','')) ;";
  330. static const char *sql_get_trust MAYBE_UNUSED =
  331. "select comm_type from trust where user_id = ?1 "
  332. "and pgp_keypair_fpr = upper(replace(?2,' ','')) ;";
  333. static const char *sql_get_trust_by_userid MAYBE_UNUSED =
  334. "select pgp_keypair_fpr, comm_type from trust where user_id = ?1 ";
  335. static const char *sql_least_trust MAYBE_UNUSED =
  336. "select min(comm_type) from trust where"
  337. " pgp_keypair_fpr = upper(replace(?1,' ',''))"
  338. " and comm_type != 0;"; // ignores PEP_ct_unknown
  339. // returns PEP_ct_unknown only when no known trust is recorded
  340. static const char *sql_update_key_sticky_bit_for_user MAYBE_UNUSED =
  341. "update trust set sticky = ?1 "
  342. " where user_id = ?2 and pgp_keypair_fpr = upper(replace(?3,' ','')) ;";
  343. static const char *sql_is_key_sticky_for_user MAYBE_UNUSED =
  344. "select sticky from trust "
  345. " where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ','')) ; ";
  346. static const char *sql_mark_as_compromised MAYBE_UNUSED =
  347. "update trust not indexed set comm_type = 15"
  348. " where pgp_keypair_fpr = upper(replace(?1,' ','')) ;";
  349. static const char *sql_crashdump MAYBE_UNUSED =
  350. "select timestamp, title, entity, description, comment"
  351. " from log order by timestamp desc limit ?1 ;";
  352. static const char *sql_languagelist MAYBE_UNUSED =
  353. "select i18n_language.lang, name, phrase"
  354. " from i18n_language join i18n_token using (lang) where i18n_token.id = 1000;" ;
  355. static const char *sql_i18n_token MAYBE_UNUSED =
  356. "select phrase from i18n_token where lang = lower(?1) and id = ?2 ;";
  357. // Own keys
  358. // We only care if it's 0 or non-zero
  359. static const char *sql_own_key_is_listed MAYBE_UNUSED =
  360. "select count(*) from ("
  361. " select pgp_keypair_fpr from trust"
  362. " join identity on trust.user_id = identity.user_id"
  363. " where pgp_keypair_fpr = upper(replace(?1,' ',''))"
  364. " and identity.is_own = 1"
  365. ");";
  366. static const char *sql_is_own_address MAYBE_UNUSED =
  367. "select count(*) from ("
  368. " select address from identity"
  369. " where (case when (address = ?1) then (1)"
  370. " when (lower(address) = lower(?1)) then (1)"
  371. " when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1)"
  372. " else 0"
  373. " end) = 1 "
  374. " and identity.is_own = 1"
  375. ");";
  376. static const char *sql_own_identities_retrieve MAYBE_UNUSED =
  377. "select address, identity.main_key_id, identity.user_id,"
  378. " (case when (identity.flags & 1024 = 0) then ifnull(identity.username, person.username) "
  379. " else identity.username end),"
  380. " lang, identity.flags,"
  381. // " identity.flags | pgp_keypair.flags,"
  382. " pEp_version_major, pEp_version_minor"
  383. " from identity"
  384. " join person on id = identity.user_id"
  385. " left join pgp_keypair on fpr = identity.main_key_id"
  386. " left join trust on id = trust.user_id"
  387. " and pgp_keypair_fpr = identity.main_key_id"
  388. " where identity.is_own = 1"
  389. " and (identity.flags & ?1) = 0;";
  390. static const char *sql_own_keys_retrieve MAYBE_UNUSED =
  391. "select distinct pgp_keypair_fpr from trust"
  392. " join identity on trust.user_id = identity.user_id"
  393. " where identity.is_own = 1";
  394. static const char* sql_get_user_default_key MAYBE_UNUSED =
  395. "select main_key_id from person"
  396. " where id = ?1;";
  397. static const char* sql_get_all_keys_for_user MAYBE_UNUSED =
  398. "select pgp_keypair_fpr from trust"
  399. " where user_id = ?1; ";
  400. static const char* sql_get_default_own_userid MAYBE_UNUSED =
  401. "select id from person"
  402. " join identity on id = identity.user_id"
  403. " where identity.is_own = 1";
  404. // Sequence
  405. static const char *sql_sequence_value1 MAYBE_UNUSED =
  406. "insert or replace into sequences (name, value) "
  407. "values (?1, "
  408. " (select coalesce((select value + 1 from sequences "
  409. " where name = ?1), 1 ))); ";
  410. static const char *sql_sequence_value2 MAYBE_UNUSED =
  411. "select value from sequences where name = ?1 ;";
  412. // Revocation tracking
  413. static const char *sql_set_revoked MAYBE_UNUSED =
  414. "insert or replace into revoked_keys ("
  415. " revoked_fpr, replacement_fpr, revocation_date) "
  416. "values (upper(replace(?1,' ','')),"
  417. " upper(replace(?2,' ','')),"
  418. " ?3) ;";
  419. static const char *sql_get_revoked MAYBE_UNUSED =
  420. "select revoked_fpr, revocation_date from revoked_keys"
  421. " where replacement_fpr = upper(replace(?1,' ','')) ;";
  422. static const char *sql_get_replacement_fpr MAYBE_UNUSED =
  423. "select replacement_fpr, revocation_date from revoked_keys"
  424. " where revoked_fpr = upper(replace(?1,' ','')) ;";
  425. static const char *sql_get_userid_alias_default MAYBE_UNUSED =
  426. "select default_id from alternate_user_id "
  427. " where alternate_id = ?1 ; ";
  428. // Revocation tracking
  429. static const char *sql_add_mistrusted_key MAYBE_UNUSED =
  430. "insert or replace into mistrusted_keys (fpr) "
  431. " values (upper(replace(?1,' ',''))) ;";
  432. static const char *sql_delete_mistrusted_key MAYBE_UNUSED =
  433. "delete from mistrusted_keys where fpr = upper(replace(?1,' ','')) ;";
  434. static const char *sql_is_mistrusted_key MAYBE_UNUSED =
  435. "select count(*) from mistrusted_keys where fpr = upper(replace(?1,' ','')) ;";
  436. static const char *sql_add_userid_alias MAYBE_UNUSED =
  437. "insert or replace into alternate_user_id (alternate_id, default_id) "
  438. "values (?2, ?1) ;";
  439. static const char *sql_add_into_social_graph MAYBE_UNUSED =
  440. "insert or replace into social_graph(own_userid, own_address, contact_userid) "
  441. "values (?1, ?2, ?3) ;";
  442. static const char *sql_get_own_address_binding_from_contact MAYBE_UNUSED =
  443. "select own_address from social_graph where own_userid = ?1 and contact_userid = ?2 ;";
  444. static const char *sql_set_revoke_contact_as_notified MAYBE_UNUSED =
  445. "insert or replace into revocation_contact_list(fpr, own_address, contact_id) values (?1, ?2, ?3) ;";
  446. static const char *sql_get_contacted_ids_from_revoke_fpr MAYBE_UNUSED =
  447. "select * from revocation_contact_list where fpr = ?1 ;";
  448. static const char *sql_was_id_for_revoke_contacted MAYBE_UNUSED =
  449. "select count(*) from revocation_contact_list where fpr = ?1 and own_address = ?2 and contact_id = ?3 ;";
  450. static const char *sql_has_id_contacted_address MAYBE_UNUSED =
  451. "select count(*) from social_graph where own_address = ?1 and contact_userid = ?2 ;";
  452. // We only need user_id and address, since in the main usage, we'll call update_identity
  453. // on this anyway when sending out messages.
  454. static const char *sql_get_last_contacted MAYBE_UNUSED =
  455. "select user_id, address from identity where datetime('now') < datetime(timestamp, '+14 days') ; ";
  456. static const char *sql_create_group MAYBE_UNUSED =
  457. "insert into groups (group_id, group_address, manager_userid, manager_address) "
  458. "VALUES (?1, ?2, ?3, ?4) ;";
  459. static const char *sql_enable_group MAYBE_UNUSED =
  460. "update groups set active = 1 "
  461. " where group_id = ?1 and group_address = ?2 ;";
  462. static const char *sql_disable_group MAYBE_UNUSED =
  463. "update groups set active = 0 "
  464. " where group_id = ?1 and group_address = ?2 ;";
  465. static const char *sql_exists_group_entry MAYBE_UNUSED =
  466. "select count(*) from groups "
  467. " where group_id = ?1 and group_address = ?2;";
  468. static const char *sql_group_add_member MAYBE_UNUSED =
  469. "insert or ignore into own_groups_members (group_id, group_address, member_id, member_address) "
  470. " values (?1, ?2, ?3, ?4) ;";
  471. static const char *sql_group_delete_member MAYBE_UNUSED =
  472. "delete from own_groups_members "
  473. " where group_id = ?1 and group_address = ?2 and "
  474. " member_id = ?3 and member_address = ?4 ;";
  475. static const char *sql_set_group_member_status MAYBE_UNUSED =
  476. "update own_groups_members set active_member = ?1 "
  477. " where group_id = ?2 and group_address = ?3 and "
  478. " member_id = ?4 and member_address = ?5; ";
  479. static const char *sql_group_join MAYBE_UNUSED =
  480. "update own_memberships set have_joined = 1 "
  481. " where group_id = ?1 and group_address = ?2 and "
  482. " own_id = ?3 and own_address = ?4; ";
  483. static const char *sql_leave_group MAYBE_UNUSED =
  484. "update own_memberships set have_joined = 0 "
  485. " where group_id = ?1 and group_address = ?2 and "
  486. " own_id = ?3 and own_address = ?4; ";
  487. static const char *sql_get_all_members MAYBE_UNUSED =
  488. "select member_id, member_address, active_member from own_groups_members "
  489. " where group_id = ?1 and group_address = ?2; ";
  490. static const char *sql_get_active_members MAYBE_UNUSED =
  491. "select member_id, member_address from own_groups_members "
  492. " where group_id = ?1 and group_address = ?2 and active_member = 1; ";
  493. static const char *sql_get_group_manager MAYBE_UNUSED =
  494. "select manager_userid, manager_address from groups "
  495. " where group_id = ?1 and group_address = ?2; ";
  496. static const char *sql_is_invited_group_member MAYBE_UNUSED =
  497. "select count(*) from own_groups_members "
  498. " where group_id = ?1 and group_address = ?2 and member_id = ?3 and member_address = ?4; ";
  499. static const char *sql_is_active_group_member MAYBE_UNUSED =
  500. "select active_member from own_groups_members "
  501. " where group_id = ?1 and group_address = ?2 and member_id = ?3 and member_address = ?4; ";
  502. static const char *sql_get_all_groups MAYBE_UNUSED =
  503. "select group_id, group_address from own_memberships; ";
  504. static const char *sql_get_active_groups MAYBE_UNUSED =
  505. "select group_id, group_address from own_memberships where have_joined = 1; ";
  506. static const char *sql_add_own_membership_entry MAYBE_UNUSED =
  507. "insert or replace into own_memberships (group_id, group_address, own_id, own_address, have_joined) "
  508. " values (?1, ?2, ?3, ?4, 0) ; ";
  509. static const char *sql_is_group_active MAYBE_UNUSED =
  510. "select count(*) from groups "
  511. " where group_id = ?1 and group_address = ?2 and active = 1; ";
  512. // This below can return multiple entries for multiple idents in same group
  513. // FIXME: decide what we really need here
  514. static const char *sql_retrieve_own_membership_info_for_group MAYBE_UNUSED =
  515. "select own_id, own_address, have_joined "
  516. " from own_memberships "
  517. " inner join groups using (group_id, group_address) "
  518. " where group_id = ?1 and group_address = ?2; ";
  519. static const char *sql_retrieve_own_membership_info_for_group_and_ident
  520. MAYBE_UNUSED =
  521. "select have_joined, manager_userid, manager_address, active "
  522. " from own_memberships "
  523. " inner join groups using (group_id, group_address) "
  524. " where group_id = ?1 and group_address = ?2 and own_id = ?3 and own_address = ?4; ";
  525. // This will return all membership info for all identities
  526. static const char *sql_retrieve_all_own_membership_info MAYBE_UNUSED =
  527. "select group_id, group_address, own_id, own_address, have_joined, manager_id, manager_address, active "
  528. " from own_memberships "
  529. " inner join using (group_id, group_address); ";
  530. static const char* sql_get_own_membership_status MAYBE_UNUSED =
  531. "select have_joined from own_memberships "
  532. " where group_id = ?1 and group_address = ?2 and "
  533. " own_id = ?3 and own_address = ?4; ";