Browse Source

Merge with sequoia_windows

ENGINE-641
Thomas 3 years ago
parent
commit
1d458d9234
11 changed files with 917 additions and 210 deletions
  1. +4
    -58
      build-windows/libpEpasn1/libpEpasn1.vcxproj
  2. +749
    -110
      build-windows/libpEpasn1/libpEpasn1.vcxproj.filters
  3. +42
    -17
      build-windows/pEpEngine.vcxproj
  4. +27
    -21
      build-windows/pEpEngine.vcxproj.filters
  5. +4
    -0
      build-windows/packages.config
  6. +2
    -0
      src/etpan_mime.h
  7. +4
    -0
      src/pEpEngine.c
  8. +1
    -0
      src/pEp_internal.h
  9. +25
    -4
      src/pgp_sequoia.c
  10. +56
    -0
      src/platform_windows.cpp
  11. +3
    -0
      src/platform_windows.h

+ 4
- 58
build-windows/libpEpasn1/libpEpasn1.vcxproj View File

@ -9,14 +9,6 @@
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9A67164D-B8F8-4601-A24B-28AFE774D41C}</ProjectGuid>
@ -38,19 +30,6 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
@ -62,15 +41,9 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(ProjectDir)..\..\asn.1;$(IncludePath)</IncludePath>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(ProjectDir)..\..\asn.1;$(IncludePath)</IncludePath>
@ -82,6 +55,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\asn.1</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -91,18 +65,6 @@
<Message>Generating Code for pEp Sync</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@ -112,6 +74,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\asn.1</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -123,22 +86,6 @@
<Message>Generating Code for pEp Sync</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
@ -149,6 +96,5 @@
<ClCompile Include="..\..\asn.1\*.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ImportGroup Label="ExtensionTargets" />
</Project>

+ 749
- 110
build-windows/libpEpasn1/libpEpasn1.vcxproj.filters
File diff suppressed because it is too large
View File


+ 42
- 17
build-windows/pEpEngine.vcxproj View File

@ -43,46 +43,56 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<RunCodeAnalysis>false</RunCodeAnalysis>
<IncludePath>$(ProjectDir)\..\..\libetpan\build-windows\include;C:\Program Files %28x86%29\GnuPG\include;$(IncludePath);$(ProjectDir)\asn.1;%ASN1C%\share\asn1c</IncludePath>
<LibraryPath>$(ProjectDir)\..\..\libetpan\build-windows\Debug;$(LibraryPath)</LibraryPath>
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
<PreLinkEventUseInBuild>true</PreLinkEventUseInBuild>
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Linkage-libiconv>
</Linkage-libiconv>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)\..\..\libetpan\build-windows\include;C:\Program Files %28x86%29\GnuPG\include;$(IncludePath);$(ProjectDir)\asn.1;%ASN1C%\share\asn1c</IncludePath>
<LibraryPath>$(ProjectDir)\..\..\libetpan\build-windows\Release;$(LibraryPath)</LibraryPath>
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
<PreLinkEventUseInBuild>true</PreLinkEventUseInBuild>
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
<Linkage-libiconv>
</Linkage-libiconv>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PEPENGINE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PEPENGINE_EXPORTS;_CRT_SECURE_NO_WARNINGS;USE_SEQUOIA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<EnablePREfast>false</EnablePREfast>
<AdditionalIncludeDirectories>$(SolutionDir)Tools\asn1c\share\asn1c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libetpan\build-windows\include;$(SolutionDir)Tools\asn1c\share\asn1c;$(SolutionDir)sequoia\openpgp-ffi\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4703</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>sequoia_openpgp_ffi.lib;gmp.lib;nettle.lib;hogweed.lib;ws2_32.lib;userenv.lib;dbghelp.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<AdditionalLibraryDirectories>$(SolutionDir)sequoia\target\debug;C:\msys64\mingw32\lib</AdditionalLibraryDirectories>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<SuppressStartupBanner>false</SuppressStartupBanner>
</Link>
<PreBuildEvent>
<Command>
</Command>
<Command>cargo build --manifest-path="$(SolutionDir)sequoia\Cargo.toml" -p sequoia-openpgp-ffi</Command>
<Message>
</Message>
</PreBuildEvent>
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)sequoia\target\debug\sequoia_openpgp_ffi.lib" "$(TargetDir)" /Y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -91,28 +101,32 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PEPENGINE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PEPENGINE_EXPORTS;USE_SEQUOIA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<TreatWarningAsError>false</TreatWarningAsError>
<AdditionalIncludeDirectories>$(SolutionDir)Tools\asn1c\share\asn1c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libetpan\build-windows\include;$(SolutionDir)Tools\asn1c\share\asn1c;$(SolutionDir)sequoia\openpgp-ffi\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
<EnablePREfast>false</EnablePREfast>
<DisableSpecificWarnings>4703</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>sequoia_openpgp_ffi.lib;gmp.lib;nettle.lib;hogweed.lib;ws2_32.lib;userenv.lib;dbghelp.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)sequoia\target\release;C:\msys64\mingw32\lib</AdditionalLibraryDirectories>
</Link>
<PreBuildEvent>
<Command>
</Command>
<Command>cargo build --manifest-path="$(SolutionDir)sequoia\Cargo.toml" --release -p sequoia-openpgp-ffi</Command>
<Message>
</Message>
</PreBuildEvent>
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)sequoia\target\release\sequoia_openpgp_ffi.lib" "$(TargetDir)" /Y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\base64.c" />
@ -135,7 +149,7 @@
<ClCompile Include="..\src\openpgp_compat.c" />
<ClCompile Include="..\src\pEpEngine.c" />
<ClCompile Include="..\src\pEp_string.c" />
<ClCompile Include="..\src\pgp_gpg.c" />
<ClCompile Include="..\src\pgp_sequoia.c" />
<ClCompile Include="..\src\platform_windows.cpp" />
<ClCompile Include="..\src\resource_id.c" />
<ClCompile Include="..\src\sqlite3.c" />
@ -161,6 +175,7 @@
<ClInclude Include="..\src\dynamic_api.h" />
<ClInclude Include="..\src\email.h" />
<ClInclude Include="..\src\etpan_mime.h" />
<ClInclude Include="..\src\fsm_common.h" />
<ClInclude Include="..\src\growing_buf.h" />
<ClInclude Include="..\src\identity_list.h" />
<ClInclude Include="..\src\keymanagement.h" />
@ -175,8 +190,8 @@
<ClInclude Include="..\src\pEpEngine.h" />
<ClInclude Include="..\src\pEp_internal.h" />
<ClInclude Include="..\src\pEp_string.h" />
<ClInclude Include="..\src\pgp_gpg.h" />
<ClInclude Include="..\src\pgp_gpg_internal.h" />
<ClInclude Include="..\src\pgp_sequoia.h" />
<ClInclude Include="..\src\pgp_sequoia_internal.h" />
<ClInclude Include="..\src\platform.h" />
<ClInclude Include="..\src\platform_windows.h" />
<ClInclude Include="..\src\resource.h" />
@ -205,7 +220,17 @@
<Project>{9a67164d-b8f8-4601-a24b-28afe774d41c}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\boost.1.70.0.0\build\boost.targets" Condition="Exists('..\..\packages\boost.1.70.0.0\build\boost.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\boost.1.70.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\boost.1.70.0.0\build\boost.targets'))" />
</Target>
</Project>

+ 27
- 21
build-windows/pEpEngine.vcxproj.filters View File

@ -33,9 +33,6 @@
<ClCompile Include="..\src\cryptotech.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\src\pgp_gpg.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\src\email.c">
<Filter>Quelldateien</Filter>
</ClCompile>
@ -54,9 +51,6 @@
<ClCompile Include="..\src\bloblist.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\src\etpan_mime.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\src\identity_list.c">
<Filter>Quelldateien</Filter>
</ClCompile>
@ -120,6 +114,12 @@
<ClCompile Include="..\src\base64.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\src\pgp_sequoia.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\src\etpan_mime.c">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\keymanagement.h">
@ -140,15 +140,9 @@
<ClInclude Include="..\src\cryptotech.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\pgp_gpg.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\pEp_internal.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\pgp_gpg_internal.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\resource.h">
<Filter>Ressourcendateien</Filter>
</ClInclude>
@ -176,9 +170,6 @@
<ClInclude Include="..\src\dynamic_api.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\etpan_mime.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\identity_list.h">
<Filter>Headerdateien</Filter>
</ClInclude>
@ -236,12 +227,6 @@
<ClInclude Include="..\src\Sync_event.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\Sync_func.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\Sync_impl.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\growing_buf.h">
<Filter>Headerdateien</Filter>
</ClInclude>
@ -257,8 +242,29 @@
<ClInclude Include="..\src\KeySync_fsm.h">
<Filter>Quelldateien</Filter>
</ClInclude>
<ClInclude Include="..\src\fsm_common.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\pgp_sequoia.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\pgp_sequoia_internal.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\Sync_func.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\Sync_impl.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="..\src\etpan_mime.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\LICENSE.txt" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

+ 4
- 0
build-windows/packages.config View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="boost" version="1.70.0.0" targetFramework="native" />
</packages>

+ 2
- 0
src/etpan_mime.h View File

@ -3,6 +3,8 @@
#pragma once
#define _EXPORT_PEP_ENGINE_DLL
#include <libetpan/libetpan.h>
#include <libetpan/mailmime.h>
#include <libetpan/mailmime_encode.h>


+ 4
- 0
src/pEpEngine.c View File

@ -2155,6 +2155,10 @@ DYNAMIC_API PEP_STATUS log_event(
)
{
#if defined(_WIN32) && !defined(NDEBUG)
log_output_debug(title, entity, description, comment);
#endif
// N.B. If testing (so NDEBUG not defined) but this message is spam,
// put -D_PEP_SERVICE_LOG_OFF into CFLAGS/CXXFLAGS
#if !defined(NDEBUG) && !defined(_PEP_SERVICE_LOG_OFF)


+ 1
- 0
src/pEp_internal.h View File

@ -62,6 +62,7 @@
#include "platform.h"
#ifdef WIN32
#define KEYS_DB windoze_keys_db()
#define LOCAL_DB windoze_local_db()
#define SYSTEM_DB windoze_system_db()
#define LIBGPGME "libgpgme-11.dll"


+ 25
- 4
src/pgp_sequoia.c View File

@ -7,7 +7,7 @@
#include "platform.h"
#include "pEp_internal.h"
#include "pgp_gpg.h"
#include "pgp_sequoia.h"
#include <limits.h>
#include <sys/stat.h>
@ -34,6 +34,13 @@
__android_log_print(ANDROID_LOG_DEBUG, "pEpEngine-sequoia", \
##__VA_ARGS__); \
} while (0)
# elif _WIN32
# define _T(...) do { \
char str[256]; \
snprintf(str, 256, ##__VA_ARGS__); \
OutputDebugStringA(str); \
} while (0)
# else
# define _T(...) do { \
fprintf(stderr, ##__VA_ARGS__); \
@ -182,15 +189,27 @@ PEP_STATUS pgp_init(PEP_SESSION session, bool in_first)
{
PEP_STATUS status = PEP_STATUS_OK;
#define PEP_KEYS_PATH "/.pEp_keys.db"
#ifdef _WIN32
int sqlite_result;
sqlite_result = sqlite3_open_v2(KEYS_DB,
&session->key_db,
SQLITE_OPEN_READWRITE
| SQLITE_OPEN_CREATE
| SQLITE_OPEN_FULLMUTEX
| SQLITE_OPEN_PRIVATECACHE,
NULL);
#else
// Create the home directory.
char *home_env = NULL;
#ifndef NDEBUG
home_env = getenv("PEP_HOME");
#endif
#define PEP_KEYS_PATH "/.pEp/keys.db"
if (!home_env)
home_env = getenv("HOME");
if (!home_env)
ERROR_OUT(NULL, PEP_INIT_GPGME_INIT_FAILED, "HOME unset");
@ -201,7 +220,7 @@ PEP_STATUS pgp_init(PEP_SESSION session, bool in_first)
if (!path)
ERROR_OUT(NULL, PEP_OUT_OF_MEMORY, "out of memory");
int r = snprintf(path, path_size, "%s" PEP_KEYS_PATH, home_env);
int r = snprintf(path, path_size, "%s" PEP_KEYS_PATH, home_env);
assert(r >= 0 && r < path_size);
if (r < 0)
ERROR_OUT(NULL, PEP_UNKNOWN_ERROR, "snprintf");
@ -215,6 +234,8 @@ PEP_STATUS pgp_init(PEP_SESSION session, bool in_first)
| SQLITE_OPEN_PRIVATECACHE,
NULL);
free(path);
#endif
if (sqlite_result != SQLITE_OK)
ERROR_OUT(NULL, PEP_INIT_CANNOT_OPEN_DB,
"opening keys DB: %s", sqlite3_errmsg(session->key_db));


+ 56
- 0
src/platform_windows.cpp View File

@ -24,11 +24,15 @@
#define LOCAL_DB_FILENAME "management.db"
#define SYSTEM_DB_FILENAME "system.db"
#define KEYS_DB "keys.db"
#define USER_FOLDER_PATH pEpUserFolderPath().c_str()
#define SYSTEM_FOLDER_PATH pEpSystemFolderPath().c_str()
#ifndef WC_ERR_INVALID_CHARS
#define WC_ERR_INVALID_CHARS 0x00000080 // error for invalid chars
#endif
using namespace std;
static string utf8_string(wstring wstr) {
@ -136,6 +140,38 @@ static inline string managementPath(const char *file_path, const char *file_name
return path;
}
static inline string pEpSystemFolderPath(void)
{
static TCHAR tPath[PATH_BUF_SIZE];
string path = PER_MACHINE_DIRECTORY;
// Get SystemFolder Registry value and use if available
bool result = readRegistryString(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\pEp"), TEXT("SystemFolder"), tPath,
PATH_BUF_SIZE, NULL);
if (result)
path = utf8_string(tPath);
return path;
}
static inline string pEpUserFolderPath(void)
{
static TCHAR tPath[PATH_BUF_SIZE];
string path = PER_USER_DIRECTORY;
// Get UserFolder Registry value and use if available
bool result = readRegistryString(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\pEp"), TEXT("UserFolder"), tPath,
PATH_BUF_SIZE, NULL);
if (result)
path = utf8_string(tPath);
return path;
}
extern "C" {
DYNAMIC_API const char *per_user_directory(void)
@ -231,6 +267,14 @@ void *dlsym(void *handle, const char *symbol) {
return (void *) (intptr_t) GetProcAddress((HMODULE) handle, symbol);
}
const char *windoze_keys_db(void) {
static string path;
if (path.length() == 0) {
path = managementPath(USER_FOLDER_PATH, KEYS_DB);
}
return path.c_str();
}
const char *windoze_local_db(void) {
static string path;
if (path.length() == 0)
@ -397,6 +441,18 @@ void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
}
}
void log_output_debug(const char *title,
const char *entity,
const char *description,
const char *comment)
{
const size_t size = 256;
char str[size];
snprintf(str, size, "*** %s %s %s %s\n", title, entity, description, comment);
OutputDebugStringA(str);
}
time_t timegm(struct tm* tm) {
return _mkgmtime(tm);
}


+ 3
- 0
src/platform_windows.h View File

@ -87,11 +87,14 @@ size_t strlcat(char* dst, const char* src, size_t size);
char *strnstr(const char *big, const char *little, size_t len);
const char *windoze_keys_db(void);
const char *windoze_local_db(void);
const char *windoze_system_db(void);
const char *gpg_conf(void);
const char *gpg_agent_conf(void);
void log_output_debug(const char *title, const char *entity, const char *description, const char *comment);
long random(void);
// on Windoze, uuid_t needs pointer semantics


Loading…
Cancel
Save