merged in sender fpr checks sender-fpr-checks
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 20 Sep 2019 11:40:38 +0200
branchsender-fpr-checks
changeset 407511a4b0c917c6
parent 4049 193b649cb621
parent 4067 79804ea86623
child 4076 acdc645f515a
merged in sender fpr checks
sync/gen_statemachine.ysl2
     1.1 --- a/src/baseprotocol.c	Wed Sep 04 18:51:10 2019 +0200
     1.2 +++ b/src/baseprotocol.c	Fri Sep 20 11:40:38 2019 +0200
     1.3 @@ -81,6 +81,7 @@
     1.4          goto enomem;
     1.5  
     1.6      add_opt_field(msg, "pEp-auto-consume", "yes");
     1.7 +    add_opt_field(msg, "in-reply-to", "pEp-auto-consume@pEp.foundation");
     1.8  
     1.9      msg->from = identity_dup(me);
    1.10      if (!msg->from)
     2.1 --- a/src/fsm_common.h	Wed Sep 04 18:51:10 2019 +0200
     2.2 +++ b/src/fsm_common.h	Fri Sep 20 11:40:38 2019 +0200
     2.3 @@ -39,6 +39,10 @@
     2.4      Extra = 128 // messages will be below this ID
     2.5  };
     2.6  
     2.7 +enum {
     2.8 +    SHUTDOWN = 0
     2.9 +};
    2.10 +
    2.11  #ifdef __cplusplus
    2.12  }
    2.13  #endif
     3.1 --- a/src/platform_windows.cpp	Wed Sep 04 18:51:10 2019 +0200
     3.2 +++ b/src/platform_windows.cpp	Fri Sep 20 11:40:38 2019 +0200
     3.3 @@ -25,8 +25,8 @@
     3.4  #define LOCAL_DB_FILENAME "management.db"
     3.5  #define SYSTEM_DB_FILENAME "system.db"
     3.6  #define KEYS_DB "keys.db"
     3.7 -#define USER_FOLDER_PATH pEpUserFolderPath().c_str()
     3.8 -#define SYSTEM_FOLDER_PATH pEpSystemFolderPath().c_str()
     3.9 +#define USER_FOLDER_PATH _per_user_directory()
    3.10 +#define SYSTEM_FOLDER_PATH _per_machine_directory()
    3.11  
    3.12  #ifndef WC_ERR_INVALID_CHARS
    3.13  #define WC_ERR_INVALID_CHARS      0x00000080  // error for invalid chars
    3.14 @@ -140,72 +140,68 @@
    3.15  	return path;
    3.16  }
    3.17  
    3.18 -static inline string pEpSystemFolderPath(void)
    3.19 +const char *_per_machine_directory(void)
    3.20  {
    3.21 -	static TCHAR tPath[PATH_BUF_SIZE];
    3.22 -	string path = PER_MACHINE_DIRECTORY;
    3.23 +	static string path;
    3.24 +	if (path.length())
    3.25 +		return path.c_str();
    3.26 +
    3.27 +	TCHAR tPath[PATH_BUF_SIZE];
    3.28  
    3.29  	// Get SystemFolder Registry value and use if available
    3.30  	bool result = readRegistryString(HKEY_CURRENT_USER,
    3.31  		TEXT("SOFTWARE\\pEp"), TEXT("SystemFolder"), tPath,
    3.32  		PATH_BUF_SIZE, NULL);
    3.33  
    3.34 -	if (result)
    3.35 -		path = utf8_string(tPath);
    3.36 +	// If not Registry value was found, use default
    3.37 +	if (!result) {
    3.38 +		DWORD length = ExpandEnvironmentStringsW(utf16_string(string(PER_MACHINE_DIRECTORY)).c_str(),
    3.39 +			tPath, PATH_BUF_SIZE);
    3.40 +		assert(length);
    3.41 +		if (length == 0)
    3.42 +			throw bad_alloc(); // BUG: there are other errors possible beside out of memory
    3.43 +	}
    3.44  
    3.45 -	return path;
    3.46 +	path = utf8_string(wstring(tPath));
    3.47 +	return path.c_str();
    3.48  }
    3.49  
    3.50 -static inline string pEpUserFolderPath(void)
    3.51 +const char *_per_user_directory(void)
    3.52  {
    3.53 -	static TCHAR tPath[PATH_BUF_SIZE];
    3.54 -	string path = PER_USER_DIRECTORY;
    3.55 +	static string path;
    3.56 +	if (path.length())
    3.57 +		return path.c_str();
    3.58 +
    3.59 +	TCHAR tPath[PATH_BUF_SIZE];
    3.60  
    3.61  	// Get UserFolder Registry value and use if available
    3.62  	bool result = readRegistryString(HKEY_CURRENT_USER,
    3.63  		TEXT("SOFTWARE\\pEp"), TEXT("UserFolder"), tPath,
    3.64  		PATH_BUF_SIZE, NULL);
    3.65  
    3.66 -	if (result)
    3.67 -		path = utf8_string(tPath);
    3.68 -	
    3.69 -	return path;
    3.70 +	// If not Registry value was found, use default
    3.71 +	if (!result) {
    3.72 +		DWORD length = ExpandEnvironmentStringsW(utf16_string(string(PER_USER_DIRECTORY)).c_str(),
    3.73 +			tPath, PATH_BUF_SIZE);
    3.74 +		assert(length);
    3.75 +		if (length == 0)
    3.76 +			throw bad_alloc(); // BUG: there are other errors possible beside out of memory
    3.77 +	}
    3.78 +
    3.79 +	path = utf8_string(wstring(tPath));
    3.80 +	return path.c_str();
    3.81  }
    3.82  
    3.83  extern "C" {
    3.84  
    3.85  DYNAMIC_API const char *per_user_directory(void)
    3.86  {
    3.87 -    static string path;
    3.88 -    if (path.length())
    3.89 -        return path.c_str();
    3.90 -
    3.91 -    TCHAR tPath[PATH_BUF_SIZE];
    3.92 -    DWORD length = ExpandEnvironmentStringsW(utf16_string(string(PER_USER_DIRECTORY)).c_str(),
    3.93 -            tPath, PATH_BUF_SIZE);
    3.94 -	assert(length);
    3.95 -    if (length == 0)
    3.96 -        throw bad_alloc(); // BUG: there are other errors possible beside out of memory
    3.97 -
    3.98 -    path = utf8_string(wstring(tPath));
    3.99 -    return path.c_str();
   3.100 +	return _per_user_directory();
   3.101  }
   3.102  
   3.103  DYNAMIC_API const char *per_machine_directory(void)
   3.104  {
   3.105 -    static string path;
   3.106 -    if (path.length())
   3.107 -        return path.c_str();
   3.108 -
   3.109 -    TCHAR tPath[PATH_BUF_SIZE];
   3.110 -    DWORD length = ExpandEnvironmentStringsW(utf16_string(string(PER_MACHINE_DIRECTORY)).c_str(),
   3.111 -            tPath, PATH_BUF_SIZE);
   3.112 -	assert(length);
   3.113 -    if (length == 0)
   3.114 -        throw bad_alloc(); // BUG: there are other errors possible beside out of memory
   3.115 -
   3.116 -    path = utf8_string(wstring(tPath));
   3.117 -    return path.c_str();
   3.118 +	return _per_machine_directory();
   3.119  }
   3.120  
   3.121  void *dlopen(const char *filename, int flag) {
   3.122 @@ -278,7 +274,7 @@
   3.123  const char *windoze_local_db(void) {
   3.124  	static string path;
   3.125  	if (path.length() == 0)
   3.126 -        path = managementPath(PER_USER_DIRECTORY, LOCAL_DB_FILENAME);
   3.127 +        path = managementPath(USER_FOLDER_PATH, LOCAL_DB_FILENAME);
   3.128      return path.c_str();
   3.129  }
   3.130  
     4.1 --- a/src/sync_api.c	Wed Sep 04 18:51:10 2019 +0200
     4.2 +++ b/src/sync_api.c	Fri Sep 20 11:40:38 2019 +0200
     4.3 @@ -267,7 +267,6 @@
     4.4      return status;
     4.5  }
     4.6  
     4.7 -
     4.8  DYNAMIC_API PEP_STATUS disable_identity_for_sync(PEP_SESSION session,
     4.9          pEp_identity *ident)
    4.10  {
     5.1 --- a/sync/cond_act_sync.yml2	Wed Sep 04 18:51:10 2019 +0200
     5.2 +++ b/sync/cond_act_sync.yml2	Fri Sep 20 11:40:38 2019 +0200
     5.3 @@ -537,4 +537,13 @@
     5.4      session->sync_state.keysync.is_group = false;
     5.5  ||
     5.6  
     5.7 -action disable;
     5.8 +action disable
     5.9 +||
    5.10 +    leave_device_group(session);
    5.11 +    // ignore the result, disable anyway
    5.12 +
    5.13 +    if (!session->inject_sync_event)
    5.14 +        return PEP_SYNC_NO_INJECT_CALLBACK;
    5.15 +
    5.16 +    session->inject_sync_event(SHUTDOWN, NULL);
    5.17 +||
     6.1 --- a/sync/gen_statemachine.ysl2	Wed Sep 04 18:51:10 2019 +0200
     6.2 +++ b/sync/gen_statemachine.ysl2	Fri Sep 20 11:40:38 2019 +0200
     6.3 @@ -554,6 +554,7 @@
     6.4                                  goto the_end;
     6.5                              }
     6.6                              add_opt_field(m, "pEp-auto-consume", "yes");
     6.7 +                            add_opt_field(m, "in-reply-to", "pEp-auto-consume@pEp.foundation");
     6.8                              free_message(_m);
     6.9                              break;
    6.10  
    6.11 @@ -732,6 +733,7 @@
    6.12                                  goto the_end;
    6.13                              }
    6.14                              add_opt_field(m, "pEp-auto-consume", "yes");
    6.15 +                            add_opt_field(m, "in-reply-to", "pEp-auto-consume@pEp.foundation");
    6.16                              free_message(_m);
    6.17                              break;
    6.18  
    6.19 @@ -756,6 +758,7 @@
    6.20                                  goto the_end;
    6.21                              }
    6.22                              add_opt_field(m, "pEp-auto-consume", "yes");
    6.23 +                            add_opt_field(m, "in-reply-to", "pEp-auto-consume@pEp.foundation");
    6.24                              free_message(_m);
    6.25                      }
    6.26  
     7.1 --- a/test/Makefile	Wed Sep 04 18:51:10 2019 +0200
     7.2 +++ b/test/Makefile	Fri Sep 20 11:40:38 2019 +0200
     7.3 @@ -115,6 +115,7 @@
     7.4  clean:
     7.5  	$(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
     7.6  	$(RM) gtest_main.o gtest-all.o
     7.7 +	$(RM) -rf ./pEp_test_home/*
     7.8  # If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
     7.9  ifneq ($(MAKECMDGOALS),clean)
    7.10      -include $(DEPS)