<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DLL Debug|Win32">
<Configuration>DLL Debug</Configuration>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DLL Debug|Win32">
<Configuration>DLL Debug</Configuration>
<ClCompile Include="..\..\source\common\uuid.cpp" />
<ClCompile Include="..\..\source\common\win32ssl.cpp" />
<ClCompile Include="..\..\source\connobject\ConnectionObject.cpp" />
+ <ClCompile Include="..\..\source\contacteditor\cdo\ContactDataObject-Save.cpp" />
<ClCompile Include="..\..\source\contacteditor\cdo\ContactDataObject.cpp" />
<ClCompile Include="..\..\source\contacteditor\frmContactEditor-Business.cpp" />
<ClCompile Include="..\..\source\contacteditor\frmContactEditor-Calendar.cpp" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>false</CLRSupport>
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(CURL_64BIT)\builds\libcurl-vc-x64-release-dll-zlib-static-ipv6-sspi-winssl\include;$(ICONV_64BIT)\include;$(WXWIDGETS_64BIT_DEBUG)\lib\vc_x64_dll\mswud;$(WXWIDGETS_64BIT_DEBUG)\include;$(SFML_64BIT)\include;$(LIBXML2_64BIT)\include\libxml2;.</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(CURL_64BIT)\builds\libcurl-vc-x64-release-dll-zlib-dll-ipv6-sspi-winssl\include;$(ICONV_64BIT)\include;$(WXWIDGETS_64BIT_DEBUG)\lib\vc_x64_dll\mswud;$(WXWIDGETS_64BIT_DEBUG)\include;$(SFML_64BIT)\include;$(LIBXML2_64BIT)\include\libxml2;.</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;_UNICODE;WXUSINGDLL;_WINDOWS;NOPCH;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<AdditionalDependencies>wxmsw30ud_core.lib;wxmsw30ud_html.lib;wxbase30ud.lib;wxmsw30ud_adv.lib;libcurl.lib;libxml2.dll.a;sfml-audio.lib;sfml-system.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;security.lib;cryptui.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>vc_mswuddll_x64\xestiaab_debug.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>$(SFML_64BIT)\lib;$(LIBXML2_64BIT)\lib;$(CURL_64BIT)\builds\libcurl-vc-x64-release-dll-zlib-static-ipv6-sspi-winssl\lib;$(WXWIDGETS_64BIT_DEBUG)\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(SFML_64BIT)\lib;$(LIBXML2_64BIT)\lib;$(CURL_64BIT)\builds\\libcurl-vc-x64-release-dll-zlib-dll-ipv6-sspi-winssl\lib;$(WXWIDGETS_64BIT_DEBUG)\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>vc_mswuddll_x64\xestiaab_debug.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<ClCompile Include="..\..\source\frmNewAccount-CardDAV2.cpp">
<Filter>Resource Files\Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\source\contacteditor\cdo\ContactDataObject-Save.cpp">
+ <Filter>Resource Files\Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="xestiaab.rc">
#if defined(__APPLE__)
#elif defined(__WIN32__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
+
+ if (ModifiedCertificateData == false) {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
+
#else
bool UsingSSLBypass = false;
#if defined(__APPLE__)
#elif defined(__WIN32__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
+
+ if (ModifiedCertificateData == FALSE) {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
+
#else
bool UsingSSLBypass = false;
#if defined(__APPLE__)
#elif defined(__WIN32__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
+
+ if (ModifiedCertificateData == false) {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
+
#else
bool UsingSSLBypass = false;
#if defined(__APPLE__)
#elif defined(__WIN32__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
+
+ if (ModifiedCertificateData == false) {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
+
#else
bool UsingSSLBypass = false;
using namespace std;
+CardDAV2::CardDAV2(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL){
+
+ this->ServerAddress = ServerAddress;
+ this->ServerPort = ServerPort;
+ this->ServerUser = ServerUser;
+ this->ServerPass = ServerPass;
+ this->ServerSSL = ServerSSL;
+
+ TestMode = true;
+ this->SetupConnectionObject();
+
+}
+
+CardDAV2::CardDAV2(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL, string ServerPrefix, string ServerAccount){
+
+ this->ServerAddress = ServerAddress;
+ this->ServerPort = ServerPort;
+ this->ServerUser = ServerUser;
+ this->ServerPass = ServerPass;
+ this->ServerSSL = ServerSSL;
+ this->ServerPrefix = ServerPrefix;
+ this->ServerAccount = ServerAccount;
+
+
+ TestMode = false;
+ this->SetupConnectionObject();
+
+}
+
size_t CardDAV2::WritebackFunc(char *ptr, size_t size, size_t nmemb, void *stream){
-
- return static_cast<CardDAV2*>(stream)->WritebackFuncImplementation(ptr, size, nmemb, stream);
+
+ return static_cast<CardDAV2PassObject*>(stream)->CardDAV2Object->WritebackFuncImplementation(ptr, size, nmemb, stream);
}
-
+
size_t CardDAV2::WritebackFuncImplementation(char *ptr, size_t size, size_t nmemb, void *stream){
// Writeback function for the CardDAV object.
- string *data = static_cast<string*>(stream);
- data->append(ptr);
+ CardDAV2PassObject *data = static_cast<CardDAV2PassObject*>(stream);
+ data->DataSetting->append(ptr);
// Get the SSL engine pointer and trust if required on certain operating systems.
-
- if (ServerSSL){
-
+
+ if (data->ServerUsingSSL == true) {
+
#if defined(__APPLE__)
-
+
const struct curl_tlssessioninfo *TLSInfo;
CURLcode TLSCode;
CURL *Connection = GetConnectionObject();
TLSCode = curl_easy_getinfo(Connection, CURLINFO_TLS_SSL_PTR, &TLSInfo);
-
- if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){
+
+ if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK) {
SSLCopyPeerTrust((SSLContext*)TLSInfo->internals, &SecTrustObject);
}
-
+
#elif defined(__WIN32__)
const struct curl_tlssessioninfo *TLSInfo;
CURLcode TLSCode;
- TLSCode = curl_easy_getinfo(ConnectionSession, CURLINFO_TLS_SSL_PTR, &TLSInfo);
+ TLSCode = curl_easy_getinfo(data->ConnectionSessionObject, CURLINFO_TLS_SSL_PTR, &TLSInfo);
- if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){
+ if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK) {
// Free the previous certificate data.
- CertFreeCertificateContext(CertificateData);
+ //CertFreeCertificateContext(CertificateData);
+
+ PCCERT_CONTEXT CertificateData;
PCtxtHandle SSLHandle = (PCtxtHandle)TLSInfo->internals;
SECURITY_STATUS GetData = QueryContextAttributes(SSLHandle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &CertificateData);
+ data->SSLContext = CertificateData;
+
}
#endif
}
-
+
return size * nmemb;
}
+void CardDAV2::SetCertificateData() {
+
+}
+
CardDAV2::~CardDAV2(){
curl_easy_cleanup(ConnectionSession);
#if defined(__WIN32__)
- CertFreeCertificateContext(CertificateData);
+ if (CertificateData != nullptr) {
+
+ CertFreeCertificateContext(CertificateData);
+
+ }
#endif
}
-void CardDAV2::BypassSSLVerification(bool EnableBypass){
+#endif
+
+void CardDAV2::BypassSSLVerification(bool EnableBypass) {
EnableSSLBypass = EnableBypass;
SSLSelfSigned = EnableBypass;
}
-#endif
-
void CardDAV2::SetupConnectionObject(){
ConnectionSession = curl_easy_init();
}
} else {
SessionResult = curl_easy_perform(ConnectionSession);
}
-
+
switch(SessionResult){
case CURLE_OK:
case CURLE_HTTP_RETURNED_ERROR:
break;
};
+ // Set the certificate data (if required).
+
+#if defined(__WIN32__)
+
+ if (ServerSSL) {
+
+ CertificateData = PageHeaderObject.SSLContext;
+
+ }
+
+#endif
+
// Check if an error occured before continuing.
// Check if authentication was successful.
string ServerAddressURL = "http://" + ServerAddress + ":" + to_string(ServerPort) + "/";
string UsernamePassword = ServerUser + ":" + ServerPass;
-
+
+ PageDataObject.CardDAV2Object = this;
+ PageDataObject.ConnectionSessionObject = ConnectionSession;
+ PageDataObject.DataSetting = &PageData;
+ PageDataObject.ServerUsingSSL = false;
+
+ PageHeaderObject.CardDAV2Object = this;
+ PageHeaderObject.ConnectionSessionObject = ConnectionSession;
+ PageHeaderObject.DataSetting = &PageHeader;
+ PageHeaderObject.ServerUsingSSL = false;
+
curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddress.c_str());
curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 1L);
- curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+ curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);
curl_easy_setopt(ConnectionSession, CURLOPT_TIMEOUT, 60);
curl_easy_setopt(ConnectionSession, CURLOPT_FAILONERROR, true);
curl_easy_setopt(ConnectionSession, CURLOPT_USERAGENT, XSDAB_USERAGENT);
curl_easy_setopt(ConnectionSession, CURLOPT_WRITEFUNCTION, CardDAV2::WritebackFunc);
- curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageData);
- curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeader);
+ curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageDataObject);
+ curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeaderObject);
curl_easy_setopt(ConnectionSession, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr);
curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr);
curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, 0L);
-
+
if (DoAuthentication == true){
curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str());
} else {
- curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, ":");
+ curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, NULL);
}
}
string ServerAddressURL = "https://" + ServerAddress + ":" + to_string(ServerPort) + "/";
string UsernamePassword = ServerUser + ":" + ServerPass;
-
+
+ PageDataObject.CardDAV2Object = this;
+ PageDataObject.ConnectionSessionObject = ConnectionSession;
+ PageDataObject.DataSetting = &PageData;
+ PageDataObject.ServerUsingSSL = true;
+
+ PageHeaderObject.CardDAV2Object = this;
+ PageHeaderObject.ConnectionSessionObject = ConnectionSession;
+ PageHeaderObject.DataSetting = &PageHeader;
+ PageHeaderObject.ServerUsingSSL = true;
+
curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 1L);
- curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+ curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);
curl_easy_setopt(ConnectionSession, CURLOPT_TIMEOUT, 60);
curl_easy_setopt(ConnectionSession, CURLOPT_FAILONERROR, true);
curl_easy_setopt(ConnectionSession, CURLOPT_USERAGENT, XSDAB_USERAGENT);
curl_easy_setopt(ConnectionSession, CURLOPT_WRITEFUNCTION, CardDAV2::WritebackFunc);
- curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageData);
- curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeader);
+ curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageDataObject);
+ curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeaderObject);
curl_easy_setopt(ConnectionSession, CURLOPT_ERRORBUFFER, SessionErrorBuffer);
curl_easy_setopt(ConnectionSession, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(ConnectionSession, CURLOPT_CERTINFO, 1);
curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr);
curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr);
curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, 0L);
-
+
if (DoAuthentication == true){
curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str());
} else {
- curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, ":");
+ curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, NULL);
}
-#if !defined(__WIN32__)
+#if !defined(__APPLE__)
if (EnableSSLBypass == true){
curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYHOST, 0);
TaskCompleted = false;
ErrorMessage = "";
SessionErrorBuffer[0] = '\0';
+ SessionResult = CURLE_OK;
PageData = "";
PageHeader = "";
if (HeaderList != nullptr){
public:
- using ConnectionObject::ConnectionObject;
+ CardDAV2(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
+ CardDAV2(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
// Destructor.
bool IsSelfSigned();
std::string GetErrorMessage();
- void BypassSSLVerification(bool EnableBypass);
-
#if defined(__APPLE__)
#elif defined(__WIN32__)
SSLCertCollectionString BuildSSLCollection();
#endif
+
+ void BypassSSLVerification(bool EnableBypass);
+ struct CardDAV2PassObject {
+ CardDAV2 *CardDAV2Object = nullptr;
+ std::string *DataSetting = nullptr;
+ bool ServerUsingSSL = false;
+ CURL *ConnectionSessionObject = nullptr;
+#if defined(__APPLE__)
+#elif defined(__WIN32__)
+ PCCERT_CONTEXT SSLContext = nullptr;
+#endif
+ };
+
protected:
private:
std::string PageHeader;
char SessionErrorBuffer[CURL_ERROR_SIZE];
+ CardDAV2PassObject PageDataObject;
+ CardDAV2PassObject PageHeaderObject;
+
static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, void *stream);
size_t WritebackFuncImplementation(char *ptr, size_t size, size_t nmemb, void *stream);
std::string GetAddressBookHomeURI();
std::string GetDefaultAddressBookURI();
void ProcessContactData(COContactList *ContactList);
-
+
#if defined(__APPLE__)
#elif defined(__WIN32__)
- PCCERT_CONTEXT CertificateData;
+ PCCERT_CONTEXT CertificateData = nullptr;
#else
- bool EnableSSLBypass = false;
#endif
+ void SetCertificateData();
+
+ bool EnableSSLBypass = false;
+
};
#endif
\ No newline at end of file
continue;
}
- SettingLine = iter->first + wxT("|") + iter->second + wxT("|") + IterwxS->second;
+ wxString ServerETag = "";
+
+ if (IterwxS == FilenameETagOriginal.end()) {
+
+ ServerETag = "";
+
+ } else {
+
+ ServerETag = IterwxS->second;
+
+ }
+
+ SettingLine = iter->first + wxT("|") + iter->second + wxT("|") + ServerETag;
ETagDBFile.InsertLine(SettingLine, LineSeek);
using namespace std;
-ConnectionObject::ConnectionObject(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL) :
+/*ConnectionObject::ConnectionObject(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL) :
ServerAddress(ServerAddress), ServerPort(ServerPort), ServerUser(ServerUser), ServerPass(ServerPass), ServerSSL(ServerSSL){
TestMode = true;
TestMode = false;
this->SetupConnectionObject();
-}
+}*/
COCONNECT_SSLFAIL,
COCONNECT_INVALID,
COCONNECT_TIMEOUT,
- COCONNECT_AUTHFAIL
+ COCONNECT_AUTHFAIL,
+ COCONNECT_NOCONNECTION,
};
enum CORequestResult {
COREQUEST_OK,
COREQUEST_ERROR_NOTCONNECTED,
COREQUEST_ERROR_SERVER,
+ COREQUEST_NOCONNECTION,
};
enum COSSLVerified {
};
struct COServerResponse {
- CORequestResult RequestResult;
- std::string EntityTag;
- int SessionCode;
- int ResultCode;
- std::string ResultMessage;
+ CORequestResult RequestResult = COREQUEST_NOCONNECTION;
+ std::string EntityTag = "";
+ int SessionCode = 0;
+ int ResultCode = 0;
+ std::string ResultMessage = "";
};
struct COContactData {
- std::string Location;
- std::string Data;
+ std::string Location = "";
+ std::string Data = "";
COContactStatus Status = COCS_UNKNOWN;
};
class ConnectionObject{
public:
- ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
- ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
+ //ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
+ //ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
// Virtual functions to be setup by the inheriting classes.
- virtual void SetupConnectionObject() = 0;
- //virtual ~ConnectionObject() {};
+ virtual void SetupConnectionObject() {};
- virtual bool IsTaskCompleted() = 0;
+ virtual bool IsTaskCompleted() { return false; };
- virtual COConnectResult Connect(bool DoAuthentication) = 0;
- virtual void BypassSSLVerification(bool EnableBypass) = 0;
+ virtual COConnectResult Connect(bool DoAuthentication) { COConnectResult x; return x; };
+ virtual void BypassSSLVerification(bool EnableBypass) {};
- virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) = 0;
- virtual COServerResponse AddContact(std::string Location, std::string Data) = 0;
- virtual COServerResponse EditContact(std::string Location, std::string Data) = 0;
- virtual COServerResponse DeleteContact(std::string Location) = 0;
- virtual COServerResponse GetServerEntityTagValue(std::string Location) = 0;
- virtual COServerResponse GetContact(std::string Location, std::string *PageData) = 0;
- virtual COContactList GetContactList(std::string SyncToken) = 0;
+ virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) { COServerResponse x; return x; };
+ virtual COServerResponse AddContact(std::string Location, std::string Data) { COServerResponse x; return x; };
+ virtual COServerResponse EditContact(std::string Location, std::string Data) { COServerResponse x; return x; };
+ virtual COServerResponse DeleteContact(std::string Location) { COServerResponse x; return x; };
+ virtual COServerResponse GetServerEntityTagValue(std::string Location) { COServerResponse x; return x; };
+ virtual COServerResponse GetContact(std::string Location, std::string *PageData) { COServerResponse x; return x; };
+ virtual COContactList GetContactList(std::string SyncToken) { COContactList x; return x; };
- virtual bool CanDoProcessing() = 0;
- virtual bool CanDoSSL() = 0;
- virtual COSSLVerified SSLVerify() = 0;
- virtual bool AbleToLogin() = 0;
- virtual bool HasValidResponse() = 0;
- virtual bool IsSelfSigned() = 0;
- virtual std::string GetErrorMessage() = 0;
+ virtual bool CanDoProcessing() { return false; };
+ virtual bool CanDoSSL() { return false; };
+ virtual COSSLVerified SSLVerify() { COSSLVerified x; return x; };
+ virtual bool AbleToLogin() { return false; };
+ virtual bool HasValidResponse() { return false; };
+ virtual bool IsSelfSigned() { return false; };
+ virtual std::string GetErrorMessage() { return ""; };
// OS specific functions.
#if defined(__APPLE__)
#elif defined(__WIN32__)
- virtual PCCERT_CONTEXT BuildSSLCollection() = 0;
+ virtual PCCERT_CONTEXT BuildSSLCollection() { return nullptr; };
#else
- virtual SSLCertCollectionString BuildSSLCollection() = 0;
+ virtual SSLCertCollectionString BuildSSLCollection() {};
#endif
FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
}
-
+
if (AnniversaryYear == 0){
FinalAnniversaryYear = wxT("--");
if (TestConnection.SSLVerify() == COSSL_UNABLETOVERIFY){
#if defined(__APPLE__)
#elif defined(__WIN32__)
+
+ TestConnection.BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = TestConnection.Connect(false);
+
+ TestConnection.BypassSSLVerification(false);
+
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&TestConnection, (HWND)this->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ return;
+ }
+
+ if (ModifiedCertificateData == false) {
+ wxMessageBox(_("An invalid certificate was received from the server."), _("Invalid certificate"));
+ return;
+ } else {
+ TestConnection.BypassSSLVerification(true);
+ COConnectResult TestConnectionResult = TestConnection.Connect(true);
+ TestConnection.BypassSSLVerification(false);
+ }
+
#else
// Connect again and fetch SSL certificate information.
}
// Get the server prefix if the connection was successful.
-
+
if (TestConnectionResult == COCONNECT_OK){
+ COConnectResult TestConnectionResult = TestConnection.Connect(true);
+
if (UsingSSLBypass == true){
TestConnection.BypassSSLVerification(true);
}
#if defined(__APPLE__)
#elif defined(__WIN32__)
+ TestConnection.BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = TestConnection.Connect(false);
+
+ TestConnection.BypassSSLVerification(false);
+
BOOL ModifiedCertificateData = false;
CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateDialogData = BuildCertificateData(&TestConnection, (HWND)this->GetHandle());
wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
}
- if (ModifiedCertificateData = false){
+ if (ModifiedCertificateData == false){
lblServerConnResult->SetLabel(_("Failed"));
lblServerResponse->SetLabel(_("Not applicable"));
lblServerSSLResult->SetLabel(_("Used"));
lblServerSSLValid->SetLabel(_("No"));
lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + TestConnection.GetErrorMessage());
+ btnPrevious->Enable(true);
return;
}
#endif
}
+ TestConnectionResult = TestConnection.Connect(true);
+
// Get the server prefix if the connection was successful.
if (TestConnectionResult == COCONNECT_OK){